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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (391) hide show
  1. package/ApiCoreFeature.js +12 -2
  2. package/ApiCoreFeature.js.map +1 -1
  3. package/exports/api/security/api-key.d.ts +1 -0
  4. package/exports/api/security/api-key.js +1 -0
  5. package/exports/api/tasks.d.ts +1 -0
  6. package/exports/api/tasks.js +1 -1
  7. package/exports/api.d.ts +1 -1
  8. package/exports/api.js +1 -1
  9. package/features/ai/Ai.d.ts +5 -1
  10. package/features/ai/Ai.js +72 -29
  11. package/features/ai/Ai.js.map +1 -1
  12. package/features/ai/AiModelRegistry.d.ts +14 -0
  13. package/features/ai/AiModelRegistry.js +39 -0
  14. package/features/ai/AiModelRegistry.js.map +1 -0
  15. package/features/ai/AiSdkToolHandlerResolver.d.ts +11 -0
  16. package/features/ai/AiSdkToolHandlerResolver.js +19 -0
  17. package/features/ai/AiSdkToolHandlerResolver.js.map +1 -0
  18. package/features/ai/AiSdkTools.d.ts +4 -3
  19. package/features/ai/AiSdkTools.js +11 -9
  20. package/features/ai/AiSdkTools.js.map +1 -1
  21. package/features/ai/AnthropicSdkFactory.js +24 -4
  22. package/features/ai/AnthropicSdkFactory.js.map +1 -1
  23. package/features/ai/DEVELOPERS.md +183 -0
  24. package/features/ai/GoogleSdkFactory.d.ts +10 -0
  25. package/features/ai/GoogleSdkFactory.js +65 -0
  26. package/features/ai/GoogleSdkFactory.js.map +1 -0
  27. package/features/ai/OpenAiSdkFactory.js +67 -11
  28. package/features/ai/OpenAiSdkFactory.js.map +1 -1
  29. package/features/ai/OpenRouterSdkFactory.d.ts +10 -0
  30. package/features/ai/OpenRouterSdkFactory.js +112 -0
  31. package/features/ai/OpenRouterSdkFactory.js.map +1 -0
  32. package/features/ai/RemoteAiModelCatalog.d.ts +13 -0
  33. package/features/ai/RemoteAiModelCatalog.js +74 -0
  34. package/features/ai/RemoteAiModelCatalog.js.map +1 -0
  35. package/features/ai/TextExtractor/DefaultTextExtractor.d.ts +9 -0
  36. package/features/ai/TextExtractor/DefaultTextExtractor.js +28 -0
  37. package/features/ai/TextExtractor/DefaultTextExtractor.js.map +1 -0
  38. package/features/ai/TextExtractor/abstractions.d.ts +12 -0
  39. package/features/ai/TextExtractor/abstractions.js +5 -0
  40. package/features/ai/TextExtractor/abstractions.js.map +1 -0
  41. package/features/ai/TextExtractor/index.d.ts +3 -0
  42. package/features/ai/TextExtractor/index.js +2 -0
  43. package/features/ai/TextExtractor/parsers/docxParser.d.ts +1 -0
  44. package/features/ai/TextExtractor/parsers/docxParser.js +111 -0
  45. package/features/ai/TextExtractor/parsers/docxParser.js.map +1 -0
  46. package/features/ai/abstractions.d.ts +102 -7
  47. package/features/ai/abstractions.js +6 -2
  48. package/features/ai/abstractions.js.map +1 -1
  49. package/features/ai/events.d.ts +59 -0
  50. package/features/ai/events.js +41 -0
  51. package/features/ai/events.js.map +1 -0
  52. package/features/ai/feature.js +12 -0
  53. package/features/ai/feature.js.map +1 -1
  54. package/features/ai/index.d.ts +5 -3
  55. package/features/ai/index.js +3 -1
  56. package/features/dateFormatter/DefaultDateFormatter.d.ts +15 -0
  57. package/features/dateFormatter/DefaultDateFormatter.js +20 -0
  58. package/features/dateFormatter/DefaultDateFormatter.js.map +1 -0
  59. package/features/dateFormatter/abstractions.d.ts +13 -0
  60. package/features/dateFormatter/abstractions.js +5 -0
  61. package/features/dateFormatter/abstractions.js.map +1 -0
  62. package/features/dateFormatter/feature.d.ts +4 -0
  63. package/features/dateFormatter/feature.js +11 -0
  64. package/features/dateFormatter/feature.js.map +1 -0
  65. package/features/dateFormatter/index.d.ts +3 -0
  66. package/features/dateFormatter/index.js +2 -0
  67. package/features/debugger/Debugger.d.ts +30 -0
  68. package/features/debugger/Debugger.js +142 -0
  69. package/features/debugger/Debugger.js.map +1 -0
  70. package/features/debugger/DebuggerRouteDecorator.d.ts +45 -0
  71. package/features/debugger/DebuggerRouteDecorator.js +102 -0
  72. package/features/debugger/DebuggerRouteDecorator.js.map +1 -0
  73. package/features/debugger/GraphQLDebuggerTransport.d.ts +28 -0
  74. package/features/debugger/GraphQLDebuggerTransport.js +45 -0
  75. package/features/debugger/GraphQLDebuggerTransport.js.map +1 -0
  76. package/features/debugger/__tests__/matchNamespace.test.d.ts +1 -0
  77. package/features/debugger/__tests__/matchNamespace.test.js +68 -0
  78. package/features/debugger/__tests__/matchNamespace.test.js.map +1 -0
  79. package/features/debugger/__tests__/serialize.test.d.ts +1 -0
  80. package/features/debugger/__tests__/serialize.test.js +220 -0
  81. package/features/debugger/__tests__/serialize.test.js.map +1 -0
  82. package/features/debugger/abstractions.d.ts +100 -0
  83. package/features/debugger/abstractions.js +6 -0
  84. package/features/debugger/abstractions.js.map +1 -0
  85. package/features/debugger/feature.d.ts +5 -0
  86. package/features/debugger/feature.js +15 -0
  87. package/features/debugger/feature.js.map +1 -0
  88. package/features/debugger/index.d.ts +12 -0
  89. package/features/debugger/index.js +7 -0
  90. package/features/debugger/limits.d.ts +18 -0
  91. package/features/debugger/limits.js +11 -0
  92. package/features/debugger/limits.js.map +1 -0
  93. package/features/debugger/matchNamespace.d.ts +14 -0
  94. package/features/debugger/matchNamespace.js +35 -0
  95. package/features/debugger/matchNamespace.js.map +1 -0
  96. package/features/debugger/parseNamespaceHeader.d.ts +7 -0
  97. package/features/debugger/parseNamespaceHeader.js +16 -0
  98. package/features/debugger/parseNamespaceHeader.js.map +1 -0
  99. package/features/debugger/permissions.d.ts +14 -0
  100. package/features/debugger/permissions.js +8 -0
  101. package/features/debugger/permissions.js.map +1 -0
  102. package/features/debugger/permissionsSchema.d.ts +17 -0
  103. package/features/debugger/permissionsSchema.js +18 -0
  104. package/features/debugger/permissionsSchema.js.map +1 -0
  105. package/features/debugger/serialize.d.ts +11 -0
  106. package/features/debugger/serialize.js +121 -0
  107. package/features/debugger/serialize.js.map +1 -0
  108. package/features/encryption/BuildParamsEncryptionConfig.d.ts +13 -0
  109. package/features/encryption/BuildParamsEncryptionConfig.js +19 -0
  110. package/features/encryption/BuildParamsEncryptionConfig.js.map +1 -0
  111. package/features/encryption/EncryptionKeyCacheFeature.d.ts +8 -0
  112. package/features/encryption/EncryptionKeyCacheFeature.js +11 -0
  113. package/features/encryption/EncryptionKeyCacheFeature.js.map +1 -0
  114. package/features/encryption/EncryptionService.d.ts +3 -2
  115. package/features/encryption/EncryptionService.js +15 -13
  116. package/features/encryption/EncryptionService.js.map +1 -1
  117. package/features/encryption/MemoryEncryptionKeyCache.d.ts +13 -0
  118. package/features/encryption/MemoryEncryptionKeyCache.js +26 -0
  119. package/features/encryption/MemoryEncryptionKeyCache.js.map +1 -0
  120. package/features/encryption/abstractions.d.ts +26 -0
  121. package/features/encryption/abstractions.js +3 -1
  122. package/features/encryption/abstractions.js.map +1 -1
  123. package/features/encryption/feature.js +2 -0
  124. package/features/encryption/feature.js.map +1 -1
  125. package/features/encryption/index.d.ts +3 -0
  126. package/features/encryption/index.js +3 -1
  127. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.d.ts +13 -0
  128. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js +61 -0
  129. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js.map +1 -0
  130. package/features/hashing/BuildParamsHashingConfig.d.ts +11 -0
  131. package/features/hashing/BuildParamsHashingConfig.js +18 -0
  132. package/features/hashing/BuildParamsHashingConfig.js.map +1 -0
  133. package/features/hashing/ScryptHasher.d.ts +2 -2
  134. package/features/hashing/ScryptHasher.js +6 -8
  135. package/features/hashing/ScryptHasher.js.map +1 -1
  136. package/features/hashing/abstractions.d.ts +15 -0
  137. package/features/hashing/abstractions.js +2 -1
  138. package/features/hashing/abstractions.js.map +1 -1
  139. package/features/hashing/feature.js +2 -0
  140. package/features/hashing/feature.js.map +1 -1
  141. package/features/hashing/index.d.ts +1 -0
  142. package/features/hashing/index.js +1 -1
  143. package/features/httpClient/HttpClient.d.ts +7 -0
  144. package/features/httpClient/HttpClient.js +72 -0
  145. package/features/httpClient/HttpClient.js.map +1 -0
  146. package/features/httpClient/HttpRequestError.d.ts +10 -0
  147. package/features/httpClient/HttpRequestError.js +13 -0
  148. package/features/httpClient/HttpRequestError.js.map +1 -0
  149. package/features/httpClient/HttpStatusError.d.ts +12 -0
  150. package/features/httpClient/HttpStatusError.js +12 -0
  151. package/features/httpClient/HttpStatusError.js.map +1 -0
  152. package/features/httpClient/abstractions.d.ts +32 -0
  153. package/features/httpClient/abstractions.js +5 -0
  154. package/features/httpClient/abstractions.js.map +1 -0
  155. package/features/httpClient/feature.d.ts +4 -0
  156. package/features/httpClient/feature.js +11 -0
  157. package/features/httpClient/feature.js.map +1 -0
  158. package/features/httpClient/index.d.ts +3 -0
  159. package/features/httpClient/index.js +3 -0
  160. package/features/keyValueStore/GlobalKeyValueStore.d.ts +9 -3
  161. package/features/keyValueStore/GlobalKeyValueStore.js +12 -2
  162. package/features/keyValueStore/GlobalKeyValueStore.js.map +1 -1
  163. package/features/keyValueStore/KeyValueStore.d.ts +6 -2
  164. package/features/keyValueStore/KeyValueStore.js +13 -3
  165. package/features/keyValueStore/KeyValueStore.js.map +1 -1
  166. package/features/keyValueStore/KeyValueStoreRepository.d.ts +8 -2
  167. package/features/keyValueStore/KeyValueStoreRepository.js +82 -4
  168. package/features/keyValueStore/KeyValueStoreRepository.js.map +1 -1
  169. package/features/keyValueStore/abstractions.d.ts +132 -14
  170. package/features/keyValueStore/abstractions.js.map +1 -1
  171. package/features/keyValueStore/errors.d.ts +29 -0
  172. package/features/keyValueStore/errors.js +49 -1
  173. package/features/keyValueStore/errors.js.map +1 -1
  174. package/features/keyValueStore/index.d.ts +4 -1
  175. package/features/keyValueStore/index.js +1 -1
  176. package/features/logger/NullLogger.d.ts +10 -0
  177. package/features/logger/NullLogger.js +12 -0
  178. package/features/logger/NullLogger.js.map +1 -0
  179. package/features/logger/index.d.ts +1 -0
  180. package/features/logger/index.js +1 -0
  181. package/features/publicUrls/NullPublicUrls.d.ts +11 -0
  182. package/features/publicUrls/NullPublicUrls.js +17 -0
  183. package/features/publicUrls/NullPublicUrls.js.map +1 -0
  184. package/features/publicUrls/PublicUrl.d.ts +24 -0
  185. package/features/publicUrls/PublicUrl.js +43 -0
  186. package/features/publicUrls/PublicUrl.js.map +1 -0
  187. package/features/publicUrls/__tests__/PublicUrl.test.d.ts +1 -0
  188. package/features/publicUrls/__tests__/PublicUrl.test.js +38 -0
  189. package/features/publicUrls/__tests__/PublicUrl.test.js.map +1 -0
  190. package/features/publicUrls/__tests__/PublicUrls.test.d.ts +1 -0
  191. package/features/publicUrls/__tests__/PublicUrls.test.js +14 -0
  192. package/features/publicUrls/__tests__/PublicUrls.test.js.map +1 -0
  193. package/features/publicUrls/abstractions.d.ts +27 -0
  194. package/features/publicUrls/abstractions.js +5 -0
  195. package/features/publicUrls/abstractions.js.map +1 -0
  196. package/features/publicUrls/feature.d.ts +8 -0
  197. package/features/publicUrls/feature.js +11 -0
  198. package/features/publicUrls/feature.js.map +1 -0
  199. package/features/publicUrls/index.d.ts +3 -0
  200. package/features/publicUrls/index.js +3 -0
  201. package/features/requestContext/RawAssumePermissions.d.ts +14 -0
  202. package/features/requestContext/RawAssumePermissions.js +19 -0
  203. package/features/requestContext/RawAssumePermissions.js.map +1 -0
  204. package/features/requestContext/abstractions.d.ts +22 -0
  205. package/features/requestContext/abstractions.js +2 -1
  206. package/features/requestContext/abstractions.js.map +1 -1
  207. package/features/requestContext/extractAssumePermissions.d.ts +14 -0
  208. package/features/requestContext/extractAssumePermissions.js +32 -0
  209. package/features/requestContext/extractAssumePermissions.js.map +1 -0
  210. package/features/requestContext/feature.d.ts +2 -1
  211. package/features/requestContext/feature.js +2 -0
  212. package/features/requestContext/feature.js.map +1 -1
  213. package/features/requestContext/index.d.ts +3 -1
  214. package/features/requestContext/index.js +2 -1
  215. package/features/security/IdentityContext/IdentityContext.d.ts +8 -4
  216. package/features/security/IdentityContext/IdentityContext.js +28 -11
  217. package/features/security/IdentityContext/IdentityContext.js.map +1 -1
  218. package/features/security/IdentityContext/abstractions.d.ts +6 -1
  219. package/features/security/IdentityContext/abstractions.js.map +1 -1
  220. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js +11 -6
  221. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js.map +1 -1
  222. package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.d.ts +1 -1
  223. package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.js.map +1 -1
  224. package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.d.ts +1 -3
  225. package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.js.map +1 -1
  226. package/features/security/apiKeys/GetApiKeyBySlug/abstractions.d.ts +1 -1
  227. package/features/security/apiKeys/GetApiKeyBySlug/abstractions.js.map +1 -1
  228. package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.d.ts +1 -3
  229. package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.js.map +1 -1
  230. package/features/security/apiKeys/GetApiKeyByToken/abstractions.d.ts +1 -1
  231. package/features/security/apiKeys/GetApiKeyByToken/abstractions.js.map +1 -1
  232. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js +9 -3
  233. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js.map +1 -1
  234. package/features/security/apiKeys/feature.js +7 -2
  235. package/features/security/apiKeys/feature.js.map +1 -1
  236. package/features/security/apiKeys/shared/ApiKeyProvider.d.ts +3 -5
  237. package/features/security/apiKeys/shared/ApiKeyProvider.js +6 -21
  238. package/features/security/apiKeys/shared/ApiKeyProvider.js.map +1 -1
  239. package/features/security/apiKeys/shared/ApiKeysRepository.d.ts +1 -0
  240. package/features/security/apiKeys/shared/ApiKeysRepository.js +19 -4
  241. package/features/security/apiKeys/shared/ApiKeysRepository.js.map +1 -1
  242. package/features/security/apiKeys/shared/generateToken.d.ts +1 -1
  243. package/features/security/apiKeys/shared/generateToken.js.map +1 -1
  244. package/features/security/apiKeys/shared/schemas.d.ts +2 -2
  245. package/features/security/apiKeys/shared/schemas.js +2 -2
  246. package/features/security/apiKeys/shared/schemas.js.map +1 -1
  247. package/features/security/apiKeys/shared/types.d.ts +1 -1
  248. package/features/security/authorization/AuthorizationContext/AuthorizationContext.d.ts +13 -3
  249. package/features/security/authorization/AuthorizationContext/AuthorizationContext.js +35 -22
  250. package/features/security/authorization/AuthorizationContext/AuthorizationContext.js.map +1 -1
  251. package/features/security/authorization/AuthorizationContext/abstractions.d.ts +2 -0
  252. package/features/security/authorization/AuthorizationContext/abstractions.js.map +1 -1
  253. package/features/security/authorization/AuthorizationContext/feature.js +6 -1
  254. package/features/security/authorization/AuthorizationContext/feature.js.map +1 -1
  255. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.d.ts +30 -0
  256. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js +60 -0
  257. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js.map +1 -0
  258. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.d.ts +3 -3
  259. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js +5 -5
  260. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js.map +1 -1
  261. package/features/security/authorization/GroupsTeamsAuthorizer/feature.js +2 -0
  262. package/features/security/authorization/GroupsTeamsAuthorizer/feature.js.map +1 -1
  263. package/features/security/roles/CreateRole/CreateRoleUseCase.js +11 -6
  264. package/features/security/roles/CreateRole/CreateRoleUseCase.js.map +1 -1
  265. package/features/security/roles/CreateRole/schema.d.ts +1 -1
  266. package/features/security/roles/CreateRole/schema.js +1 -1
  267. package/features/security/roles/CreateRole/schema.js.map +1 -1
  268. package/features/security/roles/Installer/RolesInstaller.js +1 -0
  269. package/features/security/roles/Installer/RolesInstaller.js.map +1 -1
  270. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js +9 -3
  271. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js.map +1 -1
  272. package/features/security/roles/UpdateRole/schema.d.ts +1 -1
  273. package/features/security/roles/UpdateRole/schema.js +1 -1
  274. package/features/security/roles/UpdateRole/schema.js.map +1 -1
  275. package/features/security/shared/description.d.ts +4 -0
  276. package/features/security/shared/description.js +7 -0
  277. package/features/security/shared/description.js.map +1 -0
  278. package/features/security/shared/index.d.ts +1 -0
  279. package/features/security/shared/index.js +1 -0
  280. package/features/security/teams/CreateTeam/CreateTeamUseCase.d.ts +3 -1
  281. package/features/security/teams/CreateTeam/CreateTeamUseCase.js +20 -8
  282. package/features/security/teams/CreateTeam/CreateTeamUseCase.js.map +1 -1
  283. package/features/security/teams/CreateTeam/schema.d.ts +1 -1
  284. package/features/security/teams/CreateTeam/schema.js +1 -1
  285. package/features/security/teams/CreateTeam/schema.js.map +1 -1
  286. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.d.ts +3 -1
  287. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js +20 -5
  288. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js.map +1 -1
  289. package/features/security/teams/UpdateTeam/schema.d.ts +1 -1
  290. package/features/security/teams/UpdateTeam/schema.js +1 -1
  291. package/features/security/teams/UpdateTeam/schema.js.map +1 -1
  292. package/features/security/teams/shared/resolveRoleIdentifiers.d.ts +17 -0
  293. package/features/security/teams/shared/resolveRoleIdentifiers.js +32 -0
  294. package/features/security/teams/shared/resolveRoleIdentifiers.js.map +1 -0
  295. package/features/slugify/DefaultSlugify.d.ts +8 -0
  296. package/features/slugify/DefaultSlugify.js +20 -0
  297. package/features/slugify/DefaultSlugify.js.map +1 -0
  298. package/features/slugify/abstractions.d.ts +12 -0
  299. package/features/slugify/abstractions.js +5 -0
  300. package/features/slugify/abstractions.js.map +1 -0
  301. package/features/{logger → slugify}/feature.d.ts +1 -1
  302. package/features/slugify/feature.js +11 -0
  303. package/features/slugify/feature.js.map +1 -0
  304. package/features/slugify/index.d.ts +3 -0
  305. package/features/slugify/index.js +2 -0
  306. package/features/stringFormatter/DefaultStringFormatter.d.ts +17 -0
  307. package/features/stringFormatter/DefaultStringFormatter.js +19 -0
  308. package/features/stringFormatter/DefaultStringFormatter.js.map +1 -0
  309. package/features/stringFormatter/abstractions.d.ts +11 -0
  310. package/features/stringFormatter/abstractions.js +5 -0
  311. package/features/stringFormatter/abstractions.js.map +1 -0
  312. package/features/stringFormatter/feature.d.ts +4 -0
  313. package/features/stringFormatter/feature.js +13 -0
  314. package/features/stringFormatter/feature.js.map +1 -0
  315. package/features/stringFormatter/index.d.ts +3 -0
  316. package/features/stringFormatter/index.js +2 -0
  317. package/features/task/TaskDefinition/abstractions.d.ts +69 -4
  318. package/features/task/TaskDefinition/abstractions.js +2 -1
  319. package/features/task/TaskDefinition/abstractions.js.map +1 -1
  320. package/features/tenancy/TenantContext/TenantContext.d.ts +5 -1
  321. package/features/tenancy/TenantContext/TenantContext.js +31 -23
  322. package/features/tenancy/TenantContext/TenantContext.js.map +1 -1
  323. package/features/users/shared/loaders.js.map +1 -1
  324. package/features/users/shared/types.d.ts +9 -7
  325. package/features/wcp/WcpContext/WcpContext.d.ts +11 -0
  326. package/features/wcp/WcpContext/WcpContext.js +33 -0
  327. package/features/wcp/WcpContext/WcpContext.js.map +1 -1
  328. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +14 -60
  329. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +77 -25
  330. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
  331. package/features/wcp/WcpFeature.js +2 -0
  332. package/features/wcp/WcpFeature.js.map +1 -1
  333. package/features/wcp/WcpLicenseLoader.d.ts +25 -0
  334. package/features/wcp/WcpLicenseLoader.js +58 -0
  335. package/features/wcp/WcpLicenseLoader.js.map +1 -0
  336. package/features/wcp/WcpLicenseProvider.d.ts +6 -14
  337. package/features/wcp/WcpLicenseProvider.js +3 -7
  338. package/features/wcp/WcpLicenseProvider.js.map +1 -1
  339. package/features/wcp/resolveWcpProjectEnvironment.d.ts +9 -0
  340. package/features/wcp/resolveWcpProjectEnvironment.js +23 -0
  341. package/features/wcp/resolveWcpProjectEnvironment.js.map +1 -0
  342. package/graphql/ApiCoreSchemaFactory.d.ts +1 -0
  343. package/graphql/ApiCoreSchemaFactory.js +7 -1
  344. package/graphql/ApiCoreSchemaFactory.js.map +1 -1
  345. package/graphql/featureFlags/FeatureFlagsSchemaFactory.d.ts +10 -0
  346. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js +53 -0
  347. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js.map +1 -0
  348. package/graphql/security/SecuritySchemaFactory.d.ts +1 -0
  349. package/graphql/security/SecuritySchemaFactory.js +4 -0
  350. package/graphql/security/SecuritySchemaFactory.js.map +1 -1
  351. package/graphql/system/SystemSchemaFactory.d.ts +1 -0
  352. package/graphql/system/SystemSchemaFactory.js +4 -0
  353. package/graphql/system/SystemSchemaFactory.js.map +1 -1
  354. package/graphql/users/UsersSchemaFactory.d.ts +1 -0
  355. package/graphql/users/UsersSchemaFactory.js +4 -0
  356. package/graphql/users/UsersSchemaFactory.js.map +1 -1
  357. package/graphql/wcp/WcpSchemaFactory.d.ts +1 -0
  358. package/graphql/wcp/WcpSchemaFactory.js +6 -0
  359. package/graphql/wcp/WcpSchemaFactory.js.map +1 -1
  360. package/idp/JwksCache.d.ts +14 -3
  361. package/idp/JwksCache.js +97 -17
  362. package/idp/JwksCache.js.map +1 -1
  363. package/idp/JwksStoreFeature.d.ts +8 -0
  364. package/idp/JwksStoreFeature.js +11 -0
  365. package/idp/JwksStoreFeature.js.map +1 -0
  366. package/idp/MemoryJwksStore.d.ts +14 -0
  367. package/idp/MemoryJwksStore.js +21 -0
  368. package/idp/MemoryJwksStore.js.map +1 -0
  369. package/idp/OidcJwtIdentityProvider.js +5 -1
  370. package/idp/OidcJwtIdentityProvider.js.map +1 -1
  371. package/idp/abstractions.d.ts +24 -0
  372. package/idp/abstractions.js +2 -1
  373. package/idp/abstractions.js.map +1 -1
  374. package/idp/feature.js +1 -2
  375. package/idp/feature.js.map +1 -1
  376. package/idp/index.d.ts +1 -0
  377. package/idp/index.js +1 -0
  378. package/package.json +22 -22
  379. package/testing/environment.d.ts +14 -0
  380. package/testing/environment.js +18 -0
  381. package/testing/environment.js.map +1 -0
  382. package/types/security.d.ts +1 -1
  383. package/types/users.d.ts +2 -3
  384. package/features/logger/LoggerService.d.ts +0 -14
  385. package/features/logger/LoggerService.js +0 -48
  386. package/features/logger/LoggerService.js.map +0 -1
  387. package/features/logger/feature.js +0 -11
  388. package/features/logger/feature.js.map +0 -1
  389. package/features/wcp/loadWcpLicense.d.ts +0 -2
  390. package/features/wcp/loadWcpLicense.js +0 -51
  391. package/features/wcp/loadWcpLicense.js.map +0 -1
@@ -3,15 +3,19 @@ import { Result, createImplementation } from "@webiny/feature/api";
3
3
  import { EventPublisher } from "../../../eventPublisher/index.js";
4
4
  import { CreateTeam } from "./abstractions.js";
5
5
  import { TeamsRepository } from "../shared/abstractions.js";
6
+ import { RolesRepository } from "../../roles/shared/abstractions.js";
6
7
  import { IdentityContext } from "../../IdentityContext/abstractions.js";
7
8
  import { createTeamValidation } from "./schema.js";
8
9
  import { TeamAfterCreateEvent, TeamBeforeCreateEvent } from "./events.js";
9
10
  import { NotAuthorizedError, TeamExistsError, TeamValidationError } from "../shared/errors.js";
11
+ import { descriptionOnCreate } from "../../shared/description.js";
12
+ import { resolveRoleIdentifiers } from "../shared/resolveRoleIdentifiers.js";
10
13
  class CreateTeamUseCase {
11
- constructor(identityContext, eventPublisher, repository){
14
+ constructor(identityContext, eventPublisher, repository, rolesRepository){
12
15
  this.identityContext = identityContext;
13
16
  this.eventPublisher = eventPublisher;
14
17
  this.repository = repository;
18
+ this.rolesRepository = rolesRepository;
15
19
  }
16
20
  async execute(input) {
17
21
  const hasPermission = await this.identityContext.getPermission("security.team");
@@ -24,12 +28,19 @@ class CreateTeamUseCase {
24
28
  slug: data.slug
25
29
  });
26
30
  if (existingTeamResult.isOk()) return Result.fail(new TeamExistsError(data.slug));
31
+ const roleIdsResult = await resolveRoleIdentifiers(this.rolesRepository, data.roles);
32
+ if (roleIdsResult.isFail()) return Result.fail(roleIdsResult.error);
33
+ const createInput = {
34
+ ...data,
35
+ description: descriptionOnCreate(data.description),
36
+ roles: roleIdsResult.value
37
+ };
27
38
  const team = {
28
39
  id: mdbid(),
29
- name: data.name,
30
- slug: data.slug,
31
- description: data.description,
32
- roles: data.roles,
40
+ name: createInput.name,
41
+ slug: createInput.slug,
42
+ description: descriptionOnCreate(createInput.description),
43
+ roles: createInput.roles,
33
44
  system: input.system || false,
34
45
  createdOn: new Date().toISOString(),
35
46
  createdBy: {
@@ -41,13 +52,13 @@ class CreateTeamUseCase {
41
52
  };
42
53
  await this.eventPublisher.publish(new TeamBeforeCreateEvent({
43
54
  team,
44
- input: validation.data
55
+ input: createInput
45
56
  }));
46
57
  const result = await this.repository.create(team);
47
58
  if (result.isFail()) return Result.fail(result.error);
48
59
  await this.eventPublisher.publish(new TeamAfterCreateEvent({
49
60
  team,
50
- input: validation.data
61
+ input: createInput
51
62
  }));
52
63
  return Result.ok(team);
53
64
  }
@@ -58,7 +69,8 @@ const CreateTeamUseCaseImpl = createImplementation({
58
69
  dependencies: [
59
70
  IdentityContext,
60
71
  EventPublisher,
61
- TeamsRepository
72
+ TeamsRepository,
73
+ RolesRepository
62
74
  ]
63
75
  });
64
76
  export { CreateTeamUseCase, CreateTeamUseCaseImpl };
@@ -1 +1 @@
1
- {"version":3,"file":"features/security/teams/CreateTeam/CreateTeamUseCase.js","sources":["../../../../../src/features/security/teams/CreateTeam/CreateTeamUseCase.ts"],"sourcesContent":["import { mdbid } from \"@webiny/utils\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { EventPublisher } from \"~/features/eventPublisher/index.js\";\nimport { CreateTeam } from \"./abstractions.js\";\nimport { TeamsRepository } from \"../shared/abstractions.js\";\nimport { IdentityContext } from \"../../IdentityContext/abstractions.js\";\nimport { createTeamValidation } from \"./schema.js\";\nimport { TeamBeforeCreateEvent, TeamAfterCreateEvent } from \"./events.js\";\nimport type { Team, CreateTeamInput } from \"../shared/types.js\";\nimport { NotAuthorizedError, TeamExistsError, TeamValidationError } from \"../shared/errors.js\";\n\nexport class CreateTeamUseCase implements CreateTeam.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private eventPublisher: EventPublisher.Interface,\n private repository: TeamsRepository.Interface\n ) {}\n\n async execute(input: CreateTeamInput): Promise<Result<Team, CreateTeam.Error>> {\n const hasPermission = await this.identityContext.getPermission(\"security.team\");\n\n if (!hasPermission) {\n return Result.fail(new NotAuthorizedError());\n }\n\n const validation = createTeamValidation.safeParse(input);\n if (!validation.success) {\n return Result.fail(new TeamValidationError(validation.error.issues[0].message));\n }\n\n const identity = this.identityContext.getIdentity();\n const data = validation.data;\n\n // Check if team with same slug already exists\n const existingTeamResult = await this.repository.get({ slug: data.slug });\n if (existingTeamResult.isOk()) {\n return Result.fail(new TeamExistsError(data.slug));\n }\n\n const team: Team = {\n id: mdbid(),\n name: data.name,\n slug: data.slug,\n description: data.description,\n roles: data.roles,\n system: input.system || false,\n createdOn: new Date().toISOString(),\n createdBy: {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n },\n plugin: false\n };\n\n await this.eventPublisher.publish(\n new TeamBeforeCreateEvent({ team, input: validation.data })\n );\n\n const result = await this.repository.create(team);\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n await this.eventPublisher.publish(\n new TeamAfterCreateEvent({ team, input: validation.data })\n );\n\n return Result.ok(team);\n }\n}\n\nexport const CreateTeamUseCaseImpl = createImplementation({\n abstraction: CreateTeam,\n implementation: CreateTeamUseCase,\n dependencies: [IdentityContext, EventPublisher, TeamsRepository]\n});\n"],"names":["CreateTeamUseCase","identityContext","eventPublisher","repository","input","hasPermission","Result","NotAuthorizedError","validation","createTeamValidation","TeamValidationError","identity","data","existingTeamResult","TeamExistsError","team","mdbid","Date","TeamBeforeCreateEvent","result","TeamAfterCreateEvent","CreateTeamUseCaseImpl","createImplementation","CreateTeam","IdentityContext","EventPublisher","TeamsRepository"],"mappings":";;;;;;;;;AAYO,MAAMA;IACT,YACYC,eAA0C,EAC1CC,cAAwC,EACxCC,UAAqC,CAC/C;aAHUF,eAAe,GAAfA;aACAC,cAAc,GAAdA;aACAC,UAAU,GAAVA;IACT;IAEH,MAAM,QAAQC,KAAsB,EAA2C;QAC3E,MAAMC,gBAAgB,MAAM,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC;QAE/D,IAAI,CAACA,eACD,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAG3B,MAAMC,aAAaC,qBAAqB,SAAS,CAACL;QAClD,IAAI,CAACI,WAAW,OAAO,EACnB,OAAOF,OAAO,IAAI,CAAC,IAAII,oBAAoBF,WAAW,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO;QAGjF,MAAMG,WAAW,IAAI,CAAC,eAAe,CAAC,WAAW;QACjD,MAAMC,OAAOJ,WAAW,IAAI;QAG5B,MAAMK,qBAAqB,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,MAAMD,KAAK,IAAI;QAAC;QACvE,IAAIC,mBAAmB,IAAI,IACvB,OAAOP,OAAO,IAAI,CAAC,IAAIQ,gBAAgBF,KAAK,IAAI;QAGpD,MAAMG,OAAa;YACf,IAAIC;YACJ,MAAMJ,KAAK,IAAI;YACf,MAAMA,KAAK,IAAI;YACf,aAAaA,KAAK,WAAW;YAC7B,OAAOA,KAAK,KAAK;YACjB,QAAQR,MAAM,MAAM,IAAI;YACxB,WAAW,IAAIa,OAAO,WAAW;YACjC,WAAW;gBACP,IAAIN,SAAS,EAAE;gBACf,aAAaA,SAAS,WAAW;gBACjC,MAAMA,SAAS,IAAI;YACvB;YACA,QAAQ;QACZ;QAEA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIO,sBAAsB;YAAEH;YAAM,OAAOP,WAAW,IAAI;QAAC;QAG7D,MAAMW,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAACJ;QAE5C,IAAII,OAAO,MAAM,IACb,OAAOb,OAAO,IAAI,CAACa,OAAO,KAAK;QAGnC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIC,qBAAqB;YAAEL;YAAM,OAAOP,WAAW,IAAI;QAAC;QAG5D,OAAOF,OAAO,EAAE,CAACS;IACrB;AACJ;AAEO,MAAMM,wBAAwBC,qBAAqB;IACtD,aAAaC;IACb,gBAAgBvB;IAChB,cAAc;QAACwB;QAAiBC;QAAgBC;KAAgB;AACpE"}
1
+ {"version":3,"file":"features/security/teams/CreateTeam/CreateTeamUseCase.js","sources":["../../../../../src/features/security/teams/CreateTeam/CreateTeamUseCase.ts"],"sourcesContent":["import { mdbid } from \"@webiny/utils\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { EventPublisher } from \"~/features/eventPublisher/index.js\";\nimport { CreateTeam } from \"./abstractions.js\";\nimport { TeamsRepository } from \"../shared/abstractions.js\";\nimport { RolesRepository } from \"../../roles/shared/abstractions.js\";\nimport { IdentityContext } from \"../../IdentityContext/abstractions.js\";\nimport { createTeamValidation } from \"./schema.js\";\nimport { TeamBeforeCreateEvent, TeamAfterCreateEvent } from \"./events.js\";\nimport type { Team, CreateTeamInput } from \"../shared/types.js\";\nimport { NotAuthorizedError, TeamExistsError, TeamValidationError } from \"../shared/errors.js\";\nimport { descriptionOnCreate } from \"../../shared/description.js\";\nimport { resolveRoleIdentifiers } from \"../shared/resolveRoleIdentifiers.js\";\n\nexport class CreateTeamUseCase implements CreateTeam.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private eventPublisher: EventPublisher.Interface,\n private repository: TeamsRepository.Interface,\n private rolesRepository: RolesRepository.Interface\n ) {}\n\n async execute(input: CreateTeamInput): Promise<Result<Team, CreateTeam.Error>> {\n const hasPermission = await this.identityContext.getPermission(\"security.team\");\n\n if (!hasPermission) {\n return Result.fail(new NotAuthorizedError());\n }\n\n const validation = createTeamValidation.safeParse(input);\n if (!validation.success) {\n return Result.fail(new TeamValidationError(validation.error.issues[0].message));\n }\n\n const identity = this.identityContext.getIdentity();\n const data = validation.data;\n\n // Check if team with same slug already exists\n const existingTeamResult = await this.repository.get({ slug: data.slug });\n if (existingTeamResult.isOk()) {\n return Result.fail(new TeamExistsError(data.slug));\n }\n\n // A slug here would be stored verbatim and then match no role, leaving a team that grants\n // nothing. Resolved before the entity is built so the events carry the stored IDs.\n const roleIdsResult = await resolveRoleIdentifiers(this.rolesRepository, data.roles);\n\n if (roleIdsResult.isFail()) {\n return Result.fail(roleIdsResult.error);\n }\n\n // Normalised up front so that null reaches neither the entity nor the published events.\n const createInput: CreateTeamInput = {\n ...data,\n description: descriptionOnCreate(data.description),\n roles: roleIdsResult.value\n };\n\n const team: Team = {\n id: mdbid(),\n name: createInput.name,\n slug: createInput.slug,\n description: descriptionOnCreate(createInput.description),\n roles: createInput.roles,\n system: input.system || false,\n createdOn: new Date().toISOString(),\n createdBy: {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n },\n plugin: false\n };\n\n await this.eventPublisher.publish(new TeamBeforeCreateEvent({ team, input: createInput }));\n\n const result = await this.repository.create(team);\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n await this.eventPublisher.publish(new TeamAfterCreateEvent({ team, input: createInput }));\n\n return Result.ok(team);\n }\n}\n\nexport const CreateTeamUseCaseImpl = createImplementation({\n abstraction: CreateTeam,\n implementation: CreateTeamUseCase,\n dependencies: [IdentityContext, EventPublisher, TeamsRepository, RolesRepository]\n});\n"],"names":["CreateTeamUseCase","identityContext","eventPublisher","repository","rolesRepository","input","hasPermission","Result","NotAuthorizedError","validation","createTeamValidation","TeamValidationError","identity","data","existingTeamResult","TeamExistsError","roleIdsResult","resolveRoleIdentifiers","createInput","descriptionOnCreate","team","mdbid","Date","TeamBeforeCreateEvent","result","TeamAfterCreateEvent","CreateTeamUseCaseImpl","createImplementation","CreateTeam","IdentityContext","EventPublisher","TeamsRepository","RolesRepository"],"mappings":";;;;;;;;;;;;AAeO,MAAMA;IACT,YACYC,eAA0C,EAC1CC,cAAwC,EACxCC,UAAqC,EACrCC,eAA0C,CACpD;aAJUH,eAAe,GAAfA;aACAC,cAAc,GAAdA;aACAC,UAAU,GAAVA;aACAC,eAAe,GAAfA;IACT;IAEH,MAAM,QAAQC,KAAsB,EAA2C;QAC3E,MAAMC,gBAAgB,MAAM,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC;QAE/D,IAAI,CAACA,eACD,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAG3B,MAAMC,aAAaC,qBAAqB,SAAS,CAACL;QAClD,IAAI,CAACI,WAAW,OAAO,EACnB,OAAOF,OAAO,IAAI,CAAC,IAAII,oBAAoBF,WAAW,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO;QAGjF,MAAMG,WAAW,IAAI,CAAC,eAAe,CAAC,WAAW;QACjD,MAAMC,OAAOJ,WAAW,IAAI;QAG5B,MAAMK,qBAAqB,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,MAAMD,KAAK,IAAI;QAAC;QACvE,IAAIC,mBAAmB,IAAI,IACvB,OAAOP,OAAO,IAAI,CAAC,IAAIQ,gBAAgBF,KAAK,IAAI;QAKpD,MAAMG,gBAAgB,MAAMC,uBAAuB,IAAI,CAAC,eAAe,EAAEJ,KAAK,KAAK;QAEnF,IAAIG,cAAc,MAAM,IACpB,OAAOT,OAAO,IAAI,CAACS,cAAc,KAAK;QAI1C,MAAME,cAA+B;YACjC,GAAGL,IAAI;YACP,aAAaM,oBAAoBN,KAAK,WAAW;YACjD,OAAOG,cAAc,KAAK;QAC9B;QAEA,MAAMI,OAAa;YACf,IAAIC;YACJ,MAAMH,YAAY,IAAI;YACtB,MAAMA,YAAY,IAAI;YACtB,aAAaC,oBAAoBD,YAAY,WAAW;YACxD,OAAOA,YAAY,KAAK;YACxB,QAAQb,MAAM,MAAM,IAAI;YACxB,WAAW,IAAIiB,OAAO,WAAW;YACjC,WAAW;gBACP,IAAIV,SAAS,EAAE;gBACf,aAAaA,SAAS,WAAW;gBACjC,MAAMA,SAAS,IAAI;YACvB;YACA,QAAQ;QACZ;QAEA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAIW,sBAAsB;YAAEH;YAAM,OAAOF;QAAY;QAEvF,MAAMM,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAACJ;QAE5C,IAAII,OAAO,MAAM,IACb,OAAOjB,OAAO,IAAI,CAACiB,OAAO,KAAK;QAGnC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAIC,qBAAqB;YAAEL;YAAM,OAAOF;QAAY;QAEtF,OAAOX,OAAO,EAAE,CAACa;IACrB;AACJ;AAEO,MAAMM,wBAAwBC,qBAAqB;IACtD,aAAaC;IACb,gBAAgB5B;IAChB,cAAc;QAAC6B;QAAiBC;QAAgBC;QAAiBC;KAAgB;AACrF"}
@@ -2,6 +2,6 @@ import { z } from "zod";
2
2
  export declare const createTeamValidation: z.ZodObject<{
3
3
  name: z.ZodString;
4
4
  slug: z.ZodString;
5
- description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
5
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
6
6
  roles: z.ZodArray<z.ZodString>;
7
7
  }, z.core.$strip>;
@@ -2,7 +2,7 @@ import { z } from "zod";
2
2
  const createTeamValidation = z.object({
3
3
  name: z.string().min(3),
4
4
  slug: z.string().min(3),
5
- description: z.string().max(500).optional().default(""),
5
+ description: z.string().max(500).nullish(),
6
6
  roles: z.array(z.string())
7
7
  });
8
8
  export { createTeamValidation };
@@ -1 +1 @@
1
- {"version":3,"file":"features/security/teams/CreateTeam/schema.js","sources":["../../../../../src/features/security/teams/CreateTeam/schema.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const createTeamValidation = z.object({\n name: z.string().min(3),\n slug: z.string().min(3),\n description: z.string().max(500).optional().default(\"\"),\n roles: z.array(z.string())\n});\n"],"names":["createTeamValidation","z"],"mappings":";AAEO,MAAMA,uBAAuBC,EAAE,MAAM,CAAC;IACzC,MAAMA,EAAE,MAAM,GAAG,GAAG,CAAC;IACrB,MAAMA,EAAE,MAAM,GAAG,GAAG,CAAC;IACrB,aAAaA,EAAE,MAAM,GAAG,GAAG,CAAC,KAAK,QAAQ,GAAG,OAAO,CAAC;IACpD,OAAOA,EAAE,KAAK,CAACA,EAAE,MAAM;AAC3B"}
1
+ {"version":3,"file":"features/security/teams/CreateTeam/schema.js","sources":["../../../../../src/features/security/teams/CreateTeam/schema.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const createTeamValidation = z.object({\n name: z.string().min(3),\n slug: z.string().min(3),\n // Nullable in the GraphQL schema - see `descriptionOnCreate` for why this is `.nullish()`.\n description: z.string().max(500).nullish(),\n roles: z.array(z.string())\n});\n"],"names":["createTeamValidation","z"],"mappings":";AAEO,MAAMA,uBAAuBC,EAAE,MAAM,CAAC;IACzC,MAAMA,EAAE,MAAM,GAAG,GAAG,CAAC;IACrB,MAAMA,EAAE,MAAM,GAAG,GAAG,CAAC;IAErB,aAAaA,EAAE,MAAM,GAAG,GAAG,CAAC,KAAK,OAAO;IACxC,OAAOA,EAAE,KAAK,CAACA,EAAE,MAAM;AAC3B"}
@@ -1,6 +1,7 @@
1
1
  import { Result } from "@webiny/feature/api";
2
2
  import { UpdateTeam } from "./abstractions.js";
3
3
  import { TeamsRepository } from "../shared/abstractions.js";
4
+ import { RolesRepository } from "../../roles/shared/abstractions.js";
4
5
  import { IdentityContext } from "../../IdentityContext/abstractions.js";
5
6
  import { EventPublisher } from "../../../../features/eventPublisher/index.js";
6
7
  import type { Team, UpdateTeamInput } from "../shared/types.js";
@@ -8,7 +9,8 @@ export declare class UpdateTeamUseCase {
8
9
  private repository;
9
10
  private identityContext;
10
11
  private eventPublisher;
11
- constructor(repository: TeamsRepository.Interface, identityContext: IdentityContext.Interface, eventPublisher: EventPublisher.Interface);
12
+ private rolesRepository;
13
+ constructor(repository: TeamsRepository.Interface, identityContext: IdentityContext.Interface, eventPublisher: EventPublisher.Interface, rolesRepository: RolesRepository.Interface);
12
14
  execute(id: string, input: UpdateTeamInput): Promise<Result<Team, UpdateTeam.Error>>;
13
15
  }
14
16
  export declare const UpdateTeamUseCaseImpl: import("@webiny/di").Implementation<typeof UpdateTeamUseCase>;
@@ -1,16 +1,20 @@
1
1
  import { Result, createImplementation } from "@webiny/feature/api";
2
2
  import { UpdateTeam } from "./abstractions.js";
3
3
  import { TeamsRepository } from "../shared/abstractions.js";
4
+ import { RolesRepository } from "../../roles/shared/abstractions.js";
4
5
  import { IdentityContext } from "../../IdentityContext/abstractions.js";
5
6
  import { EventPublisher } from "../../../eventPublisher/index.js";
6
7
  import { updateTeamValidation } from "./schema.js";
7
8
  import { TeamAfterUpdateEvent, TeamBeforeUpdateEvent } from "./events.js";
9
+ import { descriptionOnUpdate } from "../../shared/description.js";
10
+ import { resolveRoleIdentifiers } from "../shared/resolveRoleIdentifiers.js";
8
11
  import { CannotUpdatePluginTeamsError, CannotUpdateSystemTeamsError, NotAuthorizedError, TeamValidationError } from "../shared/errors.js";
9
12
  class UpdateTeamUseCase {
10
- constructor(repository, identityContext, eventPublisher){
13
+ constructor(repository, identityContext, eventPublisher, rolesRepository){
11
14
  this.repository = repository;
12
15
  this.identityContext = identityContext;
13
16
  this.eventPublisher = eventPublisher;
17
+ this.rolesRepository = rolesRepository;
14
18
  }
15
19
  async execute(id, input) {
16
20
  const hasPermission = await this.identityContext.getPermission("security.team");
@@ -24,21 +28,31 @@ class UpdateTeamUseCase {
24
28
  const existingTeam = existingResult.value;
25
29
  if (existingTeam.system) return Result.fail(new CannotUpdateSystemTeamsError());
26
30
  if (existingTeam.plugin) return Result.fail(new CannotUpdatePluginTeamsError());
31
+ const { description, ...rest } = validation.data;
32
+ const changes = {
33
+ ...rest,
34
+ ...descriptionOnUpdate(description)
35
+ };
36
+ if (changes.roles) {
37
+ const roleIdsResult = await resolveRoleIdentifiers(this.rolesRepository, changes.roles);
38
+ if (roleIdsResult.isFail()) return Result.fail(roleIdsResult.error);
39
+ changes.roles = roleIdsResult.value;
40
+ }
27
41
  const updatedTeam = {
28
42
  ...existingTeam,
29
- ...validation.data
43
+ ...changes
30
44
  };
31
45
  await this.eventPublisher.publish(new TeamBeforeUpdateEvent({
32
46
  original: existingTeam,
33
47
  updated: updatedTeam,
34
- input: validation.data
48
+ input: changes
35
49
  }));
36
50
  const result = await this.repository.update(updatedTeam);
37
51
  if (result.isFail()) return Result.fail(result.error);
38
52
  await this.eventPublisher.publish(new TeamAfterUpdateEvent({
39
53
  original: existingTeam,
40
54
  updated: updatedTeam,
41
- input: validation.data
55
+ input: changes
42
56
  }));
43
57
  return Result.ok(updatedTeam);
44
58
  }
@@ -49,7 +63,8 @@ const UpdateTeamUseCaseImpl = createImplementation({
49
63
  dependencies: [
50
64
  TeamsRepository,
51
65
  IdentityContext,
52
- EventPublisher
66
+ EventPublisher,
67
+ RolesRepository
53
68
  ]
54
69
  });
55
70
  export { UpdateTeamUseCase, UpdateTeamUseCaseImpl };
@@ -1 +1 @@
1
- {"version":3,"file":"features/security/teams/UpdateTeam/UpdateTeamUseCase.js","sources":["../../../../../src/features/security/teams/UpdateTeam/UpdateTeamUseCase.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { UpdateTeam } from \"./abstractions.js\";\nimport { TeamsRepository } from \"../shared/abstractions.js\";\nimport { IdentityContext } from \"../../IdentityContext/abstractions.js\";\nimport { EventPublisher } from \"~/features/eventPublisher/index.js\";\nimport { updateTeamValidation } from \"./schema.js\";\nimport { TeamBeforeUpdateEvent, TeamAfterUpdateEvent } from \"./events.js\";\nimport type { Team, UpdateTeamInput } from \"../shared/types.js\";\nimport {\n NotAuthorizedError,\n CannotUpdatePluginTeamsError,\n CannotUpdateSystemTeamsError,\n TeamValidationError\n} from \"../shared/errors.js\";\n\nexport class UpdateTeamUseCase {\n private repository: TeamsRepository.Interface;\n private identityContext: IdentityContext.Interface;\n private eventPublisher: EventPublisher.Interface;\n\n constructor(\n repository: TeamsRepository.Interface,\n identityContext: IdentityContext.Interface,\n eventPublisher: EventPublisher.Interface\n ) {\n this.repository = repository;\n this.identityContext = identityContext;\n this.eventPublisher = eventPublisher;\n }\n\n async execute(id: string, input: UpdateTeamInput): Promise<Result<Team, UpdateTeam.Error>> {\n const hasPermission = await this.identityContext.getPermission(\"security.team\");\n if (!hasPermission) {\n return Result.fail(new NotAuthorizedError());\n }\n\n const validation = updateTeamValidation.safeParse(input);\n if (!validation.success) {\n return Result.fail(new TeamValidationError(validation.error.issues[0].message));\n }\n\n const existingResult = await this.repository.get({ id });\n if (existingResult.isFail()) {\n return Result.fail(existingResult.error);\n }\n\n const existingTeam = existingResult.value;\n\n // Check if team is system team\n if (existingTeam.system) {\n return Result.fail(new CannotUpdateSystemTeamsError());\n }\n\n // Check if team is created via plugin\n if (existingTeam.plugin) {\n return Result.fail(new CannotUpdatePluginTeamsError());\n }\n\n const updatedTeam: Team = {\n ...existingTeam,\n ...validation.data\n };\n\n await this.eventPublisher.publish(\n new TeamBeforeUpdateEvent({\n original: existingTeam,\n updated: updatedTeam,\n input: validation.data\n })\n );\n\n const result = await this.repository.update(updatedTeam);\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n await this.eventPublisher.publish(\n new TeamAfterUpdateEvent({\n original: existingTeam,\n updated: updatedTeam,\n input: validation.data\n })\n );\n\n return Result.ok(updatedTeam);\n }\n}\n\nexport const UpdateTeamUseCaseImpl = createImplementation({\n abstraction: UpdateTeam,\n implementation: UpdateTeamUseCase,\n dependencies: [TeamsRepository, IdentityContext, EventPublisher]\n});\n"],"names":["UpdateTeamUseCase","repository","identityContext","eventPublisher","id","input","hasPermission","Result","NotAuthorizedError","validation","updateTeamValidation","TeamValidationError","existingResult","existingTeam","CannotUpdateSystemTeamsError","CannotUpdatePluginTeamsError","updatedTeam","TeamBeforeUpdateEvent","result","TeamAfterUpdateEvent","UpdateTeamUseCaseImpl","createImplementation","UpdateTeam","TeamsRepository","IdentityContext","EventPublisher"],"mappings":";;;;;;;;AAgBO,MAAMA;IAKT,YACIC,UAAqC,EACrCC,eAA0C,EAC1CC,cAAwC,CAC1C;QACE,IAAI,CAAC,UAAU,GAAGF;QAClB,IAAI,CAAC,eAAe,GAAGC;QACvB,IAAI,CAAC,cAAc,GAAGC;IAC1B;IAEA,MAAM,QAAQC,EAAU,EAAEC,KAAsB,EAA2C;QACvF,MAAMC,gBAAgB,MAAM,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC;QAC/D,IAAI,CAACA,eACD,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAG3B,MAAMC,aAAaC,qBAAqB,SAAS,CAACL;QAClD,IAAI,CAACI,WAAW,OAAO,EACnB,OAAOF,OAAO,IAAI,CAAC,IAAII,oBAAoBF,WAAW,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO;QAGjF,MAAMG,iBAAiB,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAAER;QAAG;QACtD,IAAIQ,eAAe,MAAM,IACrB,OAAOL,OAAO,IAAI,CAACK,eAAe,KAAK;QAG3C,MAAMC,eAAeD,eAAe,KAAK;QAGzC,IAAIC,aAAa,MAAM,EACnB,OAAON,OAAO,IAAI,CAAC,IAAIO;QAI3B,IAAID,aAAa,MAAM,EACnB,OAAON,OAAO,IAAI,CAAC,IAAIQ;QAG3B,MAAMC,cAAoB;YACtB,GAAGH,YAAY;YACf,GAAGJ,WAAW,IAAI;QACtB;QAEA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIQ,sBAAsB;YACtB,UAAUJ;YACV,SAASG;YACT,OAAOP,WAAW,IAAI;QAC1B;QAGJ,MAAMS,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAACF;QAE5C,IAAIE,OAAO,MAAM,IACb,OAAOX,OAAO,IAAI,CAACW,OAAO,KAAK;QAGnC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIC,qBAAqB;YACrB,UAAUN;YACV,SAASG;YACT,OAAOP,WAAW,IAAI;QAC1B;QAGJ,OAAOF,OAAO,EAAE,CAACS;IACrB;AACJ;AAEO,MAAMI,wBAAwBC,qBAAqB;IACtD,aAAaC;IACb,gBAAgBtB;IAChB,cAAc;QAACuB;QAAiBC;QAAiBC;KAAe;AACpE"}
1
+ {"version":3,"file":"features/security/teams/UpdateTeam/UpdateTeamUseCase.js","sources":["../../../../../src/features/security/teams/UpdateTeam/UpdateTeamUseCase.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { UpdateTeam } from \"./abstractions.js\";\nimport { TeamsRepository } from \"../shared/abstractions.js\";\nimport { RolesRepository } from \"../../roles/shared/abstractions.js\";\nimport { IdentityContext } from \"../../IdentityContext/abstractions.js\";\nimport { EventPublisher } from \"~/features/eventPublisher/index.js\";\nimport { updateTeamValidation } from \"./schema.js\";\nimport { TeamBeforeUpdateEvent, TeamAfterUpdateEvent } from \"./events.js\";\nimport type { Team, UpdateTeamInput } from \"../shared/types.js\";\nimport { descriptionOnUpdate } from \"../../shared/description.js\";\nimport { resolveRoleIdentifiers } from \"../shared/resolveRoleIdentifiers.js\";\nimport {\n NotAuthorizedError,\n CannotUpdatePluginTeamsError,\n CannotUpdateSystemTeamsError,\n TeamValidationError\n} from \"../shared/errors.js\";\n\nexport class UpdateTeamUseCase {\n private repository: TeamsRepository.Interface;\n private identityContext: IdentityContext.Interface;\n private eventPublisher: EventPublisher.Interface;\n private rolesRepository: RolesRepository.Interface;\n\n constructor(\n repository: TeamsRepository.Interface,\n identityContext: IdentityContext.Interface,\n eventPublisher: EventPublisher.Interface,\n rolesRepository: RolesRepository.Interface\n ) {\n this.repository = repository;\n this.identityContext = identityContext;\n this.eventPublisher = eventPublisher;\n this.rolesRepository = rolesRepository;\n }\n\n async execute(id: string, input: UpdateTeamInput): Promise<Result<Team, UpdateTeam.Error>> {\n const hasPermission = await this.identityContext.getPermission(\"security.team\");\n if (!hasPermission) {\n return Result.fail(new NotAuthorizedError());\n }\n\n const validation = updateTeamValidation.safeParse(input);\n if (!validation.success) {\n return Result.fail(new TeamValidationError(validation.error.issues[0].message));\n }\n\n const existingResult = await this.repository.get({ id });\n if (existingResult.isFail()) {\n return Result.fail(existingResult.error);\n }\n\n const existingTeam = existingResult.value;\n\n // Check if team is system team\n if (existingTeam.system) {\n return Result.fail(new CannotUpdateSystemTeamsError());\n }\n\n // Check if team is created via plugin\n if (existingTeam.plugin) {\n return Result.fail(new CannotUpdatePluginTeamsError());\n }\n\n // `description` is pulled out of the spread because it is the one field that accepts null.\n // Normalising it here keeps null out of both the entity and the published events, whose\n // input type declares `description?: string`.\n const { description, ...rest } = validation.data;\n\n const changes: UpdateTeamInput = {\n ...rest,\n ...descriptionOnUpdate(description)\n };\n\n /*\n * Only when the update mentions roles. An update that omits them must leave the stored ones\n * alone, and resolving an absent list would cost a read and write an empty array.\n */\n if (changes.roles) {\n const roleIdsResult = await resolveRoleIdentifiers(this.rolesRepository, changes.roles);\n\n if (roleIdsResult.isFail()) {\n return Result.fail(roleIdsResult.error);\n }\n\n changes.roles = roleIdsResult.value;\n }\n\n const updatedTeam: Team = {\n ...existingTeam,\n ...changes\n };\n\n await this.eventPublisher.publish(\n new TeamBeforeUpdateEvent({\n original: existingTeam,\n updated: updatedTeam,\n input: changes\n })\n );\n\n const result = await this.repository.update(updatedTeam);\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n await this.eventPublisher.publish(\n new TeamAfterUpdateEvent({\n original: existingTeam,\n updated: updatedTeam,\n input: changes\n })\n );\n\n return Result.ok(updatedTeam);\n }\n}\n\nexport const UpdateTeamUseCaseImpl = createImplementation({\n abstraction: UpdateTeam,\n implementation: UpdateTeamUseCase,\n dependencies: [TeamsRepository, IdentityContext, EventPublisher, RolesRepository]\n});\n"],"names":["UpdateTeamUseCase","repository","identityContext","eventPublisher","rolesRepository","id","input","hasPermission","Result","NotAuthorizedError","validation","updateTeamValidation","TeamValidationError","existingResult","existingTeam","CannotUpdateSystemTeamsError","CannotUpdatePluginTeamsError","description","rest","changes","descriptionOnUpdate","roleIdsResult","resolveRoleIdentifiers","updatedTeam","TeamBeforeUpdateEvent","result","TeamAfterUpdateEvent","UpdateTeamUseCaseImpl","createImplementation","UpdateTeam","TeamsRepository","IdentityContext","EventPublisher","RolesRepository"],"mappings":";;;;;;;;;;;AAmBO,MAAMA;IAMT,YACIC,UAAqC,EACrCC,eAA0C,EAC1CC,cAAwC,EACxCC,eAA0C,CAC5C;QACE,IAAI,CAAC,UAAU,GAAGH;QAClB,IAAI,CAAC,eAAe,GAAGC;QACvB,IAAI,CAAC,cAAc,GAAGC;QACtB,IAAI,CAAC,eAAe,GAAGC;IAC3B;IAEA,MAAM,QAAQC,EAAU,EAAEC,KAAsB,EAA2C;QACvF,MAAMC,gBAAgB,MAAM,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC;QAC/D,IAAI,CAACA,eACD,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAG3B,MAAMC,aAAaC,qBAAqB,SAAS,CAACL;QAClD,IAAI,CAACI,WAAW,OAAO,EACnB,OAAOF,OAAO,IAAI,CAAC,IAAII,oBAAoBF,WAAW,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO;QAGjF,MAAMG,iBAAiB,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAAER;QAAG;QACtD,IAAIQ,eAAe,MAAM,IACrB,OAAOL,OAAO,IAAI,CAACK,eAAe,KAAK;QAG3C,MAAMC,eAAeD,eAAe,KAAK;QAGzC,IAAIC,aAAa,MAAM,EACnB,OAAON,OAAO,IAAI,CAAC,IAAIO;QAI3B,IAAID,aAAa,MAAM,EACnB,OAAON,OAAO,IAAI,CAAC,IAAIQ;QAM3B,MAAM,EAAEC,WAAW,EAAE,GAAGC,MAAM,GAAGR,WAAW,IAAI;QAEhD,MAAMS,UAA2B;YAC7B,GAAGD,IAAI;YACP,GAAGE,oBAAoBH,YAAY;QACvC;QAMA,IAAIE,QAAQ,KAAK,EAAE;YACf,MAAME,gBAAgB,MAAMC,uBAAuB,IAAI,CAAC,eAAe,EAAEH,QAAQ,KAAK;YAEtF,IAAIE,cAAc,MAAM,IACpB,OAAOb,OAAO,IAAI,CAACa,cAAc,KAAK;YAG1CF,QAAQ,KAAK,GAAGE,cAAc,KAAK;QACvC;QAEA,MAAME,cAAoB;YACtB,GAAGT,YAAY;YACf,GAAGK,OAAO;QACd;QAEA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIK,sBAAsB;YACtB,UAAUV;YACV,SAASS;YACT,OAAOJ;QACX;QAGJ,MAAMM,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAACF;QAE5C,IAAIE,OAAO,MAAM,IACb,OAAOjB,OAAO,IAAI,CAACiB,OAAO,KAAK;QAGnC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIC,qBAAqB;YACrB,UAAUZ;YACV,SAASS;YACT,OAAOJ;QACX;QAGJ,OAAOX,OAAO,EAAE,CAACe;IACrB;AACJ;AAEO,MAAMI,wBAAwBC,qBAAqB;IACtD,aAAaC;IACb,gBAAgB7B;IAChB,cAAc;QAAC8B;QAAiBC;QAAiBC;QAAgBC;KAAgB;AACrF"}
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  export declare const updateTeamValidation: z.ZodObject<{
3
3
  name: z.ZodOptional<z.ZodString>;
4
- description: z.ZodOptional<z.ZodString>;
4
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
5
5
  roles: z.ZodOptional<z.ZodArray<z.ZodString>>;
6
6
  }, z.core.$strip>;
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  const updateTeamValidation = z.object({
3
3
  name: z.string().min(3).optional(),
4
- description: z.string().max(500).optional(),
4
+ description: z.string().max(500).nullish(),
5
5
  roles: z.array(z.string()).optional()
6
6
  });
7
7
  export { updateTeamValidation };
@@ -1 +1 @@
1
- {"version":3,"file":"features/security/teams/UpdateTeam/schema.js","sources":["../../../../../src/features/security/teams/UpdateTeam/schema.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const updateTeamValidation = z.object({\n name: z.string().min(3).optional(),\n description: z.string().max(500).optional(),\n roles: z.array(z.string()).optional()\n});\n"],"names":["updateTeamValidation","z"],"mappings":";AAEO,MAAMA,uBAAuBC,EAAE,MAAM,CAAC;IACzC,MAAMA,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG,QAAQ;IAChC,aAAaA,EAAE,MAAM,GAAG,GAAG,CAAC,KAAK,QAAQ;IACzC,OAAOA,EAAE,KAAK,CAACA,EAAE,MAAM,IAAI,QAAQ;AACvC"}
1
+ {"version":3,"file":"features/security/teams/UpdateTeam/schema.js","sources":["../../../../../src/features/security/teams/UpdateTeam/schema.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const updateTeamValidation = z.object({\n name: z.string().min(3).optional(),\n // Nullable in the GraphQL schema - see `descriptionOnUpdate` for why this is `.nullish()` and\n // must not carry a `.transform()`.\n description: z.string().max(500).nullish(),\n roles: z.array(z.string()).optional()\n});\n"],"names":["updateTeamValidation","z"],"mappings":";AAEO,MAAMA,uBAAuBC,EAAE,MAAM,CAAC;IACzC,MAAMA,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG,QAAQ;IAGhC,aAAaA,EAAE,MAAM,GAAG,GAAG,CAAC,KAAK,OAAO;IACxC,OAAOA,EAAE,KAAK,CAACA,EAAE,MAAM,IAAI,QAAQ;AACvC"}
@@ -0,0 +1,17 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { RolesRepository } from "../../roles/shared/abstractions.js";
3
+ import { TeamValidationError } from "./errors.js";
4
+ /**
5
+ * Maps whatever a caller used to name a role onto the role IDs a team stores.
6
+ *
7
+ * `team.roles` holds IDs and only IDs: GetPermissionsFromIdentity resolves them with `id_in` against
8
+ * the roles repository. A slug stored here matches nothing, so the team is created, reads correctly
9
+ * in the admin UI, and grants no permissions at all. Nothing previously caught that, because the
10
+ * field is typed `string[]` and the use case wrote it through untouched.
11
+ *
12
+ * Accepting both forms rather than rejecting slugs: which identifier a given field wants is not
13
+ * guessable from the outside, and a few lines away in the same area a team is identified by SLUG
14
+ * (folder permission targets are `team:<slug>`). An identifier that is neither is a genuine mistake
15
+ * and is reported.
16
+ */
17
+ export declare const resolveRoleIdentifiers: (rolesRepository: RolesRepository.Interface, identifiers: string[]) => Promise<Result<string[], TeamValidationError>>;
@@ -0,0 +1,32 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { TeamValidationError } from "./errors.js";
3
+ const resolveRoleIdentifiers = async (rolesRepository, identifiers)=>{
4
+ if (0 === identifiers.length) return Result.ok([]);
5
+ const rolesResult = await rolesRepository.list({});
6
+ if (rolesResult.isFail()) return Result.fail(new TeamValidationError(`Could not load roles: ${rolesResult.error}`));
7
+ const byId = new Map(rolesResult.value.map((role)=>[
8
+ role.id,
9
+ role.id
10
+ ]));
11
+ const bySlug = new Map(rolesResult.value.map((role)=>[
12
+ role.slug,
13
+ role.id
14
+ ]));
15
+ const unknown = [];
16
+ const roleIds = identifiers.map((identifier)=>{
17
+ const resolved = byId.get(identifier) ?? bySlug.get(identifier);
18
+ if (!resolved) {
19
+ unknown.push(identifier);
20
+ return identifier;
21
+ }
22
+ return resolved;
23
+ });
24
+ if (unknown.length > 0) {
25
+ const names = unknown.map((identifier)=>`"${identifier}"`).join(", ");
26
+ return Result.fail(new TeamValidationError(`Not a known role id or slug: ${names}.`));
27
+ }
28
+ return Result.ok(roleIds);
29
+ };
30
+ export { resolveRoleIdentifiers };
31
+
32
+ //# sourceMappingURL=resolveRoleIdentifiers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/security/teams/shared/resolveRoleIdentifiers.js","sources":["../../../../../src/features/security/teams/shared/resolveRoleIdentifiers.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { RolesRepository } from \"../../roles/shared/abstractions.js\";\nimport { TeamValidationError } from \"./errors.js\";\n\n/**\n * Maps whatever a caller used to name a role onto the role IDs a team stores.\n *\n * `team.roles` holds IDs and only IDs: GetPermissionsFromIdentity resolves them with `id_in` against\n * the roles repository. A slug stored here matches nothing, so the team is created, reads correctly\n * in the admin UI, and grants no permissions at all. Nothing previously caught that, because the\n * field is typed `string[]` and the use case wrote it through untouched.\n *\n * Accepting both forms rather than rejecting slugs: which identifier a given field wants is not\n * guessable from the outside, and a few lines away in the same area a team is identified by SLUG\n * (folder permission targets are `team:<slug>`). An identifier that is neither is a genuine mistake\n * and is reported.\n */\nexport const resolveRoleIdentifiers = async (\n rolesRepository: RolesRepository.Interface,\n identifiers: string[]\n): Promise<Result<string[], TeamValidationError>> => {\n if (identifiers.length === 0) {\n return Result.ok([]);\n }\n\n /*\n * Every role, in one read. `id_in` and `slug_in` are ANDed by the repository, so they cannot\n * express \"either of these\", and a project has few enough roles for the distinction not to\n * matter. Plugin-defined roles are included, which a filtered query would also have to cover.\n */\n const rolesResult = await rolesRepository.list({});\n\n if (rolesResult.isFail()) {\n return Result.fail(new TeamValidationError(`Could not load roles: ${rolesResult.error}`));\n }\n\n const byId = new Map(rolesResult.value.map(role => [role.id, role.id]));\n const bySlug = new Map(rolesResult.value.map(role => [role.slug, role.id]));\n\n const unknown: string[] = [];\n\n // ID first, so a slug that happens to equal another role's ID cannot shadow it.\n const roleIds = identifiers.map(identifier => {\n const resolved = byId.get(identifier) ?? bySlug.get(identifier);\n\n if (!resolved) {\n unknown.push(identifier);\n return identifier;\n }\n\n return resolved;\n });\n\n if (unknown.length > 0) {\n const names = unknown.map(identifier => `\"${identifier}\"`).join(\", \");\n return Result.fail(new TeamValidationError(`Not a known role id or slug: ${names}.`));\n }\n\n return Result.ok(roleIds);\n};\n"],"names":["resolveRoleIdentifiers","rolesRepository","identifiers","Result","rolesResult","TeamValidationError","byId","Map","role","bySlug","unknown","roleIds","identifier","resolved","names"],"mappings":";;AAiBO,MAAMA,yBAAyB,OAClCC,iBACAC;IAEA,IAAIA,AAAuB,MAAvBA,YAAY,MAAM,EAClB,OAAOC,OAAO,EAAE,CAAC,EAAE;IAQvB,MAAMC,cAAc,MAAMH,gBAAgB,IAAI,CAAC,CAAC;IAEhD,IAAIG,YAAY,MAAM,IAClB,OAAOD,OAAO,IAAI,CAAC,IAAIE,oBAAoB,CAAC,sBAAsB,EAAED,YAAY,KAAK,EAAE;IAG3F,MAAME,OAAO,IAAIC,IAAIH,YAAY,KAAK,CAAC,GAAG,CAACI,CAAAA,OAAQ;YAACA,KAAK,EAAE;YAAEA,KAAK,EAAE;SAAC;IACrE,MAAMC,SAAS,IAAIF,IAAIH,YAAY,KAAK,CAAC,GAAG,CAACI,CAAAA,OAAQ;YAACA,KAAK,IAAI;YAAEA,KAAK,EAAE;SAAC;IAEzE,MAAME,UAAoB,EAAE;IAG5B,MAAMC,UAAUT,YAAY,GAAG,CAACU,CAAAA;QAC5B,MAAMC,WAAWP,KAAK,GAAG,CAACM,eAAeH,OAAO,GAAG,CAACG;QAEpD,IAAI,CAACC,UAAU;YACXH,QAAQ,IAAI,CAACE;YACb,OAAOA;QACX;QAEA,OAAOC;IACX;IAEA,IAAIH,QAAQ,MAAM,GAAG,GAAG;QACpB,MAAMI,QAAQJ,QAAQ,GAAG,CAACE,CAAAA,aAAc,CAAC,CAAC,EAAEA,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC;QAChE,OAAOT,OAAO,IAAI,CAAC,IAAIE,oBAAoB,CAAC,6BAA6B,EAAES,MAAM,CAAC,CAAC;IACvF;IAEA,OAAOX,OAAO,EAAE,CAACQ;AACrB"}
@@ -0,0 +1,8 @@
1
+ import { Slugify } from "./abstractions.js";
2
+ declare class DefaultSlugifyImpl implements Slugify.Interface {
3
+ execute(value: string): string;
4
+ }
5
+ export declare const DefaultSlugify: typeof DefaultSlugifyImpl & {
6
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").ISlugify>;
7
+ };
8
+ export {};
@@ -0,0 +1,20 @@
1
+ import slugify from "slugify";
2
+ import { Slugify } from "./abstractions.js";
3
+ const DEFAULT_OPTIONS = {
4
+ replacement: "-",
5
+ lower: true,
6
+ remove: /[*#?<>_{}[\]+~.()'"!:;@]/g,
7
+ trim: false
8
+ };
9
+ class DefaultSlugifyImpl {
10
+ execute(value) {
11
+ return slugify(value, DEFAULT_OPTIONS);
12
+ }
13
+ }
14
+ const DefaultSlugify = Slugify.createImplementation({
15
+ implementation: DefaultSlugifyImpl,
16
+ dependencies: []
17
+ });
18
+ export { DefaultSlugify };
19
+
20
+ //# sourceMappingURL=DefaultSlugify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/slugify/DefaultSlugify.js","sources":["../../../src/features/slugify/DefaultSlugify.ts"],"sourcesContent":["import baseSlugify from \"slugify\";\nimport { Slugify } from \"./abstractions.js\";\n\n/**\n * Webiny's canonical slug options. These were previously duplicated at every call site; keeping them\n * in one private place means projects can change slug generation everywhere at once by decorating\n * Slugify — not by passing per-call options, so the abstraction stays independent of this library.\n */\nconst DEFAULT_OPTIONS = {\n replacement: \"-\",\n lower: true,\n remove: /[*#?<>_{}[\\]+~.()'\"!:;@]/g,\n trim: false\n};\n\nclass DefaultSlugifyImpl implements Slugify.Interface {\n execute(value: string): string {\n return baseSlugify(value, DEFAULT_OPTIONS);\n }\n}\n\nexport const DefaultSlugify = Slugify.createImplementation({\n implementation: DefaultSlugifyImpl,\n dependencies: []\n});\n"],"names":["DEFAULT_OPTIONS","DefaultSlugifyImpl","value","baseSlugify","DefaultSlugify","Slugify"],"mappings":";;AAQA,MAAMA,kBAAkB;IACpB,aAAa;IACb,OAAO;IACP,QAAQ;IACR,MAAM;AACV;AAEA,MAAMC;IACF,QAAQC,KAAa,EAAU;QAC3B,OAAOC,QAAYD,OAAOF;IAC9B;AACJ;AAEO,MAAMI,iBAAiBC,QAAQ,oBAAoB,CAAC;IACvD,gBAAgBJ;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,12 @@
1
+ export interface ISlugify {
2
+ /**
3
+ * Turns a value into a URL-friendly slug using Webiny's canonical options. This is the
4
+ * fine-grained seam behind `StringFormatter.slugify()` — decorate `Slugify` alone to change slug
5
+ * logic without touching the rest of the string formatter.
6
+ */
7
+ execute(value: string): string;
8
+ }
9
+ export declare const Slugify: import("@webiny/di").Abstraction<ISlugify>;
10
+ export declare namespace Slugify {
11
+ type Interface = ISlugify;
12
+ }
@@ -0,0 +1,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const Slugify = createAbstraction("Slugify");
3
+ export { Slugify };
4
+
5
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/slugify/abstractions.js","sources":["../../../src/features/slugify/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\nexport interface ISlugify {\n /**\n * Turns a value into a URL-friendly slug using Webiny's canonical options. This is the\n * fine-grained seam behind `StringFormatter.slugify()` — decorate `Slugify` alone to change slug\n * logic without touching the rest of the string formatter.\n */\n execute(value: string): string;\n}\n\nexport const Slugify = createAbstraction<ISlugify>(\"Slugify\");\n\nexport namespace Slugify {\n export type Interface = ISlugify;\n}\n"],"names":["Slugify","createAbstraction"],"mappings":";AAWO,MAAMA,UAAUC,kBAA4B"}
@@ -1,4 +1,4 @@
1
- export declare const LoggerFeature: {
1
+ export declare const SlugifyFeature: {
2
2
  name: string;
3
3
  register(container: import("@webiny/di").Container): void;
4
4
  };
@@ -0,0 +1,11 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { DefaultSlugify } from "./DefaultSlugify.js";
3
+ const SlugifyFeature = createFeature({
4
+ name: "SlugifyFeature",
5
+ register (container) {
6
+ container.register(DefaultSlugify);
7
+ }
8
+ });
9
+ export { SlugifyFeature };
10
+
11
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/slugify/feature.js","sources":["../../../src/features/slugify/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { DefaultSlugify } from \"./DefaultSlugify.js\";\n\nexport const SlugifyFeature = createFeature({\n name: \"SlugifyFeature\",\n register(container) {\n container.register(DefaultSlugify);\n }\n});\n"],"names":["SlugifyFeature","createFeature","container","DefaultSlugify"],"mappings":";;AAGO,MAAMA,iBAAiBC,cAAc;IACxC,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
@@ -0,0 +1,3 @@
1
+ export { Slugify } from "./abstractions.js";
2
+ export type { ISlugify } from "./abstractions.js";
3
+ export { SlugifyFeature } from "./feature.js";
@@ -0,0 +1,2 @@
1
+ export { Slugify } from "./abstractions.js";
2
+ export { SlugifyFeature } from "./feature.js";
@@ -0,0 +1,17 @@
1
+ import { Slugify } from "../../features/slugify/abstractions.js";
2
+ import { StringFormatter } from "./abstractions.js";
3
+ /**
4
+ * The string formatter is the consumer-facing API for string transforms. It keeps each transform's
5
+ * logic in its own fine-grained, decoratable feature (e.g. `Slugify`) and just delegates to it, so a
6
+ * project can change one transform without reimplementing the whole formatter. More methods will be
7
+ * added here over time.
8
+ */
9
+ declare class DefaultStringFormatterImpl implements StringFormatter.Interface {
10
+ private readonly slugifier;
11
+ constructor(slugifier: Slugify.Interface);
12
+ slugify(value: string): string;
13
+ }
14
+ export declare const DefaultStringFormatter: typeof DefaultStringFormatterImpl & {
15
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IStringFormatter>;
16
+ };
17
+ export {};
@@ -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";