@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
|
@@ -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\
|
|
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-6-astra\", name: \"GPT-6 Astra\" },\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.5-pro\", name: \"GPT-5.5 Pro\" },\n { id: \"gpt-5.4\", name: \"GPT-5.4\" },\n { id: \"gpt-5.4-pro\", name: \"GPT-5.4 Pro\" },\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.2\", name: \"GPT-5.2\" },\n { id: \"gpt-5.2-pro\", name: \"GPT-5.2 Pro\" },\n { id: \"gpt-5\", name: \"GPT-5\" },\n { id: \"gpt-5-pro\", name: \"GPT-5 Pro\" },\n { id: \"gpt-5-mini\", name: \"GPT-5 Mini\" },\n { id: \"gpt-5-nano\", name: \"GPT-5 Nano\" },\n { id: \"gpt-4.1\", name: \"GPT-4.1\" },\n { id: \"gpt-4.1-mini\", name: \"GPT-4.1 Mini\" },\n { id: \"gpt-4o\", name: \"GPT-4o\" },\n { id: \"gpt-4o-mini\", name: \"GPT-4o Mini\" },\n {\n id: \"o3-pro\",\n name: \"o3 Pro\",\n deprecated: new Date(\"2026-06-11\"),\n endOfLife: new Date(\"2026-12-11\")\n },\n {\n id: \"o3\",\n name: \"o3\",\n deprecated: new Date(\"2026-06-11\"),\n endOfLife: new Date(\"2026-12-11\")\n },\n {\n id: \"gpt-4.1-nano\",\n name: \"GPT-4.1 Nano\",\n deprecated: new Date(\"2026-04-22\"),\n endOfLife: new Date(\"2026-10-23\")\n },\n {\n id: \"o4-mini\",\n name: \"o4 Mini\",\n deprecated: new Date(\"2026-04-22\"),\n endOfLife: new Date(\"2026-10-23\")\n }\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","Date","OpenAiSdkFactoryImpl","apiKey","createOpenAI","provider","process","modelId","OpenAiSdkFactory","createImplementation","AiSdkFactoryAbstraction"],"mappings":";;AAIA,MAAMA,gBAA+B;IACjC;QAAE,IAAI;QAAe,MAAM;IAAc;IACzC;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;QAAe,MAAM;IAAc;IACzC;QAAE,IAAI;QAAW,MAAM;IAAU;IACjC;QAAE,IAAI;QAAe,MAAM;IAAc;IACzC;QAAE,IAAI;QAAgB,MAAM;IAAe;IAC3C;QAAE,IAAI;QAAgB,MAAM;IAAe;IAC3C;QAAE,IAAI;QAAW,MAAM;IAAU;IACjC;QAAE,IAAI;QAAe,MAAM;IAAc;IACzC;QAAE,IAAI;QAAS,MAAM;IAAQ;IAC7B;QAAE,IAAI;QAAa,MAAM;IAAY;IACrC;QAAE,IAAI;QAAc,MAAM;IAAa;IACvC;QAAE,IAAI;QAAc,MAAM;IAAa;IACvC;QAAE,IAAI;QAAW,MAAM;IAAU;IACjC;QAAE,IAAI;QAAgB,MAAM;IAAe;IAC3C;QAAE,IAAI;QAAU,MAAM;IAAS;IAC/B;QAAE,IAAI;QAAe,MAAM;IAAc;IACzC;QACI,IAAI;QACJ,MAAM;QACN,YAAY,IAAIC,KAAK;QACrB,WAAW,IAAIA,KAAK;IACxB;IACA;QACI,IAAI;QACJ,MAAM;QACN,YAAY,IAAIA,KAAK;QACrB,WAAW,IAAIA,KAAK;IACxB;IACA;QACI,IAAI;QACJ,MAAM;QACN,YAAY,IAAIA,KAAK;QACrB,WAAW,IAAIA,KAAK;IACxB;IACA;QACI,IAAI;QACJ,MAAM;QACN,YAAY,IAAIA,KAAK;QACrB,WAAW,IAAIA,KAAK;IACxB;CACH;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,GAAGP;;AAWtB;AAEO,MAAMQ,mBAAmBC,qBAAqB;IACjD,aAAaC;IACb,gBAAgBR;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AiSdkFactory as AiSdkFactoryAbstraction } from "./abstractions.js";
|
|
2
|
+
import type { IAiSdk, IAiSdkModel } from "./abstractions.js";
|
|
3
|
+
declare class OpenRouterSdkFactoryImpl implements AiSdkFactoryAbstraction.Interface {
|
|
4
|
+
readonly id = "openrouter";
|
|
5
|
+
readonly name = "OpenRouter";
|
|
6
|
+
readonly models: IAiSdkModel[];
|
|
7
|
+
execute(apiKey?: string): Promise<IAiSdk>;
|
|
8
|
+
}
|
|
9
|
+
export declare const OpenRouterSdkFactory: import("@webiny/di").Implementation<typeof OpenRouterSdkFactoryImpl>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { createImplementation } from "@webiny/feature/api";
|
|
2
|
+
import { AiSdkFactory } from "./abstractions.js";
|
|
3
|
+
const OPENROUTER_MODELS = [
|
|
4
|
+
{
|
|
5
|
+
id: "openrouter/auto",
|
|
6
|
+
name: "OpenRouter: Auto Router"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
id: "mistralai/mistral-large-4-0",
|
|
10
|
+
name: "Mistral: Mistral Large 4"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
id: "openai/gpt-6.1-sol",
|
|
14
|
+
name: "OpenAI: GPT-6.1 Sol"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
id: "anthropic/claude-sonnet-5.5",
|
|
18
|
+
name: "Anthropic: Claude Sonnet 5.5"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: "qwen/qwen3.8-max-prime",
|
|
22
|
+
name: "Qwen: Qwen3.8 Max Prime"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: "z-ai/glm-5.3-prime",
|
|
26
|
+
name: "Z.ai: GLM 5.3 Prime"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: "openai/gpt-6-sol",
|
|
30
|
+
name: "OpenAI: GPT-6 Sol"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: "openai/gpt-6-luna",
|
|
34
|
+
name: "OpenAI: GPT-6 Luna"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: "anthropic/claude-opus-5.5",
|
|
38
|
+
name: "Anthropic: Claude Opus 5.5"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: "x-ai/grok-4.7",
|
|
42
|
+
name: "SpaceXAI: Grok 4.7"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: "deepseek/deepseek-v4.1-flash",
|
|
46
|
+
name: "DeepSeek: DeepSeek V4.1 Flash"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: "openai/gpt-6-astra",
|
|
50
|
+
name: "OpenAI: GPT-6 Astra"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: "google/gemini-3.8-flash",
|
|
54
|
+
name: "Google: Gemini 3.8 Flash"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: "anthropic/claude-fable-5.1",
|
|
58
|
+
name: "Anthropic: Claude Fable 5.1"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: "anthropic/claude-opus-5",
|
|
62
|
+
name: "Anthropic: Claude Opus 5"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: "google/gemini-3.5-flash-lite",
|
|
66
|
+
name: "Google: Gemini 3.5 Flash Lite"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: "moonshotai/kimi-k3",
|
|
70
|
+
name: "MoonshotAI: Kimi K3"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
id: "openai/gpt-5.6-terra",
|
|
74
|
+
name: "OpenAI: GPT-5.6 Terra"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
id: "anthropic/claude-sonnet-5",
|
|
78
|
+
name: "Anthropic: Claude Sonnet 5"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: "openai/gpt-5.4-mini",
|
|
82
|
+
name: "OpenAI: GPT-5.4 Mini"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: "anthropic/claude-haiku-4.5",
|
|
86
|
+
name: "Anthropic: Claude Haiku 4.5"
|
|
87
|
+
}
|
|
88
|
+
];
|
|
89
|
+
class OpenRouterSdkFactoryImpl {
|
|
90
|
+
async execute(apiKey) {
|
|
91
|
+
const { createOpenRouter } = await import("@openrouter/ai-sdk-provider");
|
|
92
|
+
const provider = createOpenRouter({
|
|
93
|
+
apiKey: apiKey ?? process.env.WEBINY_API_OPENROUTER_API_KEY
|
|
94
|
+
});
|
|
95
|
+
return {
|
|
96
|
+
languageModel: (modelId)=>provider.chat(modelId)
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
constructor(){
|
|
100
|
+
this.id = "openrouter";
|
|
101
|
+
this.name = "OpenRouter";
|
|
102
|
+
this.models = OPENROUTER_MODELS;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const OpenRouterSdkFactory = createImplementation({
|
|
106
|
+
abstraction: AiSdkFactory,
|
|
107
|
+
implementation: OpenRouterSdkFactoryImpl,
|
|
108
|
+
dependencies: []
|
|
109
|
+
});
|
|
110
|
+
export { OpenRouterSdkFactory };
|
|
111
|
+
|
|
112
|
+
//# sourceMappingURL=OpenRouterSdkFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/ai/OpenRouterSdkFactory.js","sources":["../../../src/features/ai/OpenRouterSdkFactory.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { AiSdkFactory as AiSdkFactoryAbstraction } from \"./abstractions.js\";\nimport type { IAiSdk, IAiSdkModel } from \"./abstractions.js\";\n\n/*\n * OpenRouter model ids carry their own vendor prefix, so the composite Webiny id has two slashes:\n * \"openrouter/anthropic/claude-sonnet-5.5\". `Ai` splits on the first slash only, which leaves the\n * OpenRouter id intact.\n */\nconst OPENROUTER_MODELS: IAiSdkModel[] = [\n // OpenRouter picks the model per request, so which vendor answers can change between calls.\n { id: \"openrouter/auto\", name: \"OpenRouter: Auto Router\" },\n { id: \"mistralai/mistral-large-4-0\", name: \"Mistral: Mistral Large 4\" },\n { id: \"openai/gpt-6.1-sol\", name: \"OpenAI: GPT-6.1 Sol\" },\n { id: \"anthropic/claude-sonnet-5.5\", name: \"Anthropic: Claude Sonnet 5.5\" },\n { id: \"qwen/qwen3.8-max-prime\", name: \"Qwen: Qwen3.8 Max Prime\" },\n { id: \"z-ai/glm-5.3-prime\", name: \"Z.ai: GLM 5.3 Prime\" },\n { id: \"openai/gpt-6-sol\", name: \"OpenAI: GPT-6 Sol\" },\n { id: \"openai/gpt-6-luna\", name: \"OpenAI: GPT-6 Luna\" },\n { id: \"anthropic/claude-opus-5.5\", name: \"Anthropic: Claude Opus 5.5\" },\n { id: \"x-ai/grok-4.7\", name: \"SpaceXAI: Grok 4.7\" },\n { id: \"deepseek/deepseek-v4.1-flash\", name: \"DeepSeek: DeepSeek V4.1 Flash\" },\n { id: \"openai/gpt-6-astra\", name: \"OpenAI: GPT-6 Astra\" },\n { id: \"google/gemini-3.8-flash\", name: \"Google: Gemini 3.8 Flash\" },\n { id: \"anthropic/claude-fable-5.1\", name: \"Anthropic: Claude Fable 5.1\" },\n { id: \"anthropic/claude-opus-5\", name: \"Anthropic: Claude Opus 5\" },\n { id: \"google/gemini-3.5-flash-lite\", name: \"Google: Gemini 3.5 Flash Lite\" },\n { id: \"moonshotai/kimi-k3\", name: \"MoonshotAI: Kimi K3\" },\n { id: \"openai/gpt-5.6-terra\", name: \"OpenAI: GPT-5.6 Terra\" },\n { id: \"anthropic/claude-sonnet-5\", name: \"Anthropic: Claude Sonnet 5\" },\n { id: \"openai/gpt-5.4-mini\", name: \"OpenAI: GPT-5.4 Mini\" },\n { id: \"anthropic/claude-haiku-4.5\", name: \"Anthropic: Claude Haiku 4.5\" }\n];\n\nclass OpenRouterSdkFactoryImpl implements AiSdkFactoryAbstraction.Interface {\n readonly id = \"openrouter\";\n readonly name = \"OpenRouter\";\n readonly models = OPENROUTER_MODELS;\n\n async execute(apiKey?: string): Promise<IAiSdk> {\n const { createOpenRouter } = await import(\"@openrouter/ai-sdk-provider\");\n const provider = createOpenRouter({\n apiKey: apiKey ?? process.env.WEBINY_API_OPENROUTER_API_KEY\n });\n return {\n languageModel: modelId => provider.chat(modelId)\n };\n }\n}\n\nexport const OpenRouterSdkFactory = createImplementation({\n abstraction: AiSdkFactoryAbstraction,\n implementation: OpenRouterSdkFactoryImpl,\n dependencies: []\n});\n"],"names":["OPENROUTER_MODELS","OpenRouterSdkFactoryImpl","apiKey","createOpenRouter","provider","process","modelId","OpenRouterSdkFactory","createImplementation","AiSdkFactoryAbstraction"],"mappings":";;AASA,MAAMA,oBAAmC;IAErC;QAAE,IAAI;QAAmB,MAAM;IAA0B;IACzD;QAAE,IAAI;QAA+B,MAAM;IAA2B;IACtE;QAAE,IAAI;QAAsB,MAAM;IAAsB;IACxD;QAAE,IAAI;QAA+B,MAAM;IAA+B;IAC1E;QAAE,IAAI;QAA0B,MAAM;IAA0B;IAChE;QAAE,IAAI;QAAsB,MAAM;IAAsB;IACxD;QAAE,IAAI;QAAoB,MAAM;IAAoB;IACpD;QAAE,IAAI;QAAqB,MAAM;IAAqB;IACtD;QAAE,IAAI;QAA6B,MAAM;IAA6B;IACtE;QAAE,IAAI;QAAiB,MAAM;IAAqB;IAClD;QAAE,IAAI;QAAgC,MAAM;IAAgC;IAC5E;QAAE,IAAI;QAAsB,MAAM;IAAsB;IACxD;QAAE,IAAI;QAA2B,MAAM;IAA2B;IAClE;QAAE,IAAI;QAA8B,MAAM;IAA8B;IACxE;QAAE,IAAI;QAA2B,MAAM;IAA2B;IAClE;QAAE,IAAI;QAAgC,MAAM;IAAgC;IAC5E;QAAE,IAAI;QAAsB,MAAM;IAAsB;IACxD;QAAE,IAAI;QAAwB,MAAM;IAAwB;IAC5D;QAAE,IAAI;QAA6B,MAAM;IAA6B;IACtE;QAAE,IAAI;QAAuB,MAAM;IAAuB;IAC1D;QAAE,IAAI;QAA8B,MAAM;IAA8B;CAC3E;AAED,MAAMC;IAKF,MAAM,QAAQC,MAAe,EAAmB;QAC5C,MAAM,EAAEC,gBAAgB,EAAE,GAAG,MAAM,MAAM,CAAC;QAC1C,MAAMC,WAAWD,iBAAiB;YAC9B,QAAQD,UAAUG,QAAQ,GAAG,CAAC,6BAA6B;QAC/D;QACA,OAAO;YACH,eAAeC,CAAAA,UAAWF,SAAS,IAAI,CAACE;QAC5C;IACJ;;aAZS,EAAE,GAAG;aACL,IAAI,GAAG;aACP,MAAM,GAAGN;;AAWtB;AAEO,MAAMO,uBAAuBC,qBAAqB;IACrD,aAAaC;IACb,gBAAgBR;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AiModelCatalog as AiModelCatalogAbstraction } from "./abstractions.js";
|
|
2
|
+
import type { AiCatalogProvider } from "./abstractions.js";
|
|
3
|
+
import { Logger } from "../../features/logger/index.js";
|
|
4
|
+
import { HttpClient } from "../../features/httpClient/index.js";
|
|
5
|
+
declare class RemoteAiModelCatalogImpl implements AiModelCatalogAbstraction.Interface {
|
|
6
|
+
private readonly httpClient;
|
|
7
|
+
private readonly logger;
|
|
8
|
+
constructor(httpClient: HttpClient.Interface, logger: Logger.Interface);
|
|
9
|
+
listProviders(): Promise<AiCatalogProvider[] | undefined>;
|
|
10
|
+
private fetchProviders;
|
|
11
|
+
}
|
|
12
|
+
export declare const RemoteAiModelCatalog: import("@webiny/di").Implementation<typeof RemoteAiModelCatalogImpl>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createImplementation } from "@webiny/feature/api";
|
|
3
|
+
import { getWcpApiUrl } from "@webiny/wcp";
|
|
4
|
+
import { AiModelCatalog } from "./abstractions.js";
|
|
5
|
+
import { Logger } from "../logger/index.js";
|
|
6
|
+
import { HttpClient } from "../httpClient/index.js";
|
|
7
|
+
const FETCH_TIMEOUT_MS = 3000;
|
|
8
|
+
const SUCCESS_TTL_MS = 3600000;
|
|
9
|
+
const FAILURE_TTL_MS = 60000;
|
|
10
|
+
const optionalDate = z.coerce.date().optional();
|
|
11
|
+
const catalogSchema = z.object({
|
|
12
|
+
providers: z.array(z.object({
|
|
13
|
+
id: z.string(),
|
|
14
|
+
name: z.string(),
|
|
15
|
+
models: z.array(z.object({
|
|
16
|
+
id: z.string(),
|
|
17
|
+
name: z.string(),
|
|
18
|
+
deprecated: optionalDate,
|
|
19
|
+
endOfLife: optionalDate,
|
|
20
|
+
supports: z.object({
|
|
21
|
+
tools: z.boolean().optional(),
|
|
22
|
+
vision: z.boolean().optional(),
|
|
23
|
+
temperature: z.boolean().optional()
|
|
24
|
+
}).optional()
|
|
25
|
+
}))
|
|
26
|
+
}))
|
|
27
|
+
});
|
|
28
|
+
let cached;
|
|
29
|
+
class RemoteAiModelCatalogImpl {
|
|
30
|
+
constructor(httpClient, logger){
|
|
31
|
+
this.httpClient = httpClient;
|
|
32
|
+
this.logger = logger;
|
|
33
|
+
}
|
|
34
|
+
listProviders() {
|
|
35
|
+
if (cached && cached.expiresAt > Date.now()) return cached.providers;
|
|
36
|
+
const entry = {
|
|
37
|
+
expiresAt: Date.now() + SUCCESS_TTL_MS,
|
|
38
|
+
providers: this.fetchProviders().then((providers)=>{
|
|
39
|
+
if (!providers) entry.expiresAt = Date.now() + FAILURE_TTL_MS;
|
|
40
|
+
return providers;
|
|
41
|
+
})
|
|
42
|
+
};
|
|
43
|
+
cached = entry;
|
|
44
|
+
return entry.providers;
|
|
45
|
+
}
|
|
46
|
+
async fetchProviders() {
|
|
47
|
+
const url = getWcpApiUrl("/ai/models");
|
|
48
|
+
const response = await this.httpClient.requestJson({
|
|
49
|
+
url,
|
|
50
|
+
timeoutMs: FETCH_TIMEOUT_MS
|
|
51
|
+
});
|
|
52
|
+
if (response.isFail()) return void this.logger.warn({
|
|
53
|
+
url,
|
|
54
|
+
error: response.error
|
|
55
|
+
}, "Failed to load AI models.");
|
|
56
|
+
const result = catalogSchema.safeParse(response.value);
|
|
57
|
+
if (!result.success) return void this.logger.warn({
|
|
58
|
+
url,
|
|
59
|
+
error: result.error
|
|
60
|
+
}, "Received invalid AI models.");
|
|
61
|
+
return result.data.providers;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const RemoteAiModelCatalog = createImplementation({
|
|
65
|
+
abstraction: AiModelCatalog,
|
|
66
|
+
implementation: RemoteAiModelCatalogImpl,
|
|
67
|
+
dependencies: [
|
|
68
|
+
HttpClient,
|
|
69
|
+
Logger
|
|
70
|
+
]
|
|
71
|
+
});
|
|
72
|
+
export { RemoteAiModelCatalog };
|
|
73
|
+
|
|
74
|
+
//# sourceMappingURL=RemoteAiModelCatalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/ai/RemoteAiModelCatalog.js","sources":["../../../src/features/ai/RemoteAiModelCatalog.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { getWcpApiUrl } from \"@webiny/wcp\";\nimport { AiModelCatalog as AiModelCatalogAbstraction } from \"./abstractions.js\";\nimport type { AiCatalogProvider } from \"./abstractions.js\";\nimport { Logger } from \"~/features/logger/index.js\";\nimport { HttpClient } from \"~/features/httpClient/index.js\";\n\nconst FETCH_TIMEOUT_MS = 3000;\nconst SUCCESS_TTL_MS = 60 * 60 * 1000;\nconst FAILURE_TTL_MS = 60 * 1000;\n\nconst optionalDate = z.coerce.date().optional();\n\nconst catalogSchema = z.object({\n providers: z.array(\n z.object({\n id: z.string(),\n name: z.string(),\n models: z.array(\n z.object({\n id: z.string(),\n name: z.string(),\n deprecated: optionalDate,\n endOfLife: optionalDate,\n // Capabilities the catalog adds later are dropped here, not rejected.\n supports: z\n .object({\n tools: z.boolean().optional(),\n vision: z.boolean().optional(),\n temperature: z.boolean().optional()\n })\n .optional()\n })\n )\n })\n )\n});\n\ninterface CachedCatalog {\n expiresAt: number;\n providers: Promise<AiCatalogProvider[] | undefined>;\n}\n\n/*\n * Process-wide on purpose: the catalog is the same for every tenant and request, and\n * `Ai.resolveLanguageModel()` reads it on every call, so a warm Lambda should fetch it once.\n */\nlet cached: CachedCatalog | undefined;\n\nclass RemoteAiModelCatalogImpl implements AiModelCatalogAbstraction.Interface {\n constructor(\n private readonly httpClient: HttpClient.Interface,\n private readonly logger: Logger.Interface\n ) {}\n\n listProviders(): Promise<AiCatalogProvider[] | undefined> {\n if (cached && cached.expiresAt > Date.now()) {\n return cached.providers;\n }\n\n const entry: CachedCatalog = {\n expiresAt: Date.now() + SUCCESS_TTL_MS,\n providers: this.fetchProviders().then(providers => {\n if (!providers) {\n entry.expiresAt = Date.now() + FAILURE_TTL_MS;\n }\n return providers;\n })\n };\n cached = entry;\n\n return entry.providers;\n }\n\n private async fetchProviders(): Promise<AiCatalogProvider[] | undefined> {\n const url = getWcpApiUrl(\"/ai/models\");\n\n const response = await this.httpClient.requestJson({ url, timeoutMs: FETCH_TIMEOUT_MS });\n if (response.isFail()) {\n this.logger.warn({ url, error: response.error }, \"Failed to load AI models.\");\n return undefined;\n }\n\n const result = catalogSchema.safeParse(response.value);\n if (!result.success) {\n this.logger.warn({ url, error: result.error }, \"Received invalid AI models.\");\n return undefined;\n }\n\n return result.data.providers;\n }\n}\n\nexport const RemoteAiModelCatalog = createImplementation({\n abstraction: AiModelCatalogAbstraction,\n implementation: RemoteAiModelCatalogImpl,\n dependencies: [HttpClient, Logger]\n});\n"],"names":["FETCH_TIMEOUT_MS","SUCCESS_TTL_MS","FAILURE_TTL_MS","optionalDate","z","catalogSchema","cached","RemoteAiModelCatalogImpl","httpClient","logger","Date","entry","providers","url","getWcpApiUrl","response","result","RemoteAiModelCatalog","createImplementation","AiModelCatalogAbstraction","HttpClient","Logger"],"mappings":";;;;;;AAQA,MAAMA,mBAAmB;AACzB,MAAMC,iBAAiB;AACvB,MAAMC,iBAAiB;AAEvB,MAAMC,eAAeC,EAAE,MAAM,CAAC,IAAI,GAAG,QAAQ;AAE7C,MAAMC,gBAAgBD,EAAE,MAAM,CAAC;IAC3B,WAAWA,EAAE,KAAK,CACdA,EAAE,MAAM,CAAC;QACL,IAAIA,EAAE,MAAM;QACZ,MAAMA,EAAE,MAAM;QACd,QAAQA,EAAE,KAAK,CACXA,EAAE,MAAM,CAAC;YACL,IAAIA,EAAE,MAAM;YACZ,MAAMA,EAAE,MAAM;YACd,YAAYD;YACZ,WAAWA;YAEX,UAAUC,EAAAA,MACC,CAAC;gBACJ,OAAOA,EAAE,OAAO,GAAG,QAAQ;gBAC3B,QAAQA,EAAE,OAAO,GAAG,QAAQ;gBAC5B,aAAaA,EAAE,OAAO,GAAG,QAAQ;YACrC,GACC,QAAQ;QACjB;IAER;AAER;AAWA,IAAIE;AAEJ,MAAMC;IACF,YACqBC,UAAgC,EAChCC,MAAwB,CAC3C;aAFmBD,UAAU,GAAVA;aACAC,MAAM,GAANA;IAClB;IAEH,gBAA0D;QACtD,IAAIH,UAAUA,OAAO,SAAS,GAAGI,KAAK,GAAG,IACrC,OAAOJ,OAAO,SAAS;QAG3B,MAAMK,QAAuB;YACzB,WAAWD,KAAK,GAAG,KAAKT;YACxB,WAAW,IAAI,CAAC,cAAc,GAAG,IAAI,CAACW,CAAAA;gBAClC,IAAI,CAACA,WACDD,MAAM,SAAS,GAAGD,KAAK,GAAG,KAAKR;gBAEnC,OAAOU;YACX;QACJ;QACAN,SAASK;QAET,OAAOA,MAAM,SAAS;IAC1B;IAEA,MAAc,iBAA2D;QACrE,MAAME,MAAMC,aAAa;QAEzB,MAAMC,WAAW,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC;YAAEF;YAAK,WAAWb;QAAiB;QACtF,IAAIe,SAAS,MAAM,IAAI,YACnB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;YAAEF;YAAK,OAAOE,SAAS,KAAK;QAAC,GAAG;QAIrD,MAAMC,SAASX,cAAc,SAAS,CAACU,SAAS,KAAK;QACrD,IAAI,CAACC,OAAO,OAAO,EAAE,YACjB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;YAAEH;YAAK,OAAOG,OAAO,KAAK;QAAC,GAAG;QAInD,OAAOA,OAAO,IAAI,CAAC,SAAS;IAChC;AACJ;AAEO,MAAMC,uBAAuBC,qBAAqB;IACrD,aAAaC;IACb,gBAAgBZ;IAChB,cAAc;QAACa;QAAYC;KAAO;AACtC"}
|
|
@@ -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 @@
|
|
|
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 @@
|
|
|
1
|
+
export declare function extractDocxText(buffer: Buffer): Promise<string>;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { inflateRawSync } from "node:zlib";
|
|
2
|
+
async function extractDocxText(buffer) {
|
|
3
|
+
const xml = extractFileFromZip(buffer, "word/document.xml");
|
|
4
|
+
if (!xml) throw new Error("Invalid DOCX: word/document.xml not found.");
|
|
5
|
+
const stylesXml = extractFileFromZip(buffer, "word/styles.xml");
|
|
6
|
+
const styleMap = stylesXml ? buildStyleMap(stylesXml) : new Map();
|
|
7
|
+
return convertToMarkdown(xml, styleMap);
|
|
8
|
+
}
|
|
9
|
+
function buildStyleMap(stylesXml) {
|
|
10
|
+
const map = new Map();
|
|
11
|
+
const styleRegex = /<w:style\s[^>]*w:styleId="([^"]*)"[^>]*>[\s\S]*?<\/w:style>/g;
|
|
12
|
+
let match;
|
|
13
|
+
while(null !== (match = styleRegex.exec(stylesXml))){
|
|
14
|
+
const styleId = match[1];
|
|
15
|
+
const block = match[0];
|
|
16
|
+
const nameMatch = block.match(/<w:name\s+w:val="([^"]*)"/);
|
|
17
|
+
if (nameMatch) map.set(styleId, nameMatch[1]);
|
|
18
|
+
}
|
|
19
|
+
return map;
|
|
20
|
+
}
|
|
21
|
+
function getHeadingLevel(paragraphXml, styleMap) {
|
|
22
|
+
const styleMatch = paragraphXml.match(/<w:pStyle\s+w:val="([^"]*)"/);
|
|
23
|
+
if (!styleMatch) return 0;
|
|
24
|
+
const styleId = styleMatch[1];
|
|
25
|
+
const directMatch = styleId.match(/^[Hh]eading(\d)$/);
|
|
26
|
+
if (directMatch) return parseInt(directMatch[1], 10);
|
|
27
|
+
const styleName = styleMap.get(styleId) ?? "";
|
|
28
|
+
const nameMatch = styleName.match(/^[Hh]eading\s*(\d)$/);
|
|
29
|
+
if (nameMatch) return parseInt(nameMatch[1], 10);
|
|
30
|
+
if (/title/i.test(styleName) || /title/i.test(styleId)) return 1;
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
33
|
+
function isListItem(paragraphXml) {
|
|
34
|
+
return /<w:numId\s/.test(paragraphXml);
|
|
35
|
+
}
|
|
36
|
+
function extractRunMarkdown(runXml) {
|
|
37
|
+
const textRegex = /<w:t(?:\s[^>]*)?>([^<]*)<\/w:t>/g;
|
|
38
|
+
const texts = [];
|
|
39
|
+
let match;
|
|
40
|
+
while(null !== (match = textRegex.exec(runXml)))texts.push(match[1]);
|
|
41
|
+
if (0 === texts.length) return "";
|
|
42
|
+
const text = texts.join("");
|
|
43
|
+
const isBold = /<w:b[\s/>]/.test(runXml) && !/<w:b\s+w:val="(false|0)"/.test(runXml);
|
|
44
|
+
const isItalic = /<w:i[\s/>]/.test(runXml) && !/<w:i\s+w:val="(false|0)"/.test(runXml);
|
|
45
|
+
if (isBold && isItalic) return `***${text}***`;
|
|
46
|
+
if (isBold) return `**${text}**`;
|
|
47
|
+
if (isItalic) return `*${text}*`;
|
|
48
|
+
return text;
|
|
49
|
+
}
|
|
50
|
+
function convertToMarkdown(xml, styleMap) {
|
|
51
|
+
const paragraphs = [];
|
|
52
|
+
const paragraphRegex = /<w:p[\s>][\s\S]*?<\/w:p>/g;
|
|
53
|
+
let paragraphMatch;
|
|
54
|
+
while(null !== (paragraphMatch = paragraphRegex.exec(xml))){
|
|
55
|
+
const paragraphXml = paragraphMatch[0];
|
|
56
|
+
const runRegex = /<w:r[\s>][\s\S]*?<\/w:r>/g;
|
|
57
|
+
const runs = [];
|
|
58
|
+
let runMatch;
|
|
59
|
+
while(null !== (runMatch = runRegex.exec(paragraphXml))){
|
|
60
|
+
const md = extractRunMarkdown(runMatch[0]);
|
|
61
|
+
if (md) runs.push(md);
|
|
62
|
+
}
|
|
63
|
+
if (0 === runs.length) continue;
|
|
64
|
+
let line = runs.join("");
|
|
65
|
+
const headingLevel = getHeadingLevel(paragraphXml, styleMap);
|
|
66
|
+
if (headingLevel > 0 && headingLevel <= 6) line = `${"#".repeat(headingLevel)} ${line}`;
|
|
67
|
+
else if (isListItem(paragraphXml)) line = `- ${line}`;
|
|
68
|
+
paragraphs.push(line);
|
|
69
|
+
}
|
|
70
|
+
return paragraphs.join("\n\n");
|
|
71
|
+
}
|
|
72
|
+
function extractFileFromZip(buffer, targetPath) {
|
|
73
|
+
const eocdOffset = findEocd(buffer);
|
|
74
|
+
if (-1 === eocdOffset) throw new Error("Invalid ZIP: End of Central Directory not found.");
|
|
75
|
+
const cdOffset = buffer.readUInt32LE(eocdOffset + 16);
|
|
76
|
+
const cdSize = buffer.readUInt32LE(eocdOffset + 12);
|
|
77
|
+
const cdEnd = cdOffset + cdSize;
|
|
78
|
+
let offset = cdOffset;
|
|
79
|
+
while(offset < cdEnd){
|
|
80
|
+
const sig = buffer.readUInt32LE(offset);
|
|
81
|
+
if (0x02014b50 !== sig) break;
|
|
82
|
+
const compressionMethod = buffer.readUInt16LE(offset + 10);
|
|
83
|
+
const compressedSize = buffer.readUInt32LE(offset + 20);
|
|
84
|
+
const fileNameLen = buffer.readUInt16LE(offset + 28);
|
|
85
|
+
const extraLen = buffer.readUInt16LE(offset + 30);
|
|
86
|
+
const commentLen = buffer.readUInt16LE(offset + 32);
|
|
87
|
+
const localHeaderOffset = buffer.readUInt32LE(offset + 42);
|
|
88
|
+
const fileName = buffer.toString("utf-8", offset + 46, offset + 46 + fileNameLen);
|
|
89
|
+
if (fileName === targetPath) return readLocalFile(buffer, localHeaderOffset, compressionMethod, compressedSize);
|
|
90
|
+
offset += 46 + fileNameLen + extraLen + commentLen;
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
function readLocalFile(buffer, offset, compressionMethod, compressedSize) {
|
|
95
|
+
const sig = buffer.readUInt32LE(offset);
|
|
96
|
+
if (0x04034b50 !== sig) throw new Error("Invalid ZIP: bad local file header.");
|
|
97
|
+
const localFileNameLen = buffer.readUInt16LE(offset + 26);
|
|
98
|
+
const localExtraLen = buffer.readUInt16LE(offset + 28);
|
|
99
|
+
const dataOffset = offset + 30 + localFileNameLen + localExtraLen;
|
|
100
|
+
const raw = buffer.subarray(dataOffset, dataOffset + compressedSize);
|
|
101
|
+
if (0 === compressionMethod) return raw.toString("utf-8");
|
|
102
|
+
if (8 === compressionMethod) return inflateRawSync(raw).toString("utf-8");
|
|
103
|
+
throw new Error(`Unsupported ZIP compression method: ${compressionMethod}`);
|
|
104
|
+
}
|
|
105
|
+
function findEocd(buffer) {
|
|
106
|
+
for(let i = buffer.length - 22; i >= Math.max(0, buffer.length - 65557); i--)if (0x06054b50 === buffer.readUInt32LE(i)) return i;
|
|
107
|
+
return -1;
|
|
108
|
+
}
|
|
109
|
+
export { extractDocxText };
|
|
110
|
+
|
|
111
|
+
//# sourceMappingURL=docxParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/ai/TextExtractor/parsers/docxParser.js","sources":["../../../../../src/features/ai/TextExtractor/parsers/docxParser.ts"],"sourcesContent":["import { inflateRawSync } from \"node:zlib\";\n\nexport async function extractDocxText(buffer: Buffer): Promise<string> {\n const xml = extractFileFromZip(buffer, \"word/document.xml\");\n if (!xml) {\n throw new Error(\"Invalid DOCX: word/document.xml not found.\");\n }\n\n const stylesXml = extractFileFromZip(buffer, \"word/styles.xml\");\n const styleMap = stylesXml ? buildStyleMap(stylesXml) : new Map<string, string>();\n\n return convertToMarkdown(xml, styleMap);\n}\n\nfunction buildStyleMap(stylesXml: string): Map<string, string> {\n const map = new Map<string, string>();\n const styleRegex = /<w:style\\s[^>]*w:styleId=\"([^\"]*)\"[^>]*>[\\s\\S]*?<\\/w:style>/g;\n let match: RegExpExecArray | null;\n\n while ((match = styleRegex.exec(stylesXml)) !== null) {\n const styleId = match[1];\n const block = match[0];\n const nameMatch = block.match(/<w:name\\s+w:val=\"([^\"]*)\"/);\n if (nameMatch) {\n map.set(styleId, nameMatch[1]);\n }\n }\n\n return map;\n}\n\nfunction getHeadingLevel(paragraphXml: string, styleMap: Map<string, string>): number {\n const styleMatch = paragraphXml.match(/<w:pStyle\\s+w:val=\"([^\"]*)\"/);\n if (!styleMatch) {\n return 0;\n }\n\n const styleId = styleMatch[1];\n\n const directMatch = styleId.match(/^[Hh]eading(\\d)$/);\n if (directMatch) {\n return parseInt(directMatch[1], 10);\n }\n\n const styleName = styleMap.get(styleId) ?? \"\";\n const nameMatch = styleName.match(/^[Hh]eading\\s*(\\d)$/);\n if (nameMatch) {\n return parseInt(nameMatch[1], 10);\n }\n\n if (/title/i.test(styleName) || /title/i.test(styleId)) {\n return 1;\n }\n\n return 0;\n}\n\nfunction isListItem(paragraphXml: string): boolean {\n return /<w:numId\\s/.test(paragraphXml);\n}\n\nfunction extractRunMarkdown(runXml: string): string {\n const textRegex = /<w:t(?:\\s[^>]*)?>([^<]*)<\\/w:t>/g;\n const texts: string[] = [];\n let match: RegExpExecArray | null;\n while ((match = textRegex.exec(runXml)) !== null) {\n texts.push(match[1]);\n }\n if (texts.length === 0) {\n return \"\";\n }\n\n const text = texts.join(\"\");\n const isBold = /<w:b[\\s/>]/.test(runXml) && !/<w:b\\s+w:val=\"(false|0)\"/.test(runXml);\n const isItalic = /<w:i[\\s/>]/.test(runXml) && !/<w:i\\s+w:val=\"(false|0)\"/.test(runXml);\n\n if (isBold && isItalic) {\n return `***${text}***`;\n }\n if (isBold) {\n return `**${text}**`;\n }\n if (isItalic) {\n return `*${text}*`;\n }\n return text;\n}\n\nfunction convertToMarkdown(xml: string, styleMap: Map<string, string>): string {\n const paragraphs: string[] = [];\n const paragraphRegex = /<w:p[\\s>][\\s\\S]*?<\\/w:p>/g;\n let paragraphMatch: RegExpExecArray | null;\n\n while ((paragraphMatch = paragraphRegex.exec(xml)) !== null) {\n const paragraphXml = paragraphMatch[0];\n\n const runRegex = /<w:r[\\s>][\\s\\S]*?<\\/w:r>/g;\n const runs: string[] = [];\n let runMatch: RegExpExecArray | null;\n while ((runMatch = runRegex.exec(paragraphXml)) !== null) {\n const md = extractRunMarkdown(runMatch[0]);\n if (md) {\n runs.push(md);\n }\n }\n\n if (runs.length === 0) {\n continue;\n }\n\n let line = runs.join(\"\");\n const headingLevel = getHeadingLevel(paragraphXml, styleMap);\n\n if (headingLevel > 0 && headingLevel <= 6) {\n line = `${\"#\".repeat(headingLevel)} ${line}`;\n } else if (isListItem(paragraphXml)) {\n line = `- ${line}`;\n }\n\n paragraphs.push(line);\n }\n\n return paragraphs.join(\"\\n\\n\");\n}\n\n// --- ZIP utilities (unchanged) ---\n\nfunction extractFileFromZip(buffer: Buffer, targetPath: string): string | null {\n const eocdOffset = findEocd(buffer);\n if (eocdOffset === -1) {\n throw new Error(\"Invalid ZIP: End of Central Directory not found.\");\n }\n\n const cdOffset = buffer.readUInt32LE(eocdOffset + 16);\n const cdSize = buffer.readUInt32LE(eocdOffset + 12);\n const cdEnd = cdOffset + cdSize;\n let offset = cdOffset;\n\n while (offset < cdEnd) {\n const sig = buffer.readUInt32LE(offset);\n if (sig !== 0x02014b50) {\n break;\n }\n\n const compressionMethod = buffer.readUInt16LE(offset + 10);\n const compressedSize = buffer.readUInt32LE(offset + 20);\n const fileNameLen = buffer.readUInt16LE(offset + 28);\n const extraLen = buffer.readUInt16LE(offset + 30);\n const commentLen = buffer.readUInt16LE(offset + 32);\n const localHeaderOffset = buffer.readUInt32LE(offset + 42);\n const fileName = buffer.toString(\"utf-8\", offset + 46, offset + 46 + fileNameLen);\n\n if (fileName === targetPath) {\n return readLocalFile(buffer, localHeaderOffset, compressionMethod, compressedSize);\n }\n\n offset += 46 + fileNameLen + extraLen + commentLen;\n }\n\n return null;\n}\n\nfunction readLocalFile(\n buffer: Buffer,\n offset: number,\n compressionMethod: number,\n compressedSize: number\n): string {\n const sig = buffer.readUInt32LE(offset);\n if (sig !== 0x04034b50) {\n throw new Error(\"Invalid ZIP: bad local file header.\");\n }\n\n const localFileNameLen = buffer.readUInt16LE(offset + 26);\n const localExtraLen = buffer.readUInt16LE(offset + 28);\n const dataOffset = offset + 30 + localFileNameLen + localExtraLen;\n\n const raw = buffer.subarray(dataOffset, dataOffset + compressedSize);\n\n if (compressionMethod === 0) {\n return raw.toString(\"utf-8\");\n }\n\n if (compressionMethod === 8) {\n return inflateRawSync(raw).toString(\"utf-8\");\n }\n\n throw new Error(`Unsupported ZIP compression method: ${compressionMethod}`);\n}\n\nfunction findEocd(buffer: Buffer): number {\n for (let i = buffer.length - 22; i >= Math.max(0, buffer.length - 65557); i--) {\n if (buffer.readUInt32LE(i) === 0x06054b50) {\n return i;\n }\n }\n return -1;\n}\n"],"names":["extractDocxText","buffer","xml","extractFileFromZip","Error","stylesXml","styleMap","buildStyleMap","Map","convertToMarkdown","map","styleRegex","match","styleId","block","nameMatch","getHeadingLevel","paragraphXml","styleMatch","directMatch","parseInt","styleName","isListItem","extractRunMarkdown","runXml","textRegex","texts","text","isBold","isItalic","paragraphs","paragraphRegex","paragraphMatch","runRegex","runs","runMatch","md","line","headingLevel","targetPath","eocdOffset","findEocd","cdOffset","cdSize","cdEnd","offset","sig","compressionMethod","compressedSize","fileNameLen","extraLen","commentLen","localHeaderOffset","fileName","readLocalFile","localFileNameLen","localExtraLen","dataOffset","raw","inflateRawSync","i","Math"],"mappings":"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"}
|
|
@@ -1,10 +1,23 @@
|
|
|
1
|
+
import type { Constructor } from "@webiny/di";
|
|
1
2
|
import type { generateText } from "ai";
|
|
2
3
|
import type { streamText } from "ai";
|
|
3
4
|
import type { LanguageModel } from "ai";
|
|
4
5
|
import type { FlexibleSchema, ToolSet } from "ai";
|
|
6
|
+
/**
|
|
7
|
+
* What a model accepts, as published in the model catalog. A capability that isn't listed is unknown,
|
|
8
|
+
* and unknown is treated as unsupported: a parameter the model may reject is not sent.
|
|
9
|
+
*/
|
|
10
|
+
export interface IAiModelSupports {
|
|
11
|
+
tools?: boolean;
|
|
12
|
+
vision?: boolean;
|
|
13
|
+
temperature?: boolean;
|
|
14
|
+
}
|
|
5
15
|
export interface IAiSdkModel {
|
|
6
16
|
id: string;
|
|
7
17
|
name: string;
|
|
18
|
+
deprecated?: Date;
|
|
19
|
+
endOfLife?: Date;
|
|
20
|
+
supports?: IAiModelSupports;
|
|
8
21
|
}
|
|
9
22
|
export interface IAiSdk {
|
|
10
23
|
languageModel(modelId: string): LanguageModel;
|
|
@@ -55,6 +68,9 @@ export interface AiModel {
|
|
|
55
68
|
providerName: string;
|
|
56
69
|
modelId: string;
|
|
57
70
|
modelName: string;
|
|
71
|
+
deprecated: Date | undefined;
|
|
72
|
+
endOfLife: Date | undefined;
|
|
73
|
+
supports: IAiModelSupports | undefined;
|
|
58
74
|
}
|
|
59
75
|
export interface IAi {
|
|
60
76
|
generateText(params: AiGenerateTextParams): ReturnType<typeof generateText>;
|
|
@@ -70,16 +86,95 @@ export declare namespace Ai {
|
|
|
70
86
|
type GenerateTextParams = AiGenerateTextParams;
|
|
71
87
|
type StreamTextParams = AiStreamTextParams;
|
|
72
88
|
}
|
|
73
|
-
export interface
|
|
89
|
+
export interface IAiModelRegistry {
|
|
90
|
+
listModels(): Promise<AiModel[]>;
|
|
91
|
+
}
|
|
92
|
+
/** Single source of truth for available AI models. Decoratable to restrict the model list. */
|
|
93
|
+
export declare const AiModelRegistry: import("@webiny/di").Abstraction<IAiModelRegistry>;
|
|
94
|
+
export declare namespace AiModelRegistry {
|
|
95
|
+
type Interface = IAiModelRegistry;
|
|
96
|
+
}
|
|
97
|
+
export interface AiCatalogProvider {
|
|
98
|
+
id: string;
|
|
99
|
+
name: string;
|
|
100
|
+
models: IAiSdkModel[];
|
|
101
|
+
}
|
|
102
|
+
export interface IAiModelCatalog {
|
|
103
|
+
/** Returns `undefined` when the catalog can't be loaded. */
|
|
104
|
+
listProviders(): Promise<AiCatalogProvider[] | undefined>;
|
|
105
|
+
}
|
|
106
|
+
/** The published list of providers and models Webiny supports. SDK factories still gate what is offered. */
|
|
107
|
+
export declare const AiModelCatalog: import("@webiny/di").Abstraction<IAiModelCatalog>;
|
|
108
|
+
export declare namespace AiModelCatalog {
|
|
109
|
+
type Interface = IAiModelCatalog;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Behavioural hints about a tool. Purely advisory — they never replace a permission check.
|
|
113
|
+
* Names mirror the MCP tool annotations so they can be forwarded verbatim to MCP clients,
|
|
114
|
+
* which use them to decide what to auto-approve and what to confirm with the user.
|
|
115
|
+
*/
|
|
116
|
+
export interface IAiSdkToolAnnotations {
|
|
117
|
+
/** Tool does not modify state. */
|
|
118
|
+
readOnlyHint?: boolean;
|
|
119
|
+
/** Tool may perform destructive updates (only meaningful when not read-only). */
|
|
120
|
+
destructiveHint?: boolean;
|
|
121
|
+
/** Repeated calls with the same arguments have no additional effect. */
|
|
122
|
+
idempotentHint?: boolean;
|
|
123
|
+
/** Tool interacts with entities outside its own closed world. */
|
|
124
|
+
openWorldHint?: boolean;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* What a tool DOES. This is the half that injects use cases, so it is built only for a tool the
|
|
128
|
+
* model actually calls, and only at the moment it calls it.
|
|
129
|
+
*/
|
|
130
|
+
export interface IAiSdkToolHandler<TInput = any> {
|
|
131
|
+
execute(input: TInput): Promise<unknown>;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* What a tool IS: everything the model is told about it, plus the class that runs it.
|
|
135
|
+
*
|
|
136
|
+
* Carries no behaviour and no dependencies, which is what makes the registry cheap to read.
|
|
137
|
+
* `AiSdkTools` builds every definition to assemble the tool set, and builds a handler only for a
|
|
138
|
+
* tool the model actually calls.
|
|
139
|
+
*/
|
|
140
|
+
export interface IAiSdkToolDefinition<TInput = any> {
|
|
74
141
|
readonly name: string;
|
|
75
142
|
readonly description: string;
|
|
76
143
|
readonly inputSchema: FlexibleSchema<TInput>;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
144
|
+
/** Human-friendly display name. Falls back to `name` when omitted. */
|
|
145
|
+
readonly title?: string;
|
|
146
|
+
readonly annotations?: IAiSdkToolAnnotations;
|
|
147
|
+
readonly handler: Constructor<IAiSdkToolHandler<TInput>>;
|
|
148
|
+
}
|
|
149
|
+
export declare const AiSdkToolDefinition: import("@webiny/di").Abstraction<IAiSdkToolDefinition<any>>;
|
|
150
|
+
/**
|
|
151
|
+
* The behaviour half of a tool, built on demand through {@link AiSdkToolHandlerResolver}.
|
|
152
|
+
*
|
|
153
|
+
* Implementations are NOT registered against this abstraction. The definition points at the class
|
|
154
|
+
* directly, exactly as `HttpRouteDefinition` points at its `HttpRouteHandler`. Declaring them
|
|
155
|
+
* through it is what attaches their dependency metadata.
|
|
156
|
+
*/
|
|
157
|
+
export declare const AiSdkToolHandler: import("@webiny/di").Abstraction<IAiSdkToolHandler<any>>;
|
|
158
|
+
export declare namespace AiSdkToolDefinition {
|
|
159
|
+
type Interface<TInput = any> = IAiSdkToolDefinition<TInput>;
|
|
160
|
+
type Annotations = IAiSdkToolAnnotations;
|
|
161
|
+
}
|
|
162
|
+
export declare namespace AiSdkToolHandler {
|
|
163
|
+
type Interface<TInput = any> = IAiSdkToolHandler<TInput>;
|
|
164
|
+
}
|
|
165
|
+
export interface IAiSdkToolHandlerResolver {
|
|
166
|
+
resolve<TInput>(handler: Constructor<IAiSdkToolHandler<TInput>>): IAiSdkToolHandler<TInput>;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Builds the behaviour half of a tool on demand.
|
|
170
|
+
*
|
|
171
|
+
* Something has to turn `tool.handler` (a class) into an instance, and that needs the container.
|
|
172
|
+
* Rather than injecting the container into the tool registry, it lives behind this one narrow
|
|
173
|
+
* abstraction, so everything else depends on `resolve(handler)` and stays testable with a stub.
|
|
174
|
+
*/
|
|
175
|
+
export declare const AiSdkToolHandlerResolver: import("@webiny/di").Abstraction<IAiSdkToolHandlerResolver>;
|
|
176
|
+
export declare namespace AiSdkToolHandlerResolver {
|
|
177
|
+
type Interface = IAiSdkToolHandlerResolver;
|
|
83
178
|
}
|
|
84
179
|
export interface IAiSdkTools {
|
|
85
180
|
getToolSet(): ToolSet;
|