@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
@@ -1,48 +1,140 @@
1
1
  import { Result } from "@webiny/feature/api";
2
- import { KeyNotFoundError, KeyValueStorageError } from "./errors.js";
3
- export interface IKeyValueRecord {
2
+ import { KeyNotFoundError } from "./errors.js";
3
+ import { KeyValueStorageError } from "./errors.js";
4
+ import { KeyValueInvalidCursorError } from "./errors.js";
5
+ import { KeyValueInvalidCollectionError } from "./errors.js";
6
+ import { KeyValueKeyTooLongError } from "./errors.js";
7
+ import { KeyValueConditionFailedError } from "./errors.js";
8
+ import { KeyValueInvalidConditionError } from "./errors.js";
9
+ export interface IKeyValueRecord<T = any> {
4
10
  key: string;
5
- value: any;
11
+ value: T;
12
+ }
13
+ /**
14
+ * A record is listable only as a member of a collection, and only when the write that stored it
15
+ * named that collection. A write without `collection` takes the record out of the one it was in,
16
+ * since every write replaces the whole record.
17
+ *
18
+ * A collection name and the key of a record in a collection are each limited to 1000 UTF-8 bytes.
19
+ *
20
+ * Each collection is stored apart from every other, so keep one to records that are listed
21
+ * together, such as one user's chats. A collection spanning a whole tenant, like every uploaded
22
+ * file, puts all of them in one place that only ever grows.
23
+ */
24
+ export interface IKeyValueCollectionOptions {
25
+ collection?: string;
26
+ }
27
+ export type KeyValueComparable = string | number | boolean;
28
+ /**
29
+ * Makes a write conditional. The store checks the record and writes it as one step, so two callers
30
+ * racing for the same key cannot both succeed. A write whose condition does not hold changes nothing
31
+ * and fails with `KeyValueStore/ConditionFailed`.
32
+ *
33
+ * An expired record counts as absent, as for `get`. `equals` matches a live record whose whole value
34
+ * is that same string, number or boolean: DynamoDB cannot compare whole maps in a condition, so
35
+ * objects are not accepted. A condition is one of the two, never both.
36
+ */
37
+ export type IKeyValueWriteCondition = {
38
+ /** `false`: write only when there is no live record. `true`: only when there is one. */
39
+ exists: boolean;
40
+ equals?: never;
41
+ } | {
42
+ /** Write only when the live record's value equals this. */
43
+ equals: KeyValueComparable;
44
+ exists?: never;
45
+ };
46
+ /** Deleting where there is no live record has nothing to check, so `exists` can only be `true`. */
47
+ export type IKeyValueDeleteCondition = {
48
+ /** Delete only when there is a live record. */
49
+ exists: true;
50
+ equals?: never;
51
+ } | {
52
+ /** Delete only when the live record's value equals this. */
53
+ equals: KeyValueComparable;
54
+ exists?: never;
55
+ };
56
+ export interface IKeyValueWriteConditionOptions {
57
+ condition?: IKeyValueWriteCondition;
58
+ }
59
+ export interface IKeyValueDeleteOptions {
60
+ condition?: IKeyValueDeleteCondition;
61
+ }
62
+ export interface IKeyValueListParams {
63
+ collection: string;
64
+ /** Most records on one page. Defaults to 100, capped at 1000. */
65
+ limit?: number;
66
+ /** The `cursor` of the previous page. Omit it for the first page. */
67
+ cursor?: string;
68
+ /** Descending key order. A cursor continues in the order of the page that returned it. */
69
+ reverse?: boolean;
70
+ }
71
+ export interface IKeyValueListResult<T = any> {
72
+ items: IKeyValueRecord<T>[];
73
+ /**
74
+ * Pass it back as `cursor` for the next page; `null` when there is none. Opaque: it encodes
75
+ * where the page stopped, not a page number, so records written meanwhile are not skipped.
76
+ */
77
+ cursor: string | null;
6
78
  }
7
79
  export interface IGlobalKeyValueStoreOptions {
8
80
  scope?: string;
9
81
  expiresAt?: Date;
10
82
  }
83
+ export interface IGlobalKeyValueSetOptions extends IGlobalKeyValueStoreOptions, IKeyValueCollectionOptions, IKeyValueWriteConditionOptions {
84
+ }
85
+ export interface IGlobalKeyValueDeleteOptions extends IKeyValueDeleteOptions {
86
+ scope?: string;
87
+ }
88
+ export interface IGlobalKeyValueListParams extends IKeyValueListParams {
89
+ scope?: string;
90
+ }
11
91
  export interface IGlobalKeyValueStore {
12
92
  get<T = unknown>(key: string, options?: IGlobalKeyValueStoreOptions): Promise<Result<T, KeyValueStoreRepository.Error>>;
13
- set(key: string, value: any, options?: IGlobalKeyValueStoreOptions): Promise<Result<void, KeyValueStoreRepository.Error>>;
14
- delete(key: string, options?: IGlobalKeyValueStoreOptions): Promise<Result<void, KeyValueStoreRepository.Error>>;
93
+ set(key: string, value: any, options?: IGlobalKeyValueSetOptions): Promise<Result<void, KeyValueStoreRepository.Error>>;
94
+ delete(key: string, options?: IGlobalKeyValueDeleteOptions): Promise<Result<void, KeyValueStoreRepository.Error>>;
95
+ /**
96
+ * One page of a collection in the scope, ordered by key. Expired records are left out, so a
97
+ * page can hold fewer than `limit` records and still have a next one.
98
+ */
99
+ list<T = unknown>(params: IGlobalKeyValueListParams): Promise<Result<IKeyValueListResult<T>, KeyValueStoreRepository.Error>>;
15
100
  }
16
101
  /** Global (non-tenant-scoped) key-value store. */
17
102
  export declare const GlobalKeyValueStore: import("@webiny/di").Abstraction<IGlobalKeyValueStore>;
18
103
  export declare namespace GlobalKeyValueStore {
19
104
  type Interface = IGlobalKeyValueStore;
20
- type KeyValueRecord = IKeyValueRecord;
105
+ type KeyValueRecord<T = any> = IKeyValueRecord<T>;
106
+ type ListResult<T = any> = IKeyValueListResult<T>;
21
107
  type Error = KeyValueStoreRepository.Error;
22
108
  }
109
+ export interface IKeyValueSetOptions extends IKeyValueCollectionOptions, IKeyValueWriteConditionOptions {
110
+ }
23
111
  export interface IKeyValueStore {
24
112
  get<T = unknown>(key: string): Promise<Result<T, KeyValueStoreRepository.Error>>;
25
- set(key: string, value: any): Promise<Result<void, KeyValueStoreRepository.Error>>;
26
- delete(key: string): Promise<Result<void, KeyValueStoreRepository.Error>>;
113
+ set(key: string, value: any, options?: IKeyValueSetOptions): Promise<Result<void, KeyValueStoreRepository.Error>>;
114
+ delete(key: string, options?: IKeyValueDeleteOptions): Promise<Result<void, KeyValueStoreRepository.Error>>;
115
+ /** One page of a collection of the current tenant, ordered by key. */
116
+ list<T = unknown>(params: IKeyValueListParams): Promise<Result<IKeyValueListResult<T>, KeyValueStoreRepository.Error>>;
27
117
  }
28
118
  /** Tenant-scoped key-value store. */
29
119
  export declare const KeyValueStore: import("@webiny/di").Abstraction<IKeyValueStore>;
30
120
  export declare namespace KeyValueStore {
31
121
  type Interface = IKeyValueStore;
32
- type KeyValueRecord = IKeyValueRecord;
122
+ type KeyValueRecord<T = any> = IKeyValueRecord<T>;
123
+ type ListResult<T = any> = IKeyValueListResult<T>;
33
124
  type Error = KeyValueStoreRepository.Error;
34
125
  }
35
126
  export interface IKeyValueStoreRepositoryErrors {
36
- base: KeyNotFoundError | KeyValueStorageError;
127
+ base: KeyNotFoundError | KeyValueStorageError | KeyValueInvalidCursorError | KeyValueInvalidCollectionError | KeyValueKeyTooLongError | KeyValueConditionFailedError | KeyValueInvalidConditionError;
37
128
  }
38
129
  type RepositoryError = IKeyValueStoreRepositoryErrors[keyof IKeyValueStoreRepositoryErrors];
39
- export interface IKeyValueStoreSetOptions {
130
+ export interface IKeyValueStoreSetOptions extends IKeyValueCollectionOptions, IKeyValueWriteConditionOptions {
40
131
  expiresAt?: Date;
41
132
  }
42
133
  export interface IKeyValueStoreRepository {
43
134
  get<T = unknown>(key: string, scope: string): Promise<Result<T, RepositoryError>>;
44
135
  set(key: string, value: any, scope: string, options?: IKeyValueStoreSetOptions): Promise<Result<void, RepositoryError>>;
45
- delete(key: string, scope: string): Promise<Result<void, RepositoryError>>;
136
+ delete(key: string, scope: string, options?: IKeyValueDeleteOptions): Promise<Result<void, RepositoryError>>;
137
+ list<T = unknown>(scope: string, params: IKeyValueListParams): Promise<Result<IKeyValueListResult<T>, RepositoryError>>;
46
138
  }
47
139
  /** Persist and retrieve key-value pairs. */
48
140
  export declare const KeyValueStoreRepository: import("@webiny/di").Abstraction<IKeyValueStoreRepository>;
@@ -55,8 +147,34 @@ export interface IKeyValueStorageOperations {
55
147
  key: string;
56
148
  value: any;
57
149
  } | null>;
58
- set(key: string, value: any, scope: string, options?: IKeyValueStoreSetOptions): Promise<void>;
59
- delete(key: string, scope: string): Promise<void>;
150
+ /**
151
+ * Puts the record in `options.collection`, or in none when it is not given. With a condition in
152
+ * `options`, checks it and writes as one atomic step; resolves to whether it wrote.
153
+ */
154
+ set(key: string, value: any, scope: string, options?: IKeyValueStoreSetOptions): Promise<boolean>;
155
+ /** With a condition, checks it and deletes as one atomic step; resolves to whether it deleted. */
156
+ delete(key: string, scope: string, options?: IKeyValueDeleteOptions): Promise<boolean>;
157
+ /**
158
+ * Up to `limit` members of `collection` in `scope` past `after`, ordered by the key's UTF-8
159
+ * bytes (descending when `reverse`), expired ones left out.
160
+ */
161
+ list(params: IKeyValueStorageListParams): Promise<IKeyValueStorageListResult>;
162
+ }
163
+ export interface IKeyValueStorageListParams {
164
+ collection: string;
165
+ scope: string;
166
+ limit: number;
167
+ reverse: boolean;
168
+ /** Only keys past this one, in the order of the listing. */
169
+ after?: string;
170
+ }
171
+ export interface IKeyValueStorageListResult {
172
+ items: IKeyValueRecord[];
173
+ /**
174
+ * The last key this page read, expired records included, when more may follow; otherwise
175
+ * `null`. The next page starts after it.
176
+ */
177
+ lastKey: string | null;
60
178
  }
61
179
  /** Storage operations for key-value persistence. */
62
180
  export declare const KeyValueStorageOperations: import("@webiny/di").Abstraction<IKeyValueStorageOperations>;
@@ -1 +1 @@
1
- {"version":3,"file":"features/keyValueStore/abstractions.js","sources":["../../../src/features/keyValueStore/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { KeyNotFoundError, KeyValueStorageError } from \"./errors.js\";\n\nexport interface IKeyValueRecord {\n key: string;\n value: any;\n}\n\n// GlobalKeyValueStore - Non-tenant-aware service\nexport interface IGlobalKeyValueStoreOptions {\n scope?: string;\n expiresAt?: Date;\n}\n\nexport interface IGlobalKeyValueStore {\n get<T = unknown>(\n key: string,\n options?: IGlobalKeyValueStoreOptions\n ): Promise<Result<T, KeyValueStoreRepository.Error>>;\n set(\n key: string,\n value: any,\n options?: IGlobalKeyValueStoreOptions\n ): Promise<Result<void, KeyValueStoreRepository.Error>>;\n delete(\n key: string,\n options?: IGlobalKeyValueStoreOptions\n ): Promise<Result<void, KeyValueStoreRepository.Error>>;\n}\n\n/** Global (non-tenant-scoped) key-value store. */\nexport const GlobalKeyValueStore = createAbstraction<IGlobalKeyValueStore>(\"GlobalKeyValueStore\");\n\nexport namespace GlobalKeyValueStore {\n export type Interface = IGlobalKeyValueStore;\n export type KeyValueRecord = IKeyValueRecord;\n export type Error = KeyValueStoreRepository.Error;\n}\n\n// KeyValueStore - Tenant-aware service\nexport interface IKeyValueStore {\n get<T = unknown>(key: string): Promise<Result<T, KeyValueStoreRepository.Error>>;\n set(key: string, value: any): Promise<Result<void, KeyValueStoreRepository.Error>>;\n delete(key: string): Promise<Result<void, KeyValueStoreRepository.Error>>;\n}\n\n/** Tenant-scoped key-value store. */\nexport const KeyValueStore = createAbstraction<IKeyValueStore>(\"KeyValueStore\");\n\nexport namespace KeyValueStore {\n export type Interface = IKeyValueStore;\n export type KeyValueRecord = IKeyValueRecord;\n export type Error = KeyValueStoreRepository.Error;\n}\n\n// Repository\n\nexport interface IKeyValueStoreRepositoryErrors {\n base: KeyNotFoundError | KeyValueStorageError;\n}\n\ntype RepositoryError = IKeyValueStoreRepositoryErrors[keyof IKeyValueStoreRepositoryErrors];\n\nexport interface IKeyValueStoreSetOptions {\n expiresAt?: Date;\n}\n\nexport interface IKeyValueStoreRepository {\n get<T = unknown>(key: string, scope: string): Promise<Result<T, RepositoryError>>;\n set(\n key: string,\n value: any,\n scope: string,\n options?: IKeyValueStoreSetOptions\n ): Promise<Result<void, RepositoryError>>;\n delete(key: string, scope: string): Promise<Result<void, RepositoryError>>;\n}\n\n/** Persist and retrieve key-value pairs. */\nexport const KeyValueStoreRepository =\n createAbstraction<IKeyValueStoreRepository>(\"KeyValueStoreRepository\");\n\nexport namespace KeyValueStoreRepository {\n export type Interface = IKeyValueStoreRepository;\n export type Error = RepositoryError;\n}\n\n// Storage Operations\n\nexport interface IKeyValueStorageOperations {\n get(key: string, scope: string): Promise<{ key: string; value: any } | null>;\n set(key: string, value: any, scope: string, options?: IKeyValueStoreSetOptions): Promise<void>;\n delete(key: string, scope: string): Promise<void>;\n}\n\n/** Storage operations for key-value persistence. */\nexport const KeyValueStorageOperations = createAbstraction<IKeyValueStorageOperations>(\n \"KeyValueStorageOperations\"\n);\n\nexport namespace KeyValueStorageOperations {\n export type Interface = IKeyValueStorageOperations;\n}\n"],"names":["GlobalKeyValueStore","createAbstraction","KeyValueStore","KeyValueStoreRepository","KeyValueStorageOperations"],"mappings":";AAgCO,MAAMA,sBAAsBC,kBAAwC;AAgBpE,MAAMC,gBAAgBD,kBAAkC;AAgCxD,MAAME,0BACTF,kBAA4C;AAgBzC,MAAMG,4BAA4BH,kBACrC"}
1
+ {"version":3,"file":"features/keyValueStore/abstractions.js","sources":["../../../src/features/keyValueStore/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\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\nexport interface IKeyValueRecord<T = any> {\n key: string;\n value: T;\n}\n\n/**\n * A record is listable only as a member of a collection, and only when the write that stored it\n * named that collection. A write without `collection` takes the record out of the one it was in,\n * since every write replaces the whole record.\n *\n * A collection name and the key of a record in a collection are each limited to 1000 UTF-8 bytes.\n *\n * Each collection is stored apart from every other, so keep one to records that are listed\n * together, such as one user's chats. A collection spanning a whole tenant, like every uploaded\n * file, puts all of them in one place that only ever grows.\n */\nexport interface IKeyValueCollectionOptions {\n collection?: string;\n}\n\nexport type KeyValueComparable = string | number | boolean;\n\n/**\n * Makes a write conditional. The store checks the record and writes it as one step, so two callers\n * racing for the same key cannot both succeed. A write whose condition does not hold changes nothing\n * and fails with `KeyValueStore/ConditionFailed`.\n *\n * An expired record counts as absent, as for `get`. `equals` matches a live record whose whole value\n * is that same string, number or boolean: DynamoDB cannot compare whole maps in a condition, so\n * objects are not accepted. A condition is one of the two, never both.\n */\nexport type IKeyValueWriteCondition =\n | {\n /** `false`: write only when there is no live record. `true`: only when there is one. */\n exists: boolean;\n equals?: never;\n }\n | {\n /** Write only when the live record's value equals this. */\n equals: KeyValueComparable;\n exists?: never;\n };\n\n/** Deleting where there is no live record has nothing to check, so `exists` can only be `true`. */\nexport type IKeyValueDeleteCondition =\n | {\n /** Delete only when there is a live record. */\n exists: true;\n equals?: never;\n }\n | {\n /** Delete only when the live record's value equals this. */\n equals: KeyValueComparable;\n exists?: never;\n };\n\nexport interface IKeyValueWriteConditionOptions {\n condition?: IKeyValueWriteCondition;\n}\n\nexport interface IKeyValueDeleteOptions {\n condition?: IKeyValueDeleteCondition;\n}\n\nexport interface IKeyValueListParams {\n collection: string;\n /** Most records on one page. Defaults to 100, capped at 1000. */\n limit?: number;\n /** The `cursor` of the previous page. Omit it for the first page. */\n cursor?: string;\n /** Descending key order. A cursor continues in the order of the page that returned it. */\n reverse?: boolean;\n}\n\nexport interface IKeyValueListResult<T = any> {\n items: IKeyValueRecord<T>[];\n /**\n * Pass it back as `cursor` for the next page; `null` when there is none. Opaque: it encodes\n * where the page stopped, not a page number, so records written meanwhile are not skipped.\n */\n cursor: string | null;\n}\n\n// GlobalKeyValueStore - Non-tenant-aware service\nexport interface IGlobalKeyValueStoreOptions {\n scope?: string;\n expiresAt?: Date;\n}\n\nexport interface IGlobalKeyValueSetOptions\n extends\n IGlobalKeyValueStoreOptions,\n IKeyValueCollectionOptions,\n IKeyValueWriteConditionOptions {}\n\nexport interface IGlobalKeyValueDeleteOptions extends IKeyValueDeleteOptions {\n scope?: string;\n}\n\nexport interface IGlobalKeyValueListParams extends IKeyValueListParams {\n scope?: string;\n}\n\nexport interface IGlobalKeyValueStore {\n get<T = unknown>(\n key: string,\n options?: IGlobalKeyValueStoreOptions\n ): Promise<Result<T, KeyValueStoreRepository.Error>>;\n set(\n key: string,\n value: any,\n options?: IGlobalKeyValueSetOptions\n ): Promise<Result<void, KeyValueStoreRepository.Error>>;\n delete(\n key: string,\n options?: IGlobalKeyValueDeleteOptions\n ): Promise<Result<void, KeyValueStoreRepository.Error>>;\n /**\n * One page of a collection in the scope, ordered by key. Expired records are left out, so a\n * page can hold fewer than `limit` records and still have a next one.\n */\n list<T = unknown>(\n params: IGlobalKeyValueListParams\n ): Promise<Result<IKeyValueListResult<T>, KeyValueStoreRepository.Error>>;\n}\n\n/** Global (non-tenant-scoped) key-value store. */\nexport const GlobalKeyValueStore = createAbstraction<IGlobalKeyValueStore>(\"GlobalKeyValueStore\");\n\nexport namespace GlobalKeyValueStore {\n export type Interface = IGlobalKeyValueStore;\n export type KeyValueRecord<T = any> = IKeyValueRecord<T>;\n export type ListResult<T = any> = IKeyValueListResult<T>;\n export type Error = KeyValueStoreRepository.Error;\n}\n\n// KeyValueStore - Tenant-aware service\nexport interface IKeyValueSetOptions\n extends IKeyValueCollectionOptions, IKeyValueWriteConditionOptions {}\n\nexport interface IKeyValueStore {\n get<T = unknown>(key: string): Promise<Result<T, KeyValueStoreRepository.Error>>;\n set(\n key: string,\n value: any,\n options?: IKeyValueSetOptions\n ): Promise<Result<void, KeyValueStoreRepository.Error>>;\n delete(\n key: string,\n options?: IKeyValueDeleteOptions\n ): Promise<Result<void, KeyValueStoreRepository.Error>>;\n /** One page of a collection of the current tenant, ordered by key. */\n list<T = unknown>(\n params: IKeyValueListParams\n ): Promise<Result<IKeyValueListResult<T>, KeyValueStoreRepository.Error>>;\n}\n\n/** Tenant-scoped key-value store. */\nexport const KeyValueStore = createAbstraction<IKeyValueStore>(\"KeyValueStore\");\n\nexport namespace KeyValueStore {\n export type Interface = IKeyValueStore;\n export type KeyValueRecord<T = any> = IKeyValueRecord<T>;\n export type ListResult<T = any> = IKeyValueListResult<T>;\n export type Error = KeyValueStoreRepository.Error;\n}\n\n// Repository\n\nexport interface IKeyValueStoreRepositoryErrors {\n base:\n | KeyNotFoundError\n | KeyValueStorageError\n | KeyValueInvalidCursorError\n | KeyValueInvalidCollectionError\n | KeyValueKeyTooLongError\n | KeyValueConditionFailedError\n | KeyValueInvalidConditionError;\n}\n\ntype RepositoryError = IKeyValueStoreRepositoryErrors[keyof IKeyValueStoreRepositoryErrors];\n\nexport interface IKeyValueStoreSetOptions\n extends IKeyValueCollectionOptions, IKeyValueWriteConditionOptions {\n expiresAt?: Date;\n}\n\nexport interface IKeyValueStoreRepository {\n get<T = unknown>(key: string, scope: string): Promise<Result<T, RepositoryError>>;\n set(\n key: string,\n value: any,\n scope: string,\n options?: IKeyValueStoreSetOptions\n ): Promise<Result<void, RepositoryError>>;\n delete(\n key: string,\n scope: string,\n options?: IKeyValueDeleteOptions\n ): Promise<Result<void, RepositoryError>>;\n list<T = unknown>(\n scope: string,\n params: IKeyValueListParams\n ): Promise<Result<IKeyValueListResult<T>, RepositoryError>>;\n}\n\n/** Persist and retrieve key-value pairs. */\nexport const KeyValueStoreRepository =\n createAbstraction<IKeyValueStoreRepository>(\"KeyValueStoreRepository\");\n\nexport namespace KeyValueStoreRepository {\n export type Interface = IKeyValueStoreRepository;\n export type Error = RepositoryError;\n}\n\n// Storage Operations\n\nexport interface IKeyValueStorageOperations {\n get(key: string, scope: string): Promise<{ key: string; value: any } | null>;\n /**\n * Puts the record in `options.collection`, or in none when it is not given. With a condition in\n * `options`, checks it and writes as one atomic step; resolves to whether it wrote.\n */\n set(\n key: string,\n value: any,\n scope: string,\n options?: IKeyValueStoreSetOptions\n ): Promise<boolean>;\n /** With a condition, checks it and deletes as one atomic step; resolves to whether it deleted. */\n delete(key: string, scope: string, options?: IKeyValueDeleteOptions): Promise<boolean>;\n /**\n * Up to `limit` members of `collection` in `scope` past `after`, ordered by the key's UTF-8\n * bytes (descending when `reverse`), expired ones left out.\n */\n list(params: IKeyValueStorageListParams): Promise<IKeyValueStorageListResult>;\n}\n\nexport interface IKeyValueStorageListParams {\n collection: string;\n scope: string;\n limit: number;\n reverse: boolean;\n /** Only keys past this one, in the order of the listing. */\n after?: string;\n}\n\nexport interface IKeyValueStorageListResult {\n items: IKeyValueRecord[];\n /**\n * The last key this page read, expired records included, when more may follow; otherwise\n * `null`. The next page starts after it.\n */\n lastKey: string | null;\n}\n\n/** Storage operations for key-value persistence. */\nexport const KeyValueStorageOperations = createAbstraction<IKeyValueStorageOperations>(\n \"KeyValueStorageOperations\"\n);\n\nexport namespace KeyValueStorageOperations {\n export type Interface = IKeyValueStorageOperations;\n}\n"],"names":["GlobalKeyValueStore","createAbstraction","KeyValueStore","KeyValueStoreRepository","KeyValueStorageOperations"],"mappings":";AAyIO,MAAMA,sBAAsBC,kBAAwC;AA+BpE,MAAMC,gBAAgBD,kBAAkC;AAiDxD,MAAME,0BACTF,kBAA4C;AAiDzC,MAAMG,4BAA4BH,kBACrC"}
@@ -9,3 +9,32 @@ export declare class KeyValueStorageError extends BaseError {
9
9
  readonly code: "KeyValueStore/Persistence";
10
10
  constructor(error: Error);
11
11
  }
12
+ export declare class KeyValueInvalidCursorError extends BaseError<{
13
+ cursor: string;
14
+ }> {
15
+ readonly code: "KeyValueStore/InvalidCursor";
16
+ constructor(cursor: string);
17
+ }
18
+ export declare class KeyValueInvalidCollectionError extends BaseError<{
19
+ maxBytes: number;
20
+ }> {
21
+ readonly code: "KeyValueStore/InvalidCollection";
22
+ constructor(maxBytes: number);
23
+ }
24
+ export declare class KeyValueKeyTooLongError extends BaseError<{
25
+ key: string;
26
+ maxBytes: number;
27
+ }> {
28
+ readonly code: "KeyValueStore/KeyTooLong";
29
+ constructor(key: string, maxBytes: number);
30
+ }
31
+ export declare class KeyValueConditionFailedError extends BaseError<{
32
+ key: string;
33
+ }> {
34
+ readonly code: "KeyValueStore/ConditionFailed";
35
+ constructor(key: string);
36
+ }
37
+ export declare class KeyValueInvalidConditionError extends BaseError {
38
+ readonly code: "KeyValueStore/InvalidCondition";
39
+ constructor();
40
+ }
@@ -16,6 +16,54 @@ class KeyValueStorageError extends BaseError {
16
16
  }), this.code = "KeyValueStore/Persistence";
17
17
  }
18
18
  }
19
- export { KeyNotFoundError, KeyValueStorageError };
19
+ class KeyValueInvalidCursorError extends BaseError {
20
+ constructor(cursor){
21
+ super({
22
+ message: "The list cursor is not one this store returned.",
23
+ data: {
24
+ cursor
25
+ }
26
+ }), this.code = "KeyValueStore/InvalidCursor";
27
+ }
28
+ }
29
+ class KeyValueInvalidCollectionError extends BaseError {
30
+ constructor(maxBytes){
31
+ super({
32
+ message: `A collection name must be a non-empty string of at most ${maxBytes} bytes.`,
33
+ data: {
34
+ maxBytes
35
+ }
36
+ }), this.code = "KeyValueStore/InvalidCollection";
37
+ }
38
+ }
39
+ class KeyValueKeyTooLongError extends BaseError {
40
+ constructor(key, maxBytes){
41
+ super({
42
+ message: `A key in a collection must be at most ${maxBytes} bytes.`,
43
+ data: {
44
+ key,
45
+ maxBytes
46
+ }
47
+ }), this.code = "KeyValueStore/KeyTooLong";
48
+ }
49
+ }
50
+ class KeyValueConditionFailedError extends BaseError {
51
+ constructor(key){
52
+ super({
53
+ message: `The record "${key}" was not in the state the write required.`,
54
+ data: {
55
+ key
56
+ }
57
+ }), this.code = "KeyValueStore/ConditionFailed";
58
+ }
59
+ }
60
+ class KeyValueInvalidConditionError extends BaseError {
61
+ constructor(){
62
+ super({
63
+ message: "A condition is `exists` or `equals`, never both. `equals` takes a string, number or boolean, and a delete takes `exists` only as `true`."
64
+ }), this.code = "KeyValueStore/InvalidCondition";
65
+ }
66
+ }
67
+ export { KeyNotFoundError, KeyValueConditionFailedError, KeyValueInvalidCollectionError, KeyValueInvalidConditionError, KeyValueInvalidCursorError, KeyValueKeyTooLongError, KeyValueStorageError };
20
68
 
21
69
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"features/keyValueStore/errors.js","sources":["../../../src/features/keyValueStore/errors.ts"],"sourcesContent":["import { BaseError } from \"@webiny/feature/api\";\n\nexport class KeyNotFoundError extends BaseError<{ key: string }> {\n override readonly code = \"KeyValueStore/KeyNotFound\" as const;\n\n constructor(key: string) {\n super({\n message: `Key \"${key}\" was not found`,\n data: { key }\n });\n }\n}\n\nexport class KeyValueStorageError extends BaseError {\n override readonly code = \"KeyValueStore/Persistence\" as const;\n\n constructor(error: Error) {\n super({\n message: error.message\n });\n }\n}\n"],"names":["KeyNotFoundError","BaseError","key","KeyValueStorageError","error"],"mappings":";AAEO,MAAMA,yBAAyBC;IAGlC,YAAYC,GAAW,CAAE;QACrB,KAAK,CAAC;YACF,SAAS,CAAC,KAAK,EAAEA,IAAI,eAAe,CAAC;YACrC,MAAM;gBAAEA;YAAI;QAChB,SANc,IAAI,GAAG;IAOzB;AACJ;AAEO,MAAMC,6BAA6BF;IAGtC,YAAYG,KAAY,CAAE;QACtB,KAAK,CAAC;YACF,SAASA,MAAM,OAAO;QAC1B,SALc,IAAI,GAAG;IAMzB;AACJ"}
1
+ {"version":3,"file":"features/keyValueStore/errors.js","sources":["../../../src/features/keyValueStore/errors.ts"],"sourcesContent":["import { BaseError } from \"@webiny/feature/api\";\n\nexport class KeyNotFoundError extends BaseError<{ key: string }> {\n override readonly code = \"KeyValueStore/KeyNotFound\" as const;\n\n constructor(key: string) {\n super({\n message: `Key \"${key}\" was not found`,\n data: { key }\n });\n }\n}\n\nexport class KeyValueStorageError extends BaseError {\n override readonly code = \"KeyValueStore/Persistence\" as const;\n\n constructor(error: Error) {\n super({\n message: error.message\n });\n }\n}\n\nexport class KeyValueInvalidCursorError extends BaseError<{ cursor: string }> {\n override readonly code = \"KeyValueStore/InvalidCursor\" as const;\n\n constructor(cursor: string) {\n super({\n message: \"The list cursor is not one this store returned.\",\n data: { cursor }\n });\n }\n}\n\nexport class KeyValueInvalidCollectionError extends BaseError<{ maxBytes: number }> {\n override readonly code = \"KeyValueStore/InvalidCollection\" as const;\n\n constructor(maxBytes: number) {\n super({\n message: `A collection name must be a non-empty string of at most ${maxBytes} bytes.`,\n data: { maxBytes }\n });\n }\n}\n\nexport class KeyValueKeyTooLongError extends BaseError<{ key: string; maxBytes: number }> {\n override readonly code = \"KeyValueStore/KeyTooLong\" as const;\n\n constructor(key: string, maxBytes: number) {\n super({\n message: `A key in a collection must be at most ${maxBytes} bytes.`,\n data: { key, maxBytes }\n });\n }\n}\n\nexport class KeyValueConditionFailedError extends BaseError<{ key: string }> {\n override readonly code = \"KeyValueStore/ConditionFailed\" as const;\n\n constructor(key: string) {\n super({\n message: `The record \"${key}\" was not in the state the write required.`,\n data: { key }\n });\n }\n}\n\nexport class KeyValueInvalidConditionError extends BaseError {\n override readonly code = \"KeyValueStore/InvalidCondition\" as const;\n\n constructor() {\n super({\n message:\n \"A condition is `exists` or `equals`, never both. `equals` takes a string, number or boolean, and a delete takes `exists` only as `true`.\"\n });\n }\n}\n"],"names":["KeyNotFoundError","BaseError","key","KeyValueStorageError","error","KeyValueInvalidCursorError","cursor","KeyValueInvalidCollectionError","maxBytes","KeyValueKeyTooLongError","KeyValueConditionFailedError","KeyValueInvalidConditionError"],"mappings":";AAEO,MAAMA,yBAAyBC;IAGlC,YAAYC,GAAW,CAAE;QACrB,KAAK,CAAC;YACF,SAAS,CAAC,KAAK,EAAEA,IAAI,eAAe,CAAC;YACrC,MAAM;gBAAEA;YAAI;QAChB,SANc,IAAI,GAAG;IAOzB;AACJ;AAEO,MAAMC,6BAA6BF;IAGtC,YAAYG,KAAY,CAAE;QACtB,KAAK,CAAC;YACF,SAASA,MAAM,OAAO;QAC1B,SALc,IAAI,GAAG;IAMzB;AACJ;AAEO,MAAMC,mCAAmCJ;IAG5C,YAAYK,MAAc,CAAE;QACxB,KAAK,CAAC;YACF,SAAS;YACT,MAAM;gBAAEA;YAAO;QACnB,SANc,IAAI,GAAG;IAOzB;AACJ;AAEO,MAAMC,uCAAuCN;IAGhD,YAAYO,QAAgB,CAAE;QAC1B,KAAK,CAAC;YACF,SAAS,CAAC,wDAAwD,EAAEA,SAAS,OAAO,CAAC;YACrF,MAAM;gBAAEA;YAAS;QACrB,SANc,IAAI,GAAG;IAOzB;AACJ;AAEO,MAAMC,gCAAgCR;IAGzC,YAAYC,GAAW,EAAEM,QAAgB,CAAE;QACvC,KAAK,CAAC;YACF,SAAS,CAAC,sCAAsC,EAAEA,SAAS,OAAO,CAAC;YACnE,MAAM;gBAAEN;gBAAKM;YAAS;QAC1B,SANc,IAAI,GAAG;IAOzB;AACJ;AAEO,MAAME,qCAAqCT;IAG9C,YAAYC,GAAW,CAAE;QACrB,KAAK,CAAC;YACF,SAAS,CAAC,YAAY,EAAEA,IAAI,0CAA0C,CAAC;YACvE,MAAM;gBAAEA;YAAI;QAChB,SANc,IAAI,GAAG;IAOzB;AACJ;AAEO,MAAMS,sCAAsCV;IAG/C,aAAc;QACV,KAAK,CAAC;YACF,SACI;QACR,SANc,IAAI,GAAG;IAOzB;AACJ"}
@@ -1,2 +1,5 @@
1
1
  export { GlobalKeyValueStore, KeyValueStore, KeyValueStoreRepository, KeyValueStorageOperations } from "./abstractions.js";
