@elabs-ai/components-process 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +73 -0
- package/dist/core/index.d.ts +1029 -0
- package/dist/core/index.js +1553 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/process-worker.js +462 -0
- package/dist/core/process-worker.js.map +1 -0
- package/dist/index.d.ts +1153 -0
- package/dist/index.js +3146 -0
- package/dist/index.js.map +1 -0
- package/dist/test/index.d.ts +196 -0
- package/dist/test/index.js +527 -0
- package/dist/test/index.js.map +1 -0
- package/package.json +80 -0
- package/src/abstraction-controls/abstraction-controls-fixtures.ts +86 -0
- package/src/abstraction-controls/abstraction-controls.stories.tsx +188 -0
- package/src/abstraction-controls/abstraction-controls.test.tsx +226 -0
- package/src/abstraction-controls/abstraction-controls.tsx +288 -0
- package/src/abstraction-controls/auto-abstraction.test.ts +196 -0
- package/src/abstraction-controls/auto-abstraction.ts +128 -0
- package/src/abstraction-controls/index.ts +4 -0
- package/src/core/abstract-graph.test.ts +209 -0
- package/src/core/abstract-graph.ts +407 -0
- package/src/core/adapters/csv.test.ts +131 -0
- package/src/core/adapters/csv.ts +146 -0
- package/src/core/adapters/flat.test.ts +149 -0
- package/src/core/adapters/flat.ts +168 -0
- package/src/core/aggregate-performance.test.ts +208 -0
- package/src/core/aggregate-performance.ts +200 -0
- package/src/core/detect-rework.test.ts +134 -0
- package/src/core/detect-rework.ts +100 -0
- package/src/core/discover-graph.test.ts +378 -0
- package/src/core/discover-graph.ts +202 -0
- package/src/core/duration-stats.test.ts +116 -0
- package/src/core/duration-stats.ts +162 -0
- package/src/core/event-log.test.ts +224 -0
- package/src/core/event-log.ts +244 -0
- package/src/core/extract-variants.test.ts +126 -0
- package/src/core/extract-variants.ts +140 -0
- package/src/core/filter-log.test.ts +193 -0
- package/src/core/filter-log.ts +215 -0
- package/src/core/fixtures/generate-bpi-2012-subset.test.ts +50 -0
- package/src/core/fixtures/generate-bpi-2012-subset.ts +216 -0
- package/src/core/fixtures/generate-bpi-2012-subset.write.ts +40 -0
- package/src/core/fixtures/order-to-cash-small.json +200 -0
- package/src/core/fixtures/synthetic-log.test.ts +109 -0
- package/src/core/fixtures/synthetic-log.ts +167 -0
- package/src/core/index.ts +118 -0
- package/src/core/reconcile-graph.test.ts +175 -0
- package/src/core/reconcile-graph.ts +107 -0
- package/src/core/scale.test.ts +80 -0
- package/src/core/scale.ts +100 -0
- package/src/core/types.ts +151 -0
- package/src/core/worker/create-process-worker.test.ts +255 -0
- package/src/core/worker/create-process-worker.ts +211 -0
- package/src/core/worker/process-worker.ts +80 -0
- package/src/index.ts +29 -0
- package/src/metric-layer-switch/index.ts +6 -0
- package/src/metric-layer-switch/metric-layer-switch.stories.tsx +131 -0
- package/src/metric-layer-switch/metric-layer-switch.test.tsx +102 -0
- package/src/metric-layer-switch/metric-layer-switch.tsx +276 -0
- package/src/process-explorer.stories.tsx +392 -0
- package/src/process-kpi-strip/index.ts +6 -0
- package/src/process-kpi-strip/process-kpi-strip.stories.tsx +128 -0
- package/src/process-kpi-strip/process-kpi-strip.test.tsx +106 -0
- package/src/process-kpi-strip/process-kpi-strip.tsx +237 -0
- package/src/process-map/index.ts +13 -0
- package/src/process-map/map-model.test.ts +326 -0
- package/src/process-map/map-model.ts +873 -0
- package/src/process-map/process-activity-node.tsx +200 -0
- package/src/process-map/process-map-context.ts +71 -0
- package/src/process-map/process-map.stories.tsx +673 -0
- package/src/process-map/process-map.test.tsx +523 -0
- package/src/process-map/process-map.tsx +979 -0
- package/src/process-map/process-transition-edge.test.tsx +160 -0
- package/src/process-map/process-transition-edge.tsx +151 -0
- package/src/process-map/use-process-layout.test.tsx +265 -0
- package/src/process-map/use-process-layout.ts +315 -0
- package/src/test/contract.test.ts +99 -0
- package/src/test/contract.ts +118 -0
- package/src/test/doubles.test.tsx +51 -0
- package/src/test/doubles.tsx +82 -0
- package/src/test/index.ts +34 -0
- package/src/test/primitives.tsx +35 -0
- package/src/use-process-explorer/index.ts +8 -0
- package/src/use-process-explorer/use-process-explorer.test.ts +564 -0
- package/src/use-process-explorer/use-process-explorer.ts +540 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { HTMLAttributes } from 'react';
|
|
3
|
+
|
|
4
|
+
/** Selection carried by a process view's coordinated-selection contract (RM-068 completes it). */
|
|
5
|
+
type ProcessSelection = null | {
|
|
6
|
+
kind: "node";
|
|
7
|
+
id: string;
|
|
8
|
+
} | {
|
|
9
|
+
kind: "edge";
|
|
10
|
+
id: string;
|
|
11
|
+
};
|
|
12
|
+
/** What {@link assertProcessContract} checks for one double. */
|
|
13
|
+
interface ProcessContractSpec {
|
|
14
|
+
/** Name of the prop carrying the double's primary data payload. */
|
|
15
|
+
dataProp: "graph" | "variants";
|
|
16
|
+
/** Other props the real component requires; the double must not silently accept `undefined`. */
|
|
17
|
+
requiredProps?: string[];
|
|
18
|
+
}
|
|
19
|
+
/** Thrown by {@link assertProcessContract} when a double is used with an invalid prop shape. */
|
|
20
|
+
declare class ProcessContractError extends Error {
|
|
21
|
+
constructor(componentName: string, message: string);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Validate a double's props against its contract spec. Throws {@link ProcessContractError} on
|
|
25
|
+
* a missing/invalid required prop — mirroring what the real component would fail on at
|
|
26
|
+
* runtime, so a test that gets the props wrong fails loudly rather than silently rendering an
|
|
27
|
+
* empty double.
|
|
28
|
+
*/
|
|
29
|
+
declare function assertProcessContract(componentName: string, props: Record<string, unknown>, spec: ProcessContractSpec): void;
|
|
30
|
+
/** What a double records to `data-process-props`, for assertions without a real layout. */
|
|
31
|
+
interface ProcessDoublePayload {
|
|
32
|
+
component: string;
|
|
33
|
+
dataLength: number;
|
|
34
|
+
selection?: ProcessSelection;
|
|
35
|
+
}
|
|
36
|
+
/** Build the inspectable payload a double serializes into `data-process-props`. */
|
|
37
|
+
declare function buildProcessDoublePayload(componentName: string, props: Record<string, unknown>, spec: ProcessContractSpec): ProcessDoublePayload;
|
|
38
|
+
/** Read a mounted double's payload back out of the DOM (companion to {@link buildProcessDoublePayload}). */
|
|
39
|
+
declare function readProcessDoubleProps(el: Element): ProcessDoublePayload | null;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The framework-free event-log and process-graph model — RM-049.
|
|
43
|
+
*
|
|
44
|
+
* Every downstream item in the process-mining track (RM-050 abstraction, RM-051 the
|
|
45
|
+
* process map, RM-052 the variant explorer, RM-053 the case table, RM-054 the coverage
|
|
46
|
+
* strip) reads these shapes, so they are the wave's frozen contract. Keep additions
|
|
47
|
+
* additive: a required field added here is a breaking change for five items at once.
|
|
48
|
+
*
|
|
49
|
+
* NOTHING in this module — or anywhere under `src/core/` — may import React, React Flow,
|
|
50
|
+
* visx, d3 or an `@elabs-ai/components-*` package. See `.claude/rules/process-components.md`
|
|
51
|
+
* and `pnpm process:reuse:check`.
|
|
52
|
+
*/
|
|
53
|
+
/**
|
|
54
|
+
* One raw row of an event log, before normalization.
|
|
55
|
+
*
|
|
56
|
+
* `timestamp` accepts the three shapes tabular sources actually produce — an ISO string,
|
|
57
|
+
* an epoch number, or a `Date` — because the adapters hand rows through unchanged and a
|
|
58
|
+
* consumer should not have to pre-convert. {@link normalizeLog} resolves all three to
|
|
59
|
+
* epoch milliseconds.
|
|
60
|
+
*/
|
|
61
|
+
interface EventRow {
|
|
62
|
+
/** Case (process instance) this event belongs to. */
|
|
63
|
+
caseId: string;
|
|
64
|
+
/** Activity name. This is the node identity in the discovered graph. */
|
|
65
|
+
activity: string;
|
|
66
|
+
/** When the event completed (or, for a `lifecycle: "start"` row, when it started). */
|
|
67
|
+
timestamp: string | number | Date;
|
|
68
|
+
/**
|
|
69
|
+
* Optional explicit start of an interval event. Ignored when the row is one half of a
|
|
70
|
+
* `lifecycle` pair — the paired `"start"` row wins, because it is the observed value.
|
|
71
|
+
*/
|
|
72
|
+
startTimestamp?: string | number | Date;
|
|
73
|
+
/** Who or what executed the event (a user, a queue, a system). */
|
|
74
|
+
resource?: string;
|
|
75
|
+
/** Lifecycle transition. Absent means the row is an atomic (already-complete) event. */
|
|
76
|
+
lifecycle?: "start" | "complete";
|
|
77
|
+
/** Free-form event-level attributes carried through normalization untouched. */
|
|
78
|
+
attributes?: Record<string, string | number | boolean | null>;
|
|
79
|
+
}
|
|
80
|
+
/** A raw event log: the rows, plus optional per-case attributes keyed by `caseId`. */
|
|
81
|
+
interface EventLog {
|
|
82
|
+
events: EventRow[];
|
|
83
|
+
caseAttributes?: Record<string, Record<string, unknown>>;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Summary statistics over a set of duration samples, in milliseconds.
|
|
87
|
+
*
|
|
88
|
+
* All seven members are always present; an empty sample set yields zeros rather than
|
|
89
|
+
* `null`, so a renderer never has to branch on absence.
|
|
90
|
+
*/
|
|
91
|
+
interface DurationStats {
|
|
92
|
+
min: number;
|
|
93
|
+
max: number;
|
|
94
|
+
mean: number;
|
|
95
|
+
median: number;
|
|
96
|
+
p90: number;
|
|
97
|
+
sum: number;
|
|
98
|
+
/** Mean after discarding the lowest and highest 10% of samples. */
|
|
99
|
+
trimmedMean: number;
|
|
100
|
+
}
|
|
101
|
+
/** Per-activity aggregates in a discovered graph. */
|
|
102
|
+
interface ActivityStats {
|
|
103
|
+
/** Stable node identity — the activity name. */
|
|
104
|
+
id: string;
|
|
105
|
+
/** Human-readable label. Equal to `id` unless a caller relabels the graph. */
|
|
106
|
+
label: string;
|
|
107
|
+
/** Total occurrences across all cases. */
|
|
108
|
+
instances: number;
|
|
109
|
+
/** Number of distinct cases the activity occurs in at least once. */
|
|
110
|
+
cases: number;
|
|
111
|
+
/** True when the activity starts at least one case. */
|
|
112
|
+
isStart: boolean;
|
|
113
|
+
/** True when the activity ends at least one case. */
|
|
114
|
+
isEnd: boolean;
|
|
115
|
+
/** Distribution of the activity's own execution durations. */
|
|
116
|
+
duration: DurationStats;
|
|
117
|
+
}
|
|
118
|
+
/** Per-edge aggregates in a discovered graph (a directly-follows relation). */
|
|
119
|
+
interface TransitionStats {
|
|
120
|
+
source: string;
|
|
121
|
+
target: string;
|
|
122
|
+
/** Total occurrences of the directly-follows pair across all cases. */
|
|
123
|
+
count: number;
|
|
124
|
+
/** Number of distinct cases the pair occurs in at least once. */
|
|
125
|
+
caseCount: number;
|
|
126
|
+
/** Distribution of the flow time between the two activities. */
|
|
127
|
+
duration: DurationStats;
|
|
128
|
+
/** `source === target`. */
|
|
129
|
+
isSelfLoop: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Whether the edge points backwards in the laid-out graph. Discovery does not lay out,
|
|
132
|
+
* so this is always `false` here; a layout pass sets it (RM-044).
|
|
133
|
+
*/
|
|
134
|
+
isBackEdge: boolean;
|
|
135
|
+
}
|
|
136
|
+
/** A directly-follows graph plus its totals. */
|
|
137
|
+
interface ProcessGraph {
|
|
138
|
+
activities: ActivityStats[];
|
|
139
|
+
transitions: TransitionStats[];
|
|
140
|
+
/** Activity name → number of cases that start with it. */
|
|
141
|
+
startActivities: Record<string, number>;
|
|
142
|
+
/** Activity name → number of cases that end with it. */
|
|
143
|
+
endActivities: Record<string, number>;
|
|
144
|
+
totals: {
|
|
145
|
+
cases: number;
|
|
146
|
+
events: number;
|
|
147
|
+
variants: number;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/** One distinct activity sequence, with the cases that follow it. */
|
|
151
|
+
interface Variant {
|
|
152
|
+
/** Stable, reproducible id derived from the sequence — see `variantId`. */
|
|
153
|
+
id: string;
|
|
154
|
+
sequence: string[];
|
|
155
|
+
/** Number of cases following this sequence. */
|
|
156
|
+
count: number;
|
|
157
|
+
/** `count / totalCases`. */
|
|
158
|
+
share: number;
|
|
159
|
+
/** Running share across the descending-frequency order — monotonically non-decreasing. */
|
|
160
|
+
cumulativeShare: number;
|
|
161
|
+
/** Case ids following this sequence, in first-appearance order. */
|
|
162
|
+
caseIds: string[];
|
|
163
|
+
/** Distribution of the end-to-end case durations of `caseIds`. */
|
|
164
|
+
duration: DurationStats;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
interface DoubleOwnProps extends HTMLAttributes<HTMLDivElement> {
|
|
168
|
+
selection?: ProcessSelection;
|
|
169
|
+
onSelectionChange?: (selection: ProcessSelection) => void;
|
|
170
|
+
}
|
|
171
|
+
interface ProcessMapDoubleProps extends DoubleOwnProps {
|
|
172
|
+
graph: ProcessGraph;
|
|
173
|
+
}
|
|
174
|
+
interface VariantExplorerDoubleProps extends DoubleOwnProps {
|
|
175
|
+
variants: Variant[];
|
|
176
|
+
}
|
|
177
|
+
interface ProcessKpiStripDoubleProps extends HTMLAttributes<HTMLDivElement> {
|
|
178
|
+
graph: ProcessGraph;
|
|
179
|
+
}
|
|
180
|
+
/** Stand-in for the future `ProcessMap` (RM-051). Named with a `Double` suffix — see contract.ts header. */
|
|
181
|
+
declare const ProcessMapDouble: react.ForwardRefExoticComponent<ProcessMapDoubleProps & react.RefAttributes<HTMLDivElement>>;
|
|
182
|
+
/** Stand-in for the future `VariantExplorer` (RM-052). */
|
|
183
|
+
declare const VariantExplorerDouble: react.ForwardRefExoticComponent<VariantExplorerDoubleProps & react.RefAttributes<HTMLDivElement>>;
|
|
184
|
+
/** Stand-in for the future `ProcessKpiStrip` (RM-054). */
|
|
185
|
+
declare const ProcessKpiStripDouble: react.ForwardRefExoticComponent<ProcessKpiStripDoubleProps & react.RefAttributes<HTMLDivElement>>;
|
|
186
|
+
|
|
187
|
+
/** The derived triple most process stories/tests want from one raw log. */
|
|
188
|
+
interface ProcessFixture {
|
|
189
|
+
log: EventLog;
|
|
190
|
+
graph: ProcessGraph;
|
|
191
|
+
variants: Variant[];
|
|
192
|
+
}
|
|
193
|
+
/** Derive {@link ProcessFixture} from a raw event log. Pure — no caching, no I/O. */
|
|
194
|
+
declare function withProcessFixture(log: EventLog): ProcessFixture;
|
|
195
|
+
|
|
196
|
+
export { ProcessContractError, type ProcessContractSpec, type ProcessDoublePayload, type ProcessFixture, ProcessKpiStripDouble, type ProcessKpiStripDoubleProps, ProcessMapDouble, type ProcessMapDoubleProps, type ProcessSelection, VariantExplorerDouble, type VariantExplorerDoubleProps, assertProcessContract, buildProcessDoublePayload, readProcessDoubleProps, withProcessFixture };
|