From 7fdf7e174d12461456da5ae84124994ef53e4c97 Mon Sep 17 00:00:00 2001 From: Mahmoud Hamdi Date: Mon, 23 Mar 2026 16:10:33 +0200 Subject: [PATCH 1/2] refactor(web): convert 7 enums to as-const objects (batch 5) Convert ModelProviderQuotaGetPaid, VarInInspectType, TestRunStep, QAItemType, NoteTheme, ViewMode, and PreviewType from TypeScript enums to as-const objects with companion type aliases. Partially addresses #27998. --- .../components/chunk-card-list/types.ts | 9 +++--- .../components/panel/test-run/types.ts | 9 +++--- .../components/workflow/note-node/types.ts | 17 ++++++----- .../workflow/variable-inspect/right.tsx | 2 +- .../workflow/variable-inspect/types.ts | 18 ++++++----- web/eslint-suppressions.json | 30 +------------------ web/eslint.config.mjs | 1 + web/types/model-provider.ts | 19 ++++++------ web/types/workflow.ts | 13 ++++---- 9 files changed, 49 insertions(+), 69 deletions(-) diff --git a/web/app/components/rag-pipeline/components/chunk-card-list/types.ts b/web/app/components/rag-pipeline/components/chunk-card-list/types.ts index 6117855b3b..b1213917e4 100644 --- a/web/app/components/rag-pipeline/components/chunk-card-list/types.ts +++ b/web/app/components/rag-pipeline/components/chunk-card-list/types.ts @@ -26,7 +26,8 @@ export type QAChunks = { export type ChunkInfo = GeneralChunks | ParentChildChunks | QAChunks -export enum QAItemType { - Question = 'question', - Answer = 'answer', -} +export const QAItemType = { + Question: 'question', + Answer: 'answer', +} as const +export type QAItemType = typeof QAItemType[keyof typeof QAItemType] diff --git a/web/app/components/rag-pipeline/components/panel/test-run/types.ts b/web/app/components/rag-pipeline/components/panel/test-run/types.ts index ac5ca3ced2..d129487fe1 100644 --- a/web/app/components/rag-pipeline/components/panel/test-run/types.ts +++ b/web/app/components/rag-pipeline/components/panel/test-run/types.ts @@ -1,9 +1,10 @@ import type { DataSourceNodeType } from '@/app/components/workflow/nodes/data-source/types' -export enum TestRunStep { - dataSource = 'dataSource', - documentProcessing = 'documentProcessing', -} +export const TestRunStep = { + dataSource: 'dataSource', + documentProcessing: 'documentProcessing', +} as const +export type TestRunStep = typeof TestRunStep[keyof typeof TestRunStep] export type DataSourceOption = { label: string diff --git a/web/app/components/workflow/note-node/types.ts b/web/app/components/workflow/note-node/types.ts index ad68bd0f10..e8a18589fd 100644 --- a/web/app/components/workflow/note-node/types.ts +++ b/web/app/components/workflow/note-node/types.ts @@ -1,13 +1,14 @@ import type { CommonNodeType } from '../types' -export enum NoteTheme { - blue = 'blue', - cyan = 'cyan', - green = 'green', - yellow = 'yellow', - pink = 'pink', - violet = 'violet', -} +export const NoteTheme = { + blue: 'blue', + cyan: 'cyan', + green: 'green', + yellow: 'yellow', + pink: 'pink', + violet: 'violet', +} as const +export type NoteTheme = typeof NoteTheme[keyof typeof NoteTheme] export type NoteNodeType = CommonNodeType & { text: string diff --git a/web/app/components/workflow/variable-inspect/right.tsx b/web/app/components/workflow/variable-inspect/right.tsx index af939d41ea..893c477d04 100644 --- a/web/app/components/workflow/variable-inspect/right.tsx +++ b/web/app/components/workflow/variable-inspect/right.tsx @@ -174,7 +174,7 @@ const Right = ({ {currentNodeVar?.var && ( <> { - [VarInInspectType.environment, VarInInspectType.conversation, VarInInspectType.system].includes(currentNodeVar.nodeType as VarInInspectType) && ( + ([VarInInspectType.environment, VarInInspectType.conversation, VarInInspectType.system] as VarInInspectType[]).includes(currentNodeVar.nodeType as VarInInspectType) && ( Date: Mon, 23 Mar 2026 14:13:59 +0000 Subject: [PATCH 2/2] [autofix.ci] apply automated fixes --- web/eslint-suppressions.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/eslint-suppressions.json b/web/eslint-suppressions.json index 78dec8c288..ac293c6050 100644 --- a/web/eslint-suppressions.json +++ b/web/eslint-suppressions.json @@ -10188,4 +10188,4 @@ "count": 2 } } -} +} \ No newline at end of file