2
- export { KeyNotFoundError, KeyValueStorageError } from "./errors.js";
2
+ export type { KeyValueComparable } from "./abstractions.js";
3
+ export type { IKeyValueWriteCondition } from "./abstractions.js";
4
+ export type { IKeyValueDeleteCondition } from "./abstractions.js";
5
+ export { KeyNotFoundError, KeyValueStorageError, KeyValueInvalidCursorError, KeyValueInvalidCollectionError, KeyValueKeyTooLongError, KeyValueConditionFailedError, KeyValueInvalidConditionError } from "./errors.js";
@@ -1,2 +1,2 @@
1
1
  export { GlobalKeyValueStore, KeyValueStorageOperations, KeyValueStore, KeyValueStoreRepository } from "./abstractions.js";
2
- export { KeyNotFoundError, KeyValueStorageError } from "./errors.js";
2
+ export { KeyNotFoundError, KeyValueConditionFailedError, KeyValueInvalidCollectionError, KeyValueInvalidConditionError, KeyValueInvalidCursorError, KeyValueKeyTooLongError, KeyValueStorageError } from "./errors.js";
@@ -0,0 +1,11 @@
1
+ import { PublicUrls } from "./abstractions.js";
2
+ import { PublicUrl } from "./PublicUrl.js";
3
+ /** Default for hosting types (and tests) that don't supply public URLs. */
4
+ declare class NullPublicUrlsImpl implements PublicUrls.Interface {
5
+ getApiUrl(): Promise<PublicUrl>;
6
+ getAdminUrl(): Promise<PublicUrl>;
7
+ }
8
+ export declare const NullPublicUrls: typeof NullPublicUrlsImpl & {
9
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IPublicUrls>;
10
+ };
11
+ export {};
@@ -0,0 +1,17 @@
1
+ import { PublicUrls } from "./abstractions.js";
2
+ import { PublicUrl } from "./PublicUrl.js";
3
+ class NullPublicUrlsImpl {
4
+ async getApiUrl() {
5
+ return PublicUrl.unknown();
6
+ }
7
+ async getAdminUrl() {
8
+ return PublicUrl.unknown();
9
+ }
10
+ }
11
+ const NullPublicUrls = PublicUrls.createImplementation({
12
+ implementation: NullPublicUrlsImpl,
13
+ dependencies: []
14
+ });
15
+ export { NullPublicUrls };
16
+
17
+ //# sourceMappingURL=NullPublicUrls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/publicUrls/NullPublicUrls.js","sources":["../../../src/features/publicUrls/NullPublicUrls.ts"],"sourcesContent":["import { PublicUrls } from \"./abstractions.js\";\nimport { PublicUrl } from \"./PublicUrl.js\";\n\n/** Default for hosting types (and tests) that don't supply public URLs. */\nclass NullPublicUrlsImpl implements PublicUrls.Interface {\n async getApiUrl() {\n return PublicUrl.unknown();\n }\n\n async getAdminUrl() {\n return PublicUrl.unknown();\n }\n}\n\nexport const NullPublicUrls = PublicUrls.createImplementation({\n implementation: NullPublicUrlsImpl,\n dependencies: []\n});\n"],"names":["NullPublicUrlsImpl","PublicUrl","NullPublicUrls","PublicUrls"],"mappings":";;AAIA,MAAMA;IACF,MAAM,YAAY;QACd,OAAOC,UAAU,OAAO;IAC5B;IAEA,MAAM,cAAc;QAChB,OAAOA,UAAU,OAAO;IAC5B;AACJ;AAEO,MAAMC,iBAAiBC,WAAW,oBAAoB,CAAC;IAC1D,gBAAgBH;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * A public URL of the API or the Admin app. Usually an origin (https://api.example.com), but it can
3
+ * carry a path when the app is served under a prefix (the standalone dev proxy serves the API at
4
+ * http://localhost:3001/api). Never has a trailing slash.
5
+ *
6
+ * Always an object, never `null`: a URL the deployment doesn't know is an "unknown" `PublicUrl`
7
+ * whose string forms are empty. Check `isKnown()` only where unknown needs different output.
8
+ */
9
+ export declare class PublicUrl {
10
+ private readonly url;
11
+ private constructor();
12
+ /** Unknown for anything that isn't an absolute http(s) URL. */
13
+ static from(value: unknown): PublicUrl;
14
+ static unknown(): PublicUrl;
15
+ isKnown(): boolean;
16
+ /** Hostname plus port, e.g. `api.example.com` or `localhost:3001`. Empty when unknown. */
17
+ get host(): string;
18
+ /** Appends a path, e.g. `join("/files/")` gives `https://api.example.com/files/`. Empty when unknown. */
19
+ join(path: string): string;
20
+ /** The URL, or `fallback` when unknown, e.g. a placeholder in generated config. */
21
+ orElse(fallback: string): string;
22
+ /** Empty when unknown. */
23
+ toString(): string;
24
+ }
@@ -0,0 +1,43 @@
1
+ class PublicUrl {
2
+ constructor(url){
3
+ this.url = url;
4
+ }
5
+ static from(value) {
6
+ if ("string" != typeof value || !value.trim()) return PublicUrl.unknown();
7
+ const trimmed = value.trim();
8
+ let url;
9
+ try {
10
+ url = new URL(trimmed);
11
+ } catch {
12
+ return PublicUrl.unknown();
13
+ }
14
+ if ("https:" !== url.protocol && "http:" !== url.protocol) return PublicUrl.unknown();
15
+ url.pathname = url.pathname.replace(/\/+$/, "");
16
+ url.search = "";
17
+ url.hash = "";
18
+ return new PublicUrl(url);
19
+ }
20
+ static unknown() {
21
+ return new PublicUrl(null);
22
+ }
23
+ isKnown() {
24
+ return null !== this.url;
25
+ }
26
+ get host() {
27
+ return this.url?.host ?? "";
28
+ }
29
+ join(path) {
30
+ if (!this.url) return "";
31
+ return this.toString() + "/" + path.replace(/^\/+/, "");
32
+ }
33
+ orElse(fallback) {
34
+ return this.url ? this.toString() : fallback;
35
+ }
36
+ toString() {
37
+ if (!this.url) return "";
38
+ return this.url.origin + this.url.pathname.replace(/\/+$/, "");
39
+ }
40
+ }
41
+ export { PublicUrl };
42
+
43
+ //# sourceMappingURL=PublicUrl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/publicUrls/PublicUrl.js","sources":["../../../src/features/publicUrls/PublicUrl.ts"],"sourcesContent":["/**\n * A public URL of the API or the Admin app. Usually an origin (https://api.example.com), but it can\n * carry a path when the app is served under a prefix (the standalone dev proxy serves the API at\n * http://localhost:3001/api). Never has a trailing slash.\n *\n * Always an object, never `null`: a URL the deployment doesn't know is an \"unknown\" `PublicUrl`\n * whose string forms are empty. Check `isKnown()` only where unknown needs different output.\n */\nexport class PublicUrl {\n private constructor(private readonly url: URL | null) {}\n\n /** Unknown for anything that isn't an absolute http(s) URL. */\n static from(value: unknown): PublicUrl {\n if (typeof value !== \"string\" || !value.trim()) {\n return PublicUrl.unknown();\n }\n\n const trimmed = value.trim();\n let url: URL;\n try {\n url = new URL(trimmed);\n } catch {\n return PublicUrl.unknown();\n }\n\n if (url.protocol !== \"https:\" && url.protocol !== \"http:\") {\n return PublicUrl.unknown();\n }\n\n url.pathname = url.pathname.replace(/\\/+$/, \"\");\n url.search = \"\";\n url.hash = \"\";\n\n return new PublicUrl(url);\n }\n\n static unknown(): PublicUrl {\n return new PublicUrl(null);\n }\n\n isKnown(): boolean {\n return this.url !== null;\n }\n\n /** Hostname plus port, e.g. `api.example.com` or `localhost:3001`. Empty when unknown. */\n get host(): string {\n return this.url?.host ?? \"\";\n }\n\n /** Appends a path, e.g. `join(\"/files/\")` gives `https://api.example.com/files/`. Empty when unknown. */\n join(path: string): string {\n if (!this.url) {\n return \"\";\n }\n\n return this.toString() + \"/\" + path.replace(/^\\/+/, \"\");\n }\n\n /** The URL, or `fallback` when unknown, e.g. a placeholder in generated config. */\n orElse(fallback: string): string {\n return this.url ? this.toString() : fallback;\n }\n\n /** Empty when unknown. */\n toString(): string {\n if (!this.url) {\n return \"\";\n }\n\n return this.url.origin + this.url.pathname.replace(/\\/+$/, \"\");\n }\n}\n"],"names":["PublicUrl","url","value","trimmed","URL","path","fallback"],"mappings":"AAQO,MAAMA;IACT,YAAqCC,GAAe,CAAE;aAAjBA,GAAG,GAAHA;IAAkB;IAGvD,OAAO,KAAKC,KAAc,EAAa;QACnC,IAAI,AAAiB,YAAjB,OAAOA,SAAsB,CAACA,MAAM,IAAI,IACxC,OAAOF,UAAU,OAAO;QAG5B,MAAMG,UAAUD,MAAM,IAAI;QAC1B,IAAID;QACJ,IAAI;YACAA,MAAM,IAAIG,IAAID;QAClB,EAAE,OAAM;YACJ,OAAOH,UAAU,OAAO;QAC5B;QAEA,IAAIC,AAAiB,aAAjBA,IAAI,QAAQ,IAAiBA,AAAiB,YAAjBA,IAAI,QAAQ,EACzC,OAAOD,UAAU,OAAO;QAG5BC,IAAI,QAAQ,GAAGA,IAAI,QAAQ,CAAC,OAAO,CAAC,QAAQ;QAC5CA,IAAI,MAAM,GAAG;QACbA,IAAI,IAAI,GAAG;QAEX,OAAO,IAAID,UAAUC;IACzB;IAEA,OAAO,UAAqB;QACxB,OAAO,IAAID,UAAU;IACzB;IAEA,UAAmB;QACf,OAAO,AAAa,SAAb,IAAI,CAAC,GAAG;IACnB;IAGA,IAAI,OAAe;QACf,OAAO,IAAI,CAAC,GAAG,EAAE,QAAQ;IAC7B;IAGA,KAAKK,IAAY,EAAU;QACvB,IAAI,CAAC,IAAI,CAAC,GAAG,EACT,OAAO;QAGX,OAAO,IAAI,CAAC,QAAQ,KAAK,MAAMA,KAAK,OAAO,CAAC,QAAQ;IACxD;IAGA,OAAOC,QAAgB,EAAU;QAC7B,OAAO,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,QAAQ,KAAKA;IACxC;IAGA,WAAmB;QACf,IAAI,CAAC,IAAI,CAAC,GAAG,EACT,OAAO;QAGX,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ;IAC/D;AACJ"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,38 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { PublicUrl } from "../PublicUrl.js";
3
+ describe("PublicUrl", ()=>{
4
+ it.each([
5
+ void 0,
6
+ null,
7
+ 42,
8
+ "",
9
+ " ",
10
+ "not a url",
11
+ "api.example.com",
12
+ "ftp://example.com"
13
+ ])("is unknown for %j", (value)=>{
14
+ const url = PublicUrl.from(value);
15
+ expect(url.isKnown()).toBe(false);
16
+ expect(url.toString()).toBe("");
17
+ expect(url.host).toBe("");
18
+ expect(url.join("/files/")).toBe("");
19
+ expect(url.orElse("{API_HOST_URL}")).toBe("{API_HOST_URL}");
20
+ });
21
+ it("drops trailing slashes, query and hash", ()=>{
22
+ const url = PublicUrl.from(" https://api.example.com//?a=1#x ");
23
+ expect(url.toString()).toBe("https://api.example.com");
24
+ expect(url.isKnown()).toBe(true);
25
+ expect(url.orElse("{API_HOST_URL}")).toBe("https://api.example.com");
26
+ });
27
+ it("keeps a path prefix", ()=>{
28
+ const url = PublicUrl.from("http://localhost:3001/api/");
29
+ expect(url.toString()).toBe("http://localhost:3001/api");
30
+ expect(url.host).toBe("localhost:3001");
31
+ });
32
+ it("joins paths with exactly one slash", ()=>{
33
+ expect(PublicUrl.from("https://api.example.com/").join("/files/")).toBe("https://api.example.com/files/");
34
+ expect(PublicUrl.from("http://localhost:3001/api").join("files")).toBe("http://localhost:3001/api/files");
35
+ });
36
+ });
37
+
38
+ //# sourceMappingURL=PublicUrl.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/publicUrls/__tests__/PublicUrl.test.js","sources":["../../../../src/features/publicUrls/__tests__/PublicUrl.test.ts"],"sourcesContent":["import { describe } from \"vitest\";\nimport { it } from \"vitest\";\nimport { expect } from \"vitest\";\nimport { PublicUrl } from \"../PublicUrl.js\";\n\ndescribe(\"PublicUrl\", () => {\n it.each([undefined, null, 42, \"\", \" \", \"not a url\", \"api.example.com\", \"ftp://example.com\"])(\n \"is unknown for %j\",\n value => {\n const url = PublicUrl.from(value);\n\n expect(url.isKnown()).toBe(false);\n expect(url.toString()).toBe(\"\");\n expect(url.host).toBe(\"\");\n expect(url.join(\"/files/\")).toBe(\"\");\n expect(url.orElse(\"{API_HOST_URL}\")).toBe(\"{API_HOST_URL}\");\n }\n );\n\n it(\"drops trailing slashes, query and hash\", () => {\n const url = PublicUrl.from(\" https://api.example.com//?a=1#x \");\n\n expect(url.toString()).toBe(\"https://api.example.com\");\n expect(url.isKnown()).toBe(true);\n expect(url.orElse(\"{API_HOST_URL}\")).toBe(\"https://api.example.com\");\n });\n\n it(\"keeps a path prefix\", () => {\n const url = PublicUrl.from(\"http://localhost:3001/api/\");\n\n expect(url.toString()).toBe(\"http://localhost:3001/api\");\n expect(url.host).toBe(\"localhost:3001\");\n });\n\n it(\"joins paths with exactly one slash\", () => {\n expect(PublicUrl.from(\"https://api.example.com/\").join(\"/files/\")).toBe(\n \"https://api.example.com/files/\"\n );\n expect(PublicUrl.from(\"http://localhost:3001/api\").join(\"files\")).toBe(\n \"http://localhost:3001/api/files\"\n );\n });\n});\n"],"names":["describe","it","undefined","value","url","PublicUrl","expect"],"mappings":";;AAKAA,SAAS,aAAa;IAClBC,GAAG,IAAI,CAAC;QAACC;QAAW;QAAM;QAAI;QAAI;QAAO;QAAa;QAAmB;KAAoB,EACzF,qBACAC,CAAAA;QACI,MAAMC,MAAMC,UAAU,IAAI,CAACF;QAE3BG,OAAOF,IAAI,OAAO,IAAI,IAAI,CAAC;QAC3BE,OAAOF,IAAI,QAAQ,IAAI,IAAI,CAAC;QAC5BE,OAAOF,IAAI,IAAI,EAAE,IAAI,CAAC;QACtBE,OAAOF,IAAI,IAAI,CAAC,YAAY,IAAI,CAAC;QACjCE,OAAOF,IAAI,MAAM,CAAC,mBAAmB,IAAI,CAAC;IAC9C;IAGJH,GAAG,0CAA0C;QACzC,MAAMG,MAAMC,UAAU,IAAI,CAAC;QAE3BC,OAAOF,IAAI,QAAQ,IAAI,IAAI,CAAC;QAC5BE,OAAOF,IAAI,OAAO,IAAI,IAAI,CAAC;QAC3BE,OAAOF,IAAI,MAAM,CAAC,mBAAmB,IAAI,CAAC;IAC9C;IAEAH,GAAG,uBAAuB;QACtB,MAAMG,MAAMC,UAAU,IAAI,CAAC;QAE3BC,OAAOF,IAAI,QAAQ,IAAI,IAAI,CAAC;QAC5BE,OAAOF,IAAI,IAAI,EAAE,IAAI,CAAC;IAC1B;IAEAH,GAAG,sCAAsC;QACrCK,OAAOD,UAAU,IAAI,CAAC,4BAA4B,IAAI,CAAC,YAAY,IAAI,CACnE;QAEJC,OAAOD,UAAU,IAAI,CAAC,6BAA6B,IAAI,CAAC,UAAU,IAAI,CAClE;IAER;AACJ"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { Container } from "@webiny/feature/api";
3
+ import { PublicUrls, PublicUrlsFeature } from "../index.js";
4
+ describe("PublicUrls", ()=>{
5
+ it("returns unknown URLs by default", async ()=>{
6
+ const container = new Container();
7
+ PublicUrlsFeature.register(container);
8
+ const publicUrls = container.resolve(PublicUrls);
9
+ expect((await publicUrls.getApiUrl()).isKnown()).toBe(false);
10
+ expect((await publicUrls.getAdminUrl()).isKnown()).toBe(false);
11
+ });
12
+ });
13
+
14
+ //# sourceMappingURL=PublicUrls.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/publicUrls/__tests__/PublicUrls.test.js","sources":["../../../../src/features/publicUrls/__tests__/PublicUrls.test.ts"],"sourcesContent":["import { describe } from \"vitest\";\nimport { it } from \"vitest\";\nimport { expect } from \"vitest\";\nimport { Container } from \"@webiny/feature/api\";\nimport { PublicUrls } from \"../index.js\";\nimport { PublicUrlsFeature } from \"../index.js\";\n\ndescribe(\"PublicUrls\", () => {\n it(\"returns unknown URLs by default\", async () => {\n const container = new Container();\n PublicUrlsFeature.register(container);\n\n const publicUrls = container.resolve(PublicUrls);\n\n expect((await publicUrls.getApiUrl()).isKnown()).toBe(false);\n expect((await publicUrls.getAdminUrl()).isKnown()).toBe(false);\n });\n});\n"],"names":["describe","it","container","Container","PublicUrlsFeature","publicUrls","PublicUrls","expect"],"mappings":";;;AAOAA,SAAS,cAAc;IACnBC,GAAG,mCAAmC;QAClC,MAAMC,YAAY,IAAIC;QACtBC,kBAAkB,QAAQ,CAACF;QAE3B,MAAMG,aAAaH,UAAU,OAAO,CAACI;QAErCC,OAAQ,OAAMF,WAAW,SAAS,EAAC,EAAG,OAAO,IAAI,IAAI,CAAC;QACtDE,OAAQ,OAAMF,WAAW,WAAW,EAAC,EAAG,OAAO,IAAI,IAAI,CAAC;IAC5D;AACJ"}
@@ -0,0 +1,27 @@
1
+ import type { PublicUrl } from "./PublicUrl.js";
2
+ export interface IPublicUrls {
3
+ /**
4
+ * Public URL of the API for the current tenant, e.g. https://api.example.com. Uses the custom
5
+ * domain when one is configured. Unknown (see `PublicUrl.isKnown()`) when the deployment doesn't
6
+ * know it.
7
+ */
8
+ getApiUrl(): Promise<PublicUrl>;
9
+ /**
10
+ * Public URL of the Admin app for the current tenant, e.g. https://admin.example.com. Uses the
11
+ * custom domain when one is configured. Unknown when the deployment doesn't know it (e.g. the
12
+ * API is deployed but the Admin app isn't yet).
13
+ */
14
+ getAdminUrl(): Promise<PublicUrl>;
15
+ }
16
+ /**
17
+ * Public URLs of this deployment's API and Admin app. Each hosting type supplies its own
18
+ * implementation: AWS reads the service manifest written at deploy time
19
+ * (`@webiny/api-event-handler-aws`), standalone reads the `WEBINY_API_URL` / `WEBINY_ADMIN_URL`
20
+ * build params (`@webiny/api-event-handler-standalone`).
21
+ *
22
+ * Resolve per request and don't cache the result globally: values are "for the current tenant".
23
+ */
24
+ export declare const PublicUrls: import("@webiny/di").Abstraction<IPublicUrls>;
25
+ export declare namespace PublicUrls {
26
+ type Interface = IPublicUrls;
27
+ }
@@ -0,0 +1,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const PublicUrls = createAbstraction("Core/PublicUrls");
3
+ export { PublicUrls };
4
+
5
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/publicUrls/abstractions.js","sources":["../../../src/features/publicUrls/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { PublicUrl } from \"./PublicUrl.js\";\n\nexport interface IPublicUrls {\n /**\n * Public URL of the API for the current tenant, e.g. https://api.example.com. Uses the custom\n * domain when one is configured. Unknown (see `PublicUrl.isKnown()`) when the deployment doesn't\n * know it.\n */\n getApiUrl(): Promise<PublicUrl>;\n /**\n * Public URL of the Admin app for the current tenant, e.g. https://admin.example.com. Uses the\n * custom domain when one is configured. Unknown when the deployment doesn't know it (e.g. the\n * API is deployed but the Admin app isn't yet).\n */\n getAdminUrl(): Promise<PublicUrl>;\n}\n\n/**\n * Public URLs of this deployment's API and Admin app. Each hosting type supplies its own\n * implementation: AWS reads the service manifest written at deploy time\n * (`@webiny/api-event-handler-aws`), standalone reads the `WEBINY_API_URL` / `WEBINY_ADMIN_URL`\n * build params (`@webiny/api-event-handler-standalone`).\n *\n * Resolve per request and don't cache the result globally: values are \"for the current tenant\".\n */\nexport const PublicUrls = createAbstraction<IPublicUrls>(\"Core/PublicUrls\");\n\nexport namespace PublicUrls {\n export type Interface = IPublicUrls;\n}\n"],"names":["PublicUrls","createAbstraction"],"mappings":";AA0BO,MAAMA,aAAaC,kBAA+B"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Registers the default, which knows no URLs. Each hosting type overrides it through the
3
+ * `publicUrls` hook of `registerApiRequestStack`.
4
+ */
5
+ export declare const PublicUrlsFeature: {
6
+ name: string;
7
+ register(container: import("@webiny/di").Container): void;
8
+ };
@@ -0,0 +1,11 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { NullPublicUrls } from "./NullPublicUrls.js";
3
+ const PublicUrlsFeature = createFeature({
4
+ name: "PublicUrlsFeature",
5
+ register (container) {
6
+ container.register(NullPublicUrls);
7
+ }
8
+ });
9
+ export { PublicUrlsFeature };
10
+
11
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/publicUrls/feature.js","sources":["../../../src/features/publicUrls/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { NullPublicUrls } from \"./NullPublicUrls.js\";\n\n/**\n * Registers the default, which knows no URLs. Each hosting type overrides it through the\n * `publicUrls` hook of `registerApiRequestStack`.\n */\nexport const PublicUrlsFeature = createFeature({\n name: \"PublicUrlsFeature\",\n register(container) {\n container.register(NullPublicUrls);\n }\n});\n"],"names":["PublicUrlsFeature","createFeature","container","NullPublicUrls"],"mappings":";;AAOO,MAAMA,oBAAoBC,cAAc;IAC3C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
@@ -0,0 +1,3 @@
1
+ export { PublicUrls } from "./abstractions.js";
2
+ export { PublicUrl } from "./PublicUrl.js";
3
+ export { PublicUrlsFeature } from "./feature.js";
@@ -0,0 +1,3 @@
1
+ export { PublicUrls } from "./abstractions.js";
2
+ export { PublicUrl } from "./PublicUrl.js";
3
+ export { PublicUrlsFeature } from "./feature.js";
@@ -0,0 +1,14 @@
1
+ import { RawAssumePermissions as Abstraction } from "./abstractions.js";
2
+ /**
3
+ * Per-request holder for the transport-extracted preview target. Registered per request, so a
4
+ * fresh instance holds the value for the current request only.
5
+ */
6
+ declare class RawAssumePermissionsImpl implements Abstraction.Interface {
7
+ private value;
8
+ get(): Abstraction.Target | null;
9
+ set(value: Abstraction.Target | null): void;
10
+ }
11
+ export declare const RawAssumePermissions: typeof RawAssumePermissionsImpl & {
12
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IRawAssumePermissions>;
13
+ };
14
+ export {};