Implementation:Langgenius Dify Doc Paths Types
| Knowledge Sources | |
|---|---|
| Domains | Frontend, TypeSystem, Documentation |
| Last Updated | 2026-02-12 07:00 GMT |
Overview
Auto-generated TypeScript type declarations that provide compile-time type safety for all Dify documentation paths and API reference translations.
Description
web/types/doc-paths.ts is an auto-generated file (generated from the Dify docs JSON at https://raw.githubusercontent.com/langgenius/dify-docs/refs/heads/main/docs.json, generated on 2026-01-30). It defines string literal union types for every valid documentation path in the Dify docs system.
The file exports the following types:
DocLanguage: Union of supported documentation languages:'en' | 'zh' | 'ja'.UseDifyPath: String literal union of all documentation paths under/use-dify/, covering build, debug, getting-started, knowledge, monitor, nodes, publish, tutorials, and workspace sections (~100 paths).UseDifyNodesPath: Extracted subtype usingExtractNodesPathutility type, providing just the node-specific path suffixes.SelfHostPath: Paths for self-hosting documentation (advanced deployments, configuration, platform guides, troubleshooting).DevelopPluginPath: Paths for plugin development guides, feature specs, and publishing documentation.ApiReferencePath: Paths for API reference documentation (annotations, application, chat, chatflow, chunks, completion, conversations, datasets, documents, feedback, files, metadata/tags, models, TTS, workflow execution).DocPathWithoutLangBase: Combined union of all path types.DocPathWithoutLang: Extends the base with optional#anchorsuffix support.DifyDocPath: Full path with language prefix:${DocLanguage}/${DocPathWithoutLang}.apiReferencePathTranslations: Runtime constant mapping English API reference paths to their Chinese (zh) and Japanese (ja) translated path equivalents.
Usage
Import these types to create type-safe links to Dify documentation throughout the frontend. The types prevent broken links by catching invalid paths at compile time.
Code Reference
Source Location
- Repository: Langgenius_Dify
- File: web/types/doc-paths.ts
- Lines: 1-320
Signature
export type DocLanguage = 'en' | 'zh' | 'ja'
export type UseDifyPath =
| '/use-dify/build/additional-features'
| '/use-dify/build/goto-anything'
// ...~100 paths
type ExtractNodesPath<T> = T extends `/use-dify/nodes/${infer Path}` ? Path : never
export type UseDifyNodesPath = ExtractNodesPath<UseDifyPath>
export type SelfHostPath = '/self-host/advanced-deployments/local-source-code' | ...
export type DevelopPluginPath = '/develop-plugin/dev-guides-and-walkthroughs/agent-strategy-plugin' | ...
export type ApiReferencePath = '/api-reference/annotations/create-annotation' | ...
export type DocPathWithoutLangBase = UseDifyPath | SelfHostPath | DevelopPluginPath | ApiReferencePath
export type DocPathWithoutLang = DocPathWithoutLangBase | `${DocPathWithoutLangBase}#${string}`
export type DifyDocPath = `${DocLanguage}/${DocPathWithoutLang}`
export const apiReferencePathTranslations: Record<string, { zh?: string; ja?: string }>
Import
import type { DifyDocPath, DocLanguage, UseDifyNodesPath } from '@/types/doc-paths'
import { apiReferencePathTranslations } from '@/types/doc-paths'
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| N/A | N/A | N/A | Auto-generated type declarations; no runtime inputs. |
Outputs
| Name | Type | Description |
|---|---|---|
| DocLanguage | type | Supported documentation languages |
| UseDifyPath | type | All valid /use-dify/ doc paths |
| UseDifyNodesPath | type | Node-specific path suffixes |
| SelfHostPath | type | Self-hosting documentation paths |
| DevelopPluginPath | type | Plugin development documentation paths |
| ApiReferencePath | type | API reference documentation paths |
| DifyDocPath | type | Full path with language prefix |
| apiReferencePathTranslations | const | Runtime map of English API paths to zh/ja translations |
Usage Examples
Type-safe Documentation Link
import type { DifyDocPath } from '@/types/doc-paths'
function getDocUrl(path: DifyDocPath): string {
return `https://docs.dify.ai/${path}`
}
// Compile-time valid:
getDocUrl('en/use-dify/getting-started/introduction')
// Compile-time error:
// getDocUrl('en/invalid/path')