refactor(web): replace enums with as const objects (batch 3)

Convert 6 enums in models/ and types/ to as-const objects per issue #27998:
- DSLImportMode (models/app.ts)
- DSLImportStatus (models/app.ts)
- WorkflowRunTriggeredFrom (models/log.ts)
- ProviderName (models/common.ts)
- DataSourceCategory (models/common.ts)
- AgentStrategy (types/app.ts)
This commit is contained in:
Mahmoud Hamdi 2026-03-15 16:13:29 +02:00
parent f5cc1c8b75
commit 7a87c08c4d
4 changed files with 57 additions and 37 deletions

View File

@ -14,17 +14,23 @@ import type {
import type { Dependency } from '@/app/components/plugins/types'
import type { App, AppModeEnum, AppTemplate, SiteConfig } from '@/types/app'
export enum DSLImportMode {
YAML_CONTENT = 'yaml-content',
YAML_URL = 'yaml-url',
}
export const DSLImportMode = {
YAML_CONTENT: 'yaml-content',
YAML_URL: 'yaml-url',
} as const
export enum DSLImportStatus {
COMPLETED = 'completed',
COMPLETED_WITH_WARNINGS = 'completed-with-warnings',
PENDING = 'pending',
FAILED = 'failed',
}
// eslint-disable-next-line ts/no-redeclare -- value-type pair
export type DSLImportMode = typeof DSLImportMode[keyof typeof DSLImportMode]
export const DSLImportStatus = {
COMPLETED: 'completed',
COMPLETED_WITH_WARNINGS: 'completed-with-warnings',
PENDING: 'pending',
FAILED: 'failed',
} as const
// eslint-disable-next-line ts/no-redeclare -- value-type pair
export type DSLImportStatus = typeof DSLImportStatus[keyof typeof DSLImportStatus]
export type AppListResponse = {
data: App[]

View File

@ -82,17 +82,21 @@ export type Member = Pick<UserProfileResponse, 'id' | 'name' | 'email' | 'last_l
role: 'owner' | 'admin' | 'editor' | 'normal' | 'dataset_operator'
}
export enum ProviderName {
OPENAI = 'openai',
AZURE_OPENAI = 'azure_openai',
ANTHROPIC = 'anthropic',
Replicate = 'replicate',
HuggingfaceHub = 'huggingface_hub',
MiniMax = 'minimax',
Spark = 'spark',
Tongyi = 'tongyi',
ChatGLM = 'chatglm',
}
export const ProviderName = {
OPENAI: 'openai',
AZURE_OPENAI: 'azure_openai',
ANTHROPIC: 'anthropic',
Replicate: 'replicate',
HuggingfaceHub: 'huggingface_hub',
MiniMax: 'minimax',
Spark: 'spark',
Tongyi: 'tongyi',
ChatGLM: 'chatglm',
} as const
// eslint-disable-next-line ts/no-redeclare -- value-type pair
export type ProviderName = typeof ProviderName[keyof typeof ProviderName]
export type ProviderAzureToken = {
openai_api_base?: string
openai_api_key?: string
@ -188,9 +192,13 @@ export type DataSourceNotion = {
source_info: DataSourceNotionWorkspace
}
export enum DataSourceCategory {
website = 'website',
}
export const DataSourceCategory = {
website: 'website',
} as const
// eslint-disable-next-line ts/no-redeclare -- value-type pair
export type DataSourceCategory = typeof DataSourceCategory[keyof typeof DataSourceCategory]
export enum DataSourceProvider {
fireCrawl = 'firecrawl',
jinaReader = 'jinareader',

View File

@ -211,15 +211,18 @@ export type AnnotationsCountResponse = {
count: number
}
export enum WorkflowRunTriggeredFrom {
DEBUGGING = 'debugging',
APP_RUN = 'app-run',
RAG_PIPELINE_RUN = 'rag-pipeline-run',
RAG_PIPELINE_DEBUGGING = 'rag-pipeline-debugging',
WEBHOOK = 'webhook',
SCHEDULE = 'schedule',
PLUGIN = 'plugin',
}
export const WorkflowRunTriggeredFrom = {
DEBUGGING: 'debugging',
APP_RUN: 'app-run',
RAG_PIPELINE_RUN: 'rag-pipeline-run',
RAG_PIPELINE_DEBUGGING: 'rag-pipeline-debugging',
WEBHOOK: 'webhook',
SCHEDULE: 'schedule',
PLUGIN: 'plugin',
} as const
// eslint-disable-next-line ts/no-redeclare -- value-type pair
export type WorkflowRunTriggeredFrom = typeof WorkflowRunTriggeredFrom[keyof typeof WorkflowRunTriggeredFrom]
export type TriggerMetadata = {
type?: string

View File

@ -145,10 +145,13 @@ export type ToolItem = {
}
} | AgentTool
export enum AgentStrategy {
functionCall = 'function_call',
react = 'react',
}
export const AgentStrategy = {
functionCall: 'function_call',
react: 'react',
} as const
// eslint-disable-next-line ts/no-redeclare -- value-type pair
export type AgentStrategy = typeof AgentStrategy[keyof typeof AgentStrategy]
export type CompletionParams = {
/** Maximum number of tokens in the answer message returned by Completion */