@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,19 @@
1
+ import { Slugify } from "../slugify/abstractions.js";
2
+ import { StringFormatter } from "./abstractions.js";
3
+ class DefaultStringFormatterImpl {
4
+ constructor(slugifier){
5
+ this.slugifier = slugifier;
6
+ }
7
+ slugify(value) {
8
+ return this.slugifier.execute(value);
9
+ }
10
+ }
11
+ const DefaultStringFormatter = StringFormatter.createImplementation({
12
+ implementation: DefaultStringFormatterImpl,
13
+ dependencies: [
14
+ Slugify
15
+ ]
16
+ });
17
+ export { DefaultStringFormatter };
18
+
19
+ //# sourceMappingURL=DefaultStringFormatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/stringFormatter/DefaultStringFormatter.js","sources":["../../../src/features/stringFormatter/DefaultStringFormatter.ts"],"sourcesContent":["import { Slugify } from \"~/features/slugify/abstractions.js\";\nimport { StringFormatter } from \"./abstractions.js\";\n\n/**\n * The string formatter is the consumer-facing API for string transforms. It keeps each transform's\n * logic in its own fine-grained, decoratable feature (e.g. `Slugify`) and just delegates to it, so a\n * project can change one transform without reimplementing the whole formatter. More methods will be\n * added here over time.\n */\nclass DefaultStringFormatterImpl implements StringFormatter.Interface {\n constructor(private readonly slugifier: Slugify.Interface) {}\n\n slugify(value: string): string {\n return this.slugifier.execute(value);\n }\n}\n\nexport const DefaultStringFormatter = StringFormatter.createImplementation({\n implementation: DefaultStringFormatterImpl,\n dependencies: [Slugify]\n});\n"],"names":["DefaultStringFormatterImpl","slugifier","value","DefaultStringFormatter","StringFormatter","Slugify"],"mappings":";;AASA,MAAMA;IACF,YAA6BC,SAA4B,CAAE;aAA9BA,SAAS,GAATA;IAA+B;IAE5D,QAAQC,KAAa,EAAU;QAC3B,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAACA;IAClC;AACJ;AAEO,MAAMC,yBAAyBC,gBAAgB,oBAAoB,CAAC;IACvE,gBAAgBJ;IAChB,cAAc;QAACK;KAAQ;AAC3B"}
@@ -0,0 +1,11 @@
1
+ export interface IStringFormatter {
2
+ /**
3
+ * Turns a value into a URL-friendly slug. Delegates to the `Slugify` feature, so to change slug
4
+ * logic decorate `Slugify` alone rather than the whole string formatter.
5
+ */
6
+ slugify(value: string): string;
7
+ }
8
+ export declare const StringFormatter: import("@webiny/di").Abstraction<IStringFormatter>;
9
+ export declare namespace StringFormatter {
10
+ type Interface = IStringFormatter;
11
+ }
@@ -0,0 +1,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const StringFormatter = createAbstraction("StringFormatter");
3
+ export { StringFormatter };
4
+
5
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/stringFormatter/abstractions.js","sources":["../../../src/features/stringFormatter/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\nexport interface IStringFormatter {\n /**\n * Turns a value into a URL-friendly slug. Delegates to the `Slugify` feature, so to change slug\n * logic decorate `Slugify` alone rather than the whole string formatter.\n */\n slugify(value: string): string;\n}\n\nexport const StringFormatter = createAbstraction<IStringFormatter>(\"StringFormatter\");\n\nexport namespace StringFormatter {\n export type Interface = IStringFormatter;\n}\n"],"names":["StringFormatter","createAbstraction"],"mappings":";AAUO,MAAMA,kBAAkBC,kBAAoC"}
@@ -0,0 +1,4 @@
1
+ export declare const StringFormatterFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -0,0 +1,13 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { SlugifyFeature } from "../slugify/feature.js";
3
+ import { DefaultStringFormatter } from "./DefaultStringFormatter.js";
4
+ const StringFormatterFeature = createFeature({
5
+ name: "StringFormatterFeature",
6
+ register (container) {
7
+ SlugifyFeature.register(container);
8
+ container.register(DefaultStringFormatter);
9
+ }
10
+ });
11
+ export { StringFormatterFeature };
12
+
13
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/stringFormatter/feature.js","sources":["../../../src/features/stringFormatter/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { SlugifyFeature } from \"~/features/slugify/feature.js\";\nimport { DefaultStringFormatter } from \"./DefaultStringFormatter.js\";\n\nexport const StringFormatterFeature = createFeature({\n name: \"StringFormatterFeature\",\n register(container) {\n // Register the transforms the formatter delegates to, then the formatter itself.\n SlugifyFeature.register(container);\n container.register(DefaultStringFormatter);\n }\n});\n"],"names":["StringFormatterFeature","createFeature","container","SlugifyFeature","DefaultStringFormatter"],"mappings":";;;AAIO,MAAMA,yBAAyBC,cAAc;IAChD,MAAM;IACN,UAASC,SAAS;QAEdC,eAAe,QAAQ,CAACD;QACxBA,UAAU,QAAQ,CAACE;IACvB;AACJ"}
@@ -0,0 +1,3 @@
1
+ export { StringFormatter } from "./abstractions.js";
2
+ export type { IStringFormatter } from "./abstractions.js";
3
+ export { StringFormatterFeature } from "./feature.js";
@@ -0,0 +1,2 @@
1
+ export { StringFormatter } from "./abstractions.js";
2
+ export { StringFormatterFeature } from "./feature.js";
@@ -1,4 +1,5 @@
1
1
  import zod from "zod";
2
+ import type { Constructor } from "@webiny/di";
2
3
  import type { GenericRecord } from "@webiny/api/types";
3
4
  import type { ITask } from "../../../features/task/TaskService/index.js";
4
5
  import { TaskController } from "../../../features/task/TaskController/index.js";
@@ -14,12 +15,34 @@ export interface ITaskOutput {
14
15
  [key: string]: any;
15
16
  }
16
17
  /**
17
- * Task run params - ONLY the input data
18
+ * The task's own definition, minus its behaviour.
19
+ *
20
+ * Handed to `run()` and to every lifecycle hook so a decorator can tell which task it is wrapping
21
+ * and act on the definition's own fields. A decorator is registered against the abstraction, so it
22
+ * wraps every task; without this it has nothing to branch on but a hardcoded list of ids, which
23
+ * means editing the decorator every time a task is added.
24
+ *
25
+ * This is {@link ITaskMetadata}: identity and policy, no behaviour and no handler pointer. The
26
+ * object passed at runtime is the resolved task, so `run` is physically present; naming the metadata
27
+ * type here stops the obvious mistake of a handler calling `params.definition.run(...)` and
28
+ * recursing forever.
29
+ *
30
+ * Only the fields declared here arrive. A field a project adds to its own definition class is
31
+ * currently dropped, because `TaskDefinitionDefaultsDecorator` is a fixed pass-through that
32
+ * exposes a known set of getters and nothing else. Making them forward unknown
33
+ * properties would turn a definition into a place to declare policy (a rate limit, a set of tags)
34
+ * that a decorator acts on; `taskDefinitionInParams.test.ts` pins the current behaviour so that
35
+ * change announces itself.
36
+ */
37
+ export type ITaskDefinitionInfo = ITaskMetadata;
38
+ /**
39
+ * Task run params - the input data, plus the definition being run
18
40
  * All runtime dependencies come from TaskController (injected separately)
19
41
  */
20
42
  export interface ITaskRunParams<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> {
21
43
  input: I;
22
44
  controller: TaskController.Interface<I, O>;
45
+ definition: ITaskDefinitionInfo;
23
46
  }
24
47
  /**
25
48
  * Data for creating a new task
@@ -35,6 +58,7 @@ export interface ITaskCreateData<I = ITaskInput> {
35
58
  */
36
59
  export interface ITaskBeforeTriggerParams<I = ITaskInput> {
37
60
  data: ITaskCreateData<I>;
61
+ definition: ITaskDefinitionInfo;
38
62
  }
