feat(api): 数据源统一列举与添加前校验
build / build (push) Failing after 16s

GET /source-catalog/available 四类同一形状(wiki/drive/doc/pp),类型差异只放在 content_type;
POST /source-catalog/validate 真读一次:文档表格校验可读、知识库钉盘校验账号仍可见,失败不让添加。
This commit is contained in:
hermes
2026-10-26 17:22:09 +08:00
parent b3992bfa0f
commit 017cbcb851
5 changed files with 423 additions and 2 deletions
+10
View File
@@ -37,6 +37,15 @@ func (dingtalkSourceLister) ListAvailableDingtalkSources(ctx context.Context) (d
return dingtalkdiscovery.Discover(ctx, dingtalkdiscovery.ExecRunner{})
}
// 同一份 dws 凭据也用来列在线文档/表格并校验可读。
func (dingtalkSourceLister) ListDingtalkDocuments(ctx context.Context, query string, limit int) (dingtalkdiscovery.DocResult, error) {
return dingtalkdiscovery.DiscoverDocs(ctx, dingtalkdiscovery.ExecRunner{}, query, limit)
}
func (dingtalkSourceLister) ValidateDingtalkDocument(ctx context.Context, node string) (dingtalkdiscovery.DocumentNode, error) {
return dingtalkdiscovery.ValidateDocument(ctx, dingtalkdiscovery.ExecRunner{}, node)
}
func main() {
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer stop()
@@ -184,6 +193,7 @@ func run(ctx context.Context, getenv func(string) string) error {
ProductionReleaseAuthorizationToken: releaseAuthorizationToken,
// 数据源发现(系统设置 → 数据源配置):用与 worker 同一份 dws 状态做只读列举。
DingtalkSources: dingtalkSourceLister{},
DingtalkDocuments: dingtalkSourceLister{},
BackupSchedule: postgresstore.NewStore(pool),
VersionHistory: versionHistoryStore,
VersionHistoryRepo: versionHistoryRepo,