feat: add workplan aliases and legacy meter

Adds preferred workplan REST/event surfaces, legacy-meter telemetry and weekly review summaries, documentation/dashboard terminology updates, dashboard API loading fixes, and close-out sync for STATE-WP-0052 and STATE-WP-0054.
This commit is contained in:
2026-06-04 08:25:31 +02:00
parent 355f80b078
commit 166aedfa8d
43 changed files with 1851 additions and 145 deletions

View File

@@ -1,4 +1,65 @@
export const API = "http://127.0.0.1:8000";
export const DEFAULT_API = "http://127.0.0.1:8000";
export const API_STORAGE_KEY = "stateHubApiBase";
const API_QUERY_PARAMS = ["api_base", "apiBase"];
function cleanApiBase(value) {
if (typeof value !== "string") return null;
const cleaned = value.trim().replace(/\/+$/, "");
return cleaned || null;
}
function getStorageApiBase(storage) {
if (!storage?.getItem) return null;
try {
return cleanApiBase(storage.getItem(API_STORAGE_KEY));
} catch {
return null;
}
}
function urlFromLocation(location) {
if (!location) return null;
try {
return new URL(location.href ?? String(location));
} catch {
return null;
}
}
function getQueryApiBase(url) {
if (!url) return null;
for (const name of API_QUERY_PARAMS) {
const value = cleanApiBase(url.searchParams.get(name));
if (value) return value;
}
return null;
}
function inferApiBase(url) {
if (!url || !["http:", "https:"].includes(url.protocol)) return DEFAULT_API;
if (url.hostname === "::1" || url.hostname === "[::1]") return DEFAULT_API;
const apiUrl = new URL(url.href);
apiUrl.port = globalThis.STATE_HUB_API_PORT || "8000";
apiUrl.pathname = "";
apiUrl.search = "";
apiUrl.hash = "";
return apiUrl.origin;
}
export function resolveApiBase({
location = globalThis.location,
storage = globalThis.localStorage,
} = {}) {
const url = urlFromLocation(location);
return (
getQueryApiBase(url)
|| cleanApiBase(globalThis.STATE_HUB_API_BASE)
|| getStorageApiBase(storage)
|| inferApiBase(url)
);
}
export const API = resolveApiBase();
export const POLL = 15_000;
export const POLL_HEAVY = 60_000;
export const FETCH_TIMEOUT = 12_000;

View File

@@ -26,7 +26,7 @@ const FIELD_LINKS = {
getTitle: d => d.title,
},
workstream_id: {
apiUrl: id => `${API}/workstreams/${id}`,
apiUrl: id => `${API}/workplans/${id}`,
getUrl: (id, _d) => `/workstreams/${id}`,
getTitle: d => d.title || d.slug,
},