@beehexa/hexasync-template-report-model 2608.7.4

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.
@@ -0,0 +1,241 @@
1
+ /**
2
+ * The report as data (AD-4, core).
3
+ *
4
+ * Every shape here is inert: no markup, no rendering, no IO. That separation is the point —
5
+ * `@beehexa/hexasync-template-report-render` turns these into Markdown and HTML, and because the
6
+ * models live in core while the renderers are an adapter, no core package can emit HTML.
7
+ *
8
+ * Moved verbatim out of the CLI's compose/types.ts, which is why the wording of these
9
+ * comments still refers to the merge engine by name.
10
+ */
11
+ export type MergeOp = 'added' | 'customized' | 'excluded';
12
+ /**
13
+ * A single merge operation observed by the tracer. Emitted from `mergeKey`'s
14
+ * array branch (AD-2); the source context is stamped by `mergeToMain` per file.
15
+ */
16
+ export interface OverwriteRecord {
17
+ parentKey: string;
18
+ sourceFile: string;
19
+ oldValue: unknown;
20
+ newValue: unknown;
21
+ /** true when the OVERWRITTEN array actually held id/key components (real loss). */
22
+ hadComponents: boolean;
23
+ /** merge recursion depth (0 = a top-level component collection). Only depth-0
24
+ * overwrites represent lost top-level components. */
25
+ depth: number;
26
+ }
27
+ export type ComponentStatus = 'added' | 'inherited' | 'customized' | 'excluded' | 'lost';
28
+ export interface ComponentProvenance {
29
+ idOrKey: string;
30
+ parentKey: string;
31
+ status: ComponentStatus;
32
+ /** Project whose version won; '' for excluded/lost. */
33
+ winner: string;
34
+ weight?: number;
35
+ /** Plain path e.g. "Sapo Metrics => Misa-Sapo Metrics => THIS". */
36
+ hierarchyPath: string;
37
+ /** Same chain as clickable relative links (label + relative path, null = no link). */
38
+ hierarchy: {
39
+ label: string;
40
+ link: string | null;
41
+ }[];
42
+ /** Unified line-diff (ancestor original → final) for customized components; else undefined. */
43
+ diffText?: string;
44
+ /** Per-generation-hop diffs (deepest ancestor → … → THIS) when a component is
45
+ * overwritten across multiple projects in the inheritance chain. Only set (length > 1)
46
+ * when there is genuine multi-generation history; the last phase is THIS's override. */
47
+ diffPhases?: DiffPhase[];
48
+ /** Nested sub-components rendered as a collapsible sub-table under this row —
49
+ * e.g. a webhook's `targets` (detail mode), or a map-of-arrays entry's items. */
50
+ subTable?: SubTable;
51
+ /** Counts-only rollups for registered high-cardinality sub-collections (metrics). */
52
+ subComponents?: SubComponentSummary[];
53
+ /** For puller/pusher components: the step-phase flow, rendered as a Mermaid chart. */
54
+ flow?: ComponentFlow;
55
+ }
56
+ /** Provenance of a single sub-component (a metric, a webhook target, a map entry).
57
+ * Same status vocabulary as a top-level component, reconciled across checkpoints. */
58
+ export interface SubItemProvenance {
59
+ /** Sub-item id/key (metric id, webhook target key, map entry key). */
60
+ idOrKey: string;
61
+ /** Display label, e.g. `<id> (KIND)`. */
62
+ label: string;
63
+ status: ComponentStatus;
64
+ /** Project that authored the winning version (or last to hold a removed item). */
65
+ winner?: string;
66
+ /** Unified diff (first-introduced → final) when customized. */
67
+ diffText?: string;
68
+ /** Optional step-flow Mermaid chart (e.g. a webhook target's `pullSteps`). */
69
+ flow?: ComponentFlow;
70
+ }
71
+ /** A titled collapsible sub-table of sub-components rendered under a component row. */
72
+ export interface SubTable {
73
+ /** Sub-table heading, e.g. `metrics` / `targets` / `items`. */
74
+ title: string;
75
+ items: SubItemProvenance[];
76
+ }
77
+ /** Counts-only rollup of a parent's sub-component collection (high-cardinality,
78
+ * e.g. an object's metrics) — no per-item detail, for performance. */
79
+ export interface SubComponentSummary {
80
+ /** Collection field name, e.g. `metrics`. */
81
+ title: string;
82
+ added: number;
83
+ removed: number;
84
+ customized: number;
85
+ }
86
+ /** One generation hop in a component's overwrite history (e.g. `C → B`). */
87
+ export interface DiffPhase {
88
+ /** Deeper (source) project label. */
89
+ fromLabel: string;
90
+ /** Shallower (overriding) project label; the last hop's `toLabel` is THIS. */
91
+ toLabel: string;
92
+ /** Unified line-diff of the component as composed at `from` → as composed at `to`. */
93
+ diffText: string;
94
+ /** Number of +/- lines in this hop. */
95
+ changeCount: number;
96
+ }
97
+ /** One step inside a puller/pusher phase or a creation workflow (the subset the
98
+ * flow chart needs). */
99
+ export interface FlowStep {
100
+ /** Step identifier (matches `next` targets). */
101
+ key: string;
102
+ /** Human label: step `name` falling back to `key`. */
103
+ label: string;
104
+ /** Raw `next` value (string key, branch object, Scriban expr, or null). */
105
+ next?: unknown;
106
+ /** True when this step is an entry (`rootStep`/`root: true`). */
107
+ rootStep: boolean;
108
+ /** creationSteps only: the step `type` (API/IF/SWITCH/FORM/…), drives branching + shape. */
109
+ stepType?: string;
110
+ /** creationSteps only: raw `metadata` (IF `then`/`else`, SWITCH `cases`/`default`). */
111
+ metadata?: unknown;
112
+ /** creationSteps only: `onCancelled` target step key (cancel route). */
113
+ onCancelled?: string;
114
+ /** new-kind puller only: raw `data` (IF `then`/`else`, SWITCH branch keys). */
115
+ data?: unknown;
116
+ /** new-kind puller only: `onError` recovery target step key. */
117
+ onError?: string;
118
+ /** new-kind puller only: an Exception step's `fromStep` back-reference. */
119
+ fromStep?: string;
120
+ }
121
+ /** One ordered phase of a puller/pusher (e.g. `pullSteps`) or the single synthetic
122
+ * phase of a creation workflow, with its steps. */
123
+ export interface FlowPhase {
124
+ /** Phase key, e.g. `beforePullSteps` / `pushSteps` / `creationSteps`. */
125
+ name: string;
126
+ steps: FlowStep[];
127
+ }
128
+ /** The step-flow of a puller, pusher, or creation-workflow component (Mermaid chart). */
129
+ export interface ComponentFlow {
130
+ kind: 'puller' | 'pusher' | 'creation';
131
+ phases: FlowPhase[];
132
+ /** True for a NEW-KIND puller (steps/onErrorSteps/finalSteps): the Mermaid renderer then
133
+ * also draws IF/SWITCH-via-`data`, `onError`, and Exception `fromStep` edges. */
134
+ newKind?: boolean;
135
+ }
136
+ export interface ComposedProjectRow {
137
+ project: string;
138
+ generation: number;
139
+ weight: number;
140
+ order: number;
141
+ }
142
+ /** A variable added or changed by the current project vs its ancestors. */
143
+ export interface VariableChange {
144
+ key: string;
145
+ status: 'added' | 'customized';
146
+ /** old (ancestor) value, absent for added. */
147
+ oldValue?: string;
148
+ /** new (current) value. */
149
+ newValue: string;
150
+ /** git-diff of old→new value. */
151
+ diffText: string;
152
+ }
153
+ /** A wholesale array overwrite that DROPPED real id/key components (a suspicious,
154
+ * possibly accidental loss — distinct from an explicit `!` removal). Benign id-less
155
+ * config-array overwrites are NOT reported here. */
156
+ export interface WholesaleLoss {
157
+ parentKey: string;
158
+ sourceFile: string;
159
+ /** `sourceFile` relative to the report dir, for a clickable link (null if unavailable). */
160
+ sourceLink?: string | null;
161
+ /** id/key of each component the overwrite dropped. */
162
+ droppedIds: string[];
163
+ /** old (with components) → new (id-less replacement) unified diff. */
164
+ diffText: string;
165
+ }
166
+ export interface ReportModel {
167
+ projectTitle: string;
168
+ /**
169
+ * The compose contract this artefact was computed under (AD-13, Story 1.10 AC 3).
170
+ *
171
+ * Stamped on the ARTEFACT, not just checked at startup, because the check happens once and the
172
+ * artefact outlives it. A model that is cached, sent to a report, or compared against a CI run
173
+ * has to carry its own provenance or a later disagreement is unattributable.
174
+ */
175
+ contractVersion?: number;
176
+ /** Rendered at the TOP of the report (AD-6). */
177
+ warnings: string[];
178
+ counts: Record<ComponentStatus, number>;
179
+ composedProjects: ComposedProjectRow[];
180
+ components: ComponentProvenance[];
181
+ /** Wholesale array overwrites that dropped real id/key components (accidental-loss signal). */
182
+ wholesaleLosses: WholesaleLoss[];
183
+ /** Variables added or changed by the current project vs inherited. */
184
+ variableChanges: VariableChange[];
185
+ }
186
+ /** Impact level of a validation Issue, calibrated to worker consequences:
187
+ * critical = won't run in production; high = runs but silently wrong;
188
+ * major = logic/portability defect; medium = smell/dead config; low = style. */
189
+ export type ValidationSeverity = 'critical' | 'high' | 'major' | 'medium' | 'low';
190
+ /** One detected problem: a rule violation on a specific component/field (or project-wide). */
191
+ export interface ValidationIssue {
192
+ /** Stable rule id, e.g. "REF-9". */
193
+ ruleId: string;
194
+ /** Rule family, e.g. "REF" | "DUP" | "TBL" | "VAR" | "FLOW". */
195
+ family: string;
196
+ severity: ValidationSeverity;
197
+ /** Owning component's collection key (e.g. "objects") — omit for project-wide issues. */
198
+ parentKey?: string;
199
+ /** Owning component's id/key — omit for project-wide issues. */
200
+ idOrKey?: string;
201
+ /** Absolute source file the component came from (for locating the offending line). */
202
+ sourceFile?: string;
203
+ /** `sourceFile` relative to the report dir, for a clickable link (null when unavailable). */
204
+ sourceLink?: string | null;
205
+ /** One-line statement of the problem (the headline). */
206
+ message: string;
207
+ /** One-line explanation of what breaks (the worker consequence). */
208
+ why: string;
209
+ /** Optional git-diff-style snippet of the offending line(s) (attached by the source locator). */
210
+ snippetDiff?: string;
211
+ /** Optional value to locate for a precise snippet (else derived from the message). */
212
+ locateValue?: string;
213
+ }
214
+ /** Issues for a single component, rendered as one group in the report. */
215
+ export interface ValidationComponentGroup {
216
+ parentKey: string;
217
+ idOrKey: string;
218
+ sourceLink: string | null;
219
+ issues: ValidationIssue[];
220
+ }
221
+ /** The full validation report data model (mirror of ReportModel for the validation renderers). */
222
+ export interface ValidationReportModel {
223
+ projectTitle: string;
224
+ /** Count per severity (always all five keys present). */
225
+ counts: Record<ValidationSeverity, number>;
226
+ /** Total number of issues. */
227
+ total: number;
228
+ /** Issues grouped by component, ordered by highest severity then component key. */
229
+ issuesByComponent: ValidationComponentGroup[];
230
+ /** Issues not tied to a single component (e.g. duplicate-id pairs, orphans). */
231
+ crossCutting: ValidationIssue[];
232
+ /**
233
+ * The compose contract this artefact was computed under (AD-13, Story 1.10 AC 3).
234
+ *
235
+ * Stamped on the ARTEFACT, not just checked at startup, because the check happens once and the
236
+ * artefact outlives it. A model that is cached, sent to a report, or compared against a CI run
237
+ * has to carry its own provenance or a later disagreement is unattributable.
238
+ */
239
+ contractVersion?: number;
240
+ }
241
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,MAAM,OAAO,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E,CAAC;IAC9C,gFAAgF;IAChF,YAAY,EAAE,eAAe,EAAE,CAAC;IAChC;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@beehexa/hexasync-template-report-model",
3
+ "version": "2608.7.4",
4
+ "description": "The report as data. Emits no markup of any kind.",
5
+ "license": "SEE LICENSE IN ../../LICENSE",
6
+ "type": "module",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ }
12
+ },
13
+ "main": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "scripts": {
19
+ "typecheck": "tsc --noEmit",
20
+ "build": "tsc -p tsconfig.build.json"
21
+ },
22
+ "dependencies": {
23
+ "@beehexa/hexasync-template-model": "2608.7.4"
24
+ },
25
+ "hexasync": {
26
+ "layer": "core"
27
+ }
28
+ }