@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.
Files changed (204) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/LICENSE +202 -0
  3. package/README.md +273 -0
  4. package/dist/approval-api/contract.d.ts +45 -0
  5. package/dist/approval-api/contract.d.ts.map +1 -0
  6. package/dist/approval-api/contract.js +37 -0
  7. package/dist/approval-api/contract.js.map +1 -0
  8. package/dist/approval-api/d1-store.d.ts +52 -0
  9. package/dist/approval-api/d1-store.d.ts.map +1 -0
  10. package/dist/approval-api/d1-store.js +468 -0
  11. package/dist/approval-api/d1-store.js.map +1 -0
  12. package/dist/approval-api/grants.d.ts +52 -0
  13. package/dist/approval-api/grants.d.ts.map +1 -0
  14. package/dist/approval-api/grants.js +200 -0
  15. package/dist/approval-api/grants.js.map +1 -0
  16. package/dist/approval-api/index.d.ts +21 -0
  17. package/dist/approval-api/index.d.ts.map +1 -0
  18. package/dist/approval-api/index.js +18 -0
  19. package/dist/approval-api/index.js.map +1 -0
  20. package/dist/approval-api/retention.d.ts +32 -0
  21. package/dist/approval-api/retention.d.ts.map +1 -0
  22. package/dist/approval-api/retention.js +81 -0
  23. package/dist/approval-api/retention.js.map +1 -0
  24. package/dist/approval-api/router.d.ts +51 -0
  25. package/dist/approval-api/router.d.ts.map +1 -0
  26. package/dist/approval-api/router.js +245 -0
  27. package/dist/approval-api/router.js.map +1 -0
  28. package/dist/approval-api/service.d.ts +134 -0
  29. package/dist/approval-api/service.d.ts.map +1 -0
  30. package/dist/approval-api/service.js +537 -0
  31. package/dist/approval-api/service.js.map +1 -0
  32. package/dist/approval-api/store.d.ts +126 -0
  33. package/dist/approval-api/store.d.ts.map +1 -0
  34. package/dist/approval-api/store.js +189 -0
  35. package/dist/approval-api/store.js.map +1 -0
  36. package/dist/approval-api/tenant-brand.d.ts +35 -0
  37. package/dist/approval-api/tenant-brand.d.ts.map +1 -0
  38. package/dist/approval-api/tenant-brand.js +18 -0
  39. package/dist/approval-api/tenant-brand.js.map +1 -0
  40. package/dist/approval-api/tenant-context.d.ts +44 -0
  41. package/dist/approval-api/tenant-context.d.ts.map +1 -0
  42. package/dist/approval-api/tenant-context.js +49 -0
  43. package/dist/approval-api/tenant-context.js.map +1 -0
  44. package/dist/approval-api/tenant-store.d.ts +36 -0
  45. package/dist/approval-api/tenant-store.d.ts.map +1 -0
  46. package/dist/approval-api/tenant-store.js +122 -0
  47. package/dist/approval-api/tenant-store.js.map +1 -0
  48. package/dist/approval-api/types.d.ts +247 -0
  49. package/dist/approval-api/types.d.ts.map +1 -0
  50. package/dist/approval-api/types.js +157 -0
  51. package/dist/approval-api/types.js.map +1 -0
  52. package/dist/approval-ui/App.d.ts +11 -0
  53. package/dist/approval-ui/App.d.ts.map +1 -0
  54. package/dist/approval-ui/App.js +15 -0
  55. package/dist/approval-ui/App.js.map +1 -0
  56. package/dist/approval-ui/DetailView.d.ts +13 -0
  57. package/dist/approval-ui/DetailView.d.ts.map +1 -0
  58. package/dist/approval-ui/DetailView.js +20 -0
  59. package/dist/approval-ui/DetailView.js.map +1 -0
  60. package/dist/approval-ui/MetricsView.d.ts +7 -0
  61. package/dist/approval-ui/MetricsView.d.ts.map +1 -0
  62. package/dist/approval-ui/MetricsView.js +22 -0
  63. package/dist/approval-ui/MetricsView.js.map +1 -0
  64. package/dist/approval-ui/QueueView.d.ts +11 -0
  65. package/dist/approval-ui/QueueView.d.ts.map +1 -0
  66. package/dist/approval-ui/QueueView.js +59 -0
  67. package/dist/approval-ui/QueueView.js.map +1 -0
  68. package/dist/approval-ui/client.d.ts +34 -0
  69. package/dist/approval-ui/client.d.ts.map +1 -0
  70. package/dist/approval-ui/client.js +103 -0
  71. package/dist/approval-ui/client.js.map +1 -0
  72. package/dist/approval-ui/components.d.ts +125 -0
  73. package/dist/approval-ui/components.d.ts.map +1 -0
  74. package/dist/approval-ui/components.js +54 -0
  75. package/dist/approval-ui/components.js.map +1 -0
  76. package/dist/approval-ui/index.d.ts +21 -0
  77. package/dist/approval-ui/index.d.ts.map +1 -0
  78. package/dist/approval-ui/index.js +21 -0
  79. package/dist/approval-ui/index.js.map +1 -0
  80. package/dist/approval-ui/mount.d.ts +23 -0
  81. package/dist/approval-ui/mount.d.ts.map +1 -0
  82. package/dist/approval-ui/mount.js +17 -0
  83. package/dist/approval-ui/mount.js.map +1 -0
  84. package/dist/approval-ui/tips.d.ts +32 -0
  85. package/dist/approval-ui/tips.d.ts.map +1 -0
  86. package/dist/approval-ui/tips.js +32 -0
  87. package/dist/approval-ui/tips.js.map +1 -0
  88. package/dist/approval-ui/use-approval-dashboard.d.ts +70 -0
  89. package/dist/approval-ui/use-approval-dashboard.d.ts.map +1 -0
  90. package/dist/approval-ui/use-approval-dashboard.js +148 -0
  91. package/dist/approval-ui/use-approval-dashboard.js.map +1 -0
  92. package/dist/approval-ui/view-model.d.ts +24 -0
  93. package/dist/approval-ui/view-model.d.ts.map +1 -0
  94. package/dist/approval-ui/view-model.js +62 -0
  95. package/dist/approval-ui/view-model.js.map +1 -0
  96. package/dist/artifacts/index.d.ts +123 -0
  97. package/dist/artifacts/index.d.ts.map +1 -0
  98. package/dist/artifacts/index.js +223 -0
  99. package/dist/artifacts/index.js.map +1 -0
  100. package/dist/audit-export/index.d.ts +71 -0
  101. package/dist/audit-export/index.d.ts.map +1 -0
  102. package/dist/audit-export/index.js +124 -0
  103. package/dist/audit-export/index.js.map +1 -0
  104. package/dist/do-runner/breakwater-keys.d.ts +23 -0
  105. package/dist/do-runner/breakwater-keys.d.ts.map +1 -0
  106. package/dist/do-runner/breakwater-keys.js +38 -0
  107. package/dist/do-runner/breakwater-keys.js.map +1 -0
  108. package/dist/do-runner/cf-types.d.ts +26 -0
  109. package/dist/do-runner/cf-types.d.ts.map +1 -0
  110. package/dist/do-runner/cf-types.js +13 -0
  111. package/dist/do-runner/cf-types.js.map +1 -0
  112. package/dist/do-runner/d1-storage.d.ts +128 -0
  113. package/dist/do-runner/d1-storage.d.ts.map +1 -0
  114. package/dist/do-runner/d1-storage.js +287 -0
  115. package/dist/do-runner/d1-storage.js.map +1 -0
  116. package/dist/do-runner/durable-object.d.ts +28 -0
  117. package/dist/do-runner/durable-object.d.ts.map +1 -0
  118. package/dist/do-runner/durable-object.js +164 -0
  119. package/dist/do-runner/durable-object.js.map +1 -0
  120. package/dist/do-runner/index.d.ts +12 -0
  121. package/dist/do-runner/index.d.ts.map +1 -0
  122. package/dist/do-runner/index.js +11 -0
  123. package/dist/do-runner/index.js.map +1 -0
  124. package/dist/do-runner/init.d.ts +38 -0
  125. package/dist/do-runner/init.d.ts.map +1 -0
  126. package/dist/do-runner/init.js +45 -0
  127. package/dist/do-runner/init.js.map +1 -0
  128. package/dist/do-runner/path-safe-id.d.ts +19 -0
  129. package/dist/do-runner/path-safe-id.d.ts.map +1 -0
  130. package/dist/do-runner/path-safe-id.js +70 -0
  131. package/dist/do-runner/path-safe-id.js.map +1 -0
  132. package/dist/do-runner/resume-ledger.d.ts +48 -0
  133. package/dist/do-runner/resume-ledger.d.ts.map +1 -0
  134. package/dist/do-runner/resume-ledger.js +59 -0
  135. package/dist/do-runner/resume-ledger.js.map +1 -0
  136. package/dist/do-runner/runtime.d.ts +161 -0
  137. package/dist/do-runner/runtime.d.ts.map +1 -0
  138. package/dist/do-runner/runtime.js +509 -0
  139. package/dist/do-runner/runtime.js.map +1 -0
  140. package/dist/host-kit/approval-bridge.d.ts +109 -0
  141. package/dist/host-kit/approval-bridge.d.ts.map +1 -0
  142. package/dist/host-kit/approval-bridge.js +262 -0
  143. package/dist/host-kit/approval-bridge.js.map +1 -0
  144. package/dist/host-kit/bearer-auth.d.ts +19 -0
  145. package/dist/host-kit/bearer-auth.d.ts.map +1 -0
  146. package/dist/host-kit/bearer-auth.js +67 -0
  147. package/dist/host-kit/bearer-auth.js.map +1 -0
  148. package/dist/host-kit/do-response.d.ts +13 -0
  149. package/dist/host-kit/do-response.d.ts.map +1 -0
  150. package/dist/host-kit/do-response.js +24 -0
  151. package/dist/host-kit/do-response.js.map +1 -0
  152. package/dist/host-kit/do-run-topology.d.ts +32 -0
  153. package/dist/host-kit/do-run-topology.d.ts.map +1 -0
  154. package/dist/host-kit/do-run-topology.js +39 -0
  155. package/dist/host-kit/do-run-topology.js.map +1 -0
  156. package/dist/host-kit/env-vars.d.ts +26 -0
  157. package/dist/host-kit/env-vars.d.ts.map +1 -0
  158. package/dist/host-kit/env-vars.js +48 -0
  159. package/dist/host-kit/env-vars.js.map +1 -0
  160. package/dist/host-kit/host-approval-service.d.ts +125 -0
  161. package/dist/host-kit/host-approval-service.d.ts.map +1 -0
  162. package/dist/host-kit/host-approval-service.js +187 -0
  163. package/dist/host-kit/host-approval-service.js.map +1 -0
  164. package/dist/host-kit/index.d.ts +18 -0
  165. package/dist/host-kit/index.d.ts.map +1 -0
  166. package/dist/host-kit/index.js +34 -0
  167. package/dist/host-kit/index.js.map +1 -0
  168. package/dist/host-kit/module.d.ts +34 -0
  169. package/dist/host-kit/module.d.ts.map +1 -0
  170. package/dist/host-kit/module.js +17 -0
  171. package/dist/host-kit/module.js.map +1 -0
  172. package/dist/host-kit/registration.d.ts +11 -0
  173. package/dist/host-kit/registration.d.ts.map +1 -0
  174. package/dist/host-kit/registration.js +21 -0
  175. package/dist/host-kit/registration.js.map +1 -0
  176. package/dist/host-kit/run-route-error.d.ts +11 -0
  177. package/dist/host-kit/run-route-error.d.ts.map +1 -0
  178. package/dist/host-kit/run-route-error.js +22 -0
  179. package/dist/host-kit/run-route-error.js.map +1 -0
  180. package/dist/host-kit/run-router.d.ts +60 -0
  181. package/dist/host-kit/run-router.d.ts.map +1 -0
  182. package/dist/host-kit/run-router.js +212 -0
  183. package/dist/host-kit/run-router.js.map +1 -0
  184. package/dist/host-kit/subdomain-check.d.ts +23 -0
  185. package/dist/host-kit/subdomain-check.d.ts.map +1 -0
  186. package/dist/host-kit/subdomain-check.js +60 -0
  187. package/dist/host-kit/subdomain-check.js.map +1 -0
  188. package/dist/host-kit/tenant-registry.d.ts +51 -0
  189. package/dist/host-kit/tenant-registry.d.ts.map +1 -0
  190. package/dist/host-kit/tenant-registry.js +87 -0
  191. package/dist/host-kit/tenant-registry.js.map +1 -0
  192. package/dist/host-kit/verifier.d.ts +63 -0
  193. package/dist/host-kit/verifier.d.ts.map +1 -0
  194. package/dist/host-kit/verifier.js +191 -0
  195. package/dist/host-kit/verifier.js.map +1 -0
  196. package/dist/host-kit/workflow-meta.d.ts +25 -0
  197. package/dist/host-kit/workflow-meta.d.ts.map +1 -0
  198. package/dist/host-kit/workflow-meta.js +12 -0
  199. package/dist/host-kit/workflow-meta.js.map +1 -0
  200. package/dist/index.d.ts +9 -0
  201. package/dist/index.d.ts.map +1 -0
  202. package/dist/index.js +25 -0
  203. package/dist/index.js.map +1 -0
  204. package/package.json +95 -0
@@ -0,0 +1,122 @@
1
+ // Store factories — the ONLY way hosts obtain approval stores (INV-2: "no
2
+ // caller can obtain an approval store that is not bound to exactly one tenant
3
+ // at construction"). Each factory owns its backend handle and its schema-init
4
+ // memo, so a per-request forTenant() does not re-run DDL; system() hands the
5
+ // cron the cross-tenant view, distinctly TYPED so it cannot flow into
6
+ // request-scoped code (SystemApprovalStore is not an ApprovalStore).
7
+ import { TENANT_ID_PATTERN } from '../do-runner/path-safe-id.js';
8
+ import { createApprovalSchema, D1ApprovalStore, d1SystemApprovalStore, } from './d1-store.js';
9
+ import { approvalListComparator, InMemoryApprovalStore, matchesFilter, paginateApprovalList, } from './store.js';
10
+ import { TERMINAL_APPROVAL_STATUSES } from './types.js';
11
+ function assertTenantId(tenantId) {
12
+ if (!TENANT_ID_PATTERN.test(tenantId)) {
13
+ throw new Error(`forTenant: tenantId '${tenantId}' violates INV-3 (^[a-z0-9]{3,32}$)`);
14
+ }
15
+ }
16
+ export class D1ApprovalStoreFactory {
17
+ #db;
18
+ #schemaReady;
19
+ constructor(db) {
20
+ this.#db = db;
21
+ }
22
+ // One memoized DDL pass per factory (per isolate), shared by every bound
23
+ // store and the system view; a failed attempt clears the memo so the next
24
+ // call retries instead of pinning everything to a dead promise.
25
+ #ready = () => {
26
+ this.#schemaReady ??= createApprovalSchema(this.#db).catch((error) => {
27
+ this.#schemaReady = undefined;
28
+ throw error;
29
+ });
30
+ return this.#schemaReady;
31
+ };
32
+ forTenant(tenantId) {
33
+ assertTenantId(tenantId);
34
+ return new D1ApprovalStore(this.#db, { tenantId, ready: this.#ready });
35
+ }
36
+ system() {
37
+ return d1SystemApprovalStore(this.#db, this.#ready);
38
+ }
39
+ }
40
+ /**
41
+ * In-memory factory over ONE shared Map. Not decoration: two independent
42
+ * `new InMemoryApprovalStore(...)` instances hold separate Maps, so a
43
+ * cross-tenant get/transition test against them passes trivially without
44
+ * exercising the tenant predicate — the exact "InMemory hides what D1 does"
45
+ * divergence the shared contract suite exists to close. Tenant A and tenant B
46
+ * views minted here share the backend, like two bound D1 stores share the
47
+ * table.
48
+ */
49
+ export class InMemoryApprovalStoreFactory {
50
+ #records = new Map();
51
+ forTenant(tenantId) {
52
+ assertTenantId(tenantId);
53
+ return new InMemoryApprovalStore(tenantId, this.#records);
54
+ }
55
+ /**
56
+ * Delete every record stamped with this tenant, returning the count — the
57
+ * in-memory mirror of the D1 `purgeTenant` approvals delete (in-memory hosts
58
+ * have no D1 for that function to run against). Factory-level like
59
+ * `system()`: offboarding is not a request-scoped capability.
60
+ */
61
+ purgeTenant(tenantId) {
62
+ assertTenantId(tenantId);
63
+ let purged = 0;
64
+ for (const [id, record] of this.#records) {
65
+ if (record.tenantId === tenantId) {
66
+ this.#records.delete(id);
67
+ purged += 1;
68
+ }
69
+ }
70
+ return purged;
71
+ }
72
+ system() {
73
+ const records = this.#records;
74
+ return {
75
+ // Identical to the bound store's list() minus the tenant predicate —
76
+ // hence the shared matchesFilter/approvalListComparator/
77
+ // paginateApprovalList rather than a copy.
78
+ async list(filter = {}) {
79
+ const matched = [...records.values()]
80
+ .filter((record) => matchesFilter(record, filter))
81
+ .sort(approvalListComparator(filter));
82
+ return paginateApprovalList(matched, filter).map((record) => structuredClone(record));
83
+ },
84
+ async transition(id, from, patch) {
85
+ const current = records.get(id);
86
+ if (!current || !from.includes(current.status))
87
+ return null;
88
+ const updated = { ...current };
89
+ for (const [field, value] of Object.entries(patch)) {
90
+ if (value !== undefined) {
91
+ updated[field] = value;
92
+ }
93
+ }
94
+ records.set(id, updated);
95
+ return structuredClone(updated);
96
+ },
97
+ // Retention purge (D3/PART 4): mirrors the D1 system view's
98
+ // purgeExpired — terminal-only, cutoff is exclusive (strictly before),
99
+ // bounded by `limit`. Map iteration order is insertion order; no
100
+ // ordering guarantee is required (purgeExpiredWorkflowRuns' row-only
101
+ // batching path makes the same no-ORDER-BY choice — the shrinking
102
+ // eligible set across firings is what matters, not which N rows a
103
+ // single firing picks).
104
+ async purgeExpired(cutoffIso, limit) {
105
+ let purged = 0;
106
+ for (const [id, record] of records) {
107
+ if (purged >= limit)
108
+ break;
109
+ if (!TERMINAL_APPROVAL_STATUSES.includes(record.status))
110
+ continue;
111
+ const terminalAt = record.decidedAt ?? record.updatedAt;
112
+ if (terminalAt < cutoffIso) {
113
+ records.delete(id);
114
+ purged += 1;
115
+ }
116
+ }
117
+ return purged;
118
+ },
119
+ };
120
+ }
121
+ }
122
+ //# sourceMappingURL=tenant-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tenant-store.js","sourceRoot":"","sources":["../../src/approval-api/tenant-store.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,8EAA8E;AAC9E,8EAA8E;AAC9E,6EAA6E;AAC7E,sEAAsE;AACtE,qEAAqE;AAErE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAEL,oBAAoB,EACpB,eAAe,EACf,qBAAqB,GACtB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,aAAa,EACb,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAUpB,O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AAO,EAAE,CAAC;gBAC/C,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;oBACnD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;wBACvB,OAA8C,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;oBACjE,CAAC;gBACH,CAAC;gBACD,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;gBACzB,OAAO,eAAe,CAAC,OAAO,CAAC,CAAC;YAClC,CAAC;YACD,4DAA4D;YAC5D,uEAAuE;YACvE,iEAAiE;YACjE,qEAAqE;YACrE,kEAAkE;YAClE,kEAAkE;YAClE,wBAAwB;YACxB,KAAK,CAAC,YAAY,CAAC,SAAiB,EAAE,KAAa;gBACjD,IAAI,MAAM,GAAG,CAAC,CAAC;gBACf,KAAK,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;oBACnC,IAAI,MAAM,IAAI,KAAK;wBAAE,MAAM;oBAC3B,IAAI,CAAC,0BAA0B,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;wBAAE,SAAS;oBAClE,MAAM,UAAU,GAAG,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,SAAS,CAAC;oBACxD,IAAI,UAAU,GAAG,SAAS,EAAE,CAAC;wBAC3B,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;wBACnB,MAAM,IAAI,CAAC,CAAC;oBACd,CAAC;gBACH,CAAC;gBACD,OAAO,MAAM,CAAC;YAChB,CAAC;SACF,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,247 @@
1
+ export type ApprovalStatus = 'pending' | 'claimed' | 'approved' | 'rejected' | 'escalated';
2
+ export type ApprovalDecision = 'approve' | 'reject';
3
+ export type ApprovalPriority = 'low' | 'normal' | 'high' | 'critical';
4
+ /**
5
+ * Statuses that still await a decision. 'escalated' stays decidable —
6
+ * escalation raises visibility, it does not close the request.
7
+ */
8
+ export declare const OPEN_STATUSES: readonly ApprovalStatus[];
9
+ /**
10
+ * The approval lifecycle's closed states — the complement of OPEN_STATUSES.
11
+ * Once decided, a record never reopens (a later re-suspension of the same
12
+ * step files a FRESH record — see store.ts's open-uniqueness index). Drives
13
+ * the retention purge (retention.ts): only these statuses are ever eligible.
14
+ */
15
+ export declare const TERMINAL_APPROVAL_STATUSES: readonly ApprovalStatus[];
16
+ export declare const APPROVAL_PRIORITIES: readonly ApprovalPriority[];
17
+ export declare const APPROVAL_STATUSES: readonly ApprovalStatus[];
18
+ export interface ApprovalRecord {
19
+ id: string;
20
+ /**
21
+ * The owning tenant. STAMPED by the bound store from its own constructor
22
+ * field — never accepted from input (CreateApprovalInput deliberately has
23
+ * no tenantId: a field that cannot be supplied cannot be spoofed). Every
24
+ * read/write predicate carries it (INV-2).
25
+ */
26
+ tenantId: string;
27
+ workflowId: string;
28
+ runId: string;
29
+ /** Suspended step path this approval unblocks, e.g. ['approval']. */
30
+ stepPath?: string[];
31
+ title: string;
32
+ summary?: string;
33
+ /** Workflow-provided reviewer context (typically the suspend payload). */
34
+ payload?: unknown;
35
+ /**
36
+ * Connector ids an approval grants (breakwater write gate). Recorded at
37
+ * creation by trusted server-side code — the grant provider derives
38
+ * requestContext grants from these on approved records only.
39
+ */
40
+ connectors: string[];
41
+ priority: ApprovalPriority;
42
+ status: ApprovalStatus;
43
+ requestedBy?: string;
44
+ claimedBy?: string;
45
+ decidedBy?: string;
46
+ decision?: ApprovalDecision;
47
+ comment?: string;
48
+ /** Latest delegation target (also reflected in claimedBy). */
49
+ delegatedTo?: string;
50
+ createdAt: string;
51
+ updatedAt: string;
52
+ claimedAt?: string;
53
+ decidedAt?: string;
54
+ escalatedAt?: string;
55
+ slaDeadlineAt?: string;
56
+ /**
57
+ * Epoch-ms suspendedAt of the suspension this approval binds to (core
58
+ * clock) — see CreateApprovalInput.suspendedAt. Grant minting requires an
59
+ * EXACT match with the resumed leg's suspension timestamp when present,
60
+ * paired with `resumeCount`.
61
+ */
62
+ suspendedAt?: number;
63
+ /**
64
+ * Epoch-ms resumedAt of that suspension (core clock). INFORMATIONAL audit
65
+ * metadata only — Mastra stamps it solely on a payload-bearing resume, so it
66
+ * is NOT the grant tie-breaker (that is `resumeCount`).
67
+ */
68
+ resumedAt?: number;
69
+ /**
70
+ * Runtime-owned monotonic resume ordinal of that suspension — undefined for
71
+ * a step's FIRST suspension, 1,2,… on successive re-suspensions. Pairs with
72
+ * `suspendedAt` in the exact grant binding as the collision-free
73
+ * tie-breaker: unlike `resumedAt` the runtime increments it on every resume
74
+ * regardless of payload, so two same-step suspensions stay distinguishable
75
+ * even when their `suspendedAt` collide within a millisecond.
76
+ */
77
+ resumeCount?: number;
78
+ /**
79
+ * Explicit run-scoped standing grant: a step-less record mints its
80
+ * connectors on EVERY leg of the run. Opt-in only — a step-less record
81
+ * WITHOUT this flag mints nothing, because "absent field => maximal
82
+ * privilege" is an inverted default. Suspend-observation bridges must never
83
+ * set this (they always carry a stepPath); only trusted code that
84
+ * deliberately wants a run-wide capability does.
85
+ */
86
+ runScoped?: boolean;
87
+ }
88
+ export interface CreateApprovalInput {
89
+ workflowId: string;
90
+ runId: string;
91
+ stepPath?: string[];
92
+ title: string;
93
+ summary?: string;
94
+ payload?: unknown;
95
+ connectors?: string[];
96
+ priority?: ApprovalPriority;
97
+ /** Seconds from creation to the SLA deadline; overrides the service default. */
98
+ slaSeconds?: number;
99
+ requestedBy?: string;
100
+ /**
101
+ * Epoch-ms suspendedAt of the suspension this approval binds to, observed
102
+ * from RunSummary.suspendedAt by the creating bridge (core clock, so grant
103
+ * minting is clock-free: mint requires record.suspendedAt to EXACTLY match
104
+ * the resumed leg's suspension). Step-keyed approvals created without it
105
+ * fall back to the same-clock decidedAt-after-suspension comparison.
106
+ */
107
+ suspendedAt?: number;
108
+ /**
109
+ * Epoch-ms resumedAt of that suspension, observed from RunSummary.resumedAt
110
+ * by the same bridge. INFORMATIONAL only — not the grant tie-breaker.
111
+ */
112
+ resumedAt?: number;
113
+ /**
114
+ * Runtime resume ordinal of that suspension, observed from
115
+ * RunSummary.resumeCount by the same bridge — undefined for a first
116
+ * suspension, 1,2,… on re-suspensions. Pairs with `suspendedAt` as the
117
+ * collision-free grant-binding tie-breaker.
118
+ */
119
+ resumeCount?: number;
120
+ /**
121
+ * Opt in to a run-scoped standing grant (mints on every leg). Create-time
122
+ * only — see ApprovalRecord.runScoped. Never settable over HTTP.
123
+ */
124
+ runScoped?: boolean;
125
+ }
126
+ /** List orderings accepted by ApprovalListFilter.orderBy. */
127
+ export declare const APPROVAL_LIST_ORDERS: readonly ["created", "reviewer"];
128
+ export type ApprovalListOrder = (typeof APPROVAL_LIST_ORDERS)[number];
129
+ export interface ApprovalListFilter {
130
+ status?: ApprovalStatus | ApprovalStatus[];
131
+ workflowId?: string;
132
+ runId?: string;
133
+ claimedBy?: string;
134
+ /**
135
+ * Max records to return (clamped to [1, MAX_APPROVAL_LIST_LIMIT] — see
136
+ * clampApprovalLimit). undefined means no limit (the pre-D3 behavior);
137
+ * callers that poll a queue repeatedly should always set one.
138
+ */
139
+ limit?: number;
140
+ /**
141
+ * Opaque pagination cursor from approvalCursor() — resume list() strictly
142
+ * after that record in queue order (createdAt, then id). undefined starts
143
+ * from the beginning.
144
+ */
145
+ after?: string;
146
+ /**
147
+ * Result ordering. 'created' (default) is FIFO — (createdAt, id), the
148
+ * order `after` cursors page over. 'reviewer' is the dashboard queue
149
+ * order (byReviewerOrder: priority, then nearest SLA deadline, then
150
+ * FIFO), applied BEFORE `limit` so a bounded page is the TOP of the
151
+ * reviewer queue — under FIFO-then-limit, a fresh critical request
152
+ * beyond the oldest `limit` records was invisible to a bounded dashboard
153
+ * poll (2026-07-11 review). Incompatible with `after`; see
154
+ * approvalListOrder.
155
+ */
156
+ orderBy?: ApprovalListOrder;
157
+ }
158
+ /**
159
+ * Resolves ApprovalListFilter.orderBy to its effective value — 'created'
160
+ * unless set — and rejects the one incoherent combination: an `after` cursor
161
+ * encodes a position in (createdAt, id) order, where new records only ever
162
+ * land PAST the cursor; under 'reviewer' order they insert anywhere, so
163
+ * cursor pages would silently skip or repeat records. Every list()
164
+ * implementation (both backends, both tenant views) resolves through here;
165
+ * router.ts maps the throw to a 400 before a store sees the filter.
166
+ */
167
+ export declare function approvalListOrder(filter: Pick<ApprovalListFilter, 'after' | 'orderBy'>): ApprovalListOrder;
168
+ export declare function compareStrings(a: string, b: string): number;
169
+ /**
170
+ * Reviewer-facing queue order: priority first, then nearest SLA deadline
171
+ * (records without one last), then FIFO (createdAt, id). THE definition of
172
+ * orderBy: 'reviewer' — the dashboard's sortQueue (approval-ui/view-model.ts)
173
+ * delegates here and d1-store.ts mirrors it in SQL (store.test.ts pins the
174
+ * cross-backend parity), so a bounded server page and the client-side sort
175
+ * can never rank differently.
176
+ */
177
+ export declare function byReviewerOrder(a: ApprovalRecord, b: ApprovalRecord): number;
178
+ /** Hard cap on ApprovalListFilter.limit — see clampApprovalLimit. */
179
+ export declare const MAX_APPROVAL_LIST_LIMIT = 500;
180
+ /**
181
+ * Clamps a caller-supplied ApprovalListFilter.limit into
182
+ * [1, MAX_APPROVAL_LIST_LIMIT]. undefined passes through unchanged (no
183
+ * limit was requested at all). This is store-level defense in depth: the
184
+ * HTTP boundary (router.ts) rejects a non-integer or out-of-range limit
185
+ * outright (400) rather than silently clamping it, so a client typo is a
186
+ * loud error, not a surprising page size — this clamp exists for
187
+ * programmatic callers (in-process filters) so a pathological value can
188
+ * NEVER produce an unbounded query. That guarantee has to hold for
189
+ * non-finite input too: NaN and +/-Infinity clamp to MAX_APPROVAL_LIST_LIMIT
190
+ * (not to "no limit") — a caller that derives a limit from arithmetic that
191
+ * can divide by zero (e.g. a per-page budget) must still get a bounded
192
+ * query, not silently reopen the unbounded scan this function exists to
193
+ * prevent.
194
+ */
195
+ export declare function clampApprovalLimit(limit: number | undefined): number | undefined;
196
+ export interface ApprovalCursor {
197
+ createdAt: string;
198
+ id: string;
199
+ }
200
+ /**
201
+ * Opaque list() pagination cursor: base64 of `${createdAt}|${id}` — the
202
+ * exact (createdAt, id) tuple both stores order list() by (FIFO queue
203
+ * order — byQueueOrder in store.ts). A caller derives the next page's
204
+ * cursor from the last record of the current page and passes it as
205
+ * ApprovalListFilter.after; round-trips through parseApprovalCursor(). Both
206
+ * fields are ISO-8601/UUID-shaped and never contain '|', so the encoding is
207
+ * lossless. btoa/atob (not a bundled base64 lib) because they are ambient
208
+ * on Node >=16, Workers, and browsers alike — the same DOM-free-but-
209
+ * web-standard posture client.ts already relies on for fetch.
210
+ */
211
+ export declare function approvalCursor(record: Pick<ApprovalRecord, 'createdAt' | 'id'>): string;
212
+ /**
213
+ * Throws a plain Error (router.ts maps it to 400) when `cursor` is not a
214
+ * validly-shaped approvalCursor().
215
+ */
216
+ export declare function parseApprovalCursor(cursor: string): ApprovalCursor;
217
+ export interface ApprovalMetrics {
218
+ /** Requests still awaiting a decision (pending | claimed | escalated). */
219
+ openCount: number;
220
+ /** Open requests past their SLA deadline (swept into 'escalated' or not yet). */
221
+ slaBreachedCount: number;
222
+ /** Requests that were ever escalated, regardless of current status. */
223
+ escalationCount: number;
224
+ decidedCount: number;
225
+ approvedCount: number;
226
+ rejectedCount: number;
227
+ /** Mean createdAt→decidedAt seconds across decided requests; null when none decided. */
228
+ avgResolutionSeconds: number | null;
229
+ }
230
+ /** Outcome of the resume attempt a decision triggers. */
231
+ export interface ResumeOutcome {
232
+ /** false when no resumeRun is wired — the caller resumes separately. */
233
+ attempted: boolean;
234
+ ok?: boolean;
235
+ /** RunSummary (or whatever resumeRun returns) on success. */
236
+ summary?: unknown;
237
+ error?: string;
238
+ }
239
+ export interface DecideResult {
240
+ record: ApprovalRecord;
241
+ /**
242
+ * The decision is durable regardless of this outcome — a failed resume is
243
+ * retryable (the run stays suspended; grants derive from the store).
244
+ */
245
+ resume: ResumeOutcome;
246
+ }
247
+ //# sourceMappingURL=types.d.ts.map
@@ -0,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E;IACvE,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,wFAAwF;IACxF,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC;AAED,yDAAyD;AACzD,MAAM,WAAW,aAAa;IAC5B,wEAAwE;IACxE,SAAS,EAAE,OAAO,CAAC;IACnB,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,6DAA6D;IAC7D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,cAAc,CAAC;IACvB;;;OAGG;IACH,MAAM,EAAE,aAAa,CAAC;CACvB"}
@@ -0,0 +1,157 @@
1
+ // Approval-queue domain types. All timestamps are ISO 8601 strings — records
2
+ // travel over HTTP and in/out of D1, so the canonical representation is
3
+ // JSON-safe end to end.
4
+ /**
5
+ * Statuses that still await a decision. 'escalated' stays decidable —
6
+ * escalation raises visibility, it does not close the request.
7
+ */
8
+ export const OPEN_STATUSES = [
9
+ 'pending',
10
+ 'claimed',
11
+ 'escalated',
12
+ ];
13
+ /**
14
+ * The approval lifecycle's closed states — the complement of OPEN_STATUSES.
15
+ * Once decided, a record never reopens (a later re-suspension of the same
16
+ * step files a FRESH record — see store.ts's open-uniqueness index). Drives
17
+ * the retention purge (retention.ts): only these statuses are ever eligible.
18
+ */
19
+ export const TERMINAL_APPROVAL_STATUSES = [
20
+ 'approved',
21
+ 'rejected',
22
+ ];
23
+ export const APPROVAL_PRIORITIES = [
24
+ 'low',
25
+ 'normal',
26
+ 'high',
27
+ 'critical',
28
+ ];
29
+ export const APPROVAL_STATUSES = [
30
+ 'pending',
31
+ 'claimed',
32
+ 'approved',
33
+ 'rejected',
34
+ 'escalated',
35
+ ];
36
+ /** List orderings accepted by ApprovalListFilter.orderBy. */
37
+ export const APPROVAL_LIST_ORDERS = ['created', 'reviewer'];
38
+ /**
39
+ * Resolves ApprovalListFilter.orderBy to its effective value — 'created'
40
+ * unless set — and rejects the one incoherent combination: an `after` cursor
41
+ * encodes a position in (createdAt, id) order, where new records only ever
42
+ * land PAST the cursor; under 'reviewer' order they insert anywhere, so
43
+ * cursor pages would silently skip or repeat records. Every list()
44
+ * implementation (both backends, both tenant views) resolves through here;
45
+ * router.ts maps the throw to a 400 before a store sees the filter.
46
+ */
47
+ export function approvalListOrder(filter) {
48
+ const orderBy = filter.orderBy ?? 'created';
49
+ if (orderBy === 'reviewer' && filter.after !== undefined) {
50
+ throw new Error("orderBy 'reviewer' cannot be combined with an 'after' cursor — cursors page FIFO (createdAt, id) order only");
51
+ }
52
+ return orderBy;
53
+ }
54
+ const REVIEWER_PRIORITY_RANK = {
55
+ critical: 0,
56
+ high: 1,
57
+ normal: 2,
58
+ low: 3,
59
+ };
60
+ // D1 casts the priority TEXT column straight into the union, so the lookup
61
+ // must tolerate an out-of-enum value at runtime: it ranks after 'low',
62
+ // exactly like the SQL CASE's ELSE arm in d1-store.ts.
63
+ function reviewerPriorityRank(priority) {
64
+ return (REVIEWER_PRIORITY_RANK[priority] ?? 4);
65
+ }
66
+ // Bytewise, locale-independent — equals SQLite TEXT comparison, and equals
67
+ // chronological order for the fixed-format ISO-8601 stamps. Exported (not
68
+ // barreled) so store.ts's byQueueOrder shares the SAME collation: one
69
+ // divergent localeCompare would let the in-memory and D1 backends disagree
70
+ // on an id tie-break (concrete on mixed-case ids — 'B' < 'a' bytewise but
71
+ // 'a' < 'B' in a locale collation).
72
+ export function compareStrings(a, b) {
73
+ if (a === b)
74
+ return 0;
75
+ return a < b ? -1 : 1;
76
+ }
77
+ /**
78
+ * Reviewer-facing queue order: priority first, then nearest SLA deadline
79
+ * (records without one last), then FIFO (createdAt, id). THE definition of
80
+ * orderBy: 'reviewer' — the dashboard's sortQueue (approval-ui/view-model.ts)
81
+ * delegates here and d1-store.ts mirrors it in SQL (store.test.ts pins the
82
+ * cross-backend parity), so a bounded server page and the client-side sort
83
+ * can never rank differently.
84
+ */
85
+ export function byReviewerOrder(a, b) {
86
+ const byPriority = reviewerPriorityRank(a.priority) - reviewerPriorityRank(b.priority);
87
+ if (byPriority !== 0)
88
+ return byPriority;
89
+ if (a.slaDeadlineAt !== b.slaDeadlineAt) {
90
+ if (a.slaDeadlineAt === undefined)
91
+ return 1;
92
+ if (b.slaDeadlineAt === undefined)
93
+ return -1;
94
+ return compareStrings(a.slaDeadlineAt, b.slaDeadlineAt);
95
+ }
96
+ return compareStrings(a.createdAt, b.createdAt) || compareStrings(a.id, b.id);
97
+ }
98
+ /** Hard cap on ApprovalListFilter.limit — see clampApprovalLimit. */
99
+ export const MAX_APPROVAL_LIST_LIMIT = 500;
100
+ /**
101
+ * Clamps a caller-supplied ApprovalListFilter.limit into
102
+ * [1, MAX_APPROVAL_LIST_LIMIT]. undefined passes through unchanged (no
103
+ * limit was requested at all). This is store-level defense in depth: the
104
+ * HTTP boundary (router.ts) rejects a non-integer or out-of-range limit
105
+ * outright (400) rather than silently clamping it, so a client typo is a
106
+ * loud error, not a surprising page size — this clamp exists for
107
+ * programmatic callers (in-process filters) so a pathological value can
108
+ * NEVER produce an unbounded query. That guarantee has to hold for
109
+ * non-finite input too: NaN and +/-Infinity clamp to MAX_APPROVAL_LIST_LIMIT
110
+ * (not to "no limit") — a caller that derives a limit from arithmetic that
111
+ * can divide by zero (e.g. a per-page budget) must still get a bounded
112
+ * query, not silently reopen the unbounded scan this function exists to
113
+ * prevent.
114
+ */
115
+ export function clampApprovalLimit(limit) {
116
+ if (limit === undefined)
117
+ return undefined;
118
+ if (!Number.isFinite(limit))
119
+ return MAX_APPROVAL_LIST_LIMIT;
120
+ return Math.min(MAX_APPROVAL_LIST_LIMIT, Math.max(1, Math.trunc(limit)));
121
+ }
122
+ /**
123
+ * Opaque list() pagination cursor: base64 of `${createdAt}|${id}` — the
124
+ * exact (createdAt, id) tuple both stores order list() by (FIFO queue
125
+ * order — byQueueOrder in store.ts). A caller derives the next page's
126
+ * cursor from the last record of the current page and passes it as
127
+ * ApprovalListFilter.after; round-trips through parseApprovalCursor(). Both
128
+ * fields are ISO-8601/UUID-shaped and never contain '|', so the encoding is
129
+ * lossless. btoa/atob (not a bundled base64 lib) because they are ambient
130
+ * on Node >=16, Workers, and browsers alike — the same DOM-free-but-
131
+ * web-standard posture client.ts already relies on for fetch.
132
+ */
133
+ export function approvalCursor(record) {
134
+ return btoa(`${record.createdAt}|${record.id}`);
135
+ }
136
+ /**
137
+ * Throws a plain Error (router.ts maps it to 400) when `cursor` is not a
138
+ * validly-shaped approvalCursor().
139
+ */
140
+ export function parseApprovalCursor(cursor) {
141
+ let decoded;
142
+ try {
143
+ decoded = atob(cursor);
144
+ }
145
+ catch {
146
+ throw new Error(`invalid approval cursor: '${cursor}'`);
147
+ }
148
+ const separator = decoded.indexOf('|');
149
+ if (separator <= 0 || separator === decoded.length - 1) {
150
+ throw new Error(`invalid approval cursor: '${cursor}'`);
151
+ }
152
+ return {
153
+ createdAt: decoded.slice(0, separator),
154
+ id: decoded.slice(separator + 1),
155
+ };
156
+ }
157
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/approval-api/types.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,wEAAwE;AACxE,wBAAwB;AAaxB;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAA8B;IACtD,SAAS;IACT,SAAS;IACT,WAAW;CACZ,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAA8B;IACnE,UAAU;IACV,UAAU;CACX,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAgC;IAC9D,KAAK;IACL,QAAQ;IACR,MAAM;IACN,UAAU;CACX,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAA8B;IAC1D,SAAS;IACT,SAAS;IACT,UAAU;IACV,U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,IAAI,KAAK,CAAC,6BAA6B,MAAM,GAAG,CAAC,CAAC;IAC1D,CAAC;IACD,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACvC,IAAI,SAAS,IAAI,CAAC,IAAI,SAAS,KAAK,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvD,MAAM,IAAI,KAAK,CAAC,6BAA6B,MAAM,GAAG,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO;QACL,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC;QACtC,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC;KACjC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { JSX } from 'react';
2
+ import type { ApprovalApiClient } from './client.js';
3
+ export interface ApprovalDashboardProps {
4
+ client: ApprovalApiClient;
5
+ /** Queue/metrics refresh cadence; <= 0 disables polling. Default 10s. */
6
+ pollIntervalMs?: number;
7
+ /** Injectable clock (deterministic SLA countdowns in tests/stories). */
8
+ now?: () => number;
9
+ }
10
+ export declare function App({ client, pollIntervalMs, now, }: ApprovalDashboardProps): JSX.Element;
11
+ //# sourceMappingURL=App.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/approval-ui/App.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAOrD,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,yEAAyE;IACzE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,wEAAwE;IACxE,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAED,wBAAgB,GAAG,CAAC,EAClB,MAAM,EACN,cAAc,EACd,GAAG,GACJ,EAAE,sBAAsB,GAAG,GAAG,CAAC,OAAO,CAgCtC"}
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useApprovalUIComponents } from './components.js';
3
+ import { DetailView } from './DetailView.js';
4
+ import { MetricsView } from './MetricsView.js';
5
+ import { QueueView } from './QueueView.js';
6
+ import { useApprovalDashboard } from './use-approval-dashboard.js';
7
+ export function App({ client, pollIntervalMs, now, }) {
8
+ const C = useApprovalUIComponents();
9
+ const dashboard = useApprovalDashboard(client, { pollIntervalMs, now });
10
+ return (_jsxs(C.Stack, { direction: "vertical", gap: "lg", children: [_jsx(C.Heading, { level: 1, children: "Approvals" }), dashboard.error ? (_jsx(C.Banner, { tone: "danger", title: dashboard.error })) : null, _jsx(MetricsView, { metrics: dashboard.metrics }), _jsx(QueueView, { records: dashboard.records, nowMs: dashboard.nowMs, selectedId: dashboard.selectedId, onSelect: dashboard.select }), dashboard.selected ? (_jsx(DetailView
11
+ // Keyed reset: remount on selection change so DetailView's local
12
+ // comment/delegate state can't leak onto a different record.
13
+ , { record: dashboard.selected, nowMs: dashboard.nowMs, busy: dashboard.busy, onClaim: dashboard.claim, onDecide: dashboard.decide, onDelegate: dashboard.delegate }, dashboard.selected.id)) : null] }));
14
+ }
15
+ //# sourceMappingURL=App.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"App.js","sourceRoot":"","sources":["../../src/approval-ui/App.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAUnE,MAAM,UAAU,GAAG,CAAC,EAClB,MAAM,EACN,cAAc,EACd,GAAG,GACoB;IACvB,MAAM,CAAC,GAAG,uBAAuB,EAAE,CAAC;IACpC,MAAM,SAAS,GAAG,oBAAoB,CAAC,MAAM,EAAE,EAAE,cAAc,EAAE,GAAG,EAAE,CAAC,CAAC;IAExE,OAAO,CACL,MAAC,CAAC,CAAC,KAAK,IAAC,SAAS,EAAC,UAAU,EAAC,GAAG,EAAC,IAAI,aACpC,KAAC,CAAC,CAAC,OAAO,IAAC,KAAK,EAAE,CAAC,0BAAuB,EACzC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CACjB,KAAC,CAAC,CAAC,MAAM,IAAC,IAAI,EAAC,QAAQ,EAAC,KAAK,EAAE,SAAS,CAAC,KAAK,GAAI,CACnD,CAAC,CAAC,CAAC,IAAI,EACR,KAAC,WAAW,IAAC,OAAO,EAAE,SAAS,CAAC,OAAO,GAAI,EAC3C,KAAC,SAAS,IACR,OAAO,EAAE,SAAS,CAAC,OAAO,EAC1B,KAAK,EAAE,SAAS,CAAC,KAAK,EACtB,UAAU,EAAE,SAAS,CAAC,UAAU,EAChC,QAAQ,EAAE,SAAS,CAAC,MAAM,GAC1B,EACD,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CACpB,KAAC,UAAU;YACT,iEAAiE;YACjE,6DAA6D;gBAE7D,MAAM,EAAE,SAAS,CAAC,QAAQ,EAC1B,KAAK,EAAE,SAAS,CAAC,KAAK,EACtB,IAAI,EAAE,SAAS,CAAC,IAAI,EACpB,OAAO,EAAE,SAAS,CAAC,KAAK,EACxB,QAAQ,EAAE,SAAS,CAAC,MAAM,EAC1B,UAAU,EAAE,SAAS,CAAC,QAAQ,IANzB,SAAS,CAAC,QAAQ,CAAC,EAAE,CAO1B,CACH,CAAC,CAAC,CAAC,IAAI,IACA,CACX,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { type JSX } from 'react';
2
+ import type { ApprovalDecision, ApprovalRecord } from '../approval-api/types.js';
3
+ export interface DetailViewProps {
4
+ record: ApprovalRecord;
5
+ nowMs: number;
6
+ /** Disables the action controls while a mutation is in flight. */
7
+ busy: boolean;
8
+ onClaim: () => void;
9
+ onDecide: (decision: ApprovalDecision, comment: string) => void;
10
+ onDelegate: (to: string) => void;
11
+ }
12
+ export declare function DetailView({ record, nowMs, busy, onClaim, onDecide, onDelegate, }: DetailViewProps): JSX.Element;
13
+ //# sourceMappingURL=DetailView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DetailView.d.ts","sourceRoot":"","sources":["../../src/approval-ui/DetailView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAY,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACf,MAAM,0BAA0B,CAAC;AAMlC,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,kEAAkE;IAClE,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,CAAC,QAAQ,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAChE,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC;AAED,wBAAgB,UAAU,CAAC,EACzB,MAAM,EACN,KAAK,EACL,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,UAAU,GACX,EAAE,eAAe,GAAG,GAAG,CAAC,OAAO,CA2H/B"}
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { OPEN_STATUSES } from '../approval-api/types.js';
4
+ import { useApprovalUIComponents } from './components.js';
5
+ import { APPROVAL_TIPS } from './tips.js';
6
+ import { formatSlaCountdown } from './view-model.js';
7
+ export function DetailView({ record, nowMs, busy, onClaim, onDecide, onDelegate, }) {
8
+ const C = useApprovalUIComponents();
9
+ const [comment, setComment] = useState('');
10
+ const [delegateTo, setDelegateTo] = useState('');
11
+ const open = OPEN_STATUSES.includes(record.status);
12
+ function submitDelegate() {
13
+ if (delegateTo !== '')
14
+ onDelegate(delegateTo);
15
+ }
16
+ return (_jsx(C.Section, { "aria-label": `Approval ${record.title}`, children: _jsxs(C.Stack, { direction: "vertical", gap: "md", children: [_jsx(C.Heading, { level: 2, children: record.title }), _jsxs(C.MetadataList, { children: [_jsxs(C.MetadataItem, { label: "Run", children: [record.workflowId, "/", record.runId, record.stepPath ? ` @ ${record.stepPath.join('.')}` : null] }), _jsxs(C.MetadataItem, { label: "Status", children: [_jsx(C.InfoTip, { label: record.status, tip: APPROVAL_TIPS.status[record.status] }), record.claimedBy ? ` (claimed by ${record.claimedBy})` : null] }), _jsx(C.MetadataItem, { label: "Priority", children: _jsx(C.InfoTip, { label: record.priority, tip: APPROVAL_TIPS.priority }) }), _jsx(C.MetadataItem, { label: "SLA", children: _jsx(C.InfoTip, { label: formatSlaCountdown(record, nowMs), tip: APPROVAL_TIPS.sla }) }), _jsx(C.MetadataItem, { label: "Grants on approve", children: _jsx(C.InfoTip, { label: record.connectors.length > 0
17
+ ? record.connectors.join(', ')
18
+ : '—', tip: APPROVAL_TIPS.grantsOnApprove }) }), record.decision ? (_jsxs(C.MetadataItem, { label: "Decision", children: [_jsx(C.InfoTip, { label: record.decision, tip: APPROVAL_TIPS.decision }), ' ', "by ", record.decidedBy, record.comment ? ` · ${record.comment}` : null] })) : null] }), record.summary ? _jsx(C.Text, { children: record.summary }) : null, record.payload !== undefined ? (_jsx(C.Code, { code: JSON.stringify(record.payload, null, 2), language: "json" })) : null, open ? (_jsxs(C.Stack, { direction: "vertical", gap: "sm", children: [_jsx(C.TextField, { label: "Comment", value: comment, onChange: setComment, rows: 2, disabled: busy }), _jsxs(C.Stack, { direction: "horizontal", gap: "sm", children: [_jsx(C.Button, { label: "Approve", variant: "primary", disabled: busy, onClick: () => onDecide('approve', comment) }), _jsx(C.Button, { label: "Reject", variant: "danger", disabled: busy, onClick: () => onDecide('reject', comment) }), _jsx(C.Button, { label: "Claim", variant: "secondary", disabled: busy, onClick: onClaim })] }), _jsxs(C.Stack, { direction: "horizontal", gap: "sm", children: [_jsx(C.TextField, { label: "Delegate to", value: delegateTo, onChange: setDelegateTo, placeholder: "reviewer id", disabled: busy, onSubmit: submitDelegate }), _jsx(C.Button, { label: "Delegate", variant: "secondary", disabled: busy || delegateTo === '', onClick: submitDelegate })] }), _jsxs(C.Text, { children: [_jsx(C.InfoTip, { label: "What does claiming do?", tip: APPROVAL_TIPS.claim }), ' · ', _jsx(C.InfoTip, { label: "What does delegating do?", tip: APPROVAL_TIPS.delegate })] })] })) : null] }) }));
19
+ }
20
+ //# sourceMappingURL=DetailView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DetailView.js","sourceRoot":"","sources":["../../src/approval-ui/DetailView.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAY,QAAQ,EAAE,MAAM,OAAO,CAAC;AAK3C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAYrD,MAAM,UAAU,UAAU,CAAC,EACzB,MAAM,EACN,KAAK,EACL,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,UAAU,GACM;IAChB,MAAM,CAAC,GAAG,uBAAuB,EAAE,CAAC;IACpC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC3C,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAEnD,S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,IACR,KAAK,EAAC,0BAA0B,EAChC,GAAG,EAAE,aAAa,CAAC,QAAQ,GAC3B,IACK,IACD,CACX,CAAC,CAAC,CAAC,IAAI,IACA,GACA,CACb,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { JSX } from 'react';
2
+ import type { ApprovalMetrics } from '../approval-api/types.js';
3
+ export interface MetricsViewProps {
4
+ metrics: ApprovalMetrics | null;
5
+ }
6
+ export declare function MetricsView({ metrics }: MetricsViewProps): JSX.Element;
7
+ //# sourceMappingURL=MetricsView.d.ts.map