Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(queries): Split schema.ts for maintainability #27258

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/build-schema-json.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import tsj from 'ts-json-schema-generator'
/** @type {import('ts-json-schema-generator/dist/src/Config').Config} */
const config = {
...tsj.DEFAULT_CONFIG,
path: 'frontend/src/queries/schema.ts',
path: 'frontend/src/queries/schema/index.ts',
tsconfig: 'tsconfig.json',
discriminatorType: 'open-api',
skipTypeCheck: true,
Expand Down
711 changes: 444 additions & 267 deletions frontend/src/queries/schema.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions frontend/src/queries/schema/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* eslint-disable simple-import-sort/exports */
export * from './schema-general'
export * from './schema-assistant-queries'
export * from './schema-assistant-messages'
/* eslint-enable simple-import-sort/exports */
70 changes: 70 additions & 0 deletions frontend/src/queries/schema/schema-assistant-messages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { AssistantFunnelsQuery, AssistantTrendsQuery } from './schema-assistant-queries'

export enum AssistantMessageType {
Human = 'human',
Assistant = 'ai',
Reasoning = 'ai/reasoning',
Visualization = 'ai/viz',
Failure = 'ai/failure',
Router = 'ai/router',
}

export interface BaseAssistantMessage {
id?: string
}

export interface HumanMessage extends BaseAssistantMessage {
type: AssistantMessageType.Human
content: string
}

export interface AssistantMessage extends BaseAssistantMessage {
type: AssistantMessageType.Assistant
content: string
}

export interface ReasoningMessage extends BaseAssistantMessage {
type: AssistantMessageType.Reasoning
content: string
substeps?: string[]
}

export interface VisualizationMessage extends BaseAssistantMessage {
type: AssistantMessageType.Visualization
plan?: string
answer?: AssistantTrendsQuery | AssistantFunnelsQuery
initiator?: string
}

export interface FailureMessage extends BaseAssistantMessage {
type: AssistantMessageType.Failure
content?: string
}

export interface RouterMessage extends BaseAssistantMessage {
type: AssistantMessageType.Router
content: string
}

export type RootAssistantMessage =
| VisualizationMessage
| ReasoningMessage
| AssistantMessage
| HumanMessage
| FailureMessage
| RouterMessage

export enum AssistantEventType {
Status = 'status',
Message = 'message',
Conversation = 'conversation',
}

export enum AssistantGenerationStatusType {
Acknowledged = 'ack',
GenerationError = 'generation_error',
}

export interface AssistantGenerationStatusEvent {
type: AssistantGenerationStatusType
}
Loading
Loading