feat(curation): fetchStartableFlows supplements catalogue listing
The /api/ea2/flow/processes endpoint caps at ~203 items and pr_to_po_def is not in that window for this tenant despite being status=published. fetchStartableFlows() does a direct GET per allowlist key and merges results with the catalogue list (allowlist hits take precedence). Wired into Hub.loadPublishedFlows + agentTools.list_processes + agentTools.start_process.
This commit is contained in:
+9
-4
@@ -2,7 +2,7 @@ import { useEffect, useState } from "react";
|
||||
import { useApp } from "../state/store";
|
||||
import { api } from "../lib/api";
|
||||
import { wizardApi } from "../lib/wizardApi";
|
||||
import { curatedPublishedFlows } from "../lib/flowCuration";
|
||||
import { curatedPublishedFlows, fetchStartableFlows } from "../lib/flowCuration";
|
||||
import { Branch, Layers, Pulse } from "../components/icons";
|
||||
|
||||
export type HubKey = "procurement" | "hr" | "it";
|
||||
@@ -71,12 +71,17 @@ interface PublishedFlow {
|
||||
}
|
||||
|
||||
async function loadPublishedFlows(): Promise<PublishedFlow[]> {
|
||||
const res = await fetch(`${api.config.baseUrl}/api/ea2/flow/processes?limit=200`, {
|
||||
headers: { Authorization: `Bearer ${sessionStorage.getItem("fm.mc.token.v1")}` },
|
||||
const token = sessionStorage.getItem("fm.mc.token.v1") || "";
|
||||
const res = await fetch(`${api.config.baseUrl}/api/ea2/flow/processes?limit=500`, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
if (!res.ok) throw new Error(`processes ${res.status}`);
|
||||
const body = await res.json();
|
||||
return curatedPublishedFlows((body?.items || []) as any[]).map((it) => ({
|
||||
const fromList = curatedPublishedFlows((body?.items || []) as any[]);
|
||||
const directHits = await fetchStartableFlows(api.config.baseUrl, token);
|
||||
const merged = new Map<string, any>();
|
||||
for (const it of [...directHits, ...fromList]) merged.set(it._key, it);
|
||||
return Array.from(merged.values()).map((it) => ({
|
||||
_key: it._key,
|
||||
display_name: it.display_name!,
|
||||
description: it.description,
|
||||
|
||||
Reference in New Issue
Block a user