constant.ts


Overview

The constant.ts file serves as a centralized module for defining and exporting constant values and enumerations related to routing keys within a knowledge management or knowledge base system. Its main purpose is to provide a consistent mapping between route keys (likely used internally in the application routing logic) and their corresponding human-readable labels. This facilitates easy referencing, localization, and maintainability of route-related constants throughout the application.

This file exports:


Detailed Explanation of Contents

1. routeMap

export const routeMap = {
  [KnowledgeRouteKey.Dataset]: 'Dataset',
  [KnowledgeRouteKey.Testing]: 'Retrieval testing',
  [KnowledgeRouteKey.Configuration]: 'Configuration',
};

Example Usage:

import { routeMap } from './constant';
import { KnowledgeRouteKey } from '@/constants/knowledge';

const currentRoute = KnowledgeRouteKey.Dataset;
console.log(routeMap[currentRoute]);  // Output: "Dataset"

2. KnowledgeDatasetRouteKey (Enum)

export enum KnowledgeDatasetRouteKey {
  Chunk = 'chunk',
  File = 'file',
}

Example Usage:

function navigateToDatasetRoute(route: KnowledgeDatasetRouteKey) {
  console.log(`Navigating to dataset route: ${route}`);
}

navigateToDatasetRoute(KnowledgeDatasetRouteKey.File);  // "Navigating to dataset route: file"

3. datasetRouteMap

export const datasetRouteMap = {
  [KnowledgeDatasetRouteKey.Chunk]: 'Chunk',
  [KnowledgeDatasetRouteKey.File]: 'File Upload',
};

Example Usage:

console.log(datasetRouteMap[KnowledgeDatasetRouteKey.Chunk]);  // Output: "Chunk"
console.log(datasetRouteMap[KnowledgeDatasetRouteKey.File]);   // Output: "File Upload"

4. TagRenameId

export const TagRenameId = 'tagRename';

5. Re-export from @/constants/knowledge

export * from '@/constants/knowledge';

Implementation Details


Integration with Other System Parts


Visual Diagram

flowchart TD
    A[constant.ts] --> B[routeMap]
    A --> C[KnowledgeDatasetRouteKey Enum]
    A --> D[datasetRouteMap]
    A --> E[TagRenameId Constant]
    A --> F[Re-export all from '@/constants/knowledge']

    B -->|Uses keys| G[KnowledgeRouteKey (imported)]
    D -->|Uses keys| C

Summary

The constant.ts file is a lightweight, utility-focused module that centralizes string constants and enumerations related to knowledge system routing. Its main value lies in providing clear mappings from internal route keys to user-friendly names, enabling consistent UI rendering and reducing duplication of string literals. It also re-exports the broader knowledge constants to serve as a single entry point for related route keys and identifiers.