@undefineds.co/xpod 0.3.58 → 0.3.62
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/README.md +3 -0
- package/config/cli.json +88 -0
- package/config/cloud.json +32 -1
- package/config/components-ignore.json +3 -0
- package/config/extensions.local.initializer.json +44 -0
- package/config/resolver.json +86 -0
- package/config/xpod.base.json +4 -0
- package/dist/agents/AgentExecutorFactory.d.ts +3 -3
- package/dist/agents/AgentExecutorFactory.js +28 -15
- package/dist/agents/AgentExecutorFactory.js.map +1 -1
- package/dist/agents/BaseAgentExecutor.d.ts +2 -1
- package/dist/agents/BaseAgentExecutor.js +1 -0
- package/dist/agents/BaseAgentExecutor.js.map +1 -1
- package/dist/agents/ClaudeExecutor.d.ts +3 -1
- package/dist/agents/ClaudeExecutor.js +18 -12
- package/dist/agents/ClaudeExecutor.js.map +1 -1
- package/dist/agents/config/resolve.js +0 -21
- package/dist/agents/config/resolve.js.map +1 -1
- package/dist/agents/config/types.d.ts +2 -7
- package/dist/agents/config/types.js +2 -1
- package/dist/agents/config/types.js.map +1 -1
- package/dist/agents/types.d.ts +18 -0
- package/dist/agents/types.js.map +1 -1
- package/dist/ai/schema/types.d.ts +2 -1
- package/dist/ai/schema/types.js +1 -0
- package/dist/ai/schema/types.js.map +1 -1
- package/dist/ai/service/CredentialReader.d.ts +3 -1
- package/dist/ai/service/CredentialReader.js.map +1 -1
- package/dist/ai/service/CredentialReaderImpl.d.ts +3 -1
- package/dist/ai/service/CredentialReaderImpl.js +24 -2
- package/dist/ai/service/CredentialReaderImpl.js.map +1 -1
- package/dist/ai/service/EmbeddingServiceImpl.js +13 -2
- package/dist/ai/service/EmbeddingServiceImpl.js.map +1 -1
- package/dist/ai/service/ProviderRegistry.d.ts +4 -0
- package/dist/ai/service/ProviderRegistry.js.map +1 -1
- package/dist/ai/service/ProviderRegistry.jsonld +4 -0
- package/dist/ai/service/ProviderRegistryImpl.d.ts +4 -1
- package/dist/ai/service/ProviderRegistryImpl.js +26 -4
- package/dist/ai/service/ProviderRegistryImpl.js.map +1 -1
- package/dist/ai/service/ProviderRegistryImpl.jsonld +12 -0
- package/dist/ai/service/defaultEmbeddingProfile.d.ts +5 -0
- package/dist/ai/service/defaultEmbeddingProfile.js +31 -0
- package/dist/ai/service/defaultEmbeddingProfile.js.map +1 -0
- package/dist/ai/service/index.d.ts +1 -0
- package/dist/ai/service/index.js +1 -0
- package/dist/ai/service/index.js.map +1 -1
- package/dist/ai/service/types.d.ts +1 -0
- package/dist/ai/service/types.js.map +1 -1
- package/dist/api/ApiServer.js +17 -2
- package/dist/api/ApiServer.js.map +1 -1
- package/dist/api/ai-gateway/AiGatewayService.d.ts +106 -0
- package/dist/api/ai-gateway/AiGatewayService.js +527 -0
- package/dist/api/ai-gateway/AiGatewayService.js.map +1 -0
- package/dist/api/ai-gateway/auth/AiConnectionInvocationKeyIssuer.d.ts +38 -0
- package/dist/api/ai-gateway/auth/AiConnectionInvocationKeyIssuer.js +128 -0
- package/dist/api/ai-gateway/auth/AiConnectionInvocationKeyIssuer.js.map +1 -0
- package/dist/api/ai-gateway/auth/ClientCredentialsInternalPodAccessTokenProvider.d.ts +25 -0
- package/dist/api/ai-gateway/auth/ClientCredentialsInternalPodAccessTokenProvider.js +91 -0
- package/dist/api/ai-gateway/auth/ClientCredentialsInternalPodAccessTokenProvider.js.map +1 -0
- package/dist/api/ai-gateway/auth/GatewayApiKey.d.ts +28 -0
- package/dist/api/ai-gateway/auth/GatewayApiKey.js +162 -0
- package/dist/api/ai-gateway/auth/GatewayApiKey.js.map +1 -0
- package/dist/api/ai-gateway/auth/GatewayApiKeyAuthenticator.d.ts +56 -0
- package/dist/api/ai-gateway/auth/GatewayApiKeyAuthenticator.js +143 -0
- package/dist/api/ai-gateway/auth/GatewayApiKeyAuthenticator.js.map +1 -0
- package/dist/api/ai-gateway/auth/GatewayKeyLocatorCodec.d.ts +26 -0
- package/dist/api/ai-gateway/auth/GatewayKeyLocatorCodec.js +97 -0
- package/dist/api/ai-gateway/auth/GatewayKeyLocatorCodec.js.map +1 -0
- package/dist/api/ai-gateway/auth/GatewayPrincipal.d.ts +20 -0
- package/dist/api/ai-gateway/auth/GatewayPrincipal.js +37 -0
- package/dist/api/ai-gateway/auth/GatewayPrincipal.js.map +1 -0
- package/dist/api/ai-gateway/auth/InvocationTokenCodec.d.ts +41 -0
- package/dist/api/ai-gateway/auth/InvocationTokenCodec.js +221 -0
- package/dist/api/ai-gateway/auth/InvocationTokenCodec.js.map +1 -0
- package/dist/api/ai-gateway/auth/PodGatewayAccessKeyRepository.d.ts +54 -0
- package/dist/api/ai-gateway/auth/PodGatewayAccessKeyRepository.js +152 -0
- package/dist/api/ai-gateway/auth/PodGatewayAccessKeyRepository.js.map +1 -0
- package/dist/api/ai-gateway/connect/index.d.ts +367 -0
- package/dist/api/ai-gateway/connect/index.js +1061 -0
- package/dist/api/ai-gateway/connect/index.js.map +1 -0
- package/dist/api/ai-gateway/credentials/CloudKmsWrapper.d.ts +40 -0
- package/dist/api/ai-gateway/credentials/CloudKmsWrapper.js +59 -0
- package/dist/api/ai-gateway/credentials/CloudKmsWrapper.js.map +1 -0
- package/dist/api/ai-gateway/credentials/CredentialVault.d.ts +14 -0
- package/dist/api/ai-gateway/credentials/CredentialVault.js +11 -0
- package/dist/api/ai-gateway/credentials/CredentialVault.js.map +1 -0
- package/dist/api/ai-gateway/credentials/KeyWrapper.d.ts +27 -0
- package/dist/api/ai-gateway/credentials/KeyWrapper.js +3 -0
- package/dist/api/ai-gateway/credentials/KeyWrapper.js.map +1 -0
- package/dist/api/ai-gateway/credentials/LocalKeychainWrapper.d.ts +27 -0
- package/dist/api/ai-gateway/credentials/LocalKeychainWrapper.js +145 -0
- package/dist/api/ai-gateway/credentials/LocalKeychainWrapper.js.map +1 -0
- package/dist/api/ai-gateway/credentials/SecretCellCredentialVault.d.ts +13 -0
- package/dist/api/ai-gateway/credentials/SecretCellCredentialVault.js +133 -0
- package/dist/api/ai-gateway/credentials/SecretCellCredentialVault.js.map +1 -0
- package/dist/api/ai-gateway/credentials/SecretCellKeyWrapper.d.ts +23 -0
- package/dist/api/ai-gateway/credentials/SecretCellKeyWrapper.js +62 -0
- package/dist/api/ai-gateway/credentials/SecretCellKeyWrapper.js.map +1 -0
- package/dist/api/ai-gateway/credentials/WebCryptoCredentialVault.d.ts +23 -0
- package/dist/api/ai-gateway/credentials/WebCryptoCredentialVault.js +173 -0
- package/dist/api/ai-gateway/credentials/WebCryptoCredentialVault.js.map +1 -0
- package/dist/api/ai-gateway/errors.d.ts +21 -0
- package/dist/api/ai-gateway/errors.js +50 -0
- package/dist/api/ai-gateway/errors.js.map +1 -0
- package/dist/api/ai-gateway/protocol/ChatCompletionsFrontend.d.ts +6 -0
- package/dist/api/ai-gateway/protocol/ChatCompletionsFrontend.js +111 -0
- package/dist/api/ai-gateway/protocol/ChatCompletionsFrontend.js.map +1 -0
- package/dist/api/ai-gateway/protocol/MessagesFrontend.d.ts +6 -0
- package/dist/api/ai-gateway/protocol/MessagesFrontend.js +99 -0
- package/dist/api/ai-gateway/protocol/MessagesFrontend.js.map +1 -0
- package/dist/api/ai-gateway/protocol/ResponsesFrontend.d.ts +6 -0
- package/dist/api/ai-gateway/protocol/ResponsesFrontend.js +232 -0
- package/dist/api/ai-gateway/protocol/ResponsesFrontend.js.map +1 -0
- package/dist/api/ai-gateway/protocol/index.d.ts +3 -0
- package/dist/api/ai-gateway/protocol/index.js +10 -0
- package/dist/api/ai-gateway/protocol/index.js.map +1 -0
- package/dist/api/ai-gateway/providers/AnthropicRuntimeAdapter.d.ts +7 -0
- package/dist/api/ai-gateway/providers/AnthropicRuntimeAdapter.js +37 -0
- package/dist/api/ai-gateway/providers/AnthropicRuntimeAdapter.js.map +1 -0
- package/dist/api/ai-gateway/providers/BailianRuntimeAdapter.d.ts +9 -0
- package/dist/api/ai-gateway/providers/BailianRuntimeAdapter.js +127 -0
- package/dist/api/ai-gateway/providers/BailianRuntimeAdapter.js.map +1 -0
- package/dist/api/ai-gateway/providers/DeepSeekRuntimeAdapter.d.ts +8 -0
- package/dist/api/ai-gateway/providers/DeepSeekRuntimeAdapter.js +47 -0
- package/dist/api/ai-gateway/providers/DeepSeekRuntimeAdapter.js.map +1 -0
- package/dist/api/ai-gateway/providers/KimiRuntimeAdapter.d.ts +8 -0
- package/dist/api/ai-gateway/providers/KimiRuntimeAdapter.js +57 -0
- package/dist/api/ai-gateway/providers/KimiRuntimeAdapter.js.map +1 -0
- package/dist/api/ai-gateway/providers/OpenAiCompatibleRuntimeAdapter.d.ts +1 -0
- package/dist/api/ai-gateway/providers/OpenAiCompatibleRuntimeAdapter.js +6 -0
- package/dist/api/ai-gateway/providers/OpenAiCompatibleRuntimeAdapter.js.map +1 -0
- package/dist/api/ai-gateway/providers/OpenAiRuntimeAdapter.d.ts +13 -0
- package/dist/api/ai-gateway/providers/OpenAiRuntimeAdapter.js +34 -0
- package/dist/api/ai-gateway/providers/OpenAiRuntimeAdapter.js.map +1 -0
- package/dist/api/ai-gateway/providers/ProviderRegistry.d.ts +68 -0
- package/dist/api/ai-gateway/providers/ProviderRegistry.js +288 -0
- package/dist/api/ai-gateway/providers/ProviderRegistry.js.map +1 -0
- package/dist/api/ai-gateway/providers/ProviderRuntimeAdapter.d.ts +88 -0
- package/dist/api/ai-gateway/providers/ProviderRuntimeAdapter.js +645 -0
- package/dist/api/ai-gateway/providers/ProviderRuntimeAdapter.js.map +1 -0
- package/dist/api/ai-gateway/providers/ProviderRuntimeRegistry.d.ts +13 -0
- package/dist/api/ai-gateway/providers/ProviderRuntimeRegistry.js +48 -0
- package/dist/api/ai-gateway/providers/ProviderRuntimeRegistry.js.map +1 -0
- package/dist/api/ai-gateway/providers/index.d.ts +9 -0
- package/dist/api/ai-gateway/providers/index.js +26 -0
- package/dist/api/ai-gateway/providers/index.js.map +1 -0
- package/dist/api/ai-gateway/quota/AnthropicQuotaAdapter.d.ts +5 -0
- package/dist/api/ai-gateway/quota/AnthropicQuotaAdapter.js +21 -0
- package/dist/api/ai-gateway/quota/AnthropicQuotaAdapter.js.map +1 -0
- package/dist/api/ai-gateway/quota/BailianQuotaAdapter.d.ts +5 -0
- package/dist/api/ai-gateway/quota/BailianQuotaAdapter.js +21 -0
- package/dist/api/ai-gateway/quota/BailianQuotaAdapter.js.map +1 -0
- package/dist/api/ai-gateway/quota/DeepSeekQuotaAdapter.d.ts +10 -0
- package/dist/api/ai-gateway/quota/DeepSeekQuotaAdapter.js +83 -0
- package/dist/api/ai-gateway/quota/DeepSeekQuotaAdapter.js.map +1 -0
- package/dist/api/ai-gateway/quota/KimiQuotaAdapter.d.ts +10 -0
- package/dist/api/ai-gateway/quota/KimiQuotaAdapter.js +70 -0
- package/dist/api/ai-gateway/quota/KimiQuotaAdapter.js.map +1 -0
- package/dist/api/ai-gateway/quota/OpenAiQuotaAdapter.d.ts +5 -0
- package/dist/api/ai-gateway/quota/OpenAiQuotaAdapter.js +21 -0
- package/dist/api/ai-gateway/quota/OpenAiQuotaAdapter.js.map +1 -0
- package/dist/api/ai-gateway/quota/ProviderQuotaAdapter.d.ts +214 -0
- package/dist/api/ai-gateway/quota/ProviderQuotaAdapter.js +511 -0
- package/dist/api/ai-gateway/quota/ProviderQuotaAdapter.js.map +1 -0
- package/dist/api/ai-gateway/quota/index.d.ts +6 -0
- package/dist/api/ai-gateway/quota/index.js +23 -0
- package/dist/api/ai-gateway/quota/index.js.map +1 -0
- package/dist/api/ai-gateway/routing/InMemorySessionAffinityStore.d.ts +26 -0
- package/dist/api/ai-gateway/routing/InMemorySessionAffinityStore.js +67 -0
- package/dist/api/ai-gateway/routing/InMemorySessionAffinityStore.js.map +1 -0
- package/dist/api/ai-gateway/routing/ModelRouter.d.ts +84 -0
- package/dist/api/ai-gateway/routing/ModelRouter.js +274 -0
- package/dist/api/ai-gateway/routing/ModelRouter.js.map +1 -0
- package/dist/api/ai-gateway/routing/RedisSessionAffinityStore.d.ts +39 -0
- package/dist/api/ai-gateway/routing/RedisSessionAffinityStore.js +122 -0
- package/dist/api/ai-gateway/routing/RedisSessionAffinityStore.js.map +1 -0
- package/dist/api/ai-gateway/routing/SessionAffinityStore.d.ts +49 -0
- package/dist/api/ai-gateway/routing/SessionAffinityStore.js +66 -0
- package/dist/api/ai-gateway/routing/SessionAffinityStore.js.map +1 -0
- package/dist/api/ai-gateway/service-access/AiConnectionServiceAccess.d.ts +25 -0
- package/dist/api/ai-gateway/service-access/AiConnectionServiceAccess.js +50 -0
- package/dist/api/ai-gateway/service-access/AiConnectionServiceAccess.js.map +1 -0
- package/dist/api/ai-gateway/types.d.ts +112 -0
- package/dist/api/ai-gateway/types.js +305 -0
- package/dist/api/ai-gateway/types.js.map +1 -0
- package/dist/api/auth/AuthContext.d.ts +18 -3
- package/dist/api/auth/AuthContext.js +13 -2
- package/dist/api/auth/AuthContext.js.map +1 -1
- package/dist/api/auth/Authenticator.d.ts +3 -0
- package/dist/api/auth/Authenticator.js.map +1 -1
- package/dist/api/auth/ClientCredentialsAuthenticator.d.ts +2 -6
- package/dist/api/auth/ClientCredentialsAuthenticator.js +12 -30
- package/dist/api/auth/ClientCredentialsAuthenticator.js.map +1 -1
- package/dist/api/auth/SolidTokenAuthenticator.d.ts +2 -0
- package/dist/api/auth/SolidTokenAuthenticator.js +88 -2
- package/dist/api/auth/SolidTokenAuthenticator.js.map +1 -1
- package/dist/api/auth/TokenIdentity.d.ts +6 -0
- package/dist/api/auth/TokenIdentity.js +31 -0
- package/dist/api/auth/TokenIdentity.js.map +1 -0
- package/dist/api/chatkit/ai-provider.d.ts +9 -23
- package/dist/api/chatkit/ai-provider.js +30 -153
- package/dist/api/chatkit/ai-provider.js.map +1 -1
- package/dist/api/chatkit/default-agent.d.ts +24 -15
- package/dist/api/chatkit/default-agent.js +24 -83
- package/dist/api/chatkit/default-agent.js.map +1 -1
- package/dist/api/chatkit/index.d.ts +2 -1
- package/dist/api/chatkit/index.js +3 -1
- package/dist/api/chatkit/index.js.map +1 -1
- package/dist/api/chatkit/pod-store.d.ts +13 -1
- package/dist/api/chatkit/pod-store.js +127 -7
- package/dist/api/chatkit/pod-store.js.map +1 -1
- package/dist/api/chatkit/runtime/AcpAgentRuntime.d.ts +0 -1
- package/dist/api/chatkit/runtime/AcpAgentRuntime.js +14 -51
- package/dist/api/chatkit/runtime/AcpAgentRuntime.js.map +1 -1
- package/dist/api/chatkit/runtime/AcpRunner.js +2 -1
- package/dist/api/chatkit/runtime/AcpRunner.js.map +1 -1
- package/dist/api/chatkit/runtime/CodexRuntimeProjector.d.ts +15 -1
- package/dist/api/chatkit/runtime/CodexRuntimeProjector.js +52 -34
- package/dist/api/chatkit/runtime/CodexRuntimeProjector.js.map +1 -1
- package/dist/api/chatkit/service.d.ts +8 -1
- package/dist/api/chatkit/service.js +46 -5
- package/dist/api/chatkit/service.js.map +1 -1
- package/dist/api/chatkit/store.d.ts +23 -1
- package/dist/api/chatkit/store.js +56 -0
- package/dist/api/chatkit/store.js.map +1 -1
- package/dist/api/chatkit/types.d.ts +1 -0
- package/dist/api/chatkit/types.js.map +1 -1
- package/dist/api/container/common.js +286 -13
- package/dist/api/container/common.js.map +1 -1
- package/dist/api/container/index.js +126 -6
- package/dist/api/container/index.js.map +1 -1
- package/dist/api/container/local.js +50 -6
- package/dist/api/container/local.js.map +1 -1
- package/dist/api/container/rdf.d.ts +15 -0
- package/dist/api/container/rdf.js +90 -0
- package/dist/api/container/rdf.js.map +1 -0
- package/dist/api/container/routes.js +151 -11
- package/dist/api/container/routes.js.map +1 -1
- package/dist/api/container/types.d.ts +96 -0
- package/dist/api/container/types.js.map +1 -1
- package/dist/api/handlers/AdminHandler.d.ts +25 -2
- package/dist/api/handlers/AdminHandler.js +60 -10
- package/dist/api/handlers/AdminHandler.js.map +1 -1
- package/dist/api/handlers/AiClientConfigurationHandler.d.ts +7 -0
- package/dist/api/handlers/AiClientConfigurationHandler.js +202 -0
- package/dist/api/handlers/AiClientConfigurationHandler.js.map +1 -0
- package/dist/api/handlers/AiGatewayHandler.d.ts +23 -0
- package/dist/api/handlers/AiGatewayHandler.js +231 -0
- package/dist/api/handlers/AiGatewayHandler.js.map +1 -0
- package/dist/api/handlers/AiGatewayManagementHandler.d.ts +24 -0
- package/dist/api/handlers/AiGatewayManagementHandler.js +503 -0
- package/dist/api/handlers/AiGatewayManagementHandler.js.map +1 -0
- package/dist/api/handlers/ChatHandler.d.ts +11 -12
- package/dist/api/handlers/ChatHandler.js +12 -219
- package/dist/api/handlers/ChatHandler.js.map +1 -1
- package/dist/api/handlers/DashboardHandler.js +22 -116
- package/dist/api/handlers/DashboardHandler.js.map +1 -1
- package/dist/api/handlers/NetworkSettingsHandler.d.ts +97 -0
- package/dist/api/handlers/NetworkSettingsHandler.js +511 -0
- package/dist/api/handlers/NetworkSettingsHandler.js.map +1 -0
- package/dist/api/handlers/PodSettingsHandler.d.ts +79 -0
- package/dist/api/handlers/PodSettingsHandler.js +162 -0
- package/dist/api/handlers/PodSettingsHandler.js.map +1 -0
- package/dist/api/handlers/ProvisionHandler.d.ts +3 -1
- package/dist/api/handlers/ProvisionHandler.js +22 -87
- package/dist/api/handlers/ProvisionHandler.js.map +1 -1
- package/dist/api/handlers/RdfStatsHandler.d.ts +6 -0
- package/dist/api/handlers/RdfStatsHandler.js +85 -0
- package/dist/api/handlers/RdfStatsHandler.js.map +1 -0
- package/dist/api/handlers/SettingsHandler.d.ts +5 -0
- package/dist/api/handlers/SettingsHandler.js +13 -0
- package/dist/api/handlers/SettingsHandler.js.map +1 -0
- package/dist/api/handlers/StaticSpaHandler.d.ts +8 -0
- package/dist/api/handlers/StaticSpaHandler.js +102 -0
- package/dist/api/handlers/StaticSpaHandler.js.map +1 -0
- package/dist/api/handlers/index.d.ts +1 -0
- package/dist/api/handlers/index.js +1 -0
- package/dist/api/handlers/index.js.map +1 -1
- package/dist/api/http/readBoundedJsonBody.d.ts +14 -0
- package/dist/api/http/readBoundedJsonBody.js +58 -0
- package/dist/api/http/readBoundedJsonBody.js.map +1 -0
- package/dist/api/middleware/AuthMiddleware.d.ts +1 -0
- package/dist/api/middleware/AuthMiddleware.js +33 -4
- package/dist/api/middleware/AuthMiddleware.js.map +1 -1
- package/dist/api/runs/AgentRuntimeTypes.d.ts +18 -3
- package/dist/api/runs/AgentRuntimeTypes.js +61 -0
- package/dist/api/runs/AgentRuntimeTypes.js.map +1 -1
- package/dist/api/runs/InngestRunExecutionBackend.d.ts +28 -3
- package/dist/api/runs/InngestRunExecutionBackend.js +26 -3
- package/dist/api/runs/InngestRunExecutionBackend.js.map +1 -1
- package/dist/api/runs/ManagedRunWorker.d.ts +4 -1
- package/dist/api/runs/ManagedRunWorker.js +39 -8
- package/dist/api/runs/ManagedRunWorker.js.map +1 -1
- package/dist/api/runs/PiAgentRuntimeDriver.d.ts +5 -1
- package/dist/api/runs/PiAgentRuntimeDriver.js +94 -57
- package/dist/api/runs/PiAgentRuntimeDriver.js.map +1 -1
- package/dist/api/runs/RdfRunContextRetriever.d.ts +46 -0
- package/dist/api/runs/RdfRunContextRetriever.js +277 -0
- package/dist/api/runs/RdfRunContextRetriever.js.map +1 -0
- package/dist/api/runs/RunExecutionBackend.d.ts +38 -0
- package/dist/api/runs/RunExecutionBackend.js.map +1 -1
- package/dist/api/runs/RunStateCenter.d.ts +18 -3
- package/dist/api/runs/RunStateCenter.js +85 -24
- package/dist/api/runs/RunStateCenter.js.map +1 -1
- package/dist/api/runtime.js +163 -3
- package/dist/api/runtime.js.map +1 -1
- package/dist/api/service/AiClientConfigurationService.d.ts +97 -0
- package/dist/api/service/AiClientConfigurationService.js +379 -0
- package/dist/api/service/AiClientConfigurationService.js.map +1 -0
- package/dist/api/service/RdfBenchmarkReportCatalog.d.ts +86 -0
- package/dist/api/service/RdfBenchmarkReportCatalog.js +349 -0
- package/dist/api/service/RdfBenchmarkReportCatalog.js.map +1 -0
- package/dist/api/service/RdfBenchmarkReportGate.d.ts +78 -0
- package/dist/api/service/RdfBenchmarkReportGate.js +197 -0
- package/dist/api/service/RdfBenchmarkReportGate.js.map +1 -0
- package/dist/api/service/RdfSearchIndexingService.d.ts +113 -0
- package/dist/api/service/RdfSearchIndexingService.js +272 -0
- package/dist/api/service/RdfSearchIndexingService.js.map +1 -0
- package/dist/api/service/RdfSearchIndexingSolidFsSyncer.d.ts +27 -0
- package/dist/api/service/RdfSearchIndexingSolidFsSyncer.js +90 -0
- package/dist/api/service/RdfSearchIndexingSolidFsSyncer.js.map +1 -0
- package/dist/api/service/RdfStorageStatsService.d.ts +31 -0
- package/dist/api/service/RdfStorageStatsService.js +97 -0
- package/dist/api/service/RdfStorageStatsService.js.map +1 -0
- package/dist/api/service/VectorStoreService.d.ts +2 -0
- package/dist/api/service/VectorStoreService.js +70 -2
- package/dist/api/service/VectorStoreService.js.map +1 -1
- package/dist/api/service/VercelChatService.d.ts +27 -38
- package/dist/api/service/VercelChatService.js +153 -505
- package/dist/api/service/VercelChatService.js.map +1 -1
- package/dist/api/service/provider-http-transport.d.ts +21 -0
- package/dist/api/service/provider-http-transport.js +108 -2
- package/dist/api/service/provider-http-transport.js.map +1 -1
- package/dist/api/service/provider-registry.d.ts +5 -7
- package/dist/api/service/provider-registry.js +81 -64
- package/dist/api/service/provider-registry.js.map +1 -1
- package/dist/api/tasks/InngestTaskScheduler.d.ts +44 -4
- package/dist/api/tasks/TaskMaterializer.d.ts +10 -1
- package/dist/api/tasks/TaskMaterializer.js +39 -4
- package/dist/api/tasks/TaskMaterializer.js.map +1 -1
- package/dist/api/tasks/TaskService.d.ts +5 -1
- package/dist/api/tasks/TaskService.js +3 -0
- package/dist/api/tasks/TaskService.js.map +1 -1
- package/dist/cli/commands/rdf.d.ts +9 -0
- package/dist/cli/commands/rdf.js +66 -1
- package/dist/cli/commands/rdf.js.map +1 -1
- package/dist/cli/commands/start.js +3 -0
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/lib/solid-auth.d.ts +3 -3
- package/dist/cli/lib/solid-auth.js +4 -4
- package/dist/cli/lib/solid-auth.js.map +1 -1
- package/dist/components/components.jsonld +16 -0
- package/dist/components/context.jsonld +815 -28
- package/dist/document/Chunker.jsonld +110 -0
- package/dist/document/{DocumentParser.d.ts → DocumentReader.d.ts} +23 -11
- package/dist/document/{DocumentParser.js → DocumentReader.js} +2 -2
- package/dist/document/DocumentReader.js.map +1 -0
- package/dist/document/DocumentReader.jsonld +82 -0
- package/dist/document/HeadingChunker.jsonld +41 -0
- package/dist/document/{JinaDocumentParser.d.ts → JinaReader.d.ts} +7 -7
- package/dist/document/{JinaDocumentParser.js → JinaReader.js} +12 -12
- package/dist/document/JinaReader.js.map +1 -0
- package/dist/document/JinaReader.jsonld +133 -0
- package/dist/document/L0SourceSummary.d.ts +103 -0
- package/dist/document/L0SourceSummary.js +157 -0
- package/dist/document/L0SourceSummary.js.map +1 -0
- package/dist/document/L0SourceSummary.jsonld +326 -0
- package/dist/document/PaddleOcrReader.d.ts +40 -0
- package/dist/document/PaddleOcrReader.js +53 -0
- package/dist/document/PaddleOcrReader.js.map +1 -0
- package/dist/document/PaddleOcrReader.jsonld +234 -0
- package/dist/document/ReaderAiConfig.d.ts +50 -0
- package/dist/document/ReaderAiConfig.js +109 -0
- package/dist/document/ReaderAiConfig.js.map +1 -0
- package/dist/document/ReaderAiConfig.jsonld +185 -0
- package/dist/document/ReaderPolicy.d.ts +89 -0
- package/dist/document/ReaderPolicy.js +158 -0
- package/dist/document/ReaderPolicy.js.map +1 -0
- package/dist/document/ReaderPolicy.jsonld +218 -0
- package/dist/document/index.d.ts +6 -2
- package/dist/document/index.js +6 -2
- package/dist/document/index.js.map +1 -1
- package/dist/edge/DdnsManager.d.ts +1 -1
- package/dist/edge/DdnsManager.js.map +1 -1
- package/dist/edge/EdgeNodeAgent.d.ts +4 -0
- package/dist/edge/EdgeNodeAgent.js +6 -0
- package/dist/edge/EdgeNodeAgent.js.map +1 -1
- package/dist/edge/EdgeNodeAgent.jsonld +8 -0
- package/dist/edge/EdgeNodeAgentInitializer.d.ts +16 -0
- package/dist/edge/EdgeNodeAgentInitializer.js +51 -0
- package/dist/edge/EdgeNodeAgentInitializer.js.map +1 -1
- package/dist/edge/EdgeNodeAgentInitializer.jsonld +250 -0
- package/dist/edge/EdgeNodeCertificateCapabilityBridge.d.ts +34 -0
- package/dist/edge/EdgeNodeCertificateCapabilityBridge.js +111 -0
- package/dist/edge/EdgeNodeCertificateCapabilityBridge.js.map +1 -0
- package/dist/edge/acme/AcmeCertificateManager.d.ts +14 -1
- package/dist/edge/acme/AcmeCertificateManager.js +67 -7
- package/dist/edge/acme/AcmeCertificateManager.js.map +1 -1
- package/dist/edge/acme/AcmeCertificateManager.jsonld +22 -2
- package/dist/edge/acme/ClusterCertificateManager.d.ts +12 -0
- package/dist/edge/acme/ClusterCertificateManager.js +38 -0
- package/dist/edge/acme/ClusterCertificateManager.js.map +1 -1
- package/dist/extensions/ExtensionRuntime.d.ts +17 -0
- package/dist/extensions/ExtensionRuntime.js +171 -0
- package/dist/extensions/ExtensionRuntime.js.map +1 -0
- package/dist/extensions/PodCredentialResolver.d.ts +23 -0
- package/dist/extensions/PodCredentialResolver.js +139 -0
- package/dist/extensions/PodCredentialResolver.js.map +1 -0
- package/dist/extensions/index.d.ts +3 -0
- package/dist/extensions/index.js +20 -0
- package/dist/extensions/index.js.map +1 -0
- package/dist/extensions/types.d.ts +73 -0
- package/dist/extensions/types.js +3 -0
- package/dist/extensions/types.js.map +1 -0
- package/dist/http/SubgraphSparqlHttpHandler.d.ts +20 -1
- package/dist/http/SubgraphSparqlHttpHandler.js +324 -43
- package/dist/http/SubgraphSparqlHttpHandler.js.map +1 -1
- package/dist/http/SubgraphSparqlHttpHandler.jsonld +87 -0
- package/dist/identity/drizzle/EdgeNodeRepository.js +3 -2
- package/dist/identity/drizzle/EdgeNodeRepository.js.map +1 -1
- package/dist/identity/drizzle/schema.pg.js +1 -1
- package/dist/identity/drizzle/schema.pg.js.map +1 -1
- package/dist/identity/drizzle/schema.sqlite.js +1 -1
- package/dist/identity/drizzle/schema.sqlite.js.map +1 -1
- package/dist/identity/oidc/ScopedPickWebIdHandler.js +5 -5
- package/dist/identity/oidc/ScopedPickWebIdHandler.js.map +1 -1
- package/dist/index.d.ts +12 -2
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/dist/main.js +3 -0
- package/dist/main.js.map +1 -1
- package/dist/provision/LocalProvisionState.d.ts +28 -0
- package/dist/provision/LocalProvisionState.js +124 -0
- package/dist/provision/LocalProvisionState.js.map +1 -0
- package/dist/provision/ProvisionCodeCodec.d.ts +7 -3
- package/dist/provision/ProvisionCodeCodec.js +10 -3
- package/dist/provision/ProvisionCodeCodec.js.map +1 -1
- package/dist/provision/ProvisionPodCreator.d.ts +15 -1
- package/dist/provision/ProvisionPodCreator.js +68 -1
- package/dist/provision/ProvisionPodCreator.js.map +1 -1
- package/dist/provision/ProvisionPodCreator.jsonld +31 -0
- package/dist/provision/ServiceAccessTokenCodec.d.ts +45 -0
- package/dist/provision/ServiceAccessTokenCodec.js +86 -0
- package/dist/provision/ServiceAccessTokenCodec.js.map +1 -0
- package/dist/runtime/GatewayAdminProxyAuth.d.ts +29 -0
- package/dist/runtime/GatewayAdminProxyAuth.js +108 -0
- package/dist/runtime/GatewayAdminProxyAuth.js.map +1 -0
- package/dist/runtime/Proxy.d.ts +10 -0
- package/dist/runtime/Proxy.js +64 -6
- package/dist/runtime/Proxy.js.map +1 -1
- package/dist/runtime/XpodRuntime.js +1 -0
- package/dist/runtime/XpodRuntime.js.map +1 -1
- package/dist/runtime/bootstrap.d.ts +1 -0
- package/dist/runtime/bootstrap.js +29 -0
- package/dist/runtime/bootstrap.js.map +1 -1
- package/dist/runtime/css-process.d.ts +1 -0
- package/dist/runtime/css-process.js +1 -0
- package/dist/runtime/css-process.js.map +1 -1
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +3 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/lifecycle.d.ts +3 -1
- package/dist/runtime/lifecycle.js +3 -1
- package/dist/runtime/lifecycle.js.map +1 -1
- package/dist/runtime/runner/node/NodeGatewayRuntimeRunner.js +2 -0
- package/dist/runtime/runner/node/NodeGatewayRuntimeRunner.js.map +1 -1
- package/dist/runtime/runner/types.d.ts +3 -0
- package/dist/runtime/runner/types.js.map +1 -1
- package/dist/runtime/runtime-types.d.ts +2 -0
- package/dist/runtime/runtime-types.js.map +1 -1
- package/dist/runtime/safe-env.d.ts +15 -0
- package/dist/runtime/safe-env.js +109 -0
- package/dist/runtime/safe-env.js.map +1 -0
- package/dist/security/index.d.ts +1 -0
- package/dist/security/index.js +18 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/secret-cell/DeploymentRootKeyProvider.d.ts +17 -0
- package/dist/security/secret-cell/DeploymentRootKeyProvider.js +61 -0
- package/dist/security/secret-cell/DeploymentRootKeyProvider.js.map +1 -0
- package/dist/security/secret-cell/DeploymentRootKeyProvider.jsonld +124 -0
- package/dist/security/secret-cell/SecretCellVault.d.ts +55 -0
- package/dist/security/secret-cell/SecretCellVault.js +242 -0
- package/dist/security/secret-cell/SecretCellVault.js.map +1 -0
- package/dist/security/secret-cell/SecretCellVault.jsonld +207 -0
- package/dist/security/secret-cell/index.d.ts +2 -0
- package/dist/security/secret-cell/index.js +11 -0
- package/dist/security/secret-cell/index.js.map +1 -0
- package/dist/solidfs/CompositeSolidFsSyncer.d.ts +18 -0
- package/dist/solidfs/CompositeSolidFsSyncer.js +32 -0
- package/dist/solidfs/CompositeSolidFsSyncer.js.map +1 -0
- package/dist/solidfs/LocalSolidFS.js +25 -1
- package/dist/solidfs/LocalSolidFS.js.map +1 -1
- package/dist/solidfs/RdfIndexSolidFsSyncer.d.ts +41 -2
- package/dist/solidfs/RdfIndexSolidFsSyncer.js +331 -21
- package/dist/solidfs/RdfIndexSolidFsSyncer.js.map +1 -1
- package/dist/solidfs/SolidFsMetaNotes.d.ts +25 -0
- package/dist/solidfs/SolidFsMetaNotes.js +103 -0
- package/dist/solidfs/SolidFsMetaNotes.js.map +1 -0
- package/dist/solidfs/SolidFsSyncJournal.d.ts +2 -2
- package/dist/solidfs/SolidFsSyncJournal.js +9 -4
- package/dist/solidfs/SolidFsSyncJournal.js.map +1 -1
- package/dist/solidfs/SolidFsSyncJournal.jsonld +119 -0
- package/dist/solidfs/WorkspacePrompt.d.ts +13 -0
- package/dist/solidfs/WorkspacePrompt.js +42 -0
- package/dist/solidfs/WorkspacePrompt.js.map +1 -0
- package/dist/solidfs/index.d.ts +3 -0
- package/dist/solidfs/index.js +3 -0
- package/dist/solidfs/index.js.map +1 -1
- package/dist/solidfs/types.d.ts +12 -2
- package/dist/solidfs/types.js.map +1 -1
- package/dist/storage/accessors/MixDataAccessor.d.ts +36 -4
- package/dist/storage/accessors/MixDataAccessor.js +222 -23
- package/dist/storage/accessors/MixDataAccessor.js.map +1 -1
- package/dist/storage/accessors/MixDataAccessor.jsonld +89 -0
- package/dist/storage/accessors/SolidRdfDataAccessor.d.ts +6 -1
- package/dist/storage/accessors/SolidRdfDataAccessor.js +35 -0
- package/dist/storage/accessors/SolidRdfDataAccessor.js.map +1 -1
- package/dist/storage/accessors/SolidRdfDataAccessor.jsonld +20 -0
- package/dist/storage/database/PostgresPoolManager.d.ts +1 -0
- package/dist/storage/database/PostgresPoolManager.js +2 -2
- package/dist/storage/database/PostgresPoolManager.js.map +1 -1
- package/dist/storage/locking/UrlAwareRedisLocker.d.ts +2 -0
- package/dist/storage/locking/UrlAwareRedisLocker.js +65 -0
- package/dist/storage/locking/UrlAwareRedisLocker.js.map +1 -1
- package/dist/storage/locking/UrlAwareRedisLocker.jsonld +19 -0
- package/dist/storage/rdf/PostgresRdfEngine.d.ts +286 -9
- package/dist/storage/rdf/PostgresRdfEngine.js +10773 -2084
- package/dist/storage/rdf/PostgresRdfEngine.js.map +1 -1
- package/dist/storage/rdf/PostgresRdfEngine.jsonld +1693 -89
- package/dist/storage/rdf/PostgresRdfSqlExecutor.d.ts +24 -0
- package/dist/storage/rdf/PostgresRdfSqlExecutor.js +131 -0
- package/dist/storage/rdf/PostgresRdfSqlExecutor.js.map +1 -0
- package/dist/storage/rdf/PostgresRdfTextIndex.d.ts +54 -0
- package/dist/storage/rdf/PostgresRdfTextIndex.js +1255 -0
- package/dist/storage/rdf/PostgresRdfTextIndex.js.map +1 -0
- package/dist/storage/rdf/PostgresRdfTextIndex.jsonld +487 -0
- package/dist/storage/rdf/PostgresRdfVectorIndex.d.ts +46 -0
- package/dist/storage/rdf/PostgresRdfVectorIndex.js +1165 -0
- package/dist/storage/rdf/PostgresRdfVectorIndex.js.map +1 -0
- package/dist/storage/rdf/PostgresRdfVectorIndex.jsonld +423 -0
- package/dist/storage/rdf/Rdf3xIndex.d.ts +14 -1
- package/dist/storage/rdf/Rdf3xIndex.js +286 -2
- package/dist/storage/rdf/Rdf3xIndex.js.map +1 -1
- package/dist/storage/rdf/Rdf3xIndex.jsonld +36 -0
- package/dist/storage/rdf/Rdf3xSchema.d.ts +5 -1
- package/dist/storage/rdf/Rdf3xSchema.js +17 -3
- package/dist/storage/rdf/Rdf3xSchema.js.map +1 -1
- package/dist/storage/rdf/RdfAccessScope.d.ts +22 -0
- package/dist/storage/rdf/RdfAccessScope.js +345 -0
- package/dist/storage/rdf/RdfAccessScope.js.map +1 -0
- package/dist/storage/rdf/RdfAccessScope.jsonld +45 -0
- package/dist/storage/rdf/RdfFusionRankPlan.d.ts +2 -0
- package/dist/storage/rdf/RdfFusionRankPlan.js +186 -0
- package/dist/storage/rdf/RdfFusionRankPlan.js.map +1 -0
- package/dist/storage/rdf/RdfJoinShape.d.ts +8 -0
- package/dist/storage/rdf/RdfJoinShape.js +31 -0
- package/dist/storage/rdf/RdfJoinShape.js.map +1 -0
- package/dist/storage/rdf/RdfQuadIndex.d.ts +5 -2
- package/dist/storage/rdf/RdfQuadIndex.js +94 -6
- package/dist/storage/rdf/RdfQuadIndex.js.map +1 -1
- package/dist/storage/rdf/RdfQuadIndex.jsonld +12 -0
- package/dist/storage/rdf/RdfQueryExecutor.d.ts +3 -4
- package/dist/storage/rdf/RdfQueryExecutor.js +235 -8
- package/dist/storage/rdf/RdfQueryExecutor.js.map +1 -1
- package/dist/storage/rdf/RdfSearchSourceFilter.d.ts +10 -0
- package/dist/storage/rdf/RdfSearchSourceFilter.js +83 -0
- package/dist/storage/rdf/RdfSearchSourceFilter.js.map +1 -0
- package/dist/storage/rdf/RdfSparqlAdapter.d.ts +27 -1
- package/dist/storage/rdf/RdfSparqlAdapter.js +265 -3
- package/dist/storage/rdf/RdfSparqlAdapter.js.map +1 -1
- package/dist/storage/rdf/RdfSparqlAdapter.jsonld +8 -0
- package/dist/storage/rdf/RdfTermDictionary.d.ts +7 -1
- package/dist/storage/rdf/RdfTermDictionary.js +139 -0
- package/dist/storage/rdf/RdfTermDictionary.js.map +1 -1
- package/dist/storage/rdf/RdfTermDictionary.jsonld +4 -0
- package/dist/storage/rdf/RdfTextIndex.d.ts +45 -2
- package/dist/storage/rdf/RdfTextIndex.js +810 -114
- package/dist/storage/rdf/RdfTextIndex.js.map +1 -1
- package/dist/storage/rdf/RdfTextIndex.jsonld +193 -0
- package/dist/storage/rdf/RdfTextProjection.d.ts +10 -0
- package/dist/storage/rdf/RdfTextProjection.js +258 -0
- package/dist/storage/rdf/RdfTextProjection.js.map +1 -0
- package/dist/storage/rdf/RdfVectorIndex.d.ts +30 -2
- package/dist/storage/rdf/RdfVectorIndex.js +461 -38
- package/dist/storage/rdf/RdfVectorIndex.js.map +1 -1
- package/dist/storage/rdf/RdfVectorIndex.jsonld +163 -0
- package/dist/storage/rdf/SolidRdfEngine.d.ts +12 -9
- package/dist/storage/rdf/SolidRdfEngine.js +48 -22
- package/dist/storage/rdf/SolidRdfEngine.js.map +1 -1
- package/dist/storage/rdf/SolidRdfEngine.jsonld +33 -43
- package/dist/storage/rdf/SolidRdfSparqlEngine.d.ts +19 -8
- package/dist/storage/rdf/SolidRdfSparqlEngine.js +674 -44
- package/dist/storage/rdf/SolidRdfSparqlEngine.js.map +1 -1
- package/dist/storage/rdf/SolidRdfSparqlEngine.jsonld +51 -0
- package/dist/storage/rdf/index.d.ts +9 -5
- package/dist/storage/rdf/index.js +42 -1
- package/dist/storage/rdf/index.js.map +1 -1
- package/dist/storage/rdf/models-benchmark.d.ts +264 -2
- package/dist/storage/rdf/models-benchmark.js +4207 -155
- package/dist/storage/rdf/models-benchmark.js.map +1 -1
- package/dist/storage/rdf/types.d.ts +833 -4
- package/dist/storage/rdf/types.js.map +1 -1
- package/dist/storage/rdf/types.jsonld +348 -0
- package/dist/storage/sparql/CompatibilitySparqlEngine.d.ts +14 -13
- package/dist/storage/sparql/CompatibilitySparqlEngine.js +24 -24
- package/dist/storage/sparql/CompatibilitySparqlEngine.js.map +1 -1
- package/dist/storage/sparql/CompatibilitySparqlEngineImpl.d.ts +14 -13
- package/dist/storage/sparql/CompatibilitySparqlEngineImpl.js +30 -18
- package/dist/storage/sparql/CompatibilitySparqlEngineImpl.js.map +1 -1
- package/dist/storage/sparql/SubgraphQueryEngine.d.ts +21 -12
- package/dist/storage/sparql/SubgraphQueryEngine.js +12 -12
- package/dist/storage/sparql/SubgraphQueryEngine.js.map +1 -1
- package/dist/terminal/sandbox/MacOSSandbox.js +2 -1
- package/dist/terminal/sandbox/MacOSSandbox.js.map +1 -1
- package/dist/terminal/sandbox/index.js +2 -1
- package/dist/terminal/sandbox/index.js.map +1 -1
- package/dist/test-utils/no-auth-xpod.js +3 -0
- package/dist/test-utils/no-auth-xpod.js.map +1 -1
- package/dist/tunnel/LocalTunnelProvider.d.ts +3 -0
- package/dist/tunnel/LocalTunnelProvider.js +17 -1
- package/dist/tunnel/LocalTunnelProvider.js.map +1 -1
- package/dist/tunnel/LocalTunnelProvider.jsonld +23 -0
- package/dist/tunnel/SakuraFrpTunnelProvider.d.ts +3 -0
- package/dist/tunnel/SakuraFrpTunnelProvider.js +18 -2
- package/dist/tunnel/SakuraFrpTunnelProvider.js.map +1 -1
- package/dist/tunnel/TunnelProfiles.d.ts +22 -0
- package/dist/tunnel/TunnelProfiles.js +208 -0
- package/dist/tunnel/TunnelProfiles.js.map +1 -0
- package/dist/tunnel/index.d.ts +2 -0
- package/dist/tunnel/index.js +4 -1
- package/dist/tunnel/index.js.map +1 -1
- package/dist/util/identifiers/ClusterIdentifierStrategy.d.ts +3 -0
- package/dist/util/identifiers/ClusterIdentifierStrategy.js +18 -2
- package/dist/util/identifiers/ClusterIdentifierStrategy.js.map +1 -1
- package/dist/util/identifiers/ClusterIdentifierStrategy.jsonld +5 -1
- package/node_modules/@undefineds.co/ai-connection/dist/AiClientConfigurationSection.d.ts +55 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiClientConfigurationSection.js +167 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionHeader.d.ts +3 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionHeader.js +8 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionList.d.ts +4 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionList.js +36 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionMain.d.ts +4 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionMain.js +37 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionMainHeader.d.ts +3 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionMainHeader.js +7 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionPanel.d.ts +14 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionPanel.js +333 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiProviderCard.d.ts +22 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiProviderCard.js +43 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiQuotaCard.d.ts +8 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiQuotaCard.js +6 -0
- package/node_modules/@undefineds.co/ai-connection/dist/ai-connection-client.d.ts +120 -0
- package/node_modules/@undefineds.co/ai-connection/dist/ai-connection-client.js +414 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/base-adapter.d.ts +32 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/base-adapter.js +212 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/codex.d.ts +14 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/codex.js +90 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/index.cjs +668 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/index.d.ts +6 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/index.js +6 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/json-env-adapter.d.ts +21 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/json-env-adapter.js +82 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/pi.d.ts +13 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/pi.js +83 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/transaction.d.ts +17 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/transaction.js +153 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/types.d.ts +40 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/types.js +1 -0
- package/node_modules/@undefineds.co/ai-connection/dist/controller.d.ts +42 -0
- package/node_modules/@undefineds.co/ai-connection/dist/controller.js +289 -0
- package/node_modules/@undefineds.co/ai-connection/dist/index.d.ts +16 -0
- package/node_modules/@undefineds.co/ai-connection/dist/index.js +41 -0
- package/node_modules/@undefineds.co/ai-connection/dist/manifest.d.ts +1 -0
- package/node_modules/@undefineds.co/ai-connection/dist/manifest.js +18 -0
- package/node_modules/@undefineds.co/ai-connection/dist/service-access.d.ts +3 -0
- package/node_modules/@undefineds.co/ai-connection/dist/service-access.js +133 -0
- package/node_modules/@undefineds.co/ai-connection/package.json +50 -0
- package/node_modules/@undefineds.co/extension-sdk/README.md +299 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/index.d.ts +5 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/index.js +5 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/layout.d.ts +16 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/layout.js +36 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/manifest.d.ts +27 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/manifest.js +79 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/app-layout.d.ts +7 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/app-layout.js +8 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/auth-boundary.d.ts +27 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/auth-boundary.js +49 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/layout-context.d.ts +11 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/layout-context.js +9 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/workspace-layout.d.ts +38 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/workspace-layout.js +132 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react.d.ts +12 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react.js +19 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/testing.d.ts +7 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/testing.js +27 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/web.d.ts +225 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/web.js +142 -0
- package/node_modules/@undefineds.co/extension-sdk/package.json +49 -0
- package/node_modules/@undefineds.co/extensions/README.md +101 -0
- package/node_modules/@undefineds.co/extensions/dist/adapters/langchain.d.ts +25 -0
- package/node_modules/@undefineds.co/extensions/dist/adapters/langchain.d.ts.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/adapters/langchain.js +45 -0
- package/node_modules/@undefineds.co/extensions/dist/adapters/langchain.js.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/adapters/llamaindex.d.ts +31 -0
- package/node_modules/@undefineds.co/extensions/dist/adapters/llamaindex.d.ts.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/adapters/llamaindex.js +50 -0
- package/node_modules/@undefineds.co/extensions/dist/adapters/llamaindex.js.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/index.d.ts +7 -0
- package/node_modules/@undefineds.co/extensions/dist/index.d.ts.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/index.js +7 -0
- package/node_modules/@undefineds.co/extensions/dist/index.js.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/paddleocr.d.ts +16 -0
- package/node_modules/@undefineds.co/extensions/dist/paddleocr.d.ts.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/paddleocr.js +267 -0
- package/node_modules/@undefineds.co/extensions/dist/paddleocr.js.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/reader.d.ts +18 -0
- package/node_modules/@undefineds.co/extensions/dist/reader.d.ts.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/reader.js +39 -0
- package/node_modules/@undefineds.co/extensions/dist/reader.js.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/registry.d.ts +16 -0
- package/node_modules/@undefineds.co/extensions/dist/registry.d.ts.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/registry.js +97 -0
- package/node_modules/@undefineds.co/extensions/dist/registry.js.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/types.d.ts +141 -0
- package/node_modules/@undefineds.co/extensions/dist/types.d.ts.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/types.js +2 -0
- package/node_modules/@undefineds.co/extensions/dist/types.js.map +1 -0
- package/node_modules/@undefineds.co/extensions/package.json +38 -0
- package/node_modules/@undefineds.co/shared-ui/dist/badge.d.ts +8 -0
- package/node_modules/@undefineds.co/shared-ui/dist/badge.js +17 -0
- package/node_modules/@undefineds.co/shared-ui/dist/button.d.ts +10 -0
- package/node_modules/@undefineds.co/shared-ui/dist/button.js +30 -0
- package/node_modules/@undefineds.co/shared-ui/dist/card.d.ts +7 -0
- package/node_modules/@undefineds.co/shared-ui/dist/card.js +15 -0
- package/node_modules/@undefineds.co/shared-ui/dist/index.d.ts +6 -0
- package/node_modules/@undefineds.co/shared-ui/dist/index.js +6 -0
- package/node_modules/@undefineds.co/shared-ui/dist/input.d.ts +4 -0
- package/node_modules/@undefineds.co/shared-ui/dist/input.js +5 -0
- package/node_modules/@undefineds.co/shared-ui/dist/theme.css +121 -0
- package/node_modules/@undefineds.co/shared-ui/dist/utils.d.ts +2 -0
- package/node_modules/@undefineds.co/shared-ui/dist/utils.js +5 -0
- package/node_modules/@undefineds.co/shared-ui/dist/workspace.d.ts +23 -0
- package/node_modules/@undefineds.co/shared-ui/dist/workspace.js +38 -0
- package/node_modules/@undefineds.co/shared-ui/package.json +39 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/index.d.ts +3 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/index.js +3 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/pod-runtime.d.ts +45 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/pod-runtime.js +147 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/react.d.ts +15 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/react.js +15 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/session.d.ts +42 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/session.js +127 -0
- package/node_modules/@undefineds.co/solid-sdk/package.json +45 -0
- package/package.json +31 -13
- package/static/app/assets/index-BoYHJ6si.js +230 -0
- package/static/app/assets/inrupt-smoke.js +2 -2
- package/static/app/assets/main.css +1 -1
- package/static/app/assets/main.js +9 -9
- package/static/dashboard/assets/NetworkPage-Brt79fuQ.js +2 -0
- package/static/dashboard/assets/PaneListHeader-57nvMwH6.js +1 -0
- package/static/dashboard/assets/PodPage-CM6do1vB.js +2 -0
- package/static/dashboard/assets/ServicesPage-BUNxGJRz.js +1 -0
- package/static/dashboard/assets/card-B9Zjf_2p.js +1 -0
- package/static/dashboard/assets/dashboard-8C6o666W.js +305 -0
- package/static/dashboard/assets/dashboard-CSdewNeA.css +1 -0
- package/static/dashboard/assets/database-DPh9wDY9.js +1 -0
- package/static/dashboard/assets/external-link-VbMQvVMz.js +1 -0
- package/static/dashboard/assets/index-RfiFckzb.js +51 -0
- package/static/dashboard/assets/refresh-cw-BxVxNxNr.js +1 -0
- package/static/dashboard/assets/services-status-context-DKmJ7ISr.js +1 -0
- package/static/dashboard/dashboard.html +2 -2
- package/static/settings/assets/ModelsPage-D_IH7AH3.js +1 -0
- package/static/settings/assets/PaneListHeader-Bgaze006.js +1 -0
- package/static/settings/assets/PodPage-Cy1VNObw.js +2 -0
- package/static/settings/assets/ServicesPage-BsFaxVWC.js +1 -0
- package/static/settings/assets/SettingsPage-UafNWE_p.js +48 -0
- package/static/settings/assets/card-B_bXSIn-.js +1 -0
- package/static/settings/assets/services-status-context-DiX-AbrP.js +1 -0
- package/static/settings/assets/settings-B30oMfZq.js +305 -0
- package/static/settings/assets/settings-CSdewNeA.css +1 -0
- package/static/settings/assets/workspace-layout-Dv1Yn9Ci.js +1 -0
- package/static/settings/auth.html +21 -0
- package/static/settings/reachability.html +221 -0
- package/static/settings/reachability.svg +7 -0
- package/static/settings/reachability.webmanifest +18 -0
- package/static/settings/settings.html +13 -0
- package/static/settings/signal-pod.html +293 -0
- package/static/settings/vite.svg +1 -0
- package/dist/api/service/ai-gateway-transport.d.ts +0 -25
- package/dist/api/service/ai-gateway-transport.js +0 -136
- package/dist/api/service/ai-gateway-transport.js.map +0 -1
- package/dist/api/service/chat-protocol-adapters.d.ts +0 -5
- package/dist/api/service/chat-protocol-adapters.js +0 -146
- package/dist/api/service/chat-protocol-adapters.js.map +0 -1
- package/dist/api/service/chat-routing.d.ts +0 -8
- package/dist/api/service/chat-routing.js +0 -16
- package/dist/api/service/chat-routing.js.map +0 -1
- package/dist/api/service/platform-ai-config.d.ts +0 -10
- package/dist/api/service/platform-ai-config.js +0 -76
- package/dist/api/service/platform-ai-config.js.map +0 -1
- package/dist/document/DocumentParser.js.map +0 -1
- package/dist/document/JinaDocumentParser.js.map +0 -1
- package/static/app/assets/index-C1yksyT4.js +0 -171
- package/static/dashboard/assets/dashboard-BssaVKTn.css +0 -1
- package/static/dashboard/assets/dashboard-Ckuadl3C.js +0 -54
|
@@ -0,0 +1,1255 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PostgresRdfTextIndex = void 0;
|
|
4
|
+
const pglite_1 = require("@electric-sql/pglite");
|
|
5
|
+
const PostgresPoolManager_1 = require("../database/PostgresPoolManager");
|
|
6
|
+
const RdfSearchSourceFilter_1 = require("./RdfSearchSourceFilter");
|
|
7
|
+
const PostgresRdfSqlExecutor_1 = require("./PostgresRdfSqlExecutor");
|
|
8
|
+
const RdfTextIndex_1 = require("./RdfTextIndex");
|
|
9
|
+
const PG_NATIVE_FTS_BACKEND_VERSION = 1;
|
|
10
|
+
class PostgresRdfTextIndex {
|
|
11
|
+
constructor(options = {}) {
|
|
12
|
+
this.executor = null;
|
|
13
|
+
this.pglite = null;
|
|
14
|
+
this.pgPool = null;
|
|
15
|
+
this.sharedPoolConfig = null;
|
|
16
|
+
this.initializing = null;
|
|
17
|
+
this.options = {
|
|
18
|
+
...options,
|
|
19
|
+
driver: options.driver ?? (options.connectionString || options.pool ? 'pg' : 'pglite'),
|
|
20
|
+
textSearchBackend: options.textSearchBackend ?? 'posting',
|
|
21
|
+
};
|
|
22
|
+
if (options.autoOpen) {
|
|
23
|
+
void this.open();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async open() {
|
|
27
|
+
if (this.executor) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
this.initializing ??= this.openInternal();
|
|
31
|
+
await this.initializing;
|
|
32
|
+
}
|
|
33
|
+
async close() {
|
|
34
|
+
const executor = this.executor;
|
|
35
|
+
this.executor = null;
|
|
36
|
+
this.initializing = null;
|
|
37
|
+
if (this.sharedPoolConfig) {
|
|
38
|
+
(0, PostgresPoolManager_1.releaseSharedPool)(this.sharedPoolConfig);
|
|
39
|
+
this.sharedPoolConfig = null;
|
|
40
|
+
this.pgPool = null;
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (executor) {
|
|
44
|
+
await executor.close();
|
|
45
|
+
}
|
|
46
|
+
this.pglite = null;
|
|
47
|
+
this.pgPool = null;
|
|
48
|
+
}
|
|
49
|
+
async clear() {
|
|
50
|
+
await this.requireExecutor().exec('DELETE FROM rdf_text_rebuild_status; DELETE FROM rdf_text_entities; DELETE FROM rdf_text_terms; DELETE FROM rdf_text_chunks; DELETE FROM rdf_text_sources;');
|
|
51
|
+
}
|
|
52
|
+
async schemaVersion() {
|
|
53
|
+
const row = await this.requireExecutor()
|
|
54
|
+
.query("SELECT value FROM rdf_text_metadata WHERE key = 'schema_version'");
|
|
55
|
+
return Number(row[0]?.value ?? 0) || 0;
|
|
56
|
+
}
|
|
57
|
+
async sourceMetadata(source) {
|
|
58
|
+
const rows = await this.requireExecutor()
|
|
59
|
+
.query('SELECT * FROM rdf_text_sources WHERE source = $1', [source]);
|
|
60
|
+
return rows[0] ? rdfTextSourceMetadata(rows[0]) : undefined;
|
|
61
|
+
}
|
|
62
|
+
async recordRebuildStatus(input) {
|
|
63
|
+
await this.requireExecutor().exec(`
|
|
64
|
+
INSERT INTO rdf_text_rebuild_status (
|
|
65
|
+
source,
|
|
66
|
+
workspace,
|
|
67
|
+
local_path,
|
|
68
|
+
content_type,
|
|
69
|
+
source_version,
|
|
70
|
+
source_hash,
|
|
71
|
+
status,
|
|
72
|
+
reason,
|
|
73
|
+
message,
|
|
74
|
+
updated_at
|
|
75
|
+
)
|
|
76
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, now())
|
|
77
|
+
ON CONFLICT (source)
|
|
78
|
+
DO UPDATE SET
|
|
79
|
+
workspace = EXCLUDED.workspace,
|
|
80
|
+
local_path = EXCLUDED.local_path,
|
|
81
|
+
content_type = EXCLUDED.content_type,
|
|
82
|
+
source_version = EXCLUDED.source_version,
|
|
83
|
+
source_hash = EXCLUDED.source_hash,
|
|
84
|
+
status = EXCLUDED.status,
|
|
85
|
+
reason = EXCLUDED.reason,
|
|
86
|
+
message = EXCLUDED.message,
|
|
87
|
+
updated_at = EXCLUDED.updated_at
|
|
88
|
+
`, [
|
|
89
|
+
input.source,
|
|
90
|
+
input.workspace,
|
|
91
|
+
input.localPath ?? null,
|
|
92
|
+
input.contentType ?? null,
|
|
93
|
+
input.sourceVersion ?? null,
|
|
94
|
+
input.sourceHash ?? null,
|
|
95
|
+
input.status,
|
|
96
|
+
input.reason ?? null,
|
|
97
|
+
input.message ?? null,
|
|
98
|
+
]);
|
|
99
|
+
}
|
|
100
|
+
async rebuildStatus(source) {
|
|
101
|
+
const rows = await this.requireExecutor()
|
|
102
|
+
.query('SELECT * FROM rdf_text_rebuild_status WHERE source = $1', [source]);
|
|
103
|
+
return rows[0] ? rdfTextRebuildStatus(rows[0]) : undefined;
|
|
104
|
+
}
|
|
105
|
+
async indexText(source, text, chunks) {
|
|
106
|
+
const executor = this.requireExecutor();
|
|
107
|
+
const sourceHash = source.sourceHash ?? (0, RdfTextIndex_1.rdfTextSha256)(text);
|
|
108
|
+
const budgetSkip = (0, RdfTextIndex_1.rdfTextIndexBudgetSkip)(this.options.maxSourceBytes, text);
|
|
109
|
+
if (budgetSkip) {
|
|
110
|
+
await this.deleteSource(source.source);
|
|
111
|
+
await this.recordRebuildStatus({
|
|
112
|
+
...source,
|
|
113
|
+
sourceHash,
|
|
114
|
+
status: 'skipped',
|
|
115
|
+
reason: budgetSkip.reason,
|
|
116
|
+
message: budgetSkip.message,
|
|
117
|
+
});
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const chunkCap = (0, RdfTextIndex_1.rdfTextIndexChunkCap)(this.options.maxChunksPerSource, chunks ?? (0, RdfTextIndex_1.chunkRdfTextSource)(source, text));
|
|
121
|
+
const indexedChunks = chunkCap.chunks;
|
|
122
|
+
await executor.transaction(async (tx) => {
|
|
123
|
+
const sourceId = await this.upsertSource(tx, {
|
|
124
|
+
...source,
|
|
125
|
+
sourceHash,
|
|
126
|
+
});
|
|
127
|
+
await tx.exec('DELETE FROM rdf_text_entities WHERE source_id = $1', [sourceId]);
|
|
128
|
+
await tx.exec('DELETE FROM rdf_text_terms WHERE source_id = $1', [sourceId]);
|
|
129
|
+
await tx.exec('DELETE FROM rdf_text_chunks WHERE source_id = $1', [sourceId]);
|
|
130
|
+
for (const chunk of indexedChunks) {
|
|
131
|
+
const normalizedText = (0, RdfTextIndex_1.normalizeRdfText)(chunk.content);
|
|
132
|
+
const chunkRows = await tx.query(`
|
|
133
|
+
INSERT INTO rdf_text_chunks (
|
|
134
|
+
source_id,
|
|
135
|
+
chunk_key,
|
|
136
|
+
retrieval_kind,
|
|
137
|
+
ordinal,
|
|
138
|
+
level,
|
|
139
|
+
heading,
|
|
140
|
+
path,
|
|
141
|
+
content,
|
|
142
|
+
start_offset,
|
|
143
|
+
end_offset,
|
|
144
|
+
normalized_text,
|
|
145
|
+
token_count,
|
|
146
|
+
updated_at
|
|
147
|
+
)
|
|
148
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, now())
|
|
149
|
+
RETURNING id
|
|
150
|
+
`, [
|
|
151
|
+
sourceId,
|
|
152
|
+
chunk.chunkKey,
|
|
153
|
+
chunk.retrievalKind ?? 'file-chunk',
|
|
154
|
+
chunk.ordinal,
|
|
155
|
+
chunk.level,
|
|
156
|
+
chunk.heading || null,
|
|
157
|
+
JSON.stringify(chunk.path ?? []),
|
|
158
|
+
chunk.content,
|
|
159
|
+
chunk.startOffset,
|
|
160
|
+
chunk.endOffset,
|
|
161
|
+
normalizedText,
|
|
162
|
+
(0, RdfTextIndex_1.normalizedRdfTextTokenCount)(normalizedText),
|
|
163
|
+
]);
|
|
164
|
+
const chunkId = Number(chunkRows[0]?.id);
|
|
165
|
+
if (!Number.isFinite(chunkId)) {
|
|
166
|
+
throw new Error(`Failed to insert RDF text chunk for source: ${source.source}`);
|
|
167
|
+
}
|
|
168
|
+
await insertTermOccurrences(tx, sourceId, chunkId, normalizedText);
|
|
169
|
+
await insertEntityMentions(tx, sourceId, chunkId, chunk.entities);
|
|
170
|
+
if (this.nativeFtsEnabled()) {
|
|
171
|
+
await upsertNativeFtsChunk(tx, chunkId, chunk);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
if (chunkCap.capped) {
|
|
176
|
+
await this.recordRebuildStatus({
|
|
177
|
+
...source,
|
|
178
|
+
sourceHash,
|
|
179
|
+
status: 'capped',
|
|
180
|
+
reason: chunkCap.capped.reason,
|
|
181
|
+
message: chunkCap.capped.message,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
async moveSource(oldSource, next) {
|
|
186
|
+
const executor = this.requireExecutor();
|
|
187
|
+
return await executor.transaction(async (tx) => {
|
|
188
|
+
const oldRows = await tx.query('SELECT * FROM rdf_text_sources WHERE source = $1', [oldSource]);
|
|
189
|
+
const oldRow = oldRows[0];
|
|
190
|
+
if (!oldRow) {
|
|
191
|
+
return 0;
|
|
192
|
+
}
|
|
193
|
+
const oldId = Number(oldRow.id);
|
|
194
|
+
const countRows = await tx.query('SELECT COUNT(*) AS count FROM rdf_text_chunks WHERE source_id = $1', [oldId]);
|
|
195
|
+
const targetRows = await tx.query('SELECT * FROM rdf_text_sources WHERE source = $1', [next.source]);
|
|
196
|
+
const targetRow = targetRows[0];
|
|
197
|
+
if (targetRow && Number(targetRow.id) !== oldId) {
|
|
198
|
+
const targetId = Number(targetRow.id);
|
|
199
|
+
await tx.exec('DELETE FROM rdf_text_entities WHERE source_id = $1', [targetId]);
|
|
200
|
+
await tx.exec('DELETE FROM rdf_text_terms WHERE source_id = $1', [targetId]);
|
|
201
|
+
await tx.exec('DELETE FROM rdf_text_chunks WHERE source_id = $1', [targetId]);
|
|
202
|
+
await tx.exec('DELETE FROM rdf_text_sources WHERE id = $1', [targetId]);
|
|
203
|
+
}
|
|
204
|
+
await tx.exec(`
|
|
205
|
+
UPDATE rdf_text_sources
|
|
206
|
+
SET
|
|
207
|
+
source_key = $1,
|
|
208
|
+
source = $2,
|
|
209
|
+
workspace = $3,
|
|
210
|
+
local_path = $4,
|
|
211
|
+
content_type = $5,
|
|
212
|
+
source_version = $6,
|
|
213
|
+
source_hash = $7,
|
|
214
|
+
updated_at = now()
|
|
215
|
+
WHERE id = $8
|
|
216
|
+
`, [
|
|
217
|
+
next.sourceKey ?? oldRow.source_key ?? oldRow.source,
|
|
218
|
+
next.source,
|
|
219
|
+
next.workspace,
|
|
220
|
+
next.localPath ?? null,
|
|
221
|
+
next.contentType ?? null,
|
|
222
|
+
next.sourceVersion ?? null,
|
|
223
|
+
next.sourceHash ?? null,
|
|
224
|
+
oldId,
|
|
225
|
+
]);
|
|
226
|
+
await tx.exec(`
|
|
227
|
+
UPDATE rdf_text_rebuild_status
|
|
228
|
+
SET
|
|
229
|
+
source = $1,
|
|
230
|
+
workspace = $2,
|
|
231
|
+
local_path = $3,
|
|
232
|
+
content_type = $4,
|
|
233
|
+
source_version = $5,
|
|
234
|
+
source_hash = $6,
|
|
235
|
+
updated_at = now()
|
|
236
|
+
WHERE source = $7
|
|
237
|
+
`, [
|
|
238
|
+
next.source,
|
|
239
|
+
next.workspace,
|
|
240
|
+
next.localPath ?? null,
|
|
241
|
+
next.contentType ?? null,
|
|
242
|
+
next.sourceVersion ?? null,
|
|
243
|
+
next.sourceHash ?? null,
|
|
244
|
+
oldSource,
|
|
245
|
+
]);
|
|
246
|
+
return Math.max(Number(countRows[0]?.count ?? 0), 1);
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
async deleteSource(source) {
|
|
250
|
+
const executor = this.requireExecutor();
|
|
251
|
+
const rows = await executor.query('SELECT id FROM rdf_text_sources WHERE source = $1', [source]);
|
|
252
|
+
const id = Number(rows[0]?.id);
|
|
253
|
+
if (!Number.isFinite(id)) {
|
|
254
|
+
return 0;
|
|
255
|
+
}
|
|
256
|
+
return await executor.transaction(async (tx) => {
|
|
257
|
+
await tx.exec('DELETE FROM rdf_text_entities WHERE source_id = $1', [id]);
|
|
258
|
+
await tx.exec('DELETE FROM rdf_text_terms WHERE source_id = $1', [id]);
|
|
259
|
+
const deletedRows = await tx.query('SELECT COUNT(*) AS count FROM rdf_text_chunks WHERE source_id = $1', [id]);
|
|
260
|
+
await tx.exec('DELETE FROM rdf_text_chunks WHERE source_id = $1', [id]);
|
|
261
|
+
await tx.exec('DELETE FROM rdf_text_sources WHERE id = $1', [id]);
|
|
262
|
+
return Number(deletedRows[0]?.count ?? 0);
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
async search(options) {
|
|
266
|
+
const query = (0, RdfTextIndex_1.normalizeRdfText)(options.query);
|
|
267
|
+
const entityFilter = normalizeEntityFilter(options.entities);
|
|
268
|
+
if (!query && entityFilter.length === 0) {
|
|
269
|
+
return [];
|
|
270
|
+
}
|
|
271
|
+
if (this.canUseNativeFts(query)) {
|
|
272
|
+
return await this.searchNativeFts(options, query, entityFilter);
|
|
273
|
+
}
|
|
274
|
+
const params = [];
|
|
275
|
+
const predicate = query ? buildTextSearchPredicate(query, params) : undefined;
|
|
276
|
+
const conditions = predicate ? [predicate.sql] : ['1 = 1'];
|
|
277
|
+
appendEntitySearchFilter(entityFilter, conditions, params);
|
|
278
|
+
if (options.workspace) {
|
|
279
|
+
conditions.push(`source.workspace = ${addParam(params, options.workspace)}`);
|
|
280
|
+
}
|
|
281
|
+
(0, RdfSearchSourceFilter_1.appendPgRdfSearchSourceFilters)(options, conditions, params);
|
|
282
|
+
const scoreExpression = pgTextSearchScoreExpression(query, params);
|
|
283
|
+
const orderBy = pgTextSearchOrderBy(options.orderBy);
|
|
284
|
+
const perSourceLimit = (0, RdfTextIndex_1.normalizeRdfTextPerSourceLimit)(options.perSourceLimit);
|
|
285
|
+
const perSourceCondition = perSourceLimit === undefined
|
|
286
|
+
? ''
|
|
287
|
+
: `WHERE source_rank <= ${addParam(params, perSourceLimit)}`;
|
|
288
|
+
const window = pgTextSearchWindow(options, params);
|
|
289
|
+
const sql = perSourceLimit === undefined
|
|
290
|
+
? `
|
|
291
|
+
SELECT
|
|
292
|
+
chunk.id,
|
|
293
|
+
chunk.source_id,
|
|
294
|
+
source.source_key,
|
|
295
|
+
source.source,
|
|
296
|
+
source.workspace,
|
|
297
|
+
source.local_path,
|
|
298
|
+
source.content_type,
|
|
299
|
+
source.source_version,
|
|
300
|
+
source.source_hash,
|
|
301
|
+
chunk.chunk_key,
|
|
302
|
+
chunk.retrieval_kind,
|
|
303
|
+
chunk.ordinal,
|
|
304
|
+
chunk.level,
|
|
305
|
+
chunk.heading,
|
|
306
|
+
chunk.path,
|
|
307
|
+
chunk.content,
|
|
308
|
+
chunk.start_offset,
|
|
309
|
+
chunk.end_offset,
|
|
310
|
+
chunk.normalized_text,
|
|
311
|
+
chunk.token_count,
|
|
312
|
+
chunk.updated_at,
|
|
313
|
+
${scoreExpression} AS score
|
|
314
|
+
FROM rdf_text_chunks chunk
|
|
315
|
+
JOIN rdf_text_sources source ON source.id = chunk.source_id
|
|
316
|
+
WHERE ${conditions.join(' AND ')}
|
|
317
|
+
ORDER BY ${orderBy}, chunk.source_id ASC, chunk.ordinal ASC
|
|
318
|
+
${window}
|
|
319
|
+
`
|
|
320
|
+
: `
|
|
321
|
+
WITH matched AS (
|
|
322
|
+
SELECT
|
|
323
|
+
chunk.id,
|
|
324
|
+
chunk.source_id,
|
|
325
|
+
source.source_key,
|
|
326
|
+
source.source,
|
|
327
|
+
source.workspace,
|
|
328
|
+
source.local_path,
|
|
329
|
+
source.content_type,
|
|
330
|
+
source.source_version,
|
|
331
|
+
source.source_hash,
|
|
332
|
+
chunk.chunk_key,
|
|
333
|
+
chunk.retrieval_kind,
|
|
334
|
+
chunk.ordinal,
|
|
335
|
+
chunk.level,
|
|
336
|
+
chunk.heading,
|
|
337
|
+
chunk.path,
|
|
338
|
+
chunk.content,
|
|
339
|
+
chunk.start_offset,
|
|
340
|
+
chunk.end_offset,
|
|
341
|
+
chunk.normalized_text,
|
|
342
|
+
chunk.token_count,
|
|
343
|
+
chunk.updated_at,
|
|
344
|
+
${scoreExpression} AS score
|
|
345
|
+
FROM rdf_text_chunks chunk
|
|
346
|
+
JOIN rdf_text_sources source ON source.id = chunk.source_id
|
|
347
|
+
WHERE ${conditions.join(' AND ')}
|
|
348
|
+
),
|
|
349
|
+
ranked AS (
|
|
350
|
+
SELECT
|
|
351
|
+
matched.*,
|
|
352
|
+
ROW_NUMBER() OVER (
|
|
353
|
+
PARTITION BY source
|
|
354
|
+
ORDER BY ${pgTextSearchResultOrderBy(options.orderBy)}, source_id ASC, ordinal ASC
|
|
355
|
+
) AS source_rank
|
|
356
|
+
FROM matched
|
|
357
|
+
)
|
|
358
|
+
SELECT
|
|
359
|
+
id,
|
|
360
|
+
source_id,
|
|
361
|
+
source_key,
|
|
362
|
+
source,
|
|
363
|
+
workspace,
|
|
364
|
+
local_path,
|
|
365
|
+
content_type,
|
|
366
|
+
source_version,
|
|
367
|
+
source_hash,
|
|
368
|
+
chunk_key,
|
|
369
|
+
retrieval_kind,
|
|
370
|
+
ordinal,
|
|
371
|
+
level,
|
|
372
|
+
heading,
|
|
373
|
+
path,
|
|
374
|
+
content,
|
|
375
|
+
start_offset,
|
|
376
|
+
end_offset,
|
|
377
|
+
normalized_text,
|
|
378
|
+
token_count,
|
|
379
|
+
updated_at,
|
|
380
|
+
score
|
|
381
|
+
FROM ranked
|
|
382
|
+
${perSourceCondition}
|
|
383
|
+
ORDER BY ${pgTextSearchResultOrderBy(options.orderBy)}, source_id ASC, ordinal ASC
|
|
384
|
+
${window}
|
|
385
|
+
`;
|
|
386
|
+
const rows = await this.requireExecutor().query(sql, params);
|
|
387
|
+
const normalizedRows = rows.map((row) => ({
|
|
388
|
+
row: normalizeTextChunkRow(row),
|
|
389
|
+
score: Number(row.score),
|
|
390
|
+
}));
|
|
391
|
+
const entities = await this.entitiesForChunks(normalizedRows.map((result) => result.row.id));
|
|
392
|
+
return normalizedRows.map((result) => toSearchResult(result.row, query, result.score, entities.get(result.row.id) ?? []));
|
|
393
|
+
}
|
|
394
|
+
async estimateSearchCardinality(options) {
|
|
395
|
+
const query = (0, RdfTextIndex_1.normalizeRdfText)(options.query);
|
|
396
|
+
const entityFilter = normalizeEntityFilter(options.entities);
|
|
397
|
+
if (!query && entityFilter.length === 0) {
|
|
398
|
+
return {
|
|
399
|
+
rows: 0,
|
|
400
|
+
source: 'text-normalized-scan',
|
|
401
|
+
indexChoice: 'text-normalized-scan',
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
if (this.canUseNativeFts(query)) {
|
|
405
|
+
return await this.estimateNativeFtsSearchCardinality(options, query, entityFilter);
|
|
406
|
+
}
|
|
407
|
+
const params = [];
|
|
408
|
+
const predicate = query ? buildTextSearchPredicate(query, params) : undefined;
|
|
409
|
+
const conditions = predicate ? [predicate.sql] : ['1 = 1'];
|
|
410
|
+
appendEntitySearchFilter(entityFilter, conditions, params);
|
|
411
|
+
if (options.workspace) {
|
|
412
|
+
conditions.push(`source.workspace = ${addParam(params, options.workspace)}`);
|
|
413
|
+
}
|
|
414
|
+
(0, RdfSearchSourceFilter_1.appendPgRdfSearchSourceFilters)(options, conditions, params);
|
|
415
|
+
const perSourceLimit = (0, RdfTextIndex_1.normalizeRdfTextPerSourceLimit)(options.perSourceLimit);
|
|
416
|
+
const rows = perSourceLimit === undefined
|
|
417
|
+
? await this.requireExecutor().query(`
|
|
418
|
+
SELECT COUNT(*) AS count
|
|
419
|
+
FROM rdf_text_chunks chunk
|
|
420
|
+
JOIN rdf_text_sources source ON source.id = chunk.source_id
|
|
421
|
+
WHERE ${conditions.join(' AND ')}
|
|
422
|
+
`, params)
|
|
423
|
+
: await this.requireExecutor().query(`
|
|
424
|
+
SELECT COALESCE(SUM(CASE WHEN source_count > ${addParam(params, perSourceLimit)} THEN ${addParam(params, perSourceLimit)} ELSE source_count END), 0) AS count
|
|
425
|
+
FROM (
|
|
426
|
+
SELECT chunk.source_id, COUNT(*) AS source_count
|
|
427
|
+
FROM rdf_text_chunks chunk
|
|
428
|
+
JOIN rdf_text_sources source ON source.id = chunk.source_id
|
|
429
|
+
WHERE ${conditions.join(' AND ')}
|
|
430
|
+
GROUP BY chunk.source_id
|
|
431
|
+
) capped
|
|
432
|
+
`, params);
|
|
433
|
+
return {
|
|
434
|
+
rows: (0, RdfTextIndex_1.applyRdfTextResultWindow)(Number(rows[0]?.count ?? 0), options.offset, options.limit),
|
|
435
|
+
source: predicate?.indexChoice ?? 'text-term-posting',
|
|
436
|
+
indexChoice: predicate?.indexChoice ?? 'text-entity-posting',
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
async searchNativeFts(options, query, entityFilter) {
|
|
440
|
+
const params = [];
|
|
441
|
+
const tsQuery = `websearch_to_tsquery('simple', ${addParam(params, query)})`;
|
|
442
|
+
const conditions = [`fts.fts_vector @@ ${tsQuery}`];
|
|
443
|
+
appendEntitySearchFilter(entityFilter, conditions, params);
|
|
444
|
+
if (options.workspace) {
|
|
445
|
+
conditions.push(`source.workspace = ${addParam(params, options.workspace)}`);
|
|
446
|
+
}
|
|
447
|
+
(0, RdfSearchSourceFilter_1.appendPgRdfSearchSourceFilters)(options, conditions, params);
|
|
448
|
+
const scoreExpression = `ts_rank_cd(fts.fts_vector, ${tsQuery})`;
|
|
449
|
+
const orderBy = pgTextSearchOrderBy(options.orderBy);
|
|
450
|
+
const perSourceLimit = (0, RdfTextIndex_1.normalizeRdfTextPerSourceLimit)(options.perSourceLimit);
|
|
451
|
+
const perSourceCondition = perSourceLimit === undefined
|
|
452
|
+
? ''
|
|
453
|
+
: `WHERE source_rank <= ${addParam(params, perSourceLimit)}`;
|
|
454
|
+
const window = pgTextSearchWindow(options, params);
|
|
455
|
+
const matchedSelect = `
|
|
456
|
+
SELECT
|
|
457
|
+
chunk.id,
|
|
458
|
+
chunk.source_id,
|
|
459
|
+
source.source_key,
|
|
460
|
+
source.source,
|
|
461
|
+
source.workspace,
|
|
462
|
+
source.local_path,
|
|
463
|
+
source.content_type,
|
|
464
|
+
source.source_version,
|
|
465
|
+
source.source_hash,
|
|
466
|
+
chunk.chunk_key,
|
|
467
|
+
chunk.retrieval_kind,
|
|
468
|
+
chunk.ordinal,
|
|
469
|
+
chunk.level,
|
|
470
|
+
chunk.heading,
|
|
471
|
+
chunk.path,
|
|
472
|
+
chunk.content,
|
|
473
|
+
chunk.start_offset,
|
|
474
|
+
chunk.end_offset,
|
|
475
|
+
chunk.normalized_text,
|
|
476
|
+
chunk.token_count,
|
|
477
|
+
chunk.updated_at,
|
|
478
|
+
${scoreExpression} AS score
|
|
479
|
+
FROM rdf_text_fts_pg fts
|
|
480
|
+
JOIN rdf_text_chunks chunk ON chunk.id = fts.chunk_id
|
|
481
|
+
JOIN rdf_text_sources source ON source.id = chunk.source_id
|
|
482
|
+
WHERE ${conditions.join(' AND ')}
|
|
483
|
+
`;
|
|
484
|
+
const sql = perSourceLimit === undefined
|
|
485
|
+
? `
|
|
486
|
+
${matchedSelect}
|
|
487
|
+
ORDER BY ${orderBy}, chunk.source_id ASC, chunk.ordinal ASC
|
|
488
|
+
${window}
|
|
489
|
+
`
|
|
490
|
+
: `
|
|
491
|
+
WITH matched AS (
|
|
492
|
+
${matchedSelect}
|
|
493
|
+
),
|
|
494
|
+
ranked AS (
|
|
495
|
+
SELECT
|
|
496
|
+
matched.*,
|
|
497
|
+
ROW_NUMBER() OVER (
|
|
498
|
+
PARTITION BY source
|
|
499
|
+
ORDER BY ${pgTextSearchResultOrderBy(options.orderBy)}, source_id ASC, ordinal ASC
|
|
500
|
+
) AS source_rank
|
|
501
|
+
FROM matched
|
|
502
|
+
)
|
|
503
|
+
SELECT
|
|
504
|
+
id,
|
|
505
|
+
source_id,
|
|
506
|
+
source_key,
|
|
507
|
+
source,
|
|
508
|
+
workspace,
|
|
509
|
+
local_path,
|
|
510
|
+
content_type,
|
|
511
|
+
source_version,
|
|
512
|
+
source_hash,
|
|
513
|
+
chunk_key,
|
|
514
|
+
retrieval_kind,
|
|
515
|
+
ordinal,
|
|
516
|
+
level,
|
|
517
|
+
heading,
|
|
518
|
+
path,
|
|
519
|
+
content,
|
|
520
|
+
start_offset,
|
|
521
|
+
end_offset,
|
|
522
|
+
normalized_text,
|
|
523
|
+
token_count,
|
|
524
|
+
updated_at,
|
|
525
|
+
score
|
|
526
|
+
FROM ranked
|
|
527
|
+
${perSourceCondition}
|
|
528
|
+
ORDER BY ${pgTextSearchResultOrderBy(options.orderBy)}, source_id ASC, ordinal ASC
|
|
529
|
+
${window}
|
|
530
|
+
`;
|
|
531
|
+
const rows = await this.requireExecutor().query(sql, params);
|
|
532
|
+
const normalizedRows = rows.map((row) => ({
|
|
533
|
+
row: normalizeTextChunkRow(row),
|
|
534
|
+
score: Number(row.score),
|
|
535
|
+
}));
|
|
536
|
+
const entities = await this.entitiesForChunks(normalizedRows.map((result) => result.row.id));
|
|
537
|
+
return normalizedRows.map((result) => toSearchResult(result.row, query, result.score, entities.get(result.row.id) ?? [], 'pg-ts-rank-cd'));
|
|
538
|
+
}
|
|
539
|
+
async estimateNativeFtsSearchCardinality(options, query, entityFilter) {
|
|
540
|
+
const params = [];
|
|
541
|
+
const tsQuery = `websearch_to_tsquery('simple', ${addParam(params, query)})`;
|
|
542
|
+
const conditions = [`fts.fts_vector @@ ${tsQuery}`];
|
|
543
|
+
appendEntitySearchFilter(entityFilter, conditions, params);
|
|
544
|
+
if (options.workspace) {
|
|
545
|
+
conditions.push(`source.workspace = ${addParam(params, options.workspace)}`);
|
|
546
|
+
}
|
|
547
|
+
(0, RdfSearchSourceFilter_1.appendPgRdfSearchSourceFilters)(options, conditions, params);
|
|
548
|
+
const perSourceLimit = (0, RdfTextIndex_1.normalizeRdfTextPerSourceLimit)(options.perSourceLimit);
|
|
549
|
+
const rows = perSourceLimit === undefined
|
|
550
|
+
? await this.requireExecutor().query(`
|
|
551
|
+
SELECT COUNT(*) AS count
|
|
552
|
+
FROM rdf_text_fts_pg fts
|
|
553
|
+
JOIN rdf_text_chunks chunk ON chunk.id = fts.chunk_id
|
|
554
|
+
JOIN rdf_text_sources source ON source.id = chunk.source_id
|
|
555
|
+
WHERE ${conditions.join(' AND ')}
|
|
556
|
+
`, params)
|
|
557
|
+
: await this.requireExecutor().query(`
|
|
558
|
+
SELECT COALESCE(SUM(CASE WHEN source_count > ${addParam(params, perSourceLimit)} THEN ${addParam(params, perSourceLimit)} ELSE source_count END), 0) AS count
|
|
559
|
+
FROM (
|
|
560
|
+
SELECT chunk.source_id, COUNT(*) AS source_count
|
|
561
|
+
FROM rdf_text_fts_pg fts
|
|
562
|
+
JOIN rdf_text_chunks chunk ON chunk.id = fts.chunk_id
|
|
563
|
+
JOIN rdf_text_sources source ON source.id = chunk.source_id
|
|
564
|
+
WHERE ${conditions.join(' AND ')}
|
|
565
|
+
GROUP BY chunk.source_id
|
|
566
|
+
) capped
|
|
567
|
+
`, params);
|
|
568
|
+
return {
|
|
569
|
+
rows: (0, RdfTextIndex_1.applyRdfTextResultWindow)(Number(rows[0]?.count ?? 0), options.offset, options.limit),
|
|
570
|
+
source: 'pg-native-fts',
|
|
571
|
+
indexChoice: 'pg-native-fts',
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
async stats() {
|
|
575
|
+
const [sourceRows, chunkRows, entityRows] = await Promise.all([
|
|
576
|
+
this.requireExecutor().query('SELECT COUNT(*) AS count FROM rdf_text_sources'),
|
|
577
|
+
this.requireExecutor().query('SELECT COUNT(*) AS count FROM rdf_text_chunks'),
|
|
578
|
+
this.requireExecutor().query('SELECT COUNT(*) AS count FROM rdf_text_entities'),
|
|
579
|
+
]);
|
|
580
|
+
return {
|
|
581
|
+
sourceCount: Number(sourceRows[0]?.count ?? 0),
|
|
582
|
+
chunkCount: Number(chunkRows[0]?.count ?? 0),
|
|
583
|
+
entityMentionCount: Number(entityRows[0]?.count ?? 0),
|
|
584
|
+
databaseBytes: await this.estimateDatabaseBytes(),
|
|
585
|
+
termDocumentFrequency: await this.termDocumentFrequency(),
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
async termDocumentFrequency(limit = 100) {
|
|
589
|
+
const rows = await this.requireExecutor().query(`
|
|
590
|
+
SELECT
|
|
591
|
+
term,
|
|
592
|
+
COUNT(DISTINCT source_id) AS source_count,
|
|
593
|
+
COUNT(*) AS chunk_count,
|
|
594
|
+
COALESCE(SUM(occurrences), 0) AS total_occurrences
|
|
595
|
+
FROM rdf_text_terms
|
|
596
|
+
GROUP BY term
|
|
597
|
+
ORDER BY source_count DESC, chunk_count DESC, total_occurrences DESC, term ASC
|
|
598
|
+
LIMIT $1
|
|
599
|
+
`, [Math.max(0, limit)]);
|
|
600
|
+
return rows.map((row) => ({
|
|
601
|
+
term: row.term,
|
|
602
|
+
sourceCount: Number(row.source_count),
|
|
603
|
+
chunkCount: Number(row.chunk_count),
|
|
604
|
+
totalOccurrences: Number(row.total_occurrences),
|
|
605
|
+
}));
|
|
606
|
+
}
|
|
607
|
+
async openInternal() {
|
|
608
|
+
if (this.options.driver === 'pglite') {
|
|
609
|
+
this.pglite = new pglite_1.PGlite(this.options.dataDir);
|
|
610
|
+
this.executor = new PostgresRdfSqlExecutor_1.PgliteRdfSqlExecutor(this.pglite);
|
|
611
|
+
}
|
|
612
|
+
else if (this.options.pool) {
|
|
613
|
+
this.pgPool = this.options.pool;
|
|
614
|
+
this.executor = new PostgresRdfSqlExecutor_1.PgPoolRdfSqlExecutor(this.pgPool);
|
|
615
|
+
}
|
|
616
|
+
else {
|
|
617
|
+
this.sharedPoolConfig = {
|
|
618
|
+
connectionString: this.options.connectionString,
|
|
619
|
+
host: this.options.host,
|
|
620
|
+
port: this.options.port,
|
|
621
|
+
database: this.options.database,
|
|
622
|
+
user: this.options.user,
|
|
623
|
+
password: this.options.password,
|
|
624
|
+
};
|
|
625
|
+
this.pgPool = (0, PostgresPoolManager_1.getSharedPool)(this.sharedPoolConfig);
|
|
626
|
+
this.executor = new PostgresRdfSqlExecutor_1.PgPoolRdfSqlExecutor(this.pgPool);
|
|
627
|
+
}
|
|
628
|
+
await this.initializeSchema();
|
|
629
|
+
}
|
|
630
|
+
async initializeSchema() {
|
|
631
|
+
await this.requireExecutor().exec(`
|
|
632
|
+
CREATE TABLE IF NOT EXISTS rdf_text_metadata (
|
|
633
|
+
key TEXT PRIMARY KEY,
|
|
634
|
+
value TEXT NOT NULL
|
|
635
|
+
);
|
|
636
|
+
|
|
637
|
+
CREATE TABLE IF NOT EXISTS rdf_text_sources (
|
|
638
|
+
id BIGSERIAL PRIMARY KEY,
|
|
639
|
+
source_key TEXT,
|
|
640
|
+
source TEXT NOT NULL UNIQUE,
|
|
641
|
+
workspace TEXT NOT NULL,
|
|
642
|
+
local_path TEXT,
|
|
643
|
+
content_type TEXT,
|
|
644
|
+
source_version TEXT,
|
|
645
|
+
source_hash TEXT,
|
|
646
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
647
|
+
);
|
|
648
|
+
|
|
649
|
+
CREATE TABLE IF NOT EXISTS rdf_text_rebuild_status (
|
|
650
|
+
source TEXT PRIMARY KEY,
|
|
651
|
+
workspace TEXT NOT NULL,
|
|
652
|
+
local_path TEXT,
|
|
653
|
+
content_type TEXT,
|
|
654
|
+
source_version TEXT,
|
|
655
|
+
source_hash TEXT,
|
|
656
|
+
status TEXT NOT NULL,
|
|
657
|
+
reason TEXT,
|
|
658
|
+
message TEXT,
|
|
659
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
660
|
+
);
|
|
661
|
+
|
|
662
|
+
CREATE TABLE IF NOT EXISTS rdf_text_chunks (
|
|
663
|
+
id BIGSERIAL PRIMARY KEY,
|
|
664
|
+
source_id BIGINT NOT NULL REFERENCES rdf_text_sources(id) ON DELETE CASCADE,
|
|
665
|
+
chunk_key TEXT NOT NULL,
|
|
666
|
+
retrieval_kind TEXT NOT NULL DEFAULT 'file-chunk',
|
|
667
|
+
ordinal INTEGER NOT NULL,
|
|
668
|
+
level INTEGER NOT NULL,
|
|
669
|
+
heading TEXT,
|
|
670
|
+
path TEXT,
|
|
671
|
+
content TEXT NOT NULL,
|
|
672
|
+
start_offset INTEGER NOT NULL,
|
|
673
|
+
end_offset INTEGER NOT NULL,
|
|
674
|
+
normalized_text TEXT NOT NULL,
|
|
675
|
+
token_count INTEGER NOT NULL,
|
|
676
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
677
|
+
UNIQUE (source_id, chunk_key)
|
|
678
|
+
);
|
|
679
|
+
|
|
680
|
+
CREATE TABLE IF NOT EXISTS rdf_text_terms (
|
|
681
|
+
id BIGSERIAL PRIMARY KEY,
|
|
682
|
+
term TEXT NOT NULL CHECK (length(term) <= ${RdfTextIndex_1.RDF_TEXT_TERM_MAX_INDEX_LENGTH}),
|
|
683
|
+
source_id BIGINT NOT NULL REFERENCES rdf_text_sources(id) ON DELETE CASCADE,
|
|
684
|
+
chunk_id BIGINT NOT NULL REFERENCES rdf_text_chunks(id) ON DELETE CASCADE,
|
|
685
|
+
occurrences INTEGER NOT NULL,
|
|
686
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
687
|
+
UNIQUE (term, chunk_id)
|
|
688
|
+
);
|
|
689
|
+
|
|
690
|
+
CREATE TABLE IF NOT EXISTS rdf_text_entities (
|
|
691
|
+
id BIGSERIAL PRIMARY KEY,
|
|
692
|
+
entity TEXT NOT NULL,
|
|
693
|
+
source_id BIGINT NOT NULL REFERENCES rdf_text_sources(id) ON DELETE CASCADE,
|
|
694
|
+
chunk_id BIGINT NOT NULL REFERENCES rdf_text_chunks(id) ON DELETE CASCADE,
|
|
695
|
+
predicate TEXT,
|
|
696
|
+
label TEXT,
|
|
697
|
+
value TEXT,
|
|
698
|
+
datatype TEXT,
|
|
699
|
+
language TEXT,
|
|
700
|
+
policy_role TEXT,
|
|
701
|
+
occurrences INTEGER NOT NULL DEFAULT 1,
|
|
702
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
703
|
+
);
|
|
704
|
+
|
|
705
|
+
ALTER TABLE rdf_text_sources ADD COLUMN IF NOT EXISTS source_key TEXT;
|
|
706
|
+
UPDATE rdf_text_sources SET source_key = source WHERE source_key IS NULL;
|
|
707
|
+
ALTER TABLE rdf_text_chunks ADD COLUMN IF NOT EXISTS retrieval_kind TEXT NOT NULL DEFAULT 'file-chunk';
|
|
708
|
+
ALTER TABLE rdf_text_entities ADD COLUMN IF NOT EXISTS value TEXT;
|
|
709
|
+
ALTER TABLE rdf_text_entities ADD COLUMN IF NOT EXISTS datatype TEXT;
|
|
710
|
+
ALTER TABLE rdf_text_entities ADD COLUMN IF NOT EXISTS language TEXT;
|
|
711
|
+
ALTER TABLE rdf_text_entities ADD COLUMN IF NOT EXISTS policy_role TEXT;
|
|
712
|
+
|
|
713
|
+
CREATE INDEX IF NOT EXISTS rdf_text_sources_workspace ON rdf_text_sources(workspace);
|
|
714
|
+
CREATE INDEX IF NOT EXISTS rdf_text_sources_source ON rdf_text_sources(source);
|
|
715
|
+
CREATE INDEX IF NOT EXISTS rdf_text_sources_local_path ON rdf_text_sources(local_path);
|
|
716
|
+
CREATE INDEX IF NOT EXISTS rdf_text_sources_workspace_local_path ON rdf_text_sources(workspace, local_path);
|
|
717
|
+
CREATE INDEX IF NOT EXISTS rdf_text_chunks_source ON rdf_text_chunks(source_id, ordinal);
|
|
718
|
+
DELETE FROM rdf_text_terms WHERE length(term) > ${RdfTextIndex_1.RDF_TEXT_TERM_MAX_INDEX_LENGTH};
|
|
719
|
+
CREATE INDEX IF NOT EXISTS rdf_text_terms_term ON rdf_text_terms(term);
|
|
720
|
+
CREATE INDEX IF NOT EXISTS rdf_text_terms_source_term ON rdf_text_terms(source_id, term);
|
|
721
|
+
CREATE INDEX IF NOT EXISTS rdf_text_terms_chunk ON rdf_text_terms(chunk_id);
|
|
722
|
+
CREATE INDEX IF NOT EXISTS rdf_text_entities_entity ON rdf_text_entities(entity);
|
|
723
|
+
CREATE INDEX IF NOT EXISTS rdf_text_entities_source_entity ON rdf_text_entities(source_id, entity);
|
|
724
|
+
CREATE INDEX IF NOT EXISTS rdf_text_entities_chunk ON rdf_text_entities(chunk_id);
|
|
725
|
+
|
|
726
|
+
INSERT INTO rdf_text_metadata (key, value)
|
|
727
|
+
VALUES ('schema_version', '${RdfTextIndex_1.RDF_TEXT_SCHEMA_VERSION}')
|
|
728
|
+
ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value;
|
|
729
|
+
`);
|
|
730
|
+
await this.backfillTermPostings();
|
|
731
|
+
if (this.nativeFtsEnabled()) {
|
|
732
|
+
await this.initializeNativeFtsSchema();
|
|
733
|
+
await this.backfillNativeFtsRows();
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
async initializeNativeFtsSchema() {
|
|
737
|
+
await this.requireExecutor().exec(`
|
|
738
|
+
CREATE TABLE IF NOT EXISTS rdf_text_fts_pg (
|
|
739
|
+
chunk_id BIGINT PRIMARY KEY REFERENCES rdf_text_chunks(id) ON DELETE CASCADE,
|
|
740
|
+
backend_version INTEGER NOT NULL,
|
|
741
|
+
config REGCONFIG NOT NULL,
|
|
742
|
+
projection_hash TEXT NOT NULL,
|
|
743
|
+
fts_vector TSVECTOR NOT NULL,
|
|
744
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
745
|
+
);
|
|
746
|
+
|
|
747
|
+
CREATE INDEX IF NOT EXISTS rdf_text_fts_pg_vector_gin
|
|
748
|
+
ON rdf_text_fts_pg USING GIN (fts_vector);
|
|
749
|
+
|
|
750
|
+
CREATE INDEX IF NOT EXISTS rdf_text_fts_pg_config
|
|
751
|
+
ON rdf_text_fts_pg (backend_version, config);
|
|
752
|
+
`);
|
|
753
|
+
}
|
|
754
|
+
async backfillTermPostings() {
|
|
755
|
+
const rows = await this.requireExecutor().query(`
|
|
756
|
+
SELECT chunk.id, chunk.source_id, chunk.normalized_text
|
|
757
|
+
FROM rdf_text_chunks chunk
|
|
758
|
+
LEFT JOIN rdf_text_terms term ON term.chunk_id = chunk.id
|
|
759
|
+
WHERE term.chunk_id IS NULL AND chunk.normalized_text <> ''
|
|
760
|
+
`);
|
|
761
|
+
if (rows.length === 0) {
|
|
762
|
+
return;
|
|
763
|
+
}
|
|
764
|
+
await this.requireExecutor().transaction(async (tx) => {
|
|
765
|
+
for (const row of rows) {
|
|
766
|
+
await insertTermOccurrences(tx, Number(row.source_id), Number(row.id), row.normalized_text);
|
|
767
|
+
}
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
async backfillNativeFtsRows() {
|
|
771
|
+
const rows = await this.requireExecutor().query(`
|
|
772
|
+
SELECT chunk.id, chunk.heading, chunk.path, chunk.content
|
|
773
|
+
FROM rdf_text_chunks chunk
|
|
774
|
+
LEFT JOIN rdf_text_fts_pg fts ON fts.chunk_id = chunk.id
|
|
775
|
+
WHERE fts.chunk_id IS NULL OR fts.backend_version <> $1
|
|
776
|
+
`, [PG_NATIVE_FTS_BACKEND_VERSION]);
|
|
777
|
+
if (rows.length === 0) {
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
780
|
+
await this.requireExecutor().transaction(async (tx) => {
|
|
781
|
+
for (const row of rows) {
|
|
782
|
+
await upsertNativeFtsProjection(tx, Number(row.id), {
|
|
783
|
+
heading: row.heading ?? undefined,
|
|
784
|
+
path: (0, RdfTextIndex_1.parseRdfTextPath)(row.path),
|
|
785
|
+
content: row.content,
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
nativeFtsEnabled() {
|
|
791
|
+
return this.options.textSearchBackend === 'pg-native-fts' || this.options.textSearchBackend === 'auto';
|
|
792
|
+
}
|
|
793
|
+
canUseNativeFts(query) {
|
|
794
|
+
return this.nativeFtsEnabled() && Boolean(query) && !containsNoSpaceCjk(query);
|
|
795
|
+
}
|
|
796
|
+
async upsertSource(tx, source) {
|
|
797
|
+
const rows = await tx.query(`
|
|
798
|
+
INSERT INTO rdf_text_sources (
|
|
799
|
+
source_key,
|
|
800
|
+
source,
|
|
801
|
+
workspace,
|
|
802
|
+
local_path,
|
|
803
|
+
content_type,
|
|
804
|
+
source_version,
|
|
805
|
+
source_hash,
|
|
806
|
+
updated_at
|
|
807
|
+
)
|
|
808
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, now())
|
|
809
|
+
ON CONFLICT (source)
|
|
810
|
+
DO UPDATE SET
|
|
811
|
+
source_key = EXCLUDED.source_key,
|
|
812
|
+
workspace = EXCLUDED.workspace,
|
|
813
|
+
local_path = EXCLUDED.local_path,
|
|
814
|
+
content_type = EXCLUDED.content_type,
|
|
815
|
+
source_version = EXCLUDED.source_version,
|
|
816
|
+
source_hash = EXCLUDED.source_hash,
|
|
817
|
+
updated_at = EXCLUDED.updated_at
|
|
818
|
+
RETURNING id
|
|
819
|
+
`, [
|
|
820
|
+
source.sourceKey ?? source.source,
|
|
821
|
+
source.source,
|
|
822
|
+
source.workspace,
|
|
823
|
+
source.localPath ?? null,
|
|
824
|
+
source.contentType ?? null,
|
|
825
|
+
source.sourceVersion ?? null,
|
|
826
|
+
source.sourceHash ?? null,
|
|
827
|
+
]);
|
|
828
|
+
const id = Number(rows[0]?.id);
|
|
829
|
+
if (!Number.isFinite(id)) {
|
|
830
|
+
throw new Error(`Failed to upsert RDF text source: ${source.source}`);
|
|
831
|
+
}
|
|
832
|
+
return id;
|
|
833
|
+
}
|
|
834
|
+
async estimateDatabaseBytes() {
|
|
835
|
+
try {
|
|
836
|
+
const rows = await this.requireExecutor().query(`
|
|
837
|
+
SELECT COALESCE(SUM(pg_total_relation_size(('"' || schemaname || '"."' || tablename || '"')::regclass)), 0)::bigint AS bytes
|
|
838
|
+
FROM pg_tables
|
|
839
|
+
WHERE tablename IN ('rdf_text_sources', 'rdf_text_chunks', 'rdf_text_terms', 'rdf_text_entities', 'rdf_text_fts_pg')
|
|
840
|
+
`);
|
|
841
|
+
return Number(rows[0]?.bytes ?? 0);
|
|
842
|
+
}
|
|
843
|
+
catch {
|
|
844
|
+
return 0;
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
async entitiesForChunk(chunkId) {
|
|
848
|
+
const rows = await this.requireExecutor().query(`
|
|
849
|
+
SELECT entity, predicate, label, value, datatype, language, policy_role, occurrences
|
|
850
|
+
FROM rdf_text_entities
|
|
851
|
+
WHERE chunk_id = $1
|
|
852
|
+
ORDER BY entity ASC, predicate ASC, label ASC
|
|
853
|
+
`, [chunkId]);
|
|
854
|
+
return rows.map((row) => ({
|
|
855
|
+
entity: row.entity,
|
|
856
|
+
predicate: row.predicate ?? undefined,
|
|
857
|
+
label: row.label ?? undefined,
|
|
858
|
+
value: row.value ?? undefined,
|
|
859
|
+
datatype: row.datatype ?? undefined,
|
|
860
|
+
language: row.language ?? undefined,
|
|
861
|
+
policyRole: row.policy_role ?? undefined,
|
|
862
|
+
occurrences: Number(row.occurrences),
|
|
863
|
+
}));
|
|
864
|
+
}
|
|
865
|
+
async entitiesForChunks(chunkIds) {
|
|
866
|
+
const uniqueIds = [...new Set(chunkIds)];
|
|
867
|
+
const mentions = new Map();
|
|
868
|
+
if (uniqueIds.length === 0) {
|
|
869
|
+
return mentions;
|
|
870
|
+
}
|
|
871
|
+
const params = [];
|
|
872
|
+
const rows = await this.requireExecutor().query(`
|
|
873
|
+
SELECT chunk_id, entity, predicate, label, value, datatype, language, policy_role, occurrences
|
|
874
|
+
FROM rdf_text_entities
|
|
875
|
+
WHERE chunk_id IN (${uniqueIds.map((id) => addParam(params, id)).join(', ')})
|
|
876
|
+
ORDER BY chunk_id ASC, entity ASC, predicate ASC, label ASC
|
|
877
|
+
`, params);
|
|
878
|
+
for (const row of rows) {
|
|
879
|
+
const chunkId = Number(row.chunk_id);
|
|
880
|
+
if (!Number.isFinite(chunkId)) {
|
|
881
|
+
continue;
|
|
882
|
+
}
|
|
883
|
+
const chunkMentions = mentions.get(chunkId) ?? [];
|
|
884
|
+
chunkMentions.push({
|
|
885
|
+
entity: row.entity,
|
|
886
|
+
predicate: row.predicate ?? undefined,
|
|
887
|
+
label: row.label ?? undefined,
|
|
888
|
+
value: row.value ?? undefined,
|
|
889
|
+
datatype: row.datatype ?? undefined,
|
|
890
|
+
language: row.language ?? undefined,
|
|
891
|
+
policyRole: row.policy_role ?? undefined,
|
|
892
|
+
occurrences: Number(row.occurrences),
|
|
893
|
+
});
|
|
894
|
+
mentions.set(chunkId, chunkMentions);
|
|
895
|
+
}
|
|
896
|
+
return mentions;
|
|
897
|
+
}
|
|
898
|
+
requireExecutor() {
|
|
899
|
+
if (!this.executor) {
|
|
900
|
+
throw new Error('PostgresRdfTextIndex is not open');
|
|
901
|
+
}
|
|
902
|
+
return this.executor;
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
exports.PostgresRdfTextIndex = PostgresRdfTextIndex;
|
|
906
|
+
function buildTextSearchPredicate(query, params) {
|
|
907
|
+
const terms = [...new Set((0, RdfTextIndex_1.tokenizeNormalizedRdfText)(query))]
|
|
908
|
+
.filter((term) => term.length <= RdfTextIndex_1.RDF_TEXT_TERM_MAX_INDEX_LENGTH);
|
|
909
|
+
const phraseCondition = `chunk.normalized_text LIKE ${addParam(params, `%${(0, RdfTextIndex_1.escapeRdfTextLikePattern)(query)}%`)} ESCAPE '\\'`;
|
|
910
|
+
if (terms.length === 0) {
|
|
911
|
+
return {
|
|
912
|
+
sql: phraseCondition,
|
|
913
|
+
indexChoice: 'text-normalized-scan',
|
|
914
|
+
};
|
|
915
|
+
}
|
|
916
|
+
const unionQueries = terms.map((term) => `
|
|
917
|
+
SELECT term.chunk_id, ${addParam(params, term)} AS query_term
|
|
918
|
+
FROM rdf_text_terms term
|
|
919
|
+
WHERE term.term = ${addParam(params, term)}
|
|
920
|
+
`);
|
|
921
|
+
return {
|
|
922
|
+
sql: `
|
|
923
|
+
chunk.id IN (
|
|
924
|
+
SELECT candidate.chunk_id
|
|
925
|
+
FROM (
|
|
926
|
+
${unionQueries.join(' UNION ALL ')}
|
|
927
|
+
) candidate
|
|
928
|
+
GROUP BY candidate.chunk_id
|
|
929
|
+
HAVING COUNT(DISTINCT candidate.query_term) = ${addParam(params, terms.length)}
|
|
930
|
+
)
|
|
931
|
+
AND ${phraseCondition}
|
|
932
|
+
`,
|
|
933
|
+
indexChoice: 'text-term-posting',
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
async function insertTermOccurrences(executor, sourceId, chunkId, normalizedText) {
|
|
937
|
+
for (const [term, occurrences] of (0, RdfTextIndex_1.rdfTextTermOccurrences)(normalizedText)) {
|
|
938
|
+
if (term.length > RdfTextIndex_1.RDF_TEXT_TERM_MAX_INDEX_LENGTH) {
|
|
939
|
+
continue;
|
|
940
|
+
}
|
|
941
|
+
await executor.exec(`
|
|
942
|
+
INSERT INTO rdf_text_terms (
|
|
943
|
+
term,
|
|
944
|
+
source_id,
|
|
945
|
+
chunk_id,
|
|
946
|
+
occurrences,
|
|
947
|
+
updated_at
|
|
948
|
+
)
|
|
949
|
+
VALUES ($1, $2, $3, $4, now())
|
|
950
|
+
`, [term, sourceId, chunkId, occurrences]);
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
async function upsertNativeFtsChunk(executor, chunkId, chunk) {
|
|
954
|
+
await upsertNativeFtsProjection(executor, chunkId, {
|
|
955
|
+
heading: chunk.heading,
|
|
956
|
+
path: chunk.path ?? [],
|
|
957
|
+
content: chunk.content,
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
async function upsertNativeFtsProjection(executor, chunkId, projection) {
|
|
961
|
+
const heading = projection.heading ?? '';
|
|
962
|
+
const pathText = (projection.path ?? []).join(' ');
|
|
963
|
+
const content = projection.content;
|
|
964
|
+
const projectionHash = (0, RdfTextIndex_1.rdfTextSha256)(JSON.stringify({
|
|
965
|
+
version: PG_NATIVE_FTS_BACKEND_VERSION,
|
|
966
|
+
heading,
|
|
967
|
+
path: pathText,
|
|
968
|
+
content,
|
|
969
|
+
}));
|
|
970
|
+
await executor.exec(`
|
|
971
|
+
INSERT INTO rdf_text_fts_pg (
|
|
972
|
+
chunk_id,
|
|
973
|
+
backend_version,
|
|
974
|
+
config,
|
|
975
|
+
projection_hash,
|
|
976
|
+
fts_vector,
|
|
977
|
+
updated_at
|
|
978
|
+
)
|
|
979
|
+
VALUES (
|
|
980
|
+
$1,
|
|
981
|
+
$2,
|
|
982
|
+
'simple'::regconfig,
|
|
983
|
+
$3,
|
|
984
|
+
setweight(to_tsvector('simple', COALESCE($4, '')), 'A')
|
|
985
|
+
|| setweight(to_tsvector('simple', COALESCE($5, '')), 'B')
|
|
986
|
+
|| setweight(to_tsvector('simple', COALESCE($6, '')), 'C'),
|
|
987
|
+
now()
|
|
988
|
+
)
|
|
989
|
+
ON CONFLICT (chunk_id)
|
|
990
|
+
DO UPDATE SET
|
|
991
|
+
backend_version = EXCLUDED.backend_version,
|
|
992
|
+
config = EXCLUDED.config,
|
|
993
|
+
projection_hash = EXCLUDED.projection_hash,
|
|
994
|
+
fts_vector = EXCLUDED.fts_vector,
|
|
995
|
+
updated_at = CASE
|
|
996
|
+
WHEN rdf_text_fts_pg.backend_version <> EXCLUDED.backend_version
|
|
997
|
+
OR rdf_text_fts_pg.projection_hash <> EXCLUDED.projection_hash
|
|
998
|
+
THEN EXCLUDED.updated_at
|
|
999
|
+
ELSE rdf_text_fts_pg.updated_at
|
|
1000
|
+
END
|
|
1001
|
+
`, [
|
|
1002
|
+
chunkId,
|
|
1003
|
+
PG_NATIVE_FTS_BACKEND_VERSION,
|
|
1004
|
+
projectionHash,
|
|
1005
|
+
heading,
|
|
1006
|
+
pathText,
|
|
1007
|
+
content,
|
|
1008
|
+
]);
|
|
1009
|
+
}
|
|
1010
|
+
function appendEntitySearchFilter(entities, conditions, params) {
|
|
1011
|
+
if (entities.length === 0) {
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
1014
|
+
conditions.push(`
|
|
1015
|
+
chunk.id IN (
|
|
1016
|
+
SELECT entity.chunk_id
|
|
1017
|
+
FROM rdf_text_entities entity
|
|
1018
|
+
WHERE entity.entity IN (${entities.map((entity) => addParam(params, entity)).join(', ')})
|
|
1019
|
+
GROUP BY entity.chunk_id
|
|
1020
|
+
HAVING COUNT(DISTINCT entity.entity) = ${addParam(params, entities.length)}
|
|
1021
|
+
)
|
|
1022
|
+
`);
|
|
1023
|
+
}
|
|
1024
|
+
async function insertEntityMentions(executor, sourceId, chunkId, entities) {
|
|
1025
|
+
for (const entity of normalizeEntityMentions(entities)) {
|
|
1026
|
+
await executor.exec(`
|
|
1027
|
+
INSERT INTO rdf_text_entities (
|
|
1028
|
+
entity,
|
|
1029
|
+
source_id,
|
|
1030
|
+
chunk_id,
|
|
1031
|
+
predicate,
|
|
1032
|
+
label,
|
|
1033
|
+
value,
|
|
1034
|
+
datatype,
|
|
1035
|
+
language,
|
|
1036
|
+
policy_role,
|
|
1037
|
+
occurrences,
|
|
1038
|
+
updated_at
|
|
1039
|
+
)
|
|
1040
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, now())
|
|
1041
|
+
`, [
|
|
1042
|
+
entity.entity,
|
|
1043
|
+
sourceId,
|
|
1044
|
+
chunkId,
|
|
1045
|
+
entity.predicate ?? null,
|
|
1046
|
+
entity.label ?? null,
|
|
1047
|
+
entity.value ?? null,
|
|
1048
|
+
entity.datatype ?? null,
|
|
1049
|
+
entity.language ?? null,
|
|
1050
|
+
entity.policyRole ?? null,
|
|
1051
|
+
entity.occurrences,
|
|
1052
|
+
]);
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
function normalizeEntityFilter(entities) {
|
|
1056
|
+
return [...new Set((entities ?? []).map((entity) => entity.trim()).filter(Boolean))].sort();
|
|
1057
|
+
}
|
|
1058
|
+
function containsNoSpaceCjk(query) {
|
|
1059
|
+
return /[\u3400-\u9fff\uf900-\ufaff]/u.test(query);
|
|
1060
|
+
}
|
|
1061
|
+
function normalizeEntityMentions(entities) {
|
|
1062
|
+
const mentions = new Map();
|
|
1063
|
+
for (const entity of entities ?? []) {
|
|
1064
|
+
const iri = entity.entity.trim();
|
|
1065
|
+
if (!iri) {
|
|
1066
|
+
continue;
|
|
1067
|
+
}
|
|
1068
|
+
const predicate = entity.predicate?.trim() || undefined;
|
|
1069
|
+
const label = entity.label?.trim() || undefined;
|
|
1070
|
+
const value = entity.value;
|
|
1071
|
+
const datatype = entity.datatype?.trim() || undefined;
|
|
1072
|
+
const language = entity.language?.trim() || undefined;
|
|
1073
|
+
const policyRole = entity.policyRole?.trim() || undefined;
|
|
1074
|
+
const key = JSON.stringify([iri, predicate ?? '', label ?? '', value ?? '', datatype ?? '', language ?? '', policyRole ?? '']);
|
|
1075
|
+
const existing = mentions.get(key);
|
|
1076
|
+
const occurrences = Math.max(1, Math.trunc(entity.occurrences ?? 1));
|
|
1077
|
+
if (existing) {
|
|
1078
|
+
existing.occurrences += occurrences;
|
|
1079
|
+
}
|
|
1080
|
+
else {
|
|
1081
|
+
mentions.set(key, { entity: iri, predicate, label, value, datatype, language, policyRole, occurrences });
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
return [...mentions.values()].sort((left, right) => left.entity.localeCompare(right.entity) || (left.predicate ?? '').localeCompare(right.predicate ?? '') || (left.label ?? '').localeCompare(right.label ?? ''));
|
|
1085
|
+
}
|
|
1086
|
+
function pgTextSearchScoreExpression(query, params) {
|
|
1087
|
+
if (!query) {
|
|
1088
|
+
return '1';
|
|
1089
|
+
}
|
|
1090
|
+
const replacementNeedle = addParam(params, query);
|
|
1091
|
+
const lengthNeedle = addParam(params, query);
|
|
1092
|
+
const headingNeedle = addParam(params, `%${(0, RdfTextIndex_1.escapeRdfTextLikePattern)(query)}%`);
|
|
1093
|
+
return `
|
|
1094
|
+
CAST((length(chunk.normalized_text) - length(replace(chunk.normalized_text, ${replacementNeedle}, ''))) / GREATEST(length(${lengthNeedle}), 1) AS integer)
|
|
1095
|
+
+ CASE
|
|
1096
|
+
WHEN lower(COALESCE(chunk.heading, '')) LIKE ${headingNeedle} ESCAPE '\\' THEN 100
|
|
1097
|
+
ELSE 0
|
|
1098
|
+
END
|
|
1099
|
+
`;
|
|
1100
|
+
}
|
|
1101
|
+
function pgTextSearchOrderBy(orderBy) {
|
|
1102
|
+
const order = orderBy?.length ? orderBy : [{ field: 'score', direction: 'desc' }];
|
|
1103
|
+
return order.map((entry) => `${pgTextSearchOrderField(entry.field)} ${entry.direction === 'desc' ? 'DESC' : 'ASC'}`).join(', ');
|
|
1104
|
+
}
|
|
1105
|
+
function pgTextSearchOrderField(field) {
|
|
1106
|
+
switch (field) {
|
|
1107
|
+
case 'score':
|
|
1108
|
+
return 'score';
|
|
1109
|
+
case 'source':
|
|
1110
|
+
return 'source.source';
|
|
1111
|
+
case 'localPath':
|
|
1112
|
+
return "COALESCE(source.local_path, '')";
|
|
1113
|
+
case 'ordinal':
|
|
1114
|
+
return 'chunk.ordinal';
|
|
1115
|
+
case 'startOffset':
|
|
1116
|
+
return 'chunk.start_offset';
|
|
1117
|
+
case 'endOffset':
|
|
1118
|
+
return 'chunk.end_offset';
|
|
1119
|
+
default: {
|
|
1120
|
+
const exhaustive = field;
|
|
1121
|
+
throw new Error(`Unsupported RDF text search order field: ${exhaustive}`);
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
function pgTextSearchResultOrderBy(orderBy) {
|
|
1126
|
+
const order = orderBy?.length ? orderBy : [{ field: 'score', direction: 'desc' }];
|
|
1127
|
+
return order.map((entry) => `${pgTextSearchResultOrderField(entry.field)} ${entry.direction === 'desc' ? 'DESC' : 'ASC'}`).join(', ');
|
|
1128
|
+
}
|
|
1129
|
+
function pgTextSearchResultOrderField(field) {
|
|
1130
|
+
switch (field) {
|
|
1131
|
+
case 'score':
|
|
1132
|
+
return 'score';
|
|
1133
|
+
case 'source':
|
|
1134
|
+
return 'source';
|
|
1135
|
+
case 'localPath':
|
|
1136
|
+
return "COALESCE(local_path, '')";
|
|
1137
|
+
case 'ordinal':
|
|
1138
|
+
return 'ordinal';
|
|
1139
|
+
case 'startOffset':
|
|
1140
|
+
return 'start_offset';
|
|
1141
|
+
case 'endOffset':
|
|
1142
|
+
return 'end_offset';
|
|
1143
|
+
default: {
|
|
1144
|
+
const exhaustive = field;
|
|
1145
|
+
throw new Error(`Unsupported RDF text search order field: ${exhaustive}`);
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
function pgTextSearchWindow(options, params) {
|
|
1150
|
+
const offset = Math.max(0, options.offset ?? 0);
|
|
1151
|
+
if (options.limit === undefined) {
|
|
1152
|
+
return offset > 0 ? `OFFSET ${addParam(params, offset)}` : '';
|
|
1153
|
+
}
|
|
1154
|
+
return `LIMIT ${addParam(params, Math.max(0, options.limit))} OFFSET ${addParam(params, offset)}`;
|
|
1155
|
+
}
|
|
1156
|
+
function addParam(params, value) {
|
|
1157
|
+
params.push(value);
|
|
1158
|
+
return `$${params.length}`;
|
|
1159
|
+
}
|
|
1160
|
+
function toSearchResult(row, normalizedQuery, score, entities, algorithm = 'occurrence-heading-boost') {
|
|
1161
|
+
return {
|
|
1162
|
+
source: row.source,
|
|
1163
|
+
workspace: row.workspace,
|
|
1164
|
+
localPath: row.local_path ?? undefined,
|
|
1165
|
+
contentType: row.content_type ?? undefined,
|
|
1166
|
+
sourceVersion: row.source_version ?? undefined,
|
|
1167
|
+
sourceHash: row.source_hash ?? undefined,
|
|
1168
|
+
sourceKey: row.source_key ?? row.source,
|
|
1169
|
+
chunkKey: row.chunk_key,
|
|
1170
|
+
retrievalPointKey: row.chunk_key,
|
|
1171
|
+
retrievalKind: (0, RdfTextIndex_1.normalizeRdfTextRetrievalKind)(row.retrieval_kind),
|
|
1172
|
+
ordinal: row.ordinal,
|
|
1173
|
+
level: row.level,
|
|
1174
|
+
heading: row.heading ?? undefined,
|
|
1175
|
+
path: (0, RdfTextIndex_1.parseRdfTextPath)(row.path),
|
|
1176
|
+
content: row.content,
|
|
1177
|
+
startOffset: row.start_offset,
|
|
1178
|
+
endOffset: row.end_offset,
|
|
1179
|
+
scoreComponents: textScoreComponents(row, normalizedQuery, score, algorithm),
|
|
1180
|
+
score,
|
|
1181
|
+
entities,
|
|
1182
|
+
};
|
|
1183
|
+
}
|
|
1184
|
+
function textScoreComponents(row, normalizedQuery, score, algorithm = 'occurrence-heading-boost') {
|
|
1185
|
+
if (algorithm === 'pg-ts-rank-cd') {
|
|
1186
|
+
return {
|
|
1187
|
+
sourceType: 'text',
|
|
1188
|
+
algorithm,
|
|
1189
|
+
normalizedQuery,
|
|
1190
|
+
occurrenceScore: 0,
|
|
1191
|
+
headingBoost: 0,
|
|
1192
|
+
nativeRank: score,
|
|
1193
|
+
score,
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
if (!normalizedQuery) {
|
|
1197
|
+
return {
|
|
1198
|
+
sourceType: 'text',
|
|
1199
|
+
algorithm,
|
|
1200
|
+
normalizedQuery,
|
|
1201
|
+
occurrenceScore: 1,
|
|
1202
|
+
headingBoost: 0,
|
|
1203
|
+
score,
|
|
1204
|
+
};
|
|
1205
|
+
}
|
|
1206
|
+
const occurrenceScore = (0, RdfTextIndex_1.rdfTextOccurrenceCount)(row.normalized_text, normalizedQuery);
|
|
1207
|
+
const headingBoost = (0, RdfTextIndex_1.normalizeRdfText)(row.heading ?? '').includes(normalizedQuery) ? 100 : 0;
|
|
1208
|
+
return {
|
|
1209
|
+
sourceType: 'text',
|
|
1210
|
+
algorithm,
|
|
1211
|
+
normalizedQuery,
|
|
1212
|
+
occurrenceScore,
|
|
1213
|
+
headingBoost,
|
|
1214
|
+
score,
|
|
1215
|
+
};
|
|
1216
|
+
}
|
|
1217
|
+
function rdfTextSourceMetadata(row) {
|
|
1218
|
+
return {
|
|
1219
|
+
sourceKey: row.source_key ?? row.source,
|
|
1220
|
+
source: row.source,
|
|
1221
|
+
workspace: row.workspace,
|
|
1222
|
+
localPath: row.local_path ?? undefined,
|
|
1223
|
+
contentType: row.content_type ?? undefined,
|
|
1224
|
+
sourceVersion: row.source_version ?? undefined,
|
|
1225
|
+
sourceHash: row.source_hash ?? undefined,
|
|
1226
|
+
updatedAt: row.updated_at,
|
|
1227
|
+
};
|
|
1228
|
+
}
|
|
1229
|
+
function rdfTextRebuildStatus(row) {
|
|
1230
|
+
return {
|
|
1231
|
+
source: row.source,
|
|
1232
|
+
workspace: row.workspace,
|
|
1233
|
+
localPath: row.local_path ?? undefined,
|
|
1234
|
+
contentType: row.content_type ?? undefined,
|
|
1235
|
+
sourceVersion: row.source_version ?? undefined,
|
|
1236
|
+
sourceHash: row.source_hash ?? undefined,
|
|
1237
|
+
status: row.status,
|
|
1238
|
+
reason: row.reason ?? undefined,
|
|
1239
|
+
message: row.message ?? undefined,
|
|
1240
|
+
updatedAt: row.updated_at,
|
|
1241
|
+
};
|
|
1242
|
+
}
|
|
1243
|
+
function normalizeTextChunkRow(row) {
|
|
1244
|
+
return {
|
|
1245
|
+
...row,
|
|
1246
|
+
id: Number(row.id),
|
|
1247
|
+
source_id: Number(row.source_id),
|
|
1248
|
+
ordinal: Number(row.ordinal),
|
|
1249
|
+
level: Number(row.level),
|
|
1250
|
+
start_offset: Number(row.start_offset),
|
|
1251
|
+
end_offset: Number(row.end_offset),
|
|
1252
|
+
token_count: Number(row.token_count),
|
|
1253
|
+
};
|
|
1254
|
+
}
|
|
1255
|
+
//# sourceMappingURL=PostgresRdfTextIndex.js.map
|