@webiny/api-core 6.4.11 → 6.6.0-alpha.1

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 (341) hide show
  1. package/ApiCoreFeature.d.ts +2 -2
  2. package/ApiCoreFeature.js +29 -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.d.ts +3 -1
  7. package/exports/api.js +2 -1
  8. package/features/ai/Ai.d.ts +3 -3
  9. package/features/ai/Ai.js +60 -23
  10. package/features/ai/Ai.js.map +1 -1
  11. package/features/ai/AnthropicSdkFactory.js +12 -0
  12. package/features/ai/AnthropicSdkFactory.js.map +1 -1
  13. package/features/ai/OpenAiSdkFactory.js +16 -0
  14. package/features/ai/OpenAiSdkFactory.js.map +1 -1
  15. package/features/ai/TextExtractor/DefaultTextExtractor.d.ts +9 -0
  16. package/features/ai/TextExtractor/DefaultTextExtractor.js +28 -0
  17. package/features/ai/TextExtractor/DefaultTextExtractor.js.map +1 -0
  18. package/features/ai/TextExtractor/abstractions.d.ts +12 -0
  19. package/features/ai/TextExtractor/abstractions.js +5 -0
  20. package/features/ai/TextExtractor/abstractions.js.map +1 -0
  21. package/features/ai/TextExtractor/index.d.ts +3 -0
  22. package/features/ai/TextExtractor/index.js +2 -0
  23. package/features/ai/TextExtractor/parsers/docxParser.d.ts +1 -0
  24. package/features/ai/TextExtractor/parsers/docxParser.js +111 -0
  25. package/features/ai/TextExtractor/parsers/docxParser.js.map +1 -0
  26. package/features/ai/abstractions.d.ts +18 -7
  27. package/features/ai/abstractions.js +1 -2
  28. package/features/ai/abstractions.js.map +1 -1
  29. package/features/ai/events.d.ts +59 -0
  30. package/features/ai/events.js +41 -0
  31. package/features/ai/events.js.map +1 -0
  32. package/features/ai/feature.js +6 -2
  33. package/features/ai/feature.js.map +1 -1
  34. package/features/ai/index.d.ts +8 -2
  35. package/features/ai/index.js +4 -1
  36. package/features/ai/toolPipeline/AiOutputToolRegistry.d.ts +11 -0
  37. package/features/ai/toolPipeline/AiOutputToolRegistry.js +31 -0
  38. package/features/ai/toolPipeline/AiOutputToolRegistry.js.map +1 -0
  39. package/features/ai/toolPipeline/AiToolPipelineRunner.d.ts +10 -0
  40. package/features/ai/toolPipeline/AiToolPipelineRunner.js +36 -0
  41. package/features/ai/toolPipeline/AiToolPipelineRunner.js.map +1 -0
  42. package/features/ai/toolPipeline/abstractions.d.ts +23 -0
  43. package/features/ai/toolPipeline/abstractions.js +7 -0
  44. package/features/ai/toolPipeline/abstractions.js.map +1 -0
  45. package/features/ai/toolPipeline/index.d.ts +2 -0
  46. package/features/ai/toolPipeline/index.js +1 -0
  47. package/features/dateFormatter/DefaultDateFormatter.d.ts +15 -0
  48. package/features/dateFormatter/DefaultDateFormatter.js +20 -0
  49. package/features/dateFormatter/DefaultDateFormatter.js.map +1 -0
  50. package/features/dateFormatter/abstractions.d.ts +13 -0
  51. package/features/dateFormatter/abstractions.js +5 -0
  52. package/features/dateFormatter/abstractions.js.map +1 -0
  53. package/features/dateFormatter/feature.d.ts +4 -0
  54. package/features/dateFormatter/feature.js +11 -0
  55. package/features/dateFormatter/feature.js.map +1 -0
  56. package/features/dateFormatter/index.d.ts +3 -0
  57. package/features/dateFormatter/index.js +2 -0
  58. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.d.ts +13 -0
  59. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js +49 -0
  60. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js.map +1 -0
  61. package/features/hashing/ScryptHasher.d.ts +11 -0
  62. package/features/hashing/ScryptHasher.js +74 -0
  63. package/features/hashing/ScryptHasher.js.map +1 -0
  64. package/features/hashing/abstractions.d.ts +18 -0
  65. package/features/hashing/abstractions.js +5 -0
  66. package/features/hashing/abstractions.js.map +1 -0
  67. package/features/hashing/feature.d.ts +4 -0
  68. package/features/hashing/feature.js +11 -0
  69. package/features/hashing/feature.js.map +1 -0
  70. package/features/hashing/index.d.ts +2 -0
  71. package/features/hashing/index.js +1 -0
  72. package/features/requestContext/RawAuthToken.d.ts +14 -0
  73. package/features/requestContext/RawAuthToken.js +19 -0
  74. package/features/requestContext/RawAuthToken.js.map +1 -0
  75. package/features/requestContext/RawTenantId.d.ts +14 -0
  76. package/features/requestContext/RawTenantId.js +19 -0
  77. package/features/requestContext/RawTenantId.js.map +1 -0
  78. package/features/requestContext/RequestIdentityLoader.d.ts +19 -0
  79. package/features/requestContext/RequestIdentityLoader.js +26 -0
  80. package/features/requestContext/RequestIdentityLoader.js.map +1 -0
  81. package/features/requestContext/RequestTenantLoader.d.ts +18 -0
  82. package/features/requestContext/RequestTenantLoader.js +52 -0
  83. package/features/requestContext/RequestTenantLoader.js.map +1 -0
  84. package/features/requestContext/abstractions.d.ts +53 -0
  85. package/features/requestContext/abstractions.js +8 -0
  86. package/features/requestContext/abstractions.js.map +1 -0
  87. package/features/requestContext/feature.d.ts +11 -0
  88. package/features/requestContext/feature.js +17 -0
  89. package/features/requestContext/feature.js.map +1 -0
  90. package/features/requestContext/index.d.ts +2 -0
  91. package/features/requestContext/index.js +2 -0
  92. package/features/security/IdentityContext/IdentityContext.d.ts +3 -3
  93. package/features/security/IdentityContext/IdentityContext.js +6 -6
  94. package/features/security/IdentityContext/IdentityContext.js.map +1 -1
  95. package/features/security/apiKeys/ApiKeyAuthenticator.d.ts +14 -0
  96. package/features/security/apiKeys/ApiKeyAuthenticator.js +36 -0
  97. package/features/security/apiKeys/ApiKeyAuthenticator.js.map +1 -0
  98. package/features/security/apiKeys/ApiKeyAuthorizer.d.ts +10 -0
  99. package/features/security/apiKeys/ApiKeyAuthorizer.js +15 -0
  100. package/features/security/apiKeys/ApiKeyAuthorizer.js.map +1 -0
  101. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js +11 -6
  102. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js.map +1 -1
  103. package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.d.ts +1 -1
  104. package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.js.map +1 -1
  105. package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.d.ts +1 -3
  106. package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.js.map +1 -1
  107. package/features/security/apiKeys/GetApiKeyBySlug/abstractions.d.ts +1 -1
  108. package/features/security/apiKeys/GetApiKeyBySlug/abstractions.js.map +1 -1
  109. package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.d.ts +1 -3
  110. package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.js.map +1 -1
  111. package/features/security/apiKeys/GetApiKeyByToken/abstractions.d.ts +1 -1
  112. package/features/security/apiKeys/GetApiKeyByToken/abstractions.js.map +1 -1
  113. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js +9 -3
  114. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js.map +1 -1
  115. package/features/security/apiKeys/feature.js +11 -2
  116. package/features/security/apiKeys/feature.js.map +1 -1
  117. package/features/security/apiKeys/shared/ApiKeyProvider.d.ts +3 -5
  118. package/features/security/apiKeys/shared/ApiKeyProvider.js +6 -21
  119. package/features/security/apiKeys/shared/ApiKeyProvider.js.map +1 -1
  120. package/features/security/apiKeys/shared/ApiKeysRepository.d.ts +1 -0
  121. package/features/security/apiKeys/shared/ApiKeysRepository.js +19 -4
  122. package/features/security/apiKeys/shared/ApiKeysRepository.js.map +1 -1
  123. package/features/security/apiKeys/shared/generateToken.d.ts +1 -1
  124. package/features/security/apiKeys/shared/generateToken.js.map +1 -1
  125. package/features/security/apiKeys/shared/schemas.d.ts +2 -2
  126. package/features/security/apiKeys/shared/schemas.js +2 -2
  127. package/features/security/apiKeys/shared/schemas.js.map +1 -1
  128. package/features/security/apiKeys/shared/types.d.ts +1 -1
  129. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.d.ts +4 -4
  130. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js +5 -5
  131. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js.map +1 -1
  132. package/features/security/roles/CreateRole/CreateRoleUseCase.js +11 -6
  133. package/features/security/roles/CreateRole/CreateRoleUseCase.js.map +1 -1
  134. package/features/security/roles/CreateRole/schema.d.ts +1 -1
  135. package/features/security/roles/CreateRole/schema.js +1 -1
  136. package/features/security/roles/CreateRole/schema.js.map +1 -1
  137. package/features/security/roles/Installer/RolesInstaller.js +0 -1
  138. package/features/security/roles/Installer/RolesInstaller.js.map +1 -1
  139. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js +9 -3
  140. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js.map +1 -1
  141. package/features/security/roles/UpdateRole/schema.d.ts +1 -1
  142. package/features/security/roles/UpdateRole/schema.js +1 -1
  143. package/features/security/roles/UpdateRole/schema.js.map +1 -1
  144. package/features/security/shared/description.d.ts +4 -0
  145. package/features/security/shared/description.js +7 -0
  146. package/features/security/shared/description.js.map +1 -0
  147. package/features/security/shared/index.d.ts +1 -0
  148. package/features/security/shared/index.js +1 -0
  149. package/features/security/teams/CreateTeam/CreateTeamUseCase.d.ts +3 -1
  150. package/features/security/teams/CreateTeam/CreateTeamUseCase.js +20 -8
  151. package/features/security/teams/CreateTeam/CreateTeamUseCase.js.map +1 -1
  152. package/features/security/teams/CreateTeam/schema.d.ts +1 -1
  153. package/features/security/teams/CreateTeam/schema.js +1 -1
  154. package/features/security/teams/CreateTeam/schema.js.map +1 -1
  155. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.d.ts +3 -1
  156. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js +20 -5
  157. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js.map +1 -1
  158. package/features/security/teams/UpdateTeam/schema.d.ts +1 -1
  159. package/features/security/teams/UpdateTeam/schema.js +1 -1
  160. package/features/security/teams/UpdateTeam/schema.js.map +1 -1
  161. package/features/security/teams/shared/resolveRoleIdentifiers.d.ts +17 -0
  162. package/features/security/teams/shared/resolveRoleIdentifiers.js +32 -0
  163. package/features/security/teams/shared/resolveRoleIdentifiers.js.map +1 -0
  164. package/features/security/utils/getPermissionsFromRoles.d.ts +1 -1
  165. package/features/serviceDiscovery/ServiceDiscovery.d.ts +17 -0
  166. package/features/serviceDiscovery/ServiceDiscovery.js +22 -0
  167. package/features/serviceDiscovery/ServiceDiscovery.js.map +1 -0
  168. package/features/serviceDiscovery/__tests__/ServiceDiscovery.test.d.ts +1 -0
  169. package/features/serviceDiscovery/__tests__/ServiceDiscovery.test.js +111 -0
  170. package/features/serviceDiscovery/__tests__/ServiceDiscovery.test.js.map +1 -0
  171. package/features/serviceDiscovery/index.d.ts +3 -0
  172. package/features/serviceDiscovery/index.js +1 -0
  173. package/features/slugify/DefaultSlugify.d.ts +8 -0
  174. package/features/slugify/DefaultSlugify.js +20 -0
  175. package/features/slugify/DefaultSlugify.js.map +1 -0
  176. package/features/slugify/abstractions.d.ts +12 -0
  177. package/features/slugify/abstractions.js +5 -0
  178. package/features/slugify/abstractions.js.map +1 -0
  179. package/features/slugify/feature.d.ts +4 -0
  180. package/features/slugify/feature.js +11 -0
  181. package/features/slugify/feature.js.map +1 -0
  182. package/features/slugify/index.d.ts +3 -0
  183. package/features/slugify/index.js +2 -0
  184. package/features/storageOperations/abstractions.d.ts +21 -0
  185. package/features/storageOperations/abstractions.js +10 -0
  186. package/features/storageOperations/abstractions.js.map +1 -0
  187. package/features/stringFormatter/DefaultStringFormatter.d.ts +17 -0
  188. package/features/stringFormatter/DefaultStringFormatter.js +19 -0
  189. package/features/stringFormatter/DefaultStringFormatter.js.map +1 -0
  190. package/features/stringFormatter/abstractions.d.ts +11 -0
  191. package/features/stringFormatter/abstractions.js +5 -0
  192. package/features/stringFormatter/abstractions.js.map +1 -0
  193. package/features/stringFormatter/feature.d.ts +4 -0
  194. package/features/stringFormatter/feature.js +13 -0
  195. package/features/stringFormatter/feature.js.map +1 -0
  196. package/features/stringFormatter/index.d.ts +3 -0
  197. package/features/stringFormatter/index.js +2 -0
  198. package/features/task/TaskDefinition/abstractions.d.ts +76 -4
  199. package/features/task/TaskDefinition/abstractions.js +2 -1
  200. package/features/task/TaskDefinition/abstractions.js.map +1 -1
  201. package/features/tenancy/CreateTenant/CreateTenantUseCase.d.ts +1 -1
  202. package/features/tenancy/InstallTenant/InstallTenantUseCase.d.ts +1 -1
  203. package/features/tenancy/UpdateTenant/UpdateTenantUseCase.d.ts +2 -2
  204. package/features/users/CreateUser/decorators/CreateUserWithWcpIncrement.d.ts +1 -1
  205. package/features/wcp/WcpContext/WcpContext.d.ts +10 -5
  206. package/features/wcp/WcpContext/WcpContext.js +23 -2
  207. package/features/wcp/WcpContext/WcpContext.js.map +1 -1
  208. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +25 -7
  209. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +57 -25
  210. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
  211. package/features/wcp/WcpContext/feature.d.ts +1 -2
  212. package/features/wcp/WcpContext/feature.js +2 -2
  213. package/features/wcp/WcpContext/feature.js.map +1 -1
  214. package/features/wcp/WcpContext/index.d.ts +0 -1
  215. package/features/wcp/WcpContext/types.d.ts +0 -4
  216. package/features/wcp/WcpFeature.d.ts +1 -1
  217. package/features/wcp/WcpFeature.js +7 -2
  218. package/features/wcp/WcpFeature.js.map +1 -1
  219. package/features/wcp/WcpLicenseLoader.d.ts +25 -0
  220. package/features/wcp/WcpLicenseLoader.js +58 -0
  221. package/features/wcp/WcpLicenseLoader.js.map +1 -0
  222. package/features/wcp/WcpLicenseProvider.d.ts +21 -0
  223. package/features/wcp/WcpLicenseProvider.js +14 -0
  224. package/features/wcp/WcpLicenseProvider.js.map +1 -0
  225. package/features/wcp/resolveWcpProjectEnvironment.d.ts +9 -0
  226. package/features/wcp/resolveWcpProjectEnvironment.js +23 -0
  227. package/features/wcp/resolveWcpProjectEnvironment.js.map +1 -0
  228. package/graphql/ApiCoreSchemaFactory.d.ts +15 -0
  229. package/graphql/ApiCoreSchemaFactory.js +52 -0
  230. package/graphql/ApiCoreSchemaFactory.js.map +1 -0
  231. package/graphql/featureFlags/FeatureFlagsSchemaFactory.d.ts +9 -0
  232. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js +49 -0
  233. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js.map +1 -0
  234. package/graphql/security/NotAuthorizedResponse.d.ts +1 -1
  235. package/graphql/security/NotAuthorizedResponse.js +1 -1
  236. package/graphql/security/NotAuthorizedResponse.js.map +1 -1
  237. package/graphql/security/SecuritySchemaFactory.d.ts +14 -0
  238. package/graphql/security/SecuritySchemaFactory.js +23 -0
  239. package/graphql/security/SecuritySchemaFactory.js.map +1 -0
  240. package/graphql/security/addApiKeySchema.d.ts +2 -0
  241. package/graphql/security/{apiKey.gql.js → addApiKeySchema.js} +45 -27
  242. package/graphql/security/addApiKeySchema.js.map +1 -0
  243. package/graphql/security/addIdentitySchema.d.ts +2 -0
  244. package/graphql/security/{identity.gql.js → addIdentitySchema.js} +52 -35
  245. package/graphql/security/addIdentitySchema.js.map +1 -0
  246. package/graphql/security/addRoleSchema.d.ts +2 -0
  247. package/graphql/security/addRoleSchema.js +137 -0
  248. package/graphql/security/addRoleSchema.js.map +1 -0
  249. package/graphql/security/addSecurityBaseSchema.d.ts +2 -0
  250. package/graphql/security/{base.gql.js → addSecurityBaseSchema.js} +14 -16
  251. package/graphql/security/addSecurityBaseSchema.js.map +1 -0
  252. package/graphql/security/addTeamSchema.d.ts +2 -0
  253. package/graphql/security/addTeamSchema.js +157 -0
  254. package/graphql/security/addTeamSchema.js.map +1 -0
  255. package/graphql/system/SystemSchemaFactory.d.ts +9 -0
  256. package/graphql/system/SystemSchemaFactory.js +66 -0
  257. package/graphql/system/SystemSchemaFactory.js.map +1 -0
  258. package/graphql/users/UsersSchemaFactory.d.ts +9 -0
  259. package/graphql/users/UsersSchemaFactory.js +191 -0
  260. package/graphql/users/UsersSchemaFactory.js.map +1 -0
  261. package/graphql/wcp/WcpSchemaFactory.d.ts +9 -0
  262. package/graphql/wcp/{graphql.js → WcpSchemaFactory.js} +28 -18
  263. package/graphql/wcp/WcpSchemaFactory.js.map +1 -0
  264. package/index.d.ts +3 -1
  265. package/index.js +3 -1
  266. package/package.json +21 -24
  267. package/testing/environment.d.ts +14 -0
  268. package/testing/environment.js +18 -0
  269. package/testing/environment.js.map +1 -0
  270. package/types/core.d.ts +17 -5
  271. package/types/security.d.ts +1 -7
  272. package/types/tenancy.d.ts +0 -17
  273. package/types/users.d.ts +0 -13
  274. package/createApiCore.d.ts +0 -7
  275. package/createApiCore.js +0 -22
  276. package/createApiCore.js.map +0 -1
  277. package/features/ai/AiModelRegistry.d.ts +0 -12
  278. package/features/ai/AiModelRegistry.js +0 -28
  279. package/features/ai/AiModelRegistry.js.map +0 -1
  280. package/graphql/security/apiKey.gql.d.ts +0 -4
  281. package/graphql/security/apiKey.gql.js.map +0 -1
  282. package/graphql/security/base.gql.d.ts +0 -4
  283. package/graphql/security/base.gql.js.map +0 -1
  284. package/graphql/security/identity.gql.d.ts +0 -4
  285. package/graphql/security/identity.gql.js.map +0 -1
  286. package/graphql/security/index.d.ts +0 -1
  287. package/graphql/security/index.js +0 -15
  288. package/graphql/security/index.js.map +0 -1
  289. package/graphql/security/role.gql.d.ts +0 -4
  290. package/graphql/security/role.gql.js +0 -106
  291. package/graphql/security/role.gql.js.map +0 -1
  292. package/graphql/security/team.gql.d.ts +0 -4
  293. package/graphql/security/team.gql.js +0 -119
  294. package/graphql/security/team.gql.js.map +0 -1
  295. package/graphql/system/createSystemGraphQL.d.ts +0 -2
  296. package/graphql/system/createSystemGraphQL.js +0 -54
  297. package/graphql/system/createSystemGraphQL.js.map +0 -1
  298. package/graphql/users/user.gql.d.ts +0 -3
  299. package/graphql/users/user.gql.js +0 -167
  300. package/graphql/users/user.gql.js.map +0 -1
  301. package/graphql/wcp/graphql.d.ts +0 -2
  302. package/graphql/wcp/graphql.js.map +0 -1
  303. package/legacy/security/LegacyContext.d.ts +0 -36
  304. package/legacy/security/LegacyContext.js +0 -152
  305. package/legacy/security/LegacyContext.js.map +0 -1
  306. package/legacy/security/createSecurityContext.d.ts +0 -3
  307. package/legacy/security/createSecurityContext.js +0 -10
  308. package/legacy/security/createSecurityContext.js.map +0 -1
  309. package/legacy/security/plugins/apiKeyAuthentication.d.ts +0 -7
  310. package/legacy/security/plugins/apiKeyAuthentication.js +0 -20
  311. package/legacy/security/plugins/apiKeyAuthentication.js.map +0 -1
  312. package/legacy/security/plugins/apiKeyAuthorization.d.ts +0 -6
  313. package/legacy/security/plugins/apiKeyAuthorization.js +0 -13
  314. package/legacy/security/plugins/apiKeyAuthorization.js.map +0 -1
  315. package/legacy/security/plugins/authenticateUsingCookie.d.ts +0 -5
  316. package/legacy/security/plugins/authenticateUsingCookie.js +0 -23
  317. package/legacy/security/plugins/authenticateUsingCookie.js.map +0 -1
  318. package/legacy/security/plugins/authenticateUsingHttpHeader.d.ts +0 -5
  319. package/legacy/security/plugins/authenticateUsingHttpHeader.js +0 -20
  320. package/legacy/security/plugins/authenticateUsingHttpHeader.js.map +0 -1
  321. package/legacy/security/plugins/secureHeaders.d.ts +0 -1
  322. package/legacy/security/plugins/secureHeaders.js +0 -30
  323. package/legacy/security/plugins/secureHeaders.js.map +0 -1
  324. package/legacy/tenancy/LegacyContext.d.ts +0 -15
  325. package/legacy/tenancy/LegacyContext.js +0 -57
  326. package/legacy/tenancy/LegacyContext.js.map +0 -1
  327. package/legacy/tenancy/createTenancyContext.d.ts +0 -3
  328. package/legacy/tenancy/createTenancyContext.js +0 -31
  329. package/legacy/tenancy/createTenancyContext.js.map +0 -1
  330. package/legacy/users/LegacyContext.d.ts +0 -13
  331. package/legacy/users/LegacyContext.js +0 -55
  332. package/legacy/users/LegacyContext.js.map +0 -1
  333. package/legacy/users/createAdminUsersContext.d.ts +0 -3
  334. package/legacy/users/createAdminUsersContext.js +0 -12
  335. package/legacy/users/createAdminUsersContext.js.map +0 -1
  336. package/legacy/wcp/LegacyWcpContext.d.ts +0 -33
  337. package/legacy/wcp/LegacyWcpContext.js +0 -84
  338. package/legacy/wcp/LegacyWcpContext.js.map +0 -1
  339. package/legacy/wcp/context.d.ts +0 -5
  340. package/legacy/wcp/context.js +0 -46
  341. package/legacy/wcp/context.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { Container } from "@webiny/di";
