diff --git a/cypher-executor/src/routes/portal-data.ts b/cypher-executor/src/routes/portal-data.ts index c17a5b5..f55080c 100644 --- a/cypher-executor/src/routes/portal-data.ts +++ b/cypher-executor/src/routes/portal-data.ts @@ -214,7 +214,7 @@ portalDataRouter.get('/portal/data/graph/neighbors/:name', (c) => const result = await executeWebhookGraph( c.env, wfGraph, - { node: c.req.param('name'), depth, namespace: tenant, owner: tenant }, + { node: c.req.param('name'), depth, namespace: tenant, owner: tenant, libraries: libraries.includes('*') ? '*' : libraries.join(',') }, 'graph_neighbors', tenant, c.executionCtx, @@ -252,6 +252,7 @@ portalDataRouter.get('/portal/data/graph/overview', (c) => if (!(await hasGraphAccess(c.env, libraries))) { return c.json({ error: '無知識圖譜檢視權限' }, 403); } + const allowAll = libraries.includes('*'); const tenant = portalTenant(c.env); const res = await kbdbFetch(c.env, `/records/by-template/triplet?owner_id=${encodeURIComponent(tenant)}`); if (!res.ok) { @@ -270,6 +271,10 @@ portalDataRouter.get('/portal/data/graph/overview', (c) => const v = r && typeof r.values === 'object' && r.values ? r.values : null; if (!v) continue; if (v.status === 'deprecated') continue; + if (!allowAll) { + const lib = typeof v.library === 'string' && v.library.trim() ? v.library.trim() : 'general'; + if (!libraries.includes(lib)) continue; + } const s = typeof v.subject === 'string' ? v.subject.trim() : ''; const o = typeof v.object === 'string' ? v.object.trim() : ''; if (!s || !o) continue;