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