Files
dify/web/contract/console/sandbox-provider.ts
yyh 8f4a4214a1 feat(sandbox): preserve user config when switching to system default
Update frontend to use new backend API:
- save_config now accepts optional 'activate' parameter
- activate endpoint now requires 'type' parameter ('system' | 'user')

When switching to managed mode, call activate with type='system' instead
of deleting user config, so custom configurations are preserved for
future use.
2026-01-19 22:27:06 +08:00

55 lines
1.3 KiB
TypeScript

import type { SandboxProvider } from '@/types/sandbox-provider'
import { type } from '@orpc/contract'
import { base } from '../base'
export const getSandboxProviderListContract = base
.route({
path: '/workspaces/current/sandbox-providers',
method: 'GET',
})
.input(type<unknown>())
.output(type<SandboxProvider[]>())
export const saveSandboxProviderConfigContract = base
.route({
path: '/workspaces/current/sandbox-provider/{providerType}/config',
method: 'POST',
})
.input(type<{
params: {
providerType: string
}
body: {
config: Record<string, string>
activate?: boolean
}
}>())
.output(type<{ result: string }>())
export const deleteSandboxProviderConfigContract = base
.route({
path: '/workspaces/current/sandbox-provider/{providerType}/config',
method: 'DELETE',
})
.input(type<{
params: {
providerType: string
}
}>())
.output(type<{ result: string }>())
export const activateSandboxProviderContract = base
.route({
path: '/workspaces/current/sandbox-provider/{providerType}/activate',
method: 'POST',
})
.input(type<{
params: {
providerType: string
}
body: {
type: 'system' | 'user'
}
}>())
.output(type<{ result: string }>())