2
- import type { ApiCoreStorageOperations } from "./types/core.js";
2
+ import type { ApiCoreConfig } from "./types/core.js";
3
3
  export declare const ApiCoreFeature: {
4
4
  name: string;
5
- register(container: Container, context: ApiCoreStorageOperations): void;
5
+ register(container: Container, context?: ApiCoreConfig | undefined): void;
6
6
  };
package/ApiCoreFeature.js CHANGED
@@ -5,33 +5,57 @@ import { SecurityFeature } from "./features/security/SecurityFeature.js";
5
5
  import { SystemFeature } from "./features/system/SystemFeature.js";
6
6
  import { TenancyFeature } from "./features/tenancy/TenancyFeature.js";
7
7
  import { AdminUsersFeature } from "./features/users/AdminUsersFeature.js";
8
+ import { ApiCoreStorageOperationsFactory } from "./features/storageOperations/abstractions.js";
8
9
  import { IdpAuthenticatorFeature } from "./idp/feature.js";
9
10
  import { KeyValueStoreFeature } from "./features/keyValueStore/feature.js";
10
11
  import { BuildParamsFeature } from "./features/buildParams/feature.js";
11
12
  import { EncryptionFeature } from "./features/encryption/feature.js";
13
+ import { HasherFeature } from "./features/hashing/feature.js";
12
14
  import { FeatureFlagsFeature } from "./features/featureFlags/feature.js";
13
15
  import { MaskerFeature } from "./features/masker/feature.js";
16
+ import { StringFormatterFeature } from "./features/stringFormatter/feature.js";
17
+ import { DateFormatterFeature } from "./features/dateFormatter/feature.js";
14
18
  import { AiFeature } from "./features/ai/feature.js";
19
+ import { WcpFeature } from "./features/wcp/WcpFeature.js";
15
20
  import { NullWebhookDispatcher } from "./features/webhooks/WebhookDispatcher/NullWebhookDispatcher.js";
16
21
  import { WebhookProviderFeature } from "./features/webhooks/index.js";
22
+ import { RequestContextFeature } from "./features/requestContext/index.js";
23
+ import { ApiCoreSchemaFactory } from "./graphql/ApiCoreSchemaFactory.js";
24
+ import { SecuritySchemaFactory } from "./graphql/security/SecuritySchemaFactory.js";
25
+ import { UsersSchemaFactory } from "./graphql/users/UsersSchemaFactory.js";
26
+ import { SystemSchemaFactory } from "./graphql/system/SystemSchemaFactory.js";
27
+ import { WcpSchemaFactory } from "./graphql/wcp/WcpSchemaFactory.js";
28
+ import { FeatureFlagsSchemaFactory } from "./graphql/featureFlags/FeatureFlagsSchemaFactory.js";
17
29
  const ApiCoreFeature = createFeature({
18
30
  name: "ApiCore",
19
- register (container, config) {
31
+ register (container, config = {}) {
32
+ const storageOperations = container.resolve(ApiCoreStorageOperationsFactory).create();
33
+ WcpFeature.register(container, config.wcpLicense);
20
34
  MaskerFeature.register(container);
35
+ StringFormatterFeature.register(container);
36
+ DateFormatterFeature.register(container);
21
37
  AiFeature.register(container);
22
38
  LoggerFeature.register(container);
23
39
  EventPublisherFeature.register(container);
24
40
  BuildParamsFeature.register(container);
25
41
  EncryptionFeature.register(container);
42
+ HasherFeature.register(container);
26
43
  FeatureFlagsFeature.register(container);
27
- TenancyFeature.register(container, config.tenancyStorageOperations);
28
- SecurityFeature.register(container, config.securityStorageOperations);
29
- AdminUsersFeature.register(container, config.usersStorageOperations);
30
- KeyValueStoreFeature.register(container, config.keyValueStorageOperations);
44
+ TenancyFeature.register(container, storageOperations.tenancyStorageOperations);
45
+ SecurityFeature.register(container, storageOperations.securityStorageOperations);
46
+ AdminUsersFeature.register(container, storageOperations.usersStorageOperations);
47
+ KeyValueStoreFeature.register(container, storageOperations.keyValueStorageOperations);
31
48
  SystemFeature.register(container);
32
49
  IdpAuthenticatorFeature.register(container);
50
+ RequestContextFeature.register(container);
33
51
  container.register(NullWebhookDispatcher).inSingletonScope();
34
52
  WebhookProviderFeature.register(container);
53
+ container.register(ApiCoreSchemaFactory);
54
+ container.register(SecuritySchemaFactory);
55
+ container.register(UsersSchemaFactory);
56
+ container.register(SystemSchemaFactory);
57
+ container.register(WcpSchemaFactory);
58
+ container.register(FeatureFlagsSchemaFactory);
35
59
  }
36
60
  });
37
61
  export { ApiCoreFeature };
@@ -1 +1 @@
1
- {"version":3,"file":"ApiCoreFeature.js","sources":["../src/ApiCoreFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { Container } from \"@webiny/di\";\nimport { EventPublisherFeature } from \"~/features/eventPublisher/feature.js\";\nimport { LoggerFeature } from \"~/features/logger/feature.js\";\nimport { SecurityFeature } from \"~/features/security/SecurityFeature.js\";\nimport { SystemFeature } from \"~/features/system/SystemFeature.js\";\nimport { TenancyFeature } from \"./features/tenancy/TenancyFeature.js\";\nimport { AdminUsersFeature } from \"~/features/users/AdminUsersFeature.js\";\nimport type { ApiCoreStorageOperations } from \"~/types/core.js\";\nimport { IdpAuthenticatorFeature } from \"~/idp/feature.js\";\nimport { KeyValueStoreFeature } from \"~/features/keyValueStore/feature.js\";\nimport { BuildParamsFeature } from \"~/features/buildParams/feature.js\";\nimport { EncryptionFeature } from \"~/features/encryption/feature.js\";\nimport { FeatureFlagsFeature } from \"~/features/featureFlags/feature.js\";\nimport { MaskerFeature } from \"~/features/masker/feature.js\";\nimport { AiFeature } from \"~/features/ai/feature.js\";\nimport { NullWebhookDispatcher } from \"./features/webhooks/WebhookDispatcher/NullWebhookDispatcher.js\";\nimport { WebhookProviderFeature } from \"~/features/webhooks/index.js\";\n\nexport const ApiCoreFeature = createFeature({\n name: \"ApiCore\",\n register(container: Container, config: ApiCoreStorageOperations) {\n // Register features\n MaskerFeature.register(container);\n AiFeature.register(container);\n LoggerFeature.register(container);\n EventPublisherFeature.register(container);\n BuildParamsFeature.register(container);\n EncryptionFeature.register(container);\n FeatureFlagsFeature.register(container);\n TenancyFeature.register(container, config.tenancyStorageOperations);\n SecurityFeature.register(container, config.securityStorageOperations);\n AdminUsersFeature.register(container, config.usersStorageOperations);\n KeyValueStoreFeature.register(container, config.keyValueStorageOperations);\n SystemFeature.register(container);\n IdpAuthenticatorFeature.register(container);\n container.register(NullWebhookDispatcher).inSingletonScope();\n WebhookProviderFeature.register(container);\n }\n});\n"],"names":["ApiCoreFeature","createFeature","container","config","MaskerFeature","AiFeature","LoggerFeature","EventPublisherFeature","BuildParamsFeature","EncryptionFeature","FeatureFlagsFeature","TenancyFeature","SecurityFeature","AdminUsersFeature","KeyValueStoreFeature","SystemFeature","IdpAuthenticatorFeature","NullWebhookDispatcher","WebhookProviderFeature"],"mappings":";;;;;;;;;;;;;;;;AAmBO,MAAMA,iBAAiBC,cAAc;IACxC,MAAM;IACN,UAASC,SAAoB,EAAEC,MAAgC;QAE3DC,cAAc,QAAQ,CAACF;QACvBG,UAAU,QAAQ,CAACH;QACnBI,cAAc,QAAQ,CAACJ;QACvBK,sBAAsB,QAAQ,CAACL;QAC/BM,mBAAmB,QAAQ,CAACN;QAC5BO,kBAAkB,QAAQ,CAACP;QAC3BQ,oBAAoB,QAAQ,CAACR;QAC7BS,eAAe,QAAQ,CAACT,WAAWC,OAAO,wBAAwB;QAClES,gBAAgB,QAAQ,CAACV,WAAWC,OAAO,yBAAyB;QACpEU,kBAAkB,QAAQ,CAACX,WAAWC,OAAO,sBAAsB;QACnEW,qBAAqB,QAAQ,CAACZ,WAAWC,OAAO,yBAAyB;QACzEY,cAAc,QAAQ,CAACb;QACvBc,wBAAwB,QAAQ,CAACd;QACjCA,UAAU,QAAQ,CAACe,uBAAuB,gBAAgB;QAC1DC,uBAAuB,QAAQ,CAAChB;IACpC;AACJ"}
1
+ {"version":3,"file":"ApiCoreFeature.js","sources":["../src/ApiCoreFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { Container } from \"@webiny/di\";\nimport { EventPublisherFeature } from \"~/features/eventPublisher/feature.js\";\nimport { LoggerFeature } from \"~/features/logger/feature.js\";\nimport { SecurityFeature } from \"~/features/security/SecurityFeature.js\";\nimport { SystemFeature } from \"~/features/system/SystemFeature.js\";\nimport { TenancyFeature } from \"./features/tenancy/TenancyFeature.js\";\nimport { AdminUsersFeature } from \"~/features/users/AdminUsersFeature.js\";\nimport type { ApiCoreConfig } from \"~/types/core.js\";\nimport { ApiCoreStorageOperationsFactory } from \"~/features/storageOperations/abstractions.js\";\nimport { IdpAuthenticatorFeature } from \"~/idp/feature.js\";\nimport { KeyValueStoreFeature } from \"~/features/keyValueStore/feature.js\";\nimport { BuildParamsFeature } from \"~/features/buildParams/feature.js\";\nimport { EncryptionFeature } from \"~/features/encryption/feature.js\";\nimport { HasherFeature } from \"~/features/hashing/feature.js\";\nimport { FeatureFlagsFeature } from \"~/features/featureFlags/feature.js\";\nimport { MaskerFeature } from \"~/features/masker/feature.js\";\nimport { StringFormatterFeature } from \"~/features/stringFormatter/feature.js\";\nimport { DateFormatterFeature } from \"~/features/dateFormatter/feature.js\";\nimport { AiFeature } from \"~/features/ai/feature.js\";\nimport { WcpFeature } from \"~/features/wcp/WcpFeature.js\";\nimport { NullWebhookDispatcher } from \"./features/webhooks/WebhookDispatcher/NullWebhookDispatcher.js\";\nimport { WebhookProviderFeature } from \"~/features/webhooks/index.js\";\nimport { RequestContextFeature } from \"~/features/requestContext/index.js\";\nimport { ApiCoreSchemaFactory } from \"~/graphql/ApiCoreSchemaFactory.js\";\nimport { SecuritySchemaFactory } from \"~/graphql/security/SecuritySchemaFactory.js\";\nimport { UsersSchemaFactory } from \"~/graphql/users/UsersSchemaFactory.js\";\nimport { SystemSchemaFactory } from \"~/graphql/system/SystemSchemaFactory.js\";\nimport { WcpSchemaFactory } from \"~/graphql/wcp/WcpSchemaFactory.js\";\nimport { FeatureFlagsSchemaFactory } from \"~/graphql/featureFlags/FeatureFlagsSchemaFactory.js\";\n\nexport const ApiCoreFeature = createFeature({\n name: \"ApiCore\",\n register(container: Container, config: ApiCoreConfig = {}) {\n // Storage operations are built synchronously, here, from the adapter-provided factory —\n // the same way for every event (no out-of-feature construction, no async initializer).\n const storageOperations = container.resolve(ApiCoreStorageOperationsFactory).create();\n\n // Register features\n WcpFeature.register(container, config.wcpLicense);\n MaskerFeature.register(container);\n StringFormatterFeature.register(container);\n DateFormatterFeature.register(container);\n AiFeature.register(container);\n LoggerFeature.register(container);\n EventPublisherFeature.register(container);\n BuildParamsFeature.register(container);\n EncryptionFeature.register(container);\n HasherFeature.register(container);\n FeatureFlagsFeature.register(container);\n TenancyFeature.register(container, storageOperations.tenancyStorageOperations);\n SecurityFeature.register(container, storageOperations.securityStorageOperations);\n AdminUsersFeature.register(container, storageOperations.usersStorageOperations);\n KeyValueStoreFeature.register(container, storageOperations.keyValueStorageOperations);\n SystemFeature.register(container);\n IdpAuthenticatorFeature.register(container);\n RequestContextFeature.register(container);\n container.register(NullWebhookDispatcher).inSingletonScope();\n WebhookProviderFeature.register(container);\n\n // Core API GraphQL schema: a base factory (root types + scalars) plus one\n // CoreGraphQLSchemaFactory per domain.\n container.register(ApiCoreSchemaFactory);\n container.register(SecuritySchemaFactory);\n container.register(UsersSchemaFactory);\n container.register(SystemSchemaFactory);\n container.register(WcpSchemaFactory);\n container.register(FeatureFlagsSchemaFactory);\n }\n});\n"],"names":["ApiCoreFeature","createFeature","container","config","storageOperations","ApiCoreStorageOperationsFactory","WcpFeature","MaskerFeature","StringFormatterFeature","DateFormatterFeature","AiFeature","LoggerFeature","EventPublisherFeature","BuildParamsFeature","EncryptionFeature","HasherFeature","FeatureFlagsFeature","TenancyFeature","SecurityFeature","AdminUsersFeature","KeyValueStoreFeature","SystemFeature","IdpAuthenticatorFeature","RequestContextFeature","NullWebhookDispatcher","WebhookProviderFeature","ApiCoreSchemaFactory","SecuritySchemaFactory","UsersSchemaFactory","SystemSchemaFactory","WcpSchemaFactory","FeatureFlagsSchemaFactory"],"mappings":";;;;;;;;;;;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../features/security/apiKeys/DeleteApiKey/index.js";
3
3
  export { GetApiKeyUseCase } from "../../../features/security/apiKeys/GetApiKey/index.js";
4
4
  export { GetApiKeyByTokenUseCase } from "../../../features/security/apiKeys/GetApiKeyByToken/index.js";
5
+ export { GetApiKeyBySlugUseCase } from "../../../features/security/apiKeys/GetApiKeyBySlug/index.js";
5
6
  export { ListApiKeysUseCase } from "../../../features/security/apiKeys/ListApiKeys/index.js";
6
7
  export { ApiKeyAfterUpdateEventHandler, ApiKeyBeforeUpdateEventHandler, UpdateApiKeyUseCase } from "../../../features/security/apiKeys/UpdateApiKey/index.js";
7
8
  export { ApiKeyFactory } from "../../../features/security/apiKeys/shared/abstractions.js";
@@ -2,6 +2,7 @@ export { ApiKeyAfterCreateEventHandler, ApiKeyBeforeCreateEventHandler, CreateAp
2
2
  export { ApiKeyAfterDeleteEventHandler, ApiKeyBeforeDeleteEventHandler, DeleteApiKeyUseCase } from "../../../features/security/apiKeys/DeleteApiKey/index.js";
3
3
  export { GetApiKeyUseCase } from "../../../features/security/apiKeys/GetApiKey/index.js";
4
4
  export { GetApiKeyByTokenUseCase } from "../../../features/security/apiKeys/GetApiKeyByToken/index.js";
5
+ export { GetApiKeyBySlugUseCase } from "../../../features/security/apiKeys/GetApiKeyBySlug/index.js";
5
6
  export { ListApiKeysUseCase } from "../../../features/security/apiKeys/ListApiKeys/index.js";
6
7
  export { ApiKeyAfterUpdateEventHandler, ApiKeyBeforeUpdateEventHandler, UpdateApiKeyUseCase } from "../../../features/security/apiKeys/UpdateApiKey/index.js";
7
8
  export { ApiKeyFactory } from "../../../features/security/apiKeys/shared/abstractions.js";
package/exports/api.d.ts CHANGED
@@ -1,6 +1,8 @@
1
- export { AiSdk, AiSdkFactory, AiConnectionFactory, Ai, AiModelRegistry } from "../features/ai/index.js";
1
+ export { AiSdk, AiSdkFactory, AiSdkTool, AiConnectionFactory, Ai } from "../features/ai/index.js";
2
+ export type { IAiConnection, IAiConnectionInline } from "../features/ai/index.js";
2
3
  export { Logger } from "../features/logger/index.js";
3
4
  export { Encryption } from "../features/encryption/index.js";
5
+ export { Hasher } from "../features/hashing/index.js";
4
6
  export { BuildParam, BuildParams } from "../features/buildParams/index.js";
5
7
  export { DomainEvent, EventPublisher } from "../features/eventPublisher/index.js";
6
8
  export { GlobalKeyValueStore, KeyValueStore } from "../features/keyValueStore/index.js";
package/exports/api.js CHANGED
@@ -1,6 +1,7 @@
1
- export { Ai, AiConnectionFactory, AiModelRegistry, AiSdk, AiSdkFactory } from "../features/ai/index.js";
1
+ export { Ai, AiConnectionFactory, AiSdk, AiSdkFactory, AiSdkTool } from "../features/ai/index.js";
2
2
  export { Logger } from "../features/logger/index.js";
3
3
  export { Encryption } from "../features/encryption/index.js";
4
+ export { Hasher } from "../features/hashing/index.js";
4
5
  export { BuildParam, BuildParams } from "../features/buildParams/index.js";
5
6
  export { DomainEvent, EventPublisher } from "../features/eventPublisher/index.js";
6
7
  export { GlobalKeyValueStore, KeyValueStore } from "../features/keyValueStore/index.js";
@@ -3,17 +3,17 @@ import { streamText } from "ai";
3
3
  import { Ai as AiAbstraction } from "./abstractions.js";
4
4
  import { AiSdkFactory } from "./abstractions.js";
5
5
  import { AiConnectionFactory } from "./abstractions.js";
6
- import { AiModelRegistry } from "./abstractions.js";
7
6
  import type { AiGenerateTextParams, AiModel } from "./abstractions.js";
8
7
  import type { AiStreamTextParams } from "./abstractions.js";
9
8
  import type { IAiConnectionInline } from "./abstractions.js";
9
+ import { EventPublisher } from "../../features/eventPublisher/index.js";
10
10
  declare class AiImpl implements AiAbstraction.Interface {
11
11
  private readonly sdkFactories;
12
12
  private readonly connectionFactories;
13
- private readonly modelRegistry;
13
+ private readonly eventPublisher;
14
14
  private sdkCache;
15
15
  private resolvedConnections;
16
- constructor(sdkFactories: AiSdkFactory.Interface[], connectionFactories: AiConnectionFactory.Interface[], modelRegistry: AiModelRegistry.Interface);
16
+ constructor(sdkFactories: AiSdkFactory.Interface[], connectionFactories: AiConnectionFactory.Interface[], eventPublisher: EventPublisher.Interface);
17
17
  generateText(params: AiGenerateTextParams): ReturnType<typeof generateText>;
18
18
  streamText(params: AiStreamTextParams): Promise<ReturnType<typeof streamText>>;
19
19
  listModels(): Promise<AiModel[]>;
package/features/ai/Ai.js CHANGED
@@ -1,58 +1,95 @@
1
1
  import { createImplementation } from "@webiny/feature/api";
2
2
  import { generateText, streamText } from "ai";
3
- import { Ai, AiConnectionFactory, AiModelRegistry, AiSdkFactory } from "./abstractions.js";
3
+ import { Ai, AiConnectionFactory, AiSdkFactory } from "./abstractions.js";
4
+ import { mdbid } from "@webiny/utils/mdbid.js";
5
+ import { EventPublisher } from "../eventPublisher/index.js";
6
+ import { AiAfterGenerateTextEvent, AiBeforeGenerateTextEvent, AiBeforeStreamTextEvent, AiGenerateTextErrorEvent } from "./events.js";
7
+ function toAiModel(factory, modelId, modelName) {
8
+ return {
9
+ providerId: factory.id,
10
+ providerName: factory.name,
11
+ modelId,
12
+ modelName
13
+ };
14
+ }
4
15
  class AiImpl {
5
- constructor(sdkFactories, connectionFactories, modelRegistry){
16
+ constructor(sdkFactories, connectionFactories, eventPublisher){
6
17
  this.sdkFactories = sdkFactories;
7
18
  this.connectionFactories = connectionFactories;
8
- this.modelRegistry = modelRegistry;
19
+ this.eventPublisher = eventPublisher;
9
20
  this.sdkCache = new Map();
10
21
  this.resolvedConnections = null;
11
22
  }
12
- generateText(params) {
23
+ async generateText(params) {
13
24
  const { model, connection, ...rest } = params;
14
- return this.resolveLanguageModel(model, connection).then((resolvedModel)=>generateText({
25
+ const resolvedModel = await this.resolveLanguageModel(model, connection);
26
+ const requestId = mdbid();
27
+ await this.eventPublisher.publish(new AiBeforeGenerateTextEvent({
28
+ requestId,
29
+ params
30
+ }));
31
+ const start = performance.now();
32
+ try {
33
+ const result = await generateText({
15
34
  model: resolvedModel,
16
35
  ...rest
36
+ });
37
+ const duration = performance.now() - start;
38
+ await this.eventPublisher.publish(new AiAfterGenerateTextEvent({
39
+ requestId,
40
+ params,
41
+ result,
42
+ duration
43
+ }));
44
+ return result;
45
+ } catch (err) {
46
+ const duration = performance.now() - start;
47
+ const error = err instanceof Error ? err : new Error(String(err));
48
+ await this.eventPublisher.publish(new AiGenerateTextErrorEvent({
49
+ requestId,
50
+ params,
51
+ error,
52
+ duration
17
53
  }));
54
+ throw err;
55
+ }
18
56
  }
19
57
  async streamText(params) {
20
58
  const { model, connection, ...rest } = params;
21
59
  const resolvedModel = await this.resolveLanguageModel(model, connection);
60
+ await this.eventPublisher.publish(new AiBeforeStreamTextEvent({
61
+ params
62
+ }));
22
63
  return streamText({
23
64
  model: resolvedModel,
24
65
  ...rest
25
66
  });
26
67
  }
27
68
  listModels() {
28
- return this.modelRegistry.listModels();
69
+ return Promise.resolve(this.sdkFactories.flatMap((factory)=>factory.models.map((m)=>toAiModel(factory, m.id, m.name))));
29
70
  }
30
71
  async listModelsByConnections() {
31
- const [connections, models] = await Promise.all([
32
- this.getConnections(),
33
- this.modelRegistry.listModels()
34
- ]);
35
- const connectedProviderIds = new Set(connections.map((c)=>c.sdkName));
36
- return models.filter((m)=>connectedProviderIds.has(m.providerId));
72
+ const connections = await this.getConnections();
73
+ return connections.flatMap((conn)=>{
74
+ const factory = this.sdkFactories.find((f)=>f.id === conn.sdkName);
75
+ if (!factory) return [];
76
+ return factory.models.map((m)=>toAiModel(factory, m.id, m.name));
77
+ });
37
78
  }
38
79
  async listModelsByConnection(connection) {
39
- const [conn, models] = await Promise.all([
40
- this.resolveConnection(void 0, connection),
41
- this.modelRegistry.listModels()
42
- ]);
43
- return models.filter((m)=>m.providerId === conn.sdkName);
80
+ const conn = await this.resolveConnection(void 0, connection);
81
+ const factory = this.sdkFactories.find((f)=>f.id === conn.sdkName);
82
+ if (!factory) return [];
83
+ return factory.models.map((m)=>toAiModel(factory, m.id, m.name));
44
84
  }
45
85
  async resolveLanguageModel(modelId, connection) {
46
86
  const slashIndex = modelId.indexOf("/");
47
87
  if (-1 === slashIndex) throw new Error(`Invalid model ID "${modelId}". Expected format: "<providerId>/<modelId>" (e.g. "openai/gpt-4o").`);
48
88
  const providerId = modelId.slice(0, slashIndex);
49
- const rawModelId = modelId.slice(slashIndex + 1);
50
- const models = await this.modelRegistry.listModels();
51
- const found = models.some((m)=>m.providerId === providerId && m.modelId === rawModelId);
52
- if (!found) throw new Error(`Model "${modelId}" is not available. Use listModels() to see available models.`);
89
+ const modelName = modelId.slice(slashIndex + 1);
53
90
  const conn = await this.resolveConnection(providerId, connection);
54
91
  const sdk = await this.getSdk(conn);
55
- return sdk.languageModel(rawModelId);
92
+ return sdk.languageModel(modelName);
56
93
  }
57
94
  async getConnections() {
58
95
  if (!this.resolvedConnections) this.resolvedConnections = await Promise.all(this.connectionFactories.map((f)=>f.execute()));
@@ -106,7 +143,7 @@ const Ai_Ai = createImplementation({
106
143
  multiple: true
107
144
  }
108
145
  ],
109
- AiModelRegistry
146
+ EventPublisher
110
147
  ]
111
148
  });
112
149
  export { Ai_Ai as Ai };
@@ -1 +1 @@
1
- {"version":3,"file":"features/ai/Ai.js","sources":["../../../src/features/ai/Ai.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { generateText } from \"ai\";\nimport { streamText } from \"ai\";\nimport { Ai as AiAbstraction } from \"./abstractions.js\";\nimport { AiSdkFactory } from \"./abstractions.js\";\nimport { AiConnectionFactory } from \"./abstractions.js\";\nimport { AiModelRegistry } from \"./abstractions.js\";\nimport type { AiGenerateTextParams, AiModel } from \"./abstractions.js\";\nimport type { AiStreamTextParams } from \"./abstractions.js\";\nimport type { IAiSdk } from \"./abstractions.js\";\nimport type { IAiConnection } from \"./abstractions.js\";\nimport type { IAiConnectionInline } from \"./abstractions.js\";\nimport type { LanguageModel } from \"ai\";\n\nclass AiImpl implements AiAbstraction.Interface {\n private sdkCache = new Map<string, IAiSdk>();\n private resolvedConnections: IAiConnection[] | null = null;\n\n constructor(\n private readonly sdkFactories: AiSdkFactory.Interface[],\n private readonly connectionFactories: AiConnectionFactory.Interface[],\n private readonly modelRegistry: AiModelRegistry.Interface\n ) {}\n\n generateText(params: AiGenerateTextParams): ReturnType<typeof generateText> {\n const { model, connection, ...rest } = params;\n return this.resolveLanguageModel(model, connection).then(resolvedModel => {\n // Cast required: spreading the discriminated Prompt union loses its narrowing.\n return generateText({ model: resolvedModel, ...rest } as Parameters<\n typeof generateText\n >[0]);\n });\n }\n\n async streamText(params: AiStreamTextParams): Promise<ReturnType<typeof streamText>> {\n const { model, connection, ...rest } = params;\n const resolvedModel = await this.resolveLanguageModel(model, connection);\n // Cast required: spreading the discriminated Prompt union loses its narrowing.\n return streamText({ model: resolvedModel, ...rest } as Parameters<typeof streamText>[0]);\n }\n\n listModels(): Promise<AiModel[]> {\n return this.modelRegistry.listModels();\n }\n\n async listModelsByConnections(): Promise<AiModel[]> {\n const [connections, models] = await Promise.all([\n this.getConnections(),\n this.modelRegistry.listModels()\n ]);\n const connectedProviderIds = new Set(connections.map(c => c.sdkName));\n return models.filter(m => connectedProviderIds.has(m.providerId));\n }\n\n async listModelsByConnection(connection: string | IAiConnectionInline): Promise<AiModel[]> {\n const [conn, models] = await Promise.all([\n this.resolveConnection(undefined, connection),\n this.modelRegistry.listModels()\n ]);\n return models.filter(m => m.providerId === conn.sdkName);\n }\n\n private async resolveLanguageModel(\n modelId: string,\n connection?: string | IAiConnectionInline\n ): Promise<LanguageModel> {\n const slashIndex = modelId.indexOf(\"/\");\n if (slashIndex === -1) {\n throw new Error(\n `Invalid model ID \"${modelId}\". Expected format: \"<providerId>/<modelId>\" (e.g. \"openai/gpt-4o\").`\n );\n }\n\n const providerId = modelId.slice(0, slashIndex);\n const rawModelId = modelId.slice(slashIndex + 1);\n\n // Validate the model is in the registry.\n const models = await this.modelRegistry.listModels();\n const found = models.some(m => m.providerId === providerId && m.modelId === rawModelId);\n if (!found) {\n throw new Error(\n `Model \"${modelId}\" is not available. Use listModels() to see available models.`\n );\n }\n\n const conn = await this.resolveConnection(providerId, connection);\n const sdk = await this.getSdk(conn);\n return sdk.languageModel(rawModelId);\n }\n\n private async getConnections(): Promise<IAiConnection[]> {\n if (!this.resolvedConnections) {\n this.resolvedConnections = await Promise.all(\n this.connectionFactories.map(f => f.execute())\n );\n }\n return this.resolvedConnections;\n }\n\n private async resolveConnection(\n providerId: string | undefined,\n connection?: string | IAiConnectionInline\n ): Promise<IAiConnectionInline> {\n if (typeof connection === \"object\") {\n return connection;\n }\n\n const connections = await this.getConnections();\n\n if (typeof connection === \"string\") {\n const found = connections.find(c => c.id === connection);\n if (!found) {\n const known = connections.map(c => `\"${c.id}\"`).join(\", \");\n throw new Error(\n `Unknown AI connection \"${connection}\". Registered connections: ${known}.`\n );\n }\n return found;\n }\n\n const found = connections.find(c => c.sdkName === providerId);\n if (!found) {\n const known = connections.map(c => `\"${c.id}\" (${c.sdkName})`).join(\", \");\n throw new Error(\n `No AI connection found for provider \"${providerId}\". Registered connections: ${known}.`\n );\n }\n return found;\n }\n\n private async getSdk(connection: IAiConnectionInline): Promise<IAiSdk> {\n const cacheKey =\n \"id\" in connection\n ? (connection as IAiConnection).id\n : `${connection.sdkName}:${connection.apiKey ?? \"__env__\"}`;\n\n const cached = this.sdkCache.get(cacheKey);\n if (cached) {\n return cached;\n }\n\n const factory = this.sdkFactories.find(f => f.id === connection.sdkName);\n if (!factory) {\n const known = this.sdkFactories.map(f => `\"${f.id}\"`).join(\", \");\n throw new Error(\n `No AI SDK factory found for \"${connection.sdkName}\". Registered factories: ${known}.`\n );\n }\n\n const sdk = await factory.execute(connection.apiKey);\n this.sdkCache.set(cacheKey, sdk);\n return sdk;\n }\n}\n\nexport const Ai = createImplementation({\n abstraction: AiAbstraction,\n implementation: AiImpl,\n dependencies: [\n [AiSdkFactory, { multiple: true }],\n [AiConnectionFactory, { multiple: true }],\n AiModelRegistry\n ]\n});\n"],"names":["AiImpl","sdkFactories","connectionFactories","modelRegistry","Map","params","model","connection","rest","resolvedModel","generateText","streamText","connections","models","Promise","connectedProviderIds","Set","c","m","conn","undefined","modelId","slashIndex","Error","providerId","rawModelId","found","sdk","f","known","cacheKey","cached","factory","Ai","createImplementation","AiAbstraction","AiSdkFactory","AiConnectionFactory","AiModelRegistry"],"mappings":";;;AAcA,MAAMA;IAIF,YACqBC,YAAsC,EACtCC,mBAAoD,EACpDC,aAAwC,CAC3D;aAHmBF,YAAY,GAAZA;aACAC,mBAAmB,GAAnBA;aACAC,aAAa,GAAbA;aANb,QAAQ,GAAG,IAAIC;aACf,mBAAmB,GAA2B;IAMnD;IAEH,aAAaC,MAA4B,EAAmC;QACxE,MAAM,EAAEC,KAAK,EAAEC,UAAU,EAAE,GAAGC,MAAM,GAAGH;QACvC,OAAO,IAAI,CAAC,oBAAoB,CAACC,OAAOC,YAAY,IAAI,CAACE,CAAAA,gBAE9CC,aAAa;gBAAE,OAAOD;gBAAe,GAAGD,IAAI;YAAC;IAI5D;IAEA,MAAM,WAAWH,MAA0B,EAA0C;QACjF,MAAM,EAAEC,KAAK,EAAEC,UAAU,EAAE,GAAGC,MAAM,GAAGH;QACvC,MAAMI,gBAAgB,MAAM,IAAI,CAAC,oBAAoB,CAACH,OAAOC;QAE7D,OAAOI,WAAW;YAAE,OAAOF;YAAe,GAAGD,IAAI;QAAC;IACtD;IAEA,aAAiC;QAC7B,OAAO,IAAI,CAAC,aAAa,CAAC,UAAU;IACxC;IAEA,MAAM,0BAA8C;QAChD,MAAM,CAACI,aAAaC,OAAO,GAAG,MAAMC,QAAQ,GAAG,CAAC;YAC5C,IAAI,CAAC,cAAc;YACnB,IAAI,CAAC,aAAa,CAAC,UAAU;SAChC;QACD,MAAMC,uBAAuB,IAAIC,IAAIJ,YAAY,GAAG,CAACK,CAAAA,IAAKA,EAAE,OAAO;QACnE,OAAOJ,OAAO,MAAM,CAACK,CAAAA,IAAKH,qBAAqB,GAAG,CAACG,EAAE,UAAU;IACnE;IAEA,MAAM,uBAAuBX,UAAwC,EAAsB;QACvF,MAAM,CAACY,MAAMN,OAAO,GAAG,MAAMC,QAAQ,GA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A6B,EAAEhB,WAAW,OAAO,CAAC,yBAAyB,EAAEsB,MAAM,CAAC,CAAC;QAE9F;QAEA,MAAMF,MAAM,MAAMK,QAAQ,OAAO,CAACzB,WAAW,MAAM;QACnD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAACuB,UAAUH;QAC5B,OAAOA;IACX;AACJ;AAEO,MAAMM,QAAKC,qBAAqB;IACnC,aAAaC;IACb,gBAAgBnC;IAChB,cAAc;QACV;YAACoC;YAAc;gBAAE,UAAU;YAAK;SAAE;QAClC;YAACC;YAAqB;gBAAE,UAAU;YAAK;SAAE;QACzCC;KACH;AACL"}
1
+ {"version":3,"file":"features/ai/Ai.js","sources":["../../../src/features/ai/Ai.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { generateText } from \"ai\";\nimport { streamText } from \"ai\";\nimport { Ai as AiAbstraction } from \"./abstractions.js\";\nimport { AiSdkFactory } from \"./abstractions.js\";\nimport { AiConnectionFactory } from \"./abstractions.js\";\nimport type { AiGenerateTextParams, AiModel, IAiSdkFactory } from \"./abstractions.js\";\nimport type { AiStreamTextParams } from \"./abstractions.js\";\nimport type { IAiSdk } from \"./abstractions.js\";\nimport type { IAiConnection } from \"./abstractions.js\";\nimport type { IAiConnectionInline } from \"./abstractions.js\";\nimport type { LanguageModel } from \"ai\";\nimport { mdbid } from \"@webiny/utils/mdbid.js\";\nimport { EventPublisher } from \"~/features/eventPublisher/index.js\";\nimport {\n AiBeforeGenerateTextEvent,\n AiAfterGenerateTextEvent,\n AiGenerateTextErrorEvent,\n AiBeforeStreamTextEvent\n} from \"./events.js\";\n\nfunction toAiModel(factory: IAiSdkFactory, modelId: string, modelName: string): AiModel {\n return {\n providerId: factory.id,\n providerName: factory.name,\n modelId,\n modelName\n };\n}\n\nclass AiImpl implements AiAbstraction.Interface {\n private sdkCache = new Map<string, IAiSdk>();\n private resolvedConnections: IAiConnection[] | null = null;\n\n constructor(\n private readonly sdkFactories: AiSdkFactory.Interface[],\n private readonly connectionFactories: AiConnectionFactory.Interface[],\n private readonly eventPublisher: EventPublisher.Interface\n ) {}\n\n async generateText(params: AiGenerateTextParams): ReturnType<typeof generateText> {\n const { model, connection, ...rest } = params;\n const resolvedModel = await this.resolveLanguageModel(model, connection);\n const requestId = mdbid();\n\n await this.eventPublisher.publish(new AiBeforeGenerateTextEvent({ requestId, params }));\n\n const start = performance.now();\n\n try {\n const result = await generateText({ model: resolvedModel, ...rest } as Parameters<\n typeof generateText\n >[0]);\n\n const duration = performance.now() - start;\n\n await this.eventPublisher.publish(\n new AiAfterGenerateTextEvent({ requestId, params, result, duration })\n );\n\n return result;\n } catch (err) {\n const duration = performance.now() - start;\n const error = err instanceof Error ? err : new Error(String(err));\n\n await this.eventPublisher.publish(\n new AiGenerateTextErrorEvent({ requestId, params, error, duration })\n );\n\n throw err;\n }\n }\n\n async streamText(params: AiStreamTextParams): Promise<ReturnType<typeof streamText>> {\n const { model, connection, ...rest } = params;\n const resolvedModel = await this.resolveLanguageModel(model, connection);\n\n await this.eventPublisher.publish(new AiBeforeStreamTextEvent({ params }));\n\n // Cast required: spreading the discriminated Prompt union loses its narrowing.\n return streamText({ model: resolvedModel, ...rest } as Parameters<typeof streamText>[0]);\n }\n\n listModels(): Promise<AiModel[]> {\n return Promise.resolve(\n this.sdkFactories.flatMap(factory =>\n factory.models.map(m => toAiModel(factory, m.id, m.name))\n )\n );\n }\n\n async listModelsByConnections(): Promise<AiModel[]> {\n const connections = await this.getConnections();\n return connections.flatMap(conn => {\n const factory = this.sdkFactories.find(f => f.id === conn.sdkName);\n if (!factory) {\n return [];\n }\n return factory.models.map(m => toAiModel(factory, m.id, m.name));\n });\n }\n\n async listModelsByConnection(connection: string | IAiConnectionInline): Promise<AiModel[]> {\n const conn = await this.resolveConnection(undefined, connection);\n const factory = this.sdkFactories.find(f => f.id === conn.sdkName);\n if (!factory) {\n return [];\n }\n return factory.models.map(m => toAiModel(factory, m.id, m.name));\n }\n\n private async resolveLanguageModel(\n modelId: string,\n connection?: string | IAiConnectionInline\n ): Promise<LanguageModel> {\n const slashIndex = modelId.indexOf(\"/\");\n if (slashIndex === -1) {\n throw new Error(\n `Invalid model ID \"${modelId}\". Expected format: \"<providerId>/<modelId>\" (e.g. \"openai/gpt-4o\").`\n );\n }\n\n const providerId = modelId.slice(0, slashIndex);\n const modelName = modelId.slice(slashIndex + 1);\n\n const conn = await this.resolveConnection(providerId, connection);\n const sdk = await this.getSdk(conn);\n return sdk.languageModel(modelName);\n }\n\n private async getConnections(): Promise<IAiConnection[]> {\n if (!this.resolvedConnections) {\n this.resolvedConnections = await Promise.all(\n this.connectionFactories.map(f => f.execute())\n );\n }\n return this.resolvedConnections;\n }\n\n private async resolveConnection(\n providerId: string | undefined,\n connection?: string | IAiConnectionInline\n ): Promise<IAiConnectionInline> {\n if (typeof connection === \"object\") {\n return connection;\n }\n\n const connections = await this.getConnections();\n\n if (typeof connection === \"string\") {\n const found = connections.find(c => c.id === connection);\n if (!found) {\n const known = connections.map(c => `\"${c.id}\"`).join(\", \");\n throw new Error(\n `Unknown AI connection \"${connection}\". Registered connections: ${known}.`\n );\n }\n return found;\n }\n\n const found = connections.find(c => c.sdkName === providerId);\n if (!found) {\n const known = connections.map(c => `\"${c.id}\" (${c.sdkName})`).join(\", \");\n throw new Error(\n `No AI connection found for provider \"${providerId}\". Registered connections: ${known}.`\n );\n }\n return found;\n }\n\n private async getSdk(connection: IAiConnectionInline): Promise<IAiSdk> {\n const cacheKey =\n \"id\" in connection\n ? (connection as IAiConnection).id\n : `${connection.sdkName}:${connection.apiKey ?? \"__env__\"}`;\n\n const cached = this.sdkCache.get(cacheKey);\n if (cached) {\n return cached;\n }\n\n const factory = this.sdkFactories.find(f => f.id === connection.sdkName);\n if (!factory) {\n const known = this.sdkFactories.map(f => `\"${f.id}\"`).join(\", \");\n throw new Error(\n `No AI SDK factory found for \"${connection.sdkName}\". Registered factories: ${known}.`\n );\n }\n\n const sdk = await factory.execute(connection.apiKey);\n this.sdkCache.set(cacheKey, sdk);\n return sdk;\n }\n}\n\nexport const Ai = createImplementation({\n abstraction: AiAbstraction,\n implementation: AiImpl,\n dependencies: [\n [AiSdkFactory, { multiple: true }],\n [AiConnectionFactory, { multiple: true }],\n EventPublisher\n ]\n});\n"],"names":["toAiModel","factory","modelId","modelName","AiImpl","sdkFactories","connectionFactories","eventPublisher","Map","params","model","connection","rest","resolvedModel","requestId","mdbid","AiBeforeGenerateTextEvent","start","performance","result","generateText","duration","AiAfterGenerateTextEvent","err","error","Error","String","AiGenerateTextErrorEvent","AiBeforeStreamTextEvent","streamText","Promise","m","connections","conn","f","undefined","slashIndex","providerId","sdk","found","c","known","cacheKey","cached","Ai","createImplementation","AiAbstraction","AiSdkFactory","AiConnectionFactory","EventPublisher"],"mappings":";;;;;;AAqBA,SAASA,UAAUC,OAAsB,EAAEC,OAAe,EAAEC,SAAiB;IACzE,OAAO;QACH,YAAYF,QAAQ,EAAE;QACtB,cAAcA,QAAQ,IAAI;QAC1BC;QACAC;IACJ;AACJ;AAEA,MAAMC;IAIF,YACqBC,YAAsC,EACtCC,mBAAoD,EACpDC,cAAwC,CAC3D;aAHmBF,YAAY,GAAZA;aACAC,mBAAmB,GAAnBA;aACAC,cAAc,GAAdA;aANb,QAAQ,GAAG,IAAIC;aACf,mBAAmB,GAA2B;IAMnD;IAEH,MAAM,aAAaC,MAA4B,EAAmC;QAC9E,MAAM,EAAEC,KAAK,EAAEC,UAAU,EAAE,GAAGC,MAAM,GAAGH;QACvC,MAAMI,gBAAgB,MAAM,IAAI,CAAC,oBAAoB,CAACH,OAAOC;QAC7D,MAAMG,YAAYC;QAElB,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAIC,0BAA0B;YAAEF;YAAWL;QAAO;QAEpF,MAAMQ,QAAQC,YAAY,GAAG;QAE7B,IAAI;YACA,MAAMC,SAAS,MAAMC,aAAa;gBAAE,OAAOP;gBAAe,GAAGD,IAAI;YAAC;YAIlE,MAAMS,WAAWH,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d,WAAW,OAAO,CAAC,yBAAyB,EAAE8B,MAAM,CAAC,CAAC;QAE9F;QAEA,MAAMH,MAAM,MAAMrC,QAAQ,OAAO,CAACU,WAAW,MAAM;QACnD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC+B,UAAUJ;QAC5B,OAAOA;IACX;AACJ;AAEO,MAAMM,QAAKC,qBAAqB;IACnC,aAAaC;IACb,gBAAgB1C;IAChB,cAAc;QACV;YAAC2C;YAAc;gBAAE,UAAU;YAAK;SAAE;QAClC;YAACC;YAAqB;gBAAE,UAAU;YAAK;SAAE;QACzCC;KACH;AACL"}
@@ -1,6 +1,18 @@
1
1
  import { createImplementation } from "@webiny/feature/api";
2
2
  import { AiSdkFactory } from "./abstractions.js";
3
3
  const ANTHROPIC_MODELS = [
4
+ {
5
+ id: "claude-opus-5",
6
+ name: "Claude Opus 5"
7
+ },
8
+ {
9
+ id: "claude-sonnet-5",
10
+ name: "Claude Sonnet 5"
11
+ },
12
+ {
13
+ id: "claude-fable-5",
14
+ name: "Claude Fable 5"
15
+ },
4
16
  {
5
17
  id: "claude-opus-4-7",
6
18
  name: "Claude Opus 4.7"
@@ -1 +1 @@
1
- {"version":3,"file":"features/ai/AnthropicSdkFactory.js","sources":["../../../src/features/ai/AnthropicSdkFactory.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { AiSdkFactory as AiSdkFactoryAbstraction } from \"./abstractions.js\";\nimport type { IAiSdk, IAiSdkModel } from \"./abstractions.js\";\n\nconst ANTHROPIC_MODELS: IAiSdkModel[] = [\n { id: \"claude-opus-4-7\", name: \"Claude Opus 4.7\" },\n { id: \"claude-opus-4-6\", name: \"Claude Opus 4.6\" },\n { id: \"claude-opus-4-5\", name: \"Claude Opus 4.5\" },\n { id: \"claude-sonnet-4-6\", name: \"Claude Sonnet 4.6\" },\n { id: \"claude-sonnet-4-5\", name: \"Claude Sonnet 4.5\" },\n { id: \"claude-haiku-4-5\", name: \"Claude Haiku 4.5\" }\n];\n\nclass AnthropicSdkFactoryImpl implements AiSdkFactoryAbstraction.Interface {\n readonly id = \"anthropic\";\n readonly name = \"Anthropic\";\n readonly models = ANTHROPIC_MODELS;\n\n async execute(apiKey?: string): Promise<IAiSdk> {\n const { createAnthropic } = await import(\"@ai-sdk/anthropic\");\n const provider = createAnthropic({\n apiKey: apiKey ?? process.env.WEBINY_API_ANTHROPIC_API_KEY\n });\n return {\n languageModel: modelId => provider.chat(modelId)\n };\n }\n}\n\nexport const AnthropicSdkFactory = createImplementation({\n abstraction: AiSdkFactoryAbstraction,\n implementation: AnthropicSdkFactoryImpl,\n dependencies: []\n});\n"],"names":["ANTHROPIC_MODELS","AnthropicSdkFactoryImpl","apiKey","createAnthropic","provider","process","modelId","AnthropicSdkFactory","createImplementation","AiSdkFactoryAbstraction"],"mappings":";;AAIA,MAAMA,mBAAkC;IACpC;QAAE,IAAI;QAAmB,MAAM;IAAkB;IACjD;QAAE,IAAI;QAAmB,MAAM;IAAkB;IACjD;QAAE,IAAI;QAAmB,MAAM;IAAkB;IACjD;QAAE,IAAI;QAAqB,MAAM;IAAoB;IACrD;QAAE,IAAI;QAAqB,MAAM;IAAoB;IACrD;QAAE,IAAI;QAAoB,MAAM;IAAmB;CACtD;AAED,MAAMC;IAKF,MAAM,QAAQC,MAAe,EAAmB;QAC5C,MAAM,EAAEC,eAAe,EAAE,GAAG,MAAM,MAAM,CAAC;QACzC,MAAMC,WAAWD,gBAAgB;YAC7B,QAAQD,UAAUG,QAAQ,GAAG,CAAC,4BAA4B;QAC9D;QACA,OAAO;YACH,eAAeC,CAAAA,UAAWF,SAAS,IAAI,CAACE;QAC5C;IACJ;;aAZS,EAAE,GAAG;aACL,IAAI,GAAG;aACP,MAAM,GAAGN;;AAWtB;AAEO,MAAMO,sBAAsBC,qBAAqB;IACpD,aAAaC;IACb,gBAAgBR;IAChB,cAAc,EAAE;AACpB"}
1
+ {"version":3,"file":"features/ai/AnthropicSdkFactory.js","sources":["../../../src/features/ai/AnthropicSdkFactory.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { AiSdkFactory as AiSdkFactoryAbstraction } from \"./abstractions.js\";\nimport type { IAiSdk, IAiSdkModel } from \"./abstractions.js\";\n\nconst ANTHROPIC_MODELS: IAiSdkModel[] = [\n { id: \"claude-opus-5\", name: \"Claude Opus 5\" },\n { id: \"claude-sonnet-5\", name: \"Claude Sonnet 5\" },\n { id: \"claude-fable-5\", name: \"Claude Fable 5\" },\n { id: \"claude-opus-4-7\", name: \"Claude Opus 4.7\" },\n { id: \"claude-opus-4-6\", name: \"Claude Opus 4.6\" },\n { id: \"claude-opus-4-5\", name: \"Claude Opus 4.5\" },\n { id: \"claude-sonnet-4-6\", name: \"Claude Sonnet 4.6\" },\n { id: \"claude-sonnet-4-5\", name: \"Claude Sonnet 4.5\" },\n { id: \"claude-haiku-4-5\", name: \"Claude Haiku 4.5\" }\n];\n\nclass AnthropicSdkFactoryImpl implements AiSdkFactoryAbstraction.Interface {\n readonly id = \"anthropic\";\n readonly name = \"Anthropic\";\n readonly models = ANTHROPIC_MODELS;\n\n async execute(apiKey?: string): Promise<IAiSdk> {\n const { createAnthropic } = await import(\"@ai-sdk/anthropic\");\n const provider = createAnthropic({\n apiKey: apiKey ?? process.env.WEBINY_API_ANTHROPIC_API_KEY\n });\n return {\n languageModel: modelId => provider.chat(modelId)\n };\n }\n}\n\nexport const AnthropicSdkFactory = createImplementation({\n abstraction: AiSdkFactoryAbstraction,\n implementation: AnthropicSdkFactoryImpl,\n dependencies: []\n});\n"],"names":["ANTHROPIC_MODELS","AnthropicSdkFactoryImpl","apiKey","createAnthropic","provider","process","modelId","AnthropicSdkFactory","createImplementation","AiSdkFactoryAbstraction"],"mappings":";;AAIA,MAAMA,mBAAkC;IACpC;QAAE,IAAI;QAAiB,MAAM;IAAgB;IAC7C;QAAE,IAAI;QAAmB,MAAM;IAAkB;IACjD;QAAE,IAAI;QAAkB,MAAM;IAAiB;IAC/C;QAAE,IAAI;QAAmB,MAAM;IAAkB;IACjD;QAAE,IAAI;QAAmB,MAAM;IAAkB;IACjD;QAAE,IAAI;QAAmB,MAAM;IAAkB;IACjD;QAAE,IAAI;QAAqB,MAAM;IAAoB;IACrD;QAAE,IAAI;QAAqB,MAAM;IAAoB;IACrD;QAAE,IAAI;QAAoB,MAAM;IAAmB;CACtD;AAED,MAAMC;IAKF,MAAM,QAAQC,MAAe,EAAmB;QAC5C,MAAM,EAAEC,eAAe,EAAE,GAAG,MAAM,MAAM,CAAC;QACzC,MAAMC,WAAWD,gBAAgB;YAC7B,QAAQD,UAAUG,QAAQ,GAAG,CAAC,4BAA4B;QAC9D;QACA,OAAO;YACH,eAAeC,CAAAA,UAAWF,SAAS,IAAI,CAACE;QAC5C;IACJ;;aAZS,EAAE,GAAG;aACL,IAAI,GAAG;aACP,MAAM,GAAGN;;AAWtB;AAEO,MAAMO,sBAAsBC,qBAAqB;IACpD,aAAaC;IACb,gBAAgBR;IAChB,cAAc,EAAE;AACpB"}
@@ -1,6 +1,22 @@
1
1
  import { createImplementation } from "@webiny/feature/api";
2
2
  import { AiSdkFactory } from "./abstractions.js";
3
3
  const OPENAI_MODELS = [
4
+ {
5
+ id: "gpt-5.6-sol",
6
+ name: "GPT-5.6 Sol"
7
+ },
8
+ {
9
+ id: "gpt-5.6-terra",
10
+ name: "GPT-5.6 Terra"
11
+ },
12
+ {
13
+ id: "gpt-5.6-luna",
14
+ name: "GPT-5.6 Luna"
15
+ },
16
+ {
17
+ id: "gpt-5.5",
18
+ name: "GPT-5.5"
19
+ },
4
20
  {
5
21
  id: "gpt-5.4",
6
22
  name: "GPT-5.4"
@@ -1 +1 @@
1
- {"version":3,"file":"features/ai/OpenAiSdkFactory.js","sources":["../../../src/features/ai/OpenAiSdkFactory.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { AiSdkFactory as AiSdkFactoryAbstraction } from \"./abstractions.js\";\nimport type { IAiSdk, IAiSdkModel } from \"./abstractions.js\";\n\nconst OPENAI_MODELS: IAiSdkModel[] = [\n { id: \"gpt-5.4\", name: \"GPT-5.4\" },\n { id: \"gpt-5.4-mini\", name: \"GPT-5.4 Mini\" },\n { id: \"gpt-5.4-nano\", name: \"GPT-5.4 Nano\" },\n { id: \"gpt-5.4-pro\", name: \"GPT-5.4 Pro\" },\n { id: \"gpt-5.3-chat-latest\", name: \"GPT-5.3 Chat\" },\n { id: \"gpt-4.1\", name: \"GPT-4.1\" },\n { id: \"gpt-4.1-mini\", name: \"GPT-4.1 Mini\" },\n { id: \"gpt-4.1-nano\", name: \"GPT-4.1 Nano\" },\n { id: \"gpt-4o\", name: \"GPT-4o\" },\n { id: \"gpt-4o-mini\", name: \"GPT-4o Mini\" },\n { id: \"o4-mini\", name: \"o4 Mini\" },\n { id: \"o3\", name: \"o3\" }\n];\n\nclass OpenAiSdkFactoryImpl implements AiSdkFactoryAbstraction.Interface {\n readonly id = \"openai\";\n readonly name = \"OpenAI\";\n readonly models = OPENAI_MODELS;\n\n async execute(apiKey?: string): Promise<IAiSdk> {\n const { createOpenAI } = await import(\"@ai-sdk/openai\");\n const provider = createOpenAI({\n apiKey: apiKey ?? process.env.WEBINY_API_OPENAI_API_KEY\n });\n return {\n languageModel: modelId => provider.chat(modelId)\n };\n }\n}\n\nexport const OpenAiSdkFactory = createImplementation({\n abstraction: AiSdkFactoryAbstraction,\n implementation: OpenAiSdkFactoryImpl,\n dependencies: []\n});\n"],"names":["OPENAI_MODELS","OpenAiSdkFactoryImpl","apiKey","createOpenAI","provider","process","modelId","OpenAiSdkFactory","createImplementation","AiSdkFactoryAbstraction"],"mappings":";;AAIA,MAAMA,gBAA+B;IACjC;QAAE,IAAI;QAAW,MAAM;IAAU;IACjC;QAAE,IAAI;QAAgB,MAAM;IAAe;IAC3C;QAAE,IAAI;QAAgB,MAAM;IAAe;IAC3C;QAAE,IAAI;QAAe,MAAM;IAAc;IACzC;QAAE,IAAI;QAAuB,MAAM;IAAe;IAClD;QAAE,IAAI;QAAW,MAAM;IAAU;IACjC;QAAE,IAAI;QAAgB,MAAM;IAAe;IAC3C;QAAE,IAAI;QAAgB,MAAM;IAAe;IAC3C;QAAE,IAAI;QAAU,MAAM;IAAS;IAC/B;QAAE,IAAI;QAAe,MAAM;IAAc;IACzC;QAAE,IAAI;QAAW,MAAM;IAAU;IACjC;QAAE,IAAI;QAAM,MAAM;IAAK;CAC1B;AAED,MAAMC;IAKF,MAAM,QAAQC,MAAe,EAAmB;QAC5C,MAAM,EAAEC,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC;QACtC,MAAMC,WAAWD,aAAa;YAC1B,QAAQD,UAAUG,QAAQ,GAAG,CAAC,yBAAyB;QAC3D;QACA,OAAO;YACH,eAAeC,CAAAA,UAAWF,SAAS,IAAI,CAACE;QAC5C;IACJ;;aAZS,EAAE,GAAG;aACL,IAAI,GAAG;aACP,MAAM,GAAGN;;AAWtB;AAEO,MAAMO,mBAAmBC,qBAAqB;IACjD,aAAaC;IACb,gBAAgBR;IAChB,cAAc,EAAE;AACpB"}
1
+ {"version":3,"file":"features/ai/OpenAiSdkFactory.js","sources":["../../../src/features/ai/OpenAiSdkFactory.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { AiSdkFactory as AiSdkFactoryAbstraction } from \"./abstractions.js\";\nimport type { IAiSdk, IAiSdkModel } from \"./abstractions.js\";\n\nconst OPENAI_MODELS: IAiSdkModel[] = [\n { id: \"gpt-5.6-sol\", name: \"GPT-5.6 Sol\" },\n { id: \"gpt-5.6-terra\", name: \"GPT-5.6 Terra\" },\n { id: \"gpt-5.6-luna\", name: \"GPT-5.6 Luna\" },\n { id: \"gpt-5.5\", name: \"GPT-5.5\" },\n { id: \"gpt-5.4\", name: \"GPT-5.4\" },\n { id: \"gpt-5.4-mini\", name: \"GPT-5.4 Mini\" },\n { id: \"gpt-5.4-nano\", name: \"GPT-5.4 Nano\" },\n { id: \"gpt-5.4-pro\", name: \"GPT-5.4 Pro\" },\n { id: \"gpt-5.3-chat-latest\", name: \"GPT-5.3 Chat\" },\n { id: \"gpt-4.1\", name: \"GPT-4.1\" },\n { id: \"gpt-4.1-mini\", name: \"GPT-4.1 Mini\" },\n { id: \"gpt-4.1-nano\", name: \"GPT-4.1 Nano\" },\n { id: \"gpt-4o\", name: \"GPT-4o\" },\n { id: \"gpt-4o-mini\", name: \"GPT-4o Mini\" },\n { id: \"o4-mini\", name: \"o4 Mini\" },\n { id: \"o3\", name: \"o3\" }\n];\n\nclass OpenAiSdkFactoryImpl implements AiSdkFactoryAbstraction.Interface {\n readonly id = \"openai\";\n readonly name = \"OpenAI\";\n readonly models = OPENAI_MODELS;\n\n async execute(apiKey?: string): Promise<IAiSdk> {\n const { createOpenAI } = await import(\"@ai-sdk/openai\");\n const provider = createOpenAI({\n apiKey: apiKey ?? process.env.WEBINY_API_OPENAI_API_KEY\n });\n return {\n languageModel: modelId => provider.chat(modelId)\n };\n }\n}\n\nexport const OpenAiSdkFactory = createImplementation({\n abstraction: AiSdkFactoryAbstraction,\n implementation: OpenAiSdkFactoryImpl,\n dependencies: []\n});\n"],"names":["OPENAI_MODELS","OpenAiSdkFactoryImpl","apiKey","createOpenAI","provider","process","modelId","OpenAiSdkFactory","createImplementation","AiSdkFactoryAbstraction"],"mappings":";;AAIA,MAAMA,gBAA+B;IACjC;QAAE,IAAI;QAAe,MAAM;IAAc;IACzC;QAAE,IAAI;QAAiB,MAAM;IAAgB;IAC7C;QAAE,IAAI;QAAgB,MAAM;IAAe;IAC3C;QAAE,IAAI;QAAW,MAAM;IAAU;IACjC;QAAE,IAAI;QAAW,MAAM;IAAU;IACjC;QAAE,IAAI;QAAgB,MAAM;IAAe;IAC3C;QAAE,IAAI;QAAgB,MAAM;IAAe;IAC3C;QAAE,IAAI;QAAe,MAAM;IAAc;IACzC;QAAE,IAAI;QAAuB,MAAM;IAAe;IAClD;QAAE,IAAI;QAAW,MAAM;IAAU;IACjC;QAAE,IAAI;QAAgB,MAAM;IAAe;IAC3C;QAAE,IAAI;QAAgB,MAAM;IAAe;IAC3C;QAAE,IAAI;QAAU,MAAM;IAAS;IAC/B;QAAE,IAAI;QAAe,MAAM;IAAc;IACzC;QAAE,IAAI;QAAW,MAAM;IAAU;IACjC;QAAE,IAAI;QAAM,MAAM;IAAK;CAC1B;AAED,MAAMC;IAKF,MAAM,QAAQC,MAAe,EAAmB;QAC5C,MAAM,EAAEC,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC;QACtC,MAAMC,WAAWD,aAAa;YAC1B,QAAQD,UAAUG,QAAQ,GAAG,CAAC,yBAAyB;QAC3D;QACA,OAAO;YACH,eAAeC,CAAAA,UAAWF,SAAS,IAAI,CAACE;QAC5C;IACJ;;aAZS,EAAE,GAAG;aACL,IAAI,GAAG;aACP,MAAM,GAAGN;;AAWtB;AAEO,MAAMO,mBAAmBC,qBAAqB;IACjD,aAAaC;IACb,gBAAgBR;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,9 @@
1
+ import { TextExtractor, type TextExtractorResult } from "./abstractions.js";
2
+ declare class TextExtractorImpl implements TextExtractor.Interface {
3
+ canExtract(mimeType: string): boolean;
4
+ extract(buffer: Buffer, mimeType: string): Promise<TextExtractorResult>;
5
+ }
6
+ export declare const DefaultTextExtractor: typeof TextExtractorImpl & {
7
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").ITextExtractor>;
8
+ };
9
+ export {};
@@ -0,0 +1,28 @@
1
+ import { TextExtractor } from "./abstractions.js";
2
+ import { extractDocxText } from "./parsers/docxParser.js";
3
+ const TEXT_MIME_PREFIX = "text/";
4
+ const SUPPORTED_MIME_TYPES = new Set([
5
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
6
+ "application/json"
7
+ ]);
8
+ class TextExtractorImpl {
9
+ canExtract(mimeType) {
10
+ return mimeType.startsWith(TEXT_MIME_PREFIX) || SUPPORTED_MIME_TYPES.has(mimeType);
11
+ }
12
+ async extract(buffer, mimeType) {
13
+ if (mimeType.startsWith(TEXT_MIME_PREFIX) || "application/json" === mimeType) return {
14
+ text: buffer.toString("utf-8")
15
+ };
16
+ if ("application/vnd.openxmlformats-officedocument.wordprocessingml.document" === mimeType) return {
17
+ text: await extractDocxText(buffer)
18
+ };
19
+ throw new Error(`Unsupported MIME type: ${mimeType}`);
20
+ }
21
+ }
22
+ const DefaultTextExtractor = TextExtractor.createImplementation({
23
+ implementation: TextExtractorImpl,
24
+ dependencies: []
25
+ });
26
+ export { DefaultTextExtractor };
27
+
28
+ //# sourceMappingURL=DefaultTextExtractor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/ai/TextExtractor/DefaultTextExtractor.js","sources":["../../../../src/features/ai/TextExtractor/DefaultTextExtractor.ts"],"sourcesContent":["import { TextExtractor, type TextExtractorResult } from \"./abstractions.js\";\nimport { extractDocxText } from \"./parsers/docxParser.js\";\n\nconst TEXT_MIME_PREFIX = \"text/\";\n\nconst SUPPORTED_MIME_TYPES = new Set([\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n \"application/json\"\n]);\n\nclass TextExtractorImpl implements TextExtractor.Interface {\n canExtract(mimeType: string): boolean {\n return mimeType.startsWith(TEXT_MIME_PREFIX) || SUPPORTED_MIME_TYPES.has(mimeType);\n }\n\n async extract(buffer: Buffer, mimeType: string): Promise<TextExtractorResult> {\n if (mimeType.startsWith(TEXT_MIME_PREFIX) || mimeType === \"application/json\") {\n return { text: buffer.toString(\"utf-8\") };\n }\n\n if (\n mimeType === \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\"\n ) {\n return { text: await extractDocxText(buffer) };\n }\n\n throw new Error(`Unsupported MIME type: ${mimeType}`);\n }\n}\n\nexport const DefaultTextExtractor = TextExtractor.createImplementation({\n implementation: TextExtractorImpl,\n dependencies: []\n});\n"],"names":["TEXT_MIME_PREFIX","SUPPORTED_MIME_TYPES","Set","TextExtractorImpl","mimeType","buffer","extractDocxText","Error","DefaultTextExtractor","TextExtractor"],"mappings":";;AAGA,MAAMA,mBAAmB;AAEzB,MAAMC,uBAAuB,IAAIC,IAAI;IACjC;IACA;CACH;AAED,MAAMC;IACF,WAAWC,QAAgB,EAAW;QAClC,OAAOA,SAAS,UAAU,CAACJ,qBAAqBC,qBAAqB,GAAG,CAACG;IAC7E;IAEA,MAAM,QAAQC,MAAc,EAAED,QAAgB,EAAgC;QAC1E,IAAIA,SAAS,UAAU,CAACJ,qBAAqBI,AAAa,uBAAbA,UACzC,OAAO;YAAE,MAAMC,OAAO,QAAQ,CAAC;QAAS;QAG5C,IACID,AAAa,8EAAbA,UAEA,OAAO;YAAE,MAAM,MAAME,gBAAgBD;QAAQ;QAGjD,MAAM,IAAIE,MAAM,CAAC,uBAAuB,EAAEH,UAAU;IACxD;AACJ;AAEO,MAAMI,uBAAuBC,cAAc,oBAAoB,CAAC;IACnE,gBAAgBN;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,12 @@
1
+ export interface TextExtractorResult {
2
+ text: string;
3
+ }
4
+ export interface ITextExtractor {
5
+ canExtract(mimeType: string): boolean;
6
+ extract(buffer: Buffer, mimeType: string): Promise<TextExtractorResult>;
7
+ }
8
+ export declare const TextExtractor: import("@webiny/di").Abstraction<ITextExtractor>;
9
+ export declare namespace TextExtractor {
10
+ type Interface = ITextExtractor;
11
+ type Result = TextExtractorResult;
12
+ }
@@ -0,0 +1,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const TextExtractor = createAbstraction("TextExtractor");
3
+ export { TextExtractor };
4
+
5
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/ai/TextExtractor/abstractions.js","sources":["../../../../src/features/ai/TextExtractor/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\nexport interface TextExtractorResult {\n text: string;\n}\n\nexport interface ITextExtractor {\n canExtract(mimeType: string): boolean;\n extract(buffer: Buffer, mimeType: string): Promise<TextExtractorResult>;\n}\n\nexport const TextExtractor = createAbstraction<ITextExtractor>(\"TextExtractor\");\n\nexport namespace TextExtractor {\n export type Interface = ITextExtractor;\n export type Result = TextExtractorResult;\n}\n"],"names":["TextExtractor","createAbstraction"],"mappings":";AAWO,MAAMA,gBAAgBC,kBAAkC"}
@@ -0,0 +1,3 @@
1
+ export { TextExtractor } from "./abstractions.js";
2
+ export type { ITextExtractor, TextExtractorResult } from "./abstractions.js";
3
+ export { DefaultTextExtractor } from "./DefaultTextExtractor.js";
@@ -0,0 +1,2 @@
1
+ export { TextExtractor } from "./abstractions.js";
2
+ export { DefaultTextExtractor } from "./DefaultTextExtractor.js";
@@ -0,0 +1 @@
1
+ export declare function extractDocxText(buffer: Buffer): Promise<string>;