From 8ca54ddf94b0affce41f8e850cc61a7362fba5b1 Mon Sep 17 00:00:00 2001 From: Mahmoud Hamdy <148990144+mahmoodhamdi@users.noreply.github.com> Date: Thu, 26 Mar 2026 09:50:54 +0200 Subject: [PATCH] refactor(web): convert 7 enums to as-const objects (batch 5) (#33960) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- .../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 | 28 ------------------- web/eslint.config.mjs | 1 + web/types/model-provider.ts | 19 +++++++------ web/types/workflow.ts | 13 +++++---- 9 files changed, 48 insertions(+), 68 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 6117855b3b8..b1213917e4c 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 ac5ca3ced23..d129487fe16 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 ad68bd0f108..e8a18589fd8 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 af939d41ead..893c477d041 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) && (