@proofoftech/flowsafe 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/LICENSE +202 -0
- package/README.md +273 -0
- package/dist/approval-api/contract.d.ts +45 -0
- package/dist/approval-api/contract.d.ts.map +1 -0
- package/dist/approval-api/contract.js +37 -0
- package/dist/approval-api/contract.js.map +1 -0
- package/dist/approval-api/d1-store.d.ts +52 -0
- package/dist/approval-api/d1-store.d.ts.map +1 -0
- package/dist/approval-api/d1-store.js +468 -0
- package/dist/approval-api/d1-store.js.map +1 -0
- package/dist/approval-api/grants.d.ts +52 -0
- package/dist/approval-api/grants.d.ts.map +1 -0
- package/dist/approval-api/grants.js +200 -0
- package/dist/approval-api/grants.js.map +1 -0
- package/dist/approval-api/index.d.ts +21 -0
- package/dist/approval-api/index.d.ts.map +1 -0
- package/dist/approval-api/index.js +18 -0
- package/dist/approval-api/index.js.map +1 -0
- package/dist/approval-api/retention.d.ts +32 -0
- package/dist/approval-api/retention.d.ts.map +1 -0
- package/dist/approval-api/retention.js +81 -0
- package/dist/approval-api/retention.js.map +1 -0
- package/dist/approval-api/router.d.ts +51 -0
- package/dist/approval-api/router.d.ts.map +1 -0
- package/dist/approval-api/router.js +245 -0
- package/dist/approval-api/router.js.map +1 -0
- package/dist/approval-api/service.d.ts +134 -0
- package/dist/approval-api/service.d.ts.map +1 -0
- package/dist/approval-api/service.js +537 -0
- package/dist/approval-api/service.js.map +1 -0
- package/dist/approval-api/store.d.ts +126 -0
- package/dist/approval-api/store.d.ts.map +1 -0
- package/dist/approval-api/store.js +189 -0
- package/dist/approval-api/store.js.map +1 -0
- package/dist/approval-api/tenant-brand.d.ts +35 -0
- package/dist/approval-api/tenant-brand.d.ts.map +1 -0
- package/dist/approval-api/tenant-brand.js +18 -0
- package/dist/approval-api/tenant-brand.js.map +1 -0
- package/dist/approval-api/tenant-context.d.ts +44 -0
- package/dist/approval-api/tenant-context.d.ts.map +1 -0
- package/dist/approval-api/tenant-context.js +49 -0
- package/dist/approval-api/tenant-context.js.map +1 -0
- package/dist/approval-api/tenant-store.d.ts +36 -0
- package/dist/approval-api/tenant-store.d.ts.map +1 -0
- package/dist/approval-api/tenant-store.js +122 -0
- package/dist/approval-api/tenant-store.js.map +1 -0
- package/dist/approval-api/types.d.ts +247 -0
- package/dist/approval-api/types.d.ts.map +1 -0
- package/dist/approval-api/types.js +157 -0
- package/dist/approval-api/types.js.map +1 -0
- package/dist/approval-ui/App.d.ts +11 -0
- package/dist/approval-ui/App.d.ts.map +1 -0
- package/dist/approval-ui/App.js +15 -0
- package/dist/approval-ui/App.js.map +1 -0
- package/dist/approval-ui/DetailView.d.ts +13 -0
- package/dist/approval-ui/DetailView.d.ts.map +1 -0
- package/dist/approval-ui/DetailView.js +20 -0
- package/dist/approval-ui/DetailView.js.map +1 -0
- package/dist/approval-ui/MetricsView.d.ts +7 -0
- package/dist/approval-ui/MetricsView.d.ts.map +1 -0
- package/dist/approval-ui/MetricsView.js +22 -0
- package/dist/approval-ui/MetricsView.js.map +1 -0
- package/dist/approval-ui/QueueView.d.ts +11 -0
- package/dist/approval-ui/QueueView.d.ts.map +1 -0
- package/dist/approval-ui/QueueView.js +59 -0
- package/dist/approval-ui/QueueView.js.map +1 -0
- package/dist/approval-ui/client.d.ts +34 -0
- package/dist/approval-ui/client.d.ts.map +1 -0
- package/dist/approval-ui/client.js +103 -0
- package/dist/approval-ui/client.js.map +1 -0
- package/dist/approval-ui/components.d.ts +125 -0
- package/dist/approval-ui/components.d.ts.map +1 -0
- package/dist/approval-ui/components.js +54 -0
- package/dist/approval-ui/components.js.map +1 -0
- package/dist/approval-ui/index.d.ts +21 -0
- package/dist/approval-ui/index.d.ts.map +1 -0
- package/dist/approval-ui/index.js +21 -0
- package/dist/approval-ui/index.js.map +1 -0
- package/dist/approval-ui/mount.d.ts +23 -0
- package/dist/approval-ui/mount.d.ts.map +1 -0
- package/dist/approval-ui/mount.js +17 -0
- package/dist/approval-ui/mount.js.map +1 -0
- package/dist/approval-ui/tips.d.ts +32 -0
- package/dist/approval-ui/tips.d.ts.map +1 -0
- package/dist/approval-ui/tips.js +32 -0
- package/dist/approval-ui/tips.js.map +1 -0
- package/dist/approval-ui/use-approval-dashboard.d.ts +70 -0
- package/dist/approval-ui/use-approval-dashboard.d.ts.map +1 -0
- package/dist/approval-ui/use-approval-dashboard.js +148 -0
- package/dist/approval-ui/use-approval-dashboard.js.map +1 -0
- package/dist/approval-ui/view-model.d.ts +24 -0
- package/dist/approval-ui/view-model.d.ts.map +1 -0
- package/dist/approval-ui/view-model.js +62 -0
- package/dist/approval-ui/view-model.js.map +1 -0
- package/dist/artifacts/index.d.ts +123 -0
- package/dist/artifacts/index.d.ts.map +1 -0
- package/dist/artifacts/index.js +223 -0
- package/dist/artifacts/index.js.map +1 -0
- package/dist/audit-export/index.d.ts +71 -0
- package/dist/audit-export/index.d.ts.map +1 -0
- package/dist/audit-export/index.js +124 -0
- package/dist/audit-export/index.js.map +1 -0
- package/dist/do-runner/breakwater-keys.d.ts +23 -0
- package/dist/do-runner/breakwater-keys.d.ts.map +1 -0
- package/dist/do-runner/breakwater-keys.js +38 -0
- package/dist/do-runner/breakwater-keys.js.map +1 -0
- package/dist/do-runner/cf-types.d.ts +26 -0
- package/dist/do-runner/cf-types.d.ts.map +1 -0
- package/dist/do-runner/cf-types.js +13 -0
- package/dist/do-runner/cf-types.js.map +1 -0
- package/dist/do-runner/d1-storage.d.ts +128 -0
- package/dist/do-runner/d1-storage.d.ts.map +1 -0
- package/dist/do-runner/d1-storage.js +287 -0
- package/dist/do-runner/d1-storage.js.map +1 -0
- package/dist/do-runner/durable-object.d.ts +28 -0
- package/dist/do-runner/durable-object.d.ts.map +1 -0
- package/dist/do-runner/durable-object.js +164 -0
- package/dist/do-runner/durable-object.js.map +1 -0
- package/dist/do-runner/index.d.ts +12 -0
- package/dist/do-runner/index.d.ts.map +1 -0
- package/dist/do-runner/index.js +11 -0
- package/dist/do-runner/index.js.map +1 -0
- package/dist/do-runner/init.d.ts +38 -0
- package/dist/do-runner/init.d.ts.map +1 -0
- package/dist/do-runner/init.js +45 -0
- package/dist/do-runner/init.js.map +1 -0
- package/dist/do-runner/path-safe-id.d.ts +19 -0
- package/dist/do-runner/path-safe-id.d.ts.map +1 -0
- package/dist/do-runner/path-safe-id.js +70 -0
- package/dist/do-runner/path-safe-id.js.map +1 -0
- package/dist/do-runner/resume-ledger.d.ts +48 -0
- package/dist/do-runner/resume-ledger.d.ts.map +1 -0
- package/dist/do-runner/resume-ledger.js +59 -0
- package/dist/do-runner/resume-ledger.js.map +1 -0
- package/dist/do-runner/runtime.d.ts +161 -0
- package/dist/do-runner/runtime.d.ts.map +1 -0
- package/dist/do-runner/runtime.js +509 -0
- package/dist/do-runner/runtime.js.map +1 -0
- package/dist/host-kit/approval-bridge.d.ts +109 -0
- package/dist/host-kit/approval-bridge.d.ts.map +1 -0
- package/dist/host-kit/approval-bridge.js +262 -0
- package/dist/host-kit/approval-bridge.js.map +1 -0
- package/dist/host-kit/bearer-auth.d.ts +19 -0
- package/dist/host-kit/bearer-auth.d.ts.map +1 -0
- package/dist/host-kit/bearer-auth.js +67 -0
- package/dist/host-kit/bearer-auth.js.map +1 -0
- package/dist/host-kit/do-response.d.ts +13 -0
- package/dist/host-kit/do-response.d.ts.map +1 -0
- package/dist/host-kit/do-response.js +24 -0
- package/dist/host-kit/do-response.js.map +1 -0
- package/dist/host-kit/do-run-topology.d.ts +32 -0
- package/dist/host-kit/do-run-topology.d.ts.map +1 -0
- package/dist/host-kit/do-run-topology.js +39 -0
- package/dist/host-kit/do-run-topology.js.map +1 -0
- package/dist/host-kit/env-vars.d.ts +26 -0
- package/dist/host-kit/env-vars.d.ts.map +1 -0
- package/dist/host-kit/env-vars.js +48 -0
- package/dist/host-kit/env-vars.js.map +1 -0
- package/dist/host-kit/host-approval-service.d.ts +125 -0
- package/dist/host-kit/host-approval-service.d.ts.map +1 -0
- package/dist/host-kit/host-approval-service.js +187 -0
- package/dist/host-kit/host-approval-service.js.map +1 -0
- package/dist/host-kit/index.d.ts +18 -0
- package/dist/host-kit/index.d.ts.map +1 -0
- package/dist/host-kit/index.js +34 -0
- package/dist/host-kit/index.js.map +1 -0
- package/dist/host-kit/module.d.ts +34 -0
- package/dist/host-kit/module.d.ts.map +1 -0
- package/dist/host-kit/module.js +17 -0
- package/dist/host-kit/module.js.map +1 -0
- package/dist/host-kit/registration.d.ts +11 -0
- package/dist/host-kit/registration.d.ts.map +1 -0
- package/dist/host-kit/registration.js +21 -0
- package/dist/host-kit/registration.js.map +1 -0
- package/dist/host-kit/run-route-error.d.ts +11 -0
- package/dist/host-kit/run-route-error.d.ts.map +1 -0
- package/dist/host-kit/run-route-error.js +22 -0
- package/dist/host-kit/run-route-error.js.map +1 -0
- package/dist/host-kit/run-router.d.ts +60 -0
- package/dist/host-kit/run-router.d.ts.map +1 -0
- package/dist/host-kit/run-router.js +212 -0
- package/dist/host-kit/run-router.js.map +1 -0
- package/dist/host-kit/subdomain-check.d.ts +23 -0
- package/dist/host-kit/subdomain-check.d.ts.map +1 -0
- package/dist/host-kit/subdomain-check.js +60 -0
- package/dist/host-kit/subdomain-check.js.map +1 -0
- package/dist/host-kit/tenant-registry.d.ts +51 -0
- package/dist/host-kit/tenant-registry.d.ts.map +1 -0
- package/dist/host-kit/tenant-registry.js +87 -0
- package/dist/host-kit/tenant-registry.js.map +1 -0
- package/dist/host-kit/verifier.d.ts +63 -0
- package/dist/host-kit/verifier.d.ts.map +1 -0
- package/dist/host-kit/verifier.js +191 -0
- package/dist/host-kit/verifier.js.map +1 -0
- package/dist/host-kit/workflow-meta.d.ts +25 -0
- package/dist/host-kit/workflow-meta.d.ts.map +1 -0
- package/dist/host-kit/workflow-meta.js +12 -0
- package/dist/host-kit/workflow-meta.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/package.json +95 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MetricsView.d.ts","sourceRoot":"","sources":["../../src/approval-ui/MetricsView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAKhE,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;CACjC;AAED,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,EAAE,gBAAgB,GAAG,GAAG,CAAC,OAAO,CAuBtE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useApprovalUIComponents } from './components.js';
|
|
3
|
+
import { APPROVAL_TIPS } from './tips.js';
|
|
4
|
+
import { formatResolution } from './view-model.js';
|
|
5
|
+
export function MetricsView({ metrics }) {
|
|
6
|
+
const C = useApprovalUIComponents();
|
|
7
|
+
if (!metrics)
|
|
8
|
+
return _jsx(C.Spinner, { label: "Loading metrics\u2026" });
|
|
9
|
+
// MetricLabel pins each label to an APPROVAL_TIPS.metrics entry at compile
|
|
10
|
+
// time, so a renamed metric cannot silently lose its tip.
|
|
11
|
+
const cells = [
|
|
12
|
+
['Open', metrics.openCount],
|
|
13
|
+
['SLA breached', metrics.slaBreachedCount],
|
|
14
|
+
['Escalations', metrics.escalationCount],
|
|
15
|
+
['Decided', metrics.decidedCount],
|
|
16
|
+
['Approved', metrics.approvedCount],
|
|
17
|
+
['Rejected', metrics.rejectedCount],
|
|
18
|
+
['Avg resolution', formatResolution(metrics.avgResolutionSeconds)],
|
|
19
|
+
];
|
|
20
|
+
return (_jsx(C.MetadataList, { children: cells.map(([label, value]) => (_jsx(C.MetadataItem, { label: label, children: _jsx(C.InfoTip, { label: value, tip: APPROVAL_TIPS.metrics[label] }) }, label))) }));
|
|
21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,GAAI,IAD3C,KAAK,CAET,CAClB,CAAC,GACa,CAClB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { JSX } from 'react';
|
|
2
|
+
import type { ApprovalRecord } from '../approval-api/types.js';
|
|
3
|
+
export interface QueueViewProps {
|
|
4
|
+
/** Pre-sorted (the dashboard hook applies sortQueue). */
|
|
5
|
+
records: readonly ApprovalRecord[];
|
|
6
|
+
nowMs: number;
|
|
7
|
+
selectedId: string | null;
|
|
8
|
+
onSelect: (id: string) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function QueueView({ records, nowMs, selectedId, onSelect, }: QueueViewProps): JSX.Element;
|
|
11
|
+
//# sourceMappingURL=QueueView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueueView.d.ts","sourceRoot":"","sources":["../../src/approval-ui/QueueView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,KAAK,EAEV,cAAc,EAEf,MAAM,0BAA0B,CAAC;AA+BlC,MAAM,WAAW,cAAc;IAC7B,yDAAyD;IACzD,OAAO,EAAE,SAAS,cAAc,EAAE,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC;AAED,wBAAgB,SAAS,CAAC,EACxB,OAAO,EACP,KAAK,EACL,UAAU,EACV,QAAQ,GACT,EAAE,cAAc,GAAG,GAAG,CAAC,OAAO,CAoE9B"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useApprovalUIComponents, } from './components.js';
|
|
3
|
+
import { APPROVAL_TIPS } from './tips.js';
|
|
4
|
+
import { formatSlaCountdown, slaStateOf } from './view-model.js';
|
|
5
|
+
const STATUS_TONE = {
|
|
6
|
+
pending: 'neutral',
|
|
7
|
+
claimed: 'info',
|
|
8
|
+
approved: 'success',
|
|
9
|
+
rejected: 'danger',
|
|
10
|
+
escalated: 'warning',
|
|
11
|
+
};
|
|
12
|
+
const SLA_TONE = {
|
|
13
|
+
none: 'neutral',
|
|
14
|
+
ok: 'success',
|
|
15
|
+
warning: 'warning',
|
|
16
|
+
breached: 'danger',
|
|
17
|
+
};
|
|
18
|
+
const PRIORITY_TONE = {
|
|
19
|
+
critical: 'danger',
|
|
20
|
+
high: 'warning',
|
|
21
|
+
normal: 'neutral',
|
|
22
|
+
low: 'neutral',
|
|
23
|
+
};
|
|
24
|
+
export function QueueView({ records, nowMs, selectedId, onSelect, }) {
|
|
25
|
+
const C = useApprovalUIComponents();
|
|
26
|
+
// Selection lives in the Title cell: a focusable button per row keeps the
|
|
27
|
+
// queue keyboard-navigable regardless of the injected Table implementation.
|
|
28
|
+
const columns = [
|
|
29
|
+
{
|
|
30
|
+
key: 'title',
|
|
31
|
+
header: 'Title',
|
|
32
|
+
renderCell: (record) => (_jsx(C.Button, { label: record.title, variant: record.id === selectedId ? 'secondary' : 'ghost', pressed: record.id === selectedId, onClick: () => onSelect(record.id) })),
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
key: 'run',
|
|
36
|
+
header: 'Workflow',
|
|
37
|
+
renderCell: (record) => `${record.workflowId}/${record.runId}`,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
key: 'priority',
|
|
41
|
+
header: _jsx(C.InfoTip, { label: "Priority", tip: APPROVAL_TIPS.priority }),
|
|
42
|
+
renderCell: (record) => (_jsx(C.Badge, { tone: PRIORITY_TONE[record.priority], label: record.priority })),
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
key: 'status',
|
|
46
|
+
header: _jsx(C.InfoTip, { label: "Status", tip: APPROVAL_TIPS.statusColumn }),
|
|
47
|
+
renderCell: (record) => (_jsx(C.Badge, { tone: STATUS_TONE[record.status], label: record.status })),
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
key: 'sla',
|
|
51
|
+
header: _jsx(C.InfoTip, { label: "SLA", tip: APPROVAL_TIPS.sla }),
|
|
52
|
+
renderCell: (record) => (_jsx(C.Badge, { tone: SLA_TONE[slaStateOf(record, nowMs)], label: formatSlaCountdown(record, nowMs) })),
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
// aria-label gives the queue table an accessible name (replacing the old
|
|
56
|
+
// <caption>) — a <table> supports naming via its implicit role.
|
|
57
|
+
return (_jsx(C.Table, { "aria-label": "Approval queue", data: records, columns: columns, idKey: "id", emptyState: _jsx(C.EmptyState, { title: "No approval requests.", description: "Launch a workflow; a suspension queues its approval request here." }) }));
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=QueueView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueueView.js","sourceRoot":"","sources":["../../src/approval-ui/QueueView.tsx"],"names":[],"mappings":";AAOA,OAAO,EAGL,uBAAuB,GACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAiB,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEhF,MAAM,WAAW,GAAiC;IAChD,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,MAAM;IACf,QAAQ,EAAE,SAAS;IACnB,QAAQ,EAAE,QAAQ;IAClB,SAAS,EAAE,SAAS;CACrB,CAAC;AAEF,MAAM,QAAQ,GAA2B;IACvC,IAAI,EAAE,SAAS;IACf,EAAE,EAAE,SAAS;IACb,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,QAAQ;CACnB,CAAC;AAEF,MAAM,aAAa,GAAmC;IACpD,QAAQ,EAAE,QAAQ;IAClB,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,SAAS;IACjB,GAAG,EAAE,SAAS;CACf,CAAC;AAU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AAE,CAAC,CACtB,KAAC,CAAC,CAAC,KAAK,IAAC,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,GAAI,CACpE;SACF;QACD;YACE,GAAG,EAAE,KAAK;YACV,MAAM,EAAE,KAAC,CAAC,CAAC,OAAO,IAAC,KAAK,EAAC,KAAK,EAAC,GAAG,EAAE,aAAa,CAAC,GAAG,GAAI;YACzD,UAAU,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CACtB,KAAC,CAAC,CAAC,KAAK,IACN,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,EACzC,KAAK,EAAE,kBAAkB,CAAC,MAAM,EAAE,KAAK,CAAC,GACxC,CACH;SACF;KACF,CAAC;IAEF,yEAAyE;IACzE,gEAAgE;IAChE,OAAO,CACL,KAAC,CAAC,CAAC,KAAK,kBACK,gBAAgB,EAC3B,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,OAAO,EAChB,KAAK,EAAC,IAAI,EACV,UAAU,EACR,KAAC,CAAC,CAAC,UAAU,IACX,KAAK,EAAC,uBAAuB,EAC7B,WAAW,EAAC,mEAAmE,GAC/E,GAEJ,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ApprovalDecision, ApprovalListFilter, ApprovalMetrics, ApprovalRecord, DecideResult } from '../approval-api/types.js';
|
|
2
|
+
export interface ResponseLike {
|
|
3
|
+
ok: boolean;
|
|
4
|
+
status: number;
|
|
5
|
+
json(): Promise<unknown>;
|
|
6
|
+
}
|
|
7
|
+
export type FetchLike = (url: string, init?: {
|
|
8
|
+
method?: string;
|
|
9
|
+
headers?: Record<string, string>;
|
|
10
|
+
body?: string;
|
|
11
|
+
}) => Promise<ResponseLike>;
|
|
12
|
+
export declare class ApprovalApiError extends Error {
|
|
13
|
+
readonly status: number;
|
|
14
|
+
constructor(status: number, message: string);
|
|
15
|
+
}
|
|
16
|
+
export interface ApprovalApiClientOptions {
|
|
17
|
+
/** Default: '/api/approvals' (same-origin deployment). */
|
|
18
|
+
baseUrl?: string;
|
|
19
|
+
/** Default: globalThis.fetch. Injected in tests and non-browser hosts. */
|
|
20
|
+
fetch?: FetchLike;
|
|
21
|
+
/** Sent on every request — the deployment's auth (bearer token, etc.). */
|
|
22
|
+
headers?: Record<string, string>;
|
|
23
|
+
}
|
|
24
|
+
export declare class ApprovalApiClient {
|
|
25
|
+
#private;
|
|
26
|
+
constructor(options?: ApprovalApiClientOptions);
|
|
27
|
+
list(filter?: ApprovalListFilter): Promise<ApprovalRecord[]>;
|
|
28
|
+
get(id: string): Promise<ApprovalRecord>;
|
|
29
|
+
metrics(): Promise<ApprovalMetrics>;
|
|
30
|
+
claim(id: string): Promise<ApprovalRecord>;
|
|
31
|
+
decide(id: string, decision: ApprovalDecision, comment?: string): Promise<DecideResult>;
|
|
32
|
+
delegate(id: string, to: string): Promise<ApprovalRecord>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/approval-ui/client.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,YAAY,EACb,MAAM,0BAA0B,CAAC;AAElC,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1B;AAED,MAAM,MAAM,SAAS,GAAG,CACtB,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE;IACL,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,KACE,OAAO,CAAC,YAAY,CAAC,CAAC;AAE3B,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK5C;AAED,MAAM,WAAW,wBAAwB;IACvC,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0EAA0E;IAC1E,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,qBAAa,iBAAiB;;gBAKhB,OAAO,GAAE,wBAA6B;IAa5C,IAAI,CAAC,MAAM,GAAE,kBAAuB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAoBhE,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAMxC,OAAO,IAAI,OAAO,CAAC,eAAe,CAAC;IAInC,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAM1C,MAAM,CACV,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,YAAY,CAAC;IASlB,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;CA8ChE"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// REST client for the approval API. Deliberately DOM-free: fetch is injected
|
|
2
|
+
// behind a minimal structural type, so this file typechecks in the main
|
|
3
|
+
// (workers-types) pass, tests run it in plain node, and the browser gets the
|
|
4
|
+
// global fetch by default. Types come straight from approval-api — the wire
|
|
5
|
+
// format IS those types serialized.
|
|
6
|
+
export class ApprovalApiError extends Error {
|
|
7
|
+
status;
|
|
8
|
+
constructor(status, message) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = 'ApprovalApiError';
|
|
11
|
+
this.status = status;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export class ApprovalApiClient {
|
|
15
|
+
#baseUrl;
|
|
16
|
+
#fetch;
|
|
17
|
+
#headers;
|
|
18
|
+
constructor(options = {}) {
|
|
19
|
+
this.#baseUrl = options.baseUrl ?? '/api/approvals';
|
|
20
|
+
const fetchFn = options.fetch ??
|
|
21
|
+
globalThis.fetch;
|
|
22
|
+
if (!fetchFn) {
|
|
23
|
+
throw new Error('ApprovalApiClient: no fetch available; pass one');
|
|
24
|
+
}
|
|
25
|
+
// Global fetch must be invoked without a bound `this` complaint.
|
|
26
|
+
this.#fetch = (url, init) => fetchFn(url, init);
|
|
27
|
+
this.#headers = { ...options.headers };
|
|
28
|
+
}
|
|
29
|
+
async list(filter = {}) {
|
|
30
|
+
const params = new URLSearchParams();
|
|
31
|
+
if (filter.status !== undefined) {
|
|
32
|
+
const statuses = Array.isArray(filter.status)
|
|
33
|
+
? filter.status
|
|
34
|
+
: [filter.status];
|
|
35
|
+
params.set('status', statuses.join(','));
|
|
36
|
+
}
|
|
37
|
+
if (filter.workflowId !== undefined)
|
|
38
|
+
params.set('workflowId', filter.workflowId);
|
|
39
|
+
if (filter.runId !== undefined)
|
|
40
|
+
params.set('runId', filter.runId);
|
|
41
|
+
if (filter.claimedBy !== undefined)
|
|
42
|
+
params.set('claimedBy', filter.claimedBy);
|
|
43
|
+
if (filter.limit !== undefined)
|
|
44
|
+
params.set('limit', String(filter.limit));
|
|
45
|
+
if (filter.after !== undefined)
|
|
46
|
+
params.set('after', filter.after);
|
|
47
|
+
if (filter.orderBy !== undefined)
|
|
48
|
+
params.set('orderBy', filter.orderBy);
|
|
49
|
+
const query = params.size > 0 ? `?${params.toString()}` : '';
|
|
50
|
+
return (await this.#request(query));
|
|
51
|
+
}
|
|
52
|
+
async get(id) {
|
|
53
|
+
return (await this.#request(`/${encodeURIComponent(id)}`));
|
|
54
|
+
}
|
|
55
|
+
async metrics() {
|
|
56
|
+
return (await this.#request('/metrics'));
|
|
57
|
+
}
|
|
58
|
+
async claim(id) {
|
|
59
|
+
return (await this.#post(`/${encodeURIComponent(id)}/claim`));
|
|
60
|
+
}
|
|
61
|
+
async decide(id, decision, comment) {
|
|
62
|
+
const body = { decision };
|
|
63
|
+
if (comment !== undefined && comment !== '')
|
|
64
|
+
body.comment = comment;
|
|
65
|
+
return (await this.#post(`/${encodeURIComponent(id)}/decide`, body));
|
|
66
|
+
}
|
|
67
|
+
async delegate(id, to) {
|
|
68
|
+
return (await this.#post(`/${encodeURIComponent(id)}/delegate`, {
|
|
69
|
+
to,
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
// There is deliberately no sweep() — POST /sla/sweep no longer exists. The
|
|
73
|
+
// SLA sweep is cron-owned TCB code (approval-api sweepSLA over a
|
|
74
|
+
// SystemApprovalStore): an HTTP-reachable sweep was an unfiltered
|
|
75
|
+
// cross-tenant read+write behind a role check.
|
|
76
|
+
async #post(path, body) {
|
|
77
|
+
return this.#request(path, {
|
|
78
|
+
method: 'POST',
|
|
79
|
+
...(body !== undefined && {
|
|
80
|
+
headers: { 'content-type': 'application/json' },
|
|
81
|
+
body: JSON.stringify(body),
|
|
82
|
+
}),
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
async #request(path, init = {}) {
|
|
86
|
+
const response = await this.#fetch(`${this.#baseUrl}${path}`, {
|
|
87
|
+
...init,
|
|
88
|
+
headers: { ...this.#headers, ...init.headers },
|
|
89
|
+
});
|
|
90
|
+
const payload = await response.json().catch(() => undefined);
|
|
91
|
+
if (!response.ok) {
|
|
92
|
+
const message = payload !== null &&
|
|
93
|
+
typeof payload === 'object' &&
|
|
94
|
+
'error' in payload &&
|
|
95
|
+
typeof payload.error === 'string'
|
|
96
|
+
? payload.error
|
|
97
|
+
: `request failed with status ${response.status}`;
|
|
98
|
+
throw new ApprovalApiError(response.status, message);
|
|
99
|
+
}
|
|
100
|
+
return payload;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/approval-ui/client.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,wEAAwE;AACxE,6EAA6E;AAC7E,4EAA4E;AAC5E,oCAAoC;AAyBpC,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAChC,MAAM,CAAS;IAExB,YAAY,MAAc,EAAE,OAAe;QACzC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAWD,MAAM,OAAO,iBAAiB;IACnB,QAAQ,CAAS;IACjB,MAAM,CAAY;IAClB,QAAQ,CAAyB;IAE1C,YAAY,UAAoC,EAAE;QAChD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,OAAO,IAAI,gBAAgB,CAAC;QACpD,MAAM,OAAO,GACX,OAAO,CAAC,KAAK;YACX,UAAkC,CAAC,KAA+B,CAAC;QACvE,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACrE,CAAC;QACD,iEAAiE;QACjE,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAChD,IAAI,CAAC,QAAQ,GAAG,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,SAA6B,EAAE;QACxC,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;QACrC,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAChC,MAAM,QAAQ,GAAG,KAAK,CAA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H,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,QAAQ,CACZ,IAAY,EACZ,OAII,EAAE;QAEN,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,GAAG,IAAI,EAAE,EAAE;YAC5D,GAAG,IAAI;YACP,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE;SAC/C,CAAC,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,OAAO,GACX,OAAO,KAAK,IAAI;gBAChB,OAAO,OAAO,KAAK,QAAQ;gBAC3B,OAAO,IAAI,OAAO;gBAClB,OAAQ,OAA8B,CAAC,KAAK,KAAK,QAAQ;gBACvD,CAAC,CAAE,OAA6B,CAAC,KAAK;gBACtC,CAAC,CAAC,8BAA8B,QAAQ,CAAC,MAAM,EAAE,CAAC;YACtD,MAAM,IAAI,gBAAgB,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACvD,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { type JSX, type ReactNode } from 'react';
|
|
2
|
+
import type { ApprovalRecord } from '../approval-api/types.js';
|
|
3
|
+
export type Tone = 'neutral' | 'info' | 'success' | 'warning' | 'danger';
|
|
4
|
+
export type StackDirection = 'vertical' | 'horizontal';
|
|
5
|
+
export type StackGap = 'sm' | 'md' | 'lg';
|
|
6
|
+
export type ButtonVariant = 'primary' | 'secondary' | 'danger' | 'ghost';
|
|
7
|
+
export interface StackProps {
|
|
8
|
+
direction?: StackDirection;
|
|
9
|
+
gap?: StackGap;
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
export interface SectionProps {
|
|
13
|
+
'aria-label'?: string;
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
}
|
|
16
|
+
export interface HeadingProps {
|
|
17
|
+
level: 1 | 2;
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
}
|
|
20
|
+
export interface TextProps {
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
}
|
|
23
|
+
export interface ButtonProps {
|
|
24
|
+
label: string;
|
|
25
|
+
onClick?: () => void;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
variant?: ButtonVariant;
|
|
28
|
+
type?: 'button' | 'submit';
|
|
29
|
+
/** Conveys selection to assistive tech for toggle-like buttons. */
|
|
30
|
+
pressed?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface BadgeProps {
|
|
33
|
+
label: ReactNode;
|
|
34
|
+
tone?: Tone;
|
|
35
|
+
}
|
|
36
|
+
export interface BannerProps {
|
|
37
|
+
tone: Tone;
|
|
38
|
+
title: ReactNode;
|
|
39
|
+
}
|
|
40
|
+
export interface TextFieldProps {
|
|
41
|
+
label: string;
|
|
42
|
+
value: string;
|
|
43
|
+
onChange: (value: string) => void;
|
|
44
|
+
placeholder?: string;
|
|
45
|
+
disabled?: boolean;
|
|
46
|
+
/** Renders a multiline control (textarea) when set. */
|
|
47
|
+
rows?: number;
|
|
48
|
+
/** Fires on Enter for single-line inputs. */
|
|
49
|
+
onSubmit?: () => void;
|
|
50
|
+
}
|
|
51
|
+
export interface MetadataListProps {
|
|
52
|
+
children: ReactNode;
|
|
53
|
+
}
|
|
54
|
+
export interface MetadataItemProps {
|
|
55
|
+
label: string;
|
|
56
|
+
children: ReactNode;
|
|
57
|
+
}
|
|
58
|
+
export interface CodeProps {
|
|
59
|
+
code: string;
|
|
60
|
+
language?: string;
|
|
61
|
+
}
|
|
62
|
+
export interface EmptyStateProps {
|
|
63
|
+
title: string;
|
|
64
|
+
/** Optional supporting line (what fills this view, or what to do next). */
|
|
65
|
+
description?: string;
|
|
66
|
+
}
|
|
67
|
+
export interface SpinnerProps {
|
|
68
|
+
label?: string;
|
|
69
|
+
}
|
|
70
|
+
export interface InfoTipProps {
|
|
71
|
+
/** The visible content the tip explains (a term, a value, a header). */
|
|
72
|
+
label: ReactNode;
|
|
73
|
+
/** Plain-text explanation, shown on hover/focus. */
|
|
74
|
+
tip: string;
|
|
75
|
+
}
|
|
76
|
+
export interface ApprovalColumn {
|
|
77
|
+
key: string;
|
|
78
|
+
/**
|
|
79
|
+
* ReactNode (not string) so headers can carry an InfoTip. A custom Table
|
|
80
|
+
* slot doing string operations on `header` must render it as a node instead.
|
|
81
|
+
*/
|
|
82
|
+
header: ReactNode;
|
|
83
|
+
renderCell: (record: ApprovalRecord) => ReactNode;
|
|
84
|
+
}
|
|
85
|
+
export interface TableProps {
|
|
86
|
+
data: readonly ApprovalRecord[];
|
|
87
|
+
columns: readonly ApprovalColumn[];
|
|
88
|
+
/** Property naming each row's stable id (React keys). */
|
|
89
|
+
idKey: keyof ApprovalRecord & string;
|
|
90
|
+
emptyState?: ReactNode;
|
|
91
|
+
/** Accessible name for the table (a `<table>` supports naming via its role). */
|
|
92
|
+
'aria-label'?: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Every slot approval-ui renders through. Supply a full or partial map to
|
|
96
|
+
* <ApprovalUIProvider>; omitted slots fall back to `htmlComponents`. The Table
|
|
97
|
+
* is typed to ApprovalRecord rows on purpose — this contract styles one
|
|
98
|
+
* dashboard, it is not a general-purpose UI kit.
|
|
99
|
+
*/
|
|
100
|
+
export interface ApprovalUIComponents {
|
|
101
|
+
Stack: (props: StackProps) => ReactNode;
|
|
102
|
+
Section: (props: SectionProps) => ReactNode;
|
|
103
|
+
Heading: (props: HeadingProps) => ReactNode;
|
|
104
|
+
Text: (props: TextProps) => ReactNode;
|
|
105
|
+
Button: (props: ButtonProps) => ReactNode;
|
|
106
|
+
Badge: (props: BadgeProps) => ReactNode;
|
|
107
|
+
Banner: (props: BannerProps) => ReactNode;
|
|
108
|
+
TextField: (props: TextFieldProps) => ReactNode;
|
|
109
|
+
MetadataList: (props: MetadataListProps) => ReactNode;
|
|
110
|
+
MetadataItem: (props: MetadataItemProps) => ReactNode;
|
|
111
|
+
Code: (props: CodeProps) => ReactNode;
|
|
112
|
+
EmptyState: (props: EmptyStateProps) => ReactNode;
|
|
113
|
+
Spinner: (props: SpinnerProps) => ReactNode;
|
|
114
|
+
InfoTip: (props: InfoTipProps) => ReactNode;
|
|
115
|
+
Table: (props: TableProps) => ReactNode;
|
|
116
|
+
}
|
|
117
|
+
export declare const htmlComponents: ApprovalUIComponents;
|
|
118
|
+
export interface ApprovalUIProviderProps {
|
|
119
|
+
/** Override any subset of slots; the rest fall back to `htmlComponents`. */
|
|
120
|
+
components?: Partial<ApprovalUIComponents>;
|
|
121
|
+
children: ReactNode;
|
|
122
|
+
}
|
|
123
|
+
export declare function ApprovalUIProvider({ components, children, }: ApprovalUIProviderProps): JSX.Element;
|
|
124
|
+
export declare function useApprovalUIComponents(): ApprovalUIComponents;
|
|
125
|
+
//# sourceMappingURL=components.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/approval-ui/components.tsx"],"names":[],"mappings":"AAOA,OAAO,EAEL,KAAK,GAAG,EACR,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,MAAM,MAAM,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AACzE,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,YAAY,CAAC;AACvD,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAC1C,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEzE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EAAE,WAAW,KAAK,SAAS,CAAC;IAC1C,KAAK,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,SAAS,CAAC;IACxC,MAAM,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,SAAS,CAAC;IAC1C,SAAS,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,SAAS,CAAC;IAChD,YAAY,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,SAAS,CAAC;IACtD,YAAY,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,SAAS,CAAC;IACtD,IAAI,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,SAAS,CAAC;IACtC,UAAU,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,SAAS,CAAC;IAClD,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,SAAS,CAAC;IAC5C,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,SAAS,CAAC;IAC5C,KAAK,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,SAAS,CAAC;CACzC;AAwCD,eAAO,MAAM,cAAc,EAAE,oBAqH5B,CAAC;AAMF,MAAM,WAAW,uBAAuB;IACtC,4EAA4E;IAC5E,UAAU,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC3C,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,kBAAkB,CAAC,EACjC,UAAU,EACV,QAAQ,GACT,EAAE,uBAAuB,GAAG,GAAG,CAAC,OAAO,CAUvC;AAED,wBAAgB,uBAAuB,IAAI,oBAAoB,CAE9D"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// The styling contract. approval-ui renders every visual primitive through
|
|
3
|
+
// these slots, so an importer supplies their own design-system components
|
|
4
|
+
// (Astryx, MUI, Chakra, …) via <ApprovalUIProvider>. A plain-HTML default
|
|
5
|
+
// (`htmlComponents`) ships below — the dashboard works unstyled with zero
|
|
6
|
+
// config, and CSS-only consumers can target the `flowsafe-*` class hooks. This
|
|
7
|
+
// is the react-select / react-markdown / MDX `components` pattern.
|
|
8
|
+
import { createContext, useContext, useId, useMemo, } from 'react';
|
|
9
|
+
// ---- Plain-HTML default adapter -------------------------------------------
|
|
10
|
+
// Semantic markup + `flowsafe-*` class hooks, no CSS. Functional out of the
|
|
11
|
+
// box; style via CSS, or replace slots with a design-system adapter.
|
|
12
|
+
function HtmlTable({ data, columns, idKey, emptyState, 'aria-label': ariaLabel, }) {
|
|
13
|
+
if (data.length === 0 && emptyState !== undefined) {
|
|
14
|
+
return _jsx(_Fragment, { children: emptyState });
|
|
15
|
+
}
|
|
16
|
+
return (_jsxs("table", { className: "flowsafe-table", "aria-label": ariaLabel, children: [_jsx("thead", { children: _jsx("tr", { children: columns.map((column) => (_jsx("th", { scope: "col", children: column.header }, column.key))) }) }), _jsx("tbody", { children: data.map((record) => (_jsx("tr", { children: columns.map((column) => (_jsx("td", { children: column.renderCell(record) }, column.key))) }, String(record[idKey])))) })] }));
|
|
17
|
+
}
|
|
18
|
+
export const htmlComponents = {
|
|
19
|
+
Stack: ({ direction = 'vertical', gap = 'md', children }) => (_jsx("div", { className: `flowsafe-stack flowsafe-stack-${direction} flowsafe-gap-${gap}`, children: children })),
|
|
20
|
+
Section: ({ 'aria-label': ariaLabel, children }) => (_jsx("section", { className: "flowsafe-section", "aria-label": ariaLabel, children: children })),
|
|
21
|
+
Heading: ({ level, children }) => level === 1 ? (_jsx("h1", { className: "flowsafe-heading", children: children })) : (_jsx("h2", { className: "flowsafe-heading", children: children })),
|
|
22
|
+
Text: ({ children }) => _jsx("p", { className: "flowsafe-text", children: children }),
|
|
23
|
+
Button: ({ label, onClick, disabled, variant = 'secondary', type = 'button', pressed, }) => (_jsx("button", { type: type, className: `flowsafe-button flowsafe-button-${variant}`, onClick: onClick, disabled: disabled, "aria-pressed": pressed, children: label })),
|
|
24
|
+
Badge: ({ label, tone = 'neutral' }) => (_jsx("span", { className: `flowsafe-badge flowsafe-tone-${tone}`, children: label })),
|
|
25
|
+
Banner: ({ tone, title }) => (_jsx("p", { role: "alert", className: `flowsafe-banner flowsafe-tone-${tone}`, children: title })),
|
|
26
|
+
TextField: ({ label, value, onChange, placeholder, disabled, rows, onSubmit, }) => {
|
|
27
|
+
// useId associates the label with the control (satisfies a11y and lets
|
|
28
|
+
// the ternary pick textarea vs input without breaking the association).
|
|
29
|
+
const id = useId();
|
|
30
|
+
return (_jsxs("div", { className: "flowsafe-field", children: [_jsx("label", { htmlFor: id, children: label }), rows !== undefined ? (_jsx("textarea", { id: id, className: "flowsafe-textarea", value: value, rows: rows, disabled: disabled, placeholder: placeholder, onChange: (event) => onChange(event.currentTarget.value) })) : (_jsx("input", { id: id, className: "flowsafe-input", value: value, disabled: disabled, placeholder: placeholder, onChange: (event) => onChange(event.currentTarget.value), onKeyDown: (event) => {
|
|
31
|
+
if (event.key === 'Enter' && onSubmit) {
|
|
32
|
+
event.preventDefault();
|
|
33
|
+
onSubmit();
|
|
34
|
+
}
|
|
35
|
+
} }))] }));
|
|
36
|
+
},
|
|
37
|
+
MetadataList: ({ children }) => (_jsx("dl", { className: "flowsafe-metadata", children: children })),
|
|
38
|
+
MetadataItem: ({ label, children }) => (_jsxs("div", { className: "flowsafe-metadata-item", children: [_jsx("dt", { children: label }), _jsx("dd", { children: children })] })),
|
|
39
|
+
Code: ({ code }) => _jsx("pre", { className: "flowsafe-code", children: code }),
|
|
40
|
+
EmptyState: ({ title, description }) => (_jsxs("div", { className: "flowsafe-empty", children: [_jsx("p", { className: "flowsafe-empty-title", children: title }), description !== undefined ? (_jsx("p", { className: "flowsafe-empty-description", children: description })) : null] })),
|
|
41
|
+
Spinner: ({ label }) => (_jsx("output", { className: "flowsafe-spinner", children: label ?? 'Loading…' })),
|
|
42
|
+
InfoTip: ({ label, tip }) => (_jsx("span", { className: "flowsafe-infotip", title: tip, children: label })),
|
|
43
|
+
Table: HtmlTable,
|
|
44
|
+
};
|
|
45
|
+
// ---- Injection seam --------------------------------------------------------
|
|
46
|
+
const ApprovalUIContext = createContext(htmlComponents);
|
|
47
|
+
export function ApprovalUIProvider({ components, children, }) {
|
|
48
|
+
const merged = useMemo(() => ({ ...htmlComponents, ...components }), [components]);
|
|
49
|
+
return (_jsx(ApprovalUIContext.Provider, { value: merged, children: children }));
|
|
50
|
+
}
|
|
51
|
+
export function useApprovalUIComponents() {
|
|
52
|
+
return useContext(ApprovalUIContext);
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=components.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../src/approval-ui/components.tsx"],"names":[],"mappings":";AAAA,2EAA2E;AAC3E,0EAA0E;AAC1E,0EAA0E;AAC1E,0EAA0E;AAC1E,+EAA+E;AAC/E,mEAAmE;AAEnE,OAAO,EACL,aAAa,EAGb,UAAU,EACV,KAAK,EACL,OAAO,GACR,MAAM,OAAO,CAAC;AAyHf,8EAA8E;AAC9E,4EAA4E;AAC5E,qEAAqE;AAErE,SAAS,SAAS,CAAC,EACjB,IAAI,EACJ,OAAO,EACP,KAAK,EACL,UAAU,EACV,YAAY,EAAE,SAAS,GACZ;IACX,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAClD,OAAO,4BAAG,UAAU,GAAI,CAAC;IAC3B,CAAC;IACD,OAAO,CACL,iBAAO,SAAS,EAAC,gBAAgB,gBAAa,SAAS,aACrD,0BACE,uBACG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACvB,aAAqB,KAAK,EAAC,KAAK,YAC7B,MAAM,CAAC,MAAM,IADP,MAAM,CAAC,GAAG,CAEd,CACN,CAAC,GACC,GACC,EACR,0BACG,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACpB,uBACG,OAAO,CAA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AAuB,cAAc,CAAC,CAAC;AAQ9E,MAAM,UAAU,kBAAkB,CAAC,EACjC,UAAU,EACV,QAAQ,GACgB;IACxB,MAAM,MAAM,GAAG,OAAO,CACpB,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,cAAc,EAAE,GAAG,UAAU,EAAE,CAAC,EAC5C,CAAC,UAAU,CAAC,CACb,CAAC;IACF,OAAO,CACL,KAAC,iBAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,MAAM,YACtC,QAAQ,GACkB,CAC9B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,uBAAuB;IACrC,OAAO,UAAU,CAAC,iBAAiB,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type { ApprovalDashboardProps } from './App.js';
|
|
2
|
+
export { App } from './App.js';
|
|
3
|
+
export type { ApprovalApiClientOptions, FetchLike, ResponseLike, } from './client.js';
|
|
4
|
+
export { ApprovalApiClient, ApprovalApiError, } from './client.js';
|
|
5
|
+
export type { ApprovalColumn, ApprovalUIComponents, ApprovalUIProviderProps, BadgeProps, BannerProps, ButtonProps, ButtonVariant, CodeProps, EmptyStateProps, HeadingProps, InfoTipProps, MetadataItemProps, MetadataListProps, SectionProps, SpinnerProps, StackDirection, StackGap, StackProps, TableProps, TextFieldProps, TextProps, Tone, } from './components.js';
|
|
6
|
+
export { ApprovalUIProvider, htmlComponents, useApprovalUIComponents, } from './components.js';
|
|
7
|
+
export type { DetailViewProps } from './DetailView.js';
|
|
8
|
+
export { DetailView } from './DetailView.js';
|
|
9
|
+
export type { MetricsViewProps } from './MetricsView.js';
|
|
10
|
+
export { MetricsView } from './MetricsView.js';
|
|
11
|
+
export type { CreateApprovalDashboardOptions } from './mount.js';
|
|
12
|
+
export { createApprovalDashboard } from './mount.js';
|
|
13
|
+
export type { QueueViewProps } from './QueueView.js';
|
|
14
|
+
export { QueueView } from './QueueView.js';
|
|
15
|
+
export type { MetricLabel } from './tips.js';
|
|
16
|
+
export { APPROVAL_TIPS } from './tips.js';
|
|
17
|
+
export type { ApprovalDashboardState, UseApprovalDashboardOptions, } from './use-approval-dashboard.js';
|
|
18
|
+
export { useApprovalDashboard } from './use-approval-dashboard.js';
|
|
19
|
+
export type { SlaState } from './view-model.js';
|
|
20
|
+
export { DEFAULT_SLA_WARNING_MS, formatDuration, formatResolution, formatSlaCountdown, msRemaining, slaStateOf, sortQueue, } from './view-model.js';
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/approval-ui/index.ts"],"names":[],"mappings":"AAWA,YAAY,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,YAAY,EACV,wBAAwB,EACxB,SAAS,EACT,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,uBAAuB,EACvB,UAAU,EACV,WAAW,EACX,WAAW,EACX,aAAa,EACb,SAAS,EACT,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,UAAU,EACV,UAAU,EACV,cAAc,EACd,SAAS,EACT,IAAI,GACL,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,uBAAuB,GACxB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,YAAY,EAAE,8BAA8B,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACrD,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,YAAY,EACV,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,YAAY,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,SAAS,GACV,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Approval dashboard — a React UI over the approval REST API (queue, detail +
|
|
2
|
+
// decision form, metrics). Subpath export only
|
|
3
|
+
// ('@proofoftech/flowsafe/approval-ui'); deliberately absent from the package
|
|
4
|
+
// root barrel so DO-runner/API consumers never pull React.
|
|
5
|
+
//
|
|
6
|
+
// Styling-library agnostic: the views render through injected slot components
|
|
7
|
+
// (see ./components) with a plain-HTML default, and useApprovalDashboard is a
|
|
8
|
+
// headless core you can drive a fully custom UI from. This barrel compiles in
|
|
9
|
+
// the UI tsc pass (jsx + DOM lib); client.ts and view-model.ts are DOM-free and
|
|
10
|
+
// typecheck in the main pass too, where their tests run.
|
|
11
|
+
export { App } from './App.js';
|
|
12
|
+
export { ApprovalApiClient, ApprovalApiError, } from './client.js';
|
|
13
|
+
export { ApprovalUIProvider, htmlComponents, useApprovalUIComponents, } from './components.js';
|
|
14
|
+
export { DetailView } from './DetailView.js';
|
|
15
|
+
export { MetricsView } from './MetricsView.js';
|
|
16
|
+
export { createApprovalDashboard } from './mount.js';
|
|
17
|
+
export { QueueView } from './QueueView.js';
|
|
18
|
+
export { APPROVAL_TIPS } from './tips.js';
|
|
19
|
+
export { useApprovalDashboard } from './use-approval-dashboard.js';
|
|
20
|
+
export { DEFAULT_SLA_WARNING_MS, formatDuration, formatResolution, formatSlaCountdown, msRemaining, slaStateOf, sortQueue, } from './view-model.js';
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/approval-ui/index.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,+CAA+C;AAC/C,8EAA8E;AAC9E,2DAA2D;AAC3D,EAAE;AACF,8EAA8E;AAC9E,8EAA8E;AAC9E,8EAA8E;AAC9E,gFAAgF;AAChF,yDAAyD;AAGzD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAM/B,OAAO,EACL,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAyBrB,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,uBAAuB,GACxB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAK1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,SAAS,GACV,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ApprovalDashboardProps } from './App.js';
|
|
2
|
+
import { type ApprovalUIComponents } from './components.js';
|
|
3
|
+
export interface CreateApprovalDashboardOptions extends ApprovalDashboardProps {
|
|
4
|
+
/**
|
|
5
|
+
* Design-system adapter. Supply a full or partial slot map to style the
|
|
6
|
+
* dashboard with your components; omitted slots (or omitting this entirely)
|
|
7
|
+
* fall back to the built-in unstyled HTML adapter, which you can style via
|
|
8
|
+
* the `flowsafe-*` class hooks. If you pass a CSS-based adapter (e.g. Astryx),
|
|
9
|
+
* remember to load that library's stylesheet in your app entry.
|
|
10
|
+
*/
|
|
11
|
+
components?: Partial<ApprovalUIComponents>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Mounts the dashboard into a host element:
|
|
15
|
+
*
|
|
16
|
+
* const client = new ApprovalApiClient({ headers: { authorization: token } });
|
|
17
|
+
* const dashboard = createApprovalDashboard(el, { client, components });
|
|
18
|
+
* // later: dashboard.unmount();
|
|
19
|
+
*/
|
|
20
|
+
export declare function createApprovalDashboard(container: Element, { components, ...props }: CreateApprovalDashboardOptions): {
|
|
21
|
+
unmount: () => void;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=mount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../src/approval-ui/mount.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAO,KAAK,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAE,KAAK,oBAAoB,EAAsB,MAAM,iBAAiB,CAAC;AAEhF,MAAM,WAAW,8BAA+B,SAAQ,sBAAsB;IAC5E;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAC5C;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,OAAO,EAClB,EAAE,UAAU,EAAE,GAAG,KAAK,EAAE,EAAE,8BAA8B,GACvD;IAAE,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CAQzB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createRoot } from 'react-dom/client';
|
|
3
|
+
import { App } from './App.js';
|
|
4
|
+
import { ApprovalUIProvider } from './components.js';
|
|
5
|
+
/**
|
|
6
|
+
* Mounts the dashboard into a host element:
|
|
7
|
+
*
|
|
8
|
+
* const client = new ApprovalApiClient({ headers: { authorization: token } });
|
|
9
|
+
* const dashboard = createApprovalDashboard(el, { client, components });
|
|
10
|
+
* // later: dashboard.unmount();
|
|
11
|
+
*/
|
|
12
|
+
export function createApprovalDashboard(container, { components, ...props }) {
|
|
13
|
+
const root = createRoot(container);
|
|
14
|
+
root.render(_jsx(ApprovalUIProvider, { components: components, children: _jsx(App, { ...props }) }));
|
|
15
|
+
return { unmount: () => root.unmount() };
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=mount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount.js","sourceRoot":"","sources":["../../src/approval-ui/mount.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,GAAG,EAA+B,MAAM,UAAU,CAAC;AAC5D,OAAO,EAA6B,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAahF;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CACrC,SAAkB,EAClB,EAAE,UAAU,EAAE,GAAG,KAAK,EAAkC;IAExD,MAAM,IAAI,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;IACnC,IAAI,CAAC,MAAM,CACT,KAAC,kBAAkB,IAAC,UAAU,EAAE,UAAU,YACxC,KAAC,GAAG,OAAK,KAAK,GAAI,GACC,CACtB,CAAC;IACF,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ApprovalStatus } from '../approval-api/types.js';
|
|
2
|
+
declare const METRIC_TIPS: {
|
|
3
|
+
readonly Open: "Requests still awaiting a decision: pending, claimed, or escalated.";
|
|
4
|
+
readonly 'SLA breached': "Open requests past their SLA deadline, counted whether or not the 15-minute sweep has marked them escalated yet.";
|
|
5
|
+
readonly Escalations: "Requests ever escalated by the sweep, including ones decided since. Escalation never closes a request.";
|
|
6
|
+
readonly Decided: "Requests resolved either way: approved plus rejected.";
|
|
7
|
+
readonly Approved: "Decisions that minted a grant bound to their exact suspension.";
|
|
8
|
+
readonly Rejected: "Decisions that resumed the run to a declined outcome. No grant was minted.";
|
|
9
|
+
readonly 'Avg resolution': "Mean time from request creation to decision, across decided requests. Shows '—' until something has been decided.";
|
|
10
|
+
};
|
|
11
|
+
export type MetricLabel = keyof typeof METRIC_TIPS;
|
|
12
|
+
export declare const APPROVAL_TIPS: {
|
|
13
|
+
readonly sla: "Each request carries a decide-by deadline (4 hours here). A cron sweep every 15 minutes marks overdue requests as escalated.";
|
|
14
|
+
readonly statusColumn: "pending → claimed → approved/rejected; escalated when the SLA sweep flags an overdue request.";
|
|
15
|
+
readonly priority: "low, normal, high, or critical, set when a request is created. Approvals auto-queued from a suspension default to normal.";
|
|
16
|
+
readonly claim: "Marks you as the reviewer working this request so others don't double-handle it. Optional; deciding does not require a prior claim.";
|
|
17
|
+
readonly delegate: "Reassigns the claim to another reviewer. Last write wins by design: it moves a pointer and guards no side effect.";
|
|
18
|
+
readonly grantsOnApprove: "Connector ids this approval unlocks, for one resumed leg of this exact suspension only. Approving here never unlocks a later gate.";
|
|
19
|
+
readonly decision: "The durable decision record. Approve derived a grant for the suspended leg; reject resumed the run to a declined outcome.";
|
|
20
|
+
readonly status: Record<ApprovalStatus, string>;
|
|
21
|
+
readonly metrics: {
|
|
22
|
+
readonly Open: "Requests still awaiting a decision: pending, claimed, or escalated.";
|
|
23
|
+
readonly 'SLA breached': "Open requests past their SLA deadline, counted whether or not the 15-minute sweep has marked them escalated yet.";
|
|
24
|
+
readonly Escalations: "Requests ever escalated by the sweep, including ones decided since. Escalation never closes a request.";
|
|
25
|
+
readonly Decided: "Requests resolved either way: approved plus rejected.";
|
|
26
|
+
readonly Approved: "Decisions that minted a grant bound to their exact suspension.";
|
|
27
|
+
readonly Rejected: "Decisions that resumed the run to a declined outcome. No grant was minted.";
|
|
28
|
+
readonly 'Avg resolution': "Mean time from request creation to decision, across decided requests. Shows '—' until something has been decided.";
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=tips.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tips.d.ts","sourceRoot":"","sources":["../../src/approval-ui/tips.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAe/D,QAAA,MAAM,WAAW;;;;;;;;CAYP,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,WAAW,CAAC;AAEnD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;CAgBhB,CAAC"}
|