mirror of
https://github.com/langgenius/dify.git
synced 2026-04-05 19:39:25 +08:00
fix: remove explore context and migrate query to orpc contract (#32320)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
121
web/contract/console/explore.ts
Normal file
121
web/contract/console/explore.ts
Normal file
@@ -0,0 +1,121 @@
|
||||
import type { ChatConfig } from '@/app/components/base/chat/types'
|
||||
import type { AccessMode } from '@/models/access-control'
|
||||
import type { Banner } from '@/models/app'
|
||||
import type { App, AppCategory, InstalledApp } from '@/models/explore'
|
||||
import type { AppMeta } from '@/models/share'
|
||||
import type { AppModeEnum } from '@/types/app'
|
||||
import { type } from '@orpc/contract'
|
||||
import { base } from '../base'
|
||||
|
||||
export type ExploreAppsResponse = {
|
||||
categories: AppCategory[]
|
||||
recommended_apps: App[]
|
||||
}
|
||||
|
||||
export type ExploreAppDetailResponse = {
|
||||
id: string
|
||||
name: string
|
||||
icon: string
|
||||
icon_background: string
|
||||
mode: AppModeEnum
|
||||
export_data: string
|
||||
can_trial?: boolean
|
||||
}
|
||||
|
||||
export type InstalledAppsResponse = {
|
||||
installed_apps: InstalledApp[]
|
||||
}
|
||||
|
||||
export type InstalledAppMutationResponse = {
|
||||
result: string
|
||||
message: string
|
||||
}
|
||||
|
||||
export type AppAccessModeResponse = {
|
||||
accessMode: AccessMode
|
||||
}
|
||||
|
||||
export const exploreAppsContract = base
|
||||
.route({
|
||||
path: '/explore/apps',
|
||||
method: 'GET',
|
||||
})
|
||||
.input(type<{ query?: { language?: string } }>())
|
||||
.output(type<ExploreAppsResponse>())
|
||||
|
||||
export const exploreAppDetailContract = base
|
||||
.route({
|
||||
path: '/explore/apps/{id}',
|
||||
method: 'GET',
|
||||
})
|
||||
.input(type<{ params: { id: string } }>())
|
||||
.output(type<ExploreAppDetailResponse | null>())
|
||||
|
||||
export const exploreInstalledAppsContract = base
|
||||
.route({
|
||||
path: '/installed-apps',
|
||||
method: 'GET',
|
||||
})
|
||||
.input(type<{ query?: { app_id?: string } }>())
|
||||
.output(type<InstalledAppsResponse>())
|
||||
|
||||
export const exploreInstalledAppUninstallContract = base
|
||||
.route({
|
||||
path: '/installed-apps/{id}',
|
||||
method: 'DELETE',
|
||||
})
|
||||
.input(type<{ params: { id: string } }>())
|
||||
.output(type<unknown>())
|
||||
|
||||
export const exploreInstalledAppPinContract = base
|
||||
.route({
|
||||
path: '/installed-apps/{id}',
|
||||
method: 'PATCH',
|
||||
})
|
||||
.input(type<{
|
||||
params: { id: string }
|
||||
body: {
|
||||
is_pinned: boolean
|
||||
}
|
||||
}>())
|
||||
.output(type<InstalledAppMutationResponse>())
|
||||
|
||||
export const exploreInstalledAppAccessModeContract = base
|
||||
.route({
|
||||
path: '/enterprise/webapp/app/access-mode',
|
||||
method: 'GET',
|
||||
})
|
||||
.input(type<{ query: { appId: string } }>())
|
||||
.output(type<AppAccessModeResponse>())
|
||||
|
||||
export const exploreInstalledAppParametersContract = base
|
||||
.route({
|
||||
path: '/installed-apps/{appId}/parameters',
|
||||
method: 'GET',
|
||||
})
|
||||
.input(type<{
|
||||
params: {
|
||||
appId: string
|
||||
}
|
||||
}>())
|
||||
.output(type<ChatConfig>())
|
||||
|
||||
export const exploreInstalledAppMetaContract = base
|
||||
.route({
|
||||
path: '/installed-apps/{appId}/meta',
|
||||
method: 'GET',
|
||||
})
|
||||
.input(type<{
|
||||
params: {
|
||||
appId: string
|
||||
}
|
||||
}>())
|
||||
.output(type<AppMeta>())
|
||||
|
||||
export const exploreBannersContract = base
|
||||
.route({
|
||||
path: '/explore/banners',
|
||||
method: 'GET',
|
||||
})
|
||||
.input(type<{ query?: { language?: string } }>())
|
||||
.output(type<Banner[]>())
|
||||
@@ -1,5 +1,16 @@
|
||||
import type { InferContractRouterInputs } from '@orpc/contract'
|
||||
import { bindPartnerStackContract, invoicesContract } from './console/billing'
|
||||
import {
|
||||
exploreAppDetailContract,
|
||||
exploreAppsContract,
|
||||
exploreBannersContract,
|
||||
exploreInstalledAppAccessModeContract,
|
||||
exploreInstalledAppMetaContract,
|
||||
exploreInstalledAppParametersContract,
|
||||
exploreInstalledAppPinContract,
|
||||
exploreInstalledAppsContract,
|
||||
exploreInstalledAppUninstallContract,
|
||||
} from './console/explore'
|
||||
import { systemFeaturesContract } from './console/system'
|
||||
import {
|
||||
triggerOAuthConfigContract,
|
||||
@@ -31,6 +42,17 @@ export type MarketPlaceInputs = InferContractRouterInputs<typeof marketplaceRout
|
||||
|
||||
export const consoleRouterContract = {
|
||||
systemFeatures: systemFeaturesContract,
|
||||
explore: {
|
||||
apps: exploreAppsContract,
|
||||
appDetail: exploreAppDetailContract,
|
||||
installedApps: exploreInstalledAppsContract,
|
||||
uninstallInstalledApp: exploreInstalledAppUninstallContract,
|
||||
updateInstalledApp: exploreInstalledAppPinContract,
|
||||
appAccessMode: exploreInstalledAppAccessModeContract,
|
||||
installedAppParameters: exploreInstalledAppParametersContract,
|
||||
installedAppMeta: exploreInstalledAppMetaContract,
|
||||
banners: exploreBannersContract,
|
||||
},
|
||||
trialApps: {
|
||||
info: trialAppInfoContract,
|
||||
datasets: trialAppDatasetsContract,
|
||||
|
||||
Reference in New Issue
Block a user