@contractspec/example.workflow-system 3.7.6 → 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.
Files changed (57) hide show
  1. package/README.md +72 -119
  2. package/dist/approval/approval.event.js +1 -1
  3. package/dist/approval/approval.handler.d.ts +1 -1
  4. package/dist/approval/index.d.ts +4 -4
  5. package/dist/approval/index.js +1 -1
  6. package/dist/browser/approval/approval.event.js +1 -1
  7. package/dist/browser/approval/index.js +1 -1
  8. package/dist/browser/entities/index.js +166 -166
  9. package/dist/browser/handlers/index.js +43 -43
  10. package/dist/browser/handlers/workflow.handlers.js +43 -43
  11. package/dist/browser/index.js +1935 -1548
  12. package/dist/browser/instance/index.js +210 -210
  13. package/dist/browser/instance/instance.event.js +1 -1
  14. package/dist/browser/shared/demo-scenario.js +213 -0
  15. package/dist/browser/ui/WorkflowDashboard.visualizations.js +239 -0
  16. package/dist/browser/ui/hooks/index.js +0 -47
  17. package/dist/browser/ui/hooks/useWorkflowList.js +6 -4
  18. package/dist/browser/ui/index.js +6 -4
  19. package/dist/browser/ui/renderers/index.js +409 -73
  20. package/dist/browser/ui/renderers/workflow.markdown.js +409 -73
  21. package/dist/browser/visualizations/catalog.js +132 -0
  22. package/dist/browser/visualizations/index.js +133 -0
  23. package/dist/browser/visualizations/selectors.js +195 -0
  24. package/dist/entities/index.d.ts +53 -53
  25. package/dist/entities/index.js +166 -166
  26. package/dist/example.test.d.ts +1 -0
  27. package/dist/handlers/index.js +43 -43
  28. package/dist/handlers/workflow.handlers.js +43 -43
  29. package/dist/index.d.ts +6 -5
  30. package/dist/index.js +1935 -1548
  31. package/dist/instance/index.d.ts +3 -3
  32. package/dist/instance/index.js +210 -210
  33. package/dist/instance/instance.event.js +1 -1
  34. package/dist/instance/instance.handler.d.ts +1 -1
  35. package/dist/shared/demo-scenario.d.ts +43 -0
  36. package/dist/shared/demo-scenario.js +214 -0
  37. package/dist/shared/index.d.ts +1 -1
  38. package/dist/shared/mock-data.d.ts +1 -1
  39. package/dist/ui/WorkflowDashboard.visualizations.d.ts +4 -0
  40. package/dist/ui/WorkflowDashboard.visualizations.js +240 -0
  41. package/dist/ui/hooks/index.js +0 -47
  42. package/dist/ui/hooks/useWorkflowList.d.ts +2 -1
  43. package/dist/ui/hooks/useWorkflowList.js +6 -4
  44. package/dist/ui/index.d.ts +1 -1
  45. package/dist/ui/index.js +6 -4
  46. package/dist/ui/renderers/index.js +409 -73
  47. package/dist/ui/renderers/workflow.markdown.js +409 -73
  48. package/dist/visualizations/catalog.d.ts +11 -0
  49. package/dist/visualizations/catalog.js +133 -0
  50. package/dist/visualizations/index.d.ts +2 -0
  51. package/dist/visualizations/index.js +134 -0
  52. package/dist/visualizations/selectors.d.ts +11 -0
  53. package/dist/visualizations/selectors.js +196 -0
  54. package/dist/visualizations/selectors.test.d.ts +1 -0
  55. package/dist/workflow/index.d.ts +4 -4
  56. package/dist/workflow/workflow.handler.d.ts +1 -1
  57. package/package.json +71 -10
@@ -0,0 +1,214 @@
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
+ ];
209
+ export {
210
+ WORKFLOW_SYSTEM_DEMO_PROJECT_ID,
211
+ WORKFLOW_SYSTEM_DEMO_ORGANIZATION_ID,
212
+ WORKFLOW_SYSTEM_DEMO_INSTANCES,
213
+ WORKFLOW_SYSTEM_DEMO_DEFINITIONS
214
+ };
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * Shared utilities and types for workflow system.
3
3
  */
4
- export * from './types';
5
4
  export * from './mock-data';
5
+ export * from './types';
@@ -2,7 +2,7 @@
2
2
  * Mock data store for workflow system.
3
3
  * In production, this would be backed by a database.
4
4
  */
5
- import type { WorkflowDefinitionRecord, WorkflowStepRecord, WorkflowInstanceRecord, ApprovalRequestRecord } from './types';
5
+ import type { ApprovalRequestRecord, WorkflowDefinitionRecord, WorkflowInstanceRecord, WorkflowStepRecord } from './types';
6
6
  export declare const mockDataStore: {
7
7
  workflows: Map<string, WorkflowDefinitionRecord>;
8
8
  steps: Map<string, WorkflowStepRecord>;
@@ -0,0 +1,4 @@
1
+ import type { WorkflowInstance } from '../handlers/workflow.handlers';
2
+ export declare function WorkflowVisualizationOverview({ instances, }: {
3
+ instances: WorkflowInstance[];
4
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,240 @@
1
+ // @bun
2
+ // src/visualizations/catalog.ts
3
+ import {
4
+ defineVisualization,
5
+ VisualizationRegistry
6
+ } from "@contractspec/lib.contracts-spec/visualizations";
7
+ var INSTANCE_LIST_REF = {
8
+ key: "workflow.instance.list",
9
+ version: "1.0.0"
10
+ };
11
+ var META = {
12
+ version: "1.0.0",
13
+ domain: "workflow",
14
+ stability: "experimental",
15
+ owners: ["@example.workflow-system"],
16
+ tags: ["workflow", "visualization", "operations"]
17
+ };
18
+ var WorkflowInstanceStatusVisualization = defineVisualization({
19
+ meta: {
20
+ ...META,
21
+ key: "workflow-system.visualization.instance-status",
22
+ title: "Instance Status Breakdown",
23
+ description: "Distribution of workflow instance states.",
24
+ goal: "Surface the current workload mix.",
25
+ context: "Workflow operations overview."
26
+ },
27
+ source: { primary: INSTANCE_LIST_REF, resultPath: "data" },
28
+ visualization: {
29
+ kind: "pie",
30
+ nameDimension: "status",
31
+ valueMeasure: "instances",
32
+ dimensions: [
33
+ { key: "status", label: "Status", dataPath: "status", type: "category" }
34
+ ],
35
+ measures: [
36
+ {
37
+ key: "instances",
38
+ label: "Instances",
39
+ dataPath: "instances",
40
+ format: "number"
41
+ }
42
+ ],
43
+ table: { caption: "Workflow instance counts by status." }
44
+ }
45
+ });
46
+ var WorkflowThroughputVisualization = defineVisualization({
47
+ meta: {
48
+ ...META,
49
+ key: "workflow-system.visualization.throughput",
50
+ title: "Run Throughput",
51
+ description: "Daily workflow instance starts.",
52
+ goal: "Show operational throughput over time.",
53
+ context: "Workflow trend monitoring."
54
+ },
55
+ source: { primary: INSTANCE_LIST_REF, resultPath: "data" },
56
+ visualization: {
57
+ kind: "cartesian",
58
+ variant: "line",
59
+ xDimension: "day",
60
+ yMeasures: ["instances"],
61
+ dimensions: [{ key: "day", label: "Day", dataPath: "day", type: "time" }],
62
+ measures: [
63
+ {
64
+ key: "instances",
65
+ label: "Instances",
66
+ dataPath: "instances",
67
+ format: "number",
68
+ color: "#0f766e"
69
+ }
70
+ ],
71
+ table: { caption: "Daily workflow instance starts." }
72
+ }
73
+ });
74
+ var WorkflowActiveMetricVisualization = defineVisualization({
75
+ meta: {
76
+ ...META,
77
+ key: "workflow-system.visualization.active-work",
78
+ title: "Active Work",
79
+ description: "Current in-flight or pending workflow instances.",
80
+ goal: "Expose active operational workload.",
81
+ context: "Workflow workload comparison."
82
+ },
83
+ source: { primary: INSTANCE_LIST_REF, resultPath: "data" },
84
+ visualization: {
85
+ kind: "metric",
86
+ measure: "value",
87
+ measures: [
88
+ { key: "value", label: "Instances", dataPath: "value", format: "number" }
89
+ ],
90
+ table: { caption: "Active workflow count." }
91
+ }
92
+ });
93
+ var WorkflowCompletedMetricVisualization = defineVisualization({
94
+ meta: {
95
+ ...META,
96
+ key: "workflow-system.visualization.completed-work",
97
+ title: "Completed Work",
98
+ description: "Completed workflow instances in the current sample.",
99
+ goal: "Show output against active workload.",
100
+ context: "Workflow workload comparison."
101
+ },
102
+ source: { primary: INSTANCE_LIST_REF, resultPath: "data" },
103
+ visualization: {
104
+ kind: "metric",
105
+ measure: "value",
106
+ measures: [
107
+ { key: "value", label: "Instances", dataPath: "value", format: "number" }
108
+ ],
109
+ table: { caption: "Completed workflow count." }
110
+ }
111
+ });
112
+ var WorkflowVisualizationSpecs = [
113
+ WorkflowInstanceStatusVisualization,
114
+ WorkflowThroughputVisualization,
115
+ WorkflowActiveMetricVisualization,
116
+ WorkflowCompletedMetricVisualization
117
+ ];
118
+ var WorkflowVisualizationRegistry = new VisualizationRegistry([
119
+ ...WorkflowVisualizationSpecs
120
+ ]);
121
+ var WorkflowVisualizationRefs = WorkflowVisualizationSpecs.map((spec) => ({
122
+ key: spec.meta.key,
123
+ version: spec.meta.version
124
+ }));
125
+
126
+ // src/visualizations/selectors.ts
127
+ function toDayKey(value) {
128
+ const date = value instanceof Date ? value : new Date(value);
129
+ return date.toISOString().slice(0, 10);
130
+ }
131
+ function createWorkflowVisualizationSections(instances) {
132
+ const statusCounts = new Map;
133
+ const throughput = new Map;
134
+ let activeCount = 0;
135
+ let completedCount = 0;
136
+ for (const instance of instances) {
137
+ statusCounts.set(instance.status, (statusCounts.get(instance.status) ?? 0) + 1);
138
+ const day = toDayKey(instance.startedAt);
139
+ throughput.set(day, (throughput.get(day) ?? 0) + 1);
140
+ if (instance.status === "PENDING" || instance.status === "IN_PROGRESS") {
141
+ activeCount += 1;
142
+ }
143
+ if (instance.status === "COMPLETED") {
144
+ completedCount += 1;
145
+ }
146
+ }
147
+ const primaryItems = [
148
+ {
149
+ key: "workflow-status",
150
+ spec: WorkflowInstanceStatusVisualization,
151
+ data: {
152
+ data: Array.from(statusCounts.entries()).map(([status, count]) => ({
153
+ status,
154
+ instances: count
155
+ }))
156
+ },
157
+ title: "Instance Status Breakdown",
158
+ description: "Status mix across workflow instances.",
159
+ height: 260
160
+ },
161
+ {
162
+ key: "workflow-throughput",
163
+ spec: WorkflowThroughputVisualization,
164
+ data: {
165
+ data: Array.from(throughput.entries()).sort(([left], [right]) => left.localeCompare(right)).map(([day, count]) => ({ day, instances: count }))
166
+ },
167
+ title: "Run Throughput",
168
+ description: "Daily workflow starts from current instances."
169
+ }
170
+ ];
171
+ const comparisonItems = [
172
+ {
173
+ key: "workflow-active",
174
+ spec: WorkflowActiveMetricVisualization,
175
+ data: { data: [{ value: activeCount }] },
176
+ title: "Active Work",
177
+ description: "Pending and in-progress workflows.",
178
+ height: 200
179
+ },
180
+ {
181
+ key: "workflow-completed",
182
+ spec: WorkflowCompletedMetricVisualization,
183
+ data: { data: [{ value: completedCount }] },
184
+ title: "Completed Work",
185
+ description: "Completed workflows in the current sample.",
186
+ height: 200
187
+ }
188
+ ];
189
+ return {
190
+ primaryItems,
191
+ comparisonItems
192
+ };
193
+ }
194
+ // src/ui/WorkflowDashboard.visualizations.tsx
195
+ import {
196
+ ComparisonView,
197
+ VisualizationCard,
198
+ VisualizationGrid
199
+ } from "@contractspec/lib.design-system";
200
+ import { jsxDEV } from "react/jsx-dev-runtime";
201
+ "use client";
202
+ function WorkflowVisualizationOverview({
203
+ instances
204
+ }) {
205
+ const { primaryItems, comparisonItems } = createWorkflowVisualizationSections(instances);
206
+ return /* @__PURE__ */ jsxDEV("section", {
207
+ className: "space-y-4",
208
+ children: [
209
+ /* @__PURE__ */ jsxDEV("div", {
210
+ children: [
211
+ /* @__PURE__ */ jsxDEV("h3", {
212
+ className: "font-semibold text-lg",
213
+ children: "Workflow Visualizations"
214
+ }, undefined, false, undefined, this),
215
+ /* @__PURE__ */ jsxDEV("p", {
216
+ className: "text-muted-foreground text-sm",
217
+ children: "Contract-backed charts for workflow health and throughput."
218
+ }, undefined, false, undefined, this)
219
+ ]
220
+ }, undefined, true, undefined, this),
221
+ /* @__PURE__ */ jsxDEV(VisualizationGrid, {
222
+ children: primaryItems.map((item) => /* @__PURE__ */ jsxDEV(VisualizationCard, {
223
+ data: item.data,
224
+ description: item.description,
225
+ height: item.height,
226
+ spec: item.spec,
227
+ title: item.title
228
+ }, item.key, false, undefined, this))
229
+ }, undefined, false, undefined, this),
230
+ /* @__PURE__ */ jsxDEV(ComparisonView, {
231
+ description: "Shared comparison surface for active versus completed work.",
232
+ items: comparisonItems,
233
+ title: "Workload Comparison"
234
+ }, undefined, false, undefined, this)
235
+ ]
236
+ }, undefined, true, undefined, this);
237
+ }
238
+ export {
239
+ WorkflowVisualizationOverview
240
+ };
@@ -1,51 +1,4 @@
1
1
  // @bun
2
- // src/ui/hooks/useWorkflowList.ts
3
- import { useCallback, useEffect, useState } from "react";
4
- import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
5
- "use client";
6
- function useWorkflowList(projectId = "local-project") {
7
- const { handlers } = useTemplateRuntime();
8
- const workflow = handlers.workflow;
9
- const [definitions, setDefinitions] = useState([]);
10
- const [instances, setInstances] = useState([]);
11
- const [loading, setLoading] = useState(true);
12
- const [error, setError] = useState(null);
13
- const fetchData = useCallback(async () => {
14
- try {
15
- setLoading(true);
16
- setError(null);
17
- const [defResult, instResult] = await Promise.all([
18
- workflow.listDefinitions({ projectId, limit: 100 }),
19
- workflow.listInstances({ projectId, limit: 100 })
20
- ]);
21
- setDefinitions(defResult.definitions);
22
- setInstances(instResult.instances);
23
- } catch (err) {
24
- setError(err instanceof Error ? err : new Error("Failed to load workflows"));
25
- } finally {
26
- setLoading(false);
27
- }
28
- }, [handlers, projectId]);
29
- useEffect(() => {
30
- fetchData();
31
- }, [fetchData]);
32
- const stats = {
33
- totalDefinitions: definitions.length,
34
- activeDefinitions: definitions.filter((d) => d.status === "ACTIVE").length,
35
- totalInstances: instances.length,
36
- pendingInstances: instances.filter((i) => i.status === "PENDING").length,
37
- completedInstances: instances.filter((i) => i.status === "COMPLETED").length,
38
- rejectedInstances: instances.filter((i) => i.status === "REJECTED").length
39
- };
40
- return {
41
- definitions,
42
- instances,
43
- loading,
44
- error,
45
- stats,
46
- refetch: fetchData
47
- };
48
- }
49
2
  export {
50
3
  useWorkflowList
51
4
  };
@@ -4,10 +4,11 @@ export interface WorkflowStats {
4
4
  activeDefinitions: number;
5
5
  totalInstances: number;
6
6
  pendingInstances: number;
7
+ inProgressInstances: number;
7
8
  completedInstances: number;
8
9
  rejectedInstances: number;
9
10
  }
10
- export declare function useWorkflowList(projectId?: string): {
11
+ export declare function useWorkflowList(projectIdOverride?: string): {
11
12
  definitions: WorkflowDefinition[];
12
13
  instances: WorkflowInstance[];
13
14
  loading: boolean;
@@ -1,10 +1,11 @@
1
1
  // @bun
2
2
  // src/ui/hooks/useWorkflowList.ts
3
- import { useCallback, useEffect, useState } from "react";
4
3
  import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
4
+ import { useCallback, useEffect, useState } from "react";
5
5
  "use client";
6
- function useWorkflowList(projectId = "local-project") {
7
- const { handlers } = useTemplateRuntime();
6
+ function useWorkflowList(projectIdOverride) {
7
+ const { handlers, projectId: runtimeProjectId } = useTemplateRuntime();
8
+ const projectId = projectIdOverride ?? runtimeProjectId;
8
9
  const workflow = handlers.workflow;
9
10
  const [definitions, setDefinitions] = useState([]);
10
11
  const [instances, setInstances] = useState([]);
@@ -25,7 +26,7 @@ function useWorkflowList(projectId = "local-project") {
25
26
  } finally {
26
27
  setLoading(false);
27
28
  }
28
- }, [handlers, projectId]);
29
+ }, [projectId, workflow]);
29
30
  useEffect(() => {
30
31
  fetchData();
31
32
  }, [fetchData]);
@@ -34,6 +35,7 @@ function useWorkflowList(projectId = "local-project") {
34
35
  activeDefinitions: definitions.filter((d) => d.status === "ACTIVE").length,
35
36
  totalInstances: instances.length,
36
37
  pendingInstances: instances.filter((i) => i.status === "PENDING").length,
38
+ inProgressInstances: instances.filter((i) => i.status === "IN_PROGRESS").length,
37
39
  completedInstances: instances.filter((i) => i.status === "COMPLETED").length,
38
40
  rejectedInstances: instances.filter((i) => i.status === "REJECTED").length
39
41
  };
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Workflow System Template Components
3
3
  */
4
+ export * from './hooks';
4
5
  export * from './renderers';
5
6
  export { WorkflowDashboard } from './WorkflowDashboard';
6
- export * from './hooks';
package/dist/ui/index.js CHANGED
@@ -1,10 +1,11 @@
1
1
  // @bun
2
2
  // src/ui/hooks/useWorkflowList.ts
3
- import { useCallback, useEffect, useState } from "react";
4
3
  import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
4
+ import { useCallback, useEffect, useState } from "react";
5
5
  "use client";
6
- function useWorkflowList(projectId = "local-project") {
7
- const { handlers } = useTemplateRuntime();
6
+ function useWorkflowList(projectIdOverride) {
7
+ const { handlers, projectId: runtimeProjectId } = useTemplateRuntime();
8
+ const projectId = projectIdOverride ?? runtimeProjectId;
8
9
  const workflow = handlers.workflow;
9
10
  const [definitions, setDefinitions] = useState([]);
10
11
  const [instances, setInstances] = useState([]);
@@ -25,7 +26,7 @@ function useWorkflowList(projectId = "local-project") {
25
26
  } finally {
26
27
  setLoading(false);
27
28
  }
28
- }, [handlers, projectId]);
29
+ }, [projectId, workflow]);
29
30
  useEffect(() => {
30
31
  fetchData();
31
32
  }, [fetchData]);
@@ -34,6 +35,7 @@ function useWorkflowList(projectId = "local-project") {
34
35
  activeDefinitions: definitions.filter((d) => d.status === "ACTIVE").length,
35
36
  totalInstances: instances.length,
36
37
  pendingInstances: instances.filter((i) => i.status === "PENDING").length,
38
+ inProgressInstances: instances.filter((i) => i.status === "IN_PROGRESS").length,
37
39
  completedInstances: instances.filter((i) => i.status === "COMPLETED").length,
38
40
  rejectedInstances: instances.filter((i) => i.status === "REJECTED").length
39
41
  };