mirror of
https://github.com/langgenius/dify.git
synced 2026-04-21 19:27:40 +08:00
Replace manual fetch calls in use-sandbox-provider.ts with typed ORPC contracts and client. Adds type definitions to types/sandbox-provider.ts and registers contracts in the console router for consistent API handling.
104 lines
2.3 KiB
TypeScript
104 lines
2.3 KiB
TypeScript
import type { SystemFeatures } from '@/types/feature'
|
|
import type { SandboxProvider } from '@/types/sandbox-provider'
|
|
import { type } from '@orpc/contract'
|
|
import { base } from './base'
|
|
|
|
export const systemFeaturesContract = base
|
|
.route({
|
|
path: '/system-features',
|
|
method: 'GET',
|
|
})
|
|
.input(type<unknown>())
|
|
.output(type<SystemFeatures>())
|
|
|
|
export const billingUrlContract = base
|
|
.route({
|
|
path: '/billing/invoices',
|
|
method: 'GET',
|
|
})
|
|
.input(type<unknown>())
|
|
.output(type<{ url: string }>())
|
|
|
|
export const bindPartnerStackContract = base
|
|
.route({
|
|
path: '/billing/partners/{partnerKey}/tenants',
|
|
method: 'PUT',
|
|
})
|
|
.input(type<{
|
|
params: {
|
|
partnerKey: string
|
|
}
|
|
body: {
|
|
click_id: string
|
|
}
|
|
}>())
|
|
.output(type<unknown>())
|
|
|
|
// Sandbox Provider contracts
|
|
export const getSandboxProviderListContract = base
|
|
.route({
|
|
path: '/workspaces/current/sandbox-providers',
|
|
method: 'GET',
|
|
})
|
|
.input(type<unknown>())
|
|
.output(type<SandboxProvider[]>())
|
|
|
|
export const getSandboxProviderContract = base
|
|
.route({
|
|
path: '/workspaces/current/sandbox-provider/{providerType}',
|
|
method: 'GET',
|
|
})
|
|
.input(type<{
|
|
params: {
|
|
providerType: string
|
|
}
|
|
}>())
|
|
.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>
|
|
}
|
|
}>())
|
|
.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
|
|
}
|
|
}>())
|
|
.output(type<{ result: string }>())
|
|
|
|
export const getActiveSandboxProviderContract = base
|
|
.route({
|
|
path: '/workspaces/current/sandbox-provider/active',
|
|
method: 'GET',
|
|
})
|
|
.input(type<unknown>())
|
|
.output(type<{ provider_type: string | null }>())
|