39
63
  /**
40
64
  * Task result status enum
@@ -70,11 +94,16 @@ export type ISelfCleanupEvent = "onSuccess" | "onError" | "onAbort";
70
94
  export type ISelfCleanup = "always" | "never" | ISelfCleanupEvent | ISelfCleanupEvent[];
71
95
  export type ITaskLifecycleHook<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> = {
72
96
  task: ITask<I, O>;
97
+ definition: ITaskDefinitionInfo;
73
98
  };
74
99
  /**
75
- * Core TaskDefinition - minimal interface
100
+ * What a task IS: identity and runtime policy, with no behaviour and no dependencies.
101
+ *
102
+ * Listing tasks, resolving one by id, and applying defaults all need only this. Keeping it free of
103
+ * dependencies is the whole point — `GetRunnableTaskDefinitionUseCase` builds every registered definition
104
+ * to find one by id, so anything expensive here is paid 24 times per lookup.
76
105
  */
77
- export interface ITaskDefinition<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> {
106
+ export interface ITaskMetadata {
78
107
  id: string;
79
108
  title: string;
80
109
  description?: string;
@@ -82,6 +111,16 @@ export interface ITaskDefinition<I extends ITaskInput = ITaskInput, O extends IT
82
111
  databaseLogs?: boolean;
83
112
  isPrivate?: boolean;
84
113
  selfCleanup?: ISelfCleanup;
114
+ }
115
+ /**
116
+ * What a task DOES. This is the half that carries dependencies (a CMS context, an OpenSearch
117
+ * client), so it is built only for the task actually being run.
118
+ *
119
+ * The lifecycle hooks live here rather than on {@link ITaskMetadata} because they need the same
120
+ * dependencies `run()` does — see `MockDataManagerTask`, whose `onError` and `onAbort` both use the
121
+ * OpenSearch client injected for `run()`.
122
+ */
123
+ export interface ITaskHandler<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> {
85
124
  /**
86
125
  * Core run method - receives ONLY input params
87
126
  * All runtime dependencies (logging, state management, etc.) come from TaskController
@@ -101,23 +140,48 @@ export interface ITaskDefinition<I extends ITaskInput = ITaskInput, O extends IT
101
140
  */
102
141
  createInputValidation?(params: ITaskCreateInputValidationParams): GenericRecord<keyof I, zod.Schema> | zod.Schema;
103
142
  }
143
+ /**
144
+ * What you register: a task's {@link ITaskMetadata} plus the class that does the work.
145
+ *
146
+ * The definition takes no dependencies of its own, so `GetRunnableTaskDefinitionUseCase` can build every
147
+ * registered one to find a task by id without constructing anything expensive. Only the winner's
148
+ * `handler` gets built.
149
+ */
150
+ export interface ITaskDefinition<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> extends ITaskMetadata {
151
+ handler: Constructor<ITaskHandler<I, O>>;
152
+ }
104
153
  export interface ITaskCreateInputValidationParams {
105
154
  validator: typeof zod;
106
155
  }
107
156
  /** Define a long-running background task with lifecycle hooks. */
108
157
  export declare const TaskDefinition: import("@webiny/di").Abstraction<ITaskDefinition<ITaskInput, ITaskOutput>>;
158
+ /**
159
+ * The behaviour half of a task, resolved on demand by the runner via
160
+ * `container.resolveImplementation(definition.handler)`. Registered implementations are NOT
161
+ * registered against this abstraction — the definition points at the class directly, exactly as
162
+ * `HttpRouteDefinition` points at its `HttpRouteHandler`.
163
+ */
164
+ export declare const TaskHandler: import("@webiny/di").Abstraction<ITaskHandler<ITaskInput, ITaskOutput>>;
109
165
  /**
110
166
  * IRunnableTaskDefinition represents a TaskDefinition after decoration/processing.
111
167
  * All optional runtime properties are guaranteed to have values (with defaults applied).
112
168
  * Used internally by the task runner to ensure consistent behavior.
113
169
  */
114
- export interface IRunnableTaskDefinition<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> extends ITaskDefinition<I, O> {
170
+ export interface IRunnableTaskDefinition<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> extends ITaskMetadata, ITaskHandler<I, O> {
115
171
  isPrivate: boolean;
116
172
  databaseLogs: boolean;
117
173
  maxIterations: number;
118
174
  }
175
+ export declare namespace TaskHandler {
176
+ type Interface<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> = ITaskHandler<I, O>;
177
+ type RunParams<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> = ITaskRunParams<I, O>;
178
+ type Result<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> = ITaskResult<I, O>;
179
+ type LifecycleHookParams<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> = ITaskLifecycleHook<I, O>;
180
+ }
119
181
  export declare namespace TaskDefinition {
120
182
  type Interface<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> = ITaskDefinition<I, O>;
183
+ type Metadata = ITaskMetadata;
184
+ type Handler<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> = ITaskHandler<I, O>;
121
185
  type TaskInput = ITaskInput;
122
186
  type TaskOutput = ITaskOutput;
123
187
  type Runnable<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> = IRunnableTaskDefinition<I, O>;
@@ -132,6 +196,7 @@ export declare namespace TaskDefinition {
132
196
  type TaskCreateData<I = ITaskInput> = ITaskCreateData<I>;
133
197
  type BeforeTriggerParams<I = ITaskInput> = ITaskBeforeTriggerParams<I>;
134
198
  type LifecycleHookParams<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> = ITaskLifecycleHook<I, O>;
199
+ type Info = ITaskDefinitionInfo;
135
200
  type SelfCleanupEvent = ISelfCleanupEvent;
136
201
  type SelfCleanup = ISelfCleanup;
137
202
  }
@@ -7,6 +7,7 @@ var abstractions_TaskResultStatus = /*#__PURE__*/ function(TaskResultStatus) {
7
7
  return TaskResultStatus;
8
8
  }({});
9
9
  const TaskDefinition = createAbstraction("TaskDefinition");
10
- export { TaskDefinition, abstractions_TaskResultStatus as TaskResultStatus };
10
+ const TaskHandler = createAbstraction("TaskHandler");
11
+ export { TaskDefinition, TaskHandler, abstractions_TaskResultStatus as TaskResultStatus };
11
12
 
12
13
  //# sourceMappingURL=abstractions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"features/task/TaskDefinition/abstractions.js","sources":["../../../../src/features/task/TaskDefinition/abstractions.ts"],"sourcesContent":["import zod from \"zod\";\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport type { GenericRecord } from \"@webiny/api/types\";\nimport type { ITask } from \"~/features/task/TaskService/index.js\";\nimport { TaskController } from \"~/features/task/TaskController/index.js\";\n\nexport type ITaskInput = GenericRecord;\n\nexport interface IResponseError {\n message: string;\n code?: string | null;\n data?: GenericRecord | null;\n stack?: string;\n}\n\nexport interface ITaskOutput {\n error?: IResponseError;\n [key: string]: any;\n}\n\n/**\n * Task run params - ONLY the input data\n * All runtime dependencies come from TaskController (injected separately)\n */\nexport interface ITaskRunParams<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n> {\n input: I;\n controller: TaskController.Interface<I, O>;\n}\n\n/**\n * Data for creating a new task\n */\nexport interface ITaskCreateData<I = ITaskInput> {\n definitionId: string;\n name: string;\n input: I;\n parentId?: string;\n}\n\n/**\n * Parameters for onBeforeTrigger lifecycle hook\n */\nexport interface ITaskBeforeTriggerParams<I = ITaskInput> {\n data: ITaskCreateData<I>;\n}\n\n/**\n * Task result status enum\n */\nexport enum TaskResultStatus {\n DONE = \"done\",\n CONTINUE = \"continue\",\n ERROR = \"error\",\n ABORTED = \"aborted\"\n}\n\n/**\n * Specific result types\n */\nexport interface ITaskResultDone<O extends ITaskOutput = ITaskOutput> {\n status: TaskResultStatus.DONE;\n message?: string;\n output?: O;\n}\n\nexport interface ITaskResultContinue<I = ITaskInput> {\n status: TaskResultStatus.CONTINUE;\n input: I;\n wait?: number; // seconds to wait before next iteration\n}\n\nexport interface ITaskResultError {\n status: TaskResultStatus.ERROR;\n error: IResponseError;\n}\n\nexport interface ITaskResultAborted {\n status: TaskResultStatus.ABORTED;\n}\n\nexport type ITaskResult<I = ITaskInput, O extends ITaskOutput = ITaskOutput> =\n | ITaskResultDone<O>\n | ITaskResultContinue<I>\n | ITaskResultError\n | ITaskResultAborted;\n\nexport type ISelfCleanupEvent = \"onSuccess\" | \"onError\" | \"onAbort\";\n\nexport type ISelfCleanup = \"always\" | \"never\" | ISelfCleanupEvent | ISelfCleanupEvent[];\n\nexport type ITaskLifecycleHook<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n> = {\n task: ITask<I, O>;\n};\n\n/**\n * Core TaskDefinition - minimal interface\n */\nexport interface ITaskDefinition<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n> {\n id: string;\n title: string;\n description?: string;\n maxIterations?: number;\n databaseLogs?: boolean;\n isPrivate?: boolean;\n selfCleanup?: ISelfCleanup;\n\n /**\n * Core run method - receives ONLY input params\n * All runtime dependencies (logging, state management, etc.) come from TaskController\n */\n run(params: ITaskRunParams<I, O>): Promise<ITaskResult<I, O>>;\n\n /**\n * Optional lifecycle hooks - receive task data, no context.\n */\n onBeforeTrigger?(params: ITaskBeforeTriggerParams<I>): Promise<void>;\n onDone?(params: ITaskLifecycleHook<I, O>): Promise<void>;\n onError?(params: ITaskLifecycleHook<I, O>): Promise<void>;\n onAbort?(params: ITaskLifecycleHook<I, O>): Promise<void>;\n onMaxIterations?(params: ITaskLifecycleHook<I, O>): Promise<void>;\n /**\n * Create a validation schema for the task input.\n * This will be used to validate the input before the task is triggered.\n */\n createInputValidation?(\n params: ITaskCreateInputValidationParams\n ): GenericRecord<keyof I, zod.Schema> | zod.Schema;\n}\n\nexport interface ITaskCreateInputValidationParams {\n validator: typeof zod;\n}\n\n/** Define a long-running background task with lifecycle hooks. */\nexport const TaskDefinition = createAbstraction<ITaskDefinition>(\"TaskDefinition\");\n\n/**\n * IRunnableTaskDefinition represents a TaskDefinition after decoration/processing.\n * All optional runtime properties are guaranteed to have values (with defaults applied).\n * Used internally by the task runner to ensure consistent behavior.\n */\nexport interface IRunnableTaskDefinition<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n> extends ITaskDefinition<I, O> {\n // Override optional properties to be required with guaranteed values\n isPrivate: boolean;\n databaseLogs: boolean;\n maxIterations: number;\n}\n\nexport namespace TaskDefinition {\n export type Interface<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskDefinition<I, O>;\n\n export type TaskInput = ITaskInput;\n\n export type TaskOutput = ITaskOutput;\n\n export type Runnable<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = IRunnableTaskDefinition<I, O>;\n\n export type RunParams<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskRunParams<I, O>;\n\n export type Result<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskResult<I, O>;\n\n export type Task<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITask<I, O>;\n\n export type ResultDone<O extends ITaskOutput = ITaskOutput> = ITaskResultDone<O>;\n export type ResultContinue<I = ITaskInput> = ITaskResultContinue<I>;\n export type ResultError = ITaskResultError;\n export type ResultAborted = ITaskResultAborted;\n export type CreateInputValidationParams = ITaskCreateInputValidationParams;\n export type TaskCreateData<I = ITaskInput> = ITaskCreateData<I>;\n export type BeforeTriggerParams<I = ITaskInput> = ITaskBeforeTriggerParams<I>;\n export type LifecycleHookParams<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskLifecycleHook<I, O>;\n\n export type SelfCleanupEvent = ISelfCleanupEvent;\n export type SelfCleanup = ISelfCleanup;\n}\n"],"names":["TaskResultStatus","TaskDefinition","createAbstraction"],"mappings":";AAoDO,IAAKA,gCAAgBA,WAAAA,GAAAA,SAAhBA,gBAAgB;;;;;WAAhBA;;AA2FL,MAAMC,iBAAiBC,kBAAmC"}
1
+ {"version":3,"file":"features/task/TaskDefinition/abstractions.js","sources":["../../../../src/features/task/TaskDefinition/abstractions.ts"],"sourcesContent":["import zod from \"zod\";\nimport type { Constructor } from \"@webiny/di\";\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport type { GenericRecord } from \"@webiny/api/types\";\nimport type { ITask } from \"~/features/task/TaskService/index.js\";\nimport { TaskController } from \"~/features/task/TaskController/index.js\";\n\nexport type ITaskInput = GenericRecord;\n\nexport interface IResponseError {\n message: string;\n code?: string | null;\n data?: GenericRecord | null;\n stack?: string;\n}\n\nexport interface ITaskOutput {\n error?: IResponseError;\n [key: string]: any;\n}\n\n/**\n * The task's own definition, minus its behaviour.\n *\n * Handed to `run()` and to every lifecycle hook so a decorator can tell which task it is wrapping\n * and act on the definition's own fields. A decorator is registered against the abstraction, so it\n * wraps every task; without this it has nothing to branch on but a hardcoded list of ids, which\n * means editing the decorator every time a task is added.\n *\n * This is {@link ITaskMetadata}: identity and policy, no behaviour and no handler pointer. The\n * object passed at runtime is the resolved task, so `run` is physically present; naming the metadata\n * type here stops the obvious mistake of a handler calling `params.definition.run(...)` and\n * recursing forever.\n *\n * Only the fields declared here arrive. A field a project adds to its own definition class is\n * currently dropped, because `TaskDefinitionDefaultsDecorator` is a fixed pass-through that\n * exposes a known set of getters and nothing else. Making them forward unknown\n * properties would turn a definition into a place to declare policy (a rate limit, a set of tags)\n * that a decorator acts on; `taskDefinitionInParams.test.ts` pins the current behaviour so that\n * change announces itself.\n */\nexport type ITaskDefinitionInfo = ITaskMetadata;\n\n/**\n * Task run params - the input data, plus the definition being run\n * All runtime dependencies come from TaskController (injected separately)\n */\nexport interface ITaskRunParams<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n> {\n input: I;\n controller: TaskController.Interface<I, O>;\n definition: ITaskDefinitionInfo;\n}\n\n/**\n * Data for creating a new task\n */\nexport interface ITaskCreateData<I = ITaskInput> {\n definitionId: string;\n name: string;\n input: I;\n parentId?: string;\n}\n\n/**\n * Parameters for onBeforeTrigger lifecycle hook\n */\nexport interface ITaskBeforeTriggerParams<I = ITaskInput> {\n data: ITaskCreateData<I>;\n definition: ITaskDefinitionInfo;\n}\n\n/**\n * Task result status enum\n */\nexport enum TaskResultStatus {\n DONE = \"done\",\n CONTINUE = \"continue\",\n ERROR = \"error\",\n ABORTED = \"aborted\"\n}\n\n/**\n * Specific result types\n */\nexport interface ITaskResultDone<O extends ITaskOutput = ITaskOutput> {\n status: TaskResultStatus.DONE;\n message?: string;\n output?: O;\n}\n\nexport interface ITaskResultContinue<I = ITaskInput> {\n status: TaskResultStatus.CONTINUE;\n input: I;\n wait?: number; // seconds to wait before next iteration\n}\n\nexport interface ITaskResultError {\n status: TaskResultStatus.ERROR;\n error: IResponseError;\n}\n\nexport interface ITaskResultAborted {\n status: TaskResultStatus.ABORTED;\n}\n\nexport type ITaskResult<I = ITaskInput, O extends ITaskOutput = ITaskOutput> =\n | ITaskResultDone<O>\n | ITaskResultContinue<I>\n | ITaskResultError\n | ITaskResultAborted;\n\nexport type ISelfCleanupEvent = \"onSuccess\" | \"onError\" | \"onAbort\";\n\nexport type ISelfCleanup = \"always\" | \"never\" | ISelfCleanupEvent | ISelfCleanupEvent[];\n\nexport type ITaskLifecycleHook<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n> = {\n task: ITask<I, O>;\n definition: ITaskDefinitionInfo;\n};\n\n/**\n * What a task IS: identity and runtime policy, with no behaviour and no dependencies.\n *\n * Listing tasks, resolving one by id, and applying defaults all need only this. Keeping it free of\n * dependencies is the whole point — `GetRunnableTaskDefinitionUseCase` builds every registered definition\n * to find one by id, so anything expensive here is paid 24 times per lookup.\n */\nexport interface ITaskMetadata {\n id: string;\n title: string;\n description?: string;\n maxIterations?: number;\n databaseLogs?: boolean;\n isPrivate?: boolean;\n selfCleanup?: ISelfCleanup;\n}\n\n/**\n * What a task DOES. This is the half that carries dependencies (a CMS context, an OpenSearch\n * client), so it is built only for the task actually being run.\n *\n * The lifecycle hooks live here rather than on {@link ITaskMetadata} because they need the same\n * dependencies `run()` does — see `MockDataManagerTask`, whose `onError` and `onAbort` both use the\n * OpenSearch client injected for `run()`.\n */\nexport interface ITaskHandler<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n> {\n /**\n * Core run method - receives ONLY input params\n * All runtime dependencies (logging, state management, etc.) come from TaskController\n */\n run(params: ITaskRunParams<I, O>): Promise<ITaskResult<I, O>>;\n\n /**\n * Optional lifecycle hooks - receive task data, no context.\n */\n onBeforeTrigger?(params: ITaskBeforeTriggerParams<I>): Promise<void>;\n onDone?(params: ITaskLifecycleHook<I, O>): Promise<void>;\n onError?(params: ITaskLifecycleHook<I, O>): Promise<void>;\n onAbort?(params: ITaskLifecycleHook<I, O>): Promise<void>;\n onMaxIterations?(params: ITaskLifecycleHook<I, O>): Promise<void>;\n /**\n * Create a validation schema for the task input.\n * This will be used to validate the input before the task is triggered.\n */\n createInputValidation?(\n params: ITaskCreateInputValidationParams\n ): GenericRecord<keyof I, zod.Schema> | zod.Schema;\n}\n\n/**\n * What you register: a task's {@link ITaskMetadata} plus the class that does the work.\n *\n * The definition takes no dependencies of its own, so `GetRunnableTaskDefinitionUseCase` can build every\n * registered one to find a task by id without constructing anything expensive. Only the winner's\n * `handler` gets built.\n */\nexport interface ITaskDefinition<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n> extends ITaskMetadata {\n handler: Constructor<ITaskHandler<I, O>>;\n}\n\nexport interface ITaskCreateInputValidationParams {\n validator: typeof zod;\n}\n\n/** Define a long-running background task with lifecycle hooks. */\nexport const TaskDefinition = createAbstraction<ITaskDefinition>(\"TaskDefinition\");\n\n/**\n * The behaviour half of a task, resolved on demand by the runner via\n * `container.resolveImplementation(definition.handler)`. Registered implementations are NOT\n * registered against this abstraction — the definition points at the class directly, exactly as\n * `HttpRouteDefinition` points at its `HttpRouteHandler`.\n */\nexport const TaskHandler = createAbstraction<ITaskHandler>(\"TaskHandler\");\n\n/**\n * IRunnableTaskDefinition represents a TaskDefinition after decoration/processing.\n * All optional runtime properties are guaranteed to have values (with defaults applied).\n * Used internally by the task runner to ensure consistent behavior.\n */\nexport interface IRunnableTaskDefinition<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n>\n extends ITaskMetadata, ITaskHandler<I, O> {\n // Override optional properties to be required with guaranteed values\n isPrivate: boolean;\n databaseLogs: boolean;\n maxIterations: number;\n}\n\nexport namespace TaskHandler {\n export type Interface<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskHandler<I, O>;\n\n export type RunParams<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskRunParams<I, O>;\n\n export type Result<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskResult<I, O>;\n\n export type LifecycleHookParams<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskLifecycleHook<I, O>;\n}\n\nexport namespace TaskDefinition {\n export type Interface<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskDefinition<I, O>;\n\n export type Metadata = ITaskMetadata;\n\n export type Handler<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskHandler<I, O>;\n\n export type TaskInput = ITaskInput;\n\n export type TaskOutput = ITaskOutput;\n\n export type Runnable<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = IRunnableTaskDefinition<I, O>;\n\n export type RunParams<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskRunParams<I, O>;\n\n export type Result<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskResult<I, O>;\n\n export type Task<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITask<I, O>;\n\n export type ResultDone<O extends ITaskOutput = ITaskOutput> = ITaskResultDone<O>;\n export type ResultContinue<I = ITaskInput> = ITaskResultContinue<I>;\n export type ResultError = ITaskResultError;\n export type ResultAborted = ITaskResultAborted;\n export type CreateInputValidationParams = ITaskCreateInputValidationParams;\n export type TaskCreateData<I = ITaskInput> = ITaskCreateData<I>;\n export type BeforeTriggerParams<I = ITaskInput> = ITaskBeforeTriggerParams<I>;\n export type LifecycleHookParams<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskLifecycleHook<I, O>;\n\n export type Info = ITaskDefinitionInfo;\n\n export type SelfCleanupEvent = ISelfCleanupEvent;\n export type SelfCleanup = ISelfCleanup;\n}\n"],"names":["TaskResultStatus","TaskDefinition","createAbstraction","TaskHandler"],"mappings":";AA6EO,IAAKA,gCAAgBA,WAAAA,GAAAA,SAAhBA,gBAAgB;;;;;WAAhBA;;AAwHL,MAAMC,iBAAiBC,kBAAmC;AAQ1D,MAAMC,cAAcD,kBAAgC"}
@@ -8,7 +8,7 @@ declare class CreateTenantUseCaseImpl implements UseCaseAbstraction.Interface {
8
8
  private eventPublisher;
9
9
  private repository;
10
10
  constructor(eventPublisher: EventPublisher.Interface, repository: CreateTenantRepository.Interface);
11
- execute(data: CreateTenantInput): Promise<Result<Tenant, never> | Result<never, CreateTenantError>>;
11
+ execute(data: CreateTenantInput): Promise<Result<never, CreateTenantError> | Result<Tenant, never>>;
12
12
  }
13
13
  export declare const CreateTenantUseCase: import("@webiny/di").Implementation<typeof CreateTenantUseCaseImpl>;
14
14
  export {};
@@ -13,7 +13,7 @@ declare class InstallTenantUseCaseImpl implements UseCaseAbstraction.Interface {
13
13
  private updateTenantUseCase;
14
14
  private resolver;
15
15
  constructor(tenantContext: TenantContext.Interface, eventPublisher: EventPublisher.Interface, appInstallers: AppInstaller.Interface[], updateTenantUseCase: UpdateTenantUseCase.Interface);
16
- execute({ tenant, installationInput }: TenantInstallationInput): Promise<Result<void, never> | Result<never, InstallationDependencyError> | Result<never, InstallTenantError>>;
16
+ execute({ tenant, installationInput }: TenantInstallationInput): Promise<Result<void, never> | Result<never, InstallTenantError> | Result<never, InstallationDependencyError>>;
17
17
  private rollback;
18
18
  }
19
19
  export declare const InstallTenantUseCase: import("@webiny/di").Implementation<typeof InstallTenantUseCaseImpl>;
@@ -7,6 +7,7 @@ declare class TenantContextImpl implements Abstraction.Interface {
7
7
  constructor(getRootTenant: GetRootTenantUseCase.Interface);
8
8
  getTenant(): Tenant;
9
9
  setTenant(tenant: Tenant): void;
10
+ private restoreTenant;
10
11
  withRootTenant<T>(cb: () => T): Promise<T>;
11
12
  withEachTenant<TReturn>(tenants: Tenant[], cb: (tenant: Tenant) => Promise<TReturn>): Promise<TReturn[]>;
12
13
  withTenant<TReturn>(tenant: Tenant, cb: (tenant: Tenant) => Promise<TReturn>): Promise<TReturn>;
@@ -14,8 +14,11 @@ class TenantContextImpl {
14
14
  if (tenant.isInstalled && "disabled" === tenant.status) throw new TenantIsDisabledError();
15
15
  this.currentTenant = tenant;
16
16
  }
17
+ restoreTenant(tenant) {
18
+ this.currentTenant = tenant;
19
+ }
17
20
  async withRootTenant(cb) {
18
- const initialTenant = this.getTenant();
21
+ const initialTenant = this.currentTenant;
19
22
  const rootTenant = await this.getRootTenant.execute();
20
23
  if (!rootTenant.isOk()) return rootTenant.error;
21
24
  const tenant = rootTenant.value;
@@ -23,28 +26,30 @@ class TenantContextImpl {
23
26
  try {
24
27
  return await cb();
25
28
  } finally{
26
- this.setTenant(initialTenant);
29
+ this.restoreTenant(initialTenant);
27
30
  }
28
31
  }
29
32
  async withEachTenant(tenants, cb) {
30
- const initialTenant = this.getTenant();
33
+ const initialTenant = this.currentTenant;
31
34
  const results = [];
32
35
  for (const tenant of tenants){
33
36
  this.setTenant(tenant);
34
37
  try {
35
38
  results.push(await cb(tenant));
36
39
  } finally{
37
- this.setTenant(initialTenant);
40
+ this.restoreTenant(initialTenant);
38
41
  }
39
42
  }
40
43
  return results;
41
44
  }
42
45
  async withTenant(tenant, cb) {
43
- const initialTenant = this.getTenant();
46
+ const initialTenant = this.currentTenant;
44
47
  this.setTenant(tenant);
45
- const result = await cb(tenant);
46
- this.setTenant(initialTenant);
47
- return result;
48
+ try {
49
+ return await cb(tenant);
50
+ } finally{
51
+ this.restoreTenant(initialTenant);
52
+ }
48
53
  }
49
54
  }
50
55
  const TenantContext_TenantContext = createImplementation({
@@ -1 +1 @@
1
- {"version":3,"file":"features/tenancy/TenantContext/TenantContext.js","sources":["../../../../src/features/tenancy/TenantContext/TenantContext.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { TenantContext as Abstraction } from \"./abstractions.js\";\nimport type { Tenant } from \"~/types/tenancy.js\";\nimport { GetRootTenantUseCase } from \"~/features/tenancy/GetRootTenant/index.js\";\nimport { TenantIsDisabledError } from \"./errors.js\";\n\nclass TenantContextImpl implements Abstraction.Interface {\n private currentTenant: Tenant | null = null;\n\n constructor(private getRootTenant: GetRootTenantUseCase.Interface) {}\n\n getTenant(): Tenant {\n return this.currentTenant!;\n }\n\n setTenant(tenant: Tenant): void {\n if (tenant.isInstalled && tenant.status === \"disabled\") {\n throw new TenantIsDisabledError();\n }\n this.currentTenant = tenant;\n }\n\n async withRootTenant<T>(cb: () => T): Promise<T> {\n const initialTenant = this.getTenant();\n const rootTenant = await this.getRootTenant.execute();\n if (!rootTenant.isOk()) {\n return rootTenant.error as T;\n }\n\n const tenant = rootTenant.value as Tenant;\n\n this.setTenant(tenant);\n try {\n return await cb();\n } finally {\n // Make sure that, whatever happens in the callback, the tenant is set back to the initial one.\n this.setTenant(initialTenant);\n }\n }\n\n async withEachTenant<TReturn>(\n tenants: Tenant[],\n cb: (tenant: Tenant) => Promise<TReturn>\n ): Promise<TReturn[]> {\n const initialTenant = this.getTenant();\n const results = [];\n for (const tenant of tenants) {\n this.setTenant(tenant);\n try {\n results.push(await cb(tenant));\n } finally {\n this.setTenant(initialTenant);\n }\n }\n return results;\n }\n\n async withTenant<TReturn>(\n tenant: Tenant,\n cb: (tenant: Tenant) => Promise<TReturn>\n ): Promise<TReturn> {\n const initialTenant = this.getTenant();\n this.setTenant(tenant);\n const result = await cb(tenant);\n this.setTenant(initialTenant);\n return result;\n }\n}\n\nexport const TenantContext = createImplementation({\n abstraction: Abstraction,\n implementation: TenantContextImpl,\n dependencies: [GetRootTenantUseCase]\n});\n"],"names":["TenantContextImpl","getRootTenant","tenant","TenantIsDisabledError","cb","initialTenant","rootTenant","tenants","results","result","TenantContext","createImplementation","Abstraction","GetRootTenantUseCase"],"mappings":";;;;AAMA,MAAMA;IAGF,YAAoBC,aAA6C,CAAE;aAA/CA,aAAa,GAAbA;aAFZ,aAAa,GAAkB;IAE6B;IAEpE,YAAoB;QAChB,OAAO,IAAI,CAAC,aAAa;IAC7B;IAEA,UAAUC,MAAc,EAAQ;QAC5B,IAAIA,OAAO,WAAW,IAAIA,AAAkB,eAAlBA,OAAO,MAAM,EACnC,MAAM,IAAIC;QAEd,IAAI,CAAC,aAAa,GAAGD;IACzB;IAEA,MAAM,eAAkBE,EAAW,EAAc;QAC7C,MAAMC,gBAAgB,IAAI,CAAC,SAAS;QACpC,MAAMC,aAAa,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO;QACnD,IAAI,CAACA,WAAW,IAAI,IAChB,OAAOA,WAAW,KAAK;QAG3B,MAAMJ,SAASI,WAAW,KAAK;QAE/B,IAAI,CAAC,SAAS,CAACJ;QACf,IAAI;YACA,OAAO,MAAME;QACjB,SAAU;YAEN,IAAI,CAAC,SAAS,CAACC;QACnB;IACJ;IAEA,MAAM,eACFE,OAAiB,EACjBH,EAAwC,EACtB;QAClB,MAAMC,gBAAgB,IAAI,CAAC,SAAS;QACpC,MAAMG,UAAU,EAAE;QAClB,KAAK,MAAMN,UAAUK,QAAS;YAC1B,IAAI,CAAC,SAAS,CAACL;YACf,IAAI;gBACAM,QAAQ,IAAI,CAAC,MAAMJ,GAAGF;YAC1B,SAAU;gBACN,IAAI,CAAC,SAAS,CAACG;YACnB;QACJ;QACA,OAAOG;IACX;IAEA,MAAM,WACFN,MAAc,EACdE,EAAwC,EACxB;QAChB,MAAMC,gBAAgB,IAAI,CAAC,SAAS;QACpC,IAAI,CAAC,SAAS,CAACH;QACf,MAAMO,SAAS,MAAML,GAAGF;QACxB,IAAI,CAAC,SAAS,CAACG;QACf,OAAOI;IACX;AACJ;AAEO,MAAMC,8BAAgBC,qBAAqB;IAC9C,aAAaC;IACb,gBAAgBZ;IAChB,cAAc;QAACa;KAAqB;AACxC"}
1
+ {"version":3,"file":"features/tenancy/TenantContext/TenantContext.js","sources":["../../../../src/features/tenancy/TenantContext/TenantContext.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { TenantContext as Abstraction } from \"./abstractions.js\";\nimport type { Tenant } from \"~/types/tenancy.js\";\nimport { GetRootTenantUseCase } from \"~/features/tenancy/GetRootTenant/index.js\";\nimport { TenantIsDisabledError } from \"./errors.js\";\n\nclass TenantContextImpl implements Abstraction.Interface {\n private currentTenant: Tenant | null = null;\n\n constructor(private getRootTenant: GetRootTenantUseCase.Interface) {}\n\n getTenant(): Tenant {\n return this.currentTenant!;\n }\n\n setTenant(tenant: Tenant): void {\n if (tenant.isInstalled && tenant.status === \"disabled\") {\n throw new TenantIsDisabledError();\n }\n this.currentTenant = tenant;\n }\n\n /*\n * Puts back the tenant that was current before a `with*` call. That can be none at all: work\n * outside an HTTP request (a background task, a scheduled action) starts without a tenant.\n * Restoring is not switching, so it skips the checks `setTenant` makes.\n */\n private restoreTenant(tenant: Tenant | null): void {\n this.currentTenant = tenant;\n }\n\n async withRootTenant<T>(cb: () => T): Promise<T> {\n const initialTenant = this.currentTenant;\n const rootTenant = await this.getRootTenant.execute();\n if (!rootTenant.isOk()) {\n return rootTenant.error as T;\n }\n\n const tenant = rootTenant.value;\n\n this.setTenant(tenant);\n try {\n return await cb();\n } finally {\n // Make sure that, whatever happens in the callback, the tenant is set back to the initial one.\n this.restoreTenant(initialTenant);\n }\n }\n\n async withEachTenant<TReturn>(\n tenants: Tenant[],\n cb: (tenant: Tenant) => Promise<TReturn>\n ): Promise<TReturn[]> {\n const initialTenant = this.currentTenant;\n const results = [];\n for (const tenant of tenants) {\n this.setTenant(tenant);\n try {\n results.push(await cb(tenant));\n } finally {\n this.restoreTenant(initialTenant);\n }\n }\n return results;\n }\n\n async withTenant<TReturn>(\n tenant: Tenant,\n cb: (tenant: Tenant) => Promise<TReturn>\n ): Promise<TReturn> {\n const initialTenant = this.currentTenant;\n this.setTenant(tenant);\n try {\n return await cb(tenant);\n } finally {\n // Make sure that, whatever happens in the callback, the tenant is set back to the initial one.\n this.restoreTenant(initialTenant);\n }\n }\n}\n\nexport const TenantContext = createImplementation({\n abstraction: Abstraction,\n implementation: TenantContextImpl,\n dependencies: [GetRootTenantUseCase]\n});\n"],"names":["TenantContextImpl","getRootTenant","tenant","TenantIsDisabledError","cb","initialTenant","rootTenant","tenants","results","TenantContext","createImplementation","Abstraction","GetRootTenantUseCase"],"mappings":";;;;AAMA,MAAMA;IAGF,YAAoBC,aAA6C,CAAE;aAA/CA,aAAa,GAAbA;aAFZ,aAAa,GAAkB;IAE6B;IAEpE,YAAoB;QAChB,OAAO,IAAI,CAAC,aAAa;IAC7B;IAEA,UAAUC,MAAc,EAAQ;QAC5B,IAAIA,OAAO,WAAW,IAAIA,AAAkB,eAAlBA,OAAO,MAAM,EACnC,MAAM,IAAIC;QAEd,IAAI,CAAC,aAAa,GAAGD;IACzB;IAOQ,cAAcA,MAAqB,EAAQ;QAC/C,IAAI,CAAC,aAAa,GAAGA;IACzB;IAEA,MAAM,eAAkBE,EAAW,EAAc;QAC7C,MAAMC,gBAAgB,IAAI,CAAC,aAAa;QACxC,MAAMC,aAAa,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO;QACnD,IAAI,CAACA,WAAW,IAAI,IAChB,OAAOA,WAAW,KAAK;QAG3B,MAAMJ,SAASI,WAAW,KAAK;QAE/B,IAAI,CAAC,SAAS,CAACJ;QACf,IAAI;YACA,OAAO,MAAME;QACjB,SAAU;YAEN,IAAI,CAAC,aAAa,CAACC;QACvB;IACJ;IAEA,MAAM,eACFE,OAAiB,EACjBH,EAAwC,EACtB;QAClB,MAAMC,gBAAgB,IAAI,CAAC,aAAa;QACxC,MAAMG,UAAU,EAAE;QAClB,KAAK,MAAMN,UAAUK,QAAS;YAC1B,IAAI,CAAC,SAAS,CAACL;YACf,IAAI;gBACAM,QAAQ,IAAI,CAAC,MAAMJ,GAAGF;YAC1B,SAAU;gBACN,IAAI,CAAC,aAAa,CAACG;YACvB;QACJ;QACA,OAAOG;IACX;IAEA,MAAM,WACFN,MAAc,EACdE,EAAwC,EACxB;QAChB,MAAMC,gBAAgB,IAAI,CAAC,aAAa;QACxC,IAAI,CAAC,SAAS,CAACH;QACf,IAAI;YACA,OAAO,MAAME,GAAGF;QACpB,SAAU;YAEN,IAAI,CAAC,aAAa,CAACG;QACvB;IACJ;AACJ;AAEO,MAAMI,8BAAgBC,qBAAqB;IAC9C,aAAaC;IACb,gBAAgBX;IAChB,cAAc;QAACY;KAAqB;AACxC"}
@@ -9,9 +9,9 @@ declare class UpdateTenantUseCaseImpl implements UseCaseAbstraction.Interface {
9
9
  private eventPublisher;
10
10
  private repository;
11
11
  constructor(getTenantById: GetTenantByIdUseCase.Interface, eventPublisher: EventPublisher.Interface, repository: UpdateTenantRepository.Interface);
12
- execute(id: string, data: Partial<Tenant>): Promise<({
12
+ execute(id: string, data: Partial<Tenant>): Promise<Result<Tenant, never> | ({
13
13
  _error: import("../GetTenantById/abstractions.js").GetTenantByIdError;
14
- } & Result<Tenant, import("../GetTenantById/abstractions.js").GetTenantByIdError>) | Result<Tenant, never>>;
14
+ } & Result<Tenant, import("../GetTenantById/abstractions.js").GetTenantByIdError>)>;
15
15
  }
16
16
  export declare const UpdateTenantUseCase: import("@webiny/di").Implementation<typeof UpdateTenantUseCaseImpl>;
17
17
  export {};
@@ -5,7 +5,7 @@ declare class CreateUserWithWcpIncrementImpl implements CreateUserUseCase.Interf
5
5
  private wcp;
6
6
  private decoratee;
7
7
  constructor(wcp: WcpContext.Interface, decoratee: CreateUserUseCase.Interface);
8
- execute(input: CreateUserInput): Promise<import("@webiny/feature/api").Result<import("~/features/users/shared/types.js").AdminUser, import("../../shared/errors.js").UserStorageError | import("../../shared/errors.js").UserNotFoundError | import("../../shared/errors.js").EmailTakenError | import("../../shared/errors.js").UserValidationError | import("../../shared/errors.js").NotAuthorizedError>>;
8
+ execute(input: CreateUserInput): Promise<import("@webiny/feature/api").Result<import("~/features/users/shared/types.js").AdminUser, import("../../shared/errors.js").EmailTakenError | import("../../shared/errors.js").NotAuthorizedError | import("../../shared/errors.js").UserNotFoundError | import("../../shared/errors.js").UserStorageError | import("../../shared/errors.js").UserValidationError>>;
9
9
  }
10
10
  export declare const CreateUserWithWcpIncrement: typeof CreateUserWithWcpIncrementImpl;
11
11
  export {};
@@ -1,12 +1,11 @@
1
1
  import type { WCP_FEATURE_LABEL } from "@webiny/wcp";
2
2
  import type { DecryptedWcpProjectLicense, ILicense, WcpProjectEnvironment, WcpProject } from "@webiny/wcp/types.js";
3
3
  import { WcpContext } from "./abstractions.js";
4
- export interface CreateWcpContextParams {
5
- testProjectLicense?: DecryptedWcpProjectLicense;
6
- }
4
+ import type { WcpLicenseProvider } from "../WcpLicenseProvider.js";
7
5
  export declare class WcpContextImpl implements WcpContext.Interface {
8
- private license;
9
- constructor(license: ILicense);
6
+ private licenseProvider;
7
+ constructor(licenseProvider: WcpLicenseProvider.Interface);
8
+ private get license();
10
9
  private getWcpProjectUrl;
11
10
  private updateSeats;
12
11
  private updateTenants;
@@ -27,7 +26,19 @@ export declare class WcpContextImpl implements WcpContext.Interface {
27
26
  canUseHcmsFieldPermissions(): boolean;
28
27
  canUseAiImageEnrichment(): boolean;
29
28
  canUseAiPageGeneration(): boolean;
29
+ canUseAiPageTranslation(): boolean;
30
30
  canUseAiLexicalGeneration(): boolean;
31
+ canUseAiAdminAssistant(): boolean;
32
+ canUseAiEntryGeneration(): boolean;
33
+ canUseAiEntryComparison(): boolean;
34
+ canUseAiEntryTranslation(): boolean;
35
+ canUseAiPowerups(): boolean;
36
+ canUseAbTesting(): boolean;
37
+ canUseRemoteComponents(): boolean;
38
+ canUseCollaboration(): boolean;
39
+ canUseComments(): boolean;
40
+ canUseActivityLog(): boolean;
41
+ canUseLanguages(): boolean;
31
42
  ensureCanUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL): void;
32
43
  incrementSeats(): Promise<void>;
33
44
  decrementSeats(): Promise<void>;
@@ -3,8 +3,11 @@ import error from "@webiny/error";
3
3
  import { wcpFetch } from "./utils.js";
4
4
  const wcpProjectEnvironment = getWcpProjectEnvironment();
5
5
  class WcpContextImpl {
6
- constructor(license){
7
- this.license = license;
6
+ constructor(licenseProvider){
7
+ this.licenseProvider = licenseProvider;
8
+ }
9
+ get license() {
10
+ return this.licenseProvider.get();
8
11
  }
9
12
  getWcpProjectUrl(path = "") {
10
13
  if (!wcpProjectEnvironment) return null;
@@ -108,9 +111,45 @@ class WcpContextImpl {
108
111
  canUseAiPageGeneration() {
109
112
  return this.license.canUseAiPageGeneration();
110
113
  }
114
+ canUseAiPageTranslation() {
115
+ return this.license.canUseAiPageTranslation();
116
+ }
111
117
  canUseAiLexicalGeneration() {
112
118
  return this.license.canUseAiLexicalGeneration();
113
119
  }
120
+ canUseAiAdminAssistant() {
121
+ return this.license.canUseAiAdminAssistant();
122
+ }
123
+ canUseAiEntryGeneration() {
124
+ return this.license.canUseAiEntryGeneration();
125
+ }
126
+ canUseAiEntryComparison() {
127
+ return this.license.canUseAiEntryComparison();
128
+ }
129
+ canUseAiEntryTranslation() {
130
+ return this.license.canUseAiEntryTranslation();
131
+ }
132
+ canUseAiPowerups() {
133
+ return this.license.canUseAiPowerups();
134
+ }
135
+ canUseAbTesting() {
136
+ return this.license.canUseAbTesting();
137
+ }
138
+ canUseRemoteComponents() {
139
+ return this.license.canUseRemoteComponents();
140
+ }
141
+ canUseCollaboration() {
142
+ return this.license.canUseCollaboration();
143
+ }
144
+ canUseComments() {
145
+ return this.license.canUseComments();
146
+ }
147
+ canUseActivityLog() {
148
+ return this.license.canUseActivityLog();
149
+ }
150
+ canUseLanguages() {
151
+ return this.license.canUseLanguages();
152
+ }
114
153
  ensureCanUseFeature(wcpFeatureId) {
115
154
  if (this.license.canUseFeature(wcpFeatureId)) return;
116
155
  let message = `The ${wcpFeatureId} Webiny Control Panel feature cannot be used because your project license does not permit it.`;
@@ -1 +1 @@
1
- {"version":3,"file":"features/wcp/WcpContext/WcpContext.js","sources":["../../../../src/features/wcp/WcpContext/WcpContext.ts"],"sourcesContent":["import type { WCP_FEATURE_LABEL } from \"@webiny/wcp\";\nimport { getWcpApiUrl, getWcpAppUrl, getWcpProjectEnvironment } from \"@webiny/wcp\";\nimport WError from \"@webiny/error\";\nimport type {\n DecryptedWcpProjectLicense,\n ILicense,\n WcpProjectEnvironment,\n WcpProject\n} from \"@webiny/wcp/types.js\";\nimport { WcpContext } from \"./abstractions.js\";\nimport { wcpFetch } from \"./utils.js\";\n\nconst wcpProjectEnvironment = getWcpProjectEnvironment();\n\nexport interface CreateWcpContextParams {\n testProjectLicense?: DecryptedWcpProjectLicense;\n}\n\nexport class WcpContextImpl implements WcpContext.Interface {\n constructor(private license: ILicense) {}\n\n private getWcpProjectUrl(path = \"\"): string | null {\n if (!wcpProjectEnvironment) {\n return null;\n }\n\n const orgId = wcpProjectEnvironment.org.id;\n const projectId = wcpProjectEnvironment.project.id;\n const url = [\"/orgs\", orgId, \"projects\", projectId, path].filter(Boolean).join(\"/\");\n return getWcpApiUrl(url);\n }\n\n private async updateSeats(operation: \"increment\" | \"decrement\"): Promise<void> {\n if (!wcpProjectEnvironment) {\n return;\n }\n\n const updateSeatsUrl = this.getWcpProjectUrl(\"package/seats\");\n\n const response = await wcpFetch({\n url: updateSeatsUrl!,\n authorization: wcpProjectEnvironment.apiKey,\n body: { operation },\n meta: {\n action: operation + \"Seats\"\n }\n });\n\n if (response.error) {\n const message = response.message || `Failed to ${operation} user seats.`;\n console.error(message, response.status, response.statusText);\n throw new WError(message, \"WCP_CANNOT_UPDATE_USER_TENANTS\");\n }\n }\n\n private async updateTenants(operation: \"increment\" | \"decrement\"): Promise<void> {\n if (!wcpProjectEnvironment) {\n return;\n }\n\n const updateTenantsUrl = this.getWcpProjectUrl(\"package/tenants\");\n\n const response = await wcpFetch({\n url: updateTenantsUrl!,\n authorization: wcpProjectEnvironment.apiKey,\n body: { operation },\n meta: {\n action: operation + \"Tenants\"\n }\n });\n\n if (response.error) {\n const message = response.message || `Failed to ${operation} tenants.`;\n console.error(message, response.status, response.statusText);\n throw new WError(message, \"WCP_CANNOT_UPDATE_USER_TENANTS\");\n }\n }\n\n getRawLicense(): DecryptedWcpProjectLicense | null {\n return this.license.getRawLicense();\n }\n\n getProject(): WcpProject | null {\n return this.license.getProject();\n }\n\n getProjectWithFeatureFlags(): WcpProject | null {\n return this.getProject();\n }\n\n getProjectEnvironment(): WcpProjectEnvironment | null {\n return wcpProjectEnvironment;\n }\n\n getProjectLicense(): ILicense {\n return this.license;\n }\n\n canUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL): boolean {\n return this.license.canUseFeature(wcpFeatureId);\n }\n\n canUseAacl(): boolean {\n return this.license.canUseAacl();\n }\n\n canUseTeams(): boolean {\n return this.license.canUseTeams();\n }\n\n canUseFolderLevelPermissions(): boolean {\n return this.license.canUseFolderLevelPermissions();\n }\n\n canUsePrivateFiles(): boolean {\n return this.license.canUsePrivateFiles();\n }\n\n canUseAuditLogs(): boolean {\n return this.license.canUseAuditLogs();\n }\n\n canUseRecordLocking(): boolean {\n return this.license.canUseRecordLocking();\n }\n\n canUseFileManagerThreatDetection(): boolean {\n return this.license.canUseFileManagerThreatDetection();\n }\n\n canUseWorkflows(): boolean {\n return this.license.canUseWorkflows();\n }\n\n canUseHcmsFieldPermissions(): boolean {\n return this.license.canUseHcmsFieldPermissions();\n }\n\n canUseAiImageEnrichment(): boolean {\n return this.license.canUseAiImageEnrichment();\n }\n\n canUseAiPageGeneration(): boolean {\n return this.license.canUseAiPageGeneration();\n }\n\n canUseAiLexicalGeneration(): boolean {\n return this.license.canUseAiLexicalGeneration();\n }\n\n ensureCanUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL): void {\n if (this.license.canUseFeature(wcpFeatureId)) {\n return;\n }\n\n let message = `The ${wcpFeatureId} Webiny Control Panel feature cannot be used because your project license does not permit it.`;\n if (wcpProjectEnvironment) {\n const { org, project } = wcpProjectEnvironment;\n const upgradeProjectLicenseLink = getWcpAppUrl(`/${org.id}/${project.id}/settings`);\n message += ` To upgrade your project license, please use the following link: ${upgradeProjectLicenseLink}.`;\n }\n\n throw new WError(message, \"WCP_CANNOT_USE_FEATURE\", { wcpFeatureId });\n }\n\n async incrementSeats(): Promise<void> {\n await this.updateSeats(\"increment\");\n }\n\n async decrementSeats(): Promise<void> {\n await this.updateSeats(\"decrement\");\n }\n\n async incrementTenants(): Promise<void> {\n await this.updateTenants(\"increment\");\n }\n\n async decrementTenants(): Promise<void> {\n await this.updateTenants(\"decrement\");\n }\n\n toDto() {\n return this.getRawLicense();\n }\n}\n"],"names":["wcpProjectEnvironment","getWcpProjectEnvironment","WcpContextImpl","license","path","orgId","projectId","url","Boolean","getWcpApiUrl","operation","updateSeatsUrl","response","wcpFetch","message","console","WError","updateTenantsUrl","wcpFeatureId","org","project","upgradeProjectLicenseLink","getWcpAppUrl"],"mappings":"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"}
1
+ {"version":3,"file":"features/wcp/WcpContext/WcpContext.js","sources":["../../../../src/features/wcp/WcpContext/WcpContext.ts"],"sourcesContent":["import type { WCP_FEATURE_LABEL } from \"@webiny/wcp\";\nimport { getWcpApiUrl, getWcpAppUrl, getWcpProjectEnvironment } from \"@webiny/wcp\";\nimport WError from \"@webiny/error\";\nimport type {\n DecryptedWcpProjectLicense,\n ILicense,\n WcpProjectEnvironment,\n WcpProject\n} from \"@webiny/wcp/types.js\";\nimport { WcpContext } from \"./abstractions.js\";\nimport { wcpFetch } from \"./utils.js\";\nimport type { WcpLicenseProvider } from \"../WcpLicenseProvider.js\";\n\nconst wcpProjectEnvironment = getWcpProjectEnvironment();\n\nexport class WcpContextImpl implements WcpContext.Interface {\n constructor(private licenseProvider: WcpLicenseProvider.Interface) {}\n\n private get license(): ILicense {\n return this.licenseProvider.get();\n }\n\n private getWcpProjectUrl(path = \"\"): string | null {\n if (!wcpProjectEnvironment) {\n return null;\n }\n\n const orgId = wcpProjectEnvironment.org.id;\n const projectId = wcpProjectEnvironment.project.id;\n const url = [\"/orgs\", orgId, \"projects\", projectId, path].filter(Boolean).join(\"/\");\n return getWcpApiUrl(url);\n }\n\n private async updateSeats(operation: \"increment\" | \"decrement\"): Promise<void> {\n if (!wcpProjectEnvironment) {\n return;\n }\n\n const updateSeatsUrl = this.getWcpProjectUrl(\"package/seats\");\n\n const response = await wcpFetch({\n url: updateSeatsUrl!,\n authorization: wcpProjectEnvironment.apiKey,\n body: { operation },\n meta: {\n action: operation + \"Seats\"\n }\n });\n\n if (response.error) {\n const message = response.message || `Failed to ${operation} user seats.`;\n console.error(message, response.status, response.statusText);\n throw new WError(message, \"WCP_CANNOT_UPDATE_USER_TENANTS\");\n }\n }\n\n private async updateTenants(operation: \"increment\" | \"decrement\"): Promise<void> {\n if (!wcpProjectEnvironment) {\n return;\n }\n\n const updateTenantsUrl = this.getWcpProjectUrl(\"package/tenants\");\n\n const response = await wcpFetch({\n url: updateTenantsUrl!,\n authorization: wcpProjectEnvironment.apiKey,\n body: { operation },\n meta: {\n action: operation + \"Tenants\"\n }\n });\n\n if (response.error) {\n const message = response.message || `Failed to ${operation} tenants.`;\n console.error(message, response.status, response.statusText);\n throw new WError(message, \"WCP_CANNOT_UPDATE_USER_TENANTS\");\n }\n }\n\n getRawLicense(): DecryptedWcpProjectLicense | null {\n return this.license.getRawLicense();\n }\n\n getProject(): WcpProject | null {\n return this.license.getProject();\n }\n\n getProjectWithFeatureFlags(): WcpProject | null {\n return this.getProject();\n }\n\n getProjectEnvironment(): WcpProjectEnvironment | null {\n return wcpProjectEnvironment;\n }\n\n getProjectLicense(): ILicense {\n return this.license;\n }\n\n canUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL): boolean {\n return this.license.canUseFeature(wcpFeatureId);\n }\n\n canUseAacl(): boolean {\n return this.license.canUseAacl();\n }\n\n canUseTeams(): boolean {\n return this.license.canUseTeams();\n }\n\n canUseFolderLevelPermissions(): boolean {\n return this.license.canUseFolderLevelPermissions();\n }\n\n canUsePrivateFiles(): boolean {\n return this.license.canUsePrivateFiles();\n }\n\n canUseAuditLogs(): boolean {\n return this.license.canUseAuditLogs();\n }\n\n canUseRecordLocking(): boolean {\n return this.license.canUseRecordLocking();\n }\n\n canUseFileManagerThreatDetection(): boolean {\n return this.license.canUseFileManagerThreatDetection();\n }\n\n canUseWorkflows(): boolean {\n return this.license.canUseWorkflows();\n }\n\n canUseHcmsFieldPermissions(): boolean {\n return this.license.canUseHcmsFieldPermissions();\n }\n\n canUseAiImageEnrichment(): boolean {\n return this.license.canUseAiImageEnrichment();\n }\n\n canUseAiPageGeneration(): boolean {\n return this.license.canUseAiPageGeneration();\n }\n\n canUseAiPageTranslation(): boolean {\n return this.license.canUseAiPageTranslation();\n }\n\n canUseAiLexicalGeneration(): boolean {\n return this.license.canUseAiLexicalGeneration();\n }\n\n canUseAiAdminAssistant(): boolean {\n return this.license.canUseAiAdminAssistant();\n }\n\n canUseAiEntryGeneration(): boolean {\n return this.license.canUseAiEntryGeneration();\n }\n\n canUseAiEntryComparison(): boolean {\n return this.license.canUseAiEntryComparison();\n }\n\n canUseAiEntryTranslation(): boolean {\n return this.license.canUseAiEntryTranslation();\n }\n\n canUseAiPowerups(): boolean {\n return this.license.canUseAiPowerups();\n }\n\n canUseAbTesting(): boolean {\n return this.license.canUseAbTesting();\n }\n\n canUseRemoteComponents(): boolean {\n return this.license.canUseRemoteComponents();\n }\n\n canUseCollaboration(): boolean {\n return this.license.canUseCollaboration();\n }\n\n canUseComments(): boolean {\n return this.license.canUseComments();\n }\n\n canUseActivityLog(): boolean {\n return this.license.canUseActivityLog();\n }\n\n canUseLanguages(): boolean {\n return this.license.canUseLanguages();\n }\n\n ensureCanUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL): void {\n if (this.license.canUseFeature(wcpFeatureId)) {\n return;\n }\n\n let message = `The ${wcpFeatureId} Webiny Control Panel feature cannot be used because your project license does not permit it.`;\n if (wcpProjectEnvironment) {\n const { org, project } = wcpProjectEnvironment;\n const upgradeProjectLicenseLink = getWcpAppUrl(`/${org.id}/${project.id}/settings`);\n message += ` To upgrade your project license, please use the following link: ${upgradeProjectLicenseLink}.`;\n }\n\n throw new WError(message, \"WCP_CANNOT_USE_FEATURE\", { wcpFeatureId });\n }\n\n async incrementSeats(): Promise<void> {\n await this.updateSeats(\"increment\");\n }\n\n async decrementSeats(): Promise<void> {\n await this.updateSeats(\"decrement\");\n }\n\n async incrementTenants(): Promise<void> {\n await this.updateTenants(\"increment\");\n }\n\n async decrementTenants(): Promise<void> {\n await this.updateTenants(\"decrement\");\n }\n\n toDto() {\n return this.getRawLicense();\n }\n}\n"],"names":["wcpProjectEnvironment","getWcpProjectEnvironment","WcpContextImpl","licenseProvider","path","orgId","projectId","url","Boolean","getWcpApiUrl","operation","updateSeatsUrl","response","wcpFetch","message","console","WError","updateTenantsUrl","wcpFeatureId","org","project","upgradeProjectLicenseLink","getWcpAppUrl"],"mappings":"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"}