mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 10:28:10 +08:00
fix(web): align data contracts with backend schema
This commit is contained in:
@ -2,7 +2,6 @@ import type {
|
||||
AppAssetDeleteResponse,
|
||||
AppAssetFileDownloadUrlResponse,
|
||||
AppAssetNode,
|
||||
AppAssetPublishResponse,
|
||||
AppAssetTreeResponse,
|
||||
BatchUploadPayload,
|
||||
BatchUploadResponse,
|
||||
@ -111,16 +110,6 @@ export const reorderNodeContract = base
|
||||
}>())
|
||||
.output(type<AppAssetNode>())
|
||||
|
||||
export const publishContract = base
|
||||
.route({
|
||||
path: '/apps/{appId}/assets/publish',
|
||||
method: 'POST',
|
||||
})
|
||||
.input(type<{
|
||||
params: { appId: string }
|
||||
}>())
|
||||
.output(type<AppAssetPublishResponse>())
|
||||
|
||||
export const getFileUploadUrlContract = base
|
||||
.route({
|
||||
path: '/apps/{appId}/assets/files/upload',
|
||||
|
||||
@ -1,7 +1,28 @@
|
||||
import type { WorkflowOnlineUsersResponse } from '@/models/app'
|
||||
import type { DSLImportResponse, WorkflowOnlineUsersResponse } from '@/models/app'
|
||||
import { type } from '@orpc/contract'
|
||||
import { base } from '../base'
|
||||
|
||||
export type AppExportBundleResponse = {
|
||||
download_url: string
|
||||
filename: string
|
||||
}
|
||||
|
||||
export type AppRuntimeUpgradeResponse = {
|
||||
result: 'success' | 'no_draft' | 'already_sandboxed'
|
||||
new_app_id?: string
|
||||
converted_agents?: number
|
||||
skipped_agents?: number
|
||||
}
|
||||
|
||||
export type PublishToCreatorsPlatformResponse = {
|
||||
redirect_url: string
|
||||
}
|
||||
|
||||
export type ImportBundlePrepareResponse = {
|
||||
import_id: string
|
||||
upload_url: string
|
||||
}
|
||||
|
||||
export const workflowOnlineUsersContract = base
|
||||
.route({
|
||||
path: '/apps/workflows/online-users',
|
||||
@ -25,3 +46,69 @@ export const appDeleteContract = base
|
||||
}
|
||||
}>())
|
||||
.output(type<unknown>())
|
||||
|
||||
export const appExportBundleContract = base
|
||||
.route({
|
||||
path: '/apps/{appId}/export-bundle',
|
||||
method: 'GET',
|
||||
})
|
||||
.input(type<{
|
||||
params: {
|
||||
appId: string
|
||||
}
|
||||
query?: {
|
||||
include_secret?: boolean
|
||||
workflow_id?: string
|
||||
}
|
||||
}>())
|
||||
.output(type<AppExportBundleResponse>())
|
||||
|
||||
export const publishToCreatorsPlatformContract = base
|
||||
.route({
|
||||
path: '/apps/{appId}/publish-to-creators-platform',
|
||||
method: 'POST',
|
||||
})
|
||||
.input(type<{
|
||||
params: {
|
||||
appId: string
|
||||
}
|
||||
}>())
|
||||
.output(type<PublishToCreatorsPlatformResponse>())
|
||||
|
||||
export const upgradeAppRuntimeContract = base
|
||||
.route({
|
||||
path: '/apps/{appId}/upgrade-runtime',
|
||||
method: 'POST',
|
||||
})
|
||||
.input(type<{
|
||||
params: {
|
||||
appId: string
|
||||
}
|
||||
}>())
|
||||
.output(type<AppRuntimeUpgradeResponse>())
|
||||
|
||||
export const prepareImportBundleContract = base
|
||||
.route({
|
||||
path: '/apps/imports-bundle/prepare',
|
||||
method: 'POST',
|
||||
})
|
||||
.output(type<ImportBundlePrepareResponse>())
|
||||
|
||||
export const confirmImportBundleContract = base
|
||||
.route({
|
||||
path: '/apps/imports-bundle/{importId}/confirm',
|
||||
method: 'POST',
|
||||
})
|
||||
.input(type<{
|
||||
params: {
|
||||
importId: string
|
||||
}
|
||||
body?: {
|
||||
name?: string
|
||||
description?: string
|
||||
icon_type?: string
|
||||
icon?: string
|
||||
icon_background?: string
|
||||
}
|
||||
}>())
|
||||
.output(type<DSLImportResponse>())
|
||||
|
||||
103
web/contract/console/generator.ts
Normal file
103
web/contract/console/generator.ts
Normal file
@ -0,0 +1,103 @@
|
||||
import type { StructuredOutput } from '@/app/components/workflow/nodes/llm/types'
|
||||
import type { BlockEnum, ValueSelector, VarType } from '@/app/components/workflow/types'
|
||||
import type { CompletionParams } from '@/types/app'
|
||||
import { type } from '@orpc/contract'
|
||||
import { base } from '../base'
|
||||
|
||||
export type ContextGenerateMessage = {
|
||||
role: 'user' | 'assistant' | 'system' | 'tool'
|
||||
content: string
|
||||
tool_call_id?: string
|
||||
}
|
||||
|
||||
export type ContextGenerateAvailableVar = {
|
||||
value_selector: ValueSelector
|
||||
type: VarType
|
||||
description?: string
|
||||
node_id?: string
|
||||
node_title?: string
|
||||
node_type?: BlockEnum
|
||||
schema?: StructuredOutput['schema'] | Record<string, unknown> | null
|
||||
}
|
||||
|
||||
export type ContextGenerateParameterInfo = {
|
||||
name: string
|
||||
type?: string
|
||||
description?: string
|
||||
required?: boolean
|
||||
options?: string[]
|
||||
min?: number
|
||||
max?: number
|
||||
default?: string | number | boolean | null
|
||||
multiple?: boolean
|
||||
label?: string
|
||||
}
|
||||
|
||||
export type ContextGenerateVariable = {
|
||||
variable: string
|
||||
value_selector: string[]
|
||||
}
|
||||
|
||||
export type ContextGenerateCodeContext = {
|
||||
code: string
|
||||
outputs?: Record<string, { type: string }>
|
||||
variables?: ContextGenerateVariable[]
|
||||
}
|
||||
|
||||
export type ContextGenerateRequest = {
|
||||
language?: 'python3' | 'javascript'
|
||||
prompt_messages: ContextGenerateMessage[]
|
||||
model_config: {
|
||||
provider: string
|
||||
name: string
|
||||
completion_params?: CompletionParams
|
||||
}
|
||||
available_vars: ContextGenerateAvailableVar[]
|
||||
parameter_info: ContextGenerateParameterInfo
|
||||
code_context?: ContextGenerateCodeContext | null
|
||||
}
|
||||
|
||||
export type ContextGenerateResponse = {
|
||||
variables: ContextGenerateVariable[]
|
||||
code_language: string
|
||||
code: string
|
||||
outputs: Record<string, { type: string }>
|
||||
message: string
|
||||
error: string
|
||||
}
|
||||
|
||||
export type ContextGenerateSuggestedQuestionsRequest = {
|
||||
language: string
|
||||
model_config?: {
|
||||
provider: string
|
||||
name: string
|
||||
completion_params?: CompletionParams
|
||||
}
|
||||
available_vars: ContextGenerateAvailableVar[]
|
||||
parameter_info: ContextGenerateParameterInfo
|
||||
}
|
||||
|
||||
export type ContextGenerateSuggestedQuestionsResponse = {
|
||||
questions: string[]
|
||||
error: string
|
||||
}
|
||||
|
||||
export const contextGenerateContract = base
|
||||
.route({
|
||||
path: '/context-generate',
|
||||
method: 'POST',
|
||||
})
|
||||
.input(type<{
|
||||
body: ContextGenerateRequest
|
||||
}>())
|
||||
.output(type<ContextGenerateResponse>())
|
||||
|
||||
export const contextGenerateSuggestedQuestionsContract = base
|
||||
.route({
|
||||
path: '/context-generate/suggested-questions',
|
||||
method: 'POST',
|
||||
})
|
||||
.input(type<{
|
||||
body: ContextGenerateSuggestedQuestionsRequest
|
||||
}>())
|
||||
.output(type<ContextGenerateSuggestedQuestionsResponse>())
|
||||
@ -1,4 +1,3 @@
|
||||
import type { CommonResponse } from '@/models/common'
|
||||
import { type } from '@orpc/contract'
|
||||
import { base } from '../base'
|
||||
|
||||
@ -6,7 +5,13 @@ export type UserProfile = {
|
||||
id: string
|
||||
name: string
|
||||
email: string
|
||||
avatar?: string | null
|
||||
avatar_url?: string
|
||||
last_login_at?: number | null
|
||||
last_active_at?: number | null
|
||||
created_at?: number | null
|
||||
role?: string
|
||||
status?: string
|
||||
}
|
||||
|
||||
export type WorkflowCommentList = {
|
||||
@ -60,12 +65,12 @@ export type WorkflowCommentDetail = {
|
||||
|
||||
export type WorkflowCommentCreateRes = {
|
||||
id: string
|
||||
created_at: string
|
||||
created_at: number
|
||||
}
|
||||
|
||||
export type WorkflowCommentUpdateRes = {
|
||||
id: string
|
||||
updated_at: string
|
||||
updated_at: number
|
||||
}
|
||||
|
||||
export type WorkflowCommentResolveRes = {
|
||||
@ -75,20 +80,14 @@ export type WorkflowCommentResolveRes = {
|
||||
resolved_at: number
|
||||
}
|
||||
|
||||
export type WorkflowCommentReply = {
|
||||
export type WorkflowCommentReplyCreateRes = {
|
||||
id: string
|
||||
comment_id: string
|
||||
content: string
|
||||
created_by: string
|
||||
created_at: string
|
||||
updated_at: string
|
||||
mentioned_user_ids: string[]
|
||||
author: {
|
||||
id: string
|
||||
name: string
|
||||
email: string
|
||||
avatar?: string
|
||||
}
|
||||
created_at: number
|
||||
}
|
||||
|
||||
export type WorkflowCommentReplyUpdateRes = {
|
||||
id: string
|
||||
updated_at: number
|
||||
}
|
||||
|
||||
export type CreateCommentParams = {
|
||||
@ -173,7 +172,7 @@ export const workflowCommentDeleteContract = base
|
||||
commentId: string
|
||||
}
|
||||
}>())
|
||||
.output(type<CommonResponse>())
|
||||
.output(type<unknown>())
|
||||
|
||||
export const workflowCommentResolveContract = base
|
||||
.route({
|
||||
@ -200,7 +199,7 @@ export const workflowCommentReplyCreateContract = base
|
||||
}
|
||||
body: CreateReplyParams
|
||||
}>())
|
||||
.output(type<WorkflowCommentReply>())
|
||||
.output(type<WorkflowCommentReplyCreateRes>())
|
||||
|
||||
export const workflowCommentReplyUpdateContract = base
|
||||
.route({
|
||||
@ -215,7 +214,7 @@ export const workflowCommentReplyUpdateContract = base
|
||||
}
|
||||
body: CreateReplyParams
|
||||
}>())
|
||||
.output(type<WorkflowCommentReply>())
|
||||
.output(type<WorkflowCommentReplyUpdateRes>())
|
||||
|
||||
export const workflowCommentReplyDeleteContract = base
|
||||
.route({
|
||||
@ -229,7 +228,7 @@ export const workflowCommentReplyDeleteContract = base
|
||||
replyId: string
|
||||
}
|
||||
}>())
|
||||
.output(type<CommonResponse>())
|
||||
.output(type<unknown>())
|
||||
|
||||
export const workflowCommentMentionUsersContract = base
|
||||
.route({
|
||||
|
||||
@ -9,6 +9,7 @@ import type {
|
||||
} from '@/app/components/base/features/types'
|
||||
import type { ConversationVariable, EnvironmentVariable } from '@/app/components/workflow/types'
|
||||
import type { CommonResponse } from '@/models/common'
|
||||
import type { NestedNodeGraphPayload, NestedNodeGraphResponse } from '@/types/workflow'
|
||||
import { type } from '@orpc/contract'
|
||||
import { base } from '../base'
|
||||
|
||||
@ -97,5 +98,19 @@ export const workflowDraftNodeSkillsContract = base
|
||||
type: string
|
||||
provider: string
|
||||
tool_name: string
|
||||
enabled: boolean
|
||||
}[]
|
||||
}>())
|
||||
|
||||
export const workflowDraftNestedNodeGraphContract = base
|
||||
.route({
|
||||
path: '/apps/{appId}/workflows/draft/nested-node-graph',
|
||||
method: 'POST',
|
||||
})
|
||||
.input(type<{
|
||||
params: {
|
||||
appId: string
|
||||
}
|
||||
body: NestedNodeGraphPayload
|
||||
}>())
|
||||
.output(type<NestedNodeGraphResponse>())
|
||||
|
||||
@ -8,13 +8,20 @@ import {
|
||||
getFileDownloadUrlContract,
|
||||
getFileUploadUrlContract,
|
||||
moveNodeContract,
|
||||
publishContract,
|
||||
renameNodeContract,
|
||||
reorderNodeContract,
|
||||
treeContract,
|
||||
updateFileContentContract,
|
||||
} from './console/app-asset'
|
||||
import { appDeleteContract, workflowOnlineUsersContract } from './console/apps'
|
||||
import {
|
||||
appDeleteContract,
|
||||
appExportBundleContract,
|
||||
confirmImportBundleContract,
|
||||
prepareImportBundleContract,
|
||||
publishToCreatorsPlatformContract,
|
||||
upgradeAppRuntimeContract,
|
||||
workflowOnlineUsersContract,
|
||||
} from './console/apps'
|
||||
import { bindPartnerStackContract, invoicesContract } from './console/billing'
|
||||
import {
|
||||
exploreAppDetailContract,
|
||||
@ -27,6 +34,10 @@ import {
|
||||
exploreInstalledAppsContract,
|
||||
exploreInstalledAppUninstallContract,
|
||||
} from './console/explore'
|
||||
import {
|
||||
contextGenerateContract,
|
||||
contextGenerateSuggestedQuestionsContract,
|
||||
} from './console/generator'
|
||||
import { changePreferredProviderTypeContract, modelProvidersModelsContract } from './console/model-providers'
|
||||
import { notificationContract, notificationDismissContract } from './console/notification'
|
||||
import { pluginCheckInstalledContract, pluginLatestVersionsContract } from './console/plugins'
|
||||
@ -61,6 +72,7 @@ import {
|
||||
import { trialAppDatasetsContract, trialAppInfoContract, trialAppParametersContract, trialAppWorkflowsContract } from './console/try-app'
|
||||
import {
|
||||
workflowDraftEnvironmentVariablesContract,
|
||||
workflowDraftNestedNodeGraphContract,
|
||||
workflowDraftNodeSkillsContract,
|
||||
workflowDraftUpdateConversationVariablesContract,
|
||||
workflowDraftUpdateEnvironmentVariablesContract,
|
||||
@ -83,9 +95,20 @@ export const consoleRouterContract = {
|
||||
avatar: accountAvatarContract,
|
||||
},
|
||||
systemFeatures: systemFeaturesContract,
|
||||
generator: {
|
||||
contextGenerate: contextGenerateContract,
|
||||
contextGenerateSuggestedQuestions: contextGenerateSuggestedQuestionsContract,
|
||||
},
|
||||
apps: {
|
||||
deleteApp: appDeleteContract,
|
||||
workflowOnlineUsers: workflowOnlineUsersContract,
|
||||
exportBundle: appExportBundleContract,
|
||||
publishToCreatorsPlatform: publishToCreatorsPlatformContract,
|
||||
upgradeRuntime: upgradeAppRuntimeContract,
|
||||
importsBundle: {
|
||||
prepare: prepareImportBundleContract,
|
||||
confirm: confirmImportBundleContract,
|
||||
},
|
||||
},
|
||||
explore: {
|
||||
apps: exploreAppsContract,
|
||||
@ -138,13 +161,13 @@ export const consoleRouterContract = {
|
||||
renameNode: renameNodeContract,
|
||||
moveNode: moveNodeContract,
|
||||
reorderNode: reorderNodeContract,
|
||||
publish: publishContract,
|
||||
getFileUploadUrl: getFileUploadUrlContract,
|
||||
batchUpload: batchUploadContract,
|
||||
},
|
||||
workflowDraft: {
|
||||
environmentVariables: workflowDraftEnvironmentVariablesContract,
|
||||
nodeSkills: workflowDraftNodeSkillsContract,
|
||||
nestedNodeGraph: workflowDraftNestedNodeGraphContract,
|
||||
updateEnvironmentVariables: workflowDraftUpdateEnvironmentVariablesContract,
|
||||
updateConversationVariables: workflowDraftUpdateConversationVariablesContract,
|
||||
updateFeatures: workflowDraftUpdateFeaturesContract,
|
||||
|
||||
Reference in New Issue
Block a user