mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
chore(web): re-generate sdk and use it
This commit is contained in:
@@ -692,17 +692,23 @@ import {
|
||||
postBotsByBotIdMcp,
|
||||
putBotsByBotIdMcpById,
|
||||
deleteBotsByBotIdMcpById,
|
||||
postBotsByBotIdMcpByIdProbe,
|
||||
putBotsByBotIdMcpImport,
|
||||
getBotsByBotIdMcpByIdOauthStatus,
|
||||
postBotsByBotIdMcpByIdOauthDiscover,
|
||||
postBotsByBotIdMcpByIdOauthAuthorize,
|
||||
deleteBotsByBotIdMcpByIdOauthToken,
|
||||
} from '@memoh/sdk'
|
||||
import type {
|
||||
McpUpsertRequest,
|
||||
McpImportRequest,
|
||||
McpToolDescriptor,
|
||||
McpMcpServerEntry,
|
||||
McpOAuthStatus,
|
||||
} from '@memoh/sdk'
|
||||
import type { McpUpsertRequest, McpImportRequest } from '@memoh/sdk'
|
||||
import { client } from '@memoh/sdk/client'
|
||||
import { resolveApiErrorMessage } from '@/utils/api-error'
|
||||
import { useClipboard } from '@/composables/useClipboard'
|
||||
|
||||
interface ToolDescriptor {
|
||||
name: string
|
||||
description: string
|
||||
}
|
||||
|
||||
interface McpItem {
|
||||
id: string
|
||||
name: string
|
||||
@@ -710,29 +716,12 @@ interface McpItem {
|
||||
config: Record<string, unknown>
|
||||
is_active: boolean
|
||||
status: string
|
||||
tools_cache: ToolDescriptor[]
|
||||
tools_cache: McpToolDescriptor[]
|
||||
last_probed_at: string | null
|
||||
status_message: string
|
||||
auth_type: string
|
||||
}
|
||||
|
||||
interface McpServerEntry {
|
||||
command?: string
|
||||
args?: string[]
|
||||
env?: Record<string, string>
|
||||
cwd?: string
|
||||
url?: string
|
||||
headers?: Record<string, string>
|
||||
transport?: string
|
||||
}
|
||||
|
||||
interface ProbeResponse {
|
||||
status: string
|
||||
tools: ToolDescriptor[]
|
||||
error?: string
|
||||
auth_required?: boolean
|
||||
}
|
||||
|
||||
const DRAFT_ID = ''
|
||||
|
||||
const IMPORT_EXAMPLE = JSON.stringify({
|
||||
@@ -764,23 +753,7 @@ const probeAuthRequired = ref(false)
|
||||
const oauthDiscovering = ref(false)
|
||||
const oauthAuthorizing = ref(false)
|
||||
|
||||
interface OAuthStatusResponse {
|
||||
configured: boolean
|
||||
has_token: boolean
|
||||
expired: boolean
|
||||
scopes?: string
|
||||
expires_at?: string
|
||||
auth_server?: string
|
||||
callback_url?: string
|
||||
}
|
||||
|
||||
interface OAuthDiscoveryResponse {
|
||||
registration_endpoint?: string
|
||||
authorization_endpoint?: string
|
||||
token_endpoint?: string
|
||||
}
|
||||
|
||||
const oauthStatus = ref<OAuthStatusResponse | null>(null)
|
||||
const oauthStatus = ref<McpOAuthStatus | null>(null)
|
||||
const oauthClientId = ref('')
|
||||
const oauthClientSecret = ref('')
|
||||
const oauthNeedsClientId = ref(false)
|
||||
@@ -817,7 +790,7 @@ const filteredItems = computed(() => {
|
||||
return items.value.filter((i) => i.id === DRAFT_ID || i.name.toLowerCase().includes(kw))
|
||||
})
|
||||
|
||||
const displayTools = computed<ToolDescriptor[]>(() => {
|
||||
const displayTools = computed<McpToolDescriptor[]>(() => {
|
||||
if (!selectedItem.value) return []
|
||||
return selectedItem.value.tools_cache ?? []
|
||||
})
|
||||
@@ -939,7 +912,7 @@ function handleCreateDraft() {
|
||||
createDialogOpen.value = false
|
||||
}
|
||||
|
||||
function itemToExportEntry(item: McpItem): McpServerEntry {
|
||||
function itemToExportEntry(item: McpItem): McpMcpServerEntry {
|
||||
const cfg = item.config ?? {}
|
||||
if (item.type === 'stdio') {
|
||||
return {
|
||||
@@ -1020,13 +993,12 @@ async function handleProbe(item: McpItem) {
|
||||
probing.value = true
|
||||
probeAuthRequired.value = false
|
||||
try {
|
||||
const { data } = await client.post<ProbeResponse>({
|
||||
url: '/bots/{bot_id}/mcp/{id}/probe',
|
||||
const { data } = await postBotsByBotIdMcpByIdProbe({
|
||||
path: { bot_id: props.botId, id: item.id },
|
||||
throwOnError: true,
|
||||
})
|
||||
if (data) {
|
||||
item.status = data.status
|
||||
item.status = data.status ?? item.status
|
||||
item.tools_cache = data.tools ?? []
|
||||
item.status_message = data.error ?? ''
|
||||
item.last_probed_at = new Date().toISOString()
|
||||
@@ -1111,8 +1083,7 @@ async function handleImportFromDialog() {
|
||||
if (!parsed.mcpServers && typeof parsed === 'object') {
|
||||
parsed = { mcpServers: parsed as McpImportRequest['mcpServers'] }
|
||||
}
|
||||
await client.put({
|
||||
url: '/bots/{bot_id}/mcp-ops/import',
|
||||
await putBotsByBotIdMcpImport({
|
||||
path: { bot_id: props.botId },
|
||||
body: parsed,
|
||||
throwOnError: true,
|
||||
@@ -1130,7 +1101,7 @@ async function handleImportFromDialog() {
|
||||
|
||||
function handleExportSingle() {
|
||||
if (!selectedItem.value || !selectedItem.value.id) return
|
||||
const mcpServers: Record<string, McpServerEntry> = {
|
||||
const mcpServers: Record<string, McpMcpServerEntry> = {
|
||||
[selectedItem.value.name]: itemToExportEntry(selectedItem.value),
|
||||
}
|
||||
exportJson.value = JSON.stringify({ mcpServers }, null, 2)
|
||||
@@ -1148,8 +1119,7 @@ async function loadOAuthStatus(item: McpItem) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
const { data } = await client.get<OAuthStatusResponse>({
|
||||
url: '/bots/{bot_id}/mcp/{id}/oauth/status',
|
||||
const { data } = await getBotsByBotIdMcpByIdOauthStatus({
|
||||
path: { bot_id: props.botId, id: item.id },
|
||||
throwOnError: true,
|
||||
})
|
||||
@@ -1167,8 +1137,7 @@ async function handleOAuthDiscover() {
|
||||
oauthDiscovering.value = true
|
||||
oauthNeedsClientId.value = false
|
||||
try {
|
||||
const { data } = await client.post<OAuthDiscoveryResponse>({
|
||||
url: '/bots/{bot_id}/mcp/{id}/oauth/discover',
|
||||
const { data } = await postBotsByBotIdMcpByIdOauthDiscover({
|
||||
path: { bot_id: props.botId, id: item.id },
|
||||
throwOnError: true,
|
||||
})
|
||||
@@ -1200,8 +1169,7 @@ async function handleOAuthFlow() {
|
||||
|
||||
oauthAuthorizing.value = true
|
||||
try {
|
||||
const { data } = await client.post<{ authorization_url: string }>({
|
||||
url: '/bots/{bot_id}/mcp/{id}/oauth/authorize',
|
||||
const { data } = await postBotsByBotIdMcpByIdOauthAuthorize({
|
||||
path: { bot_id: props.botId, id: item.id },
|
||||
body: {
|
||||
client_id: oauthClientId.value.trim() || undefined,
|
||||
@@ -1250,8 +1218,7 @@ async function handleOAuthFlow() {
|
||||
async function handleOAuthRevoke() {
|
||||
if (!selectedItem.value?.id) return
|
||||
try {
|
||||
await client.delete({
|
||||
url: '/bots/{bot_id}/mcp/{id}/oauth/token',
|
||||
await deleteBotsByBotIdMcpByIdOauthToken({
|
||||
path: { bot_id: props.botId, id: selectedItem.value.id },
|
||||
throwOnError: true,
|
||||
})
|
||||
|
||||
@@ -240,18 +240,15 @@ import { toTypedSchema } from '@vee-validate/zod'
|
||||
import z from 'zod'
|
||||
import { useForm } from 'vee-validate'
|
||||
import { useMutation, useQuery, useQueryCache } from '@pinia/colada'
|
||||
import { putEmailProvidersById, deleteEmailProvidersById, getEmailProvidersMeta } from '@memoh/sdk'
|
||||
import { client } from '@memoh/sdk/client'
|
||||
import type { EmailProviderResponse, EmailFieldSchema } from '@memoh/sdk'
|
||||
|
||||
interface EmailOAuthStatusResponse {
|
||||
provider: string
|
||||
configured: boolean
|
||||
has_token: boolean
|
||||
expired: boolean
|
||||
email_address?: string
|
||||
expires_at?: string
|
||||
}
|
||||
import {
|
||||
putEmailProvidersById,
|
||||
deleteEmailProvidersById,
|
||||
getEmailProvidersMeta,
|
||||
getEmailProvidersByIdOauthAuthorize,
|
||||
getEmailProvidersByIdOauthStatus,
|
||||
deleteEmailProvidersByIdOauthToken,
|
||||
} from '@memoh/sdk'
|
||||
import type { EmailProviderResponse, EmailFieldSchema, HandlersEmailOAuthStatusResponse } from '@memoh/sdk'
|
||||
|
||||
const OAUTH_PROVIDERS = ['gmail']
|
||||
|
||||
@@ -282,7 +279,7 @@ const isOAuthProvider = computed(() =>
|
||||
OAUTH_PROVIDERS.includes(curProvider.value?.provider ?? ''),
|
||||
)
|
||||
|
||||
const oauthStatus = ref<EmailOAuthStatusResponse | null>(null)
|
||||
const oauthStatus = ref<HandlersEmailOAuthStatusResponse | null>(null)
|
||||
const oauthStatusLoading = ref(false)
|
||||
const revokeLoading = ref(false)
|
||||
|
||||
@@ -377,8 +374,8 @@ async function handleAuthorize() {
|
||||
if (!curProviderId.value) return
|
||||
authorizeLoading.value = true
|
||||
try {
|
||||
const { data, error } = await client.get<{ auth_url: string }, unknown>({
|
||||
url: `/email-providers/${curProviderId.value}/oauth/authorize`,
|
||||
const { data, error } = await getEmailProvidersByIdOauthAuthorize({
|
||||
path: { id: curProviderId.value },
|
||||
})
|
||||
if (error || !data?.auth_url) {
|
||||
throw new Error(t('emailProvider.oauth.authorizeFailed'))
|
||||
@@ -399,8 +396,8 @@ async function fetchOAuthStatus() {
|
||||
}
|
||||
oauthStatusLoading.value = true
|
||||
try {
|
||||
const { data, error } = await client.get<EmailOAuthStatusResponse, unknown>({
|
||||
url: `/email-providers/${curProviderId.value}/oauth/status`,
|
||||
const { data, error } = await getEmailProvidersByIdOauthStatus({
|
||||
path: { id: curProviderId.value },
|
||||
})
|
||||
if (error) {
|
||||
throw error
|
||||
@@ -418,8 +415,8 @@ async function handleRevoke() {
|
||||
if (!curProviderId.value) return
|
||||
revokeLoading.value = true
|
||||
try {
|
||||
const { error } = await client.delete({
|
||||
url: `/email-providers/${curProviderId.value}/oauth/token`,
|
||||
const { error } = await deleteEmailProvidersByIdOauthToken({
|
||||
path: { id: curProviderId.value },
|
||||
})
|
||||
if (error) throw error
|
||||
toast.success(t('emailProvider.oauth.logoutSuccess'))
|
||||
|
||||
@@ -27,7 +27,7 @@ import { onMounted, ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { Spinner } from '@memoh/ui'
|
||||
import { client } from '@memoh/sdk/client'
|
||||
import { postBotsByBotIdMcpByIdOauthExchange } from '@memoh/sdk'
|
||||
|
||||
const route = useRoute()
|
||||
const { t } = useI18n()
|
||||
@@ -66,8 +66,8 @@ onMounted(async () => {
|
||||
}
|
||||
|
||||
try {
|
||||
await client.post({
|
||||
url: '/bots/-/mcp/-/oauth/exchange',
|
||||
await postBotsByBotIdMcpByIdOauthExchange({
|
||||
path: { bot_id: '-', id: '-' },
|
||||
body: { code, state },
|
||||
throwOnError: true,
|
||||
})
|
||||
|
||||
@@ -219,7 +219,7 @@ import PasswordSection from './components/password-section.vue'
|
||||
import BindCodeSection from './components/bind-code-section.vue'
|
||||
import { getUsersMe, putUsersMe, putUsersMePassword, getUsersMeIdentities } from '@memoh/sdk'
|
||||
import { client } from '@memoh/sdk/client'
|
||||
import type { AccountsAccount, AccountsUpdateProfileRequest, AccountsUpdatePasswordRequest } from '@memoh/sdk'
|
||||
import type { AccountsAccount, AccountsUpdateProfileRequest, AccountsUpdatePasswordRequest, IdentitiesChannelIdentity } from '@memoh/sdk'
|
||||
import { useUserStore } from '@/store/user'
|
||||
import { useSettingsStore } from '@/store/settings'
|
||||
import type { Locale } from '@/i18n'
|
||||
@@ -228,17 +228,6 @@ import { formatDateTime } from '@/utils/date-time'
|
||||
import { useClipboard } from '@/composables/useClipboard'
|
||||
import { useAvatarInitials } from '@/composables/useAvatarInitials'
|
||||
|
||||
interface ChannelIdentity {
|
||||
id: string
|
||||
user_id?: string
|
||||
channel: string
|
||||
channel_subject_id: string
|
||||
display_name?: string
|
||||
metadata?: Record<string, unknown>
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
interface IssueBindCodeResponse {
|
||||
token: string
|
||||
platform?: string
|
||||
@@ -262,7 +251,7 @@ const { setLanguage, setTheme } = settingsStore
|
||||
|
||||
// ---- User data ----
|
||||
const account = ref<UserAccount | null>(null)
|
||||
const identities = ref<ChannelIdentity[]>([])
|
||||
const identities = ref<IdentitiesChannelIdentity[]>([])
|
||||
const bindCode = ref<IssueBindCodeResponse | null>(null)
|
||||
|
||||
const loadingInitial = ref(false)
|
||||
|
||||
Reference in New Issue
Block a user