From 8f05df9d02826b9ccec94c1aaa2f0b9c7e511111 Mon Sep 17 00:00:00 2001 From: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Date: Wed, 21 Jan 2026 14:23:58 +0800 Subject: [PATCH] update --- .../settings-modal/retrieval-section.spec.tsx | 3 +- .../documents/components/documents-header.tsx | 2 +- .../api-based-extension-page/modal.tsx | 2 +- web/scripts/gen-doc-paths.ts | 58 ++----------------- 4 files changed, 9 insertions(+), 56 deletions(-) diff --git a/web/app/components/app/configuration/dataset-config/settings-modal/retrieval-section.spec.tsx b/web/app/components/app/configuration/dataset-config/settings-modal/retrieval-section.spec.tsx index b7ab560d91..f7d3347419 100644 --- a/web/app/components/app/configuration/dataset-config/settings-modal/retrieval-section.spec.tsx +++ b/web/app/components/app/configuration/dataset-config/settings-modal/retrieval-section.spec.tsx @@ -1,5 +1,6 @@ import type { DataSet } from '@/models/datasets' import type { RetrievalConfig } from '@/types/app' +import type { DocPathWithoutLang } from '@/types/doc-paths' import { render, screen } from '@testing-library/react' import userEvent from '@testing-library/user-event' import { IndexingType } from '@/app/components/datasets/create/step-two' @@ -237,7 +238,7 @@ describe('RetrievalSection', () => { retrievalConfig={retrievalConfig} showMultiModalTip onRetrievalConfigChange={vi.fn()} - docLink={docLink as any} + docLink={docLink as unknown as (path?: DocPathWithoutLang) => string} />, ) diff --git a/web/app/components/datasets/documents/components/documents-header.tsx b/web/app/components/datasets/documents/components/documents-header.tsx index ed97742fdd..d0e2af69d4 100644 --- a/web/app/components/datasets/documents/components/documents-header.tsx +++ b/web/app/components/datasets/documents/components/documents-header.tsx @@ -121,7 +121,7 @@ const DocumentsHeader: FC = ({ className="flex items-center text-text-accent" target="_blank" rel="noopener noreferrer" - href={docLink('/guides/knowledge-base/integrate-knowledge-within-application')} + href={docLink('/use-dify/getting-started/introduction')} > {t('list.learnMore', { ns: 'datasetDocuments' })} diff --git a/web/app/components/header/account-setting/api-based-extension-page/modal.tsx b/web/app/components/header/account-setting/api-based-extension-page/modal.tsx index d3146d7baa..49f848c3f5 100644 --- a/web/app/components/header/account-setting/api-based-extension-page/modal.tsx +++ b/web/app/components/header/account-setting/api-based-extension-page/modal.tsx @@ -102,7 +102,7 @@ const ApiBasedExtensionModal: FC = ({
{t('apiBasedExtension.modal.apiEndpoint.title', { ns: 'common' })} } */', - 'export const docRedirects = new Map([', - ] - - // Use a map to deduplicate paths (same path in different languages) - const pathMap = new Map() - const langPrefixRegex = /^\/(en|zh|ja|zh-hans|ja-jp)\// - - for (const redirect of redirects) { - // Skip wildcard redirects - if (redirect.source.includes(':slug')) - continue - - // Strip language prefix from source and destination - const sourceWithoutLang = redirect.source.replace(langPrefixRegex, '') - const destWithoutLang = redirect.destination.replace(langPrefixRegex, '') - - // Only add if we haven't seen this path yet - if (!pathMap.has(sourceWithoutLang)) - pathMap.set(sourceWithoutLang, destWithoutLang) - } - - for (const [source, dest] of pathMap) { - lines.push(` ['${source}', '${dest}'],`) - } - - lines.push('])') - lines.push('') - - return lines.join('\n') -} - async function main(): Promise { - // eslint-disable-next-line no-console console.log('Fetching docs.json from GitHub...') const response = await fetch(DOCS_JSON_URL) @@ -391,18 +346,16 @@ async function main(): Promise { throw new Error(`Failed to fetch docs.json: ${response.status} ${response.statusText}`) const docsJson = await response.json() as DocsJson - // eslint-disable-next-line no-console console.log('Successfully fetched docs.json') // Extract paths from navigation const allPaths = extractPaths(docsJson.navigation) - // eslint-disable-next-line no-console console.log(`Found ${allPaths.size} total paths`) // Extract OpenAPI file paths from navigation for all languages const openApiPaths = extractOpenAPIPaths(docsJson.navigation) - // eslint-disable-next-line no-console + console.log(`Found ${openApiPaths.size} OpenAPI specs to process`) // Fetch OpenAPI specs and extract API reference paths with endpoint keys @@ -423,7 +376,6 @@ async function main(): Promise { // Get file name without language prefix (e.g., "api-reference/openapi_knowledge.json") const fileKey = openapiPath.replace(/^(en|zh|ja)\//, '') - // eslint-disable-next-line no-console console.log(`Fetching OpenAPI spec: ${openapiPath}`) const pathMap = await fetchOpenAPIAndExtractPaths(openapiPath) endpointMapsByLang[lang].set(fileKey, pathMap) @@ -456,14 +408,14 @@ async function main(): Promise { // Deduplicate English API paths const uniqueEnApiPaths = [...new Set(enApiPaths)] - // eslint-disable-next-line no-console + console.log(`Extracted ${uniqueEnApiPaths.length} unique English API reference paths`) - // eslint-disable-next-line no-console + console.log(`Generated ${Object.keys(apiPathTranslations).length} API path translations`) // Group by section const groups = groupPathsBySection(allPaths) - // eslint-disable-next-line no-console + console.log(`Grouped into ${Object.keys(groups).length} sections:`, Object.keys(groups)) // Generate TypeScript @@ -471,7 +423,7 @@ async function main(): Promise { // Write to file await writeFile(OUTPUT_PATH, tsContent, 'utf-8') - // eslint-disable-next-line no-console + console.log(`Generated TypeScript types at: ${OUTPUT_PATH}`) }