feat: Enhance wiki API and repository with slug encoding and improved search functionality

- Introduced `encodeSlugPath` function to safely encode wiki slugs for API requests, preserving hierarchical routing.
- Updated API functions to utilize the new slug encoding for `getWikiPage`, `updateWikiPage`, and `deleteWikiPage`.
- Enhanced `ListBySourceRef` method in the repository to safely handle source knowledge IDs with JSON marshalling, improving query security.
- Added `escapeLikePattern` function to ensure safe concatenation of LIKE patterns in SQL queries, preventing unintended matches.
- Updated `KnowledgePostProcessService` to include Redis client for task management, improving performance in handling wiki ingest tasks.
- Enhanced `WikiLintIssue` structure to include `TargetSlug` for better issue tracking and auto-fixing capabilities.

These changes significantly improve the robustness and security of the wiki management system, enhancing user experience and data integrity.
This commit is contained in:
wizardchen
2026-04-17 21:16:35 +08:00
parent 84edfa5439
commit 99cc721140
8 changed files with 104 additions and 43 deletions
@@ -1,9 +1,9 @@
-- Migration: 000032_wiki_pages (rollback)
-- Migration: 000036_wiki_pages (rollback)
-- Description: Remove wiki_pages table and wiki_config column from knowledge_bases.
DO $$ BEGIN RAISE NOTICE '[Migration 000032] Removing wiki_pages table and wiki_config column'; END $$;
DO $$ BEGIN RAISE NOTICE '[Migration 000036] Removing wiki_pages table and wiki_config column'; END $$;
DROP TABLE IF EXISTS wiki_pages;
ALTER TABLE knowledge_bases DROP COLUMN IF EXISTS wiki_config;
DO $$ BEGIN RAISE NOTICE '[Migration 000032] wiki_pages table and wiki_config column removed successfully'; END $$;
DO $$ BEGIN RAISE NOTICE '[Migration 000036] wiki_pages table and wiki_config column removed successfully'; END $$;
@@ -1,7 +1,7 @@
-- Migration: 000032_wiki_pages
-- Migration: 000036_wiki_pages
-- Description: Add wiki_pages table and wiki_config column to knowledge_bases.
-- Wiki pages are LLM-generated, interlinked markdown documents that form a persistent wiki.
DO $$ BEGIN RAISE NOTICE '[Migration 000032] Creating wiki_pages table and adding wiki_config column'; END $$;
DO $$ BEGIN RAISE NOTICE '[Migration 000036] Creating wiki_pages table and adding wiki_config column'; END $$;
-- Add wiki_config column to knowledge_bases
ALTER TABLE knowledge_bases ADD COLUMN IF NOT EXISTS wiki_config JSONB;
@@ -55,4 +55,4 @@ CREATE INDEX IF NOT EXISTS idx_wiki_pages_deleted_at
CREATE INDEX IF NOT EXISTS idx_wiki_pages_fulltext
ON wiki_pages USING GIN (to_tsvector('simple', coalesce(title, '') || ' ' || coalesce(content, '')));
DO $$ BEGIN RAISE NOTICE '[Migration 000032] wiki_pages table and wiki_config column created successfully'; END $$;
DO $$ BEGIN RAISE NOTICE '[Migration 000036] wiki_pages table and wiki_config column created successfully'; END $$;