refactor(core): simplify integration credentials (#31968)

This commit is contained in:
Dax
2026-06-12 02:15:25 -04:00
committed by GitHub
parent a9c810cbbc
commit 30aec297d8
112 changed files with 2478 additions and 47739 deletions

View File

@@ -2,7 +2,7 @@ import { useEvent } from "./event"
import type {
AgentV2Info,
CommandV2Info,
ConnectorInfo,
IntegrationInfo,
Event,
LocationRef,
ModelV2Info,
@@ -27,7 +27,7 @@ import { createSignal, onMount } from "solid-js"
type LocationData = {
agent?: AgentV2Info[]
command?: CommandV2Info[]
connector?: ConnectorInfo[]
integration?: IntegrationInfo[]
model?: ModelV2Info[]
provider?: ProviderV2Info[]
reference?: ReferenceInfo[]
@@ -423,13 +423,8 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
case "reference.updated":
void result.location.reference.refresh()
break
case "credential.switched": {
const location = { directory: metadata.directory, workspaceID: metadata.workspace }
void Promise.allSettled([result.location.model.refresh(location), result.location.provider.refresh(location)])
break
}
case "connector.updated":
void result.location.connector.refresh({ directory: metadata.directory, workspaceID: metadata.workspace })
case "integration.updated":
void result.location.integration.refresh({ directory: metadata.directory, workspaceID: metadata.workspace })
break
}
})
@@ -513,14 +508,17 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
setStore("location", key, "command", result.data.data)
},
},
connector: {
integration: {
list(location?: LocationRef) {
return store.location[locationKey(location ?? defaultLocation())]?.connector
return store.location[locationKey(location ?? defaultLocation())]?.integration
},
async refresh(ref?: LocationRef) {
const result = await sdk.client.v2.connector.list({ location: locationQuery(ref) }, { throwOnError: true })
const result = await sdk.client.v2.integration.list(
{ location: locationQuery(ref) },
{ throwOnError: true },
)
const key = locationKey(result.data.location)
setStore("location", key, "connector", result.data.data)
setStore("location", key, "integration", result.data.data)
},
},
model: {
@@ -570,7 +568,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
void Promise.allSettled([
result.location.refresh(),
result.location.agent.refresh(),
result.location.connector.refresh(),
result.location.integration.refresh(),
result.location.model.refresh(),
result.location.provider.refresh(),
result.location.reference.refresh(),

View File

@@ -92,11 +92,11 @@ test("refreshes resources into reactive getters", async () => {
}
})
test("refreshes connectors after connector updates", async () => {
test("refreshes integrations after integration updates", async () => {
const events = createEventSource()
let requests = 0
const calls = createFetch((url) => {
if (url.pathname !== "/api/connector") return
if (url.pathname !== "/api/integration") return
requests++
return json({
location: { directory, project: { id: "proj_test", directory } },
@@ -107,7 +107,7 @@ test("refreshes connectors after connector updates", async () => {
{
id: "openai",
name: "OpenAI",
methods: [{ id: "api-key", type: "key", label: "API Key" }],
methods: [{ type: "key" }],
},
],
})
@@ -138,12 +138,12 @@ test("refreshes connectors after connector updates", async () => {
try {
await mounted
await wait(() => data.location.connector.list() !== undefined)
expect(data.location.connector.list()).toEqual([])
await wait(() => data.location.integration.list() !== undefined)
expect(data.location.integration.list()).toEqual([])
emitEvent(events, { id: "evt_connector", type: "connector.updated", properties: {} })
await wait(() => data.location.connector.list()?.length === 1)
expect(data.location.connector.list()?.[0]).toMatchObject({ id: "openai", name: "OpenAI" })
emitEvent(events, { id: "evt_integration", type: "integration.updated", properties: {} })
await wait(() => data.location.integration.list()?.length === 1)
expect(data.location.integration.list()?.[0]).toMatchObject({ id: "openai", name: "OpenAI" })
} finally {
app.renderer.destroy()
}

View File

@@ -61,7 +61,7 @@ export function createFetch(override?: FetchHandler) {
if (url.pathname === "/path") return json({ home: "", state: "", config: "", worktree, directory })
if (url.pathname === "/api/location") return json({ directory, project: { id: "proj_test", directory: worktree } })
if (
["/api/agent", "/api/model", "/api/provider", "/api/connector", "/api/command", "/api/skill"].includes(
["/api/agent", "/api/model", "/api/provider", "/api/integration", "/api/command", "/api/skill"].includes(
url.pathname,
)
)