From d17a92f713d0ff99a274c2502a1e25f0bba9be99 Mon Sep 17 00:00:00 2001 From: yyh Date: Wed, 14 Jan 2026 16:46:04 +0800 Subject: [PATCH] refactor(web): split sandbox provider contracts into separate file Move sandbox provider related contracts from contract/console.ts to contract/console/sandbox-provider.ts for better organization --- web/contract/console.ts | 69 ----------------------- web/contract/console/sandbox-provider.ts | 70 ++++++++++++++++++++++++ web/contract/router.ts | 8 ++- 3 files changed, 75 insertions(+), 72 deletions(-) create mode 100644 web/contract/console/sandbox-provider.ts diff --git a/web/contract/console.ts b/web/contract/console.ts index ff2a9ff3b5..ec929d1357 100644 --- a/web/contract/console.ts +++ b/web/contract/console.ts @@ -1,5 +1,4 @@ import type { SystemFeatures } from '@/types/feature' -import type { SandboxProvider } from '@/types/sandbox-provider' import { type } from '@orpc/contract' import { base } from './base' @@ -33,71 +32,3 @@ export const bindPartnerStackContract = base } }>()) .output(type()) - -// Sandbox Provider contracts -export const getSandboxProviderListContract = base - .route({ - path: '/workspaces/current/sandbox-providers', - method: 'GET', - }) - .input(type()) - .output(type()) - -export const getSandboxProviderContract = base - .route({ - path: '/workspaces/current/sandbox-provider/{providerType}', - method: 'GET', - }) - .input(type<{ - params: { - providerType: string - } - }>()) - .output(type()) - -export const saveSandboxProviderConfigContract = base - .route({ - path: '/workspaces/current/sandbox-provider/{providerType}/config', - method: 'POST', - }) - .input(type<{ - params: { - providerType: string - } - body: { - config: Record - } - }>()) - .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()) - .output(type<{ provider_type: string | null }>()) diff --git a/web/contract/console/sandbox-provider.ts b/web/contract/console/sandbox-provider.ts new file mode 100644 index 0000000000..5084e24355 --- /dev/null +++ b/web/contract/console/sandbox-provider.ts @@ -0,0 +1,70 @@ +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()) + .output(type()) + +export const getSandboxProviderContract = base + .route({ + path: '/workspaces/current/sandbox-provider/{providerType}', + method: 'GET', + }) + .input(type<{ + params: { + providerType: string + } + }>()) + .output(type()) + +export const saveSandboxProviderConfigContract = base + .route({ + path: '/workspaces/current/sandbox-provider/{providerType}/config', + method: 'POST', + }) + .input(type<{ + params: { + providerType: string + } + body: { + config: Record + } + }>()) + .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()) + .output(type<{ provider_type: string | null }>()) diff --git a/web/contract/router.ts b/web/contract/router.ts index e60afef22a..8202086ce8 100644 --- a/web/contract/router.ts +++ b/web/contract/router.ts @@ -1,15 +1,17 @@ import type { InferContractRouterInputs } from '@orpc/contract' import { - activateSandboxProviderContract, billingUrlContract, bindPartnerStackContract, + systemFeaturesContract, +} from './console' +import { + activateSandboxProviderContract, deleteSandboxProviderConfigContract, getActiveSandboxProviderContract, getSandboxProviderContract, getSandboxProviderListContract, saveSandboxProviderConfigContract, - systemFeaturesContract, -} from './console' +} from './console/sandbox-provider' import { collectionPluginsContract, collectionsContract, searchAdvancedContract } from './marketplace' export const marketplaceRouterContract = {