mirror of https://github.com/langgenius/dify.git
use contract for api request
This commit is contained in:
parent
eaf888b02a
commit
1b70a7e4c7
|
|
@ -0,0 +1,14 @@
|
|||
import { type } from '@orpc/contract'
|
||||
import { base } from '../base'
|
||||
|
||||
export const accountAvatarContract = base
|
||||
.route({
|
||||
path: '/account/avatar',
|
||||
method: 'GET',
|
||||
})
|
||||
.input(type<{
|
||||
query: {
|
||||
avatar: string
|
||||
}
|
||||
}>())
|
||||
.output(type<{ avatar_url: string }>())
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
import type { WorkflowOnlineUsersResponse } from '@/models/app'
|
||||
import { type } from '@orpc/contract'
|
||||
import { base } from '../base'
|
||||
|
||||
export const workflowOnlineUsersContract = base
|
||||
.route({
|
||||
path: '/apps/workflows/online-users',
|
||||
method: 'GET',
|
||||
})
|
||||
.input(type<{
|
||||
query: {
|
||||
workflow_ids: string
|
||||
}
|
||||
}>())
|
||||
.output(type<WorkflowOnlineUsersResponse>())
|
||||
|
|
@ -0,0 +1,259 @@
|
|||
import type { CommonResponse } from '@/models/common'
|
||||
import { type } from '@orpc/contract'
|
||||
import { base } from '../base'
|
||||
|
||||
export type UserProfile = {
|
||||
id: string
|
||||
name: string
|
||||
email: string
|
||||
avatar_url?: string
|
||||
}
|
||||
|
||||
export type WorkflowCommentList = {
|
||||
id: string
|
||||
position_x: number
|
||||
position_y: number
|
||||
content: string
|
||||
created_by: string
|
||||
created_by_account: UserProfile
|
||||
created_at: number
|
||||
updated_at: number
|
||||
resolved: boolean
|
||||
resolved_by?: string
|
||||
resolved_by_account?: UserProfile
|
||||
resolved_at?: number
|
||||
mention_count: number
|
||||
reply_count: number
|
||||
participants: UserProfile[]
|
||||
}
|
||||
|
||||
export type WorkflowCommentDetailMention = {
|
||||
mentioned_user_id: string
|
||||
mentioned_user_account?: UserProfile | null
|
||||
reply_id: string | null
|
||||
}
|
||||
|
||||
export type WorkflowCommentDetailReply = {
|
||||
id: string
|
||||
content: string
|
||||
created_by: string
|
||||
created_by_account?: UserProfile | null
|
||||
created_at: number
|
||||
}
|
||||
|
||||
export type WorkflowCommentDetail = {
|
||||
id: string
|
||||
position_x: number
|
||||
position_y: number
|
||||
content: string
|
||||
created_by: string
|
||||
created_by_account: UserProfile
|
||||
created_at: number
|
||||
updated_at: number
|
||||
resolved: boolean
|
||||
resolved_by?: string
|
||||
resolved_by_account?: UserProfile
|
||||
resolved_at?: number
|
||||
replies: WorkflowCommentDetailReply[]
|
||||
mentions: WorkflowCommentDetailMention[]
|
||||
}
|
||||
|
||||
export type WorkflowCommentCreateRes = {
|
||||
id: string
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export type WorkflowCommentUpdateRes = {
|
||||
id: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export type WorkflowCommentResolveRes = {
|
||||
id: string
|
||||
resolved: boolean
|
||||
resolved_by: string
|
||||
resolved_at: number
|
||||
}
|
||||
|
||||
export type WorkflowCommentReply = {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
export type CreateCommentParams = {
|
||||
position_x: number
|
||||
position_y: number
|
||||
content: string
|
||||
mentioned_user_ids?: string[]
|
||||
}
|
||||
|
||||
export type UpdateCommentParams = {
|
||||
content: string
|
||||
position_x?: number
|
||||
position_y?: number
|
||||
mentioned_user_ids?: string[]
|
||||
}
|
||||
|
||||
export type CreateReplyParams = {
|
||||
content: string
|
||||
mentioned_user_ids?: string[]
|
||||
}
|
||||
|
||||
export const workflowCommentListContract = base
|
||||
.route({
|
||||
path: '/apps/{appId}/workflow/comments',
|
||||
method: 'GET',
|
||||
})
|
||||
.input(type<{
|
||||
params: {
|
||||
appId: string
|
||||
}
|
||||
}>())
|
||||
.output(type<{ data: WorkflowCommentList[] }>())
|
||||
|
||||
export const workflowCommentCreateContract = base
|
||||
.route({
|
||||
path: '/apps/{appId}/workflow/comments',
|
||||
method: 'POST',
|
||||
})
|
||||
.input(type<{
|
||||
params: {
|
||||
appId: string
|
||||
}
|
||||
body: CreateCommentParams
|
||||
}>())
|
||||
.output(type<WorkflowCommentCreateRes>())
|
||||
|
||||
export const workflowCommentDetailContract = base
|
||||
.route({
|
||||
path: '/apps/{appId}/workflow/comments/{commentId}',
|
||||
method: 'GET',
|
||||
})
|
||||
.input(type<{
|
||||
params: {
|
||||
appId: string
|
||||
commentId: string
|
||||
}
|
||||
}>())
|
||||
.output(type<WorkflowCommentDetail>())
|
||||
|
||||
export const workflowCommentUpdateContract = base
|
||||
.route({
|
||||
path: '/apps/{appId}/workflow/comments/{commentId}',
|
||||
method: 'PUT',
|
||||
})
|
||||
.input(type<{
|
||||
params: {
|
||||
appId: string
|
||||
commentId: string
|
||||
}
|
||||
body: UpdateCommentParams
|
||||
}>())
|
||||
.output(type<WorkflowCommentUpdateRes>())
|
||||
|
||||
export const workflowCommentDeleteContract = base
|
||||
.route({
|
||||
path: '/apps/{appId}/workflow/comments/{commentId}',
|
||||
method: 'DELETE',
|
||||
})
|
||||
.input(type<{
|
||||
params: {
|
||||
appId: string
|
||||
commentId: string
|
||||
}
|
||||
}>())
|
||||
.output(type<CommonResponse>())
|
||||
|
||||
export const workflowCommentResolveContract = base
|
||||
.route({
|
||||
path: '/apps/{appId}/workflow/comments/{commentId}/resolve',
|
||||
method: 'POST',
|
||||
})
|
||||
.input(type<{
|
||||
params: {
|
||||
appId: string
|
||||
commentId: string
|
||||
}
|
||||
}>())
|
||||
.output(type<WorkflowCommentResolveRes>())
|
||||
|
||||
export const workflowCommentReplyCreateContract = base
|
||||
.route({
|
||||
path: '/apps/{appId}/workflow/comments/{commentId}/replies',
|
||||
method: 'POST',
|
||||
})
|
||||
.input(type<{
|
||||
params: {
|
||||
appId: string
|
||||
commentId: string
|
||||
}
|
||||
body: CreateReplyParams
|
||||
}>())
|
||||
.output(type<WorkflowCommentReply>())
|
||||
|
||||
export const workflowCommentReplyUpdateContract = base
|
||||
.route({
|
||||
path: '/apps/{appId}/workflow/comments/{commentId}/replies/{replyId}',
|
||||
method: 'PUT',
|
||||
})
|
||||
.input(type<{
|
||||
params: {
|
||||
appId: string
|
||||
commentId: string
|
||||
replyId: string
|
||||
}
|
||||
body: CreateReplyParams
|
||||
}>())
|
||||
.output(type<WorkflowCommentReply>())
|
||||
|
||||
export const workflowCommentReplyDeleteContract = base
|
||||
.route({
|
||||
path: '/apps/{appId}/workflow/comments/{commentId}/replies/{replyId}',
|
||||
method: 'DELETE',
|
||||
})
|
||||
.input(type<{
|
||||
params: {
|
||||
appId: string
|
||||
commentId: string
|
||||
replyId: string
|
||||
}
|
||||
}>())
|
||||
.output(type<CommonResponse>())
|
||||
|
||||
export const workflowCommentMentionUsersContract = base
|
||||
.route({
|
||||
path: '/apps/{appId}/workflow/comments/mention-users',
|
||||
method: 'GET',
|
||||
})
|
||||
.input(type<{
|
||||
params: {
|
||||
appId: string
|
||||
}
|
||||
}>())
|
||||
.output(type<{ users: UserProfile[] }>())
|
||||
|
||||
export const workflowCommentContracts = {
|
||||
list: workflowCommentListContract,
|
||||
create: workflowCommentCreateContract,
|
||||
detail: workflowCommentDetailContract,
|
||||
update: workflowCommentUpdateContract,
|
||||
delete: workflowCommentDeleteContract,
|
||||
resolve: workflowCommentResolveContract,
|
||||
mentionUsers: workflowCommentMentionUsersContract,
|
||||
replies: {
|
||||
create: workflowCommentReplyCreateContract,
|
||||
update: workflowCommentReplyUpdateContract,
|
||||
delete: workflowCommentReplyDeleteContract,
|
||||
},
|
||||
}
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
import type {
|
||||
FileUpload,
|
||||
RetrieverResource,
|
||||
SensitiveWordAvoidance,
|
||||
SpeechToText,
|
||||
SuggestedQuestionsAfterAnswer,
|
||||
TextToSpeech,
|
||||
} from '@/app/components/base/features/types'
|
||||
import type { ConversationVariable, EnvironmentVariable } from '@/app/components/workflow/types'
|
||||
import type { CommonResponse } from '@/models/common'
|
||||
import { type } from '@orpc/contract'
|
||||
import { base } from '../base'
|
||||
|
||||
export type WorkflowDraftFeaturesPayload = {
|
||||
opening_statement: string
|
||||
suggested_questions: string[]
|
||||
suggested_questions_after_answer?: SuggestedQuestionsAfterAnswer
|
||||
text_to_speech?: TextToSpeech
|
||||
speech_to_text?: SpeechToText
|
||||
retriever_resource?: RetrieverResource
|
||||
sensitive_word_avoidance?: SensitiveWordAvoidance
|
||||
file_upload?: FileUpload
|
||||
}
|
||||
|
||||
export const workflowDraftEnvironmentVariablesContract = base
|
||||
.route({
|
||||
path: '/apps/{appId}/workflows/draft/environment-variables',
|
||||
method: 'GET',
|
||||
})
|
||||
.input(type<{
|
||||
params: {
|
||||
appId: string
|
||||
}
|
||||
}>())
|
||||
.output(type<{ items: EnvironmentVariable[] }>())
|
||||
|
||||
export const workflowDraftUpdateEnvironmentVariablesContract = base
|
||||
.route({
|
||||
path: '/apps/{appId}/workflows/draft/environment-variables',
|
||||
method: 'POST',
|
||||
})
|
||||
.input(type<{
|
||||
params: {
|
||||
appId: string
|
||||
}
|
||||
body: {
|
||||
environment_variables: EnvironmentVariable[]
|
||||
}
|
||||
}>())
|
||||
.output(type<CommonResponse>())
|
||||
|
||||
export const workflowDraftUpdateConversationVariablesContract = base
|
||||
.route({
|
||||
path: '/apps/{appId}/workflows/draft/conversation-variables',
|
||||
method: 'POST',
|
||||
})
|
||||
.input(type<{
|
||||
params: {
|
||||
appId: string
|
||||
}
|
||||
body: {
|
||||
conversation_variables: ConversationVariable[]
|
||||
}
|
||||
}>())
|
||||
.output(type<CommonResponse>())
|
||||
|
||||
export const workflowDraftUpdateFeaturesContract = base
|
||||
.route({
|
||||
path: '/apps/{appId}/workflows/draft/features',
|
||||
method: 'POST',
|
||||
})
|
||||
.input(type<{
|
||||
params: {
|
||||
appId: string
|
||||
}
|
||||
body: {
|
||||
features: WorkflowDraftFeaturesPayload
|
||||
}
|
||||
}>())
|
||||
.output(type<CommonResponse>())
|
||||
|
|
@ -1,6 +1,15 @@
|
|||
import type { InferContractRouterInputs } from '@orpc/contract'
|
||||
import { accountAvatarContract } from './console/account'
|
||||
import { workflowOnlineUsersContract } from './console/apps'
|
||||
import { bindPartnerStackContract, invoicesContract } from './console/billing'
|
||||
import { systemFeaturesContract } from './console/system'
|
||||
import {
|
||||
workflowDraftEnvironmentVariablesContract,
|
||||
workflowDraftUpdateConversationVariablesContract,
|
||||
workflowDraftUpdateEnvironmentVariablesContract,
|
||||
workflowDraftUpdateFeaturesContract,
|
||||
} from './console/workflow'
|
||||
import { workflowCommentContracts } from './console/workflow-comment'
|
||||
import { collectionPluginsContract, collectionsContract, searchAdvancedContract } from './marketplace'
|
||||
|
||||
export const marketplaceRouterContract = {
|
||||
|
|
@ -12,11 +21,24 @@ export const marketplaceRouterContract = {
|
|||
export type MarketPlaceInputs = InferContractRouterInputs<typeof marketplaceRouterContract>
|
||||
|
||||
export const consoleRouterContract = {
|
||||
account: {
|
||||
avatar: accountAvatarContract,
|
||||
},
|
||||
systemFeatures: systemFeaturesContract,
|
||||
billing: {
|
||||
invoices: invoicesContract,
|
||||
bindPartnerStack: bindPartnerStackContract,
|
||||
},
|
||||
apps: {
|
||||
workflowOnlineUsers: workflowOnlineUsersContract,
|
||||
},
|
||||
workflowDraft: {
|
||||
environmentVariables: workflowDraftEnvironmentVariablesContract,
|
||||
updateEnvironmentVariables: workflowDraftUpdateEnvironmentVariablesContract,
|
||||
updateConversationVariables: workflowDraftUpdateConversationVariablesContract,
|
||||
updateFeatures: workflowDraftUpdateFeaturesContract,
|
||||
},
|
||||
workflowComments: workflowCommentContracts,
|
||||
}
|
||||
|
||||
export type ConsoleInputs = InferContractRouterInputs<typeof consoleRouterContract>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
import type { TracingProvider } from '@/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/type'
|
||||
import type { ApiKeysListResponse, AppDailyConversationsResponse, AppDailyEndUsersResponse, AppDailyMessagesResponse, AppDetailResponse, AppListResponse, AppStatisticsResponse, AppTemplatesResponse, AppTokenCostsResponse, AppVoicesListResponse, CreateApiKeyResponse, DSLImportMode, DSLImportResponse, GenerationIntroductionResponse, TracingConfig, TracingStatus, UpdateAppModelConfigResponse, UpdateAppSiteCodeResponse, UpdateOpenAIKeyResponse, ValidateOpenAIKeyResponse, WebhookTriggerResponse, WorkflowDailyConversationsResponse, WorkflowOnlineUser, WorkflowOnlineUsersResponse } from '@/models/app'
|
||||
import type { ApiKeysListResponse, AppDailyConversationsResponse, AppDailyEndUsersResponse, AppDailyMessagesResponse, AppDetailResponse, AppListResponse, AppStatisticsResponse, AppTemplatesResponse, AppTokenCostsResponse, AppVoicesListResponse, CreateApiKeyResponse, DSLImportMode, DSLImportResponse, GenerationIntroductionResponse, TracingConfig, TracingStatus, UpdateAppModelConfigResponse, UpdateAppSiteCodeResponse, UpdateOpenAIKeyResponse, ValidateOpenAIKeyResponse, WebhookTriggerResponse, WorkflowDailyConversationsResponse, WorkflowOnlineUser } from '@/models/app'
|
||||
import type { CommonResponse } from '@/models/common'
|
||||
import type { AppIconType, AppModeEnum, ModelConfig } from '@/types/app'
|
||||
import { del, get, patch, post, put } from './base'
|
||||
import { consoleClient } from './client'
|
||||
|
||||
export const fetchAppList = ({ url, params }: { url: string, params?: Record<string, any> }): Promise<AppListResponse> => {
|
||||
return get<AppListResponse>(url, { params })
|
||||
|
|
@ -13,7 +14,9 @@ export const fetchWorkflowOnlineUsers = async ({ workflowIds }: { workflowIds: s
|
|||
return {}
|
||||
|
||||
const params = { workflow_ids: workflowIds.join(',') }
|
||||
const response = await get<WorkflowOnlineUsersResponse>('apps/workflows/online-users', { params })
|
||||
const response = await consoleClient.apps.workflowOnlineUsers({
|
||||
query: params,
|
||||
})
|
||||
|
||||
if (!response || !response.data)
|
||||
return {}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import type {
|
|||
} from '@/models/common'
|
||||
import type { RETRIEVE_METHOD } from '@/types/app'
|
||||
import { del, get, patch, post, put } from './base'
|
||||
import { consoleClient } from './client'
|
||||
|
||||
type LoginSuccess = {
|
||||
result: 'success'
|
||||
|
|
@ -385,4 +386,4 @@ export const checkEmailExisted = (body: { email: string }): Promise<CommonRespon
|
|||
post<CommonResponse>('/account/change-email/check-email-unique', { body }, { silent: true })
|
||||
|
||||
export const getAvatar = ({ avatar }: { avatar: string }): Promise<{ avatar_url: string }> =>
|
||||
get<{ avatar_url: string }>('/account/avatar', { params: { avatar } })
|
||||
consoleClient.account.avatar({ query: { avatar } })
|
||||
|
|
|
|||
|
|
@ -1,152 +1,102 @@
|
|||
import type {
|
||||
CreateCommentParams,
|
||||
CreateReplyParams,
|
||||
UpdateCommentParams,
|
||||
WorkflowCommentCreateRes,
|
||||
WorkflowCommentDetail,
|
||||
WorkflowCommentList,
|
||||
WorkflowCommentReply,
|
||||
WorkflowCommentResolveRes,
|
||||
WorkflowCommentUpdateRes,
|
||||
} from '@/contract/console/workflow-comment'
|
||||
import type { CommonResponse } from '@/models/common'
|
||||
import { del, get, post, put } from './base'
|
||||
import { consoleClient } from './client'
|
||||
|
||||
export type UserProfile = {
|
||||
id: string
|
||||
name: string
|
||||
email: string
|
||||
avatar_url?: string
|
||||
}
|
||||
|
||||
export type WorkflowCommentList = {
|
||||
id: string
|
||||
position_x: number
|
||||
position_y: number
|
||||
content: string
|
||||
created_by: string
|
||||
created_by_account: UserProfile
|
||||
created_at: number
|
||||
updated_at: number
|
||||
resolved: boolean
|
||||
resolved_by?: string
|
||||
resolved_by_account?: UserProfile
|
||||
resolved_at?: number
|
||||
mention_count: number
|
||||
reply_count: number
|
||||
participants: UserProfile[]
|
||||
}
|
||||
|
||||
export type WorkflowCommentDetailMention = {
|
||||
mentioned_user_id: string
|
||||
mentioned_user_account?: UserProfile | null
|
||||
reply_id: string | null
|
||||
}
|
||||
|
||||
export type WorkflowCommentDetailReply = {
|
||||
id: string
|
||||
content: string
|
||||
created_by: string
|
||||
created_by_account?: UserProfile | null
|
||||
created_at: number
|
||||
}
|
||||
|
||||
export type WorkflowCommentDetail = {
|
||||
id: string
|
||||
position_x: number
|
||||
position_y: number
|
||||
content: string
|
||||
created_by: string
|
||||
created_by_account: UserProfile
|
||||
created_at: number
|
||||
updated_at: number
|
||||
resolved: boolean
|
||||
resolved_by?: string
|
||||
resolved_by_account?: UserProfile
|
||||
resolved_at?: number
|
||||
replies: WorkflowCommentDetailReply[]
|
||||
mentions: WorkflowCommentDetailMention[]
|
||||
}
|
||||
|
||||
export type WorkflowCommentCreateRes = {
|
||||
id: string
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export type WorkflowCommentUpdateRes = {
|
||||
id: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export type WorkflowCommentResolveRes = {
|
||||
id: string
|
||||
resolved: boolean
|
||||
resolved_by: string
|
||||
resolved_at: number
|
||||
}
|
||||
|
||||
export type WorkflowCommentReply = {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
export type CreateCommentParams = {
|
||||
position_x: number
|
||||
position_y: number
|
||||
content: string
|
||||
mentioned_user_ids?: string[]
|
||||
}
|
||||
|
||||
export type UpdateCommentParams = {
|
||||
content: string
|
||||
position_x?: number
|
||||
position_y?: number
|
||||
mentioned_user_ids?: string[]
|
||||
}
|
||||
|
||||
export type CreateReplyParams = {
|
||||
content: string
|
||||
mentioned_user_ids?: string[]
|
||||
}
|
||||
export type {
|
||||
CreateCommentParams,
|
||||
CreateReplyParams,
|
||||
UpdateCommentParams,
|
||||
UserProfile,
|
||||
WorkflowCommentCreateRes,
|
||||
WorkflowCommentDetail,
|
||||
WorkflowCommentDetailMention,
|
||||
WorkflowCommentDetailReply,
|
||||
WorkflowCommentList,
|
||||
WorkflowCommentReply,
|
||||
WorkflowCommentResolveRes,
|
||||
WorkflowCommentUpdateRes,
|
||||
} from '@/contract/console/workflow-comment'
|
||||
|
||||
export const fetchWorkflowComments = async (appId: string): Promise<WorkflowCommentList[]> => {
|
||||
const response = await get<{ data: WorkflowCommentList[] }>(`apps/${appId}/workflow/comments`)
|
||||
const response = await consoleClient.workflowComments.list({
|
||||
params: { appId },
|
||||
})
|
||||
return response.data
|
||||
}
|
||||
|
||||
export const createWorkflowComment = async (appId: string, params: CreateCommentParams): Promise<WorkflowCommentCreateRes> => {
|
||||
return post<WorkflowCommentCreateRes>(`apps/${appId}/workflow/comments`, { body: params })
|
||||
return consoleClient.workflowComments.create({
|
||||
params: { appId },
|
||||
body: params,
|
||||
})
|
||||
}
|
||||
|
||||
export const fetchWorkflowComment = async (appId: string, commentId: string): Promise<WorkflowCommentDetail> => {
|
||||
return get<WorkflowCommentDetail>(`apps/${appId}/workflow/comments/${commentId}`)
|
||||
return consoleClient.workflowComments.detail({
|
||||
params: { appId, commentId },
|
||||
})
|
||||
}
|
||||
|
||||
export const updateWorkflowComment = async (appId: string, commentId: string, params: UpdateCommentParams): Promise<WorkflowCommentUpdateRes> => {
|
||||
return put<WorkflowCommentUpdateRes>(`apps/${appId}/workflow/comments/${commentId}`, { body: params })
|
||||
return consoleClient.workflowComments.update({
|
||||
params: { appId, commentId },
|
||||
body: params,
|
||||
})
|
||||
}
|
||||
|
||||
export const deleteWorkflowComment = async (appId: string, commentId: string): Promise<CommonResponse> => {
|
||||
return del<CommonResponse>(`apps/${appId}/workflow/comments/${commentId}`)
|
||||
return consoleClient.workflowComments.delete({
|
||||
params: { appId, commentId },
|
||||
})
|
||||
}
|
||||
|
||||
export const resolveWorkflowComment = async (appId: string, commentId: string): Promise<WorkflowCommentResolveRes> => {
|
||||
return post<WorkflowCommentResolveRes>(`apps/${appId}/workflow/comments/${commentId}/resolve`)
|
||||
return consoleClient.workflowComments.resolve({
|
||||
params: { appId, commentId },
|
||||
})
|
||||
}
|
||||
|
||||
export const createWorkflowCommentReply = async (appId: string, commentId: string, params: CreateReplyParams): Promise<WorkflowCommentReply> => {
|
||||
return post<WorkflowCommentReply>(`apps/${appId}/workflow/comments/${commentId}/replies`, { body: params })
|
||||
return consoleClient.workflowComments.replies.create({
|
||||
params: { appId, commentId },
|
||||
body: params,
|
||||
})
|
||||
}
|
||||
|
||||
export const updateWorkflowCommentReply = async (appId: string, commentId: string, replyId: string, params: CreateReplyParams): Promise<WorkflowCommentReply> => {
|
||||
return put<WorkflowCommentReply>(`apps/${appId}/workflow/comments/${commentId}/replies/${replyId}`, { body: params })
|
||||
return consoleClient.workflowComments.replies.update({
|
||||
params: {
|
||||
appId,
|
||||
commentId,
|
||||
replyId,
|
||||
},
|
||||
body: params,
|
||||
})
|
||||
}
|
||||
|
||||
export const deleteWorkflowCommentReply = async (appId: string, commentId: string, replyId: string): Promise<CommonResponse> => {
|
||||
return del<CommonResponse>(`apps/${appId}/workflow/comments/${commentId}/replies/${replyId}`)
|
||||
return consoleClient.workflowComments.replies.delete({
|
||||
params: {
|
||||
appId,
|
||||
commentId,
|
||||
replyId,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export const fetchMentionableUsers = async (appId: string) => {
|
||||
const response = await get<{ users: Array<UserProfile> }>(`apps/${appId}/workflow/comments/mention-users`)
|
||||
const response = await consoleClient.workflowComments.mentionUsers({
|
||||
params: { appId },
|
||||
})
|
||||
return response.users
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,5 @@
|
|||
import type {
|
||||
FileUpload,
|
||||
RetrieverResource,
|
||||
SensitiveWordAvoidance,
|
||||
SpeechToText,
|
||||
SuggestedQuestionsAfterAnswer,
|
||||
TextToSpeech,
|
||||
} from '@/app/components/base/features/types'
|
||||
import type { BlockEnum, ConversationVariable, EnvironmentVariable } from '@/app/components/workflow/types'
|
||||
import type { WorkflowDraftFeaturesPayload } from '@/contract/console/workflow'
|
||||
import type { CommonResponse } from '@/models/common'
|
||||
import type { FlowType } from '@/types/common'
|
||||
import type {
|
||||
|
|
@ -16,19 +9,11 @@ import type {
|
|||
VarInInspect,
|
||||
} from '@/types/workflow'
|
||||
import { get, post } from './base'
|
||||
import { consoleClient } from './client'
|
||||
import { getFlowPrefix } from './utils'
|
||||
import { sanitizeWorkflowDraftPayload } from './workflow-payload'
|
||||
|
||||
export type WorkflowDraftFeaturesPayload = {
|
||||
opening_statement: string
|
||||
suggested_questions: string[]
|
||||
suggested_questions_after_answer?: SuggestedQuestionsAfterAnswer
|
||||
text_to_speech?: TextToSpeech
|
||||
speech_to_text?: SpeechToText
|
||||
retriever_resource?: RetrieverResource
|
||||
sensitive_word_avoidance?: SensitiveWordAvoidance
|
||||
file_upload?: FileUpload
|
||||
}
|
||||
export type { WorkflowDraftFeaturesPayload } from '@/contract/console/workflow'
|
||||
|
||||
export const fetchWorkflowDraft = (url: string) => {
|
||||
return get(url, {}, { silent: true }) as Promise<FetchWorkflowDraftResponse>
|
||||
|
|
@ -118,15 +103,18 @@ export const fetchNodeInspectVars = async (flowType: FlowType, flowId: string, n
|
|||
|
||||
// Environment Variables API
|
||||
export const fetchEnvironmentVariables = async (appId: string): Promise<EnvironmentVariable[]> => {
|
||||
const { items } = (await get(`apps/${appId}/workflows/draft/environment-variables`)) as { items: EnvironmentVariable[] }
|
||||
return items
|
||||
const response = await consoleClient.workflowDraft.environmentVariables({
|
||||
params: { appId },
|
||||
})
|
||||
return response.items
|
||||
}
|
||||
|
||||
export const updateEnvironmentVariables = ({ appId, environmentVariables }: {
|
||||
appId: string
|
||||
environmentVariables: EnvironmentVariable[]
|
||||
}) => {
|
||||
return post<CommonResponse>(`apps/${appId}/workflows/draft/environment-variables`, {
|
||||
return consoleClient.workflowDraft.updateEnvironmentVariables({
|
||||
params: { appId },
|
||||
body: { environment_variables: environmentVariables },
|
||||
})
|
||||
}
|
||||
|
|
@ -135,7 +123,8 @@ export const updateConversationVariables = ({ appId, conversationVariables }: {
|
|||
appId: string
|
||||
conversationVariables: ConversationVariable[]
|
||||
}) => {
|
||||
return post<CommonResponse>(`apps/${appId}/workflows/draft/conversation-variables`, {
|
||||
return consoleClient.workflowDraft.updateConversationVariables({
|
||||
params: { appId },
|
||||
body: { conversation_variables: conversationVariables },
|
||||
})
|
||||
}
|
||||
|
|
@ -144,7 +133,8 @@ export const updateFeatures = ({ appId, features }: {
|
|||
appId: string
|
||||
features: WorkflowDraftFeaturesPayload
|
||||
}) => {
|
||||
return post<CommonResponse>(`apps/${appId}/workflows/draft/features`, {
|
||||
return consoleClient.workflowDraft.updateFeatures({
|
||||
params: { appId },
|
||||
body: { features },
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue