diff --git a/web/gen/orpc/common.gen.ts b/web/gen/orpc/common.gen.ts index 8080acb31c..82aef71b44 100644 --- a/web/gen/orpc/common.gen.ts +++ b/web/gen/orpc/common.gen.ts @@ -2,50 +2,4 @@ import { oc } from '@orpc/contract' -import { getChatAppFeedbacksContract } from './api/app.gen' -import { createAnnotationContract, deleteAnnotationContract, getAnnotationListContract, getInitialAnnotationReplySettingsStatusContract, initialAnnotationReplySettingsContract, updateAnnotationContract } from './api/apps.gen' -import { audioToTextContract } from './api/audio-to-text.gen' -import { sendChatMessageContract, stopChatMessageGenerationContract } from './api/chat-messages.gen' -import { deleteConversationContract, getConversationsListContract, getConversationVariablesContract, renameConversationContract } from './api/conversations.gen' -import { previewChatFileContract, uploadChatFileContract } from './api/files.gen' -import { getChatAppInfoContract } from './api/info.gen' -import { getConversationHistoryContract, getSuggestedQuestionsContract, postChatMessageFeedbackContract } from './api/messages.gen' -import { getChatAppMetaContract } from './api/meta.gen' -import { getChatAppParametersContract } from './api/parameters.gen' -import { getChatWebAppSettingsContract } from './api/site.gen' -import { textToAudioChatContract } from './api/text-to-audio.gen' - export const base = oc.$route({ inputStructure: 'detailed', outputStructure: 'detailed' }) - -export const contracts = { - chatMessages: { send: sendChatMessageContract, stopGeneration: stopChatMessageGenerationContract }, - files: { upload: uploadChatFileContract, preview: previewChatFileContract }, - messages: { - postFeedback: postChatMessageFeedbackContract, - getSuggestedQuestions: getSuggestedQuestionsContract, - getConversationHistory: getConversationHistoryContract, - }, - app: { getFeedbacks: getChatAppFeedbacksContract }, - conversations: { - getList: getConversationsListContract, - delete: deleteConversationContract, - rename: renameConversationContract, - getVariables: getConversationVariablesContract, - }, - audioToText: { audioToText: audioToTextContract }, - textToAudio: { textToAudio: textToAudioChatContract }, - info: { get: getChatAppInfoContract }, - parameters: { get: getChatAppParametersContract }, - meta: { get: getChatAppMetaContract }, - site: { getSettings: getChatWebAppSettingsContract }, - apps: { - getAnnotationList: getAnnotationListContract, - createAnnotation: createAnnotationContract, - deleteAnnotation: deleteAnnotationContract, - updateAnnotation: updateAnnotationContract, - initialAnnotationReplySettings: initialAnnotationReplySettingsContract, - getInitialAnnotationReplySettingsStatus: getInitialAnnotationReplySettingsStatusContract, - }, -} - -export type Contracts = typeof contracts diff --git a/web/gen/orpc/router.gen.ts b/web/gen/orpc/router.gen.ts new file mode 100644 index 0000000000..d1ae3891e3 --- /dev/null +++ b/web/gen/orpc/router.gen.ts @@ -0,0 +1,47 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { getChatAppFeedbacksContract } from './api/app.gen' +import { createAnnotationContract, deleteAnnotationContract, getAnnotationListContract, getInitialAnnotationReplySettingsStatusContract, initialAnnotationReplySettingsContract, updateAnnotationContract } from './api/apps.gen' +import { audioToTextContract } from './api/audio-to-text.gen' +import { sendChatMessageContract, stopChatMessageGenerationContract } from './api/chat-messages.gen' +import { deleteConversationContract, getConversationsListContract, getConversationVariablesContract, renameConversationContract } from './api/conversations.gen' +import { previewChatFileContract, uploadChatFileContract } from './api/files.gen' +import { getChatAppInfoContract } from './api/info.gen' +import { getConversationHistoryContract, getSuggestedQuestionsContract, postChatMessageFeedbackContract } from './api/messages.gen' +import { getChatAppMetaContract } from './api/meta.gen' +import { getChatAppParametersContract } from './api/parameters.gen' +import { getChatWebAppSettingsContract } from './api/site.gen' +import { textToAudioChatContract } from './api/text-to-audio.gen' + +export const router = { + chatMessages: { send: sendChatMessageContract, stopGeneration: stopChatMessageGenerationContract }, + files: { upload: uploadChatFileContract, preview: previewChatFileContract }, + messages: { + postFeedback: postChatMessageFeedbackContract, + getSuggestedQuestions: getSuggestedQuestionsContract, + getConversationHistory: getConversationHistoryContract, + }, + app: { getFeedbacks: getChatAppFeedbacksContract }, + conversations: { + getList: getConversationsListContract, + delete: deleteConversationContract, + rename: renameConversationContract, + getVariables: getConversationVariablesContract, + }, + audioToText: { audioToText: audioToTextContract }, + textToAudio: { textToAudio: textToAudioChatContract }, + info: { get: getChatAppInfoContract }, + parameters: { get: getChatAppParametersContract }, + meta: { get: getChatAppMetaContract }, + site: { getSettings: getChatWebAppSettingsContract }, + apps: { + getAnnotationList: getAnnotationListContract, + createAnnotation: createAnnotationContract, + deleteAnnotation: deleteAnnotationContract, + updateAnnotation: updateAnnotationContract, + initialAnnotationReplySettings: initialAnnotationReplySettingsContract, + getInitialAnnotationReplySettingsStatus: getInitialAnnotationReplySettingsStatusContract, + }, +} + +export type Router = typeof router diff --git a/web/openapi-ts.config.ts b/web/openapi-ts.config.ts index 94b6648c17..c36d263a70 100644 --- a/web/openapi-ts.config.ts +++ b/web/openapi-ts.config.ts @@ -74,6 +74,9 @@ function getFilePath(symbol: { meta?: SymbolMeta }): string | undefined { // Handle orpc plugin symbols if (meta.pluginName === 'orpc') { + if (meta.resource === 'router') { + return 'orpc/router' + } if (meta.resource === 'operation') { const segment = getApiSegment(meta.path) return `orpc/api/${segment ?? 'common'}` diff --git a/web/plugins/hey-api-orpc/plugin.ts b/web/plugins/hey-api-orpc/plugin.ts index e1439f958a..e285e3f658 100644 --- a/web/plugins/hey-api-orpc/plugin.ts +++ b/web/plugins/hey-api-orpc/plugin.ts @@ -295,11 +295,12 @@ export const handler: OrpcPlugin['Handler'] = ({ plugin }) => { plugin.node(contractNode) } - // Create contracts object export grouped by API path segment - const contractsSymbol = plugin.symbol('contracts', { + // Create contracts object export grouped by API path segment (in separate router file) + const contractsSymbol = plugin.symbol('router', { exported: true, meta: { pluginName: 'orpc', + resource: 'router', }, }) @@ -335,16 +336,17 @@ export const handler: OrpcPlugin['Handler'] = ({ plugin }) => { .assign(contractsObject) plugin.node(contractsNode) - // Create type export: export type Contracts = typeof contracts - const contractsTypeSymbol = plugin.symbol('Contracts', { + // Create type export: export type Router = typeof router (in separate router file) + const routerTypeSymbol = plugin.symbol('Router', { exported: true, meta: { pluginName: 'orpc', + resource: 'router', }, }) - const contractsTypeNode = $.type.alias(contractsTypeSymbol) + const routerTypeNode = $.type.alias(routerTypeSymbol) .export() .type($.type.query($(contractsSymbol))) - plugin.node(contractsTypeNode) + plugin.node(routerTypeNode) }