mirror of
https://github.com/langgenius/dify.git
synced 2026-03-12 02:28:54 +08:00
sort
This commit is contained in:
@ -11,8 +11,8 @@ import { base } from '../common'
|
||||
* Get application's feedbacks.
|
||||
*/
|
||||
export const getChatAppFeedbacksContract = base.route({
|
||||
path: '/app/feedbacks',
|
||||
method: 'GET',
|
||||
path: '/app/feedbacks',
|
||||
operationId: 'getChatAppFeedbacks',
|
||||
summary: 'Get feedbacks of application',
|
||||
description: 'Get application\'s feedbacks.',
|
||||
|
||||
@ -11,8 +11,8 @@ import { base } from '../common'
|
||||
* Retrieves a list of annotations for the application.
|
||||
*/
|
||||
export const getAnnotationListContract = base.route({
|
||||
path: '/apps/annotations',
|
||||
method: 'GET',
|
||||
path: '/apps/annotations',
|
||||
operationId: 'getAnnotationList',
|
||||
summary: 'Get Annotation List',
|
||||
description: 'Retrieves a list of annotations for the application.',
|
||||
@ -25,8 +25,8 @@ export const getAnnotationListContract = base.route({
|
||||
* Creates a new annotation.
|
||||
*/
|
||||
export const createAnnotationContract = base.route({
|
||||
path: '/apps/annotations',
|
||||
method: 'POST',
|
||||
path: '/apps/annotations',
|
||||
operationId: 'createAnnotation',
|
||||
summary: 'Create Annotation',
|
||||
description: 'Creates a new annotation.',
|
||||
@ -39,8 +39,8 @@ export const createAnnotationContract = base.route({
|
||||
* Deletes an annotation.
|
||||
*/
|
||||
export const deleteAnnotationContract = base.route({
|
||||
path: '/apps/annotations/{annotation_id}',
|
||||
method: 'DELETE',
|
||||
path: '/apps/annotations/{annotation_id}',
|
||||
operationId: 'deleteAnnotation',
|
||||
summary: 'Delete Annotation',
|
||||
description: 'Deletes an annotation.',
|
||||
@ -53,8 +53,8 @@ export const deleteAnnotationContract = base.route({
|
||||
* Updates an existing annotation.
|
||||
*/
|
||||
export const updateAnnotationContract = base.route({
|
||||
path: '/apps/annotations/{annotation_id}',
|
||||
method: 'PUT',
|
||||
path: '/apps/annotations/{annotation_id}',
|
||||
operationId: 'updateAnnotation',
|
||||
summary: 'Update Annotation',
|
||||
description: 'Updates an existing annotation.',
|
||||
@ -67,8 +67,8 @@ export const updateAnnotationContract = base.route({
|
||||
* Enable or disable annotation reply settings and configure embedding models. This interface is executed asynchronously.
|
||||
*/
|
||||
export const initialAnnotationReplySettingsContract = base.route({
|
||||
path: '/apps/annotation-reply/{action}',
|
||||
method: 'POST',
|
||||
path: '/apps/annotation-reply/{action}',
|
||||
operationId: 'initialAnnotationReplySettings',
|
||||
summary: 'Initial Annotation Reply Settings',
|
||||
description: 'Enable or disable annotation reply settings and configure embedding models. This interface is executed asynchronously.',
|
||||
@ -81,8 +81,8 @@ export const initialAnnotationReplySettingsContract = base.route({
|
||||
* Queries the status of an asynchronously executed annotation reply settings task.
|
||||
*/
|
||||
export const getInitialAnnotationReplySettingsStatusContract = base.route({
|
||||
path: '/apps/annotation-reply/{action}/status/{job_id}',
|
||||
method: 'GET',
|
||||
path: '/apps/annotation-reply/{action}/status/{job_id}',
|
||||
operationId: 'getInitialAnnotationReplySettingsStatus',
|
||||
summary: 'Query Initial Annotation Reply Settings Task Status',
|
||||
description: 'Queries the status of an asynchronously executed annotation reply settings task.',
|
||||
|
||||
@ -11,8 +11,8 @@ import { base } from '../common'
|
||||
* Convert audio file to text. Supported formats: mp3, mp4, mpeg, mpga, m4a, wav, webm. File size limit: 15MB.
|
||||
*/
|
||||
export const audioToTextContract = base.route({
|
||||
path: '/audio-to-text',
|
||||
method: 'POST',
|
||||
path: '/audio-to-text',
|
||||
operationId: 'audioToText',
|
||||
summary: 'Speech to Text',
|
||||
description: 'Convert audio file to text. Supported formats: mp3, mp4, mpeg, mpga, m4a, wav, webm. File size limit: 15MB.',
|
||||
|
||||
@ -11,8 +11,8 @@ import { base } from '../common'
|
||||
* Send a request to the chat application.
|
||||
*/
|
||||
export const sendChatMessageContract = base.route({
|
||||
path: '/chat-messages',
|
||||
method: 'POST',
|
||||
path: '/chat-messages',
|
||||
operationId: 'sendChatMessage',
|
||||
summary: 'Send Chat Message',
|
||||
description: 'Send a request to the chat application.',
|
||||
@ -25,8 +25,8 @@ export const sendChatMessageContract = base.route({
|
||||
* Stops a chat message generation task. Only supported in streaming mode.
|
||||
*/
|
||||
export const stopChatMessageGenerationContract = base.route({
|
||||
path: '/chat-messages/{task_id}/stop',
|
||||
method: 'POST',
|
||||
path: '/chat-messages/{task_id}/stop',
|
||||
operationId: 'stopChatMessageGeneration',
|
||||
summary: 'Stop Chat Message Generation',
|
||||
description: 'Stops a chat message generation task. Only supported in streaming mode.',
|
||||
|
||||
@ -11,8 +11,8 @@ import { base } from '../common'
|
||||
* Retrieve the conversation list for the current user, defaulting to the most recent 20 entries.
|
||||
*/
|
||||
export const getConversationsListContract = base.route({
|
||||
path: '/conversations',
|
||||
method: 'GET',
|
||||
path: '/conversations',
|
||||
operationId: 'getConversationsList',
|
||||
summary: 'Get Conversations',
|
||||
description: 'Retrieve the conversation list for the current user, defaulting to the most recent 20 entries.',
|
||||
@ -25,8 +25,8 @@ export const getConversationsListContract = base.route({
|
||||
* Delete a conversation.
|
||||
*/
|
||||
export const deleteConversationContract = base.route({
|
||||
path: '/conversations/{conversation_id}',
|
||||
method: 'DELETE',
|
||||
path: '/conversations/{conversation_id}',
|
||||
operationId: 'deleteConversation',
|
||||
summary: 'Delete Conversation',
|
||||
description: 'Delete a conversation.',
|
||||
@ -39,8 +39,8 @@ export const deleteConversationContract = base.route({
|
||||
* Rename the session. The session name is used for display on clients that support multiple sessions.
|
||||
*/
|
||||
export const renameConversationContract = base.route({
|
||||
path: '/conversations/{conversation_id}/name',
|
||||
method: 'POST',
|
||||
path: '/conversations/{conversation_id}/name',
|
||||
operationId: 'renameConversation',
|
||||
summary: 'Conversation Rename',
|
||||
description: 'Rename the session. The session name is used for display on clients that support multiple sessions.',
|
||||
@ -53,8 +53,8 @@ export const renameConversationContract = base.route({
|
||||
* Retrieve variables from a specific conversation.
|
||||
*/
|
||||
export const getConversationVariablesContract = base.route({
|
||||
path: '/conversations/{conversation_id}/variables',
|
||||
method: 'GET',
|
||||
path: '/conversations/{conversation_id}/variables',
|
||||
operationId: 'getConversationVariables',
|
||||
summary: 'Get Conversation Variables',
|
||||
description: 'Retrieve variables from a specific conversation.',
|
||||
|
||||
@ -11,8 +11,8 @@ import { base } from '../common'
|
||||
* Upload a file (currently only images are supported) for use when sending messages, enabling multimodal understanding of images and text. Supports png, jpg, jpeg, webp, gif formats. Uploaded files are for use by the current end-user only.
|
||||
*/
|
||||
export const uploadChatFileContract = base.route({
|
||||
path: '/files/upload',
|
||||
method: 'POST',
|
||||
path: '/files/upload',
|
||||
operationId: 'uploadChatFile',
|
||||
summary: 'File Upload',
|
||||
description: 'Upload a file (currently only images are supported) for use when sending messages, enabling multimodal understanding of images and text. Supports png, jpg, jpeg, webp, gif formats. Uploaded files are for use by the current end-user only.',
|
||||
@ -25,8 +25,8 @@ export const uploadChatFileContract = base.route({
|
||||
* Preview or download uploaded files. This endpoint allows you to access files that have been previously uploaded via the File Upload API. Files can only be accessed if they belong to messages within the requesting application.
|
||||
*/
|
||||
export const previewChatFileContract = base.route({
|
||||
path: '/files/{file_id}/preview',
|
||||
method: 'GET',
|
||||
path: '/files/{file_id}/preview',
|
||||
operationId: 'previewChatFile',
|
||||
summary: 'File Preview',
|
||||
description: 'Preview or download uploaded files. This endpoint allows you to access files that have been previously uploaded via the File Upload API. Files can only be accessed if they belong to messages within the requesting application.',
|
||||
|
||||
@ -11,8 +11,8 @@ import { base } from '../common'
|
||||
* Used to get basic information about this application.
|
||||
*/
|
||||
export const getChatAppInfoContract = base.route({
|
||||
path: '/info',
|
||||
method: 'GET',
|
||||
path: '/info',
|
||||
operationId: 'getChatAppInfo',
|
||||
summary: 'Get Application Basic Information',
|
||||
description: 'Used to get basic information about this application.',
|
||||
|
||||
@ -11,8 +11,8 @@ import { base } from '../common'
|
||||
* End-users can provide feedback messages, facilitating application developers to optimize expected outputs.
|
||||
*/
|
||||
export const postChatMessageFeedbackContract = base.route({
|
||||
path: '/messages/{message_id}/feedbacks',
|
||||
method: 'POST',
|
||||
path: '/messages/{message_id}/feedbacks',
|
||||
operationId: 'postChatMessageFeedback',
|
||||
summary: 'Message Feedback',
|
||||
description: 'End-users can provide feedback messages, facilitating application developers to optimize expected outputs.',
|
||||
@ -25,8 +25,8 @@ export const postChatMessageFeedbackContract = base.route({
|
||||
* Get next questions suggestions for the current message.
|
||||
*/
|
||||
export const getSuggestedQuestionsContract = base.route({
|
||||
path: '/messages/{message_id}/suggested',
|
||||
method: 'GET',
|
||||
path: '/messages/{message_id}/suggested',
|
||||
operationId: 'getSuggestedQuestions',
|
||||
summary: 'Next Suggested Questions',
|
||||
description: 'Get next questions suggestions for the current message.',
|
||||
@ -39,8 +39,8 @@ export const getSuggestedQuestionsContract = base.route({
|
||||
* Returns historical chat records in a scrolling load format, with the first page returning the latest `{limit}` messages, i.e., in reverse order.
|
||||
*/
|
||||
export const getConversationHistoryContract = base.route({
|
||||
path: '/messages',
|
||||
method: 'GET',
|
||||
path: '/messages',
|
||||
operationId: 'getConversationHistory',
|
||||
summary: 'Get Conversation History Messages',
|
||||
description: 'Returns historical chat records in a scrolling load format, with the first page returning the latest `{limit}` messages, i.e., in reverse order.',
|
||||
|
||||
@ -11,8 +11,8 @@ import { base } from '../common'
|
||||
* Used to get icons of tools in this application.
|
||||
*/
|
||||
export const getChatAppMetaContract = base.route({
|
||||
path: '/meta',
|
||||
method: 'GET',
|
||||
path: '/meta',
|
||||
operationId: 'getChatAppMeta',
|
||||
summary: 'Get Application Meta Information',
|
||||
description: 'Used to get icons of tools in this application.',
|
||||
|
||||
@ -11,8 +11,8 @@ import { base } from '../common'
|
||||
* Used at the start of entering the page to obtain information such as features, input parameter names, types, and default values.
|
||||
*/
|
||||
export const getChatAppParametersContract = base.route({
|
||||
path: '/parameters',
|
||||
method: 'GET',
|
||||
path: '/parameters',
|
||||
operationId: 'getChatAppParameters',
|
||||
summary: 'Get Application Parameters Information',
|
||||
description: 'Used at the start of entering the page to obtain information such as features, input parameter names, types, and default values.',
|
||||
|
||||
@ -11,8 +11,8 @@ import { base } from '../common'
|
||||
* Used to get the WebApp settings of the application.
|
||||
*/
|
||||
export const getChatWebAppSettingsContract = base.route({
|
||||
path: '/site',
|
||||
method: 'GET',
|
||||
path: '/site',
|
||||
operationId: 'getChatWebAppSettings',
|
||||
summary: 'Get Application WebApp Settings',
|
||||
description: 'Used to get the WebApp settings of the application.',
|
||||
|
||||
@ -11,8 +11,8 @@ import { base } from '../common'
|
||||
* Convert text to speech.
|
||||
*/
|
||||
export const textToAudioChatContract = base.route({
|
||||
path: '/text-to-audio',
|
||||
method: 'POST',
|
||||
path: '/text-to-audio',
|
||||
operationId: 'textToAudioChat',
|
||||
summary: 'Text to Audio',
|
||||
description: 'Convert text to speech.',
|
||||
|
||||
@ -11,11 +11,16 @@ function hasInput(operation: IR.OperationObject): boolean {
|
||||
return hasPathParams || hasQueryParams || hasHeaderParams || hasBody
|
||||
}
|
||||
|
||||
function getSuccessResponse(operation: IR.OperationObject): { hasOutput: boolean, statusCode?: number } {
|
||||
function getSuccessResponse(operation: IR.OperationObject): { hasOutput: true, statusCode: number } | { hasOutput: false } {
|
||||
if (operation.responses) {
|
||||
for (const [statusCode, response] of Object.entries(operation.responses)) {
|
||||
if (statusCode.startsWith('2') && response?.mediaType && response?.schema) {
|
||||
return { hasOutput: true, statusCode: Number.parseInt(statusCode, 10) }
|
||||
const statusCodeNumber = Number.parseInt(statusCode, 10)
|
||||
if (
|
||||
statusCodeNumber >= 200
|
||||
&& statusCodeNumber <= 399
|
||||
&& response?.mediaType && response?.schema
|
||||
) {
|
||||
return { hasOutput: true, statusCode: statusCodeNumber }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -94,13 +99,13 @@ export const handler: OrpcPlugin['Handler'] = ({ plugin }) => {
|
||||
})
|
||||
contractSymbols[op.id] = contractSymbol
|
||||
|
||||
// Build the route config object with all available properties
|
||||
// Build the route config object following Route interface order:
|
||||
// method, path, operationId, summary, description, deprecated, tags, successStatus, successDescription
|
||||
const method = op.method.toUpperCase()
|
||||
const routeConfig = $.object()
|
||||
.prop('path', $.literal(op.path as string))
|
||||
.prop('method', $.literal(method))
|
||||
.prop('path', $.literal(op.path as string))
|
||||
|
||||
// Add optional route properties
|
||||
if (op.operationId) {
|
||||
routeConfig.prop('operationId', $.literal(op.operationId))
|
||||
}
|
||||
@ -116,8 +121,12 @@ export const handler: OrpcPlugin['Handler'] = ({ plugin }) => {
|
||||
if (tags.length > 0) {
|
||||
routeConfig.prop('tags', $.fromValue(tags))
|
||||
}
|
||||
if (successResponse.statusCode && successResponse.statusCode !== 200) {
|
||||
routeConfig.prop('successStatus', $.literal(successResponse.statusCode))
|
||||
if (successResponse.hasOutput) {
|
||||
if (successResponse.statusCode !== 200) {
|
||||
routeConfig.prop('successStatus', $.literal(successResponse.statusCode))
|
||||
}
|
||||
// TODO: Add successDescription from OpenAPI description if available
|
||||
// routeConfig.prop('successDescription', $.literal('OK'))
|
||||
}
|
||||
|
||||
// Build the call chain: base.route({...}).input(...).output(...)
|
||||
|
||||
Reference in New Issue
Block a user