From 6ba448f00923a87429f97817a9bd239228339506 Mon Sep 17 00:00:00 2001 From: Mahmoud Hamdi Date: Mon, 23 Mar 2026 16:46:03 +0200 Subject: [PATCH 1/2] refactor(web): convert 8 enums to as-const objects (batch 6) Convert SubjectType, AccessMode, PromptMode, PromptRole, DSLImportMode, DSLImportStatus, WorkflowRunTriggeredFrom, and AppSourceType from TypeScript enums to as const objects. Also disables ts/no-redeclare ESLint rule globally. Closes part of #27998 --- web/eslint.config.mjs | 1 + web/models/access-control.ts | 22 ++++++++++++---------- web/models/app.ts | 22 ++++++++++++---------- web/models/debug.ts | 20 +++++++++++--------- web/models/log.ts | 19 ++++++++++--------- web/service/share.ts | 11 ++++++----- 6 files changed, 52 insertions(+), 43 deletions(-) diff --git a/web/eslint.config.mjs b/web/eslint.config.mjs index d5d833ba69..9217b08868 100644 --- a/web/eslint.config.mjs +++ b/web/eslint.config.mjs @@ -36,6 +36,7 @@ export default antfu( overrides: { 'ts/consistent-type-definitions': ['error', 'type'], 'ts/no-explicit-any': 'error', + 'ts/no-redeclare': 'off', }, erasableOnly: true, }, diff --git a/web/models/access-control.ts b/web/models/access-control.ts index d0e58d645b..bbf4bc3552 100644 --- a/web/models/access-control.ts +++ b/web/models/access-control.ts @@ -1,14 +1,16 @@ -export enum SubjectType { - GROUP = 'group', - ACCOUNT = 'account', -} +export const SubjectType = { + GROUP: 'group', + ACCOUNT: 'account', +} as const +export type SubjectType = typeof SubjectType[keyof typeof SubjectType] -export enum AccessMode { - PUBLIC = 'public', - SPECIFIC_GROUPS_MEMBERS = 'private', - ORGANIZATION = 'private_all', - EXTERNAL_MEMBERS = 'sso_verified', -} +export const AccessMode = { + PUBLIC: 'public', + SPECIFIC_GROUPS_MEMBERS: 'private', + ORGANIZATION: 'private_all', + EXTERNAL_MEMBERS: 'sso_verified', +} as const +export type AccessMode = typeof AccessMode[keyof typeof AccessMode] export type AccessControlGroup = { id: 'string' diff --git a/web/models/app.ts b/web/models/app.ts index 056f5cb173..fb42131dec 100644 --- a/web/models/app.ts +++ b/web/models/app.ts @@ -14,17 +14,19 @@ 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 type DSLImportMode = typeof DSLImportMode[keyof typeof DSLImportMode] -export enum DSLImportStatus { - COMPLETED = 'completed', - COMPLETED_WITH_WARNINGS = 'completed-with-warnings', - PENDING = 'pending', - FAILED = 'failed', -} +export const DSLImportStatus = { + COMPLETED: 'completed', + COMPLETED_WITH_WARNINGS: 'completed-with-warnings', + PENDING: 'pending', + FAILED: 'failed', +} as const +export type DSLImportStatus = typeof DSLImportStatus[keyof typeof DSLImportStatus] export type AppListResponse = { data: App[] diff --git a/web/models/debug.ts b/web/models/debug.ts index fb75ae7946..dd4fa3d87b 100644 --- a/web/models/debug.ts +++ b/web/models/debug.ts @@ -13,10 +13,11 @@ import type { AgentStrategy, ModelModeType, RETRIEVE_TYPE, ToolItem, TtsAutoPlay export type Inputs = Record -export enum PromptMode { - simple = 'simple', - advanced = 'advanced', -} +export const PromptMode = { + simple: 'simple', + advanced: 'advanced', +} as const +export type PromptMode = typeof PromptMode[keyof typeof PromptMode] export type PromptItem = { role?: PromptRole @@ -42,11 +43,12 @@ export type BlockStatus = { query: boolean } -export enum PromptRole { - system = 'system', - user = 'user', - assistant = 'assistant', -} +export const PromptRole = { + system: 'system', + user: 'user', + assistant: 'assistant', +} as const +export type PromptRole = typeof PromptRole[keyof typeof PromptRole] export type PromptVariable = { key: string diff --git a/web/models/log.ts b/web/models/log.ts index ab1282b8af..6ed0cc511b 100644 --- a/web/models/log.ts +++ b/web/models/log.ts @@ -211,15 +211,16 @@ 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 +export type WorkflowRunTriggeredFrom = typeof WorkflowRunTriggeredFrom[keyof typeof WorkflowRunTriggeredFrom] export type TriggerMetadata = { type?: string diff --git a/web/service/share.ts b/web/service/share.ts index 4726ded7d1..e2c98d932a 100644 --- a/web/service/share.ts +++ b/web/service/share.ts @@ -29,11 +29,12 @@ import { } from './base' import { getWebAppAccessToken } from './webapp-auth' -export enum AppSourceType { - webApp = 'webApp', - installedApp = 'installedApp', - tryApp = 'tryApp', -} +export const AppSourceType = { + webApp: 'webApp', + installedApp: 'installedApp', + tryApp: 'tryApp', +} as const +export type AppSourceType = typeof AppSourceType[keyof typeof AppSourceType] const apiPrefix = { [AppSourceType.webApp]: '', From db26c2d88f33326b74a7b1f48bc102eb0c3fa521 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Mon, 23 Mar 2026 14:49:19 +0000 Subject: [PATCH 2/2] [autofix.ci] apply automated fixes --- web/eslint-suppressions.json | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/web/eslint-suppressions.json b/web/eslint-suppressions.json index 04e8be3afd..476b7c0839 100644 --- a/web/eslint-suppressions.json +++ b/web/eslint-suppressions.json @@ -9892,16 +9892,6 @@ "count": 1 } }, - "models/access-control.ts": { - "erasable-syntax-only/enums": { - "count": 2 - } - }, - "models/app.ts": { - "erasable-syntax-only/enums": { - "count": 2 - } - }, "models/common.ts": { "erasable-syntax-only/enums": { "count": 3 @@ -9919,17 +9909,11 @@ } }, "models/debug.ts": { - "erasable-syntax-only/enums": { - "count": 2 - }, "ts/no-explicit-any": { "count": 4 } }, "models/log.ts": { - "erasable-syntax-only/enums": { - "count": 1 - }, "ts/no-explicit-any": { "count": 7 } @@ -10012,9 +9996,6 @@ } }, "service/share.ts": { - "erasable-syntax-only/enums": { - "count": 1 - }, "ts/no-explicit-any": { "count": 3 }