@burdenoff/microfe-headshotmarketing 2026.928.2 → 2026.1029.1
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/generated/global-types.d.ts +5145 -1627
- package/dist/generated/global-types.d.ts.map +1 -1
- package/dist/generated/wspace-operations.d.ts +464 -248
- package/dist/generated/wspace-operations.d.ts.map +1 -1
- package/dist/generated/wspace-operations.js +320 -292
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +21251 -468
- package/dist/generated/wspace-types.d.ts.map +1 -1
- package/dist/generated/wspace-types.js +20 -20
- package/dist/generated/wspace-types.js.map +1 -1
- package/dist/headshotmarketing/components/PageLayout.d.ts +5 -0
- package/dist/headshotmarketing/components/PageLayout.d.ts.map +1 -1
- package/dist/headshotmarketing/components/PageLayout.js +12 -6
- package/dist/headshotmarketing/components/PageLayout.js.map +1 -1
- package/dist/headshotmarketing/components/StatusBadge.d.ts.map +1 -1
- package/dist/headshotmarketing/components/StatusBadge.js +3 -0
- package/dist/headshotmarketing/components/StatusBadge.js.map +1 -1
- package/dist/headshotmarketing/pages/automation/AutomationPage.d.ts.map +1 -1
- package/dist/headshotmarketing/pages/automation/AutomationPage.js +172 -167
- package/dist/headshotmarketing/pages/automation/AutomationPage.js.map +1 -1
- package/dist/headshotmarketing/pages/automation/TriggersPage.d.ts.map +1 -1
- package/dist/headshotmarketing/pages/automation/TriggersPage.js +127 -143
- package/dist/headshotmarketing/pages/automation/TriggersPage.js.map +1 -1
- package/dist/headshotmarketing/pages/automation/WorkflowActions.d.ts +16 -16
- package/dist/headshotmarketing/pages/automation/WorkflowActions.d.ts.map +1 -1
- package/dist/headshotmarketing/pages/automation/WorkflowActions.js +104 -221
- package/dist/headshotmarketing/pages/automation/WorkflowActions.js.map +1 -1
- package/dist/headshotmarketing/pages/automation/WorkflowBuilderPage.d.ts +16 -0
- package/dist/headshotmarketing/pages/automation/WorkflowBuilderPage.d.ts.map +1 -1
- package/dist/headshotmarketing/pages/automation/WorkflowBuilderPage.js +470 -549
- package/dist/headshotmarketing/pages/automation/WorkflowBuilderPage.js.map +1 -1
- package/dist/headshotmarketing/pages/automation/WorkflowCanvasNode.d.ts +2 -0
- package/dist/headshotmarketing/pages/automation/WorkflowCanvasNode.d.ts.map +1 -1
- package/dist/headshotmarketing/pages/automation/WorkflowCanvasNode.js +19 -19
- package/dist/headshotmarketing/pages/automation/WorkflowCanvasNode.js.map +1 -1
- package/dist/headshotmarketing/pages/automation/WorkflowNodeConfigPanel.d.ts.map +1 -1
- package/dist/headshotmarketing/pages/automation/WorkflowNodeConfigPanel.js +341 -164
- package/dist/headshotmarketing/pages/automation/WorkflowNodeConfigPanel.js.map +1 -1
- package/dist/headshotmarketing/pages/automation/WorkflowRunsPanel.d.ts +13 -0
- package/dist/headshotmarketing/pages/automation/WorkflowRunsPanel.d.ts.map +1 -0
- package/dist/headshotmarketing/pages/automation/WorkflowRunsPanel.js +294 -0
- package/dist/headshotmarketing/pages/automation/WorkflowRunsPanel.js.map +1 -0
- package/dist/headshotmarketing/pages/automation/WorkflowsPage.d.ts +2 -0
- package/dist/headshotmarketing/pages/automation/WorkflowsPage.d.ts.map +1 -1
- package/dist/headshotmarketing/pages/automation/WorkflowsPage.js +198 -220
- package/dist/headshotmarketing/pages/automation/WorkflowsPage.js.map +1 -1
- package/dist/headshotmarketing/pages/automation/useAutomationData.d.ts +24 -0
- package/dist/headshotmarketing/pages/automation/useAutomationData.d.ts.map +1 -0
- package/dist/headshotmarketing/pages/automation/useAutomationData.js +77 -0
- package/dist/headshotmarketing/pages/automation/useAutomationData.js.map +1 -0
- package/dist/headshotmarketing/pages/automation/workflowBuilderModel.d.ts +73 -16
- package/dist/headshotmarketing/pages/automation/workflowBuilderModel.d.ts.map +1 -1
- package/dist/headshotmarketing/pages/automation/workflowBuilderModel.js +220 -80
- package/dist/headshotmarketing/pages/automation/workflowBuilderModel.js.map +1 -1
- package/dist/headshotmarketing/pages/automation/workflowCompiler.d.ts +51 -0
- package/dist/headshotmarketing/pages/automation/workflowCompiler.d.ts.map +1 -0
- package/dist/headshotmarketing/pages/automation/workflowCompiler.js +453 -0
- package/dist/headshotmarketing/pages/automation/workflowCompiler.js.map +1 -0
- package/dist/headshotmarketing/utils/automationMapper.d.ts +50 -29
- package/dist/headshotmarketing/utils/automationMapper.d.ts.map +1 -1
- package/dist/headshotmarketing/utils/automationMapper.js +55 -99
- package/dist/headshotmarketing/utils/automationMapper.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,39 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AutomationLog, Workflow, WorkflowTemplate } from '../types';
|
|
1
|
+
import { EngineStep } from '../pages/automation/workflowCompiler';
|
|
3
2
|
|
|
4
|
-
type
|
|
3
|
+
export type AutomationWorkflowStatus = "ACTIVE" | "PAUSED" | "DRAFT" | "ARCHIVED";
|
|
4
|
+
export type AutomationRunStatus = "PENDING" | "RUNNING" | "WAITING" | "COMPLETED" | "FAILED" | "CANCELLED";
|
|
5
|
+
/** Minimal workflow shape the helpers need (matches the GraphQL fragment). */
|
|
6
|
+
export interface AutomationWorkflowLike {
|
|
5
7
|
id: string;
|
|
6
8
|
name: string;
|
|
7
|
-
description?: string | null;
|
|
8
9
|
status: string;
|
|
9
|
-
triggerType
|
|
10
|
+
triggerType: string;
|
|
10
11
|
triggerConfig?: Record<string, unknown> | null;
|
|
11
|
-
steps
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
updatedAt: string;
|
|
17
|
-
};
|
|
18
|
-
type WorkflowExecutionLike = {
|
|
12
|
+
steps: unknown;
|
|
13
|
+
totalRuns: number;
|
|
14
|
+
}
|
|
15
|
+
/** Minimal run shape the helpers need (matches the GraphQL fragment). */
|
|
16
|
+
export interface AutomationRunLike {
|
|
19
17
|
id: string;
|
|
20
18
|
workflowId: string;
|
|
21
19
|
status: string;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
startedAt: string;
|
|
21
|
+
completedAt?: string | null;
|
|
22
|
+
context?: Record<string, unknown> | null;
|
|
23
|
+
}
|
|
24
|
+
export interface RunStats {
|
|
25
|
+
/** Runs started since the first day of the current month. */
|
|
26
|
+
runsThisMonth: number;
|
|
27
|
+
/** Emails actually delivered by SEND_EMAIL steps in this month's runs. */
|
|
28
|
+
emailsSentThisMonth: number;
|
|
29
|
+
/** This month's finished runs (COMPLETED or FAILED). */
|
|
30
|
+
finished: number;
|
|
31
|
+
completed: number;
|
|
32
|
+
failed: number;
|
|
33
|
+
/** completed / finished, 0-100, or null when nothing has finished. */
|
|
34
|
+
successRate: number | null;
|
|
35
|
+
/** Most recent run start among the loaded runs, or null. */
|
|
36
|
+
lastRunAt: string | null;
|
|
37
|
+
}
|
|
38
|
+
export declare function startOfMonth(now: Date): Date;
|
|
39
|
+
/**
|
|
40
|
+
* Count emails a run delivered: the engine records each successful step's
|
|
41
|
+
* output in the run context as `step_<stepId>`, and a delivered email's
|
|
42
|
+
* output carries `deliveredTo`.
|
|
43
|
+
*/
|
|
44
|
+
export declare function emailsDeliveredByRun(run: AutomationRunLike, emailSteps: Set<string>): number;
|
|
45
|
+
/** Per-workflow and overall run statistics. */
|
|
46
|
+
export declare function summarizeRuns(workflows: AutomationWorkflowLike[], runs: AutomationRunLike[], now?: Date): {
|
|
47
|
+
total: RunStats;
|
|
48
|
+
byWorkflow: Map<string, RunStats>;
|
|
25
49
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
export declare function
|
|
36
|
-
export declare function toAutomationLogModel(item: WorkflowExecutionLike, workflowNameById: Record<string, string>): AutomationLog;
|
|
37
|
-
export declare function toWorkflowTemplateModel(item: Workflow): WorkflowTemplate;
|
|
38
|
-
export {};
|
|
50
|
+
/** Number of user-visible steps (structural branch-end markers excluded). */
|
|
51
|
+
export declare function visibleStepCount(steps: unknown): number;
|
|
52
|
+
/** Trigger summary shown in lists, e.g. "Lead score reached 80". */
|
|
53
|
+
export declare function describeTrigger(workflow: AutomationWorkflowLike): string;
|
|
54
|
+
/** Lower-case status used by the shared StatusBadge. */
|
|
55
|
+
export declare function workflowBadgeStatus(status: string): string;
|
|
56
|
+
export declare function isRunCancellable(status: string): boolean;
|
|
57
|
+
export declare function isRunRetryable(status: string): boolean;
|
|
58
|
+
/** Step label for a run log entry: "2 · Send Email". */
|
|
59
|
+
export declare function stepName(steps: EngineStep[], stepIndex: number, fallbackType: string): string;
|
|
39
60
|
//# sourceMappingURL=automationMapper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"automationMapper.d.ts","sourceRoot":"","sources":["../../../src/headshotmarketing/utils/automationMapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"automationMapper.d.ts","sourceRoot":"","sources":["../../../src/headshotmarketing/utils/automationMapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAEL,KAAK,UAAU,EAChB,MAAM,sCAAsC,CAAC;AAG9C,MAAM,MAAM,wBAAwB,GAChC,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,UAAU,CAAC;AACf,MAAM,MAAM,mBAAmB,GAC3B,SAAS,GACT,SAAS,GACT,SAAS,GACT,WAAW,GACX,QAAQ,GACR,WAAW,CAAC;AAEhB,8EAA8E;AAC9E,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC/C,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,yEAAyE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D,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAExD;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED,wDAAwD;AACxD,wBAAgB,QAAQ,CACtB,KAAK,EAAE,UAAU,EAAE,EACnB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,GACnB,MAAM,CAaR"}
|
|
@@ -1,120 +1,76 @@
|
|
|
1
|
+
import { triggerLabel as e } from "../pages/automation/workflowBuilderModel.js";
|
|
2
|
+
import { parseEngineSteps as t } from "../pages/automation/workflowCompiler.js";
|
|
1
3
|
//#region src/headshotmarketing/utils/automationMapper.ts
|
|
2
|
-
function e(e) {
|
|
3
|
-
switch (e) {
|
|
4
|
-
case "ACTIVE": return "active";
|
|
5
|
-
case "PAUSED": return "paused";
|
|
6
|
-
case "ARCHIVED": return "archived";
|
|
7
|
-
default: return "draft";
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
function t(e) {
|
|
11
|
-
switch (e) {
|
|
12
|
-
case "FORM_SUBMIT": return "form_submit";
|
|
13
|
-
case "EVENT": return "event";
|
|
14
|
-
case "SCHEDULE": return "schedule";
|
|
15
|
-
case "CONDITION": return "condition";
|
|
16
|
-
case "WEBHOOK": return "webhook";
|
|
17
|
-
case "TAG_ADDED": return "tag_added";
|
|
18
|
-
case "SCORE_CHANGE": return "score_change";
|
|
19
|
-
default: return "event";
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
4
|
function n(e) {
|
|
23
|
-
|
|
24
|
-
case "SUCCESS": return "success";
|
|
25
|
-
case "FAILED": return "failed";
|
|
26
|
-
case "SKIPPED": return "skipped";
|
|
27
|
-
default: return "pending";
|
|
28
|
-
}
|
|
5
|
+
return new Date(e.getFullYear(), e.getMonth(), 1);
|
|
29
6
|
}
|
|
30
|
-
function r(
|
|
31
|
-
let r = t(e ?? "EVENT"), i = typeof n?.description == "string" ? n.description : r.replace("_", " ");
|
|
7
|
+
function r() {
|
|
32
8
|
return {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
9
|
+
runsThisMonth: 0,
|
|
10
|
+
emailsSentThisMonth: 0,
|
|
11
|
+
finished: 0,
|
|
12
|
+
completed: 0,
|
|
13
|
+
failed: 0,
|
|
14
|
+
successRate: null,
|
|
15
|
+
lastRunAt: null
|
|
37
16
|
};
|
|
38
17
|
}
|
|
39
18
|
function i(e) {
|
|
40
|
-
return (
|
|
41
|
-
id: typeof e == "object" && e && "id" in e ? String(e.id) : `step-${t + 1}`,
|
|
42
|
-
type: "notify",
|
|
43
|
-
config: typeof e == "object" && e ? e : {},
|
|
44
|
-
description: typeof e == "object" && e && "name" in e ? String(e.name) : `Step ${t + 1}`,
|
|
45
|
-
order: t + 1
|
|
46
|
-
}));
|
|
19
|
+
return new Set(e.filter((e) => e.type === "SEND_EMAIL").map((e) => e.id));
|
|
47
20
|
}
|
|
48
|
-
function a(e) {
|
|
49
|
-
|
|
21
|
+
function a(e, t) {
|
|
22
|
+
let n = e.context ?? {}, r = 0;
|
|
23
|
+
for (let e of t) {
|
|
24
|
+
let t = n[`step_${e}`];
|
|
25
|
+
typeof t == "object" && t && typeof t.deliveredTo == "string" && (r += 1);
|
|
26
|
+
}
|
|
27
|
+
return r;
|
|
50
28
|
}
|
|
51
29
|
function o(e) {
|
|
52
|
-
let t = e.triggerType ?? "EVENT", n = e.triggerConfig ?? {}, r = e.variables ?? {};
|
|
53
30
|
return {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
name: e.name,
|
|
57
|
-
description: e.description ?? null,
|
|
58
|
-
category: "headshotmarketing",
|
|
59
|
-
tags: e.tags ?? [],
|
|
60
|
-
context: {
|
|
61
|
-
triggerType: t,
|
|
62
|
-
triggerConfig: n,
|
|
63
|
-
variables: r,
|
|
64
|
-
product: "headshotmarketing"
|
|
65
|
-
},
|
|
66
|
-
definitionJson: {
|
|
67
|
-
triggerType: t,
|
|
68
|
-
triggerConfig: n,
|
|
69
|
-
variables: r,
|
|
70
|
-
steps: Array.isArray(e.steps) ? e.steps : typeof e.steps == "object" && e.steps !== null && Array.isArray(e.steps.steps) ? e.steps.steps : []
|
|
71
|
-
}
|
|
31
|
+
...e,
|
|
32
|
+
successRate: e.finished > 0 ? e.completed / e.finished * 100 : null
|
|
72
33
|
};
|
|
73
34
|
}
|
|
74
|
-
function s(
|
|
75
|
-
let n = e(t.
|
|
35
|
+
function s(e, s, c = /* @__PURE__ */ new Date()) {
|
|
36
|
+
let l = n(c).getTime(), u = new Map(e.map((e) => [e.id, i(t(e.steps))])), d = r(), f = /* @__PURE__ */ new Map();
|
|
37
|
+
for (let t of e) f.set(t.id, r());
|
|
38
|
+
for (let e of s) {
|
|
39
|
+
let t = f.get(e.workflowId) ?? r();
|
|
40
|
+
f.set(e.workflowId, t);
|
|
41
|
+
let n = new Date(e.startedAt).getTime(), i = Number.isFinite(n) && n >= l;
|
|
42
|
+
for (let n of [d, t]) (!n.lastRunAt || e.startedAt > n.lastRunAt) && (n.lastRunAt = e.startedAt), i && (n.runsThisMonth += 1, n.emailsSentThisMonth += a(e, u.get(e.workflowId) ?? /* @__PURE__ */ new Set()), e.status === "COMPLETED" ? (n.finished += 1, n.completed += 1) : e.status === "FAILED" && (n.finished += 1, n.failed += 1));
|
|
43
|
+
}
|
|
44
|
+
let p = /* @__PURE__ */ new Map();
|
|
45
|
+
for (let [e, t] of f) p.set(e, o(t));
|
|
76
46
|
return {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
description: t.description ?? "",
|
|
80
|
-
status: n,
|
|
81
|
-
trigger: r(t.triggerType, t.triggerConfig),
|
|
82
|
-
actions: i(t.steps),
|
|
83
|
-
enrolledCount: a,
|
|
84
|
-
completedCount: 0,
|
|
85
|
-
conversionRate: 0,
|
|
86
|
-
lastTriggeredAt: t.lastExecutedAt ?? null,
|
|
87
|
-
tags: t.tags,
|
|
88
|
-
createdAt: t.createdAt,
|
|
89
|
-
updatedAt: t.updatedAt
|
|
47
|
+
total: o(d),
|
|
48
|
+
byWorkflow: p
|
|
90
49
|
};
|
|
91
50
|
}
|
|
92
|
-
function c(e
|
|
93
|
-
return
|
|
94
|
-
id: e.id,
|
|
95
|
-
workflowId: e.workflowId,
|
|
96
|
-
workflowName: t[e.workflowId] ?? "Workflow",
|
|
97
|
-
contactId: e.triggeredBy ?? "system",
|
|
98
|
-
contactEmail: e.triggeredBy ?? "system@burdenoff.local",
|
|
99
|
-
action: "Execution",
|
|
100
|
-
status: n(e.status),
|
|
101
|
-
message: e.errorMessage ?? "Completed",
|
|
102
|
-
executedAt: e.createdAt
|
|
103
|
-
};
|
|
51
|
+
function c(e) {
|
|
52
|
+
return t(e).filter((e) => !(e.type === "GOAL" && e.config.endRun === !0)).length;
|
|
104
53
|
}
|
|
105
|
-
function l(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
54
|
+
function l(t) {
|
|
55
|
+
let n = e(t.triggerType), r = t.triggerConfig?.scoreThreshold;
|
|
56
|
+
return t.triggerType === "SCORE_THRESHOLD" && typeof r == "number" ? `${n} ${r}` : n;
|
|
57
|
+
}
|
|
58
|
+
function u(e) {
|
|
59
|
+
return e.toLowerCase();
|
|
60
|
+
}
|
|
61
|
+
function d(e) {
|
|
62
|
+
return e === "PENDING" || e === "RUNNING" || e === "WAITING";
|
|
63
|
+
}
|
|
64
|
+
function f(e) {
|
|
65
|
+
return e === "FAILED";
|
|
66
|
+
}
|
|
67
|
+
function p(e, t, n) {
|
|
68
|
+
let r = e[t], i = r?.config.label;
|
|
69
|
+
if (typeof i == "string" && i.trim()) return i;
|
|
70
|
+
let a = r?.type ?? n, o = a.toLowerCase().split("_").map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" ");
|
|
71
|
+
return a === "GOAL" && r?.config.endRun === !0 ? "End of branch" : o;
|
|
116
72
|
}
|
|
117
73
|
//#endregion
|
|
118
|
-
export {
|
|
74
|
+
export { l as describeTrigger, d as isRunCancellable, f as isRunRetryable, n as startOfMonth, p as stepName, s as summarizeRuns, c as visibleStepCount, u as workflowBadgeStatus };
|
|
119
75
|
|
|
120
76
|
//# sourceMappingURL=automationMapper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"automationMapper.js","names":[],"sources":["../../../src/headshotmarketing/utils/automationMapper.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"automationMapper.js","names":[],"sources":["../../../src/headshotmarketing/utils/automationMapper.ts"],"sourcesContent":["/**\n * View-model helpers for the product automation engine (BOFF-10192).\n *\n * Workflows and runs come from wspace-headshotmarketing-svc\n * (`headshotmarketingAutomationWorkflows`, `headshotmarketingAutomationWorkflowRuns`).\n * Every figure derived here is computed from real runs — nothing is\n * estimated or defaulted to look healthy.\n *\n * @module headshotmarketing/utils/automationMapper\n */\nimport {\n parseEngineSteps,\n type EngineStep,\n} from \"../pages/automation/workflowCompiler\";\nimport { triggerLabel } from \"../pages/automation/workflowBuilderModel\";\n\nexport type AutomationWorkflowStatus =\n | \"ACTIVE\"\n | \"PAUSED\"\n | \"DRAFT\"\n | \"ARCHIVED\";\nexport type AutomationRunStatus =\n | \"PENDING\"\n | \"RUNNING\"\n | \"WAITING\"\n | \"COMPLETED\"\n | \"FAILED\"\n | \"CANCELLED\";\n\n/** Minimal workflow shape the helpers need (matches the GraphQL fragment). */\nexport interface AutomationWorkflowLike {\n id: string;\n name: string;\n status: string;\n triggerType: string;\n triggerConfig?: Record<string, unknown> | null;\n steps: unknown;\n totalRuns: number;\n}\n\n/** Minimal run shape the helpers need (matches the GraphQL fragment). */\nexport interface AutomationRunLike {\n id: string;\n workflowId: string;\n status: string;\n startedAt: string;\n completedAt?: string | null;\n context?: Record<string, unknown> | null;\n}\n\nexport interface RunStats {\n /** Runs started since the first day of the current month. */\n runsThisMonth: number;\n /** Emails actually delivered by SEND_EMAIL steps in this month's runs. */\n emailsSentThisMonth: number;\n /** This month's finished runs (COMPLETED or FAILED). */\n finished: number;\n completed: number;\n failed: number;\n /** completed / finished, 0-100, or null when nothing has finished. */\n successRate: number | null;\n /** Most recent run start among the loaded runs, or null. */\n lastRunAt: string | null;\n}\n\nexport function startOfMonth(now: Date): Date {\n return new Date(now.getFullYear(), now.getMonth(), 1);\n}\n\nfunction emptyStats(): RunStats {\n return {\n runsThisMonth: 0,\n emailsSentThisMonth: 0,\n finished: 0,\n completed: 0,\n failed: 0,\n successRate: null,\n lastRunAt: null,\n };\n}\n\n/** Ids of the workflow's SEND_EMAIL steps. */\nfunction emailStepIds(steps: EngineStep[]): Set<string> {\n return new Set(steps.filter((s) => s.type === \"SEND_EMAIL\").map((s) => s.id));\n}\n\n/**\n * Count emails a run delivered: the engine records each successful step's\n * output in the run context as `step_<stepId>`, and a delivered email's\n * output carries `deliveredTo`.\n */\nexport function emailsDeliveredByRun(\n run: AutomationRunLike,\n emailSteps: Set<string>,\n): number {\n const context = run.context ?? {};\n let count = 0;\n for (const id of emailSteps) {\n const output = context[`step_${id}`];\n if (\n typeof output === \"object\" &&\n output !== null &&\n typeof (output as Record<string, unknown>)[\"deliveredTo\"] === \"string\"\n ) {\n count += 1;\n }\n }\n return count;\n}\n\nfunction finalize(stats: RunStats): RunStats {\n return {\n ...stats,\n successRate:\n stats.finished > 0 ? (stats.completed / stats.finished) * 100 : null,\n };\n}\n\n/** Per-workflow and overall run statistics. */\nexport function summarizeRuns(\n workflows: AutomationWorkflowLike[],\n runs: AutomationRunLike[],\n now: Date = new Date(),\n): { total: RunStats; byWorkflow: Map<string, RunStats> } {\n const monthStart = startOfMonth(now).getTime();\n const emailStepsByWorkflow = new Map(\n workflows.map((w) => [w.id, emailStepIds(parseEngineSteps(w.steps))]),\n );\n const total = emptyStats();\n const byWorkflow = new Map<string, RunStats>();\n for (const w of workflows) byWorkflow.set(w.id, emptyStats());\n\n for (const run of runs) {\n const target = byWorkflow.get(run.workflowId) ?? emptyStats();\n byWorkflow.set(run.workflowId, target);\n const started = new Date(run.startedAt).getTime();\n const thisMonth = Number.isFinite(started) && started >= monthStart;\n for (const stats of [total, target]) {\n if (!stats.lastRunAt || run.startedAt > stats.lastRunAt) {\n stats.lastRunAt = run.startedAt;\n }\n if (!thisMonth) continue;\n stats.runsThisMonth += 1;\n stats.emailsSentThisMonth += emailsDeliveredByRun(\n run,\n emailStepsByWorkflow.get(run.workflowId) ?? new Set(),\n );\n if (run.status === \"COMPLETED\") {\n stats.finished += 1;\n stats.completed += 1;\n } else if (run.status === \"FAILED\") {\n stats.finished += 1;\n stats.failed += 1;\n }\n }\n }\n\n const finalized = new Map<string, RunStats>();\n for (const [id, stats] of byWorkflow) finalized.set(id, finalize(stats));\n return { total: finalize(total), byWorkflow: finalized };\n}\n\n/** Number of user-visible steps (structural branch-end markers excluded). */\nexport function visibleStepCount(steps: unknown): number {\n return parseEngineSteps(steps).filter(\n (s) => !(s.type === \"GOAL\" && s.config[\"endRun\"] === true),\n ).length;\n}\n\n/** Trigger summary shown in lists, e.g. \"Lead score reached 80\". */\nexport function describeTrigger(workflow: AutomationWorkflowLike): string {\n const label = triggerLabel(workflow.triggerType);\n const threshold = workflow.triggerConfig?.[\"scoreThreshold\"];\n if (\n workflow.triggerType === \"SCORE_THRESHOLD\" &&\n typeof threshold === \"number\"\n )\n return `${label} ${threshold}`;\n return label;\n}\n\n/** Lower-case status used by the shared StatusBadge. */\nexport function workflowBadgeStatus(status: string): string {\n return status.toLowerCase();\n}\n\nexport function isRunCancellable(status: string): boolean {\n return status === \"PENDING\" || status === \"RUNNING\" || status === \"WAITING\";\n}\n\nexport function isRunRetryable(status: string): boolean {\n return status === \"FAILED\";\n}\n\n/** Step label for a run log entry: \"2 · Send Email\". */\nexport function stepName(\n steps: EngineStep[],\n stepIndex: number,\n fallbackType: string,\n): string {\n const step = steps[stepIndex];\n const custom = step?.config[\"label\"];\n if (typeof custom === \"string\" && custom.trim()) return custom;\n const type = step?.type ?? fallbackType;\n const readable = type\n .toLowerCase()\n .split(\"_\")\n .map((w) => w.charAt(0).toUpperCase() + w.slice(1))\n .join(\" \");\n if (type === \"GOAL\" && step?.config[\"endRun\"] === true)\n return \"End of branch\";\n return readable;\n}\n"],"mappings":";;;AAiEA,SAAgB,EAAa,GAAiB;AAC5C,QAAO,IAAI,KAAK,EAAI,aAAa,EAAE,EAAI,UAAU,EAAE,EAAE;;AAGvD,SAAS,IAAuB;AAC9B,QAAO;EACL,eAAe;EACf,qBAAqB;EACrB,UAAU;EACV,WAAW;EACX,QAAQ;EACR,aAAa;EACb,WAAW;EACZ;;AAIH,SAAS,EAAa,GAAkC;AACtD,QAAO,IAAI,IAAI,EAAM,QAAQ,MAAM,EAAE,SAAS,aAAa,CAAC,KAAK,MAAM,EAAE,GAAG,CAAC;;AAQ/E,SAAgB,EACd,GACA,GACQ;CACR,IAAM,IAAU,EAAI,WAAW,EAAE,EAC7B,IAAQ;AACZ,MAAK,IAAM,KAAM,GAAY;EAC3B,IAAM,IAAS,EAAQ,QAAQ;AAC/B,EACE,OAAO,KAAW,YAClB,KACA,OAAQ,EAAmC,eAAmB,aAE9D,KAAS;;AAGb,QAAO;;AAGT,SAAS,EAAS,GAA2B;AAC3C,QAAO;EACL,GAAG;EACH,aACE,EAAM,WAAW,IAAK,EAAM,YAAY,EAAM,WAAY,MAAM;EACnE;;AAIH,SAAgB,EACd,GACA,GACA,oBAAY,IAAI,MAAM,EACkC;CACxD,IAAM,IAAa,EAAa,EAAI,CAAC,SAAS,EACxC,IAAuB,IAAI,IAC/B,EAAU,KAAK,MAAM,CAAC,EAAE,IAAI,EAAa,EAAiB,EAAE,MAAM,CAAC,CAAC,CAAC,CACtE,EACK,IAAQ,GAAY,EACpB,oBAAa,IAAI,KAAuB;AAC9C,MAAK,IAAM,KAAK,EAAW,GAAW,IAAI,EAAE,I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