@warlock.js/grimoire 5.57.0 → 5.59.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.
Files changed (123) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/esm/apps/check-apps.mjs +11 -5
  3. package/esm/apps/check-apps.mjs.map +1 -1
  4. package/esm/book/build.d.mts.map +1 -1
  5. package/esm/book/build.mjs +2 -1
  6. package/esm/book/build.mjs.map +1 -1
  7. package/esm/book/render.mjs +10 -0
  8. package/esm/book/render.mjs.map +1 -1
  9. package/esm/bookmap/build.d.mts.map +1 -1
  10. package/esm/bookmap/build.mjs +7 -5
  11. package/esm/bookmap/build.mjs.map +1 -1
  12. package/esm/bookmap/steps.mjs +85 -39
  13. package/esm/bookmap/steps.mjs.map +1 -1
  14. package/esm/check/check-grimoire.d.mts.map +1 -1
  15. package/esm/check/check-grimoire.mjs +4 -1
  16. package/esm/check/check-grimoire.mjs.map +1 -1
  17. package/esm/check/rules/criteria.mjs +21 -2
  18. package/esm/check/rules/criteria.mjs.map +1 -1
  19. package/esm/check/rules/screenshots.mjs +57 -0
  20. package/esm/check/rules/screenshots.mjs.map +1 -0
  21. package/esm/codes/codes.d.mts +12 -0
  22. package/esm/codes/codes.d.mts.map +1 -1
  23. package/esm/codes/codes.mjs +6 -0
  24. package/esm/codes/codes.mjs.map +1 -1
  25. package/esm/contracts/adapter.d.mts +28 -1
  26. package/esm/contracts/adapter.d.mts.map +1 -1
  27. package/esm/contracts/book.d.mts +2 -0
  28. package/esm/contracts/book.d.mts.map +1 -1
  29. package/esm/contracts/book.mjs.map +1 -1
  30. package/esm/contracts/bookmap.d.mts +19 -1
  31. package/esm/contracts/bookmap.d.mts.map +1 -1
  32. package/esm/contracts/scry.d.mts +26 -6
  33. package/esm/contracts/scry.d.mts.map +1 -1
  34. package/esm/contracts/snapshot.d.mts +14 -1
  35. package/esm/contracts/snapshot.d.mts.map +1 -1
  36. package/esm/contracts/test-results.d.mts +34 -0
  37. package/esm/contracts/test-results.d.mts.map +1 -1
  38. package/esm/contracts/written.d.mts +44 -0
  39. package/esm/contracts/written.d.mts.map +1 -1
  40. package/esm/contracts/written.mjs.map +1 -1
  41. package/esm/devtools/data.mjs +116 -5
  42. package/esm/devtools/data.mjs.map +1 -1
  43. package/esm/devtools/feature-map.mjs +149 -0
  44. package/esm/devtools/feature-map.mjs.map +1 -0
  45. package/esm/devtools/index.d.mts +28 -2
  46. package/esm/devtools/index.d.mts.map +1 -1
  47. package/esm/devtools/index.mjs +111 -7
  48. package/esm/devtools/index.mjs.map +1 -1
  49. package/esm/devtools/product-map.d.mts +14 -0
  50. package/esm/devtools/product-map.d.mts.map +1 -0
  51. package/esm/devtools/product-map.mjs +460 -0
  52. package/esm/devtools/product-map.mjs.map +1 -0
  53. package/esm/devtools/site.d.mts +43 -1
  54. package/esm/devtools/site.d.mts.map +1 -1
  55. package/esm/devtools/site.mjs +190 -22
  56. package/esm/devtools/site.mjs.map +1 -1
  57. package/esm/devtools/snapshot-source.mjs +24 -7
  58. package/esm/devtools/snapshot-source.mjs.map +1 -1
  59. package/esm/graph/index.d.mts +10 -1
  60. package/esm/graph/index.d.mts.map +1 -1
  61. package/esm/graph/index.mjs +3 -2
  62. package/esm/graph/index.mjs.map +1 -1
  63. package/esm/index.d.mts +5 -5
  64. package/esm/ownership/index.d.mts.map +1 -1
  65. package/esm/ownership/index.mjs +60 -1
  66. package/esm/ownership/index.mjs.map +1 -1
  67. package/esm/paths/index.d.mts +2 -0
  68. package/esm/paths/index.d.mts.map +1 -1
  69. package/esm/paths/index.mjs +3 -1
  70. package/esm/paths/index.mjs.map +1 -1
  71. package/esm/scry/compact.mjs +170 -0
  72. package/esm/scry/compact.mjs.map +1 -0
  73. package/esm/scry/format.d.mts.map +1 -1
  74. package/esm/scry/format.mjs +19 -2
  75. package/esm/scry/format.mjs.map +1 -1
  76. package/esm/scry/query.d.mts.map +1 -1
  77. package/esm/scry/query.mjs +159 -24
  78. package/esm/scry/query.mjs.map +1 -1
  79. package/esm/test-results/index.d.mts +7 -2
  80. package/esm/test-results/index.d.mts.map +1 -1
  81. package/esm/test-results/index.mjs +79 -12
  82. package/esm/test-results/index.mjs.map +1 -1
  83. package/esm/vitest/index.d.mts +6 -0
  84. package/esm/vitest/index.d.mts.map +1 -1
  85. package/esm/vitest/index.mjs +22 -6
  86. package/esm/vitest/index.mjs.map +1 -1
  87. package/esm/warlock/actions.mjs +15 -7
  88. package/esm/warlock/actions.mjs.map +1 -1
  89. package/esm/warlock/adapter.d.mts.map +1 -1
  90. package/esm/warlock/adapter.mjs +42 -4
  91. package/esm/warlock/adapter.mjs.map +1 -1
  92. package/esm/warlock/commands.mjs +7 -2
  93. package/esm/warlock/commands.mjs.map +1 -1
  94. package/esm/warlock/logo.mjs +12 -0
  95. package/esm/warlock/logo.mjs.map +1 -0
  96. package/esm/warlock/mcp-tools.mjs +51 -15
  97. package/esm/warlock/mcp-tools.mjs.map +1 -1
  98. package/esm/workspace/cache.mjs +194 -0
  99. package/esm/workspace/cache.mjs.map +1 -0
  100. package/esm/workspace/index.d.mts.map +1 -1
  101. package/esm/workspace/index.mjs +7 -3
  102. package/esm/workspace/index.mjs.map +1 -1
  103. package/esm/written/apps.mjs +4 -2
  104. package/esm/written/apps.mjs.map +1 -1
  105. package/esm/written/features.mjs +119 -6
  106. package/esm/written/features.mjs.map +1 -1
  107. package/esm/written/markdown.mjs +66 -1
  108. package/esm/written/markdown.mjs.map +1 -1
  109. package/esm/written/parse-grimoire.d.mts.map +1 -1
  110. package/esm/written/parse-grimoire.mjs +1 -1
  111. package/esm/written/parse-grimoire.mjs.map +1 -1
  112. package/llms-full.txt +108 -12
  113. package/package.json +3 -3
  114. package/skills/backfill-a-grimoire/SKILL.md +5 -0
  115. package/skills/describe-an-app/SKILL.md +12 -0
  116. package/skills/record-a-change/SKILL.md +10 -0
  117. package/skills/use-the-grimoire/SKILL.md +44 -10
  118. package/skills/write-a-feature/SKILL.md +37 -2
  119. package/ui/grimoire-static.js +61 -6
  120. package/ui/grimoire-view.js +2133 -316
  121. package/ui/grimoire.css +1030 -24
  122. package/ui/product-map.css +785 -0
  123. package/ui/product-map.js +1265 -0
@@ -0,0 +1,460 @@
1
+ import { normalizeRoutePath } from "../bookmap/steps.mjs";
2
+ import "../bookmap/index.mjs";
3
+ import { checkGrimoire } from "../check/check-grimoire.mjs";
4
+ import "../check/index.mjs";
5
+ import { compactStep, flowOrder, neighboursOf } from "../scry/compact.mjs";
6
+ import { GrimoirePanelError } from "./data.mjs";
7
+
8
+ //#region ../../packages/grimoire/src/devtools/product-map.ts
9
+ /**
10
+ * The product map answers: the Grimoire in plain words for readers who do
11
+ * not read code. Built from the written files, the book maps, the test
12
+ * results, the open tasks, the changelogs and (when the devtools monitor
13
+ * reports them) the captured errors. A shared answer (`options.shared`)
14
+ * carries no file paths, code or test names.
15
+ */
16
+ /** How far back captured errors count (one hour). */
17
+ const ERROR_WINDOW_MS = 36e5;
18
+ function addCount(map, key, group) {
19
+ const known = map.get(key);
20
+ map.set(key, {
21
+ count: (known?.count ?? 0) + group.count,
22
+ lastSeen: Math.max(known?.lastSeen ?? 0, group.lastSeen)
23
+ });
24
+ }
25
+ /** Map the last hour's error groups to the features and flows that use their route. */
26
+ function captureErrors(snapshot, errors, now) {
27
+ const features = /* @__PURE__ */ new Map();
28
+ const flows = /* @__PURE__ */ new Map();
29
+ const routes = snapshot.book.facts.routes ?? [];
30
+ for (const group of errors) {
31
+ if (group.route === null || group.lastSeen < now - ERROR_WINDOW_MS) continue;
32
+ const path = normalizeRoutePath(group.route);
33
+ for (const route of routes) {
34
+ if (normalizeRoutePath(route.path) !== path) continue;
35
+ const file = route.handlerFile ?? route.sourceFile;
36
+ const owner = file === null ? null : snapshot.ownership.files[file]?.owner ?? null;
37
+ if (owner !== null) addCount(features, owner, group);
38
+ }
39
+ for (const feature of snapshot.written.features) for (const flow of feature.flows) if (flow.steps.some((step) => step.type === "route" && step.route !== null && normalizeRoutePath(step.route.path) === path || step.type === "page" && normalizeRoutePath(step.target) === path)) addCount(flows, flow.ref, group);
40
+ }
41
+ return {
42
+ features,
43
+ flows
44
+ };
45
+ }
46
+ /**
47
+ * The check report of a snapshot, run once per snapshot. A share link reaches
48
+ * these answers without an account, so a page view must not run the whole
49
+ * check again; a changed book opens a new snapshot and a new report.
50
+ */
51
+ const reports = /* @__PURE__ */ new WeakMap();
52
+ function reportOf(snapshot) {
53
+ let report = reports.get(snapshot);
54
+ if (report === void 0) {
55
+ report = checkGrimoire(snapshot);
56
+ reports.set(snapshot, report);
57
+ }
58
+ return report;
59
+ }
60
+ function contextOf(snapshot, options) {
61
+ const report = reportOf(snapshot);
62
+ const featureErrors = /* @__PURE__ */ new Map();
63
+ const flowErrors = /* @__PURE__ */ new Map();
64
+ const featureFindings = /* @__PURE__ */ new Map();
65
+ for (const finding of report.findings) {
66
+ if (finding.expected) continue;
67
+ const owner = finding.subject.feature ?? finding.subject.flow?.split("/")[0] ?? null;
68
+ if (owner !== null) {
69
+ const known = featureFindings.get(owner) ?? {
70
+ errors: 0,
71
+ warnings: 0
72
+ };
73
+ if (finding.severity === "error") known.errors += 1;
74
+ else known.warnings += 1;
75
+ featureFindings.set(owner, known);
76
+ }
77
+ if (finding.severity !== "error") continue;
78
+ const flow = finding.subject.flow;
79
+ const feature = finding.subject.feature ?? flow?.split("/")[0] ?? null;
80
+ if (feature !== null) featureErrors.set(feature, (featureErrors.get(feature) ?? 0) + 1);
81
+ if (flow !== null) flowErrors.set(flow, (flowErrors.get(flow) ?? 0) + 1);
82
+ }
83
+ return {
84
+ snapshot,
85
+ options,
86
+ report,
87
+ featureErrors,
88
+ flowErrors,
89
+ featureFindings,
90
+ captured: options.errors === null ? null : captureErrors(snapshot, options.errors, Date.now()),
91
+ resultsMissing: snapshot.results === null && snapshot.proofs.length > 0
92
+ };
93
+ }
94
+ const plural = (count, word) => `${count} ${word}${count === 1 ? "" : "s"}`;
95
+ /** The traffic light and its sentence (the rules of the product map). */
96
+ function healthOf(context, criteria, checkErrors, captured) {
97
+ const counts = {
98
+ total: criteria.length,
99
+ pass: 0,
100
+ fail: 0,
101
+ stale: 0,
102
+ notRun: 0,
103
+ noTest: 0
104
+ };
105
+ for (const criterion of criteria) if (criterion.status === "pass") counts.pass += 1;
106
+ else if (criterion.status === "fail") counts.fail += 1;
107
+ else if (criterion.status === "stale") counts.stale += 1;
108
+ else if (criterion.status === "not-run") counts.notRun += 1;
109
+ else counts.noTest += 1;
110
+ const errors = context.captured === null ? null : {
111
+ count: captured?.count ?? 0,
112
+ lastSeen: captured?.lastSeen ?? null
113
+ };
114
+ const recent = errors?.count ?? 0;
115
+ const total = counts.total;
116
+ let level;
117
+ let reason;
118
+ if (counts.fail > 0) {
119
+ level = "problem";
120
+ reason = `${counts.fail} of ${total} checks fail`;
121
+ } else if (checkErrors > 0) {
122
+ level = "problem";
123
+ reason = `The check found ${plural(checkErrors, "error")}`;
124
+ } else if (counts.noTest > 0) {
125
+ level = "attention";
126
+ reason = `${counts.noTest} of ${total} checks have no test`;
127
+ } else if (context.resultsMissing && total > 0) {
128
+ if (context.options.shared) {
129
+ level = "unknown";
130
+ reason = "Test results are not measured";
131
+ } else {
132
+ level = "attention";
133
+ reason = "No test results recorded";
134
+ }
135
+ } else if (counts.stale > 0 || counts.notRun > 0) {
136
+ level = "attention";
137
+ reason = "Tests have not run since they changed";
138
+ } else if (recent > 0) {
139
+ level = "attention";
140
+ reason = `${plural(recent, "error")} in the last hour`;
141
+ } else if (total > 0) {
142
+ level = "good";
143
+ reason = `All ${total} checks pass`;
144
+ } else {
145
+ level = "unknown";
146
+ reason = "No checks written yet";
147
+ }
148
+ return {
149
+ level,
150
+ reason,
151
+ criteria: counts,
152
+ errors
153
+ };
154
+ }
155
+ function featureHealth(context, feature) {
156
+ return healthOf(context, feature.flows.flatMap((flow) => context.snapshot.collected.flows[flow.ref]?.criteria ?? []), context.featureErrors.get(feature.id) ?? 0, context.captured?.features.get(feature.id));
157
+ }
158
+ function flowHealthOf(context, flow) {
159
+ return healthOf(context, context.snapshot.collected.flows[flow.ref]?.criteria ?? [], context.flowErrors.get(flow.ref) ?? 0, context.captured?.flows.get(flow.ref));
160
+ }
161
+ function findFeature(snapshot, id) {
162
+ if (id === void 0 || id === "") throw new GrimoirePanelError(400, "Missing \"feature\".");
163
+ const feature = snapshot.written.features.find((item) => item.id === id);
164
+ if (feature === void 0 || feature.readme === null) throw new GrimoirePanelError(404, `No feature "${id}" is written in grimoire/features.`);
165
+ return feature;
166
+ }
167
+ function audienceOf(feature) {
168
+ const listed = (feature.readme?.audience ?? []).map((item) => item.value);
169
+ if (listed.length > 0) return listed;
170
+ return [...new Set(feature.flows.map((flow) => flow.who.value))];
171
+ }
172
+ /** The health strip numbers of a feature card. */
173
+ function stripOf(context, feature, health) {
174
+ const bookmaps = feature.flows.flatMap((flow) => {
175
+ const found = context.snapshot.collected.flows[flow.ref];
176
+ return found === void 0 ? [] : [found];
177
+ });
178
+ const places = appearancesOf(context.snapshot, bookmaps);
179
+ return {
180
+ flows: {
181
+ total: feature.flows.length,
182
+ shipped: feature.flows.filter((flow) => flow.status.value === "shipped").length
183
+ },
184
+ criteria: {
185
+ total: health.criteria.total,
186
+ proven: health.criteria.pass,
187
+ failing: health.criteria.fail,
188
+ measured: !context.resultsMissing && (health.criteria.total === 0 || health.criteria.pass + health.criteria.fail + health.criteria.stale > 0 || health.criteria.notRun === 0)
189
+ },
190
+ screenshots: {
191
+ places: places.length,
192
+ present: places.filter((place) => place.screenshots.length > 0).length
193
+ },
194
+ findings: context.featureFindings.get(feature.id) ?? {
195
+ errors: 0,
196
+ warnings: 0
197
+ }
198
+ };
199
+ }
200
+ const DAY = /^\d{4}-\d{2}-\d{2}$/;
201
+ /** Only a real `YYYY-MM-DD` day counts as a change date; a bad `updated:` value is ignored here (check reports it). */
202
+ const isDay = (value) => DAY.test(value) && !Number.isNaN((/* @__PURE__ */ new Date(`${value}T00:00:00Z`)).getTime());
203
+ /** Compares release names by their numeric parts, so `5.9.0` comes before `5.10.0`. */
204
+ function compareReleases(left, right) {
205
+ const parts = (value) => value.split(/[.\-+]/).map((part) => part);
206
+ const a = parts(left);
207
+ const b = parts(right);
208
+ for (let index = 0; index < Math.max(a.length, b.length); index += 1) {
209
+ const x = a[index] ?? "0";
210
+ const y = b[index] ?? "0";
211
+ const diff = /^\d+$/.test(x) && /^\d+$/.test(y) ? Number(x) - Number(y) : x < y ? -1 : x > y ? 1 : 0;
212
+ if (diff !== 0) return diff;
213
+ }
214
+ return 0;
215
+ }
216
+ function card(context, feature) {
217
+ const readme = feature.readme;
218
+ if (readme === null) throw new Error("A feature card needs a README.");
219
+ const health = featureHealth(context, feature);
220
+ const entries = feature.changelog?.entries ?? [];
221
+ return {
222
+ changedAt: [readme.updated.value, ...entries.flatMap((entry) => entry.date === null ? [] : [entry.date])].filter(isDay).reduce((newest, date) => date > newest ? date : newest, ""),
223
+ changedIn: [...new Set(entries.flatMap((entry) => entry.release === null ? [] : [entry.release]))],
224
+ unreleased: entries.some((entry) => entry.release === null),
225
+ id: feature.id,
226
+ title: readme.title.value,
227
+ summary: readme.summary,
228
+ audience: audienceOf(feature),
229
+ apps: readme.apps.map((app) => app.value),
230
+ status: readme.status.value,
231
+ version: readme.version.value,
232
+ flows: feature.flows.length,
233
+ health,
234
+ strip: stripOf(context, feature, health)
235
+ };
236
+ }
237
+ /** `GET /product`: the feature map. */
238
+ function productMap(snapshot, options) {
239
+ const context = contextOf(snapshot, options);
240
+ return {
241
+ builtAt: snapshot.book.manifest.builtAt,
242
+ features: snapshot.written.features.filter((feature) => feature.readme !== null).map((feature) => card(context, feature)),
243
+ apps: snapshot.written.apps.map((app) => ({
244
+ id: app.id.value,
245
+ type: app.type.value,
246
+ title: app.heading?.value ?? null
247
+ })),
248
+ releases: snapshot.written.releases.map((item) => ({
249
+ release: item.release.value,
250
+ date: item.date.value
251
+ })).sort((left, right) => left.date.localeCompare(right.date) || compareReleases(left.release, right.release)),
252
+ developer: !options.shared,
253
+ host: snapshot.host ?? null
254
+ };
255
+ }
256
+ const slugOf = (text) => text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
257
+ function screenshotsOf(items) {
258
+ return items.flatMap((item) => item.path === null ? [] : [{
259
+ src: item.path,
260
+ alt: item.alt
261
+ }]);
262
+ }
263
+ /** Where the flows are shown, with the screenshots of the block (else of the page). */
264
+ function appearancesOf(snapshot, bookmaps) {
265
+ const seen = /* @__PURE__ */ new Set();
266
+ const list = [];
267
+ const apps = new Map(snapshot.written.apps.map((app) => [app.id.value, app]));
268
+ for (const bookmap of bookmaps) for (const shown of bookmap.shownBy) {
269
+ const key = `${shown.app}|${shown.type}|${shown.id}|${shown.block}|${bookmap.ref}`;
270
+ if (seen.has(key)) continue;
271
+ seen.add(key);
272
+ const app = apps.get(shown.app);
273
+ let title = null;
274
+ let route = null;
275
+ let screenshots = [];
276
+ if (app !== void 0 && shown.type === "layout") title = app.layouts.find((layout) => layout.id === shown.id)?.heading?.value ?? null;
277
+ else if (app !== void 0) {
278
+ const page = [...app.pages, ...app.screens].find((item) => item.id === shown.id);
279
+ if (page !== void 0) {
280
+ title = page.heading?.value ?? null;
281
+ route = page.route?.value ?? page.screen?.value ?? null;
282
+ screenshots = screenshotsOf((page.blockFiles.find((item) => item.id === slugOf(shown.block)) ?? page.blockFiles.find((item) => item.flow?.value === bookmap.ref))?.screenshots ?? []);
283
+ if (screenshots.length === 0) screenshots = screenshotsOf(page.screenshots);
284
+ }
285
+ }
286
+ list.push({
287
+ app: shown.app,
288
+ type: shown.type,
289
+ id: shown.id,
290
+ title,
291
+ route,
292
+ block: shown.block,
293
+ flow: bookmap.ref,
294
+ screenshots
295
+ });
296
+ }
297
+ return list;
298
+ }
299
+ function releasesOf(snapshot, feature) {
300
+ const dates = new Map(snapshot.written.releases.map((item) => [item.release.value, item.date.value]));
301
+ const entries = feature.changelog?.entries ?? [];
302
+ const ordered = [...entries.filter((entry) => entry.release === null), ...entries.filter((entry) => entry.release !== null)];
303
+ const groups = /* @__PURE__ */ new Map();
304
+ for (const entry of ordered) {
305
+ const key = `${entry.version.value}|${entry.release ?? ""}`;
306
+ let group = groups.get(key);
307
+ if (group === void 0) {
308
+ group = {
309
+ version: entry.version.value,
310
+ release: entry.release,
311
+ date: entry.date ?? (entry.release === null ? null : dates.get(entry.release) ?? null),
312
+ changes: []
313
+ };
314
+ groups.set(key, group);
315
+ }
316
+ group.changes.push({
317
+ word: entry.word,
318
+ flow: entry.flow,
319
+ text: entry.text
320
+ });
321
+ }
322
+ return [...groups.values()];
323
+ }
324
+ function plannedOf(snapshot, feature) {
325
+ return snapshot.collected.tasksIndex.open.filter((task) => task.feature === feature).map((task) => ({
326
+ id: task.id,
327
+ title: task.title,
328
+ type: task.type,
329
+ status: task.status,
330
+ flow: task.flow === null ? null : task.flow.replace(`${feature}/`, "")
331
+ }));
332
+ }
333
+ function flowCard(context, flow) {
334
+ return {
335
+ id: flow.id.value,
336
+ ref: flow.ref,
337
+ title: flow.heading?.value ?? flow.id.value,
338
+ summary: flow.summary,
339
+ who: flow.who.value,
340
+ status: flow.status.value,
341
+ health: flowHealthOf(context, flow)
342
+ };
343
+ }
344
+ /** `GET /product/features/:feature`. */
345
+ function productFeature(snapshot, id, options) {
346
+ const feature = findFeature(snapshot, id);
347
+ const readme = feature.readme;
348
+ if (readme === null) throw new Error("unreachable");
349
+ const context = contextOf(snapshot, options);
350
+ const bookmaps = feature.flows.flatMap((flow) => {
351
+ const bookmap = snapshot.collected.flows[flow.ref];
352
+ return bookmap === void 0 ? [] : [bookmap];
353
+ });
354
+ const own = snapshot.collected.features[feature.id];
355
+ const unexpected = context.report.findings.filter((finding) => (finding.subject.feature ?? finding.subject.flow?.split("/")[0]) === feature.id);
356
+ const unexpectedNow = unexpected.filter((finding) => !finding.expected);
357
+ const errors = unexpectedNow.filter((finding) => finding.severity === "error").length;
358
+ return {
359
+ feature: {
360
+ id: feature.id,
361
+ title: readme.title.value,
362
+ summary: readme.summary,
363
+ why: readme.why,
364
+ audience: audienceOf(feature),
365
+ apps: readme.apps.map((app) => app.value),
366
+ status: readme.status.value,
367
+ version: readme.version.value,
368
+ updated: readme.updated.value,
369
+ origin: readme.origin?.value ?? null
370
+ },
371
+ flows: flowOrder(feature).map((flow) => flowCard(context, flow)),
372
+ appearances: appearancesOf(snapshot, bookmaps),
373
+ releases: releasesOf(snapshot, feature),
374
+ planned: plannedOf(snapshot, feature.id),
375
+ health: featureHealth(context, feature),
376
+ host: snapshot.host ?? null,
377
+ developer: options.shared ? null : {
378
+ folders: readme.folders.map((folder) => folder.value),
379
+ routes: (own?.routes ?? []).map(({ file: _file, ...route }) => route),
380
+ files: own?.own.length ?? 0,
381
+ findings: {
382
+ errors,
383
+ warnings: unexpectedNow.length - errors,
384
+ expected: unexpected.length - unexpectedNow.length
385
+ }
386
+ }
387
+ };
388
+ }
389
+ const STEP_WORDS = {
390
+ page: (target) => `Open ${target}`,
391
+ route: () => "The server takes the request",
392
+ mail: (target) => `An email "${target}" is sent`,
393
+ notification: (target) => `A notification "${target}" is sent`,
394
+ job: (target) => `The job "${target}" runs in the background`,
395
+ event: (target) => `The event "${target}" happens`,
396
+ "outside service": (target) => `The outside service "${target}" is used`,
397
+ affects: (target) => `This also affects ${target}`
398
+ };
399
+ function storyOf(flow) {
400
+ if (flow.story.length > 0) return flow.story.map((step) => ({
401
+ index: step.index,
402
+ text: step.text,
403
+ screenshots: screenshotsOf(step.screenshots),
404
+ derived: false
405
+ }));
406
+ return flow.steps.map((step) => ({
407
+ index: step.index,
408
+ text: step.note ?? STEP_WORDS[step.type](step.target),
409
+ screenshots: [],
410
+ derived: true
411
+ }));
412
+ }
413
+ const DOES_NOT_APPLY = /^does not apply\b[:\s—-]*/i;
414
+ /** `GET /product/flows/:feature/:flow`. */
415
+ function productFlow(snapshot, featureId, flowId, options) {
416
+ const feature = findFeature(snapshot, featureId);
417
+ const flow = feature.flows.find((item) => item.id.value === flowId);
418
+ if (flow === void 0) throw new GrimoirePanelError(404, `No flow "${flowId ?? ""}" in feature "${feature.id}".`);
419
+ const context = contextOf(snapshot, options);
420
+ const bookmap = snapshot.collected.flows[flow.ref];
421
+ const { previous, next } = neighboursOf(feature, flow.id.value);
422
+ return {
423
+ flow: {
424
+ ref: flow.ref,
425
+ feature: feature.id,
426
+ featureTitle: feature.readme?.title.value ?? feature.id,
427
+ title: flow.heading?.value ?? flow.id.value,
428
+ summary: flow.summary,
429
+ who: flow.who.value,
430
+ status: flow.status.value,
431
+ since: flow.since.value
432
+ },
433
+ story: storyOf(flow),
434
+ proof: (bookmap?.criteria ?? []).map((criterion) => ({
435
+ id: criterion.id,
436
+ text: criterion.text,
437
+ status: criterion.status,
438
+ tests: options.shared ? null : criterion.tests
439
+ })),
440
+ cases: flow.cases.map((item) => {
441
+ const answer = item.doesNotApply ? item.answer.replace(DOES_NOT_APPLY, "").trim() : item.answer;
442
+ return {
443
+ question: item.question,
444
+ answer: answer === "" ? "Does not apply" : answer,
445
+ handled: !item.doesNotApply,
446
+ criteria: item.criteria
447
+ };
448
+ }),
449
+ appearances: bookmap === void 0 ? [] : appearancesOf(snapshot, [bookmap]),
450
+ previous,
451
+ next,
452
+ health: flowHealthOf(context, flow),
453
+ developer: options.shared ? null : { steps: (bookmap?.steps ?? []).map((step) => compactStep(snapshot, feature, step, flow)) },
454
+ host: snapshot.host ?? null
455
+ };
456
+ }
457
+
458
+ //#endregion
459
+ export { compareReleases, productFeature, productFlow, productMap };
460
+ //# sourceMappingURL=product-map.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product-map.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/devtools/product-map.ts"],"sourcesContent":["/**\n * The product map answers: the Grimoire in plain words for readers who do\n * not read code. Built from the written files, the book maps, the test\n * results, the open tasks, the changelogs and (when the devtools monitor\n * reports them) the captured errors. A shared answer (`options.shared`)\n * carries no file paths, code or test names.\n */\nimport { checkGrimoire } from \"../check\";\nimport { normalizeRoutePath } from \"../bookmap\";\nimport type { FlowBookmap, FlowBookmapCriterion } from \"../contracts/bookmap\";\nimport type { GrimoireCheckReport } from \"../contracts/findings\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\nimport type {\n WrittenApp,\n WrittenFeature,\n WrittenFlow,\n WrittenScreenshot,\n WrittenStep,\n} from \"../contracts/written\";\nimport { compactStep, flowOrder, neighboursOf } from \"../scry/compact\";\nimport type {\n ProductAppearance,\n ProductFeatureAnswer,\n ProductFeatureCard,\n ProductFlowAnswer,\n ProductFlowCard,\n ProductHealth,\n ProductMapAnswer,\n ProductPlannedItem,\n ProductRelease,\n ProductScreenshot,\n ProductStrip,\n ProductStoryStep,\n} from \"./answers\";\nimport { GrimoirePanelError } from \"./data\";\n\n/** One captured error group as devtools hands it to a panel: counts only. */\nexport type ProductErrorSummary = {\n /** The route pattern (`/products/:id`), or `null` outside a request. */\n route: string | null;\n status: number | null;\n name: string | null;\n source: \"request\" | \"log\";\n count: number;\n firstSeen: number;\n lastSeen: number;\n};\n\n/** How the product map answers are built. */\nexport type ProductMapOptions = {\n /** `true` for a read-only share link: no developer detail. */\n shared: boolean;\n /** Captured error groups, or `null` when the monitor reports none. */\n errors: readonly ProductErrorSummary[] | null;\n};\n\n/** How far back captured errors count (one hour). */\nconst ERROR_WINDOW_MS = 3_600_000;\n\ntype ErrorCount = { count: number; lastSeen: number };\n\n/** Everything the answers share, computed once per request. */\ntype Context = {\n snapshot: GrimoireSnapshot;\n options: ProductMapOptions;\n report: GrimoireCheckReport;\n featureErrors: Map<string, number>;\n flowErrors: Map<string, number>;\n /** Unexpected findings by feature id. */\n featureFindings: Map<string, { errors: number; warnings: number }>;\n captured: { features: Map<string, ErrorCount>; flows: Map<string, ErrorCount> } | null;\n resultsMissing: boolean;\n};\n\nfunction addCount(map: Map<string, ErrorCount>, key: string, group: ProductErrorSummary): void {\n const known = map.get(key);\n\n map.set(key, {\n count: (known?.count ?? 0) + group.count,\n lastSeen: Math.max(known?.lastSeen ?? 0, group.lastSeen),\n });\n}\n\n/** Map the last hour's error groups to the features and flows that use their route. */\nfunction captureErrors(\n snapshot: GrimoireSnapshot,\n errors: readonly ProductErrorSummary[],\n now: number,\n): NonNullable<Context[\"captured\"]> {\n const features = new Map<string, ErrorCount>();\n const flows = new Map<string, ErrorCount>();\n const routes = snapshot.book.facts.routes ?? [];\n\n for (const group of errors) {\n if (group.route === null || group.lastSeen < now - ERROR_WINDOW_MS) continue;\n\n const path = normalizeRoutePath(group.route);\n\n for (const route of routes) {\n if (normalizeRoutePath(route.path) !== path) continue;\n\n const file = route.handlerFile ?? route.sourceFile;\n const owner = file === null ? null : (snapshot.ownership.files[file]?.owner ?? null);\n\n if (owner !== null) addCount(features, owner, group);\n }\n\n for (const feature of snapshot.written.features) {\n for (const flow of feature.flows) {\n const hit = flow.steps.some(\n (step) =>\n (step.type === \"route\" &&\n step.route !== null &&\n normalizeRoutePath(step.route.path) === path) ||\n (step.type === \"page\" && normalizeRoutePath(step.target) === path),\n );\n\n if (hit) addCount(flows, flow.ref, group);\n }\n }\n }\n\n return { features, flows };\n}\n\n/**\n * The check report of a snapshot, run once per snapshot. A share link reaches\n * these answers without an account, so a page view must not run the whole\n * check again; a changed book opens a new snapshot and a new report.\n */\nconst reports = new WeakMap<GrimoireSnapshot, GrimoireCheckReport>();\n\nfunction reportOf(snapshot: GrimoireSnapshot): GrimoireCheckReport {\n let report = reports.get(snapshot);\n\n if (report === undefined) {\n report = checkGrimoire(snapshot);\n reports.set(snapshot, report);\n }\n\n return report;\n}\n\nfunction contextOf(snapshot: GrimoireSnapshot, options: ProductMapOptions): Context {\n const report = reportOf(snapshot);\n const featureErrors = new Map<string, number>();\n const flowErrors = new Map<string, number>();\n const featureFindings = new Map<string, { errors: number; warnings: number }>();\n\n for (const finding of report.findings) {\n if (finding.expected) continue;\n\n const owner = finding.subject.feature ?? finding.subject.flow?.split(\"/\")[0] ?? null;\n\n if (owner !== null) {\n const known = featureFindings.get(owner) ?? { errors: 0, warnings: 0 };\n\n if (finding.severity === \"error\") known.errors += 1;\n else known.warnings += 1;\n\n featureFindings.set(owner, known);\n }\n\n if (finding.severity !== \"error\") continue;\n\n const flow = finding.subject.flow;\n const feature = finding.subject.feature ?? flow?.split(\"/\")[0] ?? null;\n\n if (feature !== null) featureErrors.set(feature, (featureErrors.get(feature) ?? 0) + 1);\n if (flow !== null) flowErrors.set(flow, (flowErrors.get(flow) ?? 0) + 1);\n }\n\n return {\n snapshot,\n options,\n report,\n featureErrors,\n flowErrors,\n featureFindings,\n captured: options.errors === null ? null : captureErrors(snapshot, options.errors, Date.now()),\n resultsMissing: snapshot.results === null && snapshot.proofs.length > 0,\n };\n}\n\nconst plural = (count: number, word: string): string => `${count} ${word}${count === 1 ? \"\" : \"s\"}`;\n\n/** The traffic light and its sentence (the rules of the product map). */\nfunction healthOf(\n context: Context,\n criteria: readonly Pick<FlowBookmapCriterion, \"status\">[],\n checkErrors: number,\n captured: ErrorCount | undefined,\n): ProductHealth {\n const counts = { total: criteria.length, pass: 0, fail: 0, stale: 0, notRun: 0, noTest: 0 };\n\n for (const criterion of criteria) {\n if (criterion.status === \"pass\") counts.pass += 1;\n else if (criterion.status === \"fail\") counts.fail += 1;\n else if (criterion.status === \"stale\") counts.stale += 1;\n else if (criterion.status === \"not-run\") counts.notRun += 1;\n else counts.noTest += 1;\n }\n\n const errors =\n context.captured === null\n ? null\n : { count: captured?.count ?? 0, lastSeen: captured?.lastSeen ?? null };\n const recent = errors?.count ?? 0;\n const total = counts.total;\n let level: ProductHealth[\"level\"];\n let reason: string;\n\n if (counts.fail > 0) {\n level = \"problem\";\n reason = `${counts.fail} of ${total} checks fail`;\n } else if (checkErrors > 0) {\n level = \"problem\";\n reason = `The check found ${plural(checkErrors, \"error\")}`;\n } else if (counts.noTest > 0) {\n level = \"attention\";\n reason = `${counts.noTest} of ${total} checks have no test`;\n } else if (context.resultsMissing && total > 0) {\n // A missing results file is a missing measurement, not a product problem: a shared (business) view shows it neutral.\n if (context.options.shared) {\n level = \"unknown\";\n reason = \"Test results are not measured\";\n } else {\n level = \"attention\";\n reason = \"No test results recorded\";\n }\n } else if (counts.stale > 0 || counts.notRun > 0) {\n level = \"attention\";\n reason = \"Tests have not run since they changed\";\n } else if (recent > 0) {\n level = \"attention\";\n reason = `${plural(recent, \"error\")} in the last hour`;\n } else if (total > 0) {\n level = \"good\";\n reason = `All ${total} checks pass`;\n } else {\n level = \"unknown\";\n reason = \"No checks written yet\";\n }\n\n return { level, reason, criteria: counts, errors };\n}\n\nfunction featureHealth(context: Context, feature: WrittenFeature): ProductHealth {\n const criteria = feature.flows.flatMap(\n (flow) => context.snapshot.collected.flows[flow.ref]?.criteria ?? [],\n );\n\n return healthOf(\n context,\n criteria,\n context.featureErrors.get(feature.id) ?? 0,\n context.captured?.features.get(feature.id),\n );\n}\n\nfunction flowHealthOf(context: Context, flow: WrittenFlow): ProductHealth {\n return healthOf(\n context,\n context.snapshot.collected.flows[flow.ref]?.criteria ?? [],\n context.flowErrors.get(flow.ref) ?? 0,\n context.captured?.flows.get(flow.ref),\n );\n}\n\nfunction findFeature(snapshot: GrimoireSnapshot, id: string | undefined): WrittenFeature {\n if (id === undefined || id === \"\") throw new GrimoirePanelError(400, 'Missing \"feature\".');\n\n const feature = snapshot.written.features.find((item) => item.id === id);\n\n if (feature === undefined || feature.readme === null) {\n throw new GrimoirePanelError(404, `No feature \"${id}\" is written in grimoire/features.`);\n }\n\n return feature;\n}\n\nfunction audienceOf(feature: WrittenFeature): string[] {\n const listed = (feature.readme?.audience ?? []).map((item) => item.value);\n\n if (listed.length > 0) return listed;\n\n return [...new Set(feature.flows.map((flow) => flow.who.value))];\n}\n\n/** The health strip numbers of a feature card. */\nfunction stripOf(context: Context, feature: WrittenFeature, health: ProductHealth): ProductStrip {\n const bookmaps = feature.flows.flatMap((flow) => {\n const found = context.snapshot.collected.flows[flow.ref];\n\n return found === undefined ? [] : [found];\n });\n const places = appearancesOf(context.snapshot, bookmaps);\n\n return {\n flows: {\n total: feature.flows.length,\n shipped: feature.flows.filter((flow) => flow.status.value === \"shipped\").length,\n },\n criteria: {\n total: health.criteria.total,\n proven: health.criteria.pass,\n failing: health.criteria.fail,\n // Nothing is measured when no result was recorded, or none of the criteria has a result yet.\n measured:\n !context.resultsMissing &&\n (health.criteria.total === 0 ||\n health.criteria.pass + health.criteria.fail + health.criteria.stale > 0 ||\n health.criteria.notRun === 0),\n },\n screenshots: {\n places: places.length,\n present: places.filter((place) => place.screenshots.length > 0).length,\n },\n findings: context.featureFindings.get(feature.id) ?? { errors: 0, warnings: 0 },\n };\n}\n\nconst DAY = /^\\d{4}-\\d{2}-\\d{2}$/;\n\n/** Only a real `YYYY-MM-DD` day counts as a change date; a bad `updated:` value is ignored here (check reports it). */\nconst isDay = (value: string): boolean =>\n DAY.test(value) && !Number.isNaN(new Date(`${value}T00:00:00Z`).getTime());\n\n/** Compares release names by their numeric parts, so `5.9.0` comes before `5.10.0`. */\nexport function compareReleases(left: string, right: string): number {\n const parts = (value: string) => value.split(/[.\\-+]/).map((part) => part);\n const a = parts(left);\n const b = parts(right);\n\n for (let index = 0; index < Math.max(a.length, b.length); index += 1) {\n const x = a[index] ?? \"0\";\n const y = b[index] ?? \"0\";\n const numeric = /^\\d+$/.test(x) && /^\\d+$/.test(y);\n const diff = numeric ? Number(x) - Number(y) : x < y ? -1 : x > y ? 1 : 0;\n\n if (diff !== 0) return diff;\n }\n\n return 0;\n}\n\nfunction card(context: Context, feature: WrittenFeature): ProductFeatureCard {\n const readme = feature.readme;\n\n if (readme === null) throw new Error(\"A feature card needs a README.\");\n\n const health = featureHealth(context, feature);\n const entries = feature.changelog?.entries ?? [];\n const dates = [\n readme.updated.value,\n ...entries.flatMap((entry) => (entry.date === null ? [] : [entry.date])),\n ].filter(isDay);\n\n return {\n changedAt: dates.reduce((newest, date) => (date > newest ? date : newest), \"\"),\n changedIn: [\n ...new Set(entries.flatMap((entry) => (entry.release === null ? [] : [entry.release]))),\n ],\n unreleased: entries.some((entry) => entry.release === null),\n id: feature.id,\n title: readme.title.value,\n summary: readme.summary,\n audience: audienceOf(feature),\n apps: readme.apps.map((app) => app.value),\n status: readme.status.value,\n version: readme.version.value,\n flows: feature.flows.length,\n health,\n strip: stripOf(context, feature, health),\n };\n}\n\n/** `GET /product`: the feature map. */\nexport function productMap(\n snapshot: GrimoireSnapshot,\n options: ProductMapOptions,\n): ProductMapAnswer {\n const context = contextOf(snapshot, options);\n\n return {\n builtAt: snapshot.book.manifest.builtAt,\n features: snapshot.written.features\n .filter((feature) => feature.readme !== null)\n .map((feature) => card(context, feature)),\n apps: snapshot.written.apps.map((app) => ({\n id: app.id.value,\n type: app.type.value,\n title: app.heading?.value ?? null,\n })),\n releases: snapshot.written.releases\n .map((item) => ({ release: item.release.value, date: item.date.value }))\n .sort(\n (left, right) =>\n left.date.localeCompare(right.date) || compareReleases(left.release, right.release),\n ),\n developer: !options.shared,\n host: snapshot.host ?? null,\n };\n}\n\nconst slugOf = (text: string): string =>\n text\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n\nfunction screenshotsOf(items: readonly WrittenScreenshot[]): ProductScreenshot[] {\n return items.flatMap((item) => (item.path === null ? [] : [{ src: item.path, alt: item.alt }]));\n}\n\n/** Where the flows are shown, with the screenshots of the block (else of the page). */\nfunction appearancesOf(\n snapshot: GrimoireSnapshot,\n bookmaps: readonly FlowBookmap[],\n): ProductAppearance[] {\n const seen = new Set<string>();\n const list: ProductAppearance[] = [];\n const apps = new Map<string, WrittenApp>(snapshot.written.apps.map((app) => [app.id.value, app]));\n\n for (const bookmap of bookmaps) {\n for (const shown of bookmap.shownBy) {\n const key = `${shown.app}|${shown.type}|${shown.id}|${shown.block}|${bookmap.ref}`;\n\n if (seen.has(key)) continue;\n\n seen.add(key);\n\n const app = apps.get(shown.app);\n let title: string | null = null;\n let route: string | null = null;\n let screenshots: ProductScreenshot[] = [];\n\n if (app !== undefined && shown.type === \"layout\") {\n title = app.layouts.find((layout) => layout.id === shown.id)?.heading?.value ?? null;\n } else if (app !== undefined) {\n const page = [...app.pages, ...app.screens].find((item) => item.id === shown.id);\n\n if (page !== undefined) {\n title = page.heading?.value ?? null;\n route = page.route?.value ?? page.screen?.value ?? null;\n\n const block =\n page.blockFiles.find((item) => item.id === slugOf(shown.block)) ??\n page.blockFiles.find((item) => item.flow?.value === bookmap.ref);\n\n screenshots = screenshotsOf(block?.screenshots ?? []);\n\n if (screenshots.length === 0) screenshots = screenshotsOf(page.screenshots);\n }\n }\n\n list.push({\n app: shown.app,\n type: shown.type,\n id: shown.id,\n title,\n route,\n block: shown.block,\n flow: bookmap.ref,\n screenshots,\n });\n }\n }\n\n return list;\n}\n\nfunction releasesOf(snapshot: GrimoireSnapshot, feature: WrittenFeature): ProductRelease[] {\n const dates = new Map(\n snapshot.written.releases.map((item) => [item.release.value, item.date.value]),\n );\n const entries = feature.changelog?.entries ?? [];\n // Unreleased entries first, then the stamped ones in file order (newest first).\n const ordered = [\n ...entries.filter((entry) => entry.release === null),\n ...entries.filter((entry) => entry.release !== null),\n ];\n const groups = new Map<string, ProductRelease>();\n\n for (const entry of ordered) {\n const key = `${entry.version.value}|${entry.release ?? \"\"}`;\n let group = groups.get(key);\n\n if (group === undefined) {\n group = {\n version: entry.version.value,\n release: entry.release,\n date: entry.date ?? (entry.release === null ? null : (dates.get(entry.release) ?? null)),\n changes: [],\n };\n groups.set(key, group);\n }\n\n group.changes.push({ word: entry.word, flow: entry.flow, text: entry.text });\n }\n\n return [...groups.values()];\n}\n\nfunction plannedOf(snapshot: GrimoireSnapshot, feature: string): ProductPlannedItem[] {\n return snapshot.collected.tasksIndex.open\n .filter((task) => task.feature === feature)\n .map((task) => ({\n id: task.id,\n title: task.title,\n type: task.type,\n status: task.status,\n flow: task.flow === null ? null : task.flow.replace(`${feature}/`, \"\"),\n }));\n}\n\nfunction flowCard(context: Context, flow: WrittenFlow): ProductFlowCard {\n return {\n id: flow.id.value,\n ref: flow.ref,\n title: flow.heading?.value ?? flow.id.value,\n summary: flow.summary,\n who: flow.who.value,\n status: flow.status.value,\n health: flowHealthOf(context, flow),\n };\n}\n\n/** `GET /product/features/:feature`. */\nexport function productFeature(\n snapshot: GrimoireSnapshot,\n id: string | undefined,\n options: ProductMapOptions,\n): ProductFeatureAnswer {\n const feature = findFeature(snapshot, id);\n const readme = feature.readme;\n\n if (readme === null) throw new Error(\"unreachable\");\n\n const context = contextOf(snapshot, options);\n const bookmaps = feature.flows.flatMap((flow) => {\n const bookmap = snapshot.collected.flows[flow.ref];\n\n return bookmap === undefined ? [] : [bookmap];\n });\n const own = snapshot.collected.features[feature.id];\n const unexpected = context.report.findings.filter(\n (finding) => (finding.subject.feature ?? finding.subject.flow?.split(\"/\")[0]) === feature.id,\n );\n const unexpectedNow = unexpected.filter((finding) => !finding.expected);\n const errors = unexpectedNow.filter((finding) => finding.severity === \"error\").length;\n\n return {\n feature: {\n id: feature.id,\n title: readme.title.value,\n summary: readme.summary,\n why: readme.why,\n audience: audienceOf(feature),\n apps: readme.apps.map((app) => app.value),\n status: readme.status.value,\n version: readme.version.value,\n updated: readme.updated.value,\n origin: readme.origin?.value ?? null,\n },\n flows: flowOrder(feature).map((flow) => flowCard(context, flow)),\n appearances: appearancesOf(snapshot, bookmaps),\n releases: releasesOf(snapshot, feature),\n planned: plannedOf(snapshot, feature.id),\n health: featureHealth(context, feature),\n host: snapshot.host ?? null,\n developer: options.shared\n ? null\n : {\n folders: readme.folders.map((folder) => folder.value),\n routes: (own?.routes ?? []).map(({ file: _file, ...route }) => route),\n files: own?.own.length ?? 0,\n findings: {\n errors,\n warnings: unexpectedNow.length - errors,\n expected: unexpected.length - unexpectedNow.length,\n },\n },\n };\n}\n\nconst STEP_WORDS: Record<WrittenStep[\"type\"], (target: string) => string> = {\n page: (target) => `Open ${target}`,\n route: () => \"The server takes the request\",\n mail: (target) => `An email \"${target}\" is sent`,\n notification: (target) => `A notification \"${target}\" is sent`,\n job: (target) => `The job \"${target}\" runs in the background`,\n event: (target) => `The event \"${target}\" happens`,\n \"outside service\": (target) => `The outside service \"${target}\" is used`,\n affects: (target) => `This also affects ${target}`,\n};\n\nfunction storyOf(flow: WrittenFlow): ProductStoryStep[] {\n if (flow.story.length > 0) {\n return flow.story.map((step) => ({\n index: step.index,\n text: step.text,\n screenshots: screenshotsOf(step.screenshots),\n derived: false,\n }));\n }\n\n return flow.steps.map((step) => ({\n index: step.index,\n text: step.note ?? STEP_WORDS[step.type](step.target),\n screenshots: [],\n derived: true,\n }));\n}\n\nconst DOES_NOT_APPLY = /^does not apply\\b[:\\s—-]*/i;\n\n/** `GET /product/flows/:feature/:flow`. */\nexport function productFlow(\n snapshot: GrimoireSnapshot,\n featureId: string | undefined,\n flowId: string | undefined,\n options: ProductMapOptions,\n): ProductFlowAnswer {\n const feature = findFeature(snapshot, featureId);\n const flow = feature.flows.find((item) => item.id.value === flowId);\n\n if (flow === undefined) {\n throw new GrimoirePanelError(404, `No flow \"${flowId ?? \"\"}\" in feature \"${feature.id}\".`);\n }\n\n const context = contextOf(snapshot, options);\n const bookmap = snapshot.collected.flows[flow.ref];\n const { previous, next } = neighboursOf(feature, flow.id.value);\n\n return {\n flow: {\n ref: flow.ref,\n feature: feature.id,\n featureTitle: feature.readme?.title.value ?? feature.id,\n title: flow.heading?.value ?? flow.id.value,\n summary: flow.summary,\n who: flow.who.value,\n status: flow.status.value,\n since: flow.since.value,\n },\n story: storyOf(flow),\n proof: (bookmap?.criteria ?? []).map((criterion) => ({\n id: criterion.id,\n text: criterion.text,\n status: criterion.status,\n tests: options.shared ? null : criterion.tests,\n })),\n cases: flow.cases.map((item) => {\n const answer = item.doesNotApply\n ? item.answer.replace(DOES_NOT_APPLY, \"\").trim()\n : item.answer;\n\n return {\n question: item.question,\n answer: answer === \"\" ? \"Does not apply\" : answer,\n handled: !item.doesNotApply,\n criteria: item.criteria,\n };\n }),\n appearances: bookmap === undefined ? [] : appearancesOf(snapshot, [bookmap]),\n previous,\n next,\n health: flowHealthOf(context, flow),\n developer: options.shared\n ? null\n : {\n steps: (bookmap?.steps ?? []).map((step) => compactStep(snapshot, feature, step, flow)),\n },\n host: snapshot.host ?? null,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAyDA,MAAM,kBAAkB;AAiBxB,SAAS,SAAS,KAA8B,KAAa,OAAkC;CAC7F,MAAM,QAAQ,IAAI,IAAI,GAAG;CAEzB,IAAI,IAAI,KAAK;EACX,QAAQ,OAAO,SAAS,KAAK,MAAM;EACnC,UAAU,KAAK,IAAI,OAAO,YAAY,GAAG,MAAM,QAAQ;CACzD,CAAC;AACH;;AAGA,SAAS,cACP,UACA,QACA,KACkC;CAClC,MAAM,2BAAW,IAAI,IAAwB;CAC7C,MAAM,wBAAQ,IAAI,IAAwB;CAC1C,MAAM,SAAS,SAAS,KAAK,MAAM,UAAU,CAAC;CAE9C,KAAK,MAAM,SAAS,QAAQ;EAC1B,IAAI,MAAM,UAAU,QAAQ,MAAM,WAAW,MAAM,iBAAiB;EAEpE,MAAM,OAAO,mBAAmB,MAAM,KAAK;EAE3C,KAAK,MAAM,SAAS,QAAQ;GAC1B,IAAI,mBAAmB,MAAM,IAAI,MAAM,MAAM;GAE7C,MAAM,OAAO,MAAM,eAAe,MAAM;GACxC,MAAM,QAAQ,SAAS,OAAO,OAAQ,SAAS,UAAU,MAAM,KAAK,EAAE,SAAS;GAE/E,IAAI,UAAU,MAAM,SAAS,UAAU,OAAO,KAAK;EACrD;EAEA,KAAK,MAAM,WAAW,SAAS,QAAQ,UACrC,KAAK,MAAM,QAAQ,QAAQ,OASzB,IARY,KAAK,MAAM,MACpB,SACE,KAAK,SAAS,WACb,KAAK,UAAU,QACf,mBAAmB,KAAK,MAAM,IAAI,MAAM,QACzC,KAAK,SAAS,UAAU,mBAAmB,KAAK,MAAM,MAAM,IAG3D,GAAG,SAAS,OAAO,KAAK,KAAK,KAAK;CAG9C;CAEA,OAAO;EAAE;EAAU;CAAM;AAC3B;;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OAAO,QAAQ,gBAAgB,EAAE,CAAC,CAAC,KAAK,IAC7C,KAAK;GAET,OAAO;IACL,UAAU,KAAK;IACf,QAAQ,WAAW,KAAK,mBAAmB;IAC3C,SAAS,CAAC,KAAK;IACf,UAAU,KAAK;GACjB;EACF,CAAC;EACD,aAAa,YAAY,SAAY,CAAC,IAAI,cAAc,UAAU,CAAC,OAAO,CAAC;EAC3E;EACA;EACA,QAAQ,aAAa,SAAS,IAAI;EAClC,WAAW,QAAQ,SACf,OACA,EACE,QAAQ,SAAS,SAAS,CAAC,EAAC,CAAE,KAAK,SAAS,YAAY,UAAU,SAAS,MAAM,IAAI,CAAC,EACxF;EACJ,MAAM,SAAS,QAAQ;CACzB;AACF"}
@@ -9,6 +9,38 @@ export type ExportGrimoireSiteOptions = {
9
9
  adapter?: BookAdapter | (() => Promise<BookAdapter>);
10
10
  /** An already opened snapshot; skips opening one. */
11
11
  snapshot?: GrimoireSnapshot;
12
+ /**
13
+ * Export the business view only: the share-safe Product map (no file paths, test
14
+ * names or export names, no per-file answers, no check or search of code). The
15
+ * page opens on the Product map.
16
+ */
17
+ product?: boolean;
18
+ /** Write the page even when the folder already holds one built from the same book. Default `false`. */
19
+ force?: boolean;
20
+ };
21
+ /** What `exportGrimoireSite()` did. */
22
+ export type GrimoireSiteExport = {
23
+ /** The output folder, project-relative. */
24
+ outDir: string;
25
+ /** `true` when the folder already held a page built from the same book and nothing was written. */
26
+ upToDate: boolean;
27
+ };
28
+ /** One entry of the exported search list. `text` is written content (a flow's summary, story, cases and criteria) the search also reads. */
29
+ type SearchItem = {
30
+ type: string;
31
+ id: string;
32
+ detail: string | null;
33
+ text?: string;
34
+ };
35
+ /**
36
+ * The business-only data of the static export: the share-safe Product map, its feature
37
+ * and flow pages, and nothing else. No file paths, test names, export names, check
38
+ * findings or per-file answers; the search list is empty.
39
+ */
40
+ export declare function buildProductSiteData(snapshot: GrimoireSnapshot): {
41
+ routes: Record<string, unknown>;
42
+ files: {};
43
+ search: SearchItem[];
12
44
  };
13
45
  /**
14
46
  * Write the tab as a static folder for people without the app running.
@@ -18,9 +50,19 @@ export type ExportGrimoireSiteOptions = {
18
50
  * page and use `#grimoire/...` links; the answers that need the running app
19
51
  * (impact of a file) say so in place.
20
52
  *
53
+ * With `product: true` the page is the business export: the share-safe
54
+ * Product map only, no file paths, test names or per-file answers.
55
+ *
56
+ * The page carries a freshness stamp (the files of the book, the written
57
+ * folders and the test results). When the folder already holds a page with
58
+ * the same stamp and the same mode, nothing is rebuilt or written (`force`
59
+ * writes it anyway).
60
+ *
21
61
  * @param root Absolute project root.
22
- * @returns The output folder, project-relative.
23
62
  */
63
+ export declare function exportGrimoireSiteDetailed(root: string, options?: ExportGrimoireSiteOptions): Promise<GrimoireSiteExport>;
64
+ /** `exportGrimoireSiteDetailed()` that returns only the output folder, project-relative. */
24
65
  export declare function exportGrimoireSite(root: string, options?: ExportGrimoireSiteOptions): Promise<string>;
25
66
  //#endregion
67
+ export {};
26
68
  //# sourceMappingURL=site.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"site.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/devtools/site.ts"],"mappings":";;;;YAgBY;;EAEV;;EAEA,UAAU,qBAAqB,QAAQ;;EAEvC,WAAW;;;;;;;;;;;;;wBAgMS,mBACpB,cACA,UAAS,4BACR"}
1
+ {"version":3,"file":"site.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/devtools/site.ts"],"mappings":";;;;YAoBY;;EAEV;;EAEA,UAAU,qBAAqB,QAAQ;;EAEvC,WAAW;;;;;;EAMX;;EAEA;;;YAIU;;EAEV;;EAEA;;;KAOG;EAAe;EAAc;EAAY;EAAuB;;;;;;;wBAuJrD,qBAAqB,UAAU;;;EAmBH,QAAA;;;;;;;;;;;;;;;;;;;;wBAsPtB,2BACpB,cACA,UAAS,4BACR,QAAQ;;wBAiDW,mBACpB,cACA,UAAS,4BACR"}