feat: complete remaining capabilities and hide integration status

This commit is contained in:
yu committed 2026-11-02 10:43:11 +08:00
1 parent 66169590de
commit 95fb07e876
20 files changed
+15102 -201

No files matched your search

+34 -1
View File
@@ -5,6 +5,7 @@ import type { Catalog, CatalogComponent } from "../shared/types";
import { hasCapability } from "./engine/registry";
let cached: Catalog | null = null;
let excludedIds: Set<string> | null = null;
const RUNTIME_CONTAINERS = new Set([
"logic_control_if_else",
@@ -29,6 +30,31 @@ function resolveCatalogPath(): string {
throw new Error(`catalog.json not found; tried: ${candidates.join(", ")}`);
}
function excludedPath(): string {
const candidates = [
process.env.RPA_EXCLUDED_PATH,
path.join(process.resourcesPath, "excluded.json"),
path.join(app.getAppPath(), "resources", "excluded.json"),
path.join(__dirname, "../../resources/excluded.json")
].filter(Boolean) as string[];
const found = candidates.find((candidate) => fs.existsSync(candidate));
return found || "";
}
function loadExcludedIds(): Set<string> {
if (excludedIds) return excludedIds;
excludedIds = new Set();
const file = excludedPath();
if (!file) return excludedIds;
try {
const parsed = JSON.parse(fs.readFileSync(file, "utf8")) as { ids?: string[] };
for (const id of parsed.ids || []) excludedIds.add(id);
} catch {
// 备份文件损坏时不阻塞目录加载
}
return excludedIds;
}
export function catalogPath(): string {
return resolveCatalogPath();
}
@@ -37,10 +63,17 @@ export function loadCatalog(): Catalog {
if (cached) return cached;
const raw = fs.readFileSync(catalogPath(), "utf8");
const catalog = JSON.parse(raw) as Catalog;
catalog.components = catalog.components.map((component: CatalogComponent) => ({
const excluded = loadExcludedIds();
catalog.components = catalog.components.filter((component) => !excluded.has(component.id)).map((component: CatalogComponent) => ({
...component,
implemented: RUNTIME_CONTAINERS.has(component.id) || hasCapability(component.id) || hasCapability(component.functionName)
}));
catalog.counts.total = catalog.components.length;
catalog.counts.vendor = catalog.components.filter((component) => component.kind === "vendor").length;
catalog.counts.native = catalog.components.filter((component) => component.kind === "native").length;
catalog.counts.triggers = catalog.components.filter((component) => component.kind === "trigger").length;
catalog.counts.fields = catalog.components.reduce((sum, component) => sum + component.fields.length, 0);
for (const group of catalog.groups) group.count = catalog.components.filter((component) => component.group === group.id).length;
cached = catalog;
return catalog;
}