mirror of https://github.com/langgenius/dify.git
refactor(web): convert 6 enums to as-const objects (batch 4)
Convert enum declarations to `as const` objects with companion type aliases per issue #27998, improving tree-shaking and enabling literal type inference. Files changed: - web/app/components/workflow/types.ts: ControlMode, ErrorHandleMode - web/models/datasets.ts: DatasetPermission, WeightedScoreEnum, RerankingModeEnum, DocumentActionType
This commit is contained in:
parent
f5cc1c8b75
commit
13aae3963e
|
|
@ -58,15 +58,21 @@ export enum BlockEnum {
|
|||
TriggerPlugin = 'trigger-plugin',
|
||||
}
|
||||
|
||||
export enum ControlMode {
|
||||
Pointer = 'pointer',
|
||||
Hand = 'hand',
|
||||
}
|
||||
export enum ErrorHandleMode {
|
||||
Terminated = 'terminated',
|
||||
ContinueOnError = 'continue-on-error',
|
||||
RemoveAbnormalOutput = 'remove-abnormal-output',
|
||||
}
|
||||
export const ControlMode = {
|
||||
Pointer: 'pointer',
|
||||
Hand: 'hand',
|
||||
} as const
|
||||
|
||||
// eslint-disable-next-line ts/no-redeclare -- value-type pair
|
||||
export type ControlMode = typeof ControlMode[keyof typeof ControlMode]
|
||||
export const ErrorHandleMode = {
|
||||
Terminated: 'terminated',
|
||||
ContinueOnError: 'continue-on-error',
|
||||
RemoveAbnormalOutput: 'remove-abnormal-output',
|
||||
} as const
|
||||
|
||||
// eslint-disable-next-line ts/no-redeclare -- value-type pair
|
||||
export type ErrorHandleMode = typeof ErrorHandleMode[keyof typeof ErrorHandleMode]
|
||||
export type Branch = {
|
||||
id: string
|
||||
name: string
|
||||
|
|
|
|||
|
|
@ -15,11 +15,14 @@ export enum DataSourceType {
|
|||
WEB = 'website_crawl',
|
||||
}
|
||||
|
||||
export enum DatasetPermission {
|
||||
onlyMe = 'only_me',
|
||||
allTeamMembers = 'all_team_members',
|
||||
partialMembers = 'partial_members',
|
||||
}
|
||||
export const DatasetPermission = {
|
||||
onlyMe: 'only_me',
|
||||
allTeamMembers: 'all_team_members',
|
||||
partialMembers: 'partial_members',
|
||||
} as const
|
||||
|
||||
// eslint-disable-next-line ts/no-redeclare -- value-type pair
|
||||
export type DatasetPermission = typeof DatasetPermission[keyof typeof DatasetPermission]
|
||||
|
||||
export enum ChunkingMode {
|
||||
text = 'text_model', // General text
|
||||
|
|
@ -734,16 +737,22 @@ export type SelectedDatasetsMode = {
|
|||
inconsistentEmbeddingModel: boolean
|
||||
}
|
||||
|
||||
export enum WeightedScoreEnum {
|
||||
SemanticFirst = 'semantic_first',
|
||||
KeywordFirst = 'keyword_first',
|
||||
Customized = 'customized',
|
||||
}
|
||||
export const WeightedScoreEnum = {
|
||||
SemanticFirst: 'semantic_first',
|
||||
KeywordFirst: 'keyword_first',
|
||||
Customized: 'customized',
|
||||
} as const
|
||||
|
||||
export enum RerankingModeEnum {
|
||||
RerankingModel = 'reranking_model',
|
||||
WeightedScore = 'weighted_score',
|
||||
}
|
||||
// eslint-disable-next-line ts/no-redeclare -- value-type pair
|
||||
export type WeightedScoreEnum = typeof WeightedScoreEnum[keyof typeof WeightedScoreEnum]
|
||||
|
||||
export const RerankingModeEnum = {
|
||||
RerankingModel: 'reranking_model',
|
||||
WeightedScore: 'weighted_score',
|
||||
} as const
|
||||
|
||||
// eslint-disable-next-line ts/no-redeclare -- value-type pair
|
||||
export type RerankingModeEnum = typeof RerankingModeEnum[keyof typeof RerankingModeEnum]
|
||||
|
||||
export const DEFAULT_WEIGHTED_SCORE = {
|
||||
allHighQualityVectorSearch: {
|
||||
|
|
@ -787,14 +796,17 @@ export type UpdateDocumentParams = {
|
|||
}
|
||||
|
||||
// Used in api url
|
||||
export enum DocumentActionType {
|
||||
enable = 'enable',
|
||||
disable = 'disable',
|
||||
archive = 'archive',
|
||||
unArchive = 'un_archive',
|
||||
delete = 'delete',
|
||||
summary = 'summary',
|
||||
}
|
||||
export const DocumentActionType = {
|
||||
enable: 'enable',
|
||||
disable: 'disable',
|
||||
archive: 'archive',
|
||||
unArchive: 'un_archive',
|
||||
delete: 'delete',
|
||||
summary: 'summary',
|
||||
} as const
|
||||
|
||||
// eslint-disable-next-line ts/no-redeclare -- value-type pair
|
||||
export type DocumentActionType = typeof DocumentActionType[keyof typeof DocumentActionType]
|
||||
|
||||
export type UpdateDocumentBatchParams = {
|
||||
datasetId: string
|
||||
|
|
|
|||
Loading…
Reference in New Issue