mirror of
https://github.com/langgenius/dify.git
synced 2026-03-18 05:09:54 +08:00
Replace ExploreContext with derived permission checks using useAppContext and useMembers, eliminating redundant state synchronization. Add oRPC contract for explore endpoints, extract TryAppSelection type, and migrate app-publisher icons from @remixicon/react components to CSS icon classes. Update all related tests to reflect the new context-free architecture.
96 lines
2.2 KiB
TypeScript
96 lines
2.2 KiB
TypeScript
import type { AccessMode } from '@/models/access-control'
|
|
import type { Banner } from '@/models/app'
|
|
import type { App, AppCategory, InstalledApp } from '@/models/explore'
|
|
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 exploreBannersContract = base
|
|
.route({
|
|
path: '/explore/banners',
|
|
method: 'GET',
|
|
})
|
|
.input(type<{ query?: { language?: string } }>())
|
|
.output(type<Banner[]>())
|