mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-16 19:33:11 +02:00
Portal (#6391)
# Description of Changes ## What & why This PR introduces the **Stirling developer portal** — a new control-plane frontend that sits alongside the existing PDF editor — plus the shared design system and workspace structure needed to host both apps in one frontend. The portal is the parent product surface: where users connect sources, compose pipelines, wire agents, and manage usage / billing / infrastructure, with the PDF editor as one capability inside it. This PR lays the **foundation** — workspace reshape, design system, app shell, navigation, and a mock-driven home — rather than wiring real backends (those surfaces are placeholders for follow-up phases). ## What's in this PR **1. Frontend repo reshape (`frontend/src/` → `frontend/editor/`)** The existing editor app moved under `frontend/editor/`, so `editor`, `portal`, and `shared` are siblings in one workspace. All references were updated accordingly: `LICENSE`, `.dockerignore`, `.gitignore`, build/sign shell scripts, the GH language-check script, the Taskfile, and Docker config. **No editor source logic changed — path references only.** **2. New shared design system (`frontend/shared/`)** - **Design tokens** in `tokens.css` as the single runtime source of truth (light/dark, category accents, gradients). `tokens.ts` now holds only the `Tier` type — the old JS palette mirror was removed (nothing consumed it and it had drifted). - ~30 framework-light **components** (Card, Button, Input, Select, Tabs, Modal, Drawer, Toast, MetricCard, StatusBadge, Skeleton, EmptyState, …) with Storybook stories. - **Typed data catalogues**: `endpoints.ts` (10 verticals / 64 endpoints) and `ops.ts`. **3. New developer portal app (`frontend/portal/`)** - App shell: `Header`, `Sidebar`, `AssistantPanel`, search modal, notifications, tier switcher, theme toggle, MSW toggle. - **Tier-aware** home (free / pay-as-you-go / enterprise): KPI strip, 30-day usage chart, onboarding checklist, quick actions, recent activity, region health, product grid, and a curated **"Popular use cases"** teaser. - **Documents** view hosting the full, tab-filterable endpoint catalogue. - Placeholder views for Sources / Pipelines / Agents / Editor / Infrastructure / Usage & Billing / Developer Docs / Settings (follow-up phases). - **MSW-mocked** API layer: `api/*` issues real `fetch`, intercepted by mocks in dev/Storybook; pointing at a real backend is just a matter of not registering MSW. `react-router` URLs; Tier / View / UI contexts. **4. Tooling & guardrails** - ESLint extended to `portal` + `shared`, with **layering-boundary rules**: `shared/` may depend only on third-party packages and itself (no `@app` / `@portal` / `@core` / `@proprietary` / Tauri), so it stays cleanly extractable into a standalone package later. - `dpdm` circular-dependency check now walks editor + portal + shared (the old glob matched only 2 files). - New **devDependencies only** — Storybook (+ a11y/docs/themes addons), MSW. No runtime dependencies added. - New tasks: `frontend:dev:portal`, `frontend:build:portal`. ## Testing done locally - `tsc` for both `portal` and `shared` projects — clean - `eslint --max-warnings=0` across the whole frontend — clean - `dpdm` circular-dependency check — no cycles - Editor builds clean: `vite build editor --mode core` (✓ built, only the pre-existing >500 kB chunk-size advisory) - Editor runs in dev (core mode) with **zero console errors**; portal runs in dev across all three tiers ## Notes for reviewers - The change is overwhelmingly **additive**: `shared/` and `portal/` are brand-new; the existing editor is path-reference changes only. - The portal is intentionally **mock-driven** at this stage — real backends and the remaining views land in follow-up phases. --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [x] I have performed a self-review of my own code - [x] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### Translations (if applicable) - [ ] I ran [`scripts/counter_translation.py`](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/docs/counter_translation.md) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have run `task check` to verify linters, typechecks, and tests pass - [x] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#7-testing) for more details. --------- Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
b355ccec9e
commit
919f0ade99
@@ -0,0 +1,61 @@
|
||||
/** Mock assistant: routing rules + canned replies + suggested prompts. */
|
||||
|
||||
export interface AssistantRoute {
|
||||
patterns: readonly RegExp[];
|
||||
reply: string;
|
||||
}
|
||||
|
||||
export const ASSISTANT_ROUTES: AssistantRoute[] = [
|
||||
{
|
||||
patterns: [/extract/i, /schema/i],
|
||||
reply:
|
||||
"For extraction, point the doc at /v1/<endpoint> and the schema-aware op infers fields from your typed catalogue. Confidence-check gates anything under 0.85 by default — adjust the threshold in the composer's per-op config.",
|
||||
},
|
||||
{
|
||||
patterns: [/mcp/i, /\bagent\b/i, /connect.*agent/i],
|
||||
reply:
|
||||
"MCP wiring lives under Sources → Add → Agent. You'll get an MCP URL of the shape mcp://stirling.com/agents/{id} plus scoped credentials. Scenarios drive the eval set the agent must pass before it can take real traffic.",
|
||||
},
|
||||
{
|
||||
patterns: [/redact/i, /pii/i],
|
||||
reply:
|
||||
"The redact op runs PII enforcement across SSN / DOB / accounts / contacts / names / addresses by default. Toggle categories in the composer; auto-detected PII supports blackout, replace, and mask styles.",
|
||||
},
|
||||
{
|
||||
patterns: [/deploy/i, /docker/i, /self.host/i],
|
||||
reply:
|
||||
"Self-host via the docker variant from /editor → Self-Hosted. Air-gapped tarballs ship on Enterprise. Helm charts cover us-east-1, eu-west-1, ap-southeast-1; multi-region requires the Enterprise plan.",
|
||||
},
|
||||
{
|
||||
patterns: [/rate.*limit/i, /quota/i, /throttl/i],
|
||||
reply:
|
||||
"Free is 4.2 req/min. Pro scales to 342 req/min with burst tolerance. Enterprise lifts to 2.4k req/min with per-region pools. The 429 response carries Retry-After in seconds.",
|
||||
},
|
||||
{
|
||||
patterns: [/webhook/i, /callback/i],
|
||||
reply:
|
||||
"Outbound webhooks deliver via 3× exponential backoff. We sign every payload with HMAC-SHA256 — verify via the X-Stirling-Signature header. Inbound webhooks support Bearer, HMAC, or mTLS auth.",
|
||||
},
|
||||
];
|
||||
|
||||
export const ASSISTANT_DEFAULT_REPLY =
|
||||
"I can help with extraction, MCP / agents, redaction, deployment, rate limits, and webhooks. Try one of the suggestions, or ask something specific.";
|
||||
|
||||
export const ASSISTANT_SUGGESTIONS: readonly string[] = [
|
||||
"How do I wire an MCP agent?",
|
||||
"Extract fields from a COI",
|
||||
"Redact PII before storage",
|
||||
"Self-host with Docker",
|
||||
"What are the rate limits?",
|
||||
"Build a pipeline from a sample",
|
||||
];
|
||||
|
||||
/** Resolve an input to a canned reply by walking the route table. */
|
||||
export function routeAssistantReply(input: string): string {
|
||||
for (const route of ASSISTANT_ROUTES) {
|
||||
for (const pattern of route.patterns) {
|
||||
if (pattern.test(input)) return route.reply;
|
||||
}
|
||||
}
|
||||
return ASSISTANT_DEFAULT_REPLY;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { setupWorker } from "msw/browser";
|
||||
import { handlers } from "@portal/mocks/handlers";
|
||||
|
||||
export const worker = setupWorker(...handlers);
|
||||
|
||||
let workerStarted = false;
|
||||
|
||||
/**
|
||||
* Start the MSW worker. Idempotent — calling repeatedly is safe.
|
||||
*
|
||||
* The toggle flips MSW by writing the preference to localStorage and
|
||||
* reloading the page, so there's no need for a `stopMockWorker` counterpart:
|
||||
* the next boot just decides whether to call this or not.
|
||||
*/
|
||||
export async function startMockWorker(): Promise<void> {
|
||||
if (workerStarted) return;
|
||||
await worker.start({
|
||||
onUnhandledRequest: "bypass",
|
||||
serviceWorker: { url: "/mockServiceWorker.js" },
|
||||
quiet: true,
|
||||
});
|
||||
workerStarted = true;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { http, HttpResponse, delay } from "msw";
|
||||
import {
|
||||
ASSISTANT_SUGGESTIONS,
|
||||
routeAssistantReply,
|
||||
} from "@portal/mocks/assistant";
|
||||
|
||||
interface AssistantMessageBody {
|
||||
input: string;
|
||||
}
|
||||
|
||||
export const assistantHandlers = [
|
||||
http.get("/v1/assistant/suggestions", async () => {
|
||||
return HttpResponse.json(ASSISTANT_SUGGESTIONS);
|
||||
}),
|
||||
|
||||
http.post("/v1/assistant/messages", async ({ request }) => {
|
||||
const body = (await request.json()) as AssistantMessageBody;
|
||||
await delay(600 + Math.random() * 300);
|
||||
return HttpResponse.json({ reply: routeAssistantReply(body.input) });
|
||||
}),
|
||||
];
|
||||
@@ -0,0 +1,15 @@
|
||||
import { http, HttpResponse, delay } from "msw";
|
||||
import { VERTICALS } from "@shared/data/endpoints";
|
||||
|
||||
export const endpointsHandlers = [
|
||||
http.get("/v1/endpoints", async ({ request }) => {
|
||||
await delay(120);
|
||||
const url = new URL(request.url);
|
||||
const verticalKey = url.searchParams.get("vertical");
|
||||
if (verticalKey) {
|
||||
const v = VERTICALS.find((x) => x.key === verticalKey);
|
||||
return HttpResponse.json(v ? v.endpoints : []);
|
||||
}
|
||||
return HttpResponse.json(VERTICALS);
|
||||
}),
|
||||
];
|
||||
@@ -0,0 +1,49 @@
|
||||
import { http, HttpResponse, delay } from "msw";
|
||||
import type { Tier } from "@portal/contexts/TierContext";
|
||||
import {
|
||||
buildUsageSeries,
|
||||
buildUsageSeriesResponse,
|
||||
enterpriseKpisFor,
|
||||
FREE_KPIS,
|
||||
FREE_ONBOARDING,
|
||||
proKpisFor,
|
||||
RECENT_ACTIVITY,
|
||||
REGION_HEALTH,
|
||||
type KpiEntry,
|
||||
} from "@portal/mocks/home";
|
||||
|
||||
function kpisFor(tier: Tier): KpiEntry[] {
|
||||
if (tier === "free") return FREE_KPIS;
|
||||
const docs30d = buildUsageSeries().reduce((sum, p) => sum + p.value, 0);
|
||||
if (tier === "enterprise") return enterpriseKpisFor(docs30d);
|
||||
return proKpisFor(docs30d);
|
||||
}
|
||||
|
||||
export const homeHandlers = [
|
||||
http.get("/v1/analytics/usage", async () => {
|
||||
await delay(120);
|
||||
return HttpResponse.json(buildUsageSeriesResponse());
|
||||
}),
|
||||
|
||||
http.get("/v1/activity", async () => {
|
||||
await delay(120);
|
||||
return HttpResponse.json(RECENT_ACTIVITY);
|
||||
}),
|
||||
|
||||
http.get("/v1/home/kpis", async ({ request }) => {
|
||||
await delay(120);
|
||||
const url = new URL(request.url);
|
||||
const tier = (url.searchParams.get("tier") ?? "pro") as Tier;
|
||||
return HttpResponse.json(kpisFor(tier));
|
||||
}),
|
||||
|
||||
http.get("/v1/regions/health", async () => {
|
||||
await delay(120);
|
||||
return HttpResponse.json(REGION_HEALTH);
|
||||
}),
|
||||
|
||||
http.get("/v1/onboarding", async () => {
|
||||
await delay(120);
|
||||
return HttpResponse.json(FREE_ONBOARDING);
|
||||
}),
|
||||
];
|
||||
@@ -0,0 +1,17 @@
|
||||
import { assistantHandlers } from "@portal/mocks/handlers/assistant";
|
||||
import { endpointsHandlers } from "@portal/mocks/handlers/endpoints";
|
||||
import { homeHandlers } from "@portal/mocks/handlers/home";
|
||||
import { notificationsHandlers } from "@portal/mocks/handlers/notifications";
|
||||
import { opsHandlers } from "@portal/mocks/handlers/ops";
|
||||
import { searchHandlers } from "@portal/mocks/handlers/search";
|
||||
|
||||
export const handlers = [
|
||||
...homeHandlers,
|
||||
...opsHandlers,
|
||||
...notificationsHandlers,
|
||||
...assistantHandlers,
|
||||
...searchHandlers,
|
||||
...endpointsHandlers,
|
||||
];
|
||||
|
||||
export { resetNotificationsStore } from "@portal/mocks/handlers/notifications";
|
||||
@@ -0,0 +1,21 @@
|
||||
import { http, HttpResponse, delay } from "msw";
|
||||
import { NOTIFICATIONS, type Notification } from "@portal/mocks/notifications";
|
||||
|
||||
let store: Notification[] = [...NOTIFICATIONS];
|
||||
|
||||
export function resetNotificationsStore(seed?: Notification[]): void {
|
||||
store = seed ? [...seed] : [...NOTIFICATIONS];
|
||||
}
|
||||
|
||||
export const notificationsHandlers = [
|
||||
http.get("/v1/notifications", async () => {
|
||||
await delay(120);
|
||||
return HttpResponse.json(store);
|
||||
}),
|
||||
|
||||
http.post("/v1/notifications/mark-all-read", async () => {
|
||||
await delay(120);
|
||||
store = [];
|
||||
return HttpResponse.json({ ok: true });
|
||||
}),
|
||||
];
|
||||
@@ -0,0 +1,30 @@
|
||||
import { http, HttpResponse, delay } from "msw";
|
||||
import { FEATURED_OPS, OP_RESULTS } from "@portal/mocks/ops";
|
||||
|
||||
export const opsHandlers = [
|
||||
http.get("/v1/ops/featured", async () => {
|
||||
await delay(120);
|
||||
return HttpResponse.json(FEATURED_OPS);
|
||||
}),
|
||||
|
||||
http.post("/v1/ops/:opId/run", async ({ params }) => {
|
||||
const start = performance.now();
|
||||
await delay(800 + Math.random() * 200);
|
||||
const opId = String(params.opId);
|
||||
const result = OP_RESULTS[opId];
|
||||
if (!result) {
|
||||
return HttpResponse.json(
|
||||
{ error: `Unknown op: ${opId}` },
|
||||
{ status: 404 },
|
||||
);
|
||||
}
|
||||
const enriched =
|
||||
opId === "sign-output"
|
||||
? { ...result, signed_at: new Date().toISOString() }
|
||||
: result;
|
||||
return HttpResponse.json({
|
||||
result: enriched,
|
||||
durationMs: Math.round(performance.now() - start),
|
||||
});
|
||||
}),
|
||||
];
|
||||
@@ -0,0 +1,8 @@
|
||||
import { http, HttpResponse } from "msw";
|
||||
import { QUICK_ACTIONS } from "@portal/mocks/search";
|
||||
|
||||
export const searchHandlers = [
|
||||
http.get("/v1/search/quick-actions", () => {
|
||||
return HttpResponse.json(QUICK_ACTIONS);
|
||||
}),
|
||||
];
|
||||
@@ -0,0 +1,255 @@
|
||||
/**
|
||||
* Home dashboard fixtures and the types api/home.ts shares with them.
|
||||
* api/home.ts imports the types; the MSW handlers in mocks/handlers/ serve the
|
||||
* fixture data over the intercepted httpJson() calls. Components never reach
|
||||
* into this module directly.
|
||||
*
|
||||
* Once a real backend exists, the MSW handlers stop being registered and these
|
||||
* fixtures can be deleted (or kept as test seeds).
|
||||
*/
|
||||
|
||||
export interface UsagePoint {
|
||||
/** ISO date (YYYY-MM-DD). */
|
||||
date: string;
|
||||
/** Docs processed on that day. */
|
||||
value: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Server response for the usage-series endpoint. Returning the prior window's
|
||||
* total alongside the points lets the client derive the headline delta
|
||||
* deterministically from real data rather than carrying a hardcoded figure.
|
||||
*/
|
||||
export interface UsageSeriesResponse {
|
||||
points: UsagePoint[];
|
||||
/** Equivalent docs total from the immediately prior 30-day window. */
|
||||
priorTotal: number;
|
||||
}
|
||||
|
||||
/** Builds 30 daily points ending today. Deterministic per day. */
|
||||
export function buildUsageSeries(): UsagePoint[] {
|
||||
const points: UsagePoint[] = [];
|
||||
const now = new Date();
|
||||
for (let i = 29; i >= 0; i--) {
|
||||
const d = new Date(now);
|
||||
d.setDate(now.getDate() - i);
|
||||
const day = d.getDay();
|
||||
// Weekend dip + slow uptrend + bounded noise.
|
||||
const weekend = day === 0 || day === 6 ? 0.55 : 1;
|
||||
const trend = 1 + (30 - i) * 0.012;
|
||||
const wobble = 1 + Math.sin(i * 1.3) * 0.18 + Math.cos(i * 0.6) * 0.09;
|
||||
const base = 1450 * weekend * trend * wobble;
|
||||
points.push({
|
||||
date: d.toISOString().slice(0, 10),
|
||||
value: Math.round(base),
|
||||
});
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
/** Builds the full usage payload with a plausible prior-window total. */
|
||||
export function buildUsageSeriesResponse(): UsageSeriesResponse {
|
||||
const points = buildUsageSeries();
|
||||
const currentTotal = points.reduce((sum, p) => sum + p.value, 0);
|
||||
// The current window's series simulates ~12% growth over the prior one.
|
||||
const priorTotal = Math.round(currentTotal / 1.12);
|
||||
return { points, priorTotal };
|
||||
}
|
||||
|
||||
export type ActivityKind =
|
||||
| "pipeline-run"
|
||||
| "deploy"
|
||||
| "drift"
|
||||
| "eval"
|
||||
| "agent"
|
||||
| "billing";
|
||||
|
||||
export interface ActivityEvent {
|
||||
id: string;
|
||||
kind: ActivityKind;
|
||||
/** Short action verb shown at the top of the row. */
|
||||
action: string;
|
||||
/** Subject of the action (pipeline / endpoint / agent name). */
|
||||
subject: string;
|
||||
/** One-line detail line under the action. */
|
||||
detail: string;
|
||||
/** Relative-time string. */
|
||||
time: string;
|
||||
status: "success" | "warning" | "danger" | "info";
|
||||
}
|
||||
|
||||
export const RECENT_ACTIVITY: ActivityEvent[] = [
|
||||
{
|
||||
id: "act-1",
|
||||
kind: "pipeline-run",
|
||||
action: "Pipeline run completed",
|
||||
subject: "COI Compliance",
|
||||
detail: "1,287 docs · 0.4% errors · P95 412 ms",
|
||||
time: "2m ago",
|
||||
status: "success",
|
||||
},
|
||||
{
|
||||
id: "act-2",
|
||||
kind: "deploy",
|
||||
action: "Deployed",
|
||||
subject: "Prior Auth v3.1.0",
|
||||
detail: "Promoted to us-east-1, eu-west-1 · golden set 36/36",
|
||||
time: "14m ago",
|
||||
status: "success",
|
||||
},
|
||||
{
|
||||
id: "act-3",
|
||||
kind: "drift",
|
||||
action: "Schema drift detected",
|
||||
subject: "Invoice v3",
|
||||
detail: "12 docs in 1h didn't match — confidence ↓ 0.07",
|
||||
time: "1h ago",
|
||||
status: "warning",
|
||||
},
|
||||
{
|
||||
id: "act-4",
|
||||
kind: "eval",
|
||||
action: "Eval set passed",
|
||||
subject: "KYC Processor",
|
||||
detail: "94% (26/28) — 2 cases sent to review",
|
||||
time: "3h ago",
|
||||
status: "success",
|
||||
},
|
||||
{
|
||||
id: "act-5",
|
||||
kind: "agent",
|
||||
action: "Agent escalated",
|
||||
subject: "Contract Router",
|
||||
detail: "Low-confidence DPA routed to L2 reviewer pool",
|
||||
time: "5h ago",
|
||||
status: "info",
|
||||
},
|
||||
{
|
||||
id: "act-6",
|
||||
kind: "pipeline-run",
|
||||
action: "Pipeline run failed",
|
||||
subject: "Contract Review",
|
||||
detail: "8% error rate · 14 docs sent to review queue",
|
||||
time: "8h ago",
|
||||
status: "danger",
|
||||
},
|
||||
{
|
||||
id: "act-7",
|
||||
kind: "billing",
|
||||
action: "Approaching cap",
|
||||
subject: "Monthly usage",
|
||||
detail: "389k of 500k docs · auto-upgrade disabled",
|
||||
time: "yesterday",
|
||||
status: "warning",
|
||||
},
|
||||
{
|
||||
id: "act-8",
|
||||
kind: "deploy",
|
||||
action: "Rolled back",
|
||||
subject: "COI Compliance v2.3.7",
|
||||
detail: "Confidence regressions on Carrier supplement",
|
||||
time: "2d ago",
|
||||
status: "warning",
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* KPI labels are owned by the client (see `KPI_LABELS_BY_TIER` in Home.tsx)
|
||||
* because they're product copy that should stay stable across loading / empty
|
||||
* / ready states. The API only ships values + deltas.
|
||||
*/
|
||||
export interface KpiEntry {
|
||||
value: string | number;
|
||||
delta?: number;
|
||||
description?: string;
|
||||
deltaDirection?: "up" | "down" | "flat";
|
||||
}
|
||||
|
||||
export const FREE_KPIS: KpiEntry[] = [
|
||||
{ value: "247 / 500" },
|
||||
{ value: 189 },
|
||||
{ value: 3 },
|
||||
{ value: 1 },
|
||||
];
|
||||
|
||||
export function proKpisFor(docs30d: number): KpiEntry[] {
|
||||
return [
|
||||
{ value: docs30d.toLocaleString(), delta: 0.12 },
|
||||
{ value: 12, delta: 0.16 },
|
||||
{ value: 7, delta: 0.4 },
|
||||
{ value: "94.6%", delta: 0.02 },
|
||||
];
|
||||
}
|
||||
|
||||
export function enterpriseKpisFor(docs30d: number): KpiEntry[] {
|
||||
return [
|
||||
{ value: docs30d.toLocaleString(), delta: 0.18 },
|
||||
{ value: "412 ms", delta: -0.05 },
|
||||
{ value: "96.2%", delta: 0.01 },
|
||||
{ value: "99.987%" },
|
||||
];
|
||||
}
|
||||
|
||||
export interface RegionHealth {
|
||||
name: string;
|
||||
status: "healthy" | "degraded" | "down";
|
||||
meta: string;
|
||||
}
|
||||
|
||||
export const REGION_HEALTH: RegionHealth[] = [
|
||||
{
|
||||
name: "us-east-1",
|
||||
status: "healthy",
|
||||
meta: "2.1k/min · P95 287ms · 99.99% uptime",
|
||||
},
|
||||
{
|
||||
name: "eu-west-1",
|
||||
status: "healthy",
|
||||
meta: "1.4k/min · P95 312ms · 99.98% uptime",
|
||||
},
|
||||
{
|
||||
name: "ap-southeast-1",
|
||||
status: "degraded",
|
||||
meta: "412/min · P95 521ms · 99.92% uptime · degraded",
|
||||
},
|
||||
];
|
||||
|
||||
export interface OnboardingStep {
|
||||
id: string;
|
||||
title: string;
|
||||
blurb: string;
|
||||
done: boolean;
|
||||
/** What to render in the per-step CTA slot. */
|
||||
cta?: { kind: "try-op" } | { kind: "navigate"; target: string };
|
||||
}
|
||||
|
||||
export const FREE_ONBOARDING: OnboardingStep[] = [
|
||||
{
|
||||
id: "first-op",
|
||||
title: "Run your first operation",
|
||||
blurb: "Try extract, redact, or OCR on a sample document.",
|
||||
done: true,
|
||||
cta: { kind: "try-op" },
|
||||
},
|
||||
{
|
||||
id: "connect-source",
|
||||
title: "Connect a source",
|
||||
blurb: "Attach an S3 bucket, webhook, or email inbox.",
|
||||
done: false,
|
||||
cta: { kind: "navigate", target: "sources" },
|
||||
},
|
||||
{
|
||||
id: "build-pipeline",
|
||||
title: "Build a pipeline",
|
||||
blurb: "Compose ops into a repeatable workflow.",
|
||||
done: false,
|
||||
cta: { kind: "navigate", target: "pipelines" },
|
||||
},
|
||||
{
|
||||
id: "wire-agent",
|
||||
title: "Wire an agent",
|
||||
blurb: "Expose Stirling via MCP or REST tool definitions.",
|
||||
done: false,
|
||||
cta: { kind: "navigate", target: "sources" },
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,63 @@
|
||||
/** Mock notifications for the header dropdown. */
|
||||
|
||||
export type NotificationCategory =
|
||||
| "pipeline"
|
||||
| "deploy"
|
||||
| "billing"
|
||||
| "audit"
|
||||
| "agent"
|
||||
| "doc";
|
||||
|
||||
export interface Notification {
|
||||
id: string;
|
||||
category: NotificationCategory;
|
||||
title: string;
|
||||
description: string;
|
||||
/** Relative-time string. */
|
||||
time: string;
|
||||
}
|
||||
|
||||
export const NOTIFICATIONS: Notification[] = [
|
||||
{
|
||||
id: "n1",
|
||||
category: "pipeline",
|
||||
title: "COI Compliance — golden set passed",
|
||||
description: "48/48 docs reproduced expected outputs after schema change",
|
||||
time: "2m ago",
|
||||
},
|
||||
{
|
||||
id: "n2",
|
||||
category: "deploy",
|
||||
title: "Deploy succeeded — Prior Auth v2.4",
|
||||
description: "Rolled to us-east-1 + eu-west-1. P99 142ms.",
|
||||
time: "14m ago",
|
||||
},
|
||||
{
|
||||
id: "n3",
|
||||
category: "billing",
|
||||
title: "Approaching 80% of monthly cap",
|
||||
description: "389k of 500k docs processed. Auto-upgrade not enabled.",
|
||||
time: "1h ago",
|
||||
},
|
||||
{
|
||||
id: "n4",
|
||||
category: "audit",
|
||||
title: "Four-eyes elevation requested",
|
||||
description: "Compliance Lead approval pending for redacted doc #28471",
|
||||
time: "3h ago",
|
||||
},
|
||||
{
|
||||
id: "n5",
|
||||
category: "agent",
|
||||
title: "KYC Processor — eval drop",
|
||||
description: "Pass rate fell to 87% on the latest 72h window",
|
||||
time: "5h ago",
|
||||
},
|
||||
{
|
||||
id: "n6",
|
||||
category: "doc",
|
||||
title: "Schema drift detected — Invoice v3",
|
||||
description: "12 docs in last 24h didn't match expected schema",
|
||||
time: "yesterday",
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,166 @@
|
||||
/**
|
||||
* Mock op catalogue + canned operation results for the single-op runner.
|
||||
* Only api/ops.ts imports from this file.
|
||||
*/
|
||||
|
||||
export type OpResultMap = Record<string, unknown>;
|
||||
|
||||
export interface FeaturedOp {
|
||||
id: string;
|
||||
label: string;
|
||||
endpoint: string;
|
||||
accent: "blue" | "purple" | "green" | "amber" | "red";
|
||||
/** Shown in the picker — short single line. */
|
||||
blurb: string;
|
||||
}
|
||||
|
||||
export const FEATURED_OPS: FeaturedOp[] = [
|
||||
{
|
||||
id: "extract",
|
||||
label: "Extract",
|
||||
endpoint: "/v1/extract",
|
||||
accent: "blue",
|
||||
blurb: "Pull structured fields into a typed schema",
|
||||
},
|
||||
{
|
||||
id: "redact",
|
||||
label: "Redact PII",
|
||||
endpoint: "/v1/redact",
|
||||
accent: "red",
|
||||
blurb: "Mask SSN, DOB, addresses, accounts before storage",
|
||||
},
|
||||
{
|
||||
id: "classify",
|
||||
label: "Classify",
|
||||
endpoint: "/v1/classify",
|
||||
accent: "purple",
|
||||
blurb: "Identify document type with a confidence score",
|
||||
},
|
||||
{
|
||||
id: "ocr",
|
||||
label: "OCR",
|
||||
endpoint: "/v1/ocr",
|
||||
accent: "green",
|
||||
blurb: "Text-recognize scanned or image pages",
|
||||
},
|
||||
{
|
||||
id: "validate",
|
||||
label: "Schema validate",
|
||||
endpoint: "/v1/validate",
|
||||
accent: "blue",
|
||||
blurb: "Check fields, rules, and coverage against the schema",
|
||||
},
|
||||
{
|
||||
id: "sign-output",
|
||||
label: "Sign output",
|
||||
endpoint: "/v1/sign",
|
||||
accent: "green",
|
||||
blurb: "Tamper-evident signature over artifact + run metadata",
|
||||
},
|
||||
{
|
||||
id: "authenticity",
|
||||
label: "Authenticity",
|
||||
endpoint: "/v1/authenticity",
|
||||
accent: "blue",
|
||||
blurb: "Verify issuer signature, watermark, and metadata",
|
||||
},
|
||||
{
|
||||
id: "tamper-check",
|
||||
label: "Tamper check",
|
||||
endpoint: "/v1/tamper-check",
|
||||
accent: "amber",
|
||||
blurb: "Detect modifications since signing or last-known-good state",
|
||||
},
|
||||
{
|
||||
id: "encrypt-rest",
|
||||
label: "Encrypt at rest",
|
||||
endpoint: "/v1/encrypt",
|
||||
accent: "purple",
|
||||
blurb: "AES-256 with Stirling-managed, BYOK, or HYOK keys",
|
||||
},
|
||||
{
|
||||
id: "smart-redact",
|
||||
label: "Smart redact",
|
||||
endpoint: "/v1/smart-redact",
|
||||
accent: "red",
|
||||
blurb: "Schema-aware redaction with confidence gating",
|
||||
},
|
||||
];
|
||||
|
||||
/** Canned JSON for each featured op's runner "done" state. */
|
||||
export const OP_RESULTS: Record<string, OpResultMap> = {
|
||||
extract: {
|
||||
schema: "coi.v2",
|
||||
fields: {
|
||||
carrier: "Travelers Casualty",
|
||||
policy_number: "PHB-1108-2025",
|
||||
gl_limit: 1_000_000,
|
||||
umbrella_limit: 5_000_000,
|
||||
effective: "2026-01-15",
|
||||
expiry: "2027-01-15",
|
||||
},
|
||||
confidence_avg: 0.96,
|
||||
},
|
||||
redact: {
|
||||
redacted_pages: 4,
|
||||
pii_types: ["SSN", "DOB", "ADDRESS", "EMAIL"],
|
||||
occurrences: 19,
|
||||
redaction_style: "blackout",
|
||||
audit_id: "rdct_01HVQ7K3ZA9YJ8C",
|
||||
},
|
||||
classify: {
|
||||
schema: "invoice.v3",
|
||||
confidence: 0.94,
|
||||
alternatives: [
|
||||
{ schema: "credit_memo.v1", confidence: 0.04 },
|
||||
{ schema: "purchase_order.v2", confidence: 0.02 },
|
||||
],
|
||||
processing_ms: 287,
|
||||
},
|
||||
ocr: {
|
||||
pages: 12,
|
||||
characters_recognized: 28471,
|
||||
confidence_avg: 0.987,
|
||||
languages_detected: ["en"],
|
||||
processing_ms: 1840,
|
||||
},
|
||||
validate: {
|
||||
schema: "coi.v2",
|
||||
passed: true,
|
||||
checks_run: 14,
|
||||
warnings: [
|
||||
{ field: "additional_insured", message: "Optional field empty" },
|
||||
],
|
||||
},
|
||||
"sign-output": {
|
||||
algorithm: "Ed25519",
|
||||
key_id: "kx-prod-2026",
|
||||
manifest_hash:
|
||||
"0xb3f0c1a9d54fa1c0b8fd4eebd7fa11b1b16c9a3e2d2cc6f1f5a2f0a87e1b7a04",
|
||||
},
|
||||
authenticity: {
|
||||
verified: true,
|
||||
issuer: "State of California DMV",
|
||||
signed_at: "2025-11-04T17:22:00Z",
|
||||
watermark_match: true,
|
||||
},
|
||||
"tamper-check": {
|
||||
tampered: false,
|
||||
hash_match: true,
|
||||
modifications_detected: 0,
|
||||
last_known_good: "2026-04-22T09:14:00Z",
|
||||
},
|
||||
"encrypt-rest": {
|
||||
algorithm: "AES-256-GCM",
|
||||
key_mode: "BYOK",
|
||||
key_id: "arn:aws:kms:us-east-1:123:key/abc-…",
|
||||
object_id: "obj_01HVQ7M9B2",
|
||||
},
|
||||
"smart-redact": {
|
||||
schema: "coi.v2",
|
||||
redacted_fields: ["named_insured", "dob"],
|
||||
occurrences: 7,
|
||||
confidence_gate: 0.85,
|
||||
gated_by_confidence: 1,
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
/**
|
||||
* Lightweight preference helpers — pulled out of mocks/browser.ts so they
|
||||
* don't drag MSW + every handler + every fixture into any chunk that just
|
||||
* needs to *read* the user's choice. Loading the actual worker stays a
|
||||
* dynamic import.
|
||||
*/
|
||||
|
||||
const STORAGE_KEY = "stirling.portal.mocks-enabled";
|
||||
|
||||
export function readMocksPreference(): boolean {
|
||||
if (typeof window === "undefined") return false;
|
||||
const stored = window.localStorage.getItem(STORAGE_KEY);
|
||||
if (stored === "true") return true;
|
||||
if (stored === "false") return false;
|
||||
return import.meta.env.DEV;
|
||||
}
|
||||
|
||||
export function writeMocksPreference(enabled: boolean): void {
|
||||
if (typeof window === "undefined") return;
|
||||
window.localStorage.setItem(STORAGE_KEY, String(enabled));
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/** Mock quick-action catalogue for the ⌘K search palette. */
|
||||
|
||||
export interface QuickAction {
|
||||
group: "Jump to" | "Create" | "Theme";
|
||||
label: string;
|
||||
/** Keyboard hint shown to the right. */
|
||||
hint: string;
|
||||
}
|
||||
|
||||
export const QUICK_ACTIONS: QuickAction[] = [
|
||||
{ group: "Jump to", label: "Home", hint: "G H" },
|
||||
{ group: "Jump to", label: "Pipelines", hint: "G P" },
|
||||
{ group: "Jump to", label: "Sources", hint: "G S" },
|
||||
{ group: "Jump to", label: "Documents", hint: "G D" },
|
||||
{ group: "Create", label: "New pipeline", hint: "N P" },
|
||||
{ group: "Create", label: "New API key", hint: "N K" },
|
||||
{ group: "Theme", label: "Toggle dark / light", hint: "T" },
|
||||
];
|
||||
Reference in New Issue
Block a user