fix(client): singularize generated api groups (#34534)
This commit is contained in:
parent
f928b5be07
commit
6846542115
21 changed files with 1913 additions and 557 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { TextAttributes } from "@opentui/core"
|
||||
import type { IntegrationsConnectOauthOutput } from "@opencode-ai/client"
|
||||
import type { IntegrationConnectOauthOutput } from "@opencode-ai/client"
|
||||
import type { ConnectionInfo, IntegrationInfo, IntegrationOAuthMethod } from "@opencode-ai/sdk/v2"
|
||||
import { createMemo, createSignal, onCleanup, onMount, Show } from "solid-js"
|
||||
import { useClipboard } from "../context/clipboard"
|
||||
|
|
@ -23,7 +23,7 @@ const INTEGRATION_PRIORITY: Record<string, number> = {
|
|||
}
|
||||
|
||||
type ConnectMethod = Exclude<IntegrationInfo["methods"][number], { type: "env" }>
|
||||
type IntegrationAttempt = IntegrationsConnectOauthOutput["data"]
|
||||
type IntegrationAttempt = IntegrationConnectOauthOutput["data"]
|
||||
|
||||
export function integrationOptions(list: IntegrationInfo[]) {
|
||||
return list.toSorted(
|
||||
|
|
@ -111,7 +111,7 @@ function manageConnections(
|
|||
title: `Disconnect ${connection.label}`,
|
||||
value: connection.id,
|
||||
onSelect: () => {
|
||||
void sdk.api.credentials
|
||||
void sdk.api.credential
|
||||
.remove({ credentialID: connection.id, location: location(data) })
|
||||
.then(() => disconnected(integration.name, data, dialog, toast))
|
||||
.catch(toast.error)
|
||||
|
|
@ -159,7 +159,7 @@ function KeyMethod(props: { integration: IntegrationInfo; method: Extract<Connec
|
|||
placeholder="API key"
|
||||
onConfirm={(key) => {
|
||||
if (!key) return
|
||||
void sdk.api.integrations
|
||||
void sdk.api.integration
|
||||
.connectKey({
|
||||
integrationID: props.integration.id,
|
||||
location: location(data),
|
||||
|
|
@ -194,7 +194,7 @@ function OAuthStarting(props: {
|
|||
const toast = useToast()
|
||||
|
||||
onMount(() => {
|
||||
void sdk.api.integrations
|
||||
void sdk.api.integration
|
||||
.connectOauth({
|
||||
integrationID: props.integration.id,
|
||||
location: location(data),
|
||||
|
|
@ -248,7 +248,7 @@ function OAuthAuto(props: { integration: IntegrationInfo; title: string; attempt
|
|||
}))
|
||||
|
||||
const poll = () => {
|
||||
void sdk.api.integrations
|
||||
void sdk.api.integration
|
||||
.attemptStatus({ attemptID: props.attempt.attemptID, location: location(data) })
|
||||
.then((result) => {
|
||||
const status = result.data
|
||||
|
|
@ -275,7 +275,7 @@ function OAuthAuto(props: { integration: IntegrationInfo; title: string; attempt
|
|||
onCleanup(() => {
|
||||
if (timer) clearTimeout(timer)
|
||||
if (settled) return
|
||||
void sdk.api.integrations.attemptCancel({ attemptID: props.attempt.attemptID, location: location(data) })
|
||||
void sdk.api.integration.attemptCancel({ attemptID: props.attempt.attemptID, location: location(data) })
|
||||
})
|
||||
|
||||
return (
|
||||
|
|
@ -300,7 +300,7 @@ function OAuthCode(props: { integration: IntegrationInfo; title: string; attempt
|
|||
|
||||
onCleanup(() => {
|
||||
if (settled) return
|
||||
void sdk.api.integrations.attemptCancel({ attemptID: props.attempt.attemptID, location: location(data) })
|
||||
void sdk.api.integration.attemptCancel({ attemptID: props.attempt.attemptID, location: location(data) })
|
||||
})
|
||||
|
||||
return (
|
||||
|
|
@ -309,7 +309,7 @@ function OAuthCode(props: { integration: IntegrationInfo; title: string; attempt
|
|||
placeholder="Authorization code"
|
||||
onConfirm={(code) => {
|
||||
if (!code) return
|
||||
void sdk.api.integrations
|
||||
void sdk.api.integration
|
||||
.attemptComplete({ attemptID: props.attempt.attemptID, location: location(data), code })
|
||||
.then(() => {
|
||||
settled = true
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ export function DialogMoveSession(props: DialogMoveSessionProps) {
|
|||
async (projectID, info): Promise<ReadonlyArray<ProjectDirectory> | undefined> => {
|
||||
try {
|
||||
const location = { directory: projectContext.instance.directory() || paths.cwd }
|
||||
await sdk.api.projectCopies.refresh({
|
||||
await sdk.api.projectCopy.refresh({
|
||||
projectID,
|
||||
location,
|
||||
})
|
||||
|
|
@ -227,7 +227,7 @@ export function DialogMoveSession(props: DialogMoveSessionProps) {
|
|||
setToDelete(undefined)
|
||||
setRemoving(selected.directory)
|
||||
setWorking(true)
|
||||
const error = await sdk.api.projectCopies
|
||||
const error = await sdk.api.projectCopy
|
||||
.remove({
|
||||
projectID: props.projectID,
|
||||
location: { directory: projectContext.instance.directory() || paths.cwd },
|
||||
|
|
@ -252,7 +252,7 @@ export function DialogMoveSession(props: DialogMoveSessionProps) {
|
|||
return
|
||||
}
|
||||
reopen(selected.directory)
|
||||
const forcedError = await sdk.api.projectCopies
|
||||
const forcedError = await sdk.api.projectCopy
|
||||
.remove({
|
||||
projectID: props.projectID,
|
||||
location: { directory: projectContext.instance.directory() || paths.cwd },
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ export function DialogSessionList() {
|
|||
const [searchResults] = createResource(search, async (query) => {
|
||||
if (!query) return
|
||||
const location = data.location.default()
|
||||
const response = await sdk.api.sessions.list({
|
||||
const response = await sdk.api.session.list({
|
||||
search: query,
|
||||
limit: 50,
|
||||
order: "desc",
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ export function DialogSessionRename(props: { sessionID: string; currentTitle?: s
|
|||
onConfirm={(value) => {
|
||||
const title = value.trim()
|
||||
if (!title) return
|
||||
void sdk.api.sessions
|
||||
void sdk.api.session
|
||||
.rename({ sessionID: props.sessionID, title })
|
||||
.then(() => dialog.clear())
|
||||
.catch((error) =>
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ export function DialogTag(props: { onSelect?: (value: string) => void }) {
|
|||
const [files] = createResource(
|
||||
() => [store.filter],
|
||||
async () => {
|
||||
const result = await sdk.api.files
|
||||
const result = await sdk.api.file
|
||||
.find({
|
||||
query: store.filter,
|
||||
type: "file",
|
||||
|
|
|
|||
|
|
@ -320,7 +320,7 @@ export function Autocomplete(props: {
|
|||
if (referenceMatch()) return []
|
||||
const { lineRange, baseQuery } = extractLineRange(input.query ?? "")
|
||||
|
||||
const result = await sdk.api.files
|
||||
const result = await sdk.api.file
|
||||
.find({
|
||||
query: baseQuery,
|
||||
limit: 20,
|
||||
|
|
|
|||
|
|
@ -425,7 +425,7 @@ export function Prompt(props: PromptProps) {
|
|||
}, 5000)
|
||||
|
||||
if (store.interrupt >= 2) {
|
||||
void sdk.api.sessions.interrupt({
|
||||
void sdk.api.session.interrupt({
|
||||
sessionID: props.sessionID,
|
||||
})
|
||||
setStore("interrupt", 0)
|
||||
|
|
@ -1012,7 +1012,7 @@ export function Prompt(props: PromptProps) {
|
|||
finishMoveProgress = Boolean(move.progress())
|
||||
const location = data.location.default()
|
||||
|
||||
const created = await sdk.api.sessions
|
||||
const created = await sdk.api.session
|
||||
.create({
|
||||
location: directory
|
||||
? { directory, workspaceID }
|
||||
|
|
@ -1114,20 +1114,20 @@ export function Prompt(props: PromptProps) {
|
|||
session = data.session.get(sessionID)
|
||||
}
|
||||
if (session?.agent !== agent.id) {
|
||||
await sdk.api.sessions.switchAgent({ sessionID, agent: agent.id })
|
||||
await sdk.api.session.switchAgent({ sessionID, agent: agent.id })
|
||||
}
|
||||
if (
|
||||
session?.model?.providerID !== selectedModel.providerID ||
|
||||
session.model.id !== selectedModel.modelID ||
|
||||
session.model.variant !== variant
|
||||
) {
|
||||
await sdk.api.sessions.switchModel({
|
||||
await sdk.api.session.switchModel({
|
||||
sessionID,
|
||||
model: { providerID: selectedModel.providerID, id: selectedModel.modelID, variant },
|
||||
})
|
||||
}
|
||||
if (session?.revert) {
|
||||
const error = await sdk.api.sessions.commit({ sessionID }).then(
|
||||
const error = await sdk.api.session.commit({ sessionID }).then(
|
||||
() => undefined,
|
||||
(error) => error,
|
||||
)
|
||||
|
|
@ -1136,7 +1136,7 @@ export function Prompt(props: PromptProps) {
|
|||
return false
|
||||
}
|
||||
}
|
||||
const error = await sdk.api.sessions
|
||||
const error = await sdk.api.session
|
||||
.prompt({
|
||||
sessionID,
|
||||
prompt: {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ export function usePromptMove(input: { projectID: () => string | undefined; sess
|
|||
{ projectID, context },
|
||||
{ throwOnError: true },
|
||||
)
|
||||
const result = await sdk.api.projectCopies.create({
|
||||
const result = await sdk.api.projectCopy.create({
|
||||
projectID,
|
||||
location: { directory: project.instance.directory() || paths.cwd },
|
||||
strategy: "git_worktree",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue