@contractspec/example.workflow-system 3.8.8 → 3.8.10

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 (95) hide show
  1. package/dist/approval/approval.enum.js +1 -22
  2. package/dist/approval/approval.event.js +1 -112
  3. package/dist/approval/approval.operations.js +1 -369
  4. package/dist/approval/approval.schema.js +1 -73
  5. package/dist/approval/index.js +1 -484
  6. package/dist/browser/approval/approval.enum.js +1 -22
  7. package/dist/browser/approval/approval.event.js +1 -112
  8. package/dist/browser/approval/approval.operations.js +1 -369
  9. package/dist/browser/approval/approval.schema.js +1 -73
  10. package/dist/browser/approval/index.js +1 -484
  11. package/dist/browser/docs/index.js +5 -49
  12. package/dist/browser/docs/workflow-system.docblock.js +5 -49
  13. package/dist/browser/entities/approval.js +1 -119
  14. package/dist/browser/entities/index.js +1 -508
  15. package/dist/browser/entities/instance.js +1 -161
  16. package/dist/browser/entities/step.js +1 -124
  17. package/dist/browser/entities/workflow.js +1 -82
  18. package/dist/browser/example.js +1 -42
  19. package/dist/browser/handlers/index.js +8 -253
  20. package/dist/browser/handlers/workflow.handlers.js +8 -253
  21. package/dist/browser/index.js +13 -3524
  22. package/dist/browser/instance/index.js +1 -677
  23. package/dist/browser/instance/instance.enum.js +1 -15
  24. package/dist/browser/instance/instance.event.js +1 -164
  25. package/dist/browser/instance/instance.handler.js +1 -356
  26. package/dist/browser/instance/instance.operations.js +1 -9
  27. package/dist/browser/instance/instance.schema.js +1 -101
  28. package/dist/browser/presentations/index.js +1 -109
  29. package/dist/browser/seeders/index.js +1 -3
  30. package/dist/browser/shared/demo-scenario.js +1 -213
  31. package/dist/browser/shared/index.js +1 -3
  32. package/dist/browser/shared/mock-data.js +1 -11
  33. package/dist/browser/state-machine/index.js +1 -6
  34. package/dist/browser/tests/operations.test-spec.js +1 -6
  35. package/dist/browser/ui/WorkflowDashboard.js +1 -3
  36. package/dist/browser/ui/WorkflowDashboard.visualizations.js +1 -239
  37. package/dist/browser/ui/hooks/index.js +1 -3
  38. package/dist/browser/ui/hooks/useWorkflowList.js +1 -52
  39. package/dist/browser/ui/index.js +1 -56
  40. package/dist/browser/ui/renderers/index.js +5 -562
  41. package/dist/browser/ui/renderers/workflow.markdown.js +5 -562
  42. package/dist/browser/visualizations/catalog.js +1 -132
  43. package/dist/browser/visualizations/index.js +1 -133
  44. package/dist/browser/visualizations/selectors.js +1 -195
  45. package/dist/browser/workflow/index.js +1 -21
  46. package/dist/browser/workflow/workflow.enum.js +1 -36
  47. package/dist/browser/workflow/workflow.event.js +1 -6
  48. package/dist/browser/workflow/workflow.handler.js +1 -5
  49. package/dist/browser/workflow/workflow.operations.js +1 -8
  50. package/dist/browser/workflow/workflow.schema.js +1 -151
  51. package/dist/browser/workflow-system.capability.js +1 -5
  52. package/dist/browser/workflow-system.feature.js +1 -3
  53. package/dist/docs/index.js +5 -49
  54. package/dist/docs/workflow-system.docblock.js +5 -49
  55. package/dist/entities/approval.js +1 -119
  56. package/dist/entities/index.js +1 -508
  57. package/dist/entities/instance.js +1 -161
  58. package/dist/entities/step.js +1 -124
  59. package/dist/entities/workflow.js +1 -82
  60. package/dist/example.js +1 -42
  61. package/dist/handlers/index.js +8 -253
  62. package/dist/handlers/workflow.handlers.js +8 -253
  63. package/dist/index.js +13 -3524
  64. package/dist/instance/index.js +1 -677
  65. package/dist/instance/instance.enum.js +1 -15
  66. package/dist/instance/instance.event.js +1 -164
  67. package/dist/instance/instance.handler.js +1 -356
  68. package/dist/instance/instance.operations.js +1 -9
  69. package/dist/instance/instance.schema.js +1 -101
  70. package/dist/presentations/index.js +1 -109
  71. package/dist/seeders/index.js +1 -3
  72. package/dist/shared/demo-scenario.js +1 -213
  73. package/dist/shared/index.js +1 -3
  74. package/dist/shared/mock-data.js +1 -11
  75. package/dist/state-machine/index.js +1 -6
  76. package/dist/tests/operations.test-spec.js +1 -6
  77. package/dist/ui/WorkflowDashboard.js +1 -3
  78. package/dist/ui/WorkflowDashboard.visualizations.js +1 -239
  79. package/dist/ui/hooks/index.js +1 -3
  80. package/dist/ui/hooks/useWorkflowList.js +1 -52
  81. package/dist/ui/index.js +1 -56
  82. package/dist/ui/renderers/index.js +5 -562
  83. package/dist/ui/renderers/workflow.markdown.js +5 -562
  84. package/dist/visualizations/catalog.js +1 -132
  85. package/dist/visualizations/index.js +1 -133
  86. package/dist/visualizations/selectors.js +1 -195
  87. package/dist/workflow/index.js +1 -21
  88. package/dist/workflow/workflow.enum.js +1 -36
  89. package/dist/workflow/workflow.event.js +1 -6
  90. package/dist/workflow/workflow.handler.js +1 -5
  91. package/dist/workflow/workflow.operations.js +1 -8
  92. package/dist/workflow/workflow.schema.js +1 -151
  93. package/dist/workflow-system.capability.js +1 -5
  94. package/dist/workflow-system.feature.js +1 -3
  95. package/package.json +11 -11
@@ -1,564 +1,7 @@
1
1
  // @bun
2
- // src/shared/demo-scenario.ts
3
- var WORKFLOW_SYSTEM_DEMO_PROJECT_ID = "workflow-system-demo";
4
- var WORKFLOW_SYSTEM_DEMO_ORGANIZATION_ID = "org_demo";
5
- var WORKFLOW_SYSTEM_DEMO_DEFINITIONS = [
6
- {
7
- id: "wf_expense",
8
- name: "Expense Approval",
9
- description: "Approve non-trivial spend before finance releases budget.",
10
- type: "APPROVAL",
11
- status: "ACTIVE",
12
- createdAt: "2026-03-10T09:00:00.000Z",
13
- updatedAt: "2026-03-20T08:15:00.000Z",
14
- steps: [
15
- {
16
- id: "wfstep_expense_manager",
17
- name: "Manager Review",
18
- description: "Validate business value and team budget.",
19
- stepOrder: 1,
20
- type: "APPROVAL",
21
- requiredRoles: ["manager"],
22
- createdAt: "2026-03-10T09:00:00.000Z"
23
- },
24
- {
25
- id: "wfstep_expense_finance",
26
- name: "Finance Review",
27
- description: "Confirm ledger coding and spending threshold.",
28
- stepOrder: 2,
29
- type: "APPROVAL",
30
- requiredRoles: ["finance"],
31
- createdAt: "2026-03-10T09:10:00.000Z"
32
- }
33
- ]
34
- },
35
- {
36
- id: "wf_vendor",
37
- name: "Vendor Onboarding",
38
- description: "Sequence security, procurement, and legal before activation.",
39
- type: "SEQUENTIAL",
40
- status: "ACTIVE",
41
- createdAt: "2026-03-08T11:00:00.000Z",
42
- updatedAt: "2026-03-19T13:10:00.000Z",
43
- steps: [
44
- {
45
- id: "wfstep_vendor_security",
46
- name: "Security Check",
47
- description: "Review data access and integration scope.",
48
- stepOrder: 1,
49
- type: "APPROVAL",
50
- requiredRoles: ["security"],
51
- createdAt: "2026-03-08T11:00:00.000Z"
52
- },
53
- {
54
- id: "wfstep_vendor_procurement",
55
- name: "Procurement Check",
56
- description: "Validate pricing, procurement policy, and owner.",
57
- stepOrder: 2,
58
- type: "APPROVAL",
59
- requiredRoles: ["procurement"],
60
- createdAt: "2026-03-08T11:05:00.000Z"
61
- },
62
- {
63
- id: "wfstep_vendor_legal",
64
- name: "Legal Sign-off",
65
- description: "Approve terms before the vendor goes live.",
66
- stepOrder: 3,
67
- type: "APPROVAL",
68
- requiredRoles: ["legal"],
69
- createdAt: "2026-03-08T11:10:00.000Z"
70
- }
71
- ]
72
- },
73
- {
74
- id: "wf_policy_exception",
75
- name: "Policy Exception",
76
- description: "Escalate a temporary exception through team lead and compliance.",
77
- type: "APPROVAL",
78
- status: "DRAFT",
79
- createdAt: "2026-03-15T07:30:00.000Z",
80
- updatedAt: "2026-03-18T11:20:00.000Z",
81
- steps: [
82
- {
83
- id: "wfstep_policy_lead",
84
- name: "Team Lead Review",
85
- description: "Check urgency and expected blast radius.",
86
- stepOrder: 1,
87
- type: "APPROVAL",
88
- requiredRoles: ["team-lead"],
89
- createdAt: "2026-03-15T07:30:00.000Z"
90
- },
91
- {
92
- id: "wfstep_policy_compliance",
93
- name: "Compliance Review",
94
- description: "Accept or reject the exception request.",
95
- stepOrder: 2,
96
- type: "APPROVAL",
97
- requiredRoles: ["compliance"],
98
- createdAt: "2026-03-15T07:40:00.000Z"
99
- }
100
- ]
101
- }
102
- ];
103
- var WORKFLOW_SYSTEM_DEMO_INSTANCES = [
104
- {
105
- id: "wfinst_expense_open",
106
- definitionId: "wf_expense",
107
- status: "IN_PROGRESS",
108
- currentStepId: "wfstep_expense_finance",
109
- data: {
110
- amount: 4200,
111
- currency: "EUR",
112
- vendor: "Nimbus AI"
113
- },
114
- requestedBy: "sarah@contractspec.io",
115
- startedAt: "2026-03-20T08:00:00.000Z",
116
- approvals: [
117
- {
118
- id: "wfappr_expense_manager",
119
- stepId: "wfstep_expense_manager",
120
- status: "APPROVED",
121
- actorId: "manager.demo",
122
- comment: "Approved for the Q2 automation budget.",
123
- decidedAt: "2026-03-20T08:15:00.000Z",
124
- createdAt: "2026-03-20T08:05:00.000Z"
125
- },
126
- {
127
- id: "wfappr_expense_finance",
128
- stepId: "wfstep_expense_finance",
129
- status: "PENDING",
130
- createdAt: "2026-03-20T08:15:00.000Z"
131
- }
132
- ]
133
- },
134
- {
135
- id: "wfinst_vendor_done",
136
- definitionId: "wf_vendor",
137
- status: "COMPLETED",
138
- data: {
139
- vendor: "Acme Cloud",
140
- riskTier: "medium"
141
- },
142
- requestedBy: "leo@contractspec.io",
143
- startedAt: "2026-03-19T09:30:00.000Z",
144
- completedAt: "2026-03-19T13:10:00.000Z",
145
- approvals: [
146
- {
147
- id: "wfappr_vendor_security",
148
- stepId: "wfstep_vendor_security",
149
- status: "APPROVED",
150
- actorId: "security.demo",
151
- comment: "SOC2 scope is acceptable.",
152
- decidedAt: "2026-03-19T10:10:00.000Z",
153
- createdAt: "2026-03-19T09:35:00.000Z"
154
- },
155
- {
156
- id: "wfappr_vendor_procurement",
157
- stepId: "wfstep_vendor_procurement",
158
- status: "APPROVED",
159
- actorId: "procurement.demo",
160
- comment: "Commercial terms match the preferred vendor tier.",
161
- decidedAt: "2026-03-19T11:25:00.000Z",
162
- createdAt: "2026-03-19T10:15:00.000Z"
163
- },
164
- {
165
- id: "wfappr_vendor_legal",
166
- stepId: "wfstep_vendor_legal",
167
- status: "APPROVED",
168
- actorId: "legal.demo",
169
- comment: "MSA redlines are complete.",
170
- decidedAt: "2026-03-19T13:05:00.000Z",
171
- createdAt: "2026-03-19T11:30:00.000Z"
172
- }
173
- ]
174
- },
175
- {
176
- id: "wfinst_policy_rejected",
177
- definitionId: "wf_policy_exception",
178
- status: "REJECTED",
179
- currentStepId: "wfstep_policy_compliance",
180
- data: {
181
- policy: "Model rollout freeze",
182
- durationDays: 14
183
- },
184
- requestedBy: "maya@contractspec.io",
185
- startedAt: "2026-03-18T10:00:00.000Z",
186
- completedAt: "2026-03-18T11:20:00.000Z",
187
- approvals: [
188
- {
189
- id: "wfappr_policy_lead",
190
- stepId: "wfstep_policy_lead",
191
- status: "APPROVED",
192
- actorId: "lead.demo",
193
- comment: "Escalation justified for the release train.",
194
- decidedAt: "2026-03-18T10:30:00.000Z",
195
- createdAt: "2026-03-18T10:05:00.000Z"
196
- },
197
- {
198
- id: "wfappr_policy_compliance",
199
- stepId: "wfstep_policy_compliance",
200
- status: "REJECTED",
201
- actorId: "compliance.demo",
202
- comment: "Exception exceeds the allowed blast radius.",
203
- decidedAt: "2026-03-18T11:15:00.000Z",
204
- createdAt: "2026-03-18T10:35:00.000Z"
205
- }
206
- ]
207
- }
208
- ];
2
+ var L="workflow-system-demo",V="org_demo",i=[{id:"wf_expense",name:"Expense Approval",description:"Approve non-trivial spend before finance releases budget.",type:"APPROVAL",status:"ACTIVE",createdAt:"2026-03-10T09:00:00.000Z",updatedAt:"2026-03-20T08:15:00.000Z",steps:[{id:"wfstep_expense_manager",name:"Manager Review",description:"Validate business value and team budget.",stepOrder:1,type:"APPROVAL",requiredRoles:["manager"],createdAt:"2026-03-10T09:00:00.000Z"},{id:"wfstep_expense_finance",name:"Finance Review",description:"Confirm ledger coding and spending threshold.",stepOrder:2,type:"APPROVAL",requiredRoles:["finance"],createdAt:"2026-03-10T09:10:00.000Z"}]},{id:"wf_vendor",name:"Vendor Onboarding",description:"Sequence security, procurement, and legal before activation.",type:"SEQUENTIAL",status:"ACTIVE",createdAt:"2026-03-08T11:00:00.000Z",updatedAt:"2026-03-19T13:10:00.000Z",steps:[{id:"wfstep_vendor_security",name:"Security Check",description:"Review data access and integration scope.",stepOrder:1,type:"APPROVAL",requiredRoles:["security"],createdAt:"2026-03-08T11:00:00.000Z"},{id:"wfstep_vendor_procurement",name:"Procurement Check",description:"Validate pricing, procurement policy, and owner.",stepOrder:2,type:"APPROVAL",requiredRoles:["procurement"],createdAt:"2026-03-08T11:05:00.000Z"},{id:"wfstep_vendor_legal",name:"Legal Sign-off",description:"Approve terms before the vendor goes live.",stepOrder:3,type:"APPROVAL",requiredRoles:["legal"],createdAt:"2026-03-08T11:10:00.000Z"}]},{id:"wf_policy_exception",name:"Policy Exception",description:"Escalate a temporary exception through team lead and compliance.",type:"APPROVAL",status:"DRAFT",createdAt:"2026-03-15T07:30:00.000Z",updatedAt:"2026-03-18T11:20:00.000Z",steps:[{id:"wfstep_policy_lead",name:"Team Lead Review",description:"Check urgency and expected blast radius.",stepOrder:1,type:"APPROVAL",requiredRoles:["team-lead"],createdAt:"2026-03-15T07:30:00.000Z"},{id:"wfstep_policy_compliance",name:"Compliance Review",description:"Accept or reject the exception request.",stepOrder:2,type:"APPROVAL",requiredRoles:["compliance"],createdAt:"2026-03-15T07:40:00.000Z"}]}],O=[{id:"wfinst_expense_open",definitionId:"wf_expense",status:"IN_PROGRESS",currentStepId:"wfstep_expense_finance",data:{amount:4200,currency:"EUR",vendor:"Nimbus AI"},requestedBy:"sarah@contractspec.io",startedAt:"2026-03-20T08:00:00.000Z",approvals:[{id:"wfappr_expense_manager",stepId:"wfstep_expense_manager",status:"APPROVED",actorId:"manager.demo",comment:"Approved for the Q2 automation budget.",decidedAt:"2026-03-20T08:15:00.000Z",createdAt:"2026-03-20T08:05:00.000Z"},{id:"wfappr_expense_finance",stepId:"wfstep_expense_finance",status:"PENDING",createdAt:"2026-03-20T08:15:00.000Z"}]},{id:"wfinst_vendor_done",definitionId:"wf_vendor",status:"COMPLETED",data:{vendor:"Acme Cloud",riskTier:"medium"},requestedBy:"leo@contractspec.io",startedAt:"2026-03-19T09:30:00.000Z",completedAt:"2026-03-19T13:10:00.000Z",approvals:[{id:"wfappr_vendor_security",stepId:"wfstep_vendor_security",status:"APPROVED",actorId:"security.demo",comment:"SOC2 scope is acceptable.",decidedAt:"2026-03-19T10:10:00.000Z",createdAt:"2026-03-19T09:35:00.000Z"},{id:"wfappr_vendor_procurement",stepId:"wfstep_vendor_procurement",status:"APPROVED",actorId:"procurement.demo",comment:"Commercial terms match the preferred vendor tier.",decidedAt:"2026-03-19T11:25:00.000Z",createdAt:"2026-03-19T10:15:00.000Z"},{id:"wfappr_vendor_legal",stepId:"wfstep_vendor_legal",status:"APPROVED",actorId:"legal.demo",comment:"MSA redlines are complete.",decidedAt:"2026-03-19T13:05:00.000Z",createdAt:"2026-03-19T11:30:00.000Z"}]},{id:"wfinst_policy_rejected",definitionId:"wf_policy_exception",status:"REJECTED",currentStepId:"wfstep_policy_compliance",data:{policy:"Model rollout freeze",durationDays:14},requestedBy:"maya@contractspec.io",startedAt:"2026-03-18T10:00:00.000Z",completedAt:"2026-03-18T11:20:00.000Z",approvals:[{id:"wfappr_policy_lead",stepId:"wfstep_policy_lead",status:"APPROVED",actorId:"lead.demo",comment:"Escalation justified for the release train.",decidedAt:"2026-03-18T10:30:00.000Z",createdAt:"2026-03-18T10:05:00.000Z"},{id:"wfappr_policy_compliance",stepId:"wfstep_policy_compliance",status:"REJECTED",actorId:"compliance.demo",comment:"Exception exceeds the allowed blast radius.",decidedAt:"2026-03-18T11:15:00.000Z",createdAt:"2026-03-18T10:35:00.000Z"}]}];import{defineVisualization as A,VisualizationRegistry as l}from"@contractspec/lib.contracts-spec/visualizations";var _={key:"workflow.instance.list",version:"1.0.0"},s={version:"1.0.0",domain:"workflow",stability:"experimental",owners:["@example.workflow-system"],tags:["workflow","visualization","operations"]},T=A({meta:{...s,key:"workflow-system.visualization.instance-status",title:"Instance Status Breakdown",description:"Distribution of workflow instance states.",goal:"Surface the current workload mix.",context:"Workflow operations overview."},source:{primary:_,resultPath:"data"},visualization:{kind:"pie",nameDimension:"status",valueMeasure:"instances",dimensions:[{key:"status",label:"Status",dataPath:"status",type:"category"}],measures:[{key:"instances",label:"Instances",dataPath:"instances",format:"number"}],table:{caption:"Workflow instance counts by status."}}}),E=A({meta:{...s,key:"workflow-system.visualization.throughput",title:"Run Throughput",description:"Daily workflow instance starts.",goal:"Show operational throughput over time.",context:"Workflow trend monitoring."},source:{primary:_,resultPath:"data"},visualization:{kind:"cartesian",variant:"line",xDimension:"day",yMeasures:["instances"],dimensions:[{key:"day",label:"Day",dataPath:"day",type:"time"}],measures:[{key:"instances",label:"Instances",dataPath:"instances",format:"number",color:"#0f766e"}],table:{caption:"Daily workflow instance starts."}}}),R=A({meta:{...s,key:"workflow-system.visualization.active-work",title:"Active Work",description:"Current in-flight or pending workflow instances.",goal:"Expose active operational workload.",context:"Workflow workload comparison."},source:{primary:_,resultPath:"data"},visualization:{kind:"metric",measure:"value",measures:[{key:"value",label:"Instances",dataPath:"value",format:"number"}],table:{caption:"Active workflow count."}}}),w=A({meta:{...s,key:"workflow-system.visualization.completed-work",title:"Completed Work",description:"Completed workflow instances in the current sample.",goal:"Show output against active workload.",context:"Workflow workload comparison."},source:{primary:_,resultPath:"data"},visualization:{kind:"metric",measure:"value",measures:[{key:"value",label:"Instances",dataPath:"value",format:"number"}],table:{caption:"Completed workflow count."}}}),P=[T,E,R,w],b=new l([...P]),k=P.map((t)=>({key:t.meta.key,version:t.meta.version}));function D(t){return(t instanceof Date?t:new Date(t)).toISOString().slice(0,10)}function g(t){let p=new Map,r=new Map,o=0,a=0;for(let e of t){p.set(e.status,(p.get(e.status)??0)+1);let c=D(e.startedAt);if(r.set(c,(r.get(c)??0)+1),e.status==="PENDING"||e.status==="IN_PROGRESS")o+=1;if(e.status==="COMPLETED")a+=1}return{primaryItems:[{key:"workflow-status",spec:T,data:{data:Array.from(p.entries()).map(([e,c])=>({status:e,instances:c}))},title:"Instance Status Breakdown",description:"Status mix across workflow instances.",height:260},{key:"workflow-throughput",spec:E,data:{data:Array.from(r.entries()).sort(([e],[c])=>e.localeCompare(c)).map(([e,c])=>({day:e,instances:c}))},title:"Run Throughput",description:"Daily workflow starts from current instances."}],comparisonItems:[{key:"workflow-active",spec:R,data:{data:[{value:o}]},title:"Active Work",description:"Pending and in-progress workflows.",height:200},{key:"workflow-completed",spec:w,data:{data:[{value:a}]},title:"Completed Work",description:"Completed workflows in the current sample.",height:200}]}}var n=i,y=O,Z=new Map(n.map((t)=>[t.id,t]));function f(t){return new Date(t).toISOString().slice(0,10)}var u={target:"markdown",render:async(t)=>{if(t.source.type!=="component"||t.source.componentKey!=="WorkflowDashboard")throw Error("workflowDashboardMarkdownRenderer: not WorkflowDashboard");let p=n,r=y,o=g(r),a=p.filter((e)=>e.status==="ACTIVE"),m=r.filter((e)=>e.status==="PENDING"||e.status==="IN_PROGRESS"),d=["# Workflow Dashboard","","> Seeded workflow and approval overview for the sandbox demo.","","## Summary","","| Metric | Value |","|--------|-------|",`| Active Workflows | ${a.length} |`,`| Awaiting Action | ${m.length} |`,`| Completed | ${r.filter((e)=>e.status==="COMPLETED").length} |`,`| Rejected | ${r.filter((e)=>e.status==="REJECTED").length} |`,""];d.push("## Visualization Overview"),d.push("");for(let e of[...o.primaryItems,...o.comparisonItems])d.push(`- **${e.title}** via \`${e.spec.meta.key}\``);if(d.push(""),d.push("## Active Workflow Definitions"),d.push(""),a.length===0)d.push("_No active workflow definitions._");else{d.push("| Name | Type | Steps | Status |"),d.push("|------|------|-------|--------|");for(let e of a)d.push(`| ${e.name} | ${e.type} | ${e.steps.length} | ${e.status} |`)}if(d.push(""),d.push("## Recent Instances"),d.push(""),r.length===0)d.push("_No workflow instances._");else{d.push("| Workflow | Requested By | Status | Started |"),d.push("|----------|--------------|--------|---------|");for(let e of r.slice(0,10)){let c=f(e.startedAt),I=Z.get(e.definitionId)?.name??e.definitionId;d.push(`| ${I} | ${e.requestedBy} | ${e.status} | ${c} |`)}}return{mimeType:"text/markdown",body:d.join(`
3
+ `)}}},S={target:"markdown",render:async(t)=>{if(t.source.type!=="component"||t.source.componentKey!=="WorkflowDefinitionList")throw Error("workflowDefinitionListMarkdownRenderer: not WorkflowDefinitionList");let p=n,r=["# Workflow Definitions","","> Configure automated approval and process workflows",""];for(let o of p){r.push(`## ${o.name}`),r.push(""),r.push(`**Type:** ${o.type} | **Status:** ${o.status}`),r.push(""),r.push("### Steps"),r.push("");for(let a of o.steps)r.push(`${a.stepOrder}. **${a.name}** - Roles: ${a.requiredRoles.join(", ")}`);r.push("")}return{mimeType:"text/markdown",body:r.join(`
4
+ `)}}},x={target:"markdown",render:async(t)=>{if(t.source.type!=="component"||t.source.componentKey!=="WorkflowInstanceDetail")throw Error("workflowInstanceDetailMarkdownRenderer: not WorkflowInstanceDetail");let p=y.find((a)=>a.status==="IN_PROGRESS")??y[0];if(!p)return{mimeType:"text/markdown",body:`# No Workflow Instances
209
5
 
210
- // src/visualizations/catalog.ts
211
- import {
212
- defineVisualization,
213
- VisualizationRegistry
214
- } from "@contractspec/lib.contracts-spec/visualizations";
215
- var INSTANCE_LIST_REF = {
216
- key: "workflow.instance.list",
217
- version: "1.0.0"
218
- };
219
- var META = {
220
- version: "1.0.0",
221
- domain: "workflow",
222
- stability: "experimental",
223
- owners: ["@example.workflow-system"],
224
- tags: ["workflow", "visualization", "operations"]
225
- };
226
- var WorkflowInstanceStatusVisualization = defineVisualization({
227
- meta: {
228
- ...META,
229
- key: "workflow-system.visualization.instance-status",
230
- title: "Instance Status Breakdown",
231
- description: "Distribution of workflow instance states.",
232
- goal: "Surface the current workload mix.",
233
- context: "Workflow operations overview."
234
- },
235
- source: { primary: INSTANCE_LIST_REF, resultPath: "data" },
236
- visualization: {
237
- kind: "pie",
238
- nameDimension: "status",
239
- valueMeasure: "instances",
240
- dimensions: [
241
- { key: "status", label: "Status", dataPath: "status", type: "category" }
242
- ],
243
- measures: [
244
- {
245
- key: "instances",
246
- label: "Instances",
247
- dataPath: "instances",
248
- format: "number"
249
- }
250
- ],
251
- table: { caption: "Workflow instance counts by status." }
252
- }
253
- });
254
- var WorkflowThroughputVisualization = defineVisualization({
255
- meta: {
256
- ...META,
257
- key: "workflow-system.visualization.throughput",
258
- title: "Run Throughput",
259
- description: "Daily workflow instance starts.",
260
- goal: "Show operational throughput over time.",
261
- context: "Workflow trend monitoring."
262
- },
263
- source: { primary: INSTANCE_LIST_REF, resultPath: "data" },
264
- visualization: {
265
- kind: "cartesian",
266
- variant: "line",
267
- xDimension: "day",
268
- yMeasures: ["instances"],
269
- dimensions: [{ key: "day", label: "Day", dataPath: "day", type: "time" }],
270
- measures: [
271
- {
272
- key: "instances",
273
- label: "Instances",
274
- dataPath: "instances",
275
- format: "number",
276
- color: "#0f766e"
277
- }
278
- ],
279
- table: { caption: "Daily workflow instance starts." }
280
- }
281
- });
282
- var WorkflowActiveMetricVisualization = defineVisualization({
283
- meta: {
284
- ...META,
285
- key: "workflow-system.visualization.active-work",
286
- title: "Active Work",
287
- description: "Current in-flight or pending workflow instances.",
288
- goal: "Expose active operational workload.",
289
- context: "Workflow workload comparison."
290
- },
291
- source: { primary: INSTANCE_LIST_REF, resultPath: "data" },
292
- visualization: {
293
- kind: "metric",
294
- measure: "value",
295
- measures: [
296
- { key: "value", label: "Instances", dataPath: "value", format: "number" }
297
- ],
298
- table: { caption: "Active workflow count." }
299
- }
300
- });
301
- var WorkflowCompletedMetricVisualization = defineVisualization({
302
- meta: {
303
- ...META,
304
- key: "workflow-system.visualization.completed-work",
305
- title: "Completed Work",
306
- description: "Completed workflow instances in the current sample.",
307
- goal: "Show output against active workload.",
308
- context: "Workflow workload comparison."
309
- },
310
- source: { primary: INSTANCE_LIST_REF, resultPath: "data" },
311
- visualization: {
312
- kind: "metric",
313
- measure: "value",
314
- measures: [
315
- { key: "value", label: "Instances", dataPath: "value", format: "number" }
316
- ],
317
- table: { caption: "Completed workflow count." }
318
- }
319
- });
320
- var WorkflowVisualizationSpecs = [
321
- WorkflowInstanceStatusVisualization,
322
- WorkflowThroughputVisualization,
323
- WorkflowActiveMetricVisualization,
324
- WorkflowCompletedMetricVisualization
325
- ];
326
- var WorkflowVisualizationRegistry = new VisualizationRegistry([
327
- ...WorkflowVisualizationSpecs
328
- ]);
329
- var WorkflowVisualizationRefs = WorkflowVisualizationSpecs.map((spec) => ({
330
- key: spec.meta.key,
331
- version: spec.meta.version
332
- }));
333
-
334
- // src/visualizations/selectors.ts
335
- function toDayKey(value) {
336
- const date = value instanceof Date ? value : new Date(value);
337
- return date.toISOString().slice(0, 10);
338
- }
339
- function createWorkflowVisualizationSections(instances) {
340
- const statusCounts = new Map;
341
- const throughput = new Map;
342
- let activeCount = 0;
343
- let completedCount = 0;
344
- for (const instance of instances) {
345
- statusCounts.set(instance.status, (statusCounts.get(instance.status) ?? 0) + 1);
346
- const day = toDayKey(instance.startedAt);
347
- throughput.set(day, (throughput.get(day) ?? 0) + 1);
348
- if (instance.status === "PENDING" || instance.status === "IN_PROGRESS") {
349
- activeCount += 1;
350
- }
351
- if (instance.status === "COMPLETED") {
352
- completedCount += 1;
353
- }
354
- }
355
- const primaryItems = [
356
- {
357
- key: "workflow-status",
358
- spec: WorkflowInstanceStatusVisualization,
359
- data: {
360
- data: Array.from(statusCounts.entries()).map(([status, count]) => ({
361
- status,
362
- instances: count
363
- }))
364
- },
365
- title: "Instance Status Breakdown",
366
- description: "Status mix across workflow instances.",
367
- height: 260
368
- },
369
- {
370
- key: "workflow-throughput",
371
- spec: WorkflowThroughputVisualization,
372
- data: {
373
- data: Array.from(throughput.entries()).sort(([left], [right]) => left.localeCompare(right)).map(([day, count]) => ({ day, instances: count }))
374
- },
375
- title: "Run Throughput",
376
- description: "Daily workflow starts from current instances."
377
- }
378
- ];
379
- const comparisonItems = [
380
- {
381
- key: "workflow-active",
382
- spec: WorkflowActiveMetricVisualization,
383
- data: { data: [{ value: activeCount }] },
384
- title: "Active Work",
385
- description: "Pending and in-progress workflows.",
386
- height: 200
387
- },
388
- {
389
- key: "workflow-completed",
390
- spec: WorkflowCompletedMetricVisualization,
391
- data: { data: [{ value: completedCount }] },
392
- title: "Completed Work",
393
- description: "Completed workflows in the current sample.",
394
- height: 200
395
- }
396
- ];
397
- return {
398
- primaryItems,
399
- comparisonItems
400
- };
401
- }
402
- // src/ui/renderers/workflow.markdown.ts
403
- var workflowDefinitions = WORKFLOW_SYSTEM_DEMO_DEFINITIONS;
404
- var workflowInstances = WORKFLOW_SYSTEM_DEMO_INSTANCES;
405
- var workflowDefinitionById = new Map(workflowDefinitions.map((definition) => [definition.id, definition]));
406
- function formatDate(value) {
407
- return new Date(value).toISOString().slice(0, 10);
408
- }
409
- var workflowDashboardMarkdownRenderer = {
410
- target: "markdown",
411
- render: async (desc) => {
412
- if (desc.source.type !== "component" || desc.source.componentKey !== "WorkflowDashboard") {
413
- throw new Error("workflowDashboardMarkdownRenderer: not WorkflowDashboard");
414
- }
415
- const definitions = workflowDefinitions;
416
- const instances = workflowInstances;
417
- const visualizations = createWorkflowVisualizationSections(instances);
418
- const activeDefinitions = definitions.filter((d) => d.status === "ACTIVE");
419
- const awaitingActionInstances = instances.filter((i) => i.status === "PENDING" || i.status === "IN_PROGRESS");
420
- const lines = [
421
- "# Workflow Dashboard",
422
- "",
423
- "> Seeded workflow and approval overview for the sandbox demo.",
424
- "",
425
- "## Summary",
426
- "",
427
- "| Metric | Value |",
428
- "|--------|-------|",
429
- `| Active Workflows | ${activeDefinitions.length} |`,
430
- `| Awaiting Action | ${awaitingActionInstances.length} |`,
431
- `| Completed | ${instances.filter((i) => i.status === "COMPLETED").length} |`,
432
- `| Rejected | ${instances.filter((i) => i.status === "REJECTED").length} |`,
433
- ""
434
- ];
435
- lines.push("## Visualization Overview");
436
- lines.push("");
437
- for (const item of [
438
- ...visualizations.primaryItems,
439
- ...visualizations.comparisonItems
440
- ]) {
441
- lines.push(`- **${item.title}** via \`${item.spec.meta.key}\``);
442
- }
443
- lines.push("");
444
- lines.push("## Active Workflow Definitions");
445
- lines.push("");
446
- if (activeDefinitions.length === 0) {
447
- lines.push("_No active workflow definitions._");
448
- } else {
449
- lines.push("| Name | Type | Steps | Status |");
450
- lines.push("|------|------|-------|--------|");
451
- for (const def of activeDefinitions) {
452
- lines.push(`| ${def.name} | ${def.type} | ${def.steps.length} | ${def.status} |`);
453
- }
454
- }
455
- lines.push("");
456
- lines.push("## Recent Instances");
457
- lines.push("");
458
- if (instances.length === 0) {
459
- lines.push("_No workflow instances._");
460
- } else {
461
- lines.push("| Workflow | Requested By | Status | Started |");
462
- lines.push("|----------|--------------|--------|---------|");
463
- for (const inst of instances.slice(0, 10)) {
464
- const startedDate = formatDate(inst.startedAt);
465
- const definitionName = workflowDefinitionById.get(inst.definitionId)?.name ?? inst.definitionId;
466
- lines.push(`| ${definitionName} | ${inst.requestedBy} | ${inst.status} | ${startedDate} |`);
467
- }
468
- }
469
- return {
470
- mimeType: "text/markdown",
471
- body: lines.join(`
472
- `)
473
- };
474
- }
475
- };
476
- var workflowDefinitionListMarkdownRenderer = {
477
- target: "markdown",
478
- render: async (desc) => {
479
- if (desc.source.type !== "component" || desc.source.componentKey !== "WorkflowDefinitionList") {
480
- throw new Error("workflowDefinitionListMarkdownRenderer: not WorkflowDefinitionList");
481
- }
482
- const definitions = workflowDefinitions;
483
- const lines = [
484
- "# Workflow Definitions",
485
- "",
486
- "> Configure automated approval and process workflows",
487
- ""
488
- ];
489
- for (const def of definitions) {
490
- lines.push(`## ${def.name}`);
491
- lines.push("");
492
- lines.push(`**Type:** ${def.type} | **Status:** ${def.status}`);
493
- lines.push("");
494
- lines.push("### Steps");
495
- lines.push("");
496
- for (const step of def.steps) {
497
- lines.push(`${step.stepOrder}. **${step.name}** - Roles: ${step.requiredRoles.join(", ")}`);
498
- }
499
- lines.push("");
500
- }
501
- return {
502
- mimeType: "text/markdown",
503
- body: lines.join(`
504
- `)
505
- };
506
- }
507
- };
508
- var workflowInstanceDetailMarkdownRenderer = {
509
- target: "markdown",
510
- render: async (desc) => {
511
- if (desc.source.type !== "component" || desc.source.componentKey !== "WorkflowInstanceDetail") {
512
- throw new Error("workflowInstanceDetailMarkdownRenderer: not WorkflowInstanceDetail");
513
- }
514
- const instance = workflowInstances.find((workflowInstance) => workflowInstance.status === "IN_PROGRESS") ?? workflowInstances[0];
515
- if (!instance) {
516
- return {
517
- mimeType: "text/markdown",
518
- body: `# No Workflow Instances
519
-
520
- No workflow instances available.`
521
- };
522
- }
523
- const definition = workflowDefinitions.find((d) => d.id === instance.definitionId);
524
- const lines = [
525
- `# Workflow: ${definition?.name ?? instance.definitionId}`,
526
- "",
527
- `**Instance ID:** ${instance.id}`,
528
- `**Status:** ${instance.status}`,
529
- `**Requested By:** ${instance.requestedBy}`,
530
- `**Started:** ${formatDate(instance.startedAt)}`,
531
- "",
532
- "## Steps Progress",
533
- ""
534
- ];
535
- if (definition) {
536
- for (const step of definition.steps) {
537
- const isCurrent = step.id === instance.currentStepId;
538
- const isCompleted = definition.steps.indexOf(step) < definition.steps.findIndex((s) => s.id === instance.currentStepId);
539
- let status = "\u2B1C Pending";
540
- if (isCompleted)
541
- status = "\u2705 Completed";
542
- if (isCurrent)
543
- status = "\uD83D\uDD04 In Progress";
544
- lines.push(`- ${status} **${step.name}**`);
545
- }
546
- }
547
- lines.push("");
548
- lines.push("## Actions");
549
- lines.push("");
550
- lines.push("- **Approve** - Move to next step");
551
- lines.push("- **Reject** - End the workflow with a rejection outcome");
552
- lines.push("- **Delegate** - Assign to another approver");
553
- return {
554
- mimeType: "text/markdown",
555
- body: lines.join(`
556
- `)
557
- };
558
- }
559
- };
560
- export {
561
- workflowInstanceDetailMarkdownRenderer,
562
- workflowDefinitionListMarkdownRenderer,
563
- workflowDashboardMarkdownRenderer
564
- };
6
+ No workflow instances available.`};let r=n.find((a)=>a.id===p.definitionId),o=[`# Workflow: ${r?.name??p.definitionId}`,"",`**Instance ID:** ${p.id}`,`**Status:** ${p.status}`,`**Requested By:** ${p.requestedBy}`,`**Started:** ${f(p.startedAt)}`,"","## Steps Progress",""];if(r)for(let a of r.steps){let m=a.id===p.currentStepId,d=r.steps.indexOf(a)<r.steps.findIndex((c)=>c.id===p.currentStepId),e="\u2B1C Pending";if(d)e="\u2705 Completed";if(m)e="\uD83D\uDD04 In Progress";o.push(`- ${e} **${a.name}**`)}return o.push(""),o.push("## Actions"),o.push(""),o.push("- **Approve** - Move to next step"),o.push("- **Reject** - End the workflow with a rejection outcome"),o.push("- **Delegate** - Assign to another approver"),{mimeType:"text/markdown",body:o.join(`
7
+ `)}}};export{x as workflowInstanceDetailMarkdownRenderer,S as workflowDefinitionListMarkdownRenderer,u as workflowDashboardMarkdownRenderer};