@webiny/api-core 0.0.0-unstable.7be00a75a9 → 0.0.0-unstable.7c2def32a7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ApiCoreFeature.d.ts +2 -2
- package/ApiCoreFeature.js +35 -5
- package/ApiCoreFeature.js.map +1 -1
- package/exports/api/security/api-key.d.ts +1 -0
- package/exports/api/security/api-key.js +1 -0
- package/exports/api/tasks.d.ts +1 -0
- package/exports/api/tasks.js +1 -1
- package/exports/api.d.ts +2 -1
- package/exports/api.js +2 -1
- package/features/ai/Ai.d.ts +5 -1
- package/features/ai/Ai.js +72 -29
- package/features/ai/Ai.js.map +1 -1
- package/features/ai/AiModelRegistry.d.ts +14 -0
- package/features/ai/AiModelRegistry.js +39 -0
- package/features/ai/AiModelRegistry.js.map +1 -0
- package/features/ai/AiSdkToolHandlerResolver.d.ts +11 -0
- package/features/ai/AiSdkToolHandlerResolver.js +19 -0
- package/features/ai/AiSdkToolHandlerResolver.js.map +1 -0
- package/features/ai/AiSdkTools.d.ts +4 -3
- package/features/ai/AiSdkTools.js +11 -9
- package/features/ai/AiSdkTools.js.map +1 -1
- package/features/ai/AnthropicSdkFactory.js +18 -34
- package/features/ai/AnthropicSdkFactory.js.map +1 -1
- package/features/ai/DEVELOPERS.md +183 -0
- package/features/ai/GoogleSdkFactory.d.ts +10 -0
- package/features/ai/GoogleSdkFactory.js +65 -0
- package/features/ai/GoogleSdkFactory.js.map +1 -0
- package/features/ai/OpenAiSdkFactory.js +42 -150
- package/features/ai/OpenAiSdkFactory.js.map +1 -1
- package/features/ai/OpenRouterSdkFactory.d.ts +10 -0
- package/features/ai/OpenRouterSdkFactory.js +112 -0
- package/features/ai/OpenRouterSdkFactory.js.map +1 -0
- package/features/ai/RemoteAiModelCatalog.d.ts +13 -0
- package/features/ai/RemoteAiModelCatalog.js +74 -0
- package/features/ai/RemoteAiModelCatalog.js.map +1 -0
- package/features/ai/TextExtractor/DefaultTextExtractor.d.ts +9 -0
- package/features/ai/TextExtractor/DefaultTextExtractor.js +28 -0
- package/features/ai/TextExtractor/DefaultTextExtractor.js.map +1 -0
- package/features/ai/TextExtractor/abstractions.d.ts +12 -0
- package/features/ai/TextExtractor/abstractions.js +5 -0
- package/features/ai/TextExtractor/abstractions.js.map +1 -0
- package/features/ai/TextExtractor/index.d.ts +3 -0
- package/features/ai/TextExtractor/index.js +2 -0
- package/features/ai/TextExtractor/parsers/docxParser.d.ts +1 -0
- package/features/ai/TextExtractor/parsers/docxParser.js +111 -0
- package/features/ai/TextExtractor/parsers/docxParser.js.map +1 -0
- package/features/ai/abstractions.d.ts +102 -7
- package/features/ai/abstractions.js +6 -2
- package/features/ai/abstractions.js.map +1 -1
- package/features/ai/events.d.ts +59 -0
- package/features/ai/events.js +41 -0
- package/features/ai/events.js.map +1 -0
- package/features/ai/feature.js +16 -0
- package/features/ai/feature.js.map +1 -1
- package/features/ai/index.d.ts +6 -2
- package/features/ai/index.js +4 -1
- package/features/ai/toolPipeline/AiOutputToolRegistry.d.ts +11 -0
- package/features/ai/toolPipeline/AiOutputToolRegistry.js +31 -0
- package/features/ai/toolPipeline/AiOutputToolRegistry.js.map +1 -0
- package/features/ai/toolPipeline/AiToolPipelineRunner.d.ts +10 -0
- package/features/ai/toolPipeline/AiToolPipelineRunner.js +36 -0
- package/features/ai/toolPipeline/AiToolPipelineRunner.js.map +1 -0
- package/features/ai/toolPipeline/abstractions.d.ts +23 -0
- package/features/ai/toolPipeline/abstractions.js +7 -0
- package/features/ai/toolPipeline/abstractions.js.map +1 -0
- package/features/ai/toolPipeline/index.d.ts +2 -0
- package/features/ai/toolPipeline/index.js +1 -0
- package/features/dateFormatter/DefaultDateFormatter.d.ts +15 -0
- package/features/dateFormatter/DefaultDateFormatter.js +20 -0
- package/features/dateFormatter/DefaultDateFormatter.js.map +1 -0
- package/features/dateFormatter/abstractions.d.ts +13 -0
- package/features/dateFormatter/abstractions.js +5 -0
- package/features/dateFormatter/abstractions.js.map +1 -0
- package/features/dateFormatter/feature.d.ts +4 -0
- package/features/dateFormatter/feature.js +11 -0
- package/features/dateFormatter/feature.js.map +1 -0
- package/features/dateFormatter/index.d.ts +3 -0
- package/features/dateFormatter/index.js +2 -0
- package/features/debugger/Debugger.d.ts +30 -0
- package/features/debugger/Debugger.js +142 -0
- package/features/debugger/Debugger.js.map +1 -0
- package/features/debugger/DebuggerRouteDecorator.d.ts +45 -0
- package/features/debugger/DebuggerRouteDecorator.js +107 -0
- package/features/debugger/DebuggerRouteDecorator.js.map +1 -0
- package/features/debugger/GraphQLDebuggerTransport.d.ts +28 -0
- package/features/debugger/GraphQLDebuggerTransport.js +45 -0
- package/features/debugger/GraphQLDebuggerTransport.js.map +1 -0
- package/features/debugger/__tests__/matchNamespace.test.d.ts +1 -0
- package/features/debugger/__tests__/matchNamespace.test.js +68 -0
- package/features/debugger/__tests__/matchNamespace.test.js.map +1 -0
- package/features/debugger/__tests__/serialize.test.d.ts +1 -0
- package/features/debugger/__tests__/serialize.test.js +220 -0
- package/features/debugger/__tests__/serialize.test.js.map +1 -0
- package/features/debugger/abstractions.d.ts +100 -0
- package/features/debugger/abstractions.js +6 -0
- package/features/debugger/abstractions.js.map +1 -0
- package/features/debugger/feature.d.ts +5 -0
- package/features/debugger/feature.js +15 -0
- package/features/debugger/feature.js.map +1 -0
- package/features/debugger/index.d.ts +12 -0
- package/features/debugger/index.js +7 -0
- package/features/debugger/limits.d.ts +18 -0
- package/features/debugger/limits.js +11 -0
- package/features/debugger/limits.js.map +1 -0
- package/features/debugger/matchNamespace.d.ts +14 -0
- package/features/debugger/matchNamespace.js +35 -0
- package/features/debugger/matchNamespace.js.map +1 -0
- package/features/debugger/parseNamespaceHeader.d.ts +7 -0
- package/features/debugger/parseNamespaceHeader.js +16 -0
- package/features/debugger/parseNamespaceHeader.js.map +1 -0
- package/features/debugger/permissions.d.ts +14 -0
- package/features/debugger/permissions.js +8 -0
- package/features/debugger/permissions.js.map +1 -0
- package/features/debugger/permissionsSchema.d.ts +17 -0
- package/features/debugger/permissionsSchema.js +18 -0
- package/features/debugger/permissionsSchema.js.map +1 -0
- package/features/debugger/serialize.d.ts +11 -0
- package/features/debugger/serialize.js +121 -0
- package/features/debugger/serialize.js.map +1 -0
- package/features/encryption/EncryptionKeyCacheFeature.d.ts +8 -0
- package/features/encryption/EncryptionKeyCacheFeature.js +11 -0
- package/features/encryption/EncryptionKeyCacheFeature.js.map +1 -0
- package/features/encryption/EncryptionService.d.ts +2 -1
- package/features/encryption/EncryptionService.js +11 -4
- package/features/encryption/EncryptionService.js.map +1 -1
- package/features/encryption/MemoryEncryptionKeyCache.d.ts +13 -0
- package/features/encryption/MemoryEncryptionKeyCache.js +26 -0
- package/features/encryption/MemoryEncryptionKeyCache.js.map +1 -0
- package/features/encryption/abstractions.d.ts +11 -0
- package/features/encryption/abstractions.js +2 -1
- package/features/encryption/abstractions.js.map +1 -1
- package/features/encryption/index.d.ts +1 -0
- package/features/encryption/index.js +1 -0
- package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.d.ts +13 -0
- package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js +62 -0
- package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js.map +1 -0
- package/features/hashing/ScryptHasher.d.ts +11 -0
- package/features/hashing/ScryptHasher.js +74 -0
- package/features/hashing/ScryptHasher.js.map +1 -0
- package/features/hashing/abstractions.d.ts +18 -0
- package/features/hashing/abstractions.js +5 -0
- package/features/hashing/abstractions.js.map +1 -0
- package/features/hashing/feature.d.ts +4 -0
- package/features/hashing/feature.js +11 -0
- package/features/hashing/feature.js.map +1 -0
- package/features/hashing/index.d.ts +2 -0
- package/features/hashing/index.js +1 -0
- package/features/httpClient/HttpClient.d.ts +7 -0
- package/features/httpClient/HttpClient.js +72 -0
- package/features/httpClient/HttpClient.js.map +1 -0
- package/features/httpClient/HttpRequestError.d.ts +10 -0
- package/features/httpClient/HttpRequestError.js +13 -0
- package/features/httpClient/HttpRequestError.js.map +1 -0
- package/features/httpClient/HttpStatusError.d.ts +12 -0
- package/features/httpClient/HttpStatusError.js +12 -0
- package/features/httpClient/HttpStatusError.js.map +1 -0
- package/features/httpClient/abstractions.d.ts +32 -0
- package/features/httpClient/abstractions.js +5 -0
- package/features/httpClient/abstractions.js.map +1 -0
- package/features/httpClient/feature.d.ts +4 -0
- package/features/httpClient/feature.js +11 -0
- package/features/httpClient/feature.js.map +1 -0
- package/features/httpClient/index.d.ts +3 -0
- package/features/httpClient/index.js +3 -0
- package/features/keyValueStore/GlobalKeyValueStore.d.ts +9 -3
- package/features/keyValueStore/GlobalKeyValueStore.js +12 -2
- package/features/keyValueStore/GlobalKeyValueStore.js.map +1 -1
- package/features/keyValueStore/KeyValueStore.d.ts +6 -2
- package/features/keyValueStore/KeyValueStore.js +13 -3
- package/features/keyValueStore/KeyValueStore.js.map +1 -1
- package/features/keyValueStore/KeyValueStoreRepository.d.ts +8 -2
- package/features/keyValueStore/KeyValueStoreRepository.js +82 -4
- package/features/keyValueStore/KeyValueStoreRepository.js.map +1 -1
- package/features/keyValueStore/abstractions.d.ts +132 -14
- package/features/keyValueStore/abstractions.js.map +1 -1
- package/features/keyValueStore/errors.d.ts +29 -0
- package/features/keyValueStore/errors.js +49 -1
- package/features/keyValueStore/errors.js.map +1 -1
- package/features/keyValueStore/index.d.ts +4 -1
- package/features/keyValueStore/index.js +1 -1
- package/features/publicUrls/NullPublicUrls.d.ts +11 -0
- package/features/publicUrls/NullPublicUrls.js +17 -0
- package/features/publicUrls/NullPublicUrls.js.map +1 -0
- package/features/publicUrls/PublicUrl.d.ts +24 -0
- package/features/publicUrls/PublicUrl.js +43 -0
- package/features/publicUrls/PublicUrl.js.map +1 -0
- package/features/publicUrls/__tests__/PublicUrl.test.d.ts +1 -0
- package/features/publicUrls/__tests__/PublicUrl.test.js +38 -0
- package/features/publicUrls/__tests__/PublicUrl.test.js.map +1 -0
- package/features/publicUrls/__tests__/PublicUrls.test.d.ts +1 -0
- package/features/publicUrls/__tests__/PublicUrls.test.js +14 -0
- package/features/publicUrls/__tests__/PublicUrls.test.js.map +1 -0
- package/features/publicUrls/abstractions.d.ts +27 -0
- package/features/publicUrls/abstractions.js +5 -0
- package/features/publicUrls/abstractions.js.map +1 -0
- package/features/publicUrls/feature.d.ts +8 -0
- package/features/publicUrls/feature.js +11 -0
- package/features/publicUrls/feature.js.map +1 -0
- package/features/publicUrls/index.d.ts +3 -0
- package/features/publicUrls/index.js +3 -0
- package/features/requestContext/RawAssumePermissions.d.ts +14 -0
- package/features/requestContext/RawAssumePermissions.js +19 -0
- package/features/requestContext/RawAssumePermissions.js.map +1 -0
- package/features/requestContext/RawAuthToken.d.ts +14 -0
- package/features/requestContext/RawAuthToken.js +19 -0
- package/features/requestContext/RawAuthToken.js.map +1 -0
- package/features/requestContext/RawTenantId.d.ts +14 -0
- package/features/requestContext/RawTenantId.js +19 -0
- package/features/requestContext/RawTenantId.js.map +1 -0
- package/features/requestContext/RequestIdentityLoader.d.ts +19 -0
- package/features/requestContext/RequestIdentityLoader.js +26 -0
- package/features/requestContext/RequestIdentityLoader.js.map +1 -0
- package/features/requestContext/RequestTenantLoader.d.ts +18 -0
- package/features/requestContext/RequestTenantLoader.js +52 -0
- package/features/requestContext/RequestTenantLoader.js.map +1 -0
- package/features/requestContext/abstractions.d.ts +75 -0
- package/features/requestContext/abstractions.js +9 -0
- package/features/requestContext/abstractions.js.map +1 -0
- package/features/requestContext/extractAssumePermissions.d.ts +14 -0
- package/features/requestContext/extractAssumePermissions.js +32 -0
- package/features/requestContext/extractAssumePermissions.js.map +1 -0
- package/features/requestContext/feature.d.ts +12 -0
- package/features/requestContext/feature.js +19 -0
- package/features/requestContext/feature.js.map +1 -0
- package/features/requestContext/index.d.ts +4 -0
- package/features/requestContext/index.js +3 -0
- package/features/security/IdentityContext/IdentityContext.d.ts +3 -3
- package/features/security/IdentityContext/IdentityContext.js +6 -6
- package/features/security/IdentityContext/IdentityContext.js.map +1 -1
- package/features/security/apiKeys/ApiKeyAuthenticator.d.ts +14 -0
- package/features/security/apiKeys/ApiKeyAuthenticator.js +36 -0
- package/features/security/apiKeys/ApiKeyAuthenticator.js.map +1 -0
- package/features/security/apiKeys/ApiKeyAuthorizer.d.ts +10 -0
- package/features/security/apiKeys/ApiKeyAuthorizer.js +15 -0
- package/features/security/apiKeys/ApiKeyAuthorizer.js.map +1 -0
- package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js +11 -6
- package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.d.ts +1 -1
- package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.d.ts +1 -3
- package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyBySlug/abstractions.d.ts +1 -1
- package/features/security/apiKeys/GetApiKeyBySlug/abstractions.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.d.ts +1 -3
- package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyByToken/abstractions.d.ts +1 -1
- package/features/security/apiKeys/GetApiKeyByToken/abstractions.js.map +1 -1
- package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js +9 -3
- package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js.map +1 -1
- package/features/security/apiKeys/feature.js +11 -2
- package/features/security/apiKeys/feature.js.map +1 -1
- package/features/security/apiKeys/shared/ApiKeyProvider.d.ts +3 -5
- package/features/security/apiKeys/shared/ApiKeyProvider.js +6 -21
- package/features/security/apiKeys/shared/ApiKeyProvider.js.map +1 -1
- package/features/security/apiKeys/shared/ApiKeysRepository.d.ts +1 -0
- package/features/security/apiKeys/shared/ApiKeysRepository.js +19 -4
- package/features/security/apiKeys/shared/ApiKeysRepository.js.map +1 -1
- package/features/security/apiKeys/shared/generateToken.d.ts +1 -1
- package/features/security/apiKeys/shared/generateToken.js.map +1 -1
- package/features/security/apiKeys/shared/schemas.d.ts +2 -2
- package/features/security/apiKeys/shared/schemas.js +2 -2
- package/features/security/apiKeys/shared/schemas.js.map +1 -1
- package/features/security/apiKeys/shared/types.d.ts +1 -1
- package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.d.ts +30 -0
- package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js +60 -0
- package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js.map +1 -0
- package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.d.ts +4 -4
- package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js +5 -5
- package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js.map +1 -1
- package/features/security/authorization/GroupsTeamsAuthorizer/feature.js +2 -0
- package/features/security/authorization/GroupsTeamsAuthorizer/feature.js.map +1 -1
- package/features/security/roles/CreateRole/CreateRoleUseCase.js +11 -6
- package/features/security/roles/CreateRole/CreateRoleUseCase.js.map +1 -1
- package/features/security/roles/CreateRole/schema.d.ts +1 -1
- package/features/security/roles/CreateRole/schema.js +1 -1
- package/features/security/roles/CreateRole/schema.js.map +1 -1
- package/features/security/roles/Installer/RolesInstaller.js +1 -0
- package/features/security/roles/Installer/RolesInstaller.js.map +1 -1
- package/features/security/roles/UpdateRole/UpdateRoleUseCase.js +9 -3
- package/features/security/roles/UpdateRole/UpdateRoleUseCase.js.map +1 -1
- package/features/security/roles/UpdateRole/schema.d.ts +1 -1
- package/features/security/roles/UpdateRole/schema.js +1 -1
- package/features/security/roles/UpdateRole/schema.js.map +1 -1
- package/features/security/shared/description.d.ts +4 -0
- package/features/security/shared/description.js +7 -0
- package/features/security/shared/description.js.map +1 -0
- package/features/security/shared/index.d.ts +1 -0
- package/features/security/shared/index.js +1 -0
- package/features/security/teams/CreateTeam/CreateTeamUseCase.d.ts +3 -1
- package/features/security/teams/CreateTeam/CreateTeamUseCase.js +20 -8
- package/features/security/teams/CreateTeam/CreateTeamUseCase.js.map +1 -1
- package/features/security/teams/CreateTeam/schema.d.ts +1 -1
- package/features/security/teams/CreateTeam/schema.js +1 -1
- package/features/security/teams/CreateTeam/schema.js.map +1 -1
- package/features/security/teams/UpdateTeam/UpdateTeamUseCase.d.ts +3 -1
- package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js +20 -5
- package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js.map +1 -1
- package/features/security/teams/UpdateTeam/schema.d.ts +1 -1
- package/features/security/teams/UpdateTeam/schema.js +1 -1
- package/features/security/teams/UpdateTeam/schema.js.map +1 -1
- package/features/security/teams/shared/resolveRoleIdentifiers.d.ts +17 -0
- package/features/security/teams/shared/resolveRoleIdentifiers.js +32 -0
- package/features/security/teams/shared/resolveRoleIdentifiers.js.map +1 -0
- package/features/security/utils/getPermissionsFromRoles.d.ts +1 -1
- package/features/serviceDiscovery/ServiceDiscovery.d.ts +17 -0
- package/features/serviceDiscovery/ServiceDiscovery.js +22 -0
- package/features/serviceDiscovery/ServiceDiscovery.js.map +1 -0
- package/features/serviceDiscovery/__tests__/ServiceDiscovery.test.d.ts +1 -0
- package/features/serviceDiscovery/__tests__/ServiceDiscovery.test.js +111 -0
- package/features/serviceDiscovery/__tests__/ServiceDiscovery.test.js.map +1 -0
- package/features/serviceDiscovery/index.d.ts +3 -0
- package/features/serviceDiscovery/index.js +1 -0
- package/features/slugify/DefaultSlugify.d.ts +8 -0
- package/features/slugify/DefaultSlugify.js +20 -0
- package/features/slugify/DefaultSlugify.js.map +1 -0
- package/features/slugify/abstractions.d.ts +12 -0
- package/features/slugify/abstractions.js +5 -0
- package/features/slugify/abstractions.js.map +1 -0
- package/features/slugify/feature.d.ts +4 -0
- package/features/slugify/feature.js +11 -0
- package/features/slugify/feature.js.map +1 -0
- package/features/slugify/index.d.ts +3 -0
- package/features/slugify/index.js +2 -0
- package/features/storageOperations/abstractions.d.ts +21 -0
- package/features/storageOperations/abstractions.js +10 -0
- package/features/storageOperations/abstractions.js.map +1 -0
- package/features/stringFormatter/DefaultStringFormatter.d.ts +17 -0
- package/features/stringFormatter/DefaultStringFormatter.js +19 -0
- package/features/stringFormatter/DefaultStringFormatter.js.map +1 -0
- package/features/stringFormatter/abstractions.d.ts +11 -0
- package/features/stringFormatter/abstractions.js +5 -0
- package/features/stringFormatter/abstractions.js.map +1 -0
- package/features/stringFormatter/feature.d.ts +4 -0
- package/features/stringFormatter/feature.js +13 -0
- package/features/stringFormatter/feature.js.map +1 -0
- package/features/stringFormatter/index.d.ts +3 -0
- package/features/stringFormatter/index.js +2 -0
- package/features/task/TaskDefinition/abstractions.d.ts +69 -4
- package/features/task/TaskDefinition/abstractions.js +2 -1
- package/features/task/TaskDefinition/abstractions.js.map +1 -1
- package/features/tenancy/CreateTenant/CreateTenantUseCase.d.ts +1 -1
- package/features/tenancy/InstallTenant/InstallTenantUseCase.d.ts +1 -1
- package/features/tenancy/TenantContext/TenantContext.d.ts +1 -0
- package/features/tenancy/TenantContext/TenantContext.js +13 -8
- package/features/tenancy/TenantContext/TenantContext.js.map +1 -1
- package/features/tenancy/UpdateTenant/UpdateTenantUseCase.d.ts +2 -2
- package/features/users/CreateUser/decorators/CreateUserWithWcpIncrement.d.ts +1 -1
- package/features/wcp/WcpContext/WcpContext.d.ts +16 -5
- package/features/wcp/WcpContext/WcpContext.js +41 -2
- package/features/wcp/WcpContext/WcpContext.js.map +1 -1
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +15 -60
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +81 -25
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
- package/features/wcp/WcpContext/feature.d.ts +1 -2
- package/features/wcp/WcpContext/feature.js +2 -2
- package/features/wcp/WcpContext/feature.js.map +1 -1
- package/features/wcp/WcpContext/index.d.ts +0 -1
- package/features/wcp/WcpContext/types.d.ts +0 -4
- package/features/wcp/WcpFeature.d.ts +1 -1
- package/features/wcp/WcpFeature.js +7 -2
- package/features/wcp/WcpFeature.js.map +1 -1
- package/features/wcp/WcpLicenseLoader.d.ts +25 -0
- package/features/wcp/WcpLicenseLoader.js +58 -0
- package/features/wcp/WcpLicenseLoader.js.map +1 -0
- package/features/wcp/WcpLicenseProvider.d.ts +21 -0
- package/features/wcp/WcpLicenseProvider.js +14 -0
- package/features/wcp/WcpLicenseProvider.js.map +1 -0
- package/features/wcp/resolveWcpProjectEnvironment.d.ts +9 -0
- package/features/wcp/resolveWcpProjectEnvironment.js +23 -0
- package/features/wcp/resolveWcpProjectEnvironment.js.map +1 -0
- package/graphql/ApiCoreSchemaFactory.d.ts +16 -0
- package/graphql/ApiCoreSchemaFactory.js +58 -0
- package/graphql/ApiCoreSchemaFactory.js.map +1 -0
- package/graphql/featureFlags/FeatureFlagsSchemaFactory.d.ts +10 -0
- package/graphql/featureFlags/FeatureFlagsSchemaFactory.js +53 -0
- package/graphql/featureFlags/FeatureFlagsSchemaFactory.js.map +1 -0
- package/graphql/security/NotAuthorizedResponse.d.ts +1 -1
- package/graphql/security/NotAuthorizedResponse.js +1 -1
- package/graphql/security/NotAuthorizedResponse.js.map +1 -1
- package/graphql/security/SecuritySchemaFactory.d.ts +15 -0
- package/graphql/security/SecuritySchemaFactory.js +27 -0
- package/graphql/security/SecuritySchemaFactory.js.map +1 -0
- package/graphql/security/addApiKeySchema.d.ts +2 -0
- package/graphql/security/{apiKey.gql.js → addApiKeySchema.js} +45 -27
- package/graphql/security/addApiKeySchema.js.map +1 -0
- package/graphql/security/addIdentitySchema.d.ts +2 -0
- package/graphql/security/{identity.gql.js → addIdentitySchema.js} +52 -35
- package/graphql/security/addIdentitySchema.js.map +1 -0
- package/graphql/security/addRoleSchema.d.ts +2 -0
- package/graphql/security/addRoleSchema.js +137 -0
- package/graphql/security/addRoleSchema.js.map +1 -0
- package/graphql/security/addSecurityBaseSchema.d.ts +2 -0
- package/graphql/security/{base.gql.js → addSecurityBaseSchema.js} +14 -16
- package/graphql/security/addSecurityBaseSchema.js.map +1 -0
- package/graphql/security/addTeamSchema.d.ts +2 -0
- package/graphql/security/addTeamSchema.js +157 -0
- package/graphql/security/addTeamSchema.js.map +1 -0
- package/graphql/system/SystemSchemaFactory.d.ts +10 -0
- package/graphql/system/SystemSchemaFactory.js +70 -0
- package/graphql/system/SystemSchemaFactory.js.map +1 -0
- package/graphql/users/UsersSchemaFactory.d.ts +10 -0
- package/graphql/users/UsersSchemaFactory.js +195 -0
- package/graphql/users/UsersSchemaFactory.js.map +1 -0
- package/graphql/wcp/WcpSchemaFactory.d.ts +10 -0
- package/graphql/wcp/{graphql.js → WcpSchemaFactory.js} +32 -18
- package/graphql/wcp/WcpSchemaFactory.js.map +1 -0
- package/idp/JwksCache.d.ts +14 -3
- package/idp/JwksCache.js +97 -17
- package/idp/JwksCache.js.map +1 -1
- package/idp/JwksStoreFeature.d.ts +8 -0
- package/idp/JwksStoreFeature.js +11 -0
- package/idp/JwksStoreFeature.js.map +1 -0
- package/idp/MemoryJwksStore.d.ts +14 -0
- package/idp/MemoryJwksStore.js +21 -0
- package/idp/MemoryJwksStore.js.map +1 -0
- package/idp/OidcJwtIdentityProvider.js +5 -1
- package/idp/OidcJwtIdentityProvider.js.map +1 -1
- package/idp/abstractions.d.ts +24 -0
- package/idp/abstractions.js +2 -1
- package/idp/abstractions.js.map +1 -1
- package/idp/feature.js +1 -2
- package/idp/feature.js.map +1 -1
- package/idp/index.d.ts +1 -0
- package/idp/index.js +1 -0
- package/index.d.ts +3 -1
- package/index.js +3 -1
- package/package.json +23 -24
- package/testing/environment.d.ts +14 -0
- package/testing/environment.js +18 -0
- package/testing/environment.js.map +1 -0
- package/types/core.d.ts +17 -5
- package/types/security.d.ts +1 -7
- package/types/tenancy.d.ts +0 -17
- package/types/users.d.ts +0 -13
- package/createApiCore.d.ts +0 -7
- package/createApiCore.js +0 -22
- package/createApiCore.js.map +0 -1
- package/graphql/security/apiKey.gql.d.ts +0 -4
- package/graphql/security/apiKey.gql.js.map +0 -1
- package/graphql/security/base.gql.d.ts +0 -4
- package/graphql/security/base.gql.js.map +0 -1
- package/graphql/security/identity.gql.d.ts +0 -4
- package/graphql/security/identity.gql.js.map +0 -1
- package/graphql/security/index.d.ts +0 -1
- package/graphql/security/index.js +0 -15
- package/graphql/security/index.js.map +0 -1
- package/graphql/security/role.gql.d.ts +0 -4
- package/graphql/security/role.gql.js +0 -106
- package/graphql/security/role.gql.js.map +0 -1
- package/graphql/security/team.gql.d.ts +0 -4
- package/graphql/security/team.gql.js +0 -119
- package/graphql/security/team.gql.js.map +0 -1
- package/graphql/system/createSystemGraphQL.d.ts +0 -2
- package/graphql/system/createSystemGraphQL.js +0 -54
- package/graphql/system/createSystemGraphQL.js.map +0 -1
- package/graphql/users/user.gql.d.ts +0 -3
- package/graphql/users/user.gql.js +0 -167
- package/graphql/users/user.gql.js.map +0 -1
- package/graphql/wcp/graphql.d.ts +0 -2
- package/graphql/wcp/graphql.js.map +0 -1
- package/legacy/security/LegacyContext.d.ts +0 -36
- package/legacy/security/LegacyContext.js +0 -152
- package/legacy/security/LegacyContext.js.map +0 -1
- package/legacy/security/createSecurityContext.d.ts +0 -3
- package/legacy/security/createSecurityContext.js +0 -10
- package/legacy/security/createSecurityContext.js.map +0 -1
- package/legacy/security/plugins/apiKeyAuthentication.d.ts +0 -7
- package/legacy/security/plugins/apiKeyAuthentication.js +0 -20
- package/legacy/security/plugins/apiKeyAuthentication.js.map +0 -1
- package/legacy/security/plugins/apiKeyAuthorization.d.ts +0 -6
- package/legacy/security/plugins/apiKeyAuthorization.js +0 -13
- package/legacy/security/plugins/apiKeyAuthorization.js.map +0 -1
- package/legacy/security/plugins/authenticateUsingCookie.d.ts +0 -5
- package/legacy/security/plugins/authenticateUsingCookie.js +0 -23
- package/legacy/security/plugins/authenticateUsingCookie.js.map +0 -1
- package/legacy/security/plugins/authenticateUsingHttpHeader.d.ts +0 -5
- package/legacy/security/plugins/authenticateUsingHttpHeader.js +0 -20
- package/legacy/security/plugins/authenticateUsingHttpHeader.js.map +0 -1
- package/legacy/security/plugins/secureHeaders.d.ts +0 -1
- package/legacy/security/plugins/secureHeaders.js +0 -30
- package/legacy/security/plugins/secureHeaders.js.map +0 -1
- package/legacy/tenancy/LegacyContext.d.ts +0 -15
- package/legacy/tenancy/LegacyContext.js +0 -57
- package/legacy/tenancy/LegacyContext.js.map +0 -1
- package/legacy/tenancy/createTenancyContext.d.ts +0 -3
- package/legacy/tenancy/createTenancyContext.js +0 -31
- package/legacy/tenancy/createTenancyContext.js.map +0 -1
- package/legacy/users/LegacyContext.d.ts +0 -13
- package/legacy/users/LegacyContext.js +0 -55
- package/legacy/users/LegacyContext.js.map +0 -1
- package/legacy/users/createAdminUsersContext.d.ts +0 -3
- package/legacy/users/createAdminUsersContext.js +0 -12
- package/legacy/users/createAdminUsersContext.js.map +0 -1
- package/legacy/wcp/LegacyWcpContext.d.ts +0 -33
- package/legacy/wcp/LegacyWcpContext.js +0 -84
- package/legacy/wcp/LegacyWcpContext.js.map +0 -1
- package/legacy/wcp/context.d.ts +0 -5
- package/legacy/wcp/context.js +0 -46
- package/legacy/wcp/context.js.map +0 -1
package/ApiCoreFeature.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Container } from "@webiny/di";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ApiCoreConfig } from "./types/core.js";
|
|
3
3
|
export declare const ApiCoreFeature: {
|
|
4
4
|
name: string;
|
|
5
|
-
register(container: Container, context
|
|
5
|
+
register(container: Container, context?: ApiCoreConfig | undefined): void;
|
|
6
6
|
};
|
package/ApiCoreFeature.js
CHANGED
|
@@ -5,33 +5,63 @@ 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";
|
|
12
|
+
import { PublicUrlsFeature } from "./features/publicUrls/feature.js";
|
|
13
|
+
import { DebuggerFeature } from "./features/debugger/feature.js";
|
|
11
14
|
import { EncryptionFeature } from "./features/encryption/feature.js";
|
|
15
|
+
import { HasherFeature } from "./features/hashing/feature.js";
|
|
12
16
|
import { FeatureFlagsFeature } from "./features/featureFlags/feature.js";
|
|
13
17
|
import { MaskerFeature } from "./features/masker/feature.js";
|
|
18
|
+
import { StringFormatterFeature } from "./features/stringFormatter/feature.js";
|
|
19
|
+
import { DateFormatterFeature } from "./features/dateFormatter/feature.js";
|
|
14
20
|
import { AiFeature } from "./features/ai/feature.js";
|
|
21
|
+
import { WcpFeature } from "./features/wcp/WcpFeature.js";
|
|
22
|
+
import { HttpClientFeature } from "./features/httpClient/feature.js";
|
|
15
23
|
import { NullWebhookDispatcher } from "./features/webhooks/WebhookDispatcher/NullWebhookDispatcher.js";
|
|
16
24
|
import { WebhookProviderFeature } from "./features/webhooks/index.js";
|
|
25
|
+
import { RequestContextFeature } from "./features/requestContext/index.js";
|
|
26
|
+
import { ApiCoreSchemaFactory } from "./graphql/ApiCoreSchemaFactory.js";
|
|
27
|
+
import { SecuritySchemaFactory } from "./graphql/security/SecuritySchemaFactory.js";
|
|
28
|
+
import { UsersSchemaFactory } from "./graphql/users/UsersSchemaFactory.js";
|
|
29
|
+
import { SystemSchemaFactory } from "./graphql/system/SystemSchemaFactory.js";
|
|
30
|
+
import { WcpSchemaFactory } from "./graphql/wcp/WcpSchemaFactory.js";
|
|
31
|
+
import { FeatureFlagsSchemaFactory } from "./graphql/featureFlags/FeatureFlagsSchemaFactory.js";
|
|
17
32
|
const ApiCoreFeature = createFeature({
|
|
18
33
|
name: "ApiCore",
|
|
19
|
-
register (container, config) {
|
|
34
|
+
register (container, config = {}) {
|
|
35
|
+
const storageOperations = container.resolve(ApiCoreStorageOperationsFactory).create();
|
|
36
|
+
WcpFeature.register(container, config.wcpLicense);
|
|
20
37
|
MaskerFeature.register(container);
|
|
38
|
+
StringFormatterFeature.register(container);
|
|
39
|
+
DateFormatterFeature.register(container);
|
|
40
|
+
HttpClientFeature.register(container);
|
|
21
41
|
AiFeature.register(container);
|
|
22
42
|
LoggerFeature.register(container);
|
|
23
43
|
EventPublisherFeature.register(container);
|
|
24
44
|
BuildParamsFeature.register(container);
|
|
45
|
+
PublicUrlsFeature.register(container);
|
|
46
|
+
DebuggerFeature.register(container);
|
|
25
47
|
EncryptionFeature.register(container);
|
|
48
|
+
HasherFeature.register(container);
|
|
26
49
|
FeatureFlagsFeature.register(container);
|
|
27
|
-
TenancyFeature.register(container,
|
|
28
|
-
SecurityFeature.register(container,
|
|
29
|
-
AdminUsersFeature.register(container,
|
|
30
|
-
KeyValueStoreFeature.register(container,
|
|
50
|
+
TenancyFeature.register(container, storageOperations.tenancyStorageOperations);
|
|
51
|
+
SecurityFeature.register(container, storageOperations.securityStorageOperations);
|
|
52
|
+
AdminUsersFeature.register(container, storageOperations.usersStorageOperations);
|
|
53
|
+
KeyValueStoreFeature.register(container, storageOperations.keyValueStorageOperations);
|
|
31
54
|
SystemFeature.register(container);
|
|
32
55
|
IdpAuthenticatorFeature.register(container);
|
|
56
|
+
RequestContextFeature.register(container);
|
|
33
57
|
container.register(NullWebhookDispatcher).inSingletonScope();
|
|
34
58
|
WebhookProviderFeature.register(container);
|
|
59
|
+
container.register(ApiCoreSchemaFactory);
|
|
60
|
+
container.register(SecuritySchemaFactory);
|
|
61
|
+
container.register(UsersSchemaFactory);
|
|
62
|
+
container.register(SystemSchemaFactory);
|
|
63
|
+
container.register(WcpSchemaFactory);
|
|
64
|
+
container.register(FeatureFlagsSchemaFactory);
|
|
35
65
|
}
|
|
36
66
|
});
|
|
37
67
|
export { ApiCoreFeature };
|
package/ApiCoreFeature.js.map
CHANGED
|
@@ -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 {
|
|
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 { PublicUrlsFeature } from \"~/features/publicUrls/feature.js\";\nimport { DebuggerFeature } from \"~/features/debugger/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 { HttpClientFeature } from \"~/features/httpClient/feature.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 HttpClientFeature.register(container);\n AiFeature.register(container);\n LoggerFeature.register(container);\n EventPublisherFeature.register(container);\n BuildParamsFeature.register(container);\n PublicUrlsFeature.register(container);\n DebuggerFeature.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","HttpClientFeature","AiFeature","LoggerFeature","EventPublisherFeature","BuildParamsFeature","PublicUrlsFeature","DebuggerFeature","EncryptionFeature","HasherFeature","FeatureFlagsFeature","TenancyFeature","SecurityFeature","AdminUsersFeature","KeyValueStoreFeature","SystemFeature","IdpAuthenticatorFeature","RequestContextFeature","NullWebhookDispatcher","WebhookProviderFeature","ApiCoreSchemaFactory","SecuritySchemaFactory","UsersSchemaFactory","SystemSchemaFactory","WcpSchemaFactory","FeatureFlagsSchemaFactory"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCO,MAAMA,iBAAiBC,cAAc;IACxC,MAAM;IACN,UAASC,SAAoB,EAAEC,SAAwB,CAAC,CAAC;QAGrD,MAAMC,oBAAoBF,UAAU,OAAO,CAACG,iCAAiC,MAAM;QAGnFC,WAAW,QAAQ,CAACJ,WAAWC,OAAO,UAAU;QAChDI,cAAc,QAAQ,CAACL;QACvBM,uBAAuB,QAAQ,CAACN;QAChCO,qBAAqB,QAAQ,CAACP;QAC9BQ,kBAAkB,QAAQ,CAACR;QAC3BS,UAAU,QAAQ,CAACT;QACnBU,cAAc,QAAQ,CAACV;QACvBW,sBAAsB,QAAQ,CAACX;QAC/BY,mBAAmB,QAAQ,CAACZ;QAC5Ba,kBAAkB,QAAQ,CAACb;QAC3Bc,gBAAgB,QAAQ,CAACd;QACzBe,kBAAkB,QAAQ,CAACf;QAC3BgB,cAAc,QAAQ,CAAChB;QACvBiB,oBAAoB,QAAQ,CAACjB;QAC7BkB,eAAe,QAAQ,CAAClB,WAAWE,kBAAkB,wBAAwB;QAC7EiB,gBAAgB,QAAQ,CAACnB,WAAWE,kBAAkB,yBAAyB;QAC/EkB,kBAAkB,QAAQ,CAACpB,WAAWE,kBAAkB,sBAAsB;QAC9EmB,qBAAqB,QAAQ,CAACrB,WAAWE,kBAAkB,yBAAyB;QACpFoB,cAAc,QAAQ,CAACtB;QACvBuB,wBAAwB,QAAQ,CAACvB;QACjCwB,sBAAsB,QAAQ,CAACxB;QAC/BA,UAAU,QAAQ,CAACyB,uBAAuB,gBAAgB;QAC1DC,uBAAuB,QAAQ,CAAC1B;QAIhCA,UAAU,QAAQ,CAAC2B;QACnB3B,UAAU,QAAQ,CAAC4B;QACnB5B,UAAU,QAAQ,CAAC6B;QACnB7B,UAAU,QAAQ,CAAC8B;QACnB9B,UAAU,QAAQ,CAAC+B;QACnB/B,UAAU,QAAQ,CAACgC;IACvB;AACJ"}
|
|
@@ -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";
|
|
@@ -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/tasks.d.ts
CHANGED
package/exports/api/tasks.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { TaskService } from "../../features/task/TaskService/index.js";
|
|
2
|
-
export { TaskDefinition } from "../../features/task/TaskDefinition/index.js";
|
|
2
|
+
export { TaskDefinition, TaskHandler } from "../../features/task/TaskDefinition/index.js";
|
package/exports/api.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export { AiSdk, AiSdkFactory, AiConnectionFactory, Ai } from "../features/ai/index.js";
|
|
1
|
+
export { AiSdk, AiSdkFactory, AiSdkToolDefinition, AiSdkToolHandler, AiConnectionFactory, Ai, AiModelRegistry } from "../features/ai/index.js";
|
|
2
2
|
export type { IAiConnection, IAiConnectionInline } from "../features/ai/index.js";
|
|
3
3
|
export { Logger } from "../features/logger/index.js";
|
|
4
4
|
export { Encryption } from "../features/encryption/index.js";
|
|
5
|
+
export { Hasher } from "../features/hashing/index.js";
|
|
5
6
|
export { BuildParam, BuildParams } from "../features/buildParams/index.js";
|
|
6
7
|
export { DomainEvent, EventPublisher } from "../features/eventPublisher/index.js";
|
|
7
8
|
export { GlobalKeyValueStore, KeyValueStore } from "../features/keyValueStore/index.js";
|
package/exports/api.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { Ai, AiConnectionFactory, AiSdk, AiSdkFactory } from "../features/ai/index.js";
|
|
1
|
+
export { Ai, AiConnectionFactory, AiModelRegistry, AiSdk, AiSdkFactory, AiSdkToolDefinition, AiSdkToolHandler } 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";
|
package/features/ai/Ai.d.ts
CHANGED
|
@@ -3,15 +3,19 @@ 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";
|
|
6
7
|
import type { AiGenerateTextParams, AiModel } from "./abstractions.js";
|
|
7
8
|
import type { AiStreamTextParams } from "./abstractions.js";
|
|
8
9
|
import type { IAiConnectionInline } from "./abstractions.js";
|
|
10
|
+
import { EventPublisher } from "../../features/eventPublisher/index.js";
|
|
9
11
|
declare class AiImpl implements AiAbstraction.Interface {
|
|
10
12
|
private readonly sdkFactories;
|
|
11
13
|
private readonly connectionFactories;
|
|
14
|
+
private readonly eventPublisher;
|
|
15
|
+
private readonly modelRegistry;
|
|
12
16
|
private sdkCache;
|
|
13
17
|
private resolvedConnections;
|
|
14
|
-
constructor(sdkFactories: AiSdkFactory.Interface[], connectionFactories: AiConnectionFactory.Interface[]);
|
|
18
|
+
constructor(sdkFactories: AiSdkFactory.Interface[], connectionFactories: AiConnectionFactory.Interface[], eventPublisher: EventPublisher.Interface, modelRegistry: AiModelRegistry.Interface);
|
|
15
19
|
generateText(params: AiGenerateTextParams): ReturnType<typeof generateText>;
|
|
16
20
|
streamText(params: AiStreamTextParams): Promise<ReturnType<typeof streamText>>;
|
|
17
21
|
listModels(): Promise<AiModel[]>;
|
package/features/ai/Ai.js
CHANGED
|
@@ -1,61 +1,102 @@
|
|
|
1
1
|
import { createImplementation } from "@webiny/feature/api";
|
|
2
2
|
import { generateText, streamText } from "ai";
|
|
3
|
-
import { Ai, AiConnectionFactory, AiSdkFactory } from "./abstractions.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
3
|
+
import { Ai, AiConnectionFactory, AiModelRegistry, 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
|
+
const withSupportedOptions = (options, model)=>{
|
|
8
|
+
if (void 0 === options.temperature || model.supports?.temperature === true) return options;
|
|
9
|
+
const { temperature: _temperature, ...rest } = options;
|
|
10
|
+
return rest;
|
|
11
|
+
};
|
|
12
12
|
class AiImpl {
|
|
13
|
-
constructor(sdkFactories, connectionFactories){
|
|
13
|
+
constructor(sdkFactories, connectionFactories, eventPublisher, modelRegistry){
|
|
14
14
|
this.sdkFactories = sdkFactories;
|
|
15
15
|
this.connectionFactories = connectionFactories;
|
|
16
|
+
this.eventPublisher = eventPublisher;
|
|
17
|
+
this.modelRegistry = modelRegistry;
|
|
16
18
|
this.sdkCache = new Map();
|
|
17
19
|
this.resolvedConnections = null;
|
|
18
20
|
}
|
|
19
|
-
generateText(params) {
|
|
20
|
-
const { model, connection, ...
|
|
21
|
-
|
|
21
|
+
async generateText(params) {
|
|
22
|
+
const { model, connection, ...options } = params;
|
|
23
|
+
const { languageModel: resolvedModel, model: catalogModel } = await this.resolveLanguageModel(model, connection);
|
|
24
|
+
const rest = withSupportedOptions(options, catalogModel);
|
|
25
|
+
const requestId = mdbid();
|
|
26
|
+
await this.eventPublisher.publish(new AiBeforeGenerateTextEvent({
|
|
27
|
+
requestId,
|
|
28
|
+
params
|
|
29
|
+
}));
|
|
30
|
+
const start = performance.now();
|
|
31
|
+
try {
|
|
32
|
+
const result = await generateText({
|
|
22
33
|
model: resolvedModel,
|
|
23
34
|
...rest
|
|
35
|
+
});
|
|
36
|
+
const duration = performance.now() - start;
|
|
37
|
+
await this.eventPublisher.publish(new AiAfterGenerateTextEvent({
|
|
38
|
+
requestId,
|
|
39
|
+
params,
|
|
40
|
+
result,
|
|
41
|
+
duration
|
|
42
|
+
}));
|
|
43
|
+
return result;
|
|
44
|
+
} catch (err) {
|
|
45
|
+
const duration = performance.now() - start;
|
|
46
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
47
|
+
await this.eventPublisher.publish(new AiGenerateTextErrorEvent({
|
|
48
|
+
requestId,
|
|
49
|
+
params,
|
|
50
|
+
error,
|
|
51
|
+
duration
|
|
24
52
|
}));
|
|
53
|
+
throw err;
|
|
54
|
+
}
|
|
25
55
|
}
|
|
26
56
|
async streamText(params) {
|
|
27
|
-
const { model, connection, ...
|
|
28
|
-
const resolvedModel = await this.resolveLanguageModel(model, connection);
|
|
57
|
+
const { model, connection, ...options } = params;
|
|
58
|
+
const { languageModel: resolvedModel, model: catalogModel } = await this.resolveLanguageModel(model, connection);
|
|
59
|
+
const rest = withSupportedOptions(options, catalogModel);
|
|
60
|
+
await this.eventPublisher.publish(new AiBeforeStreamTextEvent({
|
|
61
|
+
params
|
|
62
|
+
}));
|
|
29
63
|
return streamText({
|
|
30
64
|
model: resolvedModel,
|
|
31
65
|
...rest
|
|
32
66
|
});
|
|
33
67
|
}
|
|
34
68
|
listModels() {
|
|
35
|
-
return
|
|
69
|
+
return this.modelRegistry.listModels();
|
|
36
70
|
}
|
|
37
71
|
async listModelsByConnections() {
|
|
38
|
-
const connections = await
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
72
|
+
const [connections, models] = await Promise.all([
|
|
73
|
+
this.getConnections(),
|
|
74
|
+
this.modelRegistry.listModels()
|
|
75
|
+
]);
|
|
76
|
+
const connectedProviderIds = new Set(connections.map((c)=>c.sdkName));
|
|
77
|
+
return models.filter((m)=>connectedProviderIds.has(m.providerId));
|
|
44
78
|
}
|
|
45
79
|
async listModelsByConnection(connection) {
|
|
46
|
-
const conn = await
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
80
|
+
const [conn, models] = await Promise.all([
|
|
81
|
+
this.resolveConnection(void 0, connection),
|
|
82
|
+
this.modelRegistry.listModels()
|
|
83
|
+
]);
|
|
84
|
+
return models.filter((m)=>m.providerId === conn.sdkName);
|
|
50
85
|
}
|
|
51
86
|
async resolveLanguageModel(modelId, connection) {
|
|
52
87
|
const slashIndex = modelId.indexOf("/");
|
|
53
88
|
if (-1 === slashIndex) throw new Error(`Invalid model ID "${modelId}". Expected format: "<providerId>/<modelId>" (e.g. "openai/gpt-4o").`);
|
|
54
89
|
const providerId = modelId.slice(0, slashIndex);
|
|
55
|
-
const
|
|
90
|
+
const rawModelId = modelId.slice(slashIndex + 1);
|
|
91
|
+
const models = await this.modelRegistry.listModels();
|
|
92
|
+
const found = models.find((m)=>m.providerId === providerId && m.modelId === rawModelId);
|
|
93
|
+
if (!found) throw new Error(`Model "${modelId}" is not available. Use listModels() to see available models.`);
|
|
56
94
|
const conn = await this.resolveConnection(providerId, connection);
|
|
57
95
|
const sdk = await this.getSdk(conn);
|
|
58
|
-
return
|
|
96
|
+
return {
|
|
97
|
+
languageModel: sdk.languageModel(rawModelId),
|
|
98
|
+
model: found
|
|
99
|
+
};
|
|
59
100
|
}
|
|
60
101
|
async getConnections() {
|
|
61
102
|
if (!this.resolvedConnections) this.resolvedConnections = await Promise.all(this.connectionFactories.map((f)=>f.execute()));
|
|
@@ -108,7 +149,9 @@ const Ai_Ai = createImplementation({
|
|
|
108
149
|
{
|
|
109
150
|
multiple: true
|
|
110
151
|
}
|
|
111
|
-
]
|
|
152
|
+
],
|
|
153
|
+
EventPublisher,
|
|
154
|
+
AiModelRegistry
|
|
112
155
|
]
|
|
113
156
|
});
|
|
114
157
|
export { Ai_Ai as Ai };
|
package/features/ai/Ai.js.map
CHANGED
|
@@ -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 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\";\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 ) {}\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 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 ]\n});\n"],"names":["toAiModel","factory","modelId","modelName","AiImpl","sdkFactories","connectionFactories","Map","params","model","connection","rest","resolvedModel","generateText","streamText","Promise","m","connections","conn","f","undefined","slashIndex","Error","providerId","sdk","found","c","known","cacheKey","cached","Ai","createImplementation","AiAbstraction","AiSdkFactory","AiConnectionFactory"],"mappings":";;;AAaA,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,CACvE;aAFmBD,YAAY,GAAZA;aACAC,mBAAmB,GAAnBA;aALb,QAAQ,GAAG,IAAIC;aACf,mBAAmB,GAA2B;IAKnD;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,OAAOI,QAAQ,OAAO,CAClB,IAAI,CAAC,YAAY,CAAC,OAAO,CAACd,CAAAA,UACtBA,QAAQ,MAAM,CAAC,GAAG,CAACe,CAAAA,IAAKhB,UAAUC,SAASe,EAAE,EAAE,EAAEA,EAAE,IAAI;IAGnE;IAEA,MAAM,0BAA8C;QAChD,MAAM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AC,IAAI,CAACkB,CAAAA,IAAKA,EAAE,EAAE,KAAKT,WAAW,OAAO;QACvE,IAAI,CAACT,SAAS;YACV,MAAM0B,QAAQ,IAAI,CAAC,YAAY,CAAC,GAAG,CAACR,CAAAA,IAAK,CAAC,CAAC,EAAEA,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;YAC3D,MAAM,IAAIG,MACN,CAAC,6BAA6B,EAAEZ,WAAW,OAAO,CAAC,yBAAyB,EAAEiB,MAAM,CAAC,CAAC;QAE9F;QAEA,MAAMH,MAAM,MAAMvB,QAAQ,OAAO,CAACS,WAAW,MAAM;QACnD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAACkB,UAAUJ;QAC5B,OAAOA;IACX;AACJ;AAEO,MAAMM,QAAKC,qBAAqB;IACnC,aAAaC;IACb,gBAAgB5B;IAChB,cAAc;QACV;YAAC6B;YAAc;gBAAE,UAAU;YAAK;SAAE;QAClC;YAACC;YAAqB;gBAAE,UAAU;YAAK;SAAE;KAC5C;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 { 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\";\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\n/**\n * Drops call options the model doesn't accept. Several current models reject `temperature` outright\n * (a 400, not a warning), so it is only sent when the catalog says the model supports it. No\n * information counts as unsupported: leaving it out costs some determinism, sending it can fail the\n * whole request.\n */\nconst withSupportedOptions = <T extends { temperature?: number }>(\n options: T,\n model: AiModel\n): T => {\n if (options.temperature === undefined || model.supports?.temperature === true) {\n return options;\n }\n const { temperature: _temperature, ...rest } = options;\n return rest as T;\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 private readonly modelRegistry: AiModelRegistry.Interface\n ) {}\n\n async generateText(params: AiGenerateTextParams): ReturnType<typeof generateText> {\n const { model, connection, ...options } = params;\n const { languageModel: resolvedModel, model: catalogModel } =\n await this.resolveLanguageModel(model, connection);\n const rest = withSupportedOptions(options, catalogModel);\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, ...options } = params;\n const { languageModel: resolvedModel, model: catalogModel } =\n await this.resolveLanguageModel(model, connection);\n const rest = withSupportedOptions(options, catalogModel);\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 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: LanguageModel; model: AiModel }> {\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 const models = await this.modelRegistry.listModels();\n const found = models.find(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 { languageModel: sdk.languageModel(rawModelId), model: found };\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 AiModelRegistry\n ]\n});\n"],"names":["withSupportedOptions","options","model","undefined","_temperature","rest","AiImpl","sdkFactories","connectionFactories","eventPublisher","modelRegistry","Map","params","connection","resolvedModel","catalogModel","requestId","mdbid","AiBeforeGenerateTextEvent","start","performance","result","generateText","duration","AiAfterGenerateTextEvent","err","error","Error","String","AiGenerateTextErrorEvent","AiBeforeStreamTextEvent","streamText","connections","models","Promise","connectedProviderIds","Set","c","m","conn","modelId","slashIndex","providerId","rawModelId","found","sdk","f","known","cacheKey","cached","factory","Ai","createImplementation","AiAbstraction","AiSdkFactory","AiConnectionFactory","EventPublisher","AiModelRegistry"],"mappings":";;;;;;AA4BA,MAAMA,uBAAuB,CACz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ACV;YAACgD;YAAc;gBAAE,UAAU;YAAK;SAAE;QAClC;YAACC;YAAqB;gBAAE,UAAU;YAAK;SAAE;QACzCC;QACAC;KACH;AACL"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AiModelRegistry as AiModelRegistryAbstraction } from "./abstractions.js";
|
|
2
|
+
import { AiSdkFactory } from "./abstractions.js";
|
|
3
|
+
import { AiModelCatalog } from "./abstractions.js";
|
|
4
|
+
import type { AiModel } from "./abstractions.js";
|
|
5
|
+
declare class AiModelRegistryImpl implements AiModelRegistryAbstraction.Interface {
|
|
6
|
+
private readonly sdkFactories;
|
|
7
|
+
private readonly catalog;
|
|
8
|
+
constructor(sdkFactories: AiSdkFactory.Interface[], catalog: AiModelCatalog.Interface);
|
|
9
|
+
listModels(): Promise<AiModel[]>;
|
|
10
|
+
}
|
|
11
|
+
export declare const AiModelRegistry: typeof AiModelRegistryImpl & {
|
|
12
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IAiModelRegistry>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { AiModelCatalog, AiModelRegistry, AiSdkFactory } from "./abstractions.js";
|
|
2
|
+
class AiModelRegistryImpl {
|
|
3
|
+
constructor(sdkFactories, catalog){
|
|
4
|
+
this.sdkFactories = sdkFactories;
|
|
5
|
+
this.catalog = catalog;
|
|
6
|
+
}
|
|
7
|
+
async listModels() {
|
|
8
|
+
const providers = await this.catalog.listProviders();
|
|
9
|
+
return this.sdkFactories.flatMap((factory)=>{
|
|
10
|
+
const provider = providers?.find((p)=>p.id === factory.id);
|
|
11
|
+
const providerName = provider?.name ?? factory.name;
|
|
12
|
+
const models = provider?.models ?? factory.models;
|
|
13
|
+
return models.map((m)=>({
|
|
14
|
+
providerId: factory.id,
|
|
15
|
+
providerName,
|
|
16
|
+
modelId: m.id,
|
|
17
|
+
modelName: m.name,
|
|
18
|
+
deprecated: m.deprecated,
|
|
19
|
+
endOfLife: m.endOfLife,
|
|
20
|
+
supports: m.supports
|
|
21
|
+
}));
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const AiModelRegistry_AiModelRegistry = AiModelRegistry.createImplementation({
|
|
26
|
+
implementation: AiModelRegistryImpl,
|
|
27
|
+
dependencies: [
|
|
28
|
+
[
|
|
29
|
+
AiSdkFactory,
|
|
30
|
+
{
|
|
31
|
+
multiple: true
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
AiModelCatalog
|
|
35
|
+
]
|
|
36
|
+
});
|
|
37
|
+
export { AiModelRegistry_AiModelRegistry as AiModelRegistry };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=AiModelRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/ai/AiModelRegistry.js","sources":["../../../src/features/ai/AiModelRegistry.ts"],"sourcesContent":["import { AiModelRegistry as AiModelRegistryAbstraction } from \"./abstractions.js\";\nimport { AiSdkFactory } from \"./abstractions.js\";\nimport { AiModelCatalog } from \"./abstractions.js\";\nimport type { AiModel } from \"./abstractions.js\";\n\nclass AiModelRegistryImpl implements AiModelRegistryAbstraction.Interface {\n constructor(\n private readonly sdkFactories: AiSdkFactory.Interface[],\n private readonly catalog: AiModelCatalog.Interface\n ) {}\n\n async listModels(): Promise<AiModel[]> {\n const providers = await this.catalog.listProviders();\n\n /*\n * A provider is only offered when an SDK factory can serve it. The catalog decides its\n * models; a factory the catalog doesn't know (a custom SDK), or an unreachable catalog,\n * falls back to the factory's own list.\n */\n return this.sdkFactories.flatMap(factory => {\n const provider = providers?.find(p => p.id === factory.id);\n const providerName = provider?.name ?? factory.name;\n const models = provider?.models ?? factory.models;\n\n return models.map(m => ({\n providerId: factory.id,\n providerName,\n modelId: m.id,\n modelName: m.name,\n deprecated: m.deprecated,\n endOfLife: m.endOfLife,\n supports: m.supports\n }));\n });\n }\n}\n\nexport const AiModelRegistry = AiModelRegistryAbstraction.createImplementation({\n implementation: AiModelRegistryImpl,\n dependencies: [[AiSdkFactory, { multiple: true }], AiModelCatalog]\n});\n"],"names":["AiModelRegistryImpl","sdkFactories","catalog","providers","factory","provider","p","providerName","models","m","AiModelRegistry","AiModelRegistryAbstraction","AiSdkFactory","AiModelCatalog"],"mappings":";AAKA,MAAMA;IACF,YACqBC,YAAsC,EACtCC,OAAiC,CACpD;aAFmBD,YAAY,GAAZA;aACAC,OAAO,GAAPA;IAClB;IAEH,MAAM,aAAiC;QACnC,MAAMC,YAAY,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa;QAOlD,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAACC,CAAAA;YAC7B,MAAMC,WAAWF,WAAW,KAAKG,CAAAA,IAAKA,EAAE,EAAE,KAAKF,QAAQ,EAAE;YACzD,MAAMG,eAAeF,UAAU,QAAQD,QAAQ,IAAI;YACnD,MAAMI,SAASH,UAAU,UAAUD,QAAQ,MAAM;YAEjD,OAAOI,OAAO,GAAG,CAACC,CAAAA,IAAM;oBACpB,YAAYL,QAAQ,EAAE;oBACtBG;oBACA,SAASE,EAAE,EAAE;oBACb,WAAWA,EAAE,IAAI;oBACjB,YAAYA,EAAE,UAAU;oBACxB,WAAWA,EAAE,SAAS;oBACtB,UAAUA,EAAE,QAAQ;gBACxB;QACJ;IACJ;AACJ;AAEO,MAAMC,kCAAkBC,gBAAAA,oBAA+C,CAAC;IAC3E,gBAAgBX;IAChB,cAAc;QAAC;YAACY;YAAc;gBAAE,UAAU;YAAK;SAAE;QAAEC;KAAe;AACtE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Container, Constructor } from "@webiny/di";
|
|
2
|
+
import { AiSdkToolHandler, AiSdkToolHandlerResolver as Abstraction } from "./abstractions.js";
|
|
3
|
+
declare class ContainerAiSdkToolHandlerResolver implements Abstraction.Interface {
|
|
4
|
+
private readonly container;
|
|
5
|
+
constructor(container: Container);
|
|
6
|
+
resolve<TInput>(handler: Constructor<AiSdkToolHandler.Interface<TInput>>): AiSdkToolHandler.Interface<TInput>;
|
|
7
|
+
}
|
|
8
|
+
export declare const AiSdkToolHandlerResolver: typeof ContainerAiSdkToolHandlerResolver & {
|
|
9
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IAiSdkToolHandlerResolver>;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RequestContainer } from "@webiny/event-handler-core/features/events/RequestContainer.js";
|
|
2
|
+
import { AiSdkToolHandlerResolver } from "./abstractions.js";
|
|
3
|
+
class ContainerAiSdkToolHandlerResolver {
|
|
4
|
+
constructor(container){
|
|
5
|
+
this.container = container;
|
|
6
|
+
}
|
|
7
|
+
resolve(handler) {
|
|
8
|
+
return this.container.resolveImplementation(handler);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const AiSdkToolHandlerResolver_AiSdkToolHandlerResolver = AiSdkToolHandlerResolver.createImplementation({
|
|
12
|
+
implementation: ContainerAiSdkToolHandlerResolver,
|
|
13
|
+
dependencies: [
|
|
14
|
+
RequestContainer
|
|
15
|
+
]
|
|
16
|
+
});
|
|
17
|
+
export { AiSdkToolHandlerResolver_AiSdkToolHandlerResolver as AiSdkToolHandlerResolver };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=AiSdkToolHandlerResolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/ai/AiSdkToolHandlerResolver.js","sources":["../../../src/features/ai/AiSdkToolHandlerResolver.ts"],"sourcesContent":["import type { Container, Constructor } from \"@webiny/di\";\nimport { RequestContainer } from \"@webiny/event-handler-core/features/events/RequestContainer.js\";\nimport { AiSdkToolHandler, AiSdkToolHandlerResolver as Abstraction } from \"./abstractions.js\";\n\nclass ContainerAiSdkToolHandlerResolver implements Abstraction.Interface {\n constructor(private readonly container: Container) {}\n\n resolve<TInput>(\n handler: Constructor<AiSdkToolHandler.Interface<TInput>>\n ): AiSdkToolHandler.Interface<TInput> {\n /*\n * `resolveImplementation` builds the class from its own dependency metadata and runs it\n * through the normal resolution path, so decorators registered against the handler still\n * apply. It deliberately ignores registrations, which is what we want here: the tool names\n * the class directly and nothing registers handlers against an abstraction.\n */\n return this.container.resolveImplementation(handler);\n }\n}\n\nexport const AiSdkToolHandlerResolver = Abstraction.createImplementation({\n implementation: ContainerAiSdkToolHandlerResolver,\n dependencies: [RequestContainer]\n});\n"],"names":["ContainerAiSdkToolHandlerResolver","container","handler","AiSdkToolHandlerResolver","Abstraction","RequestContainer"],"mappings":";;AAIA,MAAMA;IACF,YAA6BC,SAAoB,CAAE;aAAtBA,SAAS,GAATA;IAAuB;IAEpD,QACIC,OAAwD,EACtB;QAOlC,OAAO,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAACA;IAChD;AACJ;AAEO,MAAMC,oDAA2BC,yBAAAA,oBAAgC,CAAC;IACrE,gBAAgBJ;IAChB,cAAc;QAACK;KAAiB;AACpC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AiSdkToolDefinition, AiSdkToolHandlerResolver, AiSdkTools as AiSdkToolsAbstraction } from "./abstractions.js";
|
|
2
2
|
import type { ToolSet } from "ai";
|
|
3
3
|
declare class AiSdkToolsImpl implements AiSdkToolsAbstraction.Interface {
|
|
4
|
-
private
|
|
5
|
-
|
|
4
|
+
private definitions;
|
|
5
|
+
private resolver;
|
|
6
|
+
constructor(definitions: AiSdkToolDefinition.Interface[], resolver: AiSdkToolHandlerResolver.Interface);
|
|
6
7
|
getToolSet(): ToolSet;
|
|
7
8
|
}
|
|
8
9
|
export declare const AiSdkTools: typeof AiSdkToolsImpl & {
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AiSdkToolDefinition, AiSdkToolHandlerResolver, AiSdkTools } from "./abstractions.js";
|
|
2
2
|
class AiSdkToolsImpl {
|
|
3
|
-
constructor(
|
|
4
|
-
this.
|
|
3
|
+
constructor(definitions, resolver){
|
|
4
|
+
this.definitions = definitions;
|
|
5
|
+
this.resolver = resolver;
|
|
5
6
|
}
|
|
6
7
|
getToolSet() {
|
|
7
8
|
const map = {};
|
|
8
|
-
for (const
|
|
9
|
-
description:
|
|
10
|
-
inputSchema:
|
|
11
|
-
execute: (input)=>
|
|
9
|
+
for (const definition of this.definitions)map[definition.name] = {
|
|
10
|
+
description: definition.description,
|
|
11
|
+
inputSchema: definition.inputSchema,
|
|
12
|
+
execute: (input)=>this.resolver.resolve(definition.handler).execute(input)
|
|
12
13
|
};
|
|
13
14
|
return map;
|
|
14
15
|
}
|
|
@@ -17,11 +18,12 @@ const AiSdkTools_AiSdkTools = AiSdkTools.createImplementation({
|
|
|
17
18
|
implementation: AiSdkToolsImpl,
|
|
18
19
|
dependencies: [
|
|
19
20
|
[
|
|
20
|
-
|
|
21
|
+
AiSdkToolDefinition,
|
|
21
22
|
{
|
|
22
23
|
multiple: true
|
|
23
24
|
}
|
|
24
|
-
]
|
|
25
|
+
],
|
|
26
|
+
AiSdkToolHandlerResolver
|
|
25
27
|
]
|
|
26
28
|
});
|
|
27
29
|
export { AiSdkTools_AiSdkTools as AiSdkTools };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/ai/AiSdkTools.js","sources":["../../../src/features/ai/AiSdkTools.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"features/ai/AiSdkTools.js","sources":["../../../src/features/ai/AiSdkTools.ts"],"sourcesContent":["import {\n AiSdkToolDefinition,\n AiSdkToolHandlerResolver,\n AiSdkTools as AiSdkToolsAbstraction\n} from \"./abstractions.js\";\nimport type { ToolSet } from \"ai\";\n\nclass AiSdkToolsImpl implements AiSdkToolsAbstraction.Interface {\n constructor(\n private definitions: AiSdkToolDefinition.Interface[],\n private resolver: AiSdkToolHandlerResolver.Interface\n ) {}\n\n getToolSet(): ToolSet {\n const map: ToolSet = {};\n for (const definition of this.definitions) {\n map[definition.name] = {\n description: definition.description,\n inputSchema: definition.inputSchema,\n /*\n * Deliberately resolved inside the call, not here. The model is offered every\n * tool and calls a few, which is what keeps the rest of their use cases unbuilt.\n *\n * `resolve` IS `container.resolveImplementation`, one layer down. It lives behind\n * an abstraction so this class does not inject a container. Note it builds the\n * class the definition names; resolving the `AiSdkToolHandler` abstraction would\n * find nothing, since handlers are declared through it but never registered.\n */\n execute: (input: unknown) =>\n this.resolver.resolve(definition.handler).execute(input)\n };\n }\n return map;\n }\n}\n\nexport const AiSdkTools = AiSdkToolsAbstraction.createImplementation({\n implementation: AiSdkToolsImpl,\n dependencies: [[AiSdkToolDefinition, { multiple: true }], AiSdkToolHandlerResolver]\n});\n"],"names":["AiSdkToolsImpl","definitions","resolver","map","definition","input","AiSdkTools","AiSdkToolsAbstraction","AiSdkToolDefinition","AiSdkToolHandlerResolver"],"mappings":";AAOA,MAAMA;IACF,YACYC,WAA4C,EAC5CC,QAA4C,CACtD;aAFUD,WAAW,GAAXA;aACAC,QAAQ,GAARA;IACT;IAEH,aAAsB;QAClB,MAAMC,MAAe,CAAC;QACtB,KAAK,MAAMC,cAAc,IAAI,CAAC,WAAW,CACrCD,GAAG,CAACC,WAAW,IAAI,CAAC,GAAG;YACnB,aAAaA,WAAW,WAAW;YACnC,aAAaA,WAAW,WAAW;YAUnC,SAAS,CAACC,QACN,IAAI,CAAC,QAAQ,CAAC,OAAO,CAACD,WAAW,OAAO,EAAE,OAAO,CAACC;QAC1D;QAEJ,OAAOF;IACX;AACJ;AAEO,MAAMG,wBAAaC,WAAAA,oBAA0C,CAAC;IACjE,gBAAgBP;IAChB,cAAc;QAAC;YAACQ;YAAqB;gBAAE,UAAU;YAAK;SAAE;QAAEC;KAAyB;AACvF"}
|