@contractspec/example.workflow-system 3.7.7 → 3.8.2
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/README.md +3 -0
- package/dist/browser/handlers/index.js +43 -43
- package/dist/browser/handlers/workflow.handlers.js +43 -43
- package/dist/browser/index.js +572 -183
- package/dist/browser/shared/demo-scenario.js +213 -0
- package/dist/browser/ui/WorkflowDashboard.visualizations.js +239 -0
- package/dist/browser/ui/hooks/index.js +0 -47
- package/dist/browser/ui/hooks/useWorkflowList.js +5 -3
- package/dist/browser/ui/index.js +5 -3
- package/dist/browser/ui/renderers/index.js +409 -73
- package/dist/browser/ui/renderers/workflow.markdown.js +409 -73
- package/dist/browser/visualizations/catalog.js +132 -0
- package/dist/browser/visualizations/index.js +133 -0
- package/dist/browser/visualizations/selectors.js +195 -0
- package/dist/example.test.d.ts +1 -0
- package/dist/handlers/index.js +43 -43
- package/dist/handlers/workflow.handlers.js +43 -43
- package/dist/index.d.ts +1 -0
- package/dist/index.js +572 -183
- package/dist/shared/demo-scenario.d.ts +43 -0
- package/dist/shared/demo-scenario.js +214 -0
- package/dist/ui/WorkflowDashboard.visualizations.d.ts +4 -0
- package/dist/ui/WorkflowDashboard.visualizations.js +240 -0
- package/dist/ui/hooks/index.js +0 -47
- package/dist/ui/hooks/useWorkflowList.d.ts +2 -1
- package/dist/ui/hooks/useWorkflowList.js +5 -3
- package/dist/ui/index.js +5 -3
- package/dist/ui/renderers/index.js +409 -73
- package/dist/ui/renderers/workflow.markdown.js +409 -73
- package/dist/visualizations/catalog.d.ts +11 -0
- package/dist/visualizations/catalog.js +133 -0
- package/dist/visualizations/index.d.ts +2 -0
- package/dist/visualizations/index.js +134 -0
- package/dist/visualizations/selectors.d.ts +11 -0
- package/dist/visualizations/selectors.js +196 -0
- package/dist/visualizations/selectors.test.d.ts +1 -0
- package/package.json +69 -8
|
@@ -1,112 +1,447 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
var
|
|
1
|
+
// src/shared/demo-scenario.ts
|
|
2
|
+
var WORKFLOW_SYSTEM_DEMO_PROJECT_ID = "workflow-system-demo";
|
|
3
|
+
var WORKFLOW_SYSTEM_DEMO_ORGANIZATION_ID = "org_demo";
|
|
4
|
+
var WORKFLOW_SYSTEM_DEMO_DEFINITIONS = [
|
|
3
5
|
{
|
|
4
|
-
id: "
|
|
5
|
-
name: "
|
|
6
|
+
id: "wf_expense",
|
|
7
|
+
name: "Expense Approval",
|
|
8
|
+
description: "Approve non-trivial spend before finance releases budget.",
|
|
6
9
|
type: "APPROVAL",
|
|
10
|
+
status: "ACTIVE",
|
|
11
|
+
createdAt: "2026-03-10T09:00:00.000Z",
|
|
12
|
+
updatedAt: "2026-03-20T08:15:00.000Z",
|
|
7
13
|
steps: [
|
|
8
14
|
{
|
|
9
|
-
id: "
|
|
15
|
+
id: "wfstep_expense_manager",
|
|
10
16
|
name: "Manager Review",
|
|
11
|
-
|
|
12
|
-
|
|
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"
|
|
13
22
|
},
|
|
14
23
|
{
|
|
15
|
-
id: "
|
|
24
|
+
id: "wfstep_expense_finance",
|
|
16
25
|
name: "Finance Review",
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
+
]
|
|
23
33
|
},
|
|
24
34
|
{
|
|
25
|
-
id: "
|
|
26
|
-
name: "
|
|
27
|
-
|
|
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",
|
|
28
42
|
steps: [
|
|
29
43
|
{
|
|
30
|
-
id: "
|
|
31
|
-
name: "
|
|
32
|
-
|
|
33
|
-
|
|
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"
|
|
34
51
|
},
|
|
35
|
-
{
|
|
36
|
-
|
|
37
|
-
|
|
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
|
+
]
|
|
38
71
|
},
|
|
39
72
|
{
|
|
40
|
-
id: "
|
|
41
|
-
name: "
|
|
42
|
-
|
|
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",
|
|
43
80
|
steps: [
|
|
44
|
-
{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
+
]
|
|
49
100
|
}
|
|
50
101
|
];
|
|
51
|
-
var
|
|
102
|
+
var WORKFLOW_SYSTEM_DEMO_INSTANCES = [
|
|
52
103
|
{
|
|
53
|
-
id: "
|
|
54
|
-
definitionId: "
|
|
55
|
-
definitionName: "Purchase Approval",
|
|
104
|
+
id: "wfinst_expense_open",
|
|
105
|
+
definitionId: "wf_expense",
|
|
56
106
|
status: "IN_PROGRESS",
|
|
57
|
-
currentStepId: "
|
|
58
|
-
|
|
59
|
-
|
|
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
|
+
]
|
|
60
132
|
},
|
|
61
133
|
{
|
|
62
|
-
id: "
|
|
63
|
-
definitionId: "
|
|
64
|
-
definitionName: "Purchase Approval",
|
|
134
|
+
id: "wfinst_vendor_done",
|
|
135
|
+
definitionId: "wf_vendor",
|
|
65
136
|
status: "COMPLETED",
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
+
]
|
|
70
173
|
},
|
|
71
174
|
{
|
|
72
|
-
id: "
|
|
73
|
-
definitionId: "
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
+
]
|
|
79
206
|
}
|
|
80
207
|
];
|
|
208
|
+
|
|
209
|
+
// src/visualizations/catalog.ts
|
|
210
|
+
import {
|
|
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
|
+
}
|
|
81
408
|
var workflowDashboardMarkdownRenderer = {
|
|
82
409
|
target: "markdown",
|
|
83
410
|
render: async (desc) => {
|
|
84
411
|
if (desc.source.type !== "component" || desc.source.componentKey !== "WorkflowDashboard") {
|
|
85
412
|
throw new Error("workflowDashboardMarkdownRenderer: not WorkflowDashboard");
|
|
86
413
|
}
|
|
87
|
-
const definitions =
|
|
88
|
-
const instances =
|
|
414
|
+
const definitions = workflowDefinitions;
|
|
415
|
+
const instances = workflowInstances;
|
|
416
|
+
const visualizations = createWorkflowVisualizationSections(instances);
|
|
89
417
|
const activeDefinitions = definitions.filter((d) => d.status === "ACTIVE");
|
|
90
|
-
const
|
|
91
|
-
const inProgressInstances = instances.filter((i) => i.status === "IN_PROGRESS");
|
|
92
|
-
const completedInstances = instances.filter((i) => i.status === "COMPLETED");
|
|
418
|
+
const awaitingActionInstances = instances.filter((i) => i.status === "PENDING" || i.status === "IN_PROGRESS");
|
|
93
419
|
const lines = [
|
|
94
420
|
"# Workflow Dashboard",
|
|
95
421
|
"",
|
|
96
|
-
">
|
|
422
|
+
"> Seeded workflow and approval overview for the sandbox demo.",
|
|
97
423
|
"",
|
|
98
424
|
"## Summary",
|
|
99
425
|
"",
|
|
100
426
|
"| Metric | Value |",
|
|
101
427
|
"|--------|-------|",
|
|
102
428
|
`| Active Workflows | ${activeDefinitions.length} |`,
|
|
103
|
-
`|
|
|
104
|
-
`|
|
|
105
|
-
`|
|
|
106
|
-
"",
|
|
107
|
-
"## Active Workflow Definitions",
|
|
429
|
+
`| Awaiting Action | ${awaitingActionInstances.length} |`,
|
|
430
|
+
`| Completed | ${instances.filter((i) => i.status === "COMPLETED").length} |`,
|
|
431
|
+
`| Rejected | ${instances.filter((i) => i.status === "REJECTED").length} |`,
|
|
108
432
|
""
|
|
109
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("");
|
|
110
445
|
if (activeDefinitions.length === 0) {
|
|
111
446
|
lines.push("_No active workflow definitions._");
|
|
112
447
|
} else {
|
|
@@ -125,8 +460,9 @@ var workflowDashboardMarkdownRenderer = {
|
|
|
125
460
|
lines.push("| Workflow | Requested By | Status | Started |");
|
|
126
461
|
lines.push("|----------|--------------|--------|---------|");
|
|
127
462
|
for (const inst of instances.slice(0, 10)) {
|
|
128
|
-
const startedDate =
|
|
129
|
-
|
|
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} |`);
|
|
130
466
|
}
|
|
131
467
|
}
|
|
132
468
|
return {
|
|
@@ -142,7 +478,7 @@ var workflowDefinitionListMarkdownRenderer = {
|
|
|
142
478
|
if (desc.source.type !== "component" || desc.source.componentKey !== "WorkflowDefinitionList") {
|
|
143
479
|
throw new Error("workflowDefinitionListMarkdownRenderer: not WorkflowDefinitionList");
|
|
144
480
|
}
|
|
145
|
-
const definitions =
|
|
481
|
+
const definitions = workflowDefinitions;
|
|
146
482
|
const lines = [
|
|
147
483
|
"# Workflow Definitions",
|
|
148
484
|
"",
|
|
@@ -157,7 +493,7 @@ var workflowDefinitionListMarkdownRenderer = {
|
|
|
157
493
|
lines.push("### Steps");
|
|
158
494
|
lines.push("");
|
|
159
495
|
for (const step of def.steps) {
|
|
160
|
-
lines.push(`${step.
|
|
496
|
+
lines.push(`${step.stepOrder}. **${step.name}** - Roles: ${step.requiredRoles.join(", ")}`);
|
|
161
497
|
}
|
|
162
498
|
lines.push("");
|
|
163
499
|
}
|
|
@@ -174,7 +510,7 @@ var workflowInstanceDetailMarkdownRenderer = {
|
|
|
174
510
|
if (desc.source.type !== "component" || desc.source.componentKey !== "WorkflowInstanceDetail") {
|
|
175
511
|
throw new Error("workflowInstanceDetailMarkdownRenderer: not WorkflowInstanceDetail");
|
|
176
512
|
}
|
|
177
|
-
const instance =
|
|
513
|
+
const instance = workflowInstances.find((workflowInstance) => workflowInstance.status === "IN_PROGRESS") ?? workflowInstances[0];
|
|
178
514
|
if (!instance) {
|
|
179
515
|
return {
|
|
180
516
|
mimeType: "text/markdown",
|
|
@@ -183,14 +519,14 @@ var workflowInstanceDetailMarkdownRenderer = {
|
|
|
183
519
|
No workflow instances available.`
|
|
184
520
|
};
|
|
185
521
|
}
|
|
186
|
-
const definition =
|
|
522
|
+
const definition = workflowDefinitions.find((d) => d.id === instance.definitionId);
|
|
187
523
|
const lines = [
|
|
188
|
-
`# Workflow: ${instance.
|
|
524
|
+
`# Workflow: ${definition?.name ?? instance.definitionId}`,
|
|
189
525
|
"",
|
|
190
526
|
`**Instance ID:** ${instance.id}`,
|
|
191
527
|
`**Status:** ${instance.status}`,
|
|
192
528
|
`**Requested By:** ${instance.requestedBy}`,
|
|
193
|
-
`**Started:** ${
|
|
529
|
+
`**Started:** ${formatDate(instance.startedAt)}`,
|
|
194
530
|
"",
|
|
195
531
|
"## Steps Progress",
|
|
196
532
|
""
|
|
@@ -211,7 +547,7 @@ No workflow instances available.`
|
|
|
211
547
|
lines.push("## Actions");
|
|
212
548
|
lines.push("");
|
|
213
549
|
lines.push("- **Approve** - Move to next step");
|
|
214
|
-
lines.push("- **Reject** -
|
|
550
|
+
lines.push("- **Reject** - End the workflow with a rejection outcome");
|
|
215
551
|
lines.push("- **Delegate** - Assign to another approver");
|
|
216
552
|
return {
|
|
217
553
|
mimeType: "text/markdown",
|