@undefineds.co/xpod 0.4.11 → 0.4.13
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/config/components-ignore.json +5 -1
- package/config/notifications.json +68 -0
- package/config/xpod.base.json +9 -11
- package/dist/acceptance/QleverSemanticConformance.js +7 -0
- package/dist/ai/service/AiCredentialSecret.d.ts +30 -0
- package/dist/ai/service/AiCredentialSecret.js +120 -0
- package/dist/ai/service/CredentialReaderImpl.d.ts +18 -0
- package/dist/ai/service/CredentialReaderImpl.js +81 -5
- package/dist/ai/service/CredentialReaderImpl.jsonld +42 -2
- package/dist/ai/service/EmbeddingModelPolicy.d.ts +79 -0
- package/dist/ai/service/EmbeddingModelPolicy.js +134 -0
- package/dist/ai/service/EmbeddingProviderError.js +6 -0
- package/dist/ai/service/EmbeddingServiceImpl.d.ts +13 -1
- package/dist/ai/service/EmbeddingServiceImpl.js +18 -5
- package/dist/ai/service/EmbeddingServiceImpl.jsonld +35 -0
- package/dist/ai/service/index.d.ts +2 -0
- package/dist/ai/service/index.js +2 -0
- package/dist/api/ai-gateway/connect/index.d.ts +20 -2
- package/dist/api/ai-gateway/connect/index.js +162 -16
- package/dist/api/ai-gateway/credentials/AiCredentialSecretDecoder.d.ts +12 -0
- package/dist/api/ai-gateway/credentials/AiCredentialSecretDecoder.js +30 -0
- package/dist/api/ai-gateway/errors.d.ts +1 -1
- package/dist/api/ai-gateway/models/GatewayEmbeddingModelCatalog.d.ts +11 -0
- package/dist/api/ai-gateway/models/GatewayEmbeddingModelCatalog.js +31 -0
- package/dist/api/ai-gateway/models/PodModelSelectionRepository.js +7 -3
- package/dist/api/ai-gateway/models/ProviderCustomModelsService.d.ts +18 -0
- package/dist/api/ai-gateway/models/ProviderCustomModelsService.js +23 -0
- package/dist/api/ai-gateway/models/ProviderModelDiscoveryAdapters.d.ts +3 -1
- package/dist/api/ai-gateway/models/ProviderModelDiscoveryAdapters.js +2 -45
- package/dist/api/ai-gateway/models/ProviderModelSelectionService.d.ts +10 -0
- package/dist/api/ai-gateway/models/ProviderModelSelectionService.js +57 -20
- package/dist/api/ai-gateway/models/ProviderModelType.d.ts +28 -0
- package/dist/api/ai-gateway/models/ProviderModelType.js +34 -0
- package/dist/api/ai-gateway/models/ProviderModelsAdapter.d.ts +10 -0
- package/dist/api/ai-gateway/models/ProviderModelsAdapter.js +3 -4
- package/dist/api/ai-gateway/models/index.d.ts +1 -0
- package/dist/api/ai-gateway/models/index.js +3 -1
- package/dist/api/ai-gateway/providers/CustomRuntimeAdapter.d.ts +7 -0
- package/dist/api/ai-gateway/providers/CustomRuntimeAdapter.js +9 -2
- package/dist/api/ai-gateway/providers/ModelsDevCatalog.d.ts +7 -1
- package/dist/api/ai-gateway/providers/ModelsDevCatalog.js +4 -10
- package/dist/api/ai-gateway/providers/OfferingAuthorization.d.ts +6 -1
- package/dist/api/ai-gateway/providers/OfferingAuthorization.js +0 -3
- package/dist/api/ai-gateway/providers/ProviderRegistry.d.ts +107 -0
- package/dist/api/ai-gateway/providers/ProviderRegistry.js +246 -23
- package/dist/api/ai-gateway/providers/ProviderRuntimeRegistry.d.ts +5 -0
- package/dist/api/ai-gateway/providers/ProviderRuntimeRegistry.js +5 -1
- package/dist/api/ai-gateway/quota/SubscriptionQuotaAdapters.d.ts +12 -4
- package/dist/api/ai-gateway/quota/SubscriptionQuotaAdapters.js +11 -11
- package/dist/api/ai-gateway/routing/ModelRouter.d.ts +14 -0
- package/dist/api/ai-gateway/routing/ModelRouter.js +43 -4
- package/dist/api/ai-gateway/service-access/AiConnectionsServiceAccess.d.ts +9 -1
- package/dist/api/ai-gateway/service-access/AiConnectionsServiceAccess.js +3 -27
- package/dist/api/chatkit/pod-store.d.ts +31 -0
- package/dist/api/chatkit/pod-store.js +132 -8
- package/dist/api/container/common.js +24 -4
- package/dist/api/container/routes.js +17 -2
- package/dist/api/container/types.d.ts +3 -1
- package/dist/api/handlers/AdminHandler.d.ts +13 -0
- package/dist/api/handlers/AdminHandler.js +47 -18
- package/dist/api/handlers/AiConfigHandler.d.ts +6 -0
- package/dist/api/handlers/AiConfigHandler.js +28 -0
- package/dist/api/handlers/AiGatewayManagementHandler.js +36 -0
- package/dist/api/runs/RdfRunContextRetriever.d.ts +14 -0
- package/dist/api/runs/RdfRunContextRetriever.js +41 -5
- package/dist/api/runtime.js +2 -1
- package/dist/api/service/AiClientConfigurationService.d.ts +1 -1
- package/dist/api/service/AiClientConfigurationService.js +1 -1
- package/dist/cli/commands/secret.d.ts +1 -0
- package/dist/cli/commands/secret.js +25 -7
- package/dist/components/components.jsonld +3 -1
- package/dist/components/context.jsonld +53 -1
- package/dist/http/SubgraphSparqlHttpHandler.d.ts +59 -2
- package/dist/http/SubgraphSparqlHttpHandler.js +145 -13
- package/dist/http/SubgraphSparqlHttpHandler.jsonld +37 -0
- package/dist/identity/drizzle/EdgeNodeRepository.d.ts +0 -12
- package/dist/identity/drizzle/EdgeNodeRepository.js +5 -13
- package/dist/index.d.ts +2 -1
- package/dist/index.js +7 -3
- package/dist/logging/log-file.d.ts +17 -0
- package/dist/logging/log-file.js +69 -0
- package/dist/main.js +2 -1
- package/dist/notifications/NotificationChannelSweeper.d.ts +50 -0
- package/dist/notifications/NotificationChannelSweeper.js +131 -0
- package/dist/notifications/NotificationChannelSweeper.jsonld +136 -0
- package/dist/notifications/ReclaimingWebSocket2023Storer.d.ts +25 -0
- package/dist/notifications/ReclaimingWebSocket2023Storer.js +56 -0
- package/dist/notifications/ReclaimingWebSocket2023Storer.jsonld +77 -0
- package/dist/notifications/index.d.ts +2 -0
- package/dist/notifications/index.js +2 -0
- package/dist/runtime/Proxy.d.ts +37 -0
- package/dist/runtime/Proxy.js +88 -16
- package/dist/runtime/bootstrap.js +2 -1
- package/dist/runtime/upgrade/BunNativeUpgradeRelay.d.ts +116 -0
- package/dist/runtime/upgrade/BunNativeUpgradeRelay.js +423 -0
- package/dist/runtime/upgrade/UpgradeHandshake.d.ts +63 -0
- package/dist/runtime/upgrade/UpgradeHandshake.js +199 -0
- package/dist/runtime/upgrade/WebSocketFrames.d.ts +67 -0
- package/dist/runtime/upgrade/WebSocketFrames.js +224 -0
- package/dist/storage/rdf/PostgresRdfEngine.js +10 -4
- package/dist/storage/rdf/RdfAccessScope.js +15 -1
- package/dist/storage/rdf/RdfEngineRdfJsSource.js +10 -2
- package/node_modules/@undefineds.co/ai-connections/dist/AiApiKeyPool.d.ts +1 -1
- package/node_modules/@undefineds.co/ai-connections/dist/AiApiKeyPool.js +9 -2
- package/node_modules/@undefineds.co/ai-connections/dist/AiAuthorizationActions.d.ts +12 -3
- package/node_modules/@undefineds.co/ai-connections/dist/AiAuthorizationActions.js +27 -10
- package/node_modules/@undefineds.co/ai-connections/dist/AiClientConfigurationSection.d.ts +7 -0
- package/node_modules/@undefineds.co/ai-connections/dist/AiClientConfigurationSection.js +15 -13
- package/node_modules/@undefineds.co/ai-connections/dist/AiConnectDialog.d.ts +1 -1
- package/node_modules/@undefineds.co/ai-connections/dist/AiConnectDialog.js +1 -1
- package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsList.js +10 -6
- package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsMain.d.ts +15 -0
- package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsMain.js +29 -3
- package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsMainHeader.js +18 -3
- package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsPanel.d.ts +17 -2
- package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsPanel.js +94 -22
- package/node_modules/@undefineds.co/ai-connections/dist/AiCopyButton.d.ts +35 -0
- package/node_modules/@undefineds.co/ai-connections/dist/AiCopyButton.js +45 -0
- package/node_modules/@undefineds.co/ai-connections/dist/AiCredentialPoolSection.d.ts +1 -1
- package/node_modules/@undefineds.co/ai-connections/dist/AiCredentialPoolSection.js +71 -11
- package/node_modules/@undefineds.co/ai-connections/dist/AiCredentialRow.d.ts +1 -1
- package/node_modules/@undefineds.co/ai-connections/dist/AiCredentialRow.js +9 -7
- package/node_modules/@undefineds.co/ai-connections/dist/AiCustomProviderDialog.d.ts +1 -1
- package/node_modules/@undefineds.co/ai-connections/dist/AiEndpointList.d.ts +23 -0
- package/node_modules/@undefineds.co/ai-connections/dist/AiEndpointList.js +24 -0
- package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayKeyRow.d.ts +1 -1
- package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayKeysSection.d.ts +14 -5
- package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayKeysSection.js +35 -38
- package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayModelsSection.d.ts +21 -0
- package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayModelsSection.js +51 -0
- package/node_modules/@undefineds.co/ai-connections/dist/AiInfoTooltip.d.ts +15 -0
- package/node_modules/@undefineds.co/ai-connections/dist/AiInfoTooltip.js +16 -0
- package/node_modules/@undefineds.co/ai-connections/dist/AiModelCatalog.d.ts +175 -0
- package/node_modules/@undefineds.co/ai-connections/dist/AiModelCatalog.js +133 -0
- package/node_modules/@undefineds.co/ai-connections/dist/AiOfferingDetails.d.ts +1 -1
- package/node_modules/@undefineds.co/ai-connections/dist/AiOfferingDetails.js +2 -2
- package/node_modules/@undefineds.co/ai-connections/dist/AiProviderCard.d.ts +1 -1
- package/node_modules/@undefineds.co/ai-connections/dist/AiProviderCard.js +13 -64
- package/node_modules/@undefineds.co/ai-connections/dist/AiProviderHeader.d.ts +21 -0
- package/node_modules/@undefineds.co/ai-connections/dist/AiProviderHeader.js +12 -0
- package/node_modules/@undefineds.co/ai-connections/dist/AiQuotaCard.d.ts +1 -1
- package/node_modules/@undefineds.co/ai-connections/dist/AiRowAction.d.ts +15 -0
- package/node_modules/@undefineds.co/ai-connections/dist/AiRowAction.js +12 -0
- package/node_modules/@undefineds.co/ai-connections/dist/AiSortableCredentialList.d.ts +1 -1
- package/node_modules/@undefineds.co/ai-connections/dist/AiSortableCredentialList.js +2 -1
- package/node_modules/@undefineds.co/ai-connections/dist/authorization-methods.d.ts +39 -6
- package/node_modules/@undefineds.co/ai-connections/dist/authorization-methods.js +57 -11
- package/node_modules/@undefineds.co/ai-connections/dist/collection-runtime.d.ts +46 -0
- package/node_modules/@undefineds.co/ai-connections/dist/collection-runtime.js +231 -0
- package/node_modules/@undefineds.co/ai-connections/dist/collections.d.ts +119 -0
- package/node_modules/@undefineds.co/ai-connections/dist/collections.js +173 -0
- package/node_modules/@undefineds.co/ai-connections/dist/controller.d.ts +71 -5
- package/node_modules/@undefineds.co/ai-connections/dist/controller.js +288 -18
- package/node_modules/@undefineds.co/ai-connections/dist/credential-labels.d.ts +6 -1
- package/node_modules/@undefineds.co/ai-connections/dist/credential-labels.js +8 -3
- package/node_modules/@undefineds.co/ai-connections/dist/display-wording.d.ts +20 -0
- package/node_modules/@undefineds.co/ai-connections/dist/display-wording.js +73 -0
- package/node_modules/@undefineds.co/ai-connections/dist/error-wording.d.ts +24 -0
- package/node_modules/@undefineds.co/ai-connections/dist/error-wording.js +253 -0
- package/node_modules/@undefineds.co/ai-connections/dist/gateway-endpoints.d.ts +14 -0
- package/node_modules/@undefineds.co/ai-connections/dist/gateway-endpoints.js +20 -0
- package/node_modules/@undefineds.co/ai-connections/dist/index.d.ts +8 -1
- package/node_modules/@undefineds.co/ai-connections/dist/index.js +8 -1
- package/node_modules/@undefineds.co/ai-connections/dist/manifest.js +1 -1
- package/node_modules/@undefineds.co/ai-connections/dist/offering-endpoints.d.ts +15 -1
- package/node_modules/@undefineds.co/ai-connections/dist/offering-endpoints.js +17 -0
- package/node_modules/@undefineds.co/ai-connections/dist/offering-label.d.ts +1 -1
- package/node_modules/@undefineds.co/ai-connections/dist/provider-visuals.d.ts +6 -1
- package/node_modules/@undefineds.co/ai-connections/dist/provider-visuals.js +5 -0
- package/node_modules/@undefineds.co/ai-connections/dist/service-access.js +2 -27
- package/node_modules/@undefineds.co/ai-connections/dist/useAiConnectDialog.d.ts +1 -1
- package/node_modules/@undefineds.co/ai-connections/package.json +2 -24
- package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/ai-connections-client.d.ts +12 -3
- package/node_modules/@undefineds.co/ai-connections-core/dist/ai-connections-client.js +21 -0
- package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client/normalize.d.ts +17 -7
- package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client/normalize.js +48 -216
- package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client/request.js +3 -3
- package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client/types.d.ts +31 -2
- package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/base-adapter.d.ts +1 -3
- package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/base-adapter.js +3 -7
- package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/index.cjs +9 -7
- package/node_modules/@undefineds.co/ai-connections-core/dist/credential-storage.d.ts +59 -0
- package/node_modules/@undefineds.co/ai-connections-core/dist/credential-storage.js +131 -0
- package/node_modules/@undefineds.co/ai-connections-core/dist/endpoint-urls.d.ts +15 -0
- package/node_modules/@undefineds.co/ai-connections-core/dist/endpoint-urls.js +20 -0
- package/node_modules/@undefineds.co/ai-connections-core/dist/index.d.ts +9 -0
- package/node_modules/@undefineds.co/ai-connections-core/dist/index.js +9 -0
- package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/provider-catalog.cjs +68 -24
- package/node_modules/@undefineds.co/ai-connections-core/dist/provider-catalog.d.ts +84 -0
- package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/provider-catalog.js +121 -22
- package/node_modules/@undefineds.co/ai-connections-core/package.json +61 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/manifest.d.ts +1 -1
- package/node_modules/@undefineds.co/extension-sdk/dist/manifest.js +2 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/web.d.ts +150 -0
- package/node_modules/@undefineds.co/extension-sdk/package.json +2 -1
- package/node_modules/@undefineds.co/models/README.md +1 -1
- package/node_modules/@undefineds.co/models/dist/ai-config/index.d.ts +3 -3
- package/node_modules/@undefineds.co/models/dist/ai-gateway.schema.d.ts +5 -0
- package/node_modules/@undefineds.co/models/dist/ai-gateway.schema.js +9 -0
- package/node_modules/@undefineds.co/models/dist/ai-runtime.repository.d.ts +1 -1
- package/node_modules/@undefineds.co/models/dist/approval.repository.d.ts +2 -2
- package/node_modules/@undefineds.co/models/dist/audit.presentation.d.ts +2 -2
- package/node_modules/@undefineds.co/models/dist/capture.repository.d.ts +1 -1
- package/node_modules/@undefineds.co/models/dist/chat-project.repository.d.ts +1 -1
- package/node_modules/@undefineds.co/models/dist/chat.repository.d.ts +2 -2
- package/node_modules/@undefineds.co/models/dist/control-request.repository.d.ts +2 -2
- package/node_modules/@undefineds.co/models/dist/conversation-share.repository.d.ts +1 -1
- package/node_modules/@undefineds.co/models/dist/credential.schema.d.ts +12 -0
- package/node_modules/@undefineds.co/models/dist/credential.schema.js +15 -1
- package/node_modules/@undefineds.co/models/dist/discovery/index.d.ts +2 -2
- package/node_modules/@undefineds.co/models/dist/discovery/providers.json +248 -7
- package/node_modules/@undefineds.co/models/dist/discovery/types.d.ts +31 -0
- package/node_modules/@undefineds.co/models/dist/extension/index.d.ts +1 -1
- package/node_modules/@undefineds.co/models/dist/favorite/index.d.ts +2 -2
- package/node_modules/@undefineds.co/models/dist/fixtures/contracts-chat-contact.d.ts +5 -5
- package/node_modules/@undefineds.co/models/dist/import/index.d.ts +1 -1
- package/node_modules/@undefineds.co/models/dist/index.d.ts +73 -73
- package/node_modules/@undefineds.co/models/dist/index.js +1 -1
- package/node_modules/@undefineds.co/models/dist/input-request.repository.d.ts +2 -2
- package/node_modules/@undefineds.co/models/dist/knowledge/index.d.ts +1 -1
- package/node_modules/@undefineds.co/models/dist/message.repository.d.ts +1 -1
- package/node_modules/@undefineds.co/models/dist/namespaces.js +5 -0
- package/node_modules/@undefineds.co/models/dist/pod-storage-descriptor.d.ts +4815 -26
- package/node_modules/@undefineds.co/models/dist/pod-storage-descriptor.js +482 -132
- package/node_modules/@undefineds.co/models/dist/schema.d.ts +4 -0
- package/node_modules/@undefineds.co/models/dist/session/index.d.ts +1 -1
- package/node_modules/@undefineds.co/models/dist/settings/index.d.ts +1 -1
- package/node_modules/@undefineds.co/models/dist/sidecar/persistence-mapping.d.ts +5 -5
- package/node_modules/@undefineds.co/models/dist/thread.repository.d.ts +2 -2
- package/node_modules/@undefineds.co/models/dist/types/message-block.d.ts +1 -1
- package/node_modules/@undefineds.co/models/dist/vocab/_namespaces.d.ts +1 -1
- package/node_modules/@undefineds.co/models/dist/vocab/index.d.ts +10 -10
- package/node_modules/@undefineds.co/models/dist/vocab/sidecar.vocab.d.ts +1 -0
- package/node_modules/@undefineds.co/models/dist/vocab/sidecar.vocab.js +1 -0
- package/node_modules/@undefineds.co/models/package.json +4 -2
- package/node_modules/@undefineds.co/pod-collections/README.md +71 -0
- package/node_modules/@undefineds.co/pod-collections/dist/diff.d.ts +85 -0
- package/node_modules/@undefineds.co/pod-collections/dist/diff.js +166 -0
- package/node_modules/@undefineds.co/pod-collections/dist/feed.d.ts +17 -0
- package/node_modules/@undefineds.co/pod-collections/dist/feed.js +27 -0
- package/node_modules/@undefineds.co/pod-collections/dist/index.cjs +1042 -0
- package/node_modules/@undefineds.co/pod-collections/dist/index.d.ts +37 -0
- package/node_modules/@undefineds.co/pod-collections/dist/index.js +89 -0
- package/node_modules/@undefineds.co/pod-collections/dist/layout.d.ts +75 -0
- package/node_modules/@undefineds.co/pod-collections/dist/layout.js +173 -0
- package/node_modules/@undefineds.co/pod-collections/dist/mapping.d.ts +78 -0
- package/node_modules/@undefineds.co/pod-collections/dist/mapping.js +287 -0
- package/node_modules/@undefineds.co/pod-collections/dist/mutations.d.ts +83 -0
- package/node_modules/@undefineds.co/pod-collections/dist/mutations.js +273 -0
- package/node_modules/@undefineds.co/pod-collections/dist/react.d.ts +21 -0
- package/node_modules/@undefineds.co/pod-collections/dist/react.js +22 -0
- package/node_modules/@undefineds.co/pod-collections/dist/read.d.ts +65 -0
- package/node_modules/@undefineds.co/pod-collections/dist/read.js +31 -0
- package/node_modules/@undefineds.co/pod-collections/dist/sync.d.ts +66 -0
- package/node_modules/@undefineds.co/pod-collections/dist/sync.js +260 -0
- package/node_modules/@undefineds.co/pod-collections/dist/types.d.ts +155 -0
- package/node_modules/@undefineds.co/pod-collections/dist/types.js +9 -0
- package/node_modules/@undefineds.co/pod-collections/package.json +42 -0
- package/node_modules/@undefineds.co/shared-ui/dist/index.d.ts +4 -2
- package/node_modules/@undefineds.co/shared-ui/dist/index.js +4 -2
- package/node_modules/@undefineds.co/shared-ui/dist/login/LoginModal.d.ts +4 -1
- package/node_modules/@undefineds.co/shared-ui/dist/login/LoginModal.js +12 -6
- package/node_modules/@undefineds.co/shared-ui/dist/login/LoginView.d.ts +1 -1
- package/node_modules/@undefineds.co/shared-ui/dist/login/host-types.d.ts +7 -1
- package/node_modules/@undefineds.co/shared-ui/dist/login/login-branding.d.ts +6 -0
- package/node_modules/@undefineds.co/shared-ui/dist/login/login-branding.js +18 -0
- package/node_modules/@undefineds.co/shared-ui/dist/user-facing-errors.d.ts +14 -2
- package/node_modules/@undefineds.co/shared-ui/dist/user-facing-errors.js +26 -17
- package/node_modules/@undefineds.co/solid-sdk/dist/login-store.d.ts +3 -3
- package/node_modules/@undefineds.co/solid-sdk/dist/login-store.js +3 -3
- package/package.json +17 -7
- package/static/app/assets/main.css +1 -1
- package/static/auth-callback/assets/AiConfigContext-DlFyEWy9.js +1 -0
- package/static/auth-callback/assets/AiConfigPage-CkYk-SFW.js +1 -0
- package/static/auth-callback/assets/DocumentProcessingPanel-CqIr3JqN.js +1 -0
- package/static/auth-callback/assets/IndexLifecyclePanel-C1GKV3Vx.js +1 -0
- package/static/auth-callback/assets/{IndexSubjectPanel-BbUqop4b.js → IndexSubjectPanel-ro9lC6XW.js} +1 -1
- package/static/auth-callback/assets/ModelAssignmentsPanel-DxNdyKRJ.js +1 -0
- package/static/auth-callback/assets/ModelsPage-BVtWSPBU.js +11 -0
- package/static/auth-callback/assets/{NetworkPage-Vp2PrMxs.js → NetworkPage-cEvxRMAl.js} +2 -2
- package/static/auth-callback/assets/{PaneListHeader-DY7baSFl.js → PaneListHeader-ByKw8ada.js} +1 -1
- package/static/auth-callback/assets/SearchIndexingPanel-CulBKcYT.js +1 -0
- package/static/auth-callback/assets/{StatusSubjectPanel-ArIS-TxT.js → StatusSubjectPanel-VOcfrt8o.js} +1 -1
- package/static/{settings/assets/StatusWorkspace-CoMFRXoV.js → auth-callback/assets/StatusWorkspace-Jsz6hAdE.js} +1 -1
- package/static/auth-callback/assets/{SystemSettingsPage-BDvT1NUz.js → SystemSettingsPage-BFNvGAle.js} +1 -1
- package/static/{dashboard/assets/SystemSettingsSubjectPanel-WaE8mTQi.js → auth-callback/assets/SystemSettingsSubjectPanel-DFRdrSfK.js} +5 -5
- package/static/auth-callback/assets/XpodAiConnectionsPodStore-C6KpvHVg.js +3 -0
- package/static/auth-callback/assets/{activity-D1Dsfa_0.js → activity-DnTlb9iM.js} +1 -1
- package/static/auth-callback/assets/ai-connections-C6yaE6WQ.js +1 -0
- package/static/auth-callback/assets/auth-callback-Cx9D_1qj.css +1 -0
- package/static/auth-callback/assets/{auth-callback-Cmf4hXVZ.js → auth-callback-D2UkK5Xj.js} +6 -6
- package/static/auth-callback/assets/{badge-CZsHq3Ih.js → badge-D7IJuuTM.js} +1 -1
- package/static/auth-callback/assets/collection-runtime-wT1n4GS2.js +1 -0
- package/static/auth-callback/assets/dialog-DickLu5z.js +1 -0
- package/static/auth-callback/assets/{download-DU9ntlHw.js → download-kn8WnRu3.js} +1 -1
- package/static/auth-callback/assets/{external-link-BfzaaZDx.js → external-link-B6B8jfSn.js} +1 -1
- package/static/auth-callback/assets/index-Cu0EguPo.js +4 -0
- package/static/auth-callback/assets/index-DHF97YLP.js +41 -0
- package/static/auth-callback/assets/index-Dz83EEHD.js +1 -0
- package/static/auth-callback/assets/{index-browser-BNFqqC74.js → index-browser-CSghinyi.js} +1 -1
- package/static/auth-callback/assets/{key-round-BwP3DBWo.js → key-round-ChkOx3E1.js} +1 -1
- package/static/auth-callback/assets/layout-DB3pMyTl.js +1 -0
- package/static/auth-callback/assets/pod-collections-host-KnnGFZHL.js +8 -0
- package/static/auth-callback/assets/{rotate-ccw-VMwnmyab.js → rotate-ccw-B3hE-nyd.js} +1 -1
- package/static/auth-callback/assets/{skeleton-CoD55rBT.js → skeleton-kEqR7tpI.js} +1 -1
- package/static/auth-callback/assets/{waypoints-DRo_1Ca7.js → waypoints-D6Jo-SZa.js} +1 -1
- package/static/auth-callback/assets/{workspace-layout--mcXl3My.js → workspace-layout-BHwT_cHd.js} +1 -1
- package/static/auth-callback/auth-callback.html +2 -2
- package/static/dashboard/assets/AiConfigContext-BfC3v-x2.js +1 -0
- package/static/dashboard/assets/AiConfigPage-QNS3u7Ff.js +1 -0
- package/static/dashboard/assets/DocumentProcessingPanel-Dr4XLeT4.js +1 -0
- package/static/dashboard/assets/IndexLifecyclePanel-KtM_gpeO.js +1 -0
- package/static/dashboard/assets/{IndexSubjectPanel-B2cXwl8X.js → IndexSubjectPanel-DLaiKdLc.js} +1 -1
- package/static/dashboard/assets/ModelAssignmentsPanel-Bk7TvQRq.js +1 -0
- package/static/dashboard/assets/ModelsPage-Cci3vlos.js +11 -0
- package/static/dashboard/assets/{NetworkPage-DV2V0qWO.js → NetworkPage-Ot4G2dX5.js} +2 -2
- package/static/dashboard/assets/{PaneListHeader-D0c1yCFH.js → PaneListHeader-qHME_s08.js} +1 -1
- package/static/dashboard/assets/SearchIndexingPanel-HZPKj8H9.js +1 -0
- package/static/dashboard/assets/{StatusSubjectPanel-oPSECj7i.js → StatusSubjectPanel-ij7IpI8d.js} +1 -1
- package/static/dashboard/assets/{StatusWorkspace-PdovQPKa.js → StatusWorkspace-Cp02JcaN.js} +1 -1
- package/static/dashboard/assets/{SystemSettingsPage-CtNDklkx.js → SystemSettingsPage-BSeuvb8X.js} +1 -1
- package/static/{settings/assets/SystemSettingsSubjectPanel-DExjDo_v.js → dashboard/assets/SystemSettingsSubjectPanel-CP4_luGS.js} +5 -5
- package/static/dashboard/assets/XpodAiConnectionsPodStore-urO6zaHL.js +18 -0
- package/static/dashboard/assets/{activity-B9ylSoyr.js → activity-DxjgQNvr.js} +1 -1
- package/static/dashboard/assets/ai-connections-CXp5gd1J.js +1 -0
- package/static/dashboard/assets/{badge-BNbFbpIb.js → badge-53qCrRbl.js} +1 -1
- package/static/dashboard/assets/collection-runtime-BPAmHG46.js +1 -0
- package/static/dashboard/assets/{dashboard-CD-FFVRD.js → dashboard-BcT2ByXw.js} +4 -4
- package/static/dashboard/assets/dashboard-Cx9D_1qj.css +1 -0
- package/static/dashboard/assets/dialog-B28YtNhS.js +1 -0
- package/static/dashboard/assets/{download-nOP38LtW.js → download-DkLNceJ4.js} +1 -1
- package/static/dashboard/assets/{external-link-Bh2ewN9E.js → external-link-D3TXnlo3.js} +1 -1
- package/static/dashboard/assets/index-CFIenkeK.js +41 -0
- package/static/dashboard/assets/index-CIiBu9mr.js +1 -0
- package/static/dashboard/assets/index-Gp3cLolR.js +4 -0
- package/static/dashboard/assets/{key-round-bGmguBLv.js → key-round-B5ccp6nx.js} +1 -1
- package/static/dashboard/assets/layout-DB3pMyTl.js +1 -0
- package/static/dashboard/assets/pod-collections-host-KnnGFZHL.js +8 -0
- package/static/dashboard/assets/{rotate-ccw-D2x__ODW.js → rotate-ccw-DUpfkNnk.js} +1 -1
- package/static/dashboard/assets/{skeleton-VOqft8WS.js → skeleton-BRe19fO0.js} +1 -1
- package/static/dashboard/assets/{waypoints-fgRqm4oH.js → waypoints-BKDMxEvu.js} +1 -1
- package/static/dashboard/assets/{workspace-layout-DV4dgeHX.js → workspace-layout-ZTF7C16h.js} +1 -1
- package/static/dashboard/dashboard.html +2 -2
- package/static/settings/assets/AiConfigContext-DsyWgu2i.js +1 -0
- package/static/settings/assets/AiConfigPage-CSCBckKo.js +1 -0
- package/static/settings/assets/DocumentProcessingPanel-w9yQDbBe.js +1 -0
- package/static/settings/assets/IndexLifecyclePanel-CUUXI8mP.js +1 -0
- package/static/settings/assets/{IndexSubjectPanel-BgbI9c-a.js → IndexSubjectPanel-BypAU5TJ.js} +1 -1
- package/static/settings/assets/ModelAssignmentsPanel-BetgXw1G.js +1 -0
- package/static/settings/assets/ModelsPage-DZpTlTZ3.js +11 -0
- package/static/settings/assets/{NetworkPage-C8OA9Mtp.js → NetworkPage-BVkasFGM.js} +2 -2
- package/static/settings/assets/{PaneListHeader-COvlPJWj.js → PaneListHeader-BGOqGec4.js} +1 -1
- package/static/settings/assets/SearchIndexingPanel-DYAbpZ_9.js +1 -0
- package/static/settings/assets/{StatusSubjectPanel-BuLml7qn.js → StatusSubjectPanel-CFgzeQ8Q.js} +1 -1
- package/static/settings/assets/StatusWorkspace-4Z6g4Jvv.js +1 -0
- package/static/settings/assets/{SystemSettingsPage-DlzmaWV-.js → SystemSettingsPage-C1tlrgvI.js} +1 -1
- package/static/{auth-callback/assets/SystemSettingsSubjectPanel-CDqRuC4t.js → settings/assets/SystemSettingsSubjectPanel-CcURI-1L.js} +5 -5
- package/static/settings/assets/XpodAiConnectionsPodStore-owBQc5nY.js +3 -0
- package/static/settings/assets/{activity-TLerXgMs.js → activity-CtBc9cNy.js} +1 -1
- package/static/settings/assets/ai-connections-C6yaE6WQ.js +1 -0
- package/static/settings/assets/{badge-Bcs8iWrH.js → badge--r-FDIhU.js} +1 -1
- package/static/settings/assets/collection-runtime-CnhPmwAM.js +1 -0
- package/static/settings/assets/dialog-B7ZRsjN7.js +1 -0
- package/static/settings/assets/{download-Ct3QmHPt.js → download-DgQ1F8QR.js} +1 -1
- package/static/settings/assets/{external-link-C8KiHbss.js → external-link-Bz7NckNO.js} +1 -1
- package/static/settings/assets/index-BdXwm8nh.js +4 -0
- package/static/settings/assets/index-CkGda_Pg.js +41 -0
- package/static/settings/assets/index-Vv-8Vslg.js +1 -0
- package/static/settings/assets/{index-browser-CazX1pc2.js → index-browser-Dq7omlpY.js} +1 -1
- package/static/settings/assets/{key-round-B19YD1GA.js → key-round-CvuhloKV.js} +1 -1
- package/static/settings/assets/layout-DB3pMyTl.js +1 -0
- package/static/settings/assets/pod-collections-host-KnnGFZHL.js +8 -0
- package/static/settings/assets/{rotate-ccw-AQm2kMgU.js → rotate-ccw-DgFKDaz7.js} +1 -1
- package/static/settings/assets/{settings-C-VBtt9r.js → settings-BvqY7K96.js} +5 -5
- package/static/settings/assets/settings-Cx9D_1qj.css +1 -0
- package/static/settings/assets/{skeleton-DyZ1OBYf.js → skeleton-D3OeFDF6.js} +1 -1
- package/static/settings/assets/{waypoints-CC3wq-SU.js → waypoints-C4WbspTb.js} +1 -1
- package/static/settings/assets/{workspace-layout-BxXNKgf9.js → workspace-layout-B9H1Tqrk.js} +1 -1
- package/static/settings/settings.html +2 -2
- package/node_modules/@undefineds.co/ai-connections/dist/ai-connections-client.js +0 -13
- package/node_modules/@undefineds.co/ai-connections/dist/provider-catalog.d.ts +0 -9
- package/static/auth-callback/assets/AiConfigContext-DqWRSm7n.js +0 -1
- package/static/auth-callback/assets/AiConfigPage-C5YYyvzl.js +0 -1
- package/static/auth-callback/assets/DocumentProcessingPanel-DZCiacBz.js +0 -1
- package/static/auth-callback/assets/IndexLifecyclePanel-CCLeOljB.js +0 -1
- package/static/auth-callback/assets/ModelAssignmentsPanel-jUUTDKuh.js +0 -1
- package/static/auth-callback/assets/ModelsPage-B08zdtff.js +0 -10
- package/static/auth-callback/assets/SearchIndexingPanel-D4YRg1-8.js +0 -1
- package/static/auth-callback/assets/StatusWorkspace-Cp5LQ9Yx.js +0 -1
- package/static/auth-callback/assets/ai-connections-CHNTKemd.js +0 -1
- package/static/auth-callback/assets/auth-callback-DWMMiFjh.css +0 -1
- package/static/auth-callback/assets/index-DSNnLUbU.js +0 -4
- package/static/auth-callback/assets/index-FHhHoKgp.js +0 -41
- package/static/dashboard/assets/AiConfigContext-BpPDKSzI.js +0 -1
- package/static/dashboard/assets/AiConfigPage-wsqEZDIX.js +0 -1
- package/static/dashboard/assets/DocumentProcessingPanel-CDSy3juc.js +0 -1
- package/static/dashboard/assets/IndexLifecyclePanel-CVd6vQCX.js +0 -1
- package/static/dashboard/assets/ModelAssignmentsPanel-BeBZhnQd.js +0 -1
- package/static/dashboard/assets/ModelsPage-B6McSCJw.js +0 -25
- package/static/dashboard/assets/SearchIndexingPanel-CGs0OZ12.js +0 -1
- package/static/dashboard/assets/ai-connections-CHNTKemd.js +0 -1
- package/static/dashboard/assets/dashboard-DWMMiFjh.css +0 -1
- package/static/dashboard/assets/index-PgS-Bt7X.js +0 -41
- package/static/dashboard/assets/index-QN2QgEwr.js +0 -4
- package/static/settings/assets/AiConfigContext-zKQYdfai.js +0 -1
- package/static/settings/assets/AiConfigPage-Bs1EE3Ei.js +0 -1
- package/static/settings/assets/DocumentProcessingPanel-CSFfdOXS.js +0 -1
- package/static/settings/assets/IndexLifecyclePanel-BR9Su49B.js +0 -1
- package/static/settings/assets/ModelAssignmentsPanel-C0BE7nbk.js +0 -1
- package/static/settings/assets/ModelsPage-CU-YQ8_7.js +0 -10
- package/static/settings/assets/SearchIndexingPanel-Bdd46mIV.js +0 -1
- package/static/settings/assets/ai-connections-CHNTKemd.js +0 -1
- package/static/settings/assets/index-1Q2cRjZd.js +0 -41
- package/static/settings/assets/index-DBO_Vq0P.js +0 -4
- package/static/settings/assets/settings-DWMMiFjh.css +0 -1
- /package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client/request.d.ts +0 -0
- /package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client/types.js +0 -0
- /package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/codex.d.ts +0 -0
- /package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/codex.js +0 -0
- /package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/index.d.ts +0 -0
- /package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/index.js +0 -0
- /package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/json-env-adapter.d.ts +0 -0
- /package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/json-env-adapter.js +0 -0
- /package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/pi.d.ts +0 -0
- /package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/pi.js +0 -0
- /package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/transaction.d.ts +0 -0
- /package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/transaction.js +0 -0
- /package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/types.d.ts +0 -0
- /package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/types.js +0 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { AiConnectionsPodStore, WebExtensionHost } from '@undefineds.co/extension-sdk/web';
|
|
2
|
+
import type { AiConnectionsClient } from '@undefineds.co/ai-connections-core/client';
|
|
3
|
+
import { type CredentialCollection } from './collections';
|
|
4
|
+
/**
|
|
5
|
+
* The half of the credentials table that needs the collection layer at runtime.
|
|
6
|
+
*
|
|
7
|
+
* This module is reached **only** through `collections.credentialCollectionRuntime()`
|
|
8
|
+
* (a dynamic import): it is the single place in the applet that pulls
|
|
9
|
+
* `@undefineds.co/pod-collections` - and with it the TanStack DB engine - so the
|
|
10
|
+
* settings entry and every page that renders the applet without live rows do not
|
|
11
|
+
* carry that weight (`docs/pod-collections.md` §9-9).
|
|
12
|
+
*
|
|
13
|
+
* Everything here is behind an `await`: defining the table (the host may still be
|
|
14
|
+
* fetching the engine), reading rows and writing rows. The page keeps rendering
|
|
15
|
+
* the store's own summary until it lands, which is exactly how it behaves when
|
|
16
|
+
* the host offers no `podCollections` capability at all.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* The host's live credentials collection, or `undefined` when the host offers no
|
|
20
|
+
* `podCollections` capability (or cannot lay the table out).
|
|
21
|
+
*
|
|
22
|
+
* A missing capability is a degradation, not an error: the page keeps reading
|
|
23
|
+
* through the store exactly as before. `layout_document_required` cannot happen
|
|
24
|
+
* for this descriptor (its document is derived from `storage.base`) but is
|
|
25
|
+
* handled the same way rather than taking the page down with it.
|
|
26
|
+
*
|
|
27
|
+
* `load()` is the host accessor that works whether the collection engine is
|
|
28
|
+
* already in the host or still arriving; `define()` is the eager host's
|
|
29
|
+
* synchronous path and stays the fallback for a host that does not implement it.
|
|
30
|
+
*/
|
|
31
|
+
export declare function openCredentialCollection(host: WebExtensionHost): Promise<CredentialCollection | undefined>;
|
|
32
|
+
/** Inverse of {@link credentialIdOfRow}: collection key for a credential resource id. */
|
|
33
|
+
export declare function credentialRowKey(id: string): string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* The credential mutations of `AiConnectionsClient`, backed by the collection.
|
|
36
|
+
*
|
|
37
|
+
* Everything the descriptor declares is written through `insert` / `update` /
|
|
38
|
+
* `delete`, so it is optimistic, rolls back on rejection and reconciles with the
|
|
39
|
+
* document instead of being overwritten by the next read. Everything it cannot
|
|
40
|
+
* express - the secret envelope, `offeringId`, `metadata`, base URLs,
|
|
41
|
+
* `compatibility` - is written by the store within the same user action; if that
|
|
42
|
+
* completion fails, the row the collection created is deleted again and a
|
|
43
|
+
* partially applied update is put back, so a failed write leaves no
|
|
44
|
+
* half-written credential behind.
|
|
45
|
+
*/
|
|
46
|
+
export declare function collectionCredentialMutations(credentials: CredentialCollection, store: AiConnectionsPodStore): Pick<AiConnectionsClient, 'createApiKeyCredential' | 'createLocalCredential' | 'updateProviderCredential' | 'deleteProviderCredential'>;
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { credentialDescriptor, credentialResource } from '@undefineds.co/models';
|
|
2
|
+
import { rowKeyOf } from '@undefineds.co/pod-collections';
|
|
3
|
+
import { credentialProviderRelation, credentialRowKeyFor, customCredentialProviderRelation, } from '@undefineds.co/ai-connections-core/client';
|
|
4
|
+
import { credentialSummaryFromRow } from './collections.js';
|
|
5
|
+
import { normalizeProxyUrl } from '@undefineds.co/ai-connections-core/client';
|
|
6
|
+
import { credentialOfferingMetadata, defaultOfferingFor, offeringBaseUrl, storedOfferingIdFor, } from '@undefineds.co/ai-connections-core/provider-catalog';
|
|
7
|
+
/**
|
|
8
|
+
* The half of the credentials table that needs the collection layer at runtime.
|
|
9
|
+
*
|
|
10
|
+
* This module is reached **only** through `collections.credentialCollectionRuntime()`
|
|
11
|
+
* (a dynamic import): it is the single place in the applet that pulls
|
|
12
|
+
* `@undefineds.co/pod-collections` - and with it the TanStack DB engine - so the
|
|
13
|
+
* settings entry and every page that renders the applet without live rows do not
|
|
14
|
+
* carry that weight (`docs/pod-collections.md` §9-9).
|
|
15
|
+
*
|
|
16
|
+
* Everything here is behind an `await`: defining the table (the host may still be
|
|
17
|
+
* fetching the engine), reading rows and writing rows. The page keeps rendering
|
|
18
|
+
* the store's own summary until it lands, which is exactly how it behaves when
|
|
19
|
+
* the host offers no `podCollections` capability at all.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* The host's live credentials collection, or `undefined` when the host offers no
|
|
23
|
+
* `podCollections` capability (or cannot lay the table out).
|
|
24
|
+
*
|
|
25
|
+
* A missing capability is a degradation, not an error: the page keeps reading
|
|
26
|
+
* through the store exactly as before. `layout_document_required` cannot happen
|
|
27
|
+
* for this descriptor (its document is derived from `storage.base`) but is
|
|
28
|
+
* handled the same way rather than taking the page down with it.
|
|
29
|
+
*
|
|
30
|
+
* `load()` is the host accessor that works whether the collection engine is
|
|
31
|
+
* already in the host or still arriving; `define()` is the eager host's
|
|
32
|
+
* synchronous path and stays the fallback for a host that does not implement it.
|
|
33
|
+
*/
|
|
34
|
+
export async function openCredentialCollection(host) {
|
|
35
|
+
const capability = host.capabilities.podCollections;
|
|
36
|
+
if (!capability)
|
|
37
|
+
return undefined;
|
|
38
|
+
try {
|
|
39
|
+
if (capability.load) {
|
|
40
|
+
return { collection: await capability.load(credentialDescriptor, { table: credentialResource }) };
|
|
41
|
+
}
|
|
42
|
+
return { collection: capability.define(credentialDescriptor, { table: credentialResource }) };
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** Inverse of {@link credentialIdOfRow}: collection key for a credential resource id. */
|
|
49
|
+
export function credentialRowKey(id) {
|
|
50
|
+
if (!id.includes('#'))
|
|
51
|
+
return id;
|
|
52
|
+
return rowKeyOf(credentialDescriptor, { id });
|
|
53
|
+
}
|
|
54
|
+
/** Writes a row the descriptor declares; confirmation is the collection's own protocol. */
|
|
55
|
+
async function insertCredentialRow(collection, row) {
|
|
56
|
+
await collection.insert(row).isPersisted.promise;
|
|
57
|
+
}
|
|
58
|
+
/** Patches the descriptor-declared fields of one row (label, status, …). */
|
|
59
|
+
async function updateCredentialRow(collection, key, patch) {
|
|
60
|
+
await collection.update(key, (draft) => {
|
|
61
|
+
Object.assign(draft, patch);
|
|
62
|
+
}).isPersisted.promise;
|
|
63
|
+
}
|
|
64
|
+
async function deleteCredentialRow(collection, key) {
|
|
65
|
+
await collection.delete(key).isPersisted.promise;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The row a create writes through the collection: exactly the columns the
|
|
69
|
+
* models descriptor declares.
|
|
70
|
+
*
|
|
71
|
+
* The secret envelope is deliberately absent, and not because the confirmation
|
|
72
|
+
* protocol could not handle it any more (that defect is fixed: a write intent
|
|
73
|
+
* carrying a `secret: true` field now confirms, §9-7). It is absent because the
|
|
74
|
+
* store owns it: `encryptedSecret` is built by the store's encryption path.
|
|
75
|
+
*
|
|
76
|
+
* `offeringId` / `metadata` / `baseUrl` / `proxyUrl` are a different case: models
|
|
77
|
+
* 0.2.57 **does** declare them, so a read projects them back and this row has to
|
|
78
|
+
* carry the same values the store writes or our own echo looks like a change and
|
|
79
|
+
* replaces the row (see `credentials collection` in
|
|
80
|
+
* `packages/ai-connections/test/pod-collections.test.tsx`). Their derivation
|
|
81
|
+
* currently lives in the store adapter, which is why this row still omits them;
|
|
82
|
+
* reconciling that is the open item, not a decision this comment can settle.
|
|
83
|
+
*/
|
|
84
|
+
function newCredentialRow(key, input) {
|
|
85
|
+
const { provider } = input;
|
|
86
|
+
// The offering columns are derived here exactly as the store derives them, so
|
|
87
|
+
// the row the collection writes is already the row the store will confirm.
|
|
88
|
+
const offeringId = storedOfferingIdFor(provider, input.offeringId ?? defaultOfferingFor(provider, input.authMode));
|
|
89
|
+
const baseUrl = input.baseUrl ?? offeringBaseUrl(provider, offeringId);
|
|
90
|
+
const proxyUrl = normalizeProxyUrl(input.proxyUrl);
|
|
91
|
+
return {
|
|
92
|
+
id: key,
|
|
93
|
+
service: 'ai',
|
|
94
|
+
// The credential descriptor's provider relation (models 0.2.57 names the
|
|
95
|
+
// field `provider`; the retired `providerId` still compiles because `RowOf`
|
|
96
|
+
// carries an index signature, and read back `undefined` at runtime).
|
|
97
|
+
provider: provider === 'custom'
|
|
98
|
+
? customCredentialProviderRelation(key)
|
|
99
|
+
: credentialProviderRelation(provider),
|
|
100
|
+
authMode: input.authMode,
|
|
101
|
+
status: 'active',
|
|
102
|
+
accountLabel: input.accountLabel,
|
|
103
|
+
label: input.accountLabel,
|
|
104
|
+
keyVersion: '1',
|
|
105
|
+
reauthRequired: false,
|
|
106
|
+
encryptionAlgorithm: 'PLAINTEXT',
|
|
107
|
+
offeringId,
|
|
108
|
+
...(baseUrl ? { baseUrl } : {}),
|
|
109
|
+
...(proxyUrl ? { proxyUrl } : {}),
|
|
110
|
+
metadata: credentialOfferingMetadata({ offeringId, baseUrl }),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The credential mutations of `AiConnectionsClient`, backed by the collection.
|
|
115
|
+
*
|
|
116
|
+
* Everything the descriptor declares is written through `insert` / `update` /
|
|
117
|
+
* `delete`, so it is optimistic, rolls back on rejection and reconciles with the
|
|
118
|
+
* document instead of being overwritten by the next read. Everything it cannot
|
|
119
|
+
* express - the secret envelope, `offeringId`, `metadata`, base URLs,
|
|
120
|
+
* `compatibility` - is written by the store within the same user action; if that
|
|
121
|
+
* completion fails, the row the collection created is deleted again and a
|
|
122
|
+
* partially applied update is put back, so a failed write leaves no
|
|
123
|
+
* half-written credential behind.
|
|
124
|
+
*/
|
|
125
|
+
export function collectionCredentialMutations(credentials, store) {
|
|
126
|
+
const { collection } = credentials;
|
|
127
|
+
const discard = async (key) => {
|
|
128
|
+
await deleteCredentialRow(collection, key).catch(() => undefined);
|
|
129
|
+
};
|
|
130
|
+
const summaryOf = (key, provider) => {
|
|
131
|
+
const row = collection.get(key);
|
|
132
|
+
return row ? credentialSummaryFromRow(row, provider) : undefined;
|
|
133
|
+
};
|
|
134
|
+
const create = async (provider, key, row, complete) => {
|
|
135
|
+
await insertCredentialRow(collection, row);
|
|
136
|
+
try {
|
|
137
|
+
const completed = await complete(credentialResource.buildId({ id: key }));
|
|
138
|
+
const summary = completed ?? summaryOf(key, provider);
|
|
139
|
+
if (!summary)
|
|
140
|
+
throw new Error('credential_create_failed');
|
|
141
|
+
return summary;
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
await discard(key);
|
|
145
|
+
throw error;
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
return {
|
|
149
|
+
async createApiKeyCredential(provider, input) {
|
|
150
|
+
if (!store.createApiKeyCredential)
|
|
151
|
+
throw new Error('credential_store_unavailable');
|
|
152
|
+
const key = credentialRowKeyFor(provider, 'apiKey');
|
|
153
|
+
const label = input.label ?? provider;
|
|
154
|
+
return await create(provider, key, newCredentialRow(key, {
|
|
155
|
+
provider,
|
|
156
|
+
authMode: 'apiKey',
|
|
157
|
+
accountLabel: label,
|
|
158
|
+
offeringId: input.offeringId,
|
|
159
|
+
baseUrl: input.baseUrl,
|
|
160
|
+
proxyUrl: input.proxyUrl,
|
|
161
|
+
}), (id) => store.createApiKeyCredential(provider, { ...input, label, id }));
|
|
162
|
+
},
|
|
163
|
+
async createLocalCredential(provider, input) {
|
|
164
|
+
if (!store.createLocalCredential)
|
|
165
|
+
throw new Error('credential_store_unavailable');
|
|
166
|
+
const key = credentialRowKeyFor(provider, 'local');
|
|
167
|
+
const label = input.label ?? 'Local';
|
|
168
|
+
return await create(provider, key, newCredentialRow(key, {
|
|
169
|
+
provider,
|
|
170
|
+
authMode: 'local',
|
|
171
|
+
accountLabel: label,
|
|
172
|
+
offeringId: input.offeringId,
|
|
173
|
+
baseUrl: input.baseUrl,
|
|
174
|
+
}), (id) => store.createLocalCredential(provider, { ...input, label, id }));
|
|
175
|
+
},
|
|
176
|
+
async updateProviderCredential(provider, credentialId, input) {
|
|
177
|
+
const key = credentialRowKey(credentialId);
|
|
178
|
+
if (!key)
|
|
179
|
+
throw new Error('credential_not_found');
|
|
180
|
+
// `label` and `enabled` are descriptor fields: they land optimistically
|
|
181
|
+
// through the collection. Priority and base URLs are not, so they go to
|
|
182
|
+
// the store within the same call. Built as a literal because models 0.2.59
|
|
183
|
+
// declares these row fields readonly.
|
|
184
|
+
const patch = {
|
|
185
|
+
...(input.label === undefined ? {} : { label: input.label, accountLabel: input.label }),
|
|
186
|
+
...(input.enabled === undefined ? {} : { status: input.enabled ? 'active' : 'disabled' }),
|
|
187
|
+
};
|
|
188
|
+
const before = collection.get(key);
|
|
189
|
+
if (Object.keys(patch).length > 0)
|
|
190
|
+
await updateCredentialRow(collection, key, patch);
|
|
191
|
+
const attributes = {
|
|
192
|
+
...(input.priority === undefined ? {} : { priority: input.priority }),
|
|
193
|
+
...(input.baseUrl === undefined ? {} : { baseUrl: input.baseUrl }),
|
|
194
|
+
...(input.proxyUrl === undefined ? {} : { proxyUrl: input.proxyUrl }),
|
|
195
|
+
};
|
|
196
|
+
if (Object.keys(attributes).length === 0)
|
|
197
|
+
return summaryOf(key, provider);
|
|
198
|
+
if (!store.updateProviderCredential)
|
|
199
|
+
throw new Error('credential_store_unavailable');
|
|
200
|
+
try {
|
|
201
|
+
const completed = await store.updateProviderCredential(provider, credentialId, {
|
|
202
|
+
expectedVersion: input.expectedVersion,
|
|
203
|
+
...attributes,
|
|
204
|
+
});
|
|
205
|
+
return completed ?? summaryOf(key, provider);
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
// The optimistic part must not survive a rejected completion: put the
|
|
209
|
+
// row's own fields back, then report the failure.
|
|
210
|
+
if (before && Object.keys(patch).length > 0) {
|
|
211
|
+
await updateCredentialRow(collection, key, {
|
|
212
|
+
...(patch.label === undefined ? {} : {
|
|
213
|
+
label: before.label,
|
|
214
|
+
accountLabel: before.accountLabel,
|
|
215
|
+
}),
|
|
216
|
+
...(patch.status === undefined ? {} : { status: before.status }),
|
|
217
|
+
}).catch(() => undefined);
|
|
218
|
+
}
|
|
219
|
+
throw error;
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
async deleteProviderCredential(provider, credentialId) {
|
|
223
|
+
const key = credentialRowKey(credentialId);
|
|
224
|
+
if (!key)
|
|
225
|
+
return undefined;
|
|
226
|
+
const before = summaryOf(key, provider);
|
|
227
|
+
await deleteCredentialRow(collection, key);
|
|
228
|
+
return before;
|
|
229
|
+
},
|
|
230
|
+
};
|
|
231
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { credentialDescriptor } from '@undefineds.co/models';
|
|
2
|
+
import type { PodCollection, RowOf } from '@undefineds.co/pod-collections';
|
|
3
|
+
import type { AiConnectionsProvider, AiProviderCredentialSummary, AiProviderSummary } from '@undefineds.co/ai-connections-core/client';
|
|
4
|
+
/**
|
|
5
|
+
* The credentials table, declared once (`docs/pod-collections.md` §6.4-2).
|
|
6
|
+
*
|
|
7
|
+
* This module is the *shape* of the table and everything that can be computed
|
|
8
|
+
* from a row without the collection layer: the row type, the projection of a row
|
|
9
|
+
* into the summary the page renders, and the enrichment carriers. Nothing here
|
|
10
|
+
* imports `@undefineds.co/pod-collections` at runtime - the row type is a type,
|
|
11
|
+
* and the two things that do need the layer (declaring the table, reading and
|
|
12
|
+
* writing its rows) live in `./collection-runtime`, which is reached through the
|
|
13
|
+
* dynamic import below. That is what keeps the engine out of the settings
|
|
14
|
+
* entry's chunk and out of any page that renders without live rows (§9-9).
|
|
15
|
+
*
|
|
16
|
+
* The one read the page does here, `useCredentialRows`, is a `useSyncExternalStore`
|
|
17
|
+
* subscription to a rows source (the controller's live snapshot of the
|
|
18
|
+
* collection). It is deliberately not `@tanstack/react-db`'s `useLiveQuery`: the
|
|
19
|
+
* page needs "all rows of one table, once its first read landed", which the
|
|
20
|
+
* collection's own change feed answers, and loading a hook lazily would force
|
|
21
|
+
* the whole panel to remount when the chunk arrived. The design doc names this
|
|
22
|
+
* exit explicitly (§7.4-4, §8.7-5: engine only, no react hook).
|
|
23
|
+
*
|
|
24
|
+
* ## What the collection can carry, and what it cannot (yet)
|
|
25
|
+
*
|
|
26
|
+
* Rows are the descriptor's projection: `id`, `service`, `provider`, `label`,
|
|
27
|
+
* `accountLabel`, `authMode`, `status`, `keyVersion`, `expiresAt`,
|
|
28
|
+
* `reauthRequired`, … The known schema drift (locked by
|
|
29
|
+
* `packages/pod-collections/test/guards.test.ts`) means `offeringId`,
|
|
30
|
+
* `metadata`, `baseUrl` and `proxyUrl` are **not** projectable, and `secret`
|
|
31
|
+
* fields are not projected however they are written. So
|
|
32
|
+
*
|
|
33
|
+
* - reading carries the undeclared attributes over from the store's own summary
|
|
34
|
+
* of the same row (`credentialCarriers`), and
|
|
35
|
+
* - writing hands them to the store (`AiConnectionsPodStore`), which owns those
|
|
36
|
+
* columns and the secret envelope.
|
|
37
|
+
*
|
|
38
|
+
* Both are migration-window behaviour. models 0.2.57 now declares all four, so
|
|
39
|
+
* their delete condition is formally met, but they stay until the descriptor
|
|
40
|
+
* projection work (P4) retires the carrier path as a whole - removing them one
|
|
41
|
+
* at a time would leave reads and writes disagreeing in between.
|
|
42
|
+
*/
|
|
43
|
+
/** A credentials-table row as the collection projects it. */
|
|
44
|
+
export type CredentialRow = RowOf<typeof credentialDescriptor>;
|
|
45
|
+
/** The collection's `syncState` is the page's availability signal. */
|
|
46
|
+
export interface CredentialCollection {
|
|
47
|
+
readonly collection: PodCollection<CredentialRow>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A live rows source: the controller's snapshot of the credentials collection.
|
|
51
|
+
*
|
|
52
|
+
* `credentialRows` is `undefined` until the collection's first read lands - and
|
|
53
|
+
* stays `undefined` while the collection layer is still loading, when the host
|
|
54
|
+
* offers no `podCollections` capability, or after a failed first read. The page
|
|
55
|
+
* keeps its store-backed rendering in every one of those states.
|
|
56
|
+
*/
|
|
57
|
+
export interface CredentialRowsSource {
|
|
58
|
+
subscribe(listener: () => void): () => void;
|
|
59
|
+
readonly credentialRows?: readonly CredentialRow[];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Live rows for the credentials table. Re-renders on sync and on optimistic
|
|
63
|
+
* writes, because the source is the collection's own change feed.
|
|
64
|
+
*/
|
|
65
|
+
export declare function useCredentialRows(source: CredentialRowsSource): readonly CredentialRow[] | undefined;
|
|
66
|
+
/** The lazy half of this module's subject: everything that needs the engine. */
|
|
67
|
+
export type CredentialCollectionRuntime = typeof import('./collection-runtime');
|
|
68
|
+
/**
|
|
69
|
+
* The collection layer at the point of use, fetched once.
|
|
70
|
+
*
|
|
71
|
+
* This is the applet's only dynamic import of it: the settings entry and the
|
|
72
|
+
* applet's own chunk contain no part of the engine, and a page that never
|
|
73
|
+
* reaches the credentials list never fetches it.
|
|
74
|
+
*/
|
|
75
|
+
export declare function credentialCollectionRuntime(): Promise<CredentialCollectionRuntime>;
|
|
76
|
+
/**
|
|
77
|
+
* The row's resource id in the shape the rest of the applet uses for
|
|
78
|
+
* credentials: `credentials.ttl#<key>`. The collection's key is only the
|
|
79
|
+
* `resourceIdPattern` slot (`#{id}` → `openai-<uuid>`), so the document segment
|
|
80
|
+
* comes from the same models builder the store writes with.
|
|
81
|
+
*/
|
|
82
|
+
export declare function credentialIdOfRow(row: CredentialRow): string;
|
|
83
|
+
/**
|
|
84
|
+
* Which provider a row belongs to, from the row's own `provider` relation.
|
|
85
|
+
*
|
|
86
|
+
* Rows have to be attributable without the store's help: a credential another
|
|
87
|
+
* device just wrote reaches this page as a live row, before any summary read
|
|
88
|
+
* has seen it.
|
|
89
|
+
*/
|
|
90
|
+
export declare function providerOfCredentialRow(row: CredentialRow): AiConnectionsProvider | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* A row as the page's credential summary.
|
|
93
|
+
*
|
|
94
|
+
* The row wins for everything the descriptor declares; `carrier` - the store's
|
|
95
|
+
* summary of the same credential - supplies the attributes the descriptor cannot
|
|
96
|
+
* project and the secret-derived hint. A row the store has not read yet (an
|
|
97
|
+
* optimistic insert) falls back to the descriptor's own defaults.
|
|
98
|
+
*/
|
|
99
|
+
export declare function credentialSummaryFromRow(row: CredentialRow, provider: AiConnectionsProvider, carrier?: AiProviderCredentialSummary): AiProviderCredentialSummary;
|
|
100
|
+
/** The provider's credential list, rebuilt from the live rows of one table document. */
|
|
101
|
+
export declare function credentialSummariesForProvider(provider: AiConnectionsProvider, rows: readonly CredentialRow[], carrier?: readonly AiProviderCredentialSummary[]): AiProviderCredentialSummary[];
|
|
102
|
+
/**
|
|
103
|
+
* The enrichment carrier per provider: the store's own summary of every
|
|
104
|
+
* credential, plus any credential a mutation of this session added and the store
|
|
105
|
+
* has not read back yet.
|
|
106
|
+
*
|
|
107
|
+
* The store's entries win where both know the same credential - it is the
|
|
108
|
+
* independent read - and the session's overlay only fills the gap, so a
|
|
109
|
+
* just-created row keeps its offering and base URL while it is still optimistic.
|
|
110
|
+
*/
|
|
111
|
+
export declare function credentialCarriers(storeProducts: Partial<Record<AiConnectionsProvider, AiProviderSummary>>, overlayProducts: Partial<Record<AiConnectionsProvider, AiProviderSummary>>): Partial<Record<AiConnectionsProvider, readonly AiProviderCredentialSummary[]>>;
|
|
112
|
+
/**
|
|
113
|
+
* The provider products the page renders, with every credential list rebuilt
|
|
114
|
+
* from the live rows.
|
|
115
|
+
*
|
|
116
|
+
* `carriers` only enriches: which credentials exist, and every field the
|
|
117
|
+
* descriptor declares, come from the rows.
|
|
118
|
+
*/
|
|
119
|
+
export declare function withLiveCredentials(products: Partial<Record<AiConnectionsProvider, AiProviderSummary>>, carriers: Partial<Record<AiConnectionsProvider, readonly AiProviderCredentialSummary[]>>, rows: readonly CredentialRow[] | undefined): Partial<Record<AiConnectionsProvider, AiProviderSummary>>;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { credentialResource } from '@undefineds.co/models';
|
|
2
|
+
import { useSyncExternalStore } from 'react';
|
|
3
|
+
import { AI_CONNECTIONS_PROVIDERS } from '@undefineds.co/ai-connections-core/client';
|
|
4
|
+
import { defaultOfferingFor } from '@undefineds.co/ai-connections-core/provider-catalog';
|
|
5
|
+
import { providerOfCredentialKey, providerResourceKey } from '@undefineds.co/ai-connections-core/client';
|
|
6
|
+
/**
|
|
7
|
+
* Live rows for the credentials table. Re-renders on sync and on optimistic
|
|
8
|
+
* writes, because the source is the collection's own change feed.
|
|
9
|
+
*/
|
|
10
|
+
export function useCredentialRows(source) {
|
|
11
|
+
return useSyncExternalStore(source.subscribe, () => source.credentialRows, () => source.credentialRows);
|
|
12
|
+
}
|
|
13
|
+
let runtime;
|
|
14
|
+
/**
|
|
15
|
+
* The collection layer at the point of use, fetched once.
|
|
16
|
+
*
|
|
17
|
+
* This is the applet's only dynamic import of it: the settings entry and the
|
|
18
|
+
* applet's own chunk contain no part of the engine, and a page that never
|
|
19
|
+
* reaches the credentials list never fetches it.
|
|
20
|
+
*/
|
|
21
|
+
export function credentialCollectionRuntime() {
|
|
22
|
+
runtime ?? (runtime = import('./collection-runtime.js'));
|
|
23
|
+
return runtime;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The row's resource id in the shape the rest of the applet uses for
|
|
27
|
+
* credentials: `credentials.ttl#<key>`. The collection's key is only the
|
|
28
|
+
* `resourceIdPattern` slot (`#{id}` → `openai-<uuid>`), so the document segment
|
|
29
|
+
* comes from the same models builder the store writes with.
|
|
30
|
+
*/
|
|
31
|
+
export function credentialIdOfRow(row) {
|
|
32
|
+
return credentialResource.buildId({ id: String(row.id) });
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Which provider a row belongs to, from the row's own `provider` relation.
|
|
36
|
+
*
|
|
37
|
+
* Rows have to be attributable without the store's help: a credential another
|
|
38
|
+
* device just wrote reaches this page as a live row, before any summary read
|
|
39
|
+
* has seen it.
|
|
40
|
+
*/
|
|
41
|
+
export function providerOfCredentialRow(row) {
|
|
42
|
+
// `RowOf` carries an index signature (models types `fields` as
|
|
43
|
+
// `Record<string, PodModelFieldDescriptor>`), so a stale attribute name
|
|
44
|
+
// type-checks and reads back `undefined` at runtime instead of failing the
|
|
45
|
+
// build. `collections.test.ts` pins this read against a row whose id does not
|
|
46
|
+
// embed its provider, which is the only case the fallback below cannot answer.
|
|
47
|
+
const relation = typeof row.provider === 'string' ? row.provider : undefined;
|
|
48
|
+
const key = providerResourceKey(relation);
|
|
49
|
+
if (key) {
|
|
50
|
+
if (key.startsWith('custom-instance-'))
|
|
51
|
+
return 'custom';
|
|
52
|
+
const declared = AI_CONNECTIONS_PROVIDERS.find((provider) => key === provider || key.startsWith(`${provider}-`));
|
|
53
|
+
if (declared)
|
|
54
|
+
return declared;
|
|
55
|
+
}
|
|
56
|
+
// A row without a provider relation still declares one in its own key
|
|
57
|
+
// (`openai-<uuid>`); the store's reader falls back the same way.
|
|
58
|
+
return providerOfCredentialKey(String(row.id));
|
|
59
|
+
}
|
|
60
|
+
function stringValue(value) {
|
|
61
|
+
return typeof value === 'string' && value.trim() ? value : undefined;
|
|
62
|
+
}
|
|
63
|
+
function numberValue(value) {
|
|
64
|
+
if (typeof value === 'number' && Number.isFinite(value))
|
|
65
|
+
return value;
|
|
66
|
+
if (typeof value === 'string' && value.trim()) {
|
|
67
|
+
const parsed = Number(value);
|
|
68
|
+
return Number.isFinite(parsed) ? parsed : undefined;
|
|
69
|
+
}
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
function isoStringValue(value) {
|
|
73
|
+
if (value instanceof Date)
|
|
74
|
+
return value.toISOString();
|
|
75
|
+
return stringValue(value);
|
|
76
|
+
}
|
|
77
|
+
function authModeValue(value) {
|
|
78
|
+
if (value === 'oauth' || value === 'deviceCode' || value === 'apiKey' || value === 'local') {
|
|
79
|
+
return value;
|
|
80
|
+
}
|
|
81
|
+
if (value === 'deviceCodeOAuth')
|
|
82
|
+
return 'deviceCode';
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* A row as the page's credential summary.
|
|
87
|
+
*
|
|
88
|
+
* The row wins for everything the descriptor declares; `carrier` - the store's
|
|
89
|
+
* summary of the same credential - supplies the attributes the descriptor cannot
|
|
90
|
+
* project and the secret-derived hint. A row the store has not read yet (an
|
|
91
|
+
* optimistic insert) falls back to the descriptor's own defaults.
|
|
92
|
+
*/
|
|
93
|
+
export function credentialSummaryFromRow(row, provider, carrier) {
|
|
94
|
+
const authMode = authModeValue(row.authMode) ?? carrier?.authMode ?? 'apiKey';
|
|
95
|
+
const status = stringValue(row.status);
|
|
96
|
+
// models 0.2.59 types this column as a boolean; a Pod written by an older
|
|
97
|
+
// release can still carry the literal as a string, so keep tolerating both.
|
|
98
|
+
const reauthRequired = row.reauthRequired === true || String(row.reauthRequired) === 'true';
|
|
99
|
+
return {
|
|
100
|
+
id: String(row.id),
|
|
101
|
+
provider,
|
|
102
|
+
offeringId: carrier?.offeringId ?? defaultOfferingFor(provider, authMode),
|
|
103
|
+
authMode,
|
|
104
|
+
label: stringValue(row.accountLabel) ?? stringValue(row.label) ?? carrier?.label,
|
|
105
|
+
enabled: status === undefined ? carrier?.enabled ?? true : status === 'active',
|
|
106
|
+
priority: carrier?.priority ?? 100,
|
|
107
|
+
health: reauthRequired ? 'expired' : carrier?.health ?? 'unknown',
|
|
108
|
+
maskedHint: carrier?.maskedHint,
|
|
109
|
+
baseUrl: carrier?.baseUrl,
|
|
110
|
+
proxyUrl: carrier?.proxyUrl,
|
|
111
|
+
compatibility: carrier?.compatibility,
|
|
112
|
+
expiresAt: isoStringValue(row.expiresAt) ?? carrier?.expiresAt,
|
|
113
|
+
version: numberValue(row.keyVersion) ?? carrier?.version ?? 0,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/** The provider's credential list, rebuilt from the live rows of one table document. */
|
|
117
|
+
export function credentialSummariesForProvider(provider, rows, carrier = []) {
|
|
118
|
+
const byId = new Map(carrier.map((credential) => [credential.id, credential]));
|
|
119
|
+
const summaries = [];
|
|
120
|
+
for (const row of rows) {
|
|
121
|
+
if (providerOfCredentialRow(row) !== provider)
|
|
122
|
+
continue;
|
|
123
|
+
summaries.push(credentialSummaryFromRow(row, provider, byId.get(String(row.id))));
|
|
124
|
+
}
|
|
125
|
+
return summaries;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* The enrichment carrier per provider: the store's own summary of every
|
|
129
|
+
* credential, plus any credential a mutation of this session added and the store
|
|
130
|
+
* has not read back yet.
|
|
131
|
+
*
|
|
132
|
+
* The store's entries win where both know the same credential - it is the
|
|
133
|
+
* independent read - and the session's overlay only fills the gap, so a
|
|
134
|
+
* just-created row keeps its offering and base URL while it is still optimistic.
|
|
135
|
+
*/
|
|
136
|
+
export function credentialCarriers(storeProducts, overlayProducts) {
|
|
137
|
+
const carriers = {};
|
|
138
|
+
for (const provider of AI_CONNECTIONS_PROVIDERS) {
|
|
139
|
+
const byId = new Map();
|
|
140
|
+
for (const credential of overlayProducts[provider]?.credentials ?? []) {
|
|
141
|
+
byId.set(credential.id, credential);
|
|
142
|
+
}
|
|
143
|
+
for (const credential of storeProducts[provider]?.credentials ?? []) {
|
|
144
|
+
byId.set(credential.id, credential);
|
|
145
|
+
}
|
|
146
|
+
carriers[provider] = [...byId.values()];
|
|
147
|
+
}
|
|
148
|
+
return carriers;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* The provider products the page renders, with every credential list rebuilt
|
|
152
|
+
* from the live rows.
|
|
153
|
+
*
|
|
154
|
+
* `carriers` only enriches: which credentials exist, and every field the
|
|
155
|
+
* descriptor declares, come from the rows.
|
|
156
|
+
*/
|
|
157
|
+
export function withLiveCredentials(products, carriers, rows) {
|
|
158
|
+
if (!rows)
|
|
159
|
+
return products;
|
|
160
|
+
const live = {};
|
|
161
|
+
for (const provider of AI_CONNECTIONS_PROVIDERS) {
|
|
162
|
+
const product = products[provider];
|
|
163
|
+
if (!product)
|
|
164
|
+
continue;
|
|
165
|
+
live[provider] = {
|
|
166
|
+
...product,
|
|
167
|
+
credentials: credentialSummariesForProvider(provider, rows, carriers[provider] ?? []),
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
// Providers outside the catalog keep whatever the store reported: the page
|
|
171
|
+
// never renders them from this table.
|
|
172
|
+
return { ...products, ...live };
|
|
173
|
+
}
|