@warlock.js/grimoire 5.57.0 → 5.58.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/CHANGELOG.md +20 -0
- package/esm/book/build.d.mts.map +1 -1
- package/esm/book/build.mjs +2 -1
- package/esm/book/build.mjs.map +1 -1
- package/esm/book/render.mjs +10 -0
- package/esm/book/render.mjs.map +1 -1
- package/esm/bookmap/build.d.mts.map +1 -1
- package/esm/bookmap/build.mjs +2 -2
- package/esm/bookmap/build.mjs.map +1 -1
- package/esm/bookmap/steps.mjs +53 -38
- package/esm/bookmap/steps.mjs.map +1 -1
- package/esm/check/check-grimoire.d.mts.map +1 -1
- package/esm/check/check-grimoire.mjs +4 -1
- package/esm/check/check-grimoire.mjs.map +1 -1
- package/esm/check/rules/criteria.mjs +21 -2
- package/esm/check/rules/criteria.mjs.map +1 -1
- package/esm/check/rules/screenshots.mjs +57 -0
- package/esm/check/rules/screenshots.mjs.map +1 -0
- package/esm/codes/codes.d.mts +12 -0
- package/esm/codes/codes.d.mts.map +1 -1
- package/esm/codes/codes.mjs +6 -0
- package/esm/codes/codes.mjs.map +1 -1
- package/esm/contracts/adapter.d.mts +6 -0
- package/esm/contracts/adapter.d.mts.map +1 -1
- package/esm/contracts/book.d.mts +2 -0
- package/esm/contracts/book.d.mts.map +1 -1
- package/esm/contracts/book.mjs.map +1 -1
- package/esm/contracts/bookmap.d.mts +19 -1
- package/esm/contracts/bookmap.d.mts.map +1 -1
- package/esm/contracts/snapshot.d.mts +11 -0
- package/esm/contracts/snapshot.d.mts.map +1 -1
- package/esm/contracts/test-results.d.mts +34 -0
- package/esm/contracts/test-results.d.mts.map +1 -1
- package/esm/contracts/written.d.mts +44 -0
- package/esm/contracts/written.d.mts.map +1 -1
- package/esm/contracts/written.mjs.map +1 -1
- package/esm/devtools/data.mjs +94 -3
- package/esm/devtools/data.mjs.map +1 -1
- package/esm/devtools/index.d.mts +26 -0
- package/esm/devtools/index.d.mts.map +1 -1
- package/esm/devtools/index.mjs +88 -5
- package/esm/devtools/index.mjs.map +1 -1
- package/esm/devtools/product-map.d.mts +14 -0
- package/esm/devtools/product-map.d.mts.map +1 -0
- package/esm/devtools/product-map.mjs +385 -0
- package/esm/devtools/product-map.mjs.map +1 -0
- package/esm/devtools/site.d.mts.map +1 -1
- package/esm/devtools/site.mjs +85 -13
- package/esm/devtools/site.mjs.map +1 -1
- package/esm/devtools/snapshot-source.mjs +10 -6
- package/esm/devtools/snapshot-source.mjs.map +1 -1
- package/esm/graph/index.d.mts +10 -1
- package/esm/graph/index.d.mts.map +1 -1
- package/esm/graph/index.mjs +3 -2
- package/esm/graph/index.mjs.map +1 -1
- package/esm/index.d.mts +4 -4
- package/esm/paths/index.d.mts +2 -0
- package/esm/paths/index.d.mts.map +1 -1
- package/esm/paths/index.mjs +3 -1
- package/esm/paths/index.mjs.map +1 -1
- package/esm/scry/compact.mjs +169 -0
- package/esm/scry/compact.mjs.map +1 -0
- package/esm/scry/format.d.mts.map +1 -1
- package/esm/scry/format.mjs +7 -1
- package/esm/scry/format.mjs.map +1 -1
- package/esm/scry/query.d.mts.map +1 -1
- package/esm/scry/query.mjs +12 -1
- package/esm/scry/query.mjs.map +1 -1
- package/esm/test-results/index.d.mts +7 -2
- package/esm/test-results/index.d.mts.map +1 -1
- package/esm/test-results/index.mjs +79 -12
- package/esm/test-results/index.mjs.map +1 -1
- package/esm/vitest/index.d.mts +6 -0
- package/esm/vitest/index.d.mts.map +1 -1
- package/esm/vitest/index.mjs +22 -6
- package/esm/vitest/index.mjs.map +1 -1
- package/esm/warlock/adapter.d.mts.map +1 -1
- package/esm/warlock/adapter.mjs +6 -2
- package/esm/warlock/adapter.mjs.map +1 -1
- package/esm/warlock/mcp-tools.mjs +48 -12
- package/esm/warlock/mcp-tools.mjs.map +1 -1
- package/esm/workspace/index.d.mts.map +1 -1
- package/esm/workspace/index.mjs +4 -2
- package/esm/workspace/index.mjs.map +1 -1
- package/esm/written/apps.mjs +4 -2
- package/esm/written/apps.mjs.map +1 -1
- package/esm/written/features.mjs +119 -6
- package/esm/written/features.mjs.map +1 -1
- package/esm/written/markdown.mjs +66 -1
- package/esm/written/markdown.mjs.map +1 -1
- package/esm/written/parse-grimoire.d.mts.map +1 -1
- package/esm/written/parse-grimoire.mjs +1 -1
- package/esm/written/parse-grimoire.mjs.map +1 -1
- package/llms-full.txt +76 -3
- package/package.json +3 -3
- package/skills/backfill-a-grimoire/SKILL.md +5 -0
- package/skills/describe-an-app/SKILL.md +12 -0
- package/skills/record-a-change/SKILL.md +8 -0
- package/skills/use-the-grimoire/SKILL.md +14 -1
- package/skills/write-a-feature/SKILL.md +37 -2
- package/ui/grimoire-static.js +4 -0
- package/ui/grimoire-view.js +1016 -178
- package/ui/grimoire.css +427 -2
- package/ui/product-map.css +636 -0
- package/ui/product-map.js +817 -0
package/esm/devtools/index.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { apps, check, feature, features, file,
|
|
1
|
+
import { apps, check, checkGroups, checkPage, feature, features, file, flowAnswer, graphOfFeature, graphOfFile, graphOfModules, graphOfPage, impact, page, release, releases, route, search, stepFiles, summary, tasks } from "./data.mjs";
|
|
2
|
+
import { productFeature, productFlow, productMap } from "./product-map.mjs";
|
|
2
3
|
import { createSnapshotSource } from "./snapshot-source.mjs";
|
|
3
4
|
import { exportGrimoireSite } from "./site.mjs";
|
|
5
|
+
import path from "node:path";
|
|
4
6
|
|
|
5
7
|
//#region ../../packages/grimoire/src/devtools/index.ts
|
|
6
8
|
/** The first value of a query parameter. */
|
|
@@ -14,16 +16,70 @@ async function grimoireDevtoolsPanel(context) {
|
|
|
14
16
|
write: context.mode !== "production",
|
|
15
17
|
mode: context.mode ?? "development",
|
|
16
18
|
...context.adapter === void 0 ? {} : { adapter: context.adapter },
|
|
17
|
-
...context.ttlMs === void 0 ? {} : { ttlMs: context.ttlMs }
|
|
19
|
+
...context.ttlMs === void 0 ? {} : { ttlMs: context.ttlMs },
|
|
20
|
+
...context.testResultsFile === void 0 ? {} : { testResultsFile: context.testResultsFile }
|
|
18
21
|
});
|
|
19
22
|
if (context.mode === "production") source.warm();
|
|
20
23
|
const answer = (read) => async (request) => read(await source.get(), request);
|
|
24
|
+
/** The product map answers: the shared flag from the request, the errors fetched per request. */
|
|
25
|
+
const product = (read) => async (request) => {
|
|
26
|
+
const snapshot = await source.get();
|
|
27
|
+
let errors = null;
|
|
28
|
+
try {
|
|
29
|
+
errors = await context.errors?.() ?? null;
|
|
30
|
+
} catch {
|
|
31
|
+
errors = null;
|
|
32
|
+
}
|
|
33
|
+
return read(snapshot, request, {
|
|
34
|
+
shared: request.shared === true,
|
|
35
|
+
errors
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
const number = (value) => {
|
|
39
|
+
if (value === void 0 || value === "") return void 0;
|
|
40
|
+
const parsed = Number(value);
|
|
41
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
42
|
+
};
|
|
43
|
+
const checkFilter = (query) => {
|
|
44
|
+
const filter = {};
|
|
45
|
+
const code = one(query, "code");
|
|
46
|
+
const feature = one(query, "feature");
|
|
47
|
+
const flow = one(query, "flow");
|
|
48
|
+
const severity = one(query, "severity");
|
|
49
|
+
const state = one(query, "state");
|
|
50
|
+
const offset = number(one(query, "offset"));
|
|
51
|
+
const limit = number(one(query, "limit"));
|
|
52
|
+
let any = false;
|
|
53
|
+
if (code) filter.code = code, any = true;
|
|
54
|
+
if (feature) filter.feature = feature, any = true;
|
|
55
|
+
if (flow) filter.flow = flow, any = true;
|
|
56
|
+
if (severity === "error" || severity === "warning") filter.severity = severity, any = true;
|
|
57
|
+
if (state === "expected" || state === "unexpected") filter.state = state, any = true;
|
|
58
|
+
if (offset !== void 0) filter.offset = offset, any = true;
|
|
59
|
+
if (limit !== void 0) filter.limit = limit, any = true;
|
|
60
|
+
return any ? filter : null;
|
|
61
|
+
};
|
|
21
62
|
return {
|
|
22
63
|
id: "grimoire",
|
|
23
64
|
title: "Grimoire",
|
|
24
65
|
production: true,
|
|
25
66
|
view: new URL("../../ui/grimoire-view.js", import.meta.url),
|
|
26
|
-
assets: {
|
|
67
|
+
assets: {
|
|
68
|
+
"grimoire.css": new URL("../../ui/grimoire.css", import.meta.url),
|
|
69
|
+
"product-map.js": new URL("../../ui/product-map.js", import.meta.url),
|
|
70
|
+
"product-map.css": new URL("../../ui/product-map.css", import.meta.url)
|
|
71
|
+
},
|
|
72
|
+
files: { dir: path.join(context.root, "grimoire", "screenshots") },
|
|
73
|
+
share: {
|
|
74
|
+
view: new URL("../../ui/product-map.js", import.meta.url),
|
|
75
|
+
routes: [
|
|
76
|
+
"/product",
|
|
77
|
+
"/product/features/:feature",
|
|
78
|
+
"/product/flows/:feature/:flow"
|
|
79
|
+
],
|
|
80
|
+
assets: ["product-map.css"],
|
|
81
|
+
files: true
|
|
82
|
+
},
|
|
27
83
|
routes: [
|
|
28
84
|
{
|
|
29
85
|
path: "/summary",
|
|
@@ -58,7 +114,27 @@ async function grimoireDevtoolsPanel(context) {
|
|
|
58
114
|
},
|
|
59
115
|
{
|
|
60
116
|
path: "/flows/:feature/:flow",
|
|
61
|
-
handler: answer((snapshot, { params }) =>
|
|
117
|
+
handler: answer((snapshot, { params }) => flowAnswer(snapshot, params.feature, params.flow))
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
path: "/flows/:feature/:flow/steps/:index/files",
|
|
121
|
+
handler: answer((snapshot, { params, query }) => stepFiles(snapshot, params.feature, params.flow, params.index, {
|
|
122
|
+
set: one(query, "set"),
|
|
123
|
+
offset: one(query, "offset"),
|
|
124
|
+
limit: one(query, "limit")
|
|
125
|
+
}))
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
path: "/product",
|
|
129
|
+
handler: product((snapshot, _request, options) => productMap(snapshot, options))
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
path: "/product/features/:feature",
|
|
133
|
+
handler: product((snapshot, { params }, options) => productFeature(snapshot, params.feature, options))
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
path: "/product/flows/:feature/:flow",
|
|
137
|
+
handler: product((snapshot, { params }, options) => productFlow(snapshot, params.feature, params.flow, options))
|
|
62
138
|
},
|
|
63
139
|
{
|
|
64
140
|
path: "/apps",
|
|
@@ -82,7 +158,14 @@ async function grimoireDevtoolsPanel(context) {
|
|
|
82
158
|
},
|
|
83
159
|
{
|
|
84
160
|
path: "/check",
|
|
85
|
-
handler: answer((snapshot) =>
|
|
161
|
+
handler: answer((snapshot, { query }) => {
|
|
162
|
+
const filter = checkFilter(query);
|
|
163
|
+
return filter === null ? check(snapshot) : checkPage(snapshot, filter);
|
|
164
|
+
})
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
path: "/check/groups",
|
|
168
|
+
handler: answer((snapshot) => checkGroups(snapshot))
|
|
86
169
|
},
|
|
87
170
|
{
|
|
88
171
|
path: "/graph/file",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["data.summary","data.search","data.file","data.impact","data.route","data.features","data.feature","data.flow","data.apps","data.page","data.tasks","data.releases","data.release","data.check","data.graphOfFile","data.graphOfFeature","data.graphOfPage","data.graphOfModules"],"sources":["../../../../../../../../packages/grimoire/src/devtools/index.ts"],"sourcesContent":["/**\n * `@warlock.js/grimoire/devtools`: the Grimoire tab of the devtools\n * dashboard. An app enables it in `src/config/devtools.ts`:\n *\n * ```ts\n * panels: [\"@warlock.js/grimoire/devtools\"]\n * ```\n *\n * The default export is a panel factory (devtools' `DevtoolsPanelExport`),\n * typed structurally here so this entry needs no `@warlock.js/devtools`\n * import. The browser view lives in the package's `ui/` folder. Data routes\n * open the snapshot with `routes: \"cached\"` (never booting the app) and keep\n * the generated book up to date; agent-written files are only read.\n */\nimport type { BookAdapter } from \"../contracts/adapter\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\nimport * as data from \"./data\";\nimport { createSnapshotSource } from \"./snapshot-source\";\n\nexport { exportGrimoireSite } from \"./site\";\nexport type { ExportGrimoireSiteOptions } from \"./site\";\n\n/** The parts of devtools' `DevtoolsPanelRequest` the routes read. */\nexport type GrimoirePanelRequest = {\n params: Readonly<Record<string, string>>;\n query: Readonly<Record<string, string | readonly string[]>>;\n body: unknown;\n};\n\n/** Devtools' `DevtoolsPanel`, structurally. */\nexport type GrimoireDevtoolsPanel = {\n id: string;\n title: string;\n view: string | URL;\n routes?: readonly {\n method?: \"GET\" | \"POST\";\n path: string;\n handler: (request: GrimoirePanelRequest) => unknown;\n }[];\n assets?: Readonly<Record<string, string | URL>>;\n /** Safe for the production monitor: the tab only reads (see `GrimoirePanelContext.mode`). */\n production?: boolean;\n};\n\n/** What the panel factory takes: devtools passes `{ root, mode }`; the rest is for tests and custom setups. */\nexport type GrimoirePanelContext = {\n /** The app root. */\n root: string;\n /**\n * Where the dashboard runs. In `\"production\"` the tab writes no files:\n * it reads the book as it is on disk. Default: development.\n */\n mode?: \"development\" | \"production\";\n /** The adapter to open the book with. Default: the Warlock adapter, loaded on first request. */\n adapter?: BookAdapter | (() => Promise<BookAdapter>);\n /**\n * How long an opened snapshot is reused when the book did not change (ms).\n * Default in development: 2000, longer after a slow open; the old snapshot is served while a\n * background open refreshes it. Default in production: until the book changes.\n */\n ttlMs?: number;\n};\n\n/** The first value of a query parameter. */\nfunction one(query: GrimoirePanelRequest[\"query\"], name: string): string | undefined {\n const value = query[name];\n\n return Array.isArray(value) ? value[0] : (value as string | undefined);\n}\n\n/** Build the panel for the app at `root`. */\nexport async function grimoireDevtoolsPanel(\n context: GrimoirePanelContext,\n): Promise<GrimoireDevtoolsPanel> {\n // In development the tab keeps Warlock's generated files (book, book maps, indexes) up to date, so\n // the next open is incremental. In production it writes nothing. Agent-written files are only read,\n // and cached routes never boot the app.\n const source = createSnapshotSource(context.root, {\n write: context.mode !== \"production\",\n mode: context.mode ?? \"development\",\n ...(context.adapter === undefined ? {} : { adapter: context.adapter }),\n ...(context.ttlMs === undefined ? {} : { ttlMs: context.ttlMs }),\n });\n\n // In production, start opening the book now so the first tab view is fast.\n if (context.mode === \"production\") source.warm();\n\n const answer =\n <Answer>(read: (snapshot: GrimoireSnapshot, request: GrimoirePanelRequest) => Answer) =>\n async (request: GrimoirePanelRequest): Promise<Answer> =>\n read(await source.get(), request);\n\n return {\n id: \"grimoire\",\n title: \"Grimoire\",\n production: true,\n view: new URL(\"../../ui/grimoire-view.js\", import.meta.url),\n assets: { \"grimoire.css\": new URL(\"../../ui/grimoire.css\", import.meta.url) },\n routes: [\n { path: \"/summary\", handler: answer((snapshot) => data.summary(snapshot)) },\n {\n path: \"/search\",\n handler: answer((snapshot, { query }) => {\n const limit = Number(one(query, \"limit\"));\n\n return data.search(\n snapshot,\n one(query, \"q\") ?? \"\",\n Number.isFinite(limit) && limit > 0 ? limit : undefined,\n );\n }),\n },\n {\n path: \"/file\",\n handler: answer((snapshot, { query }) => data.file(snapshot, one(query, \"path\"))),\n },\n {\n path: \"/impact\",\n handler: answer((snapshot, { query }) => data.impact(snapshot, one(query, \"path\"))),\n },\n {\n path: \"/route\",\n handler: answer((snapshot, { query }) =>\n data.route(snapshot, one(query, \"method\"), one(query, \"path\")),\n ),\n },\n { path: \"/features\", handler: answer((snapshot) => data.features(snapshot)) },\n {\n path: \"/features/:feature\",\n handler: answer((snapshot, { params }) => data.feature(snapshot, params.feature)),\n },\n {\n path: \"/flows/:feature/:flow\",\n handler: answer((snapshot, { params }) => data.flow(snapshot, params.feature, params.flow)),\n },\n { path: \"/apps\", handler: answer((snapshot) => data.apps(snapshot)) },\n {\n path: \"/apps/:app/pages/:page\",\n handler: answer((snapshot, { params }) => data.page(snapshot, params.app, params.page)),\n },\n { path: \"/tasks\", handler: answer((snapshot) => data.tasks(snapshot)) },\n { path: \"/releases\", handler: answer((snapshot) => data.releases(snapshot)) },\n {\n path: \"/releases/:release\",\n handler: answer((snapshot, { params }) => data.release(snapshot, params.release)),\n },\n { path: \"/check\", handler: answer((snapshot) => data.check(snapshot)) },\n {\n path: \"/graph/file\",\n handler: answer((snapshot, { query }) => data.graphOfFile(snapshot, one(query, \"path\"))),\n },\n {\n path: \"/graph/feature/:feature\",\n handler: answer((snapshot, { params }) => data.graphOfFeature(snapshot, params.feature)),\n },\n {\n path: \"/graph/page\",\n handler: answer((snapshot, { query }) =>\n data.graphOfPage(snapshot, one(query, \"app\"), one(query, \"page\")),\n ),\n },\n { path: \"/graph/modules\", handler: answer((snapshot) => data.graphOfModules(snapshot)) },\n ],\n };\n}\n\nexport default grimoireDevtoolsPanel;\n"],"mappings":";;;;;;AAgEA,SAAS,IAAI,OAAsC,MAAkC;CACnF,MAAM,QAAQ,MAAM;CAEpB,OAAO,MAAM,QAAQ,KAAK,IAAI,MAAM,KAAM;AAC5C;;AAGA,eAAsB,sBACpB,SACgC;CAIhC,MAAM,SAAS,qBAAqB,QAAQ,MAAM;EAChD,OAAO,QAAQ,SAAS;EACxB,MAAM,QAAQ,QAAQ;EACtB,GAAI,QAAQ,YAAY,SAAY,CAAC,IAAI,EAAE,SAAS,QAAQ,QAAQ;EACpE,GAAI,QAAQ,UAAU,SAAY,CAAC,IAAI,EAAE,OAAO,QAAQ,MAAM;CAChE,CAAC;CAGD,IAAI,QAAQ,SAAS,cAAc,OAAO,KAAK;CAE/C,MAAM,UACK,SACT,OAAO,YACL,KAAK,MAAM,OAAO,IAAI,GAAG,OAAO;CAEpC,OAAO;EACL,IAAI;EACJ,OAAO;EACP,YAAY;EACZ,MAAM,IAAI,IAAI,6BAA6B,YAAY,GAAG;EAC1D,QAAQ,EAAE,gBAAgB,IAAI,IAAI,yBAAyB,YAAY,GAAG,EAAE;EAC5E,QAAQ;GACN;IAAE,MAAM;IAAY,SAAS,QAAQ,aAAaA,QAAa,QAAQ,CAAC;GAAE;GAC1E;IACE,MAAM;IACN,SAAS,QAAQ,UAAU,EAAE,YAAY;KACvC,MAAM,QAAQ,OAAO,IAAI,OAAO,OAAO,CAAC;KAExC,OAAOC,OACL,UACA,IAA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,MAAM,CAAC,CAAC;GACzF;GACA;IACE,MAAM;IACN,SAAS,QAAQ,UAAU,EAAE,aAAaC,eAAoB,UAAU,OAAO,OAAO,CAAC;GACzF;GACA;IACE,MAAM;IACN,SAAS,QAAQ,UAAU,EAAE,YAC3BC,YAAiB,UAAU,IAAI,OAAO,KAAK,GAAG,IAAI,OAAO,MAAM,CAAC,CAClE;GACF;GACA;IAAE,MAAM;IAAkB,SAAS,QAAQ,aAAaC,eAAoB,QAAQ,CAAC;GAAE;EACzF;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["data.summary","data.search","data.file","data.impact","data.route","data.features","data.feature","data.flowAnswer","data.stepFiles","data.apps","data.page","data.tasks","data.releases","data.release","data.check","data.checkPage","data.checkGroups","data.graphOfFile","data.graphOfFeature","data.graphOfPage","data.graphOfModules"],"sources":["../../../../../../../../packages/grimoire/src/devtools/index.ts"],"sourcesContent":["/**\n * `@warlock.js/grimoire/devtools`: the Grimoire tab of the devtools\n * dashboard. An app enables it in `src/config/devtools.ts`:\n *\n * ```ts\n * panels: [\"@warlock.js/grimoire/devtools\"]\n * ```\n *\n * The default export is a panel factory (devtools' `DevtoolsPanelExport`),\n * typed structurally here so this entry needs no `@warlock.js/devtools`\n * import. The browser view lives in the package's `ui/` folder. Data routes\n * open the snapshot with `routes: \"cached\"` (never booting the app) and keep\n * the generated book up to date; agent-written files are only read.\n */\nimport type { BookAdapter } from \"../contracts/adapter\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\nimport path from \"node:path\";\nimport type { GrimoireCheckFilter } from \"./answers\";\nimport * as data from \"./data\";\nimport { productFeature, productFlow, productMap, type ProductErrorSummary } from \"./product-map\";\nimport { createSnapshotSource } from \"./snapshot-source\";\n\nexport { exportGrimoireSite } from \"./site\";\nexport type { ExportGrimoireSiteOptions } from \"./site\";\n\n/** The parts of devtools' `DevtoolsPanelRequest` the routes read. */\nexport type GrimoirePanelRequest = {\n params: Readonly<Record<string, string>>;\n query: Readonly<Record<string, string | readonly string[]>>;\n body: unknown;\n /** `true` when the request came through a read-only share link. */\n shared?: boolean;\n};\n\n/** Devtools' `DevtoolsPanelShare`, structurally: what a share link may show. */\nexport type GrimoireDevtoolsPanelShare = {\n view: string | URL;\n routes: readonly string[];\n assets?: readonly string[];\n files?: boolean;\n};\n\n/** Devtools' `DevtoolsPanel`, structurally. */\nexport type GrimoireDevtoolsPanel = {\n id: string;\n title: string;\n view: string | URL;\n routes?: readonly {\n method?: \"GET\" | \"POST\";\n path: string;\n handler: (request: GrimoirePanelRequest) => unknown;\n }[];\n assets?: Readonly<Record<string, string | URL>>;\n /** A folder of images served next to the panel. */\n files?: { dir: string; extensions?: readonly string[] };\n /** What a read-only share link may show. */\n share?: GrimoireDevtoolsPanelShare;\n /** Safe for the production monitor: the tab only reads (see `GrimoirePanelContext.mode`). */\n production?: boolean;\n};\n\n/** What the panel factory takes: devtools passes `{ root, mode }`; the rest is for tests and custom setups. */\nexport type GrimoirePanelContext = {\n /** The app root. */\n root: string;\n /**\n * Where the dashboard runs. In `\"production\"` the tab writes no files:\n * it reads the book as it is on disk. Default: development.\n */\n mode?: \"development\" | \"production\";\n /** The adapter to open the book with. Default: the Warlock adapter, loaded on first request. */\n adapter?: BookAdapter | (() => Promise<BookAdapter>);\n /**\n * How long an opened snapshot is reused when the book did not change (ms).\n * Default in development: 2000, longer after a slow open; the old snapshot is served while a\n * background open refreshes it. Default in production: until the book changes.\n */\n ttlMs?: number;\n /**\n * Where the test results are read from (project-relative or absolute).\n * Default `grimoire/book/test-results.json`. Set it when the deploy ships\n * the results from CI; the Vitest reporter writes there with\n * `grimoireReporter({ file })`.\n */\n testResultsFile?: string;\n /** Captured error groups of the monitor (counts only), for the product map's health. Devtools passes it. */\n errors?: () => Promise<readonly ProductErrorSummary[]>;\n};\n\n/** The first value of a query parameter. */\nfunction one(query: GrimoirePanelRequest[\"query\"], name: string): string | undefined {\n const value = query[name];\n\n return Array.isArray(value) ? value[0] : (value as string | undefined);\n}\n\n/** Build the panel for the app at `root`. */\nexport async function grimoireDevtoolsPanel(\n context: GrimoirePanelContext,\n): Promise<GrimoireDevtoolsPanel> {\n // In development the tab keeps Warlock's generated files (book, book maps, indexes) up to date, so\n // the next open is incremental. In production it writes nothing. Agent-written files are only read,\n // and cached routes never boot the app.\n const source = createSnapshotSource(context.root, {\n write: context.mode !== \"production\",\n mode: context.mode ?? \"development\",\n ...(context.adapter === undefined ? {} : { adapter: context.adapter }),\n ...(context.ttlMs === undefined ? {} : { ttlMs: context.ttlMs }),\n ...(context.testResultsFile === undefined ? {} : { testResultsFile: context.testResultsFile }),\n });\n\n // In production, start opening the book now so the first tab view is fast.\n if (context.mode === \"production\") source.warm();\n\n const answer =\n <Answer>(read: (snapshot: GrimoireSnapshot, request: GrimoirePanelRequest) => Answer) =>\n async (request: GrimoirePanelRequest): Promise<Answer> =>\n read(await source.get(), request);\n\n /** The product map answers: the shared flag from the request, the errors fetched per request. */\n const product =\n <Answer>(\n read: (\n snapshot: GrimoireSnapshot,\n request: GrimoirePanelRequest,\n options: { shared: boolean; errors: readonly ProductErrorSummary[] | null },\n ) => Answer,\n ) =>\n async (request: GrimoirePanelRequest): Promise<Answer> => {\n const snapshot = await source.get();\n let errors: readonly ProductErrorSummary[] | null = null;\n\n try {\n errors = (await context.errors?.()) ?? null;\n } catch {\n errors = null;\n }\n\n return read(snapshot, request, { shared: request.shared === true, errors });\n };\n\n const number = (value: string | undefined): number | undefined => {\n if (value === undefined || value === \"\") return undefined;\n\n const parsed = Number(value);\n\n return Number.isFinite(parsed) ? parsed : undefined;\n };\n\n const checkFilter = (query: GrimoirePanelRequest[\"query\"]): GrimoireCheckFilter | null => {\n const filter: GrimoireCheckFilter = {};\n const code = one(query, \"code\");\n const feature = one(query, \"feature\");\n const flow = one(query, \"flow\");\n const severity = one(query, \"severity\");\n const state = one(query, \"state\");\n const offset = number(one(query, \"offset\"));\n const limit = number(one(query, \"limit\"));\n let any = false;\n\n if (code) (filter.code = code), (any = true);\n if (feature) (filter.feature = feature), (any = true);\n if (flow) (filter.flow = flow), (any = true);\n if (severity === \"error\" || severity === \"warning\") (filter.severity = severity), (any = true);\n if (state === \"expected\" || state === \"unexpected\") (filter.state = state), (any = true);\n if (offset !== undefined) (filter.offset = offset), (any = true);\n if (limit !== undefined) (filter.limit = limit), (any = true);\n\n return any ? filter : null;\n };\n\n return {\n id: \"grimoire\",\n title: \"Grimoire\",\n production: true,\n view: new URL(\"../../ui/grimoire-view.js\", import.meta.url),\n assets: {\n \"grimoire.css\": new URL(\"../../ui/grimoire.css\", import.meta.url),\n \"product-map.js\": new URL(\"../../ui/product-map.js\", import.meta.url),\n \"product-map.css\": new URL(\"../../ui/product-map.css\", import.meta.url),\n },\n files: { dir: path.join(context.root, \"grimoire\", \"screenshots\") },\n share: {\n view: new URL(\"../../ui/product-map.js\", import.meta.url),\n routes: [\"/product\", \"/product/features/:feature\", \"/product/flows/:feature/:flow\"],\n assets: [\"product-map.css\"],\n files: true,\n },\n routes: [\n { path: \"/summary\", handler: answer((snapshot) => data.summary(snapshot)) },\n {\n path: \"/search\",\n handler: answer((snapshot, { query }) => {\n const limit = Number(one(query, \"limit\"));\n\n return data.search(\n snapshot,\n one(query, \"q\") ?? \"\",\n Number.isFinite(limit) && limit > 0 ? limit : undefined,\n );\n }),\n },\n {\n path: \"/file\",\n handler: answer((snapshot, { query }) => data.file(snapshot, one(query, \"path\"))),\n },\n {\n path: \"/impact\",\n handler: answer((snapshot, { query }) => data.impact(snapshot, one(query, \"path\"))),\n },\n {\n path: \"/route\",\n handler: answer((snapshot, { query }) =>\n data.route(snapshot, one(query, \"method\"), one(query, \"path\")),\n ),\n },\n { path: \"/features\", handler: answer((snapshot) => data.features(snapshot)) },\n {\n path: \"/features/:feature\",\n handler: answer((snapshot, { params }) => data.feature(snapshot, params.feature)),\n },\n {\n path: \"/flows/:feature/:flow\",\n handler: answer((snapshot, { params }) =>\n data.flowAnswer(snapshot, params.feature, params.flow),\n ),\n },\n {\n path: \"/flows/:feature/:flow/steps/:index/files\",\n handler: answer((snapshot, { params, query }) =>\n data.stepFiles(snapshot, params.feature, params.flow, params.index, {\n set: one(query, \"set\"),\n offset: one(query, \"offset\"),\n limit: one(query, \"limit\"),\n }),\n ),\n },\n { path: \"/product\", handler: product((snapshot, _request, options) => productMap(snapshot, options)) },\n {\n path: \"/product/features/:feature\",\n handler: product((snapshot, { params }, options) =>\n productFeature(snapshot, params.feature, options),\n ),\n },\n {\n path: \"/product/flows/:feature/:flow\",\n handler: product((snapshot, { params }, options) =>\n productFlow(snapshot, params.feature, params.flow, options),\n ),\n },\n { path: \"/apps\", handler: answer((snapshot) => data.apps(snapshot)) },\n {\n path: \"/apps/:app/pages/:page\",\n handler: answer((snapshot, { params }) => data.page(snapshot, params.app, params.page)),\n },\n { path: \"/tasks\", handler: answer((snapshot) => data.tasks(snapshot)) },\n { path: \"/releases\", handler: answer((snapshot) => data.releases(snapshot)) },\n {\n path: \"/releases/:release\",\n handler: answer((snapshot, { params }) => data.release(snapshot, params.release)),\n },\n {\n path: \"/check\",\n handler: answer((snapshot, { query }) => {\n const filter = checkFilter(query);\n\n return filter === null ? data.check(snapshot) : data.checkPage(snapshot, filter);\n }),\n },\n { path: \"/check/groups\", handler: answer((snapshot) => data.checkGroups(snapshot)) },\n {\n path: \"/graph/file\",\n handler: answer((snapshot, { query }) => data.graphOfFile(snapshot, one(query, \"path\"))),\n },\n {\n path: \"/graph/feature/:feature\",\n handler: answer((snapshot, { params }) => data.graphOfFeature(snapshot, params.feature)),\n },\n {\n path: \"/graph/page\",\n handler: answer((snapshot, { query }) =>\n data.graphOfPage(snapshot, one(query, \"app\"), one(query, \"page\")),\n ),\n },\n { path: \"/graph/modules\", handler: answer((snapshot) => data.graphOfModules(snapshot)) },\n ],\n };\n}\n\nexport default grimoireDevtoolsPanel;\n"],"mappings":";;;;;;;;AA0FA,SAAS,IAAI,OAAsC,MAAkC;CACnF,MAAM,QAAQ,MAAM;CAEpB,OAA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,KAAK,OAAO,IAAI,CAAC;GACxF;GACA;IAAE,MAAM;IAAU,SAAS,QAAQ,aAAaC,MAAW,QAAQ,CAAC;GAAE;GACtE;IAAE,MAAM;IAAa,SAAS,QAAQ,aAAaC,SAAc,QAAQ,CAAC;GAAE;GAC5E;IACE,MAAM;IACN,SAAS,QAAQ,UAAU,EAAE,aAAaC,QAAa,UAAU,OAAO,OAAO,CAAC;GAClF;GACA;IACE,MAAM;IACN,SAAS,QAAQ,UAAU,EAAE,YAAY;KACvC,MAAM,SAAS,YAAY,KAAK;KAEhC,OAAO,WAAW,OAAOC,MAAW,QAAQ,IAAIC,UAAe,UAAU,MAAM;IACjF,CAAC;GACH;GACA;IAAE,MAAM;IAAiB,SAAS,QAAQ,aAAaC,YAAiB,QAAQ,CAAC;GAAE;GACnF;IACE,MAAM;IACN,SAAS,QAAQ,UAAU,EAAE,YAAYC,YAAiB,UAAU,IAAI,OAAO,MAAM,CAAC,CAAC;GACzF;GACA;IACE,MAAM;IACN,SAAS,QAAQ,UAAU,EAAE,aAAaC,eAAoB,UAAU,OAAO,OAAO,CAAC;GACzF;GACA;IACE,MAAM;IACN,SAAS,QAAQ,UAAU,EAAE,YAC3BC,YAAiB,UAAU,IAAI,OAAO,KAAK,GAAG,IAAI,OAAO,MAAM,CAAC,CAClE;GACF;GACA;IAAE,MAAM;IAAkB,SAAS,QAAQ,aAAaC,eAAoB,QAAQ,CAAC;GAAE;EACzF;CACF;AACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region ../../packages/grimoire/src/devtools/product-map.d.ts
|
|
2
|
+
/** One captured error group as devtools hands it to a panel: counts only. */
|
|
3
|
+
export type ProductErrorSummary = {
|
|
4
|
+
/** The route pattern (`/products/:id`), or `null` outside a request. */
|
|
5
|
+
route: string | null;
|
|
6
|
+
status: number | null;
|
|
7
|
+
name: string | null;
|
|
8
|
+
source: "request" | "log";
|
|
9
|
+
count: number;
|
|
10
|
+
firstSeen: number;
|
|
11
|
+
lastSeen: number;
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
//# sourceMappingURL=product-map.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-map.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/devtools/product-map.ts"],"mappings":";;YAoCY;;EAEV;EACA;EACA;EACA;EACA;EACA;EACA"}
|
|
@@ -0,0 +1,385 @@
|
|
|
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
|
+
for (const finding of report.findings) {
|
|
65
|
+
if (finding.expected || finding.severity !== "error") continue;
|
|
66
|
+
const flow = finding.subject.flow;
|
|
67
|
+
const feature = finding.subject.feature ?? flow?.split("/")[0] ?? null;
|
|
68
|
+
if (feature !== null) featureErrors.set(feature, (featureErrors.get(feature) ?? 0) + 1);
|
|
69
|
+
if (flow !== null) flowErrors.set(flow, (flowErrors.get(flow) ?? 0) + 1);
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
snapshot,
|
|
73
|
+
options,
|
|
74
|
+
report,
|
|
75
|
+
featureErrors,
|
|
76
|
+
flowErrors,
|
|
77
|
+
captured: options.errors === null ? null : captureErrors(snapshot, options.errors, Date.now()),
|
|
78
|
+
resultsMissing: snapshot.results === null && snapshot.proofs.length > 0
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const plural = (count, word) => `${count} ${word}${count === 1 ? "" : "s"}`;
|
|
82
|
+
/** The traffic light and its sentence (the rules of the product map). */
|
|
83
|
+
function healthOf(context, criteria, checkErrors, captured) {
|
|
84
|
+
const counts = {
|
|
85
|
+
total: criteria.length,
|
|
86
|
+
pass: 0,
|
|
87
|
+
fail: 0,
|
|
88
|
+
stale: 0,
|
|
89
|
+
notRun: 0,
|
|
90
|
+
noTest: 0
|
|
91
|
+
};
|
|
92
|
+
for (const criterion of criteria) if (criterion.status === "pass") counts.pass += 1;
|
|
93
|
+
else if (criterion.status === "fail") counts.fail += 1;
|
|
94
|
+
else if (criterion.status === "stale") counts.stale += 1;
|
|
95
|
+
else if (criterion.status === "not-run") counts.notRun += 1;
|
|
96
|
+
else counts.noTest += 1;
|
|
97
|
+
const errors = context.captured === null ? null : {
|
|
98
|
+
count: captured?.count ?? 0,
|
|
99
|
+
lastSeen: captured?.lastSeen ?? null
|
|
100
|
+
};
|
|
101
|
+
const recent = errors?.count ?? 0;
|
|
102
|
+
const total = counts.total;
|
|
103
|
+
let level;
|
|
104
|
+
let reason;
|
|
105
|
+
if (counts.fail > 0) {
|
|
106
|
+
level = "problem";
|
|
107
|
+
reason = `${counts.fail} of ${total} checks fail`;
|
|
108
|
+
} else if (checkErrors > 0) {
|
|
109
|
+
level = "problem";
|
|
110
|
+
reason = `The check found ${plural(checkErrors, "error")}`;
|
|
111
|
+
} else if (counts.noTest > 0) {
|
|
112
|
+
level = "attention";
|
|
113
|
+
reason = `${counts.noTest} of ${total} checks have no test`;
|
|
114
|
+
} else if (context.resultsMissing && total > 0) {
|
|
115
|
+
level = "attention";
|
|
116
|
+
reason = "No test results recorded";
|
|
117
|
+
} else if (counts.stale > 0 || counts.notRun > 0) {
|
|
118
|
+
level = "attention";
|
|
119
|
+
reason = "Tests have not run since they changed";
|
|
120
|
+
} else if (recent > 0) {
|
|
121
|
+
level = "attention";
|
|
122
|
+
reason = `${plural(recent, "error")} in the last hour`;
|
|
123
|
+
} else if (total > 0) {
|
|
124
|
+
level = "good";
|
|
125
|
+
reason = `All ${total} checks pass`;
|
|
126
|
+
} else {
|
|
127
|
+
level = "unknown";
|
|
128
|
+
reason = "No checks written yet";
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
level,
|
|
132
|
+
reason,
|
|
133
|
+
criteria: counts,
|
|
134
|
+
errors
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function featureHealth(context, feature) {
|
|
138
|
+
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));
|
|
139
|
+
}
|
|
140
|
+
function flowHealthOf(context, flow) {
|
|
141
|
+
return healthOf(context, context.snapshot.collected.flows[flow.ref]?.criteria ?? [], context.flowErrors.get(flow.ref) ?? 0, context.captured?.flows.get(flow.ref));
|
|
142
|
+
}
|
|
143
|
+
function findFeature(snapshot, id) {
|
|
144
|
+
if (id === void 0 || id === "") throw new GrimoirePanelError(400, "Missing \"feature\".");
|
|
145
|
+
const feature = snapshot.written.features.find((item) => item.id === id);
|
|
146
|
+
if (feature === void 0 || feature.readme === null) throw new GrimoirePanelError(404, `No feature "${id}" is written in grimoire/features.`);
|
|
147
|
+
return feature;
|
|
148
|
+
}
|
|
149
|
+
function audienceOf(feature) {
|
|
150
|
+
const listed = (feature.readme?.audience ?? []).map((item) => item.value);
|
|
151
|
+
if (listed.length > 0) return listed;
|
|
152
|
+
return [...new Set(feature.flows.map((flow) => flow.who.value))];
|
|
153
|
+
}
|
|
154
|
+
function card(context, feature) {
|
|
155
|
+
const readme = feature.readme;
|
|
156
|
+
if (readme === null) throw new Error("A feature card needs a README.");
|
|
157
|
+
return {
|
|
158
|
+
id: feature.id,
|
|
159
|
+
title: readme.title.value,
|
|
160
|
+
summary: readme.summary,
|
|
161
|
+
audience: audienceOf(feature),
|
|
162
|
+
apps: readme.apps.map((app) => app.value),
|
|
163
|
+
status: readme.status.value,
|
|
164
|
+
version: readme.version.value,
|
|
165
|
+
flows: feature.flows.length,
|
|
166
|
+
health: featureHealth(context, feature)
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
/** `GET /product`: the feature map. */
|
|
170
|
+
function productMap(snapshot, options) {
|
|
171
|
+
const context = contextOf(snapshot, options);
|
|
172
|
+
return {
|
|
173
|
+
builtAt: snapshot.book.manifest.builtAt,
|
|
174
|
+
features: snapshot.written.features.filter((feature) => feature.readme !== null).map((feature) => card(context, feature)),
|
|
175
|
+
apps: snapshot.written.apps.map((app) => ({
|
|
176
|
+
id: app.id.value,
|
|
177
|
+
type: app.type.value,
|
|
178
|
+
title: app.heading?.value ?? null
|
|
179
|
+
})),
|
|
180
|
+
developer: !options.shared
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
const slugOf = (text) => text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
184
|
+
function screenshotsOf(items) {
|
|
185
|
+
return items.flatMap((item) => item.path === null ? [] : [{
|
|
186
|
+
src: item.path,
|
|
187
|
+
alt: item.alt
|
|
188
|
+
}]);
|
|
189
|
+
}
|
|
190
|
+
/** Where the flows are shown, with the screenshots of the block (else of the page). */
|
|
191
|
+
function appearancesOf(snapshot, bookmaps) {
|
|
192
|
+
const seen = /* @__PURE__ */ new Set();
|
|
193
|
+
const list = [];
|
|
194
|
+
const apps = new Map(snapshot.written.apps.map((app) => [app.id.value, app]));
|
|
195
|
+
for (const bookmap of bookmaps) for (const shown of bookmap.shownBy) {
|
|
196
|
+
const key = `${shown.app}|${shown.type}|${shown.id}|${shown.block}|${bookmap.ref}`;
|
|
197
|
+
if (seen.has(key)) continue;
|
|
198
|
+
seen.add(key);
|
|
199
|
+
const app = apps.get(shown.app);
|
|
200
|
+
let title = null;
|
|
201
|
+
let route = null;
|
|
202
|
+
let screenshots = [];
|
|
203
|
+
if (app !== void 0 && shown.type === "layout") title = app.layouts.find((layout) => layout.id === shown.id)?.heading?.value ?? null;
|
|
204
|
+
else if (app !== void 0) {
|
|
205
|
+
const page = [...app.pages, ...app.screens].find((item) => item.id === shown.id);
|
|
206
|
+
if (page !== void 0) {
|
|
207
|
+
title = page.heading?.value ?? null;
|
|
208
|
+
route = page.route?.value ?? page.screen?.value ?? null;
|
|
209
|
+
screenshots = screenshotsOf((page.blockFiles.find((item) => item.id === slugOf(shown.block)) ?? page.blockFiles.find((item) => item.flow?.value === bookmap.ref))?.screenshots ?? []);
|
|
210
|
+
if (screenshots.length === 0) screenshots = screenshotsOf(page.screenshots);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
list.push({
|
|
214
|
+
app: shown.app,
|
|
215
|
+
type: shown.type,
|
|
216
|
+
id: shown.id,
|
|
217
|
+
title,
|
|
218
|
+
route,
|
|
219
|
+
block: shown.block,
|
|
220
|
+
flow: bookmap.ref,
|
|
221
|
+
screenshots
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
return list;
|
|
225
|
+
}
|
|
226
|
+
function releasesOf(snapshot, feature) {
|
|
227
|
+
const dates = new Map(snapshot.written.releases.map((item) => [item.release.value, item.date.value]));
|
|
228
|
+
const entries = feature.changelog?.entries ?? [];
|
|
229
|
+
const ordered = [...entries.filter((entry) => entry.release === null), ...entries.filter((entry) => entry.release !== null)];
|
|
230
|
+
const groups = /* @__PURE__ */ new Map();
|
|
231
|
+
for (const entry of ordered) {
|
|
232
|
+
const key = `${entry.version.value}|${entry.release ?? ""}`;
|
|
233
|
+
let group = groups.get(key);
|
|
234
|
+
if (group === void 0) {
|
|
235
|
+
group = {
|
|
236
|
+
version: entry.version.value,
|
|
237
|
+
release: entry.release,
|
|
238
|
+
date: entry.date ?? (entry.release === null ? null : dates.get(entry.release) ?? null),
|
|
239
|
+
changes: []
|
|
240
|
+
};
|
|
241
|
+
groups.set(key, group);
|
|
242
|
+
}
|
|
243
|
+
group.changes.push({
|
|
244
|
+
word: entry.word,
|
|
245
|
+
flow: entry.flow,
|
|
246
|
+
text: entry.text
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
return [...groups.values()];
|
|
250
|
+
}
|
|
251
|
+
function plannedOf(snapshot, feature) {
|
|
252
|
+
return snapshot.collected.tasksIndex.open.filter((task) => task.feature === feature).map((task) => ({
|
|
253
|
+
id: task.id,
|
|
254
|
+
title: task.title,
|
|
255
|
+
type: task.type,
|
|
256
|
+
status: task.status,
|
|
257
|
+
flow: task.flow === null ? null : task.flow.replace(`${feature}/`, "")
|
|
258
|
+
}));
|
|
259
|
+
}
|
|
260
|
+
function flowCard(context, flow) {
|
|
261
|
+
return {
|
|
262
|
+
id: flow.id.value,
|
|
263
|
+
ref: flow.ref,
|
|
264
|
+
title: flow.heading?.value ?? flow.id.value,
|
|
265
|
+
summary: flow.summary,
|
|
266
|
+
who: flow.who.value,
|
|
267
|
+
status: flow.status.value,
|
|
268
|
+
health: flowHealthOf(context, flow)
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
/** `GET /product/features/:feature`. */
|
|
272
|
+
function productFeature(snapshot, id, options) {
|
|
273
|
+
const feature = findFeature(snapshot, id);
|
|
274
|
+
const readme = feature.readme;
|
|
275
|
+
if (readme === null) throw new Error("unreachable");
|
|
276
|
+
const context = contextOf(snapshot, options);
|
|
277
|
+
const bookmaps = feature.flows.flatMap((flow) => {
|
|
278
|
+
const bookmap = snapshot.collected.flows[flow.ref];
|
|
279
|
+
return bookmap === void 0 ? [] : [bookmap];
|
|
280
|
+
});
|
|
281
|
+
const own = snapshot.collected.features[feature.id];
|
|
282
|
+
const unexpected = context.report.findings.filter((finding) => (finding.subject.feature ?? finding.subject.flow?.split("/")[0]) === feature.id);
|
|
283
|
+
const unexpectedNow = unexpected.filter((finding) => !finding.expected);
|
|
284
|
+
const errors = unexpectedNow.filter((finding) => finding.severity === "error").length;
|
|
285
|
+
return {
|
|
286
|
+
feature: {
|
|
287
|
+
id: feature.id,
|
|
288
|
+
title: readme.title.value,
|
|
289
|
+
summary: readme.summary,
|
|
290
|
+
why: readme.why,
|
|
291
|
+
audience: audienceOf(feature),
|
|
292
|
+
apps: readme.apps.map((app) => app.value),
|
|
293
|
+
status: readme.status.value,
|
|
294
|
+
version: readme.version.value,
|
|
295
|
+
updated: readme.updated.value,
|
|
296
|
+
origin: readme.origin?.value ?? null
|
|
297
|
+
},
|
|
298
|
+
flows: flowOrder(feature).map((flow) => flowCard(context, flow)),
|
|
299
|
+
appearances: appearancesOf(snapshot, bookmaps),
|
|
300
|
+
releases: releasesOf(snapshot, feature),
|
|
301
|
+
planned: plannedOf(snapshot, feature.id),
|
|
302
|
+
health: featureHealth(context, feature),
|
|
303
|
+
developer: options.shared ? null : {
|
|
304
|
+
folders: readme.folders.map((folder) => folder.value),
|
|
305
|
+
routes: (own?.routes ?? []).map(({ file: _file, ...route }) => route),
|
|
306
|
+
files: own?.own.length ?? 0,
|
|
307
|
+
findings: {
|
|
308
|
+
errors,
|
|
309
|
+
warnings: unexpectedNow.length - errors,
|
|
310
|
+
expected: unexpected.length - unexpectedNow.length
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
const STEP_WORDS = {
|
|
316
|
+
page: (target) => `Open ${target}`,
|
|
317
|
+
route: () => "The server takes the request",
|
|
318
|
+
mail: (target) => `An email "${target}" is sent`,
|
|
319
|
+
notification: (target) => `A notification "${target}" is sent`,
|
|
320
|
+
job: (target) => `The job "${target}" runs in the background`,
|
|
321
|
+
event: (target) => `The event "${target}" happens`,
|
|
322
|
+
"outside service": (target) => `The outside service "${target}" is used`,
|
|
323
|
+
affects: (target) => `This also affects ${target}`
|
|
324
|
+
};
|
|
325
|
+
function storyOf(flow) {
|
|
326
|
+
if (flow.story.length > 0) return flow.story.map((step) => ({
|
|
327
|
+
index: step.index,
|
|
328
|
+
text: step.text,
|
|
329
|
+
screenshots: screenshotsOf(step.screenshots),
|
|
330
|
+
derived: false
|
|
331
|
+
}));
|
|
332
|
+
return flow.steps.map((step) => ({
|
|
333
|
+
index: step.index,
|
|
334
|
+
text: step.note ?? STEP_WORDS[step.type](step.target),
|
|
335
|
+
screenshots: [],
|
|
336
|
+
derived: true
|
|
337
|
+
}));
|
|
338
|
+
}
|
|
339
|
+
const DOES_NOT_APPLY = /^does not apply\b[:\s—-]*/i;
|
|
340
|
+
/** `GET /product/flows/:feature/:flow`. */
|
|
341
|
+
function productFlow(snapshot, featureId, flowId, options) {
|
|
342
|
+
const feature = findFeature(snapshot, featureId);
|
|
343
|
+
const flow = feature.flows.find((item) => item.id.value === flowId);
|
|
344
|
+
if (flow === void 0) throw new GrimoirePanelError(404, `No flow "${flowId ?? ""}" in feature "${feature.id}".`);
|
|
345
|
+
const context = contextOf(snapshot, options);
|
|
346
|
+
const bookmap = snapshot.collected.flows[flow.ref];
|
|
347
|
+
const { previous, next } = neighboursOf(feature, flow.id.value);
|
|
348
|
+
return {
|
|
349
|
+
flow: {
|
|
350
|
+
ref: flow.ref,
|
|
351
|
+
feature: feature.id,
|
|
352
|
+
featureTitle: feature.readme?.title.value ?? feature.id,
|
|
353
|
+
title: flow.heading?.value ?? flow.id.value,
|
|
354
|
+
summary: flow.summary,
|
|
355
|
+
who: flow.who.value,
|
|
356
|
+
status: flow.status.value,
|
|
357
|
+
since: flow.since.value
|
|
358
|
+
},
|
|
359
|
+
story: storyOf(flow),
|
|
360
|
+
proof: (bookmap?.criteria ?? []).map((criterion) => ({
|
|
361
|
+
id: criterion.id,
|
|
362
|
+
text: criterion.text,
|
|
363
|
+
status: criterion.status,
|
|
364
|
+
tests: options.shared ? null : criterion.tests
|
|
365
|
+
})),
|
|
366
|
+
cases: flow.cases.map((item) => {
|
|
367
|
+
const answer = item.doesNotApply ? item.answer.replace(DOES_NOT_APPLY, "").trim() : item.answer;
|
|
368
|
+
return {
|
|
369
|
+
question: item.question,
|
|
370
|
+
answer: answer === "" ? "Does not apply" : answer,
|
|
371
|
+
handled: !item.doesNotApply,
|
|
372
|
+
criteria: item.criteria
|
|
373
|
+
};
|
|
374
|
+
}),
|
|
375
|
+
appearances: bookmap === void 0 ? [] : appearancesOf(snapshot, [bookmap]),
|
|
376
|
+
previous,
|
|
377
|
+
next,
|
|
378
|
+
health: flowHealthOf(context, flow),
|
|
379
|
+
developer: options.shared ? null : { steps: (bookmap?.steps ?? []).map((step) => compactStep(snapshot, feature, step, flow)) }
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
//#endregion
|
|
384
|
+
export { productFeature, productFlow, productMap };
|
|
385
|
+
//# 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 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 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\n for (const finding of report.findings) {\n if (finding.expected || 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 captured:\n 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 ? null : { 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 level = \"attention\";\n reason = \"No test results recorded\";\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\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 return {\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: featureHealth(context, feature),\n };\n}\n\n/** `GET /product`: the feature map. */\nexport function productMap(snapshot: GrimoireSnapshot, options: ProductMapOptions): 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 developer: !options.shared,\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(snapshot: GrimoireSnapshot, bookmaps: readonly FlowBookmap[]): 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(snapshot.written.releases.map((item) => [item.release.value, item.date.value]));\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) =>\n (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 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 ? item.answer.replace(DOES_NOT_APPLY, \"\").trim() : 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 };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAwDA,MAAM,kBAAkB;AAexB,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,O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