mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-10 01:18:48 +00:00
refactor(core): derive catalog availability from integrations (#32272)
This commit is contained in:
parent
4810df0a71
commit
0cf3ee4406
29 changed files with 624 additions and 511 deletions
|
|
@ -1,30 +1,38 @@
|
|||
import { Credential } from "@opencode-ai/core/credential"
|
||||
import { Schema } from "effect"
|
||||
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/unstable/httpapi"
|
||||
import { LocationMiddleware, LocationQuery, locationQueryOpenApi } from "./location"
|
||||
|
||||
export const CredentialGroup = HttpApiGroup.make("server.credential")
|
||||
.add(
|
||||
HttpApiEndpoint.patch("credential.update", "/api/credential/:credentialID", {
|
||||
params: { credentialID: Credential.ID },
|
||||
query: LocationQuery,
|
||||
payload: Schema.Struct({ label: Schema.String }),
|
||||
success: HttpApiSchema.NoContent,
|
||||
}).annotateMerge(
|
||||
OpenApi.annotations({
|
||||
identifier: "v2.credential.update",
|
||||
summary: "Update credential",
|
||||
description: "Update a stored credential label.",
|
||||
}),
|
||||
),
|
||||
})
|
||||
.annotateMerge(locationQueryOpenApi)
|
||||
.annotateMerge(
|
||||
OpenApi.annotations({
|
||||
identifier: "v2.credential.update",
|
||||
summary: "Update credential",
|
||||
description: "Update a stored credential label.",
|
||||
}),
|
||||
),
|
||||
)
|
||||
.add(
|
||||
HttpApiEndpoint.delete("credential.remove", "/api/credential/:credentialID", {
|
||||
params: { credentialID: Credential.ID },
|
||||
query: LocationQuery,
|
||||
success: HttpApiSchema.NoContent,
|
||||
}).annotateMerge(
|
||||
OpenApi.annotations({
|
||||
identifier: "v2.credential.remove",
|
||||
summary: "Remove credential",
|
||||
description: "Remove a stored integration credential.",
|
||||
}),
|
||||
),
|
||||
})
|
||||
.annotateMerge(locationQueryOpenApi)
|
||||
.annotateMerge(
|
||||
OpenApi.annotations({
|
||||
identifier: "v2.credential.remove",
|
||||
summary: "Remove credential",
|
||||
description: "Remove a stored integration credential.",
|
||||
}),
|
||||
),
|
||||
)
|
||||
.middleware(LocationMiddleware)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Credential } from "@opencode-ai/core/credential"
|
||||
import { Integration } from "@opencode-ai/core/integration"
|
||||
import { Effect } from "effect"
|
||||
import { HttpApiBuilder, HttpApiSchema } from "effect/unstable/httpapi"
|
||||
import { Api } from "../api"
|
||||
|
|
@ -8,14 +8,14 @@ export const CredentialHandler = HttpApiBuilder.group(Api, "server.credential",
|
|||
.handle(
|
||||
"credential.update",
|
||||
Effect.fn(function* (ctx) {
|
||||
yield* (yield* Credential.Service).update(ctx.params.credentialID, { label: ctx.payload.label })
|
||||
yield* (yield* Integration.Service).connection.update(ctx.params.credentialID, { label: ctx.payload.label })
|
||||
return HttpApiSchema.NoContent.make()
|
||||
}),
|
||||
)
|
||||
.handle(
|
||||
"credential.remove",
|
||||
Effect.fn(function* (ctx) {
|
||||
yield* (yield* Credential.Service).remove(ctx.params.credentialID)
|
||||
yield* (yield* Integration.Service).connection.remove(ctx.params.credentialID)
|
||||
return HttpApiSchema.NoContent.make()
|
||||
}),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ export const IntegrationHandler = HttpApiBuilder.group(Api, "server.integration"
|
|||
Effect.fn(function* (ctx) {
|
||||
const service = yield* Integration.Service
|
||||
yield* authorize(
|
||||
service.connect.key({
|
||||
service.connection.key({
|
||||
integrationID: ctx.params.integrationID,
|
||||
key: ctx.payload.key,
|
||||
label: ctx.payload.label,
|
||||
|
|
@ -53,7 +53,7 @@ export const IntegrationHandler = HttpApiBuilder.group(Api, "server.integration"
|
|||
const service = yield* Integration.Service
|
||||
return yield* response(
|
||||
authorize(
|
||||
service.connect.oauth({
|
||||
service.connection.oauth({
|
||||
integrationID: ctx.params.integrationID,
|
||||
methodID: ctx.payload.methodID,
|
||||
inputs: ctx.payload.inputs,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue