@warlock.js/grimoire 5.58.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 (71) hide show
  1. package/CHANGELOG.md +24 -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.map +1 -1
  6. package/esm/bookmap/build.d.mts.map +1 -1
  7. package/esm/bookmap/build.mjs +5 -3
  8. package/esm/bookmap/build.mjs.map +1 -1
  9. package/esm/bookmap/steps.mjs +34 -3
  10. package/esm/bookmap/steps.mjs.map +1 -1
  11. package/esm/contracts/adapter.d.mts +22 -1
  12. package/esm/contracts/adapter.d.mts.map +1 -1
  13. package/esm/contracts/scry.d.mts +26 -6
  14. package/esm/contracts/scry.d.mts.map +1 -1
  15. package/esm/contracts/snapshot.d.mts +3 -1
  16. package/esm/contracts/snapshot.d.mts.map +1 -1
  17. package/esm/devtools/data.mjs +23 -3
  18. package/esm/devtools/data.mjs.map +1 -1
  19. package/esm/devtools/feature-map.mjs +149 -0
  20. package/esm/devtools/feature-map.mjs.map +1 -0
  21. package/esm/devtools/index.d.mts +2 -2
  22. package/esm/devtools/index.mjs +30 -9
  23. package/esm/devtools/index.mjs.map +1 -1
  24. package/esm/devtools/product-map.d.mts.map +1 -1
  25. package/esm/devtools/product-map.mjs +82 -7
  26. package/esm/devtools/product-map.mjs.map +1 -1
  27. package/esm/devtools/site.d.mts +43 -1
  28. package/esm/devtools/site.d.mts.map +1 -1
  29. package/esm/devtools/site.mjs +111 -15
  30. package/esm/devtools/site.mjs.map +1 -1
  31. package/esm/devtools/snapshot-source.mjs +15 -2
  32. package/esm/devtools/snapshot-source.mjs.map +1 -1
  33. package/esm/index.d.mts +3 -3
  34. package/esm/ownership/index.d.mts.map +1 -1
  35. package/esm/ownership/index.mjs +60 -1
  36. package/esm/ownership/index.mjs.map +1 -1
  37. package/esm/scry/compact.mjs +2 -1
  38. package/esm/scry/compact.mjs.map +1 -1
  39. package/esm/scry/format.d.mts.map +1 -1
  40. package/esm/scry/format.mjs +12 -1
  41. package/esm/scry/format.mjs.map +1 -1
  42. package/esm/scry/query.d.mts.map +1 -1
  43. package/esm/scry/query.mjs +147 -23
  44. package/esm/scry/query.mjs.map +1 -1
  45. package/esm/test-results/index.d.mts.map +1 -1
  46. package/esm/test-results/index.mjs.map +1 -1
  47. package/esm/warlock/actions.mjs +15 -7
  48. package/esm/warlock/actions.mjs.map +1 -1
  49. package/esm/warlock/adapter.d.mts.map +1 -1
  50. package/esm/warlock/adapter.mjs +36 -2
  51. package/esm/warlock/adapter.mjs.map +1 -1
  52. package/esm/warlock/commands.mjs +7 -2
  53. package/esm/warlock/commands.mjs.map +1 -1
  54. package/esm/warlock/logo.mjs +12 -0
  55. package/esm/warlock/logo.mjs.map +1 -0
  56. package/esm/warlock/mcp-tools.mjs +6 -6
  57. package/esm/warlock/mcp-tools.mjs.map +1 -1
  58. package/esm/workspace/cache.mjs +194 -0
  59. package/esm/workspace/cache.mjs.map +1 -0
  60. package/esm/workspace/index.d.mts.map +1 -1
  61. package/esm/workspace/index.mjs +3 -1
  62. package/esm/workspace/index.mjs.map +1 -1
  63. package/llms-full.txt +32 -9
  64. package/package.json +3 -3
  65. package/skills/record-a-change/SKILL.md +2 -0
  66. package/skills/use-the-grimoire/SKILL.md +30 -9
  67. package/ui/grimoire-static.js +57 -6
  68. package/ui/grimoire-view.js +1289 -310
  69. package/ui/grimoire.css +583 -2
  70. package/ui/product-map.css +157 -8
  71. package/ui/product-map.js +507 -59
@@ -93,15 +93,27 @@ export type ScryRouteResult = ScryNotes & {
93
93
  /** Page whose route matches, for a page route. */
94
94
  page: BookPage | null;
95
95
  };
96
+ /** One flow of a feature answer, with the counts the flow cards show. */
97
+ export type ScryFeatureFlow = {
98
+ id: string;
99
+ status: string;
100
+ since: string;
101
+ heading: string | null;
102
+ /** Technical steps written in the flow file. */
103
+ steps: number;
104
+ /** Edge cases written in the flow (`## Cases`). */
105
+ cases: number;
106
+ /** Acceptance criteria written in the flow. */
107
+ criteria: number;
108
+ /** Criteria with at least one `@proves` test. */
109
+ tested: number;
110
+ /** Findings about the flow that are not expected (a `proposed` flow's findings are). */
111
+ findings: number;
112
+ };
96
113
  export type ScryFeatureResult = ScryNotes & {
97
114
  type: "feature";
98
115
  readme: WrittenFeatureReadme;
99
- flows: {
100
- id: string;
101
- status: string;
102
- since: string;
103
- heading: string | null;
104
- }[];
116
+ flows: ScryFeatureFlow[];
105
117
  bookmap: FeatureBookmap;
106
118
  /** Newest first, at most 10. */
107
119
  changes: WrittenChangelogEntry[];
@@ -132,10 +144,18 @@ export type ScryHit = {
132
144
  detail: string | null;
133
145
  /** Higher is better. Only the order is meaningful. */
134
146
  score: number;
147
+ /**
148
+ * For a feature or flow found by its written text: the part that matched
149
+ * (`AC-5: …`, `case duplicate: …`, `story 2: …`, `summary: …`). Absent when the name matched.
150
+ */
151
+ matched?: string;
135
152
  };
136
153
  export type ScrySearchResult = ScryNotes & {
137
154
  type: "search";
138
155
  text: string;
156
+ /** How many candidates matched, per type, before the limit cut the list. */
157
+ counts: Partial<Record<ScryHitType, number>>;
158
+ /** Grouped by type (features and flows first), best first inside a group. */
139
159
  hits: ScryHit[];
140
160
  };
141
161
  export type ScryResult = ScryFileResult | ScryImpactResult | ScryRouteResult | ScryFeatureResult | ScryFlowResult | ScrySearchResult;
@@ -1 +1 @@
1
- {"version":3,"file":"scry.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/contracts/scry.ts"],"mappings":";;;;;;YAWY;;;EAEN;EAAc;;;;EAEd;EAAgB;;;;EAEhB;EAAe;EAAgB;;;;EAE/B;EAAiB;;;;EAEjB;EAAc;EAAiB;;;;EAE/B;EAAgB;EAAc;;;YAGxB;EACV,QAAQ;EACR;;;YAIU;EAAgB;EAAa;EAAe;EAAc;;YAE1D,iBAAiB;EAC3B;EACA,OAAO;;EAEP;;YAIU,mBAAmB,KAAK;EAClC;EACA;;EAEA;IAAa;IAAkB;;;;;;EAK/B,QAAQ,KAAK;EACb,OAAO;;EAEP;;EAEA;IAAY;IAAY;;;EAExB;;YAGU,kBAAkB;EAC5B;EACA,OAAO;;EAEP;;EAEA;IAAS;IAAc;;;EAEvB,MAAM;;YAGI,oBAAoB;EAC9B;EACA,QAAQ;EACR;IAAS;IAAY;IAAgB;IAAe;;EACpD,SAAS;;EAET,SAAS;;EAET,OAAO;EACP,UAAU;;YAGA,iBAAiB;EAC3B;EACA,MAAM;EACN,SAAS;;EAET,SAAS;EACT,UAAU;;;YAIA;;YAcA;EACV,MAAM;;;;;;EAMN;;EAEA;;EAEA;;YAGU,mBAAmB;EAC7B;EACA;EACA,MAAM;;YAGI,aACR,iBACA,mBACA,kBACA,oBACA,iBACA"}
1
+ {"version":3,"file":"scry.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/contracts/scry.ts"],"mappings":";;;;;;YAWY;;;EAEN;EAAc;;;;EAEd;EAAgB;;;;EAEhB;EAAe;EAAgB;;;;EAE/B;EAAiB;;;;EAEjB;EAAc;EAAiB;;;;EAE/B;EAAgB;EAAc;;;YAGxB;EACV,QAAQ;EACR;;;YAIU;EAAgB;EAAa;EAAe;EAAc;;YAE1D,iBAAiB;EAC3B;EACA,OAAO;;EAEP;;YAIU,mBAAmB,KAAK;EAClC;EACA;;EAEA;IAAa;IAAkB;;;;;;EAK/B,QAAQ,KAAK;EACb,OAAO;;EAEP;;EAEA;IAAY;IAAY;;;EAExB;;YAGU,kBAAkB;EAC5B;EACA,OAAO;;EAEP;;EAEA;IAAS;IAAc;;;EAEvB,MAAM;;;YAII;EACV;EACA;EACA;EACA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;YAGU,oBAAoB;EAC9B;EACA,QAAQ;EACR,OAAO;EACP,SAAS;;EAET,SAAS;;EAET,OAAO;EACP,UAAU;;YAGA,iBAAiB;EAC3B;EACA,MAAM;EACN,SAAS;;EAET,SAAS;EACT,UAAU;;;YAIA;;YAcA;EACV,MAAM;;;;;;EAMN;;EAEA;;EAEA;;;;;EAKA;;YAGU,mBAAmB;EAC7B;EACA;;EAEA,QAAQ,QAAQ,OAAO;;EAEvB,MAAM;;YAGI,aACR,iBACA,mBACA,kBACA,oBACA,iBACA"}
@@ -1,4 +1,4 @@
1
- import { BookMobileApp, BookSite } from "./adapter.mjs";
1
+ import { BookHost, BookMobileApp, BookSite } from "./adapter.mjs";
2
2
  import { GrimoireFinding, RouteFreshness } from "./findings.mjs";
3
3
  import { BookAnnotations, LoadedBook } from "./book.mjs";
4
4
  import { WrittenGrimoire } from "./written.mjs";
@@ -28,6 +28,8 @@ export type GrimoireSnapshot = {
28
28
  collected: CollectedFiles;
29
29
  annotations: BookAnnotations;
30
30
  routes: RouteFreshness;
31
+ /** What the adapter's `host()` reported (framework brand, app name and version); `null` or absent when it reports none. */
32
+ host?: BookHost | null;
31
33
  };
32
34
  /** Options of `openGrimoire()`. */
33
35
  export type OpenGrimoireOptions = {
@@ -1 +1 @@
1
- {"version":3,"file":"snapshot.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/contracts/snapshot.ts"],"mappings":";;;;;;;YAYY;;EAEV;EACA,SAAS;;EAET,WAAW;EACX,MAAM;EACN,WAAW;;EAEX,MAAM,eAAe;EACrB,QAAQ;;EAER,eAAe;;EAEf,SAAS;;;;;EAKT;EACA,WAAW;EACX,aAAa;EACb,QAAQ;;;YAIE;;EAEV;;EAEA;;EAEA;;;;;;EAMA;EACA,YAAY;;;YAIF,gBAAgB,UAAU,qBAAqB;;;;;;;YAQ/C;EACV;EACA;EACA,MAAM;EACN,QAAQ"}
1
+ {"version":3,"file":"snapshot.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/contracts/snapshot.ts"],"mappings":";;;;;;;YAYY;;EAEV;EACA,SAAS;;EAET,WAAW;EACX,MAAM;EACN,WAAW;;EAEX,MAAM,eAAe;EACrB,QAAQ;;EAER,eAAe;;EAEf,SAAS;;;;;EAKT;EACA,WAAW;EACX,aAAa;EACb,QAAQ;;EAER,OAAO;;;YAIG;;EAEV;;EAEA;;EAEA;;;;;;EAMA;EACA,YAAY;;;YAIF,gBAAgB,UAAU,qBAAqB;;;;;;;YAQ/C;EACV;EACA;EACA,MAAM;EACN,QAAQ"}
@@ -5,6 +5,7 @@ import "../check/index.mjs";
5
5
  import { scry } from "../scry/query.mjs";
6
6
  import "../scry/index.mjs";
7
7
  import { STEP_FILE_SETS, compactFlow, stepFilePage } from "../scry/compact.mjs";
8
+ import { featureFileGroups, featureMap, featureProofs } from "./feature-map.mjs";
8
9
  import { featureGraph, fileGraph, moduleGraph, pageGraph } from "./graphs.mjs";
9
10
 
10
11
  //#region ../../packages/grimoire/src/devtools/data.ts
@@ -39,7 +40,16 @@ function required(value, name) {
39
40
  function summary(snapshot) {
40
41
  const files = snapshot.book.facts.files;
41
42
  const written = snapshot.written;
43
+ const steps = Object.values(snapshot.collected.flows).flatMap((flow) => flow.steps);
44
+ const resolved = steps.filter((step) => step.found === true).length;
45
+ const missing = steps.filter((step) => step.found === false).length;
42
46
  return {
47
+ steps: {
48
+ checked: resolved + missing,
49
+ resolved,
50
+ missing,
51
+ unchecked: steps.length - resolved - missing
52
+ },
43
53
  routes: snapshot.routes,
44
54
  features: snapshot.collected.featuresIndex,
45
55
  tasks: snapshot.collected.tasksIndex,
@@ -61,7 +71,8 @@ function summary(snapshot) {
61
71
  screens: written.apps.reduce((total, app) => total + app.screens.length, 0)
62
72
  },
63
73
  releases: written.releases.length,
64
- results: testResultsInfo(snapshot)
74
+ results: testResultsInfo(snapshot),
75
+ host: snapshot.host ?? null
65
76
  };
66
77
  }
67
78
  /** The features listing: the features index with each README summary and flow headings. */
@@ -107,10 +118,19 @@ function route(snapshot, method, path) {
107
118
  });
108
119
  }
109
120
  function feature(snapshot, id) {
110
- return ask(snapshot, {
121
+ const wanted = required(id, "feature");
122
+ const result = ask(snapshot, {
111
123
  type: "feature",
112
- feature: required(id, "feature")
124
+ feature: wanted
113
125
  });
126
+ const written = snapshot.written.features.find((item) => item.id === wanted);
127
+ if (written === void 0) throw new GrimoirePanelError(404, `No feature "${wanted}" is written.`);
128
+ return {
129
+ ...result,
130
+ map: featureMap(snapshot, written),
131
+ fileGroups: featureFileGroups(snapshot, result.bookmap.own),
132
+ proofs: featureProofs(snapshot, written)
133
+ };
114
134
  }
115
135
  function flow(snapshot, featureId, flowId) {
116
136
  return ask(snapshot, {
@@ -1 +1 @@
1
- {"version":3,"file":"data.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/devtools/data.ts"],"sourcesContent":["/**\n * The answers of the tab, as functions of the snapshot. The devtools routes\n * and the static export both call them; questions about one item go to\n * `scry()`, the rest read the snapshot directly.\n */\nimport { explainGrimoireCode, isGrimoireCode } from \"../codes\";\nimport { checkGrimoire } from \"../check\";\nimport type { BookPage, BookScreen } from \"../contracts/adapter\";\nimport type { TasksIndex, FeaturesIndex } from \"../contracts/bookmap\";\nimport type { GrimoireCheckReport, GrimoireFinding, RouteFreshness } from \"../contracts/findings\";\nimport type {\n ScryFeatureResult,\n ScryFileResult,\n ScryFlowResult,\n ScryImpactResult,\n ScryRouteResult,\n ScrySearchResult,\n} from \"../contracts/scry\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\nimport type { WrittenApp, WrittenLayout, WrittenPage, WrittenRelease } from \"../contracts/written\";\nimport { scry } from \"../scry\";\nimport { compactFlow, STEP_FILE_SETS, stepFilePage } from \"../scry/compact\";\nimport { testResultsInfo } from \"../test-results\";\nimport { featureGraph, fileGraph, moduleGraph, pageGraph, type GrimoireGraph } from \"./graphs\";\nimport {\n STEP_FILES_PAGE_LIMIT,\n type GrimoireCheckFilter,\n type GrimoireCheckGroup,\n type GrimoireCheckGroups,\n type GrimoireCheckPage,\n type GrimoireFlowAnswer,\n type GrimoireStepFilesAnswer,\n type StepFileSet,\n} from \"./answers\";\nimport type { TestResultsInfo } from \"../contracts/test-results\";\n\n/** An error a route answers with a status (devtools turns `statusCode` into the response status). */\nexport class GrimoirePanelError extends Error {\n public readonly statusCode: number;\n\n public constructor(statusCode: number, message: string) {\n super(message);\n this.name = \"GrimoirePanelError\";\n this.statusCode = statusCode;\n }\n}\n\nexport type GrimoireSummary = {\n routes: RouteFreshness;\n features: FeaturesIndex;\n tasks: TasksIndex;\n counts: GrimoireCheckReport[\"counts\"];\n /** Whether any feature, app, task or release is written, and how big the book is. */\n written: boolean;\n book: { files: number; modules: number; builtAt: string };\n /** How many apps, pages, screens and releases are written (the tab's navigation and overview badges). */\n apps: { apps: number; pages: number; screens: number };\n releases: number;\n /** Whether test results were read, from where, and how many proofs have one. */\n results: TestResultsInfo;\n};\n\n/** One feature of the listing: the index entry plus what the cards show. */\nexport type GrimoireFeatureRow = Omit<FeaturesIndex[\"features\"][number], \"flows\"> & {\n /** The README paragraph under the heading, or `null`. */\n summary: string | null;\n /** The index flows with their headings. */\n flows: (FeaturesIndex[\"features\"][number][\"flows\"][number] & { heading: string | null })[];\n};\n\nexport type GrimoireFeaturesAnswer = { features: GrimoireFeatureRow[] };\n\n/** One page or screen of an app, as the listing shows it. */\nexport type GrimoireAppRow = {\n id: string;\n type: \"page\" | \"screen\";\n /** The page route or the screen name, or `null` when the file gives none. */\n route: string | null;\n heading: string | null;\n /** `confirmed` or `inferred` when the file says so, otherwise `null`. */\n origin: \"confirmed\" | \"inferred\" | null;\n layout: string | null;\n /** How many block rows the page lists itself. */\n blocks: number;\n};\n\nexport type GrimoireAppsAnswer = {\n apps: {\n id: string;\n type: string;\n root: string;\n pages: string[];\n screens: string[];\n /** Every page and screen with what the listing needs. */\n rows: GrimoireAppRow[];\n }[];\n};\n\nexport type GrimoirePageAnswer = {\n page: WrittenPage;\n layout: WrittenLayout | null;\n book: BookPage | BookScreen | null;\n};\n\nexport type GrimoireReleasesAnswer = {\n releases: { release: string; date: string; file: string }[];\n};\n\n/** `scry()` with its not-found codes turned into a 404 and the rest into a 400. */\nfunction ask<Result>(snapshot: GrimoireSnapshot, query: Parameters<typeof scry>[1]): Result {\n try {\n return scry(snapshot, query) as Result;\n } catch (error) {\n const code = (error as { code?: unknown }).code;\n\n if (typeof code === \"string\" && isGrimoireCode(code)) {\n throw new GrimoirePanelError(code === \"GR9006\" ? 400 : 404, (error as Error).message);\n }\n\n throw error;\n }\n}\n\nfunction required(value: string | undefined, name: string): string {\n if (value === undefined || value === \"\") throw new GrimoirePanelError(400, `Missing \"${name}\".`);\n\n return value;\n}\n\nexport function summary(snapshot: GrimoireSnapshot): GrimoireSummary {\n const files = snapshot.book.facts.files;\n const written = snapshot.written;\n\n return {\n routes: snapshot.routes,\n features: snapshot.collected.featuresIndex,\n tasks: snapshot.collected.tasksIndex,\n counts: checkGrimoire(snapshot).counts,\n written: [written.features, written.apps, written.tasks, written.releases].some(\n (items) => items.length > 0,\n ),\n book: {\n files: files.length,\n modules: new Set(files.map((file) => file.module)).size,\n builtAt: snapshot.book.manifest.builtAt,\n },\n apps: {\n apps: written.apps.length,\n pages: written.apps.reduce((total, app) => total + app.pages.length, 0),\n screens: written.apps.reduce((total, app) => total + app.screens.length, 0),\n },\n releases: written.releases.length,\n results: testResultsInfo(snapshot),\n };\n}\n\n/** The features listing: the features index with each README summary and flow headings. */\nexport function features(snapshot: GrimoireSnapshot): GrimoireFeaturesAnswer {\n const written = new Map(snapshot.written.features.map((feature) => [feature.id, feature]));\n\n return {\n features: snapshot.collected.featuresIndex.features.map((entry) => {\n const source = written.get(entry.id);\n const headings = new Map(\n (source?.flows ?? []).map((flow) => [flow.id.value, flow.heading?.value ?? null]),\n );\n\n return {\n ...entry,\n summary: source?.readme?.summary ?? null,\n flows: entry.flows.map((flow) => ({ ...flow, heading: headings.get(flow.id) ?? null })),\n };\n }),\n };\n}\n\nexport function search(snapshot: GrimoireSnapshot, text: string, limit?: number): ScrySearchResult {\n return ask<ScrySearchResult>(snapshot, {\n type: \"search\",\n text,\n ...(limit !== undefined && Number.isFinite(limit) && limit > 0\n ? { limit: Math.min(limit, 100) }\n : {}),\n });\n}\n\nexport function file(snapshot: GrimoireSnapshot, path: string | undefined): ScryFileResult {\n return ask(snapshot, { type: \"file\", file: required(path, \"path\") });\n}\n\nexport function impact(snapshot: GrimoireSnapshot, path: string | undefined): ScryImpactResult {\n return ask(snapshot, { type: \"impact\", file: required(path, \"path\") });\n}\n\nexport function route(\n snapshot: GrimoireSnapshot,\n method: string | undefined,\n path: string | undefined,\n): ScryRouteResult {\n return ask(snapshot, {\n type: \"route\",\n method: required(method, \"method\"),\n path: required(path, \"path\"),\n });\n}\n\nexport function feature(snapshot: GrimoireSnapshot, id: string | undefined): ScryFeatureResult {\n return ask(snapshot, { type: \"feature\", feature: required(id, \"feature\") });\n}\n\nexport function flow(\n snapshot: GrimoireSnapshot,\n featureId: string | undefined,\n flowId: string | undefined,\n): ScryFlowResult {\n return ask(snapshot, {\n type: \"flow\",\n feature: required(featureId, \"feature\"),\n flow: required(flowId, \"flow\"),\n });\n}\n\nexport function apps(snapshot: GrimoireSnapshot): GrimoireAppsAnswer {\n return {\n apps: snapshot.written.apps.map((app) => ({\n id: app.id.value,\n type: app.type.value,\n root: app.root.value,\n pages: app.pages.map((page) => page.id),\n screens: app.screens.map((screen) => screen.id),\n rows: [...app.pages, ...app.screens].map((item) => ({\n id: item.id,\n type: item.type,\n route: item.route?.value ?? item.screen?.value ?? null,\n heading: item.heading?.value ?? null,\n origin: item.origin?.value ?? null,\n layout: item.layout?.value ?? null,\n blocks: item.blocks.length,\n })),\n })),\n };\n}\n\nfunction findApp(snapshot: GrimoireSnapshot, id: string | undefined): WrittenApp {\n const app = snapshot.written.apps.find((candidate) => candidate.id.value === id);\n\n if (app === undefined)\n throw new GrimoirePanelError(404, `No app \"${id ?? \"\"}\" is written in grimoire/apps.`);\n\n return app;\n}\n\n/** A page or screen by its id or its route. */\nexport function findPage(app: WrittenApp, key: string): WrittenPage | undefined {\n return [...app.pages, ...app.screens].find(\n (page) => page.id === key || page.route?.value === key || page.screen?.value === key,\n );\n}\n\nexport function page(\n snapshot: GrimoireSnapshot,\n appId: string | undefined,\n key: string | undefined,\n): GrimoirePageAnswer {\n const app = findApp(snapshot, appId);\n const written = findPage(app, required(key, \"page\"));\n\n if (written === undefined) {\n throw new GrimoirePanelError(\n 404,\n `App \"${app.id.value}\" has no page or screen \"${key ?? \"\"}\".`,\n );\n }\n\n const match = snapshot.apps[app.id.value];\n const route = written.route?.value ?? written.screen?.value ?? null;\n let book: BookPage | BookScreen | null = null;\n\n if (route !== null && match?.site) {\n book =\n snapshot.book.facts.pages.find(\n (candidate) => candidate.site === match.site?.id && candidate.route === route,\n ) ?? null;\n } else if (route !== null && match?.mobile) {\n book = match.mobile.screens.find((screen) => screen.route === route) ?? null;\n }\n\n const layoutId = written.layout?.value ?? null;\n\n return {\n page: written,\n layout:\n layoutId === null ? null : (app.layouts.find((layout) => layout.id === layoutId) ?? null),\n book,\n };\n}\n\nexport function tasks(snapshot: GrimoireSnapshot): TasksIndex {\n return snapshot.collected.tasksIndex;\n}\n\nexport function releases(snapshot: GrimoireSnapshot): GrimoireReleasesAnswer {\n return {\n releases: snapshot.written.releases.map((release) => ({\n release: release.release.value,\n date: release.date.value,\n file: release.file,\n })),\n };\n}\n\nexport function release(snapshot: GrimoireSnapshot, id: string | undefined): WrittenRelease {\n const found = snapshot.written.releases.find((candidate) => candidate.release.value === id);\n\n if (found === undefined)\n throw new GrimoirePanelError(404, `No release \"${id ?? \"\"}\" in grimoire/releases.`);\n\n return found;\n}\n\nexport function check(snapshot: GrimoireSnapshot): GrimoireCheckReport {\n return checkGrimoire(snapshot);\n}\n\nfunction graphOrNotFound(graph: GrimoireGraph | null, what: string): GrimoireGraph {\n if (graph === null) throw new GrimoirePanelError(404, `${what} is not in the book.`);\n\n return graph;\n}\n\nexport function graphOfFile(snapshot: GrimoireSnapshot, path: string | undefined): GrimoireGraph {\n const target = required(path, \"path\");\n\n return graphOrNotFound(fileGraph(snapshot, target), `\"${target}\"`);\n}\n\nexport function graphOfFeature(snapshot: GrimoireSnapshot, id: string | undefined): GrimoireGraph {\n const target = required(id, \"feature\");\n\n return graphOrNotFound(featureGraph(snapshot, target), `Feature \"${target}\"`);\n}\n\nexport function graphOfPage(\n snapshot: GrimoireSnapshot,\n appId: string | undefined,\n key: string | undefined,\n): GrimoireGraph {\n const target = required(key, \"page\");\n\n return graphOrNotFound(pageGraph(snapshot, required(appId, \"app\"), target), `Page \"${target}\"`);\n}\n\nexport function graphOfModules(snapshot: GrimoireSnapshot): GrimoireGraph {\n return moduleGraph(snapshot);\n}\n\n// ── Compact flow, step files, check pages and groups ───────────────────────\n\n/** `GET /flows/:feature/:flow`: the compact flow answer (step counts, direct imports, health, neighbours). */\nexport function flowAnswer(\n snapshot: GrimoireSnapshot,\n featureId: string | undefined,\n flowId: string | undefined,\n): GrimoireFlowAnswer {\n return compactFlow(snapshot, flow(snapshot, featureId, flowId));\n}\n\n/** A whole number from a query value, or a 400 naming the parameter. */\nfunction whole(value: string | undefined, name: string, fallback: number, min: number): number {\n if (value === undefined || value === \"\") return fallback;\n\n const number = Number(value);\n\n if (!Number.isInteger(number) || number < min) {\n throw new GrimoirePanelError(400, `\"${name}\" must be a whole number of ${min} or more.`);\n }\n\n return number;\n}\n\n/** `GET /flows/:feature/:flow/steps/:index/files`: one page of a step's files. */\nexport function stepFiles(\n snapshot: GrimoireSnapshot,\n featureId: string | undefined,\n flowId: string | undefined,\n index: string | undefined,\n query: { set?: string | undefined; offset?: string | undefined; limit?: string | undefined },\n): GrimoireStepFilesAnswer {\n const feature = required(featureId, \"feature\");\n const id = required(flowId, \"flow\");\n const set = query.set === undefined || query.set === \"\" ? \"reachable\" : query.set;\n\n if (!(STEP_FILE_SETS as readonly string[]).includes(set)) {\n throw new GrimoirePanelError(\n 400,\n `Unknown set \"${set}\". Use one of: ${STEP_FILE_SETS.join(\", \")}.`,\n );\n }\n\n const stepIndex = whole(required(index, \"index\"), \"index\", 0, 0);\n const offset = whole(query.offset, \"offset\", 0, 0);\n const limit = Math.min(whole(query.limit, \"limit\", STEP_FILES_PAGE_LIMIT, 1), STEP_FILES_PAGE_LIMIT);\n const written = snapshot.written.features\n .find((item) => item.id === feature)\n ?.flows.find((item) => item.id.value === id);\n const bookmap = written === undefined ? undefined : snapshot.collected.flows[written.ref];\n\n if (written === undefined || bookmap === undefined) {\n throw new GrimoirePanelError(404, `No flow ${feature}/${id} is written.`);\n }\n\n const step = bookmap.steps.find((item) => item.index === stepIndex);\n\n if (step === undefined) {\n throw new GrimoirePanelError(404, `${written.ref} has no step ${stepIndex}.`);\n }\n\n return stepFilePage(snapshot, bookmap, step, set as StepFileSet, offset, limit);\n}\n\n/** `GET /check?code=&feature=&flow=&severity=&state=&offset=&limit=`: matching findings, paged. */\nexport function checkPage(snapshot: GrimoireSnapshot, filter: GrimoireCheckFilter): GrimoireCheckPage {\n const report = checkGrimoire(snapshot);\n const limit = Math.min(Math.max(1, Math.floor(filter.limit ?? 100)), 500);\n const offset = Math.max(0, Math.floor(filter.offset ?? 0));\n const code = filter.code?.trim().toUpperCase();\n const matching = report.findings.filter((finding) => {\n if (code !== undefined && code !== \"\" && finding.code !== code) return false;\n if (filter.severity !== undefined && finding.severity !== filter.severity) return false;\n if (filter.state !== undefined && finding.expected !== (filter.state === \"expected\")) return false;\n if (filter.flow !== undefined && filter.flow !== \"\" && finding.subject.flow !== filter.flow) {\n return false;\n }\n\n if (filter.feature !== undefined && filter.feature !== \"\") {\n return featureOfFinding(finding) === filter.feature;\n }\n\n return true;\n });\n\n return {\n ...report,\n findings: matching.slice(offset, offset + limit),\n total: matching.length,\n offset,\n limit,\n };\n}\n\n/** The feature a finding belongs to: its subject, else the feature of its flow, else `(none)`. */\nfunction featureOfFinding(finding: GrimoireFinding): string {\n return finding.subject.feature ?? finding.subject.flow?.split(\"/\")[0] ?? \"(none)\";\n}\n\n/** `GET /check/groups`: the check by code, errors first, then by count. */\nexport function checkGroups(snapshot: GrimoireSnapshot): GrimoireCheckGroups {\n const report = checkGrimoire(snapshot);\n const byCode = new Map<string, GrimoireFinding[]>();\n\n for (const finding of report.findings) {\n byCode.set(finding.code, [...(byCode.get(finding.code) ?? []), finding]);\n }\n\n const groups: GrimoireCheckGroup[] = [];\n\n for (const [code, findings] of byCode) {\n const definition = explainGrimoireCode(code);\n const unexpected = findings.filter((finding) => !finding.expected);\n const features = new Map<string, number>();\n\n for (const finding of unexpected) {\n const feature = featureOfFinding(finding);\n\n features.set(feature, (features.get(feature) ?? 0) + 1);\n }\n\n groups.push({\n code,\n severity: findings[0]?.severity ?? definition?.severity ?? \"warning\",\n area: definition?.area ?? \"\",\n title: definition?.title ?? code,\n fix: definition?.fix ?? findings[0]?.hint ?? \"\",\n count: unexpected.length,\n expected: findings.length - unexpected.length,\n features: [...features]\n .map(([feature, count]) => ({ feature, count }))\n .sort((left, right) => right.count - left.count || (left.feature < right.feature ? -1 : 1)),\n });\n }\n\n groups.sort(\n (left, right) =>\n (left.severity === right.severity ? 0 : left.severity === \"error\" ? -1 : 1) ||\n right.count - left.count ||\n (left.code < right.code ? -1 : 1),\n );\n\n return { counts: report.counts, ok: report.ok, groups };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAqCA,IAAa,qBAAb,cAAwC,MAAM;CAC5C,AAAgB;CAEhB,AAAO,YAAY,YAAoB,SAAiB;EACtD,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,aAAa;CACpB;AACF;;AAgEA,SAAS,IAAY,UAA4B,OAA2C;CAC1F,IAAI;EACF,OAAO,KAAK,UAAU,KAAK;CAC7B,SAAS,OAAO;EACd,MAAM,OAAQ,MAA6B;EAE3C,IAAI,OAAO,SAAS,YAAY,eAAe,IAAI,GACjD,MAAM,IAAI,mBAAmB,SAAS,WAAW,MAAM,KAAM,MAAgB,OAAO;EAGtF,MAAM;CACR;AACF;AAEA,SAAS,SAAS,OAA2B,MAAsB;CACjE,IAAI,UAAU,UAAa,UAAU,IAAI,MAAM,IAAI,mBAAmB,KAAK,YAA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,WAAW,OAAO,UAC3B,OAAO,IAAI,QAAQ,MAAM,CAAC,GAAI,OAAO,IAAI,QAAQ,IAAI,KAAK,CAAC,GAAI,OAAO,CAAC;CAGzE,MAAM,SAA+B,CAAC;CAEtC,KAAK,MAAM,CAAC,MAAM,aAAa,QAAQ;EACrC,MAAM,aAAa,oBAAoB,IAAI;EAC3C,MAAM,aAAa,SAAS,QAAQ,YAAY,CAAC,QAAQ,QAAQ;EACjE,MAAM,2BAAW,IAAI,IAAoB;EAEzC,KAAK,MAAM,WAAW,YAAY;GAChC,MAAM,UAAU,iBAAiB,OAAO;GAExC,SAAS,IAAI,UAAU,SAAS,IAAI,OAAO,KAAK,KAAK,CAAC;EACxD;EAEA,OAAO,KAAK;GACV;GACA,UAAU,SAAS,EAAE,EAAE,YAAY,YAAY,YAAY;GAC3D,MAAM,YAAY,QAAQ;GAC1B,OAAO,YAAY,SAAS;GAC5B,KAAK,YAAY,OAAO,SAAS,EAAE,EAAE,QAAQ;GAC7C,OAAO,WAAW;GAClB,UAAU,SAAS,SAAS,WAAW;GACvC,UAAU,CAAC,GAAG,QAAQ,CAAC,CACpB,KAAK,CAAC,SAAS,YAAY;IAAE;IAAS;GAAM,EAAE,CAAC,CAC/C,MAAM,MAAM,UAAU,MAAM,QAAQ,KAAK,UAAU,KAAK,UAAU,MAAM,UAAU,KAAK,EAAE;EAC9F,CAAC;CACH;CAEA,OAAO,MACJ,MAAM,WACJ,KAAK,aAAa,MAAM,WAAW,IAAI,KAAK,aAAa,UAAU,KAAK,MACzE,MAAM,QAAQ,KAAK,UAClB,KAAK,OAAO,MAAM,OAAO,KAAK,EACnC;CAEA,OAAO;EAAE,QAAQ,OAAO;EAAQ,IAAI,OAAO;EAAI;CAAO;AACxD"}
1
+ {"version":3,"file":"data.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/devtools/data.ts"],"sourcesContent":["/**\n * The answers of the tab, as functions of the snapshot. The devtools routes\n * and the static export both call them; questions about one item go to\n * `scry()`, the rest read the snapshot directly.\n */\nimport { explainGrimoireCode, isGrimoireCode } from \"../codes\";\nimport { checkGrimoire } from \"../check\";\nimport type { BookHost, BookPage, BookScreen } from \"../contracts/adapter\";\nimport type { TasksIndex, FeaturesIndex } from \"../contracts/bookmap\";\nimport type { GrimoireCheckReport, GrimoireFinding, RouteFreshness } from \"../contracts/findings\";\nimport type {\n ScryFeatureResult,\n ScryFileResult,\n ScryFlowResult,\n ScryImpactResult,\n ScryRouteResult,\n ScrySearchResult,\n} from \"../contracts/scry\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\nimport type { WrittenApp, WrittenLayout, WrittenPage, WrittenRelease } from \"../contracts/written\";\nimport { scry } from \"../scry\";\nimport { compactFlow, STEP_FILE_SETS, stepFilePage } from \"../scry/compact\";\nimport { testResultsInfo } from \"../test-results\";\nimport { featureFileGroups, featureMap, featureProofs } from \"./feature-map\";\nimport { featureGraph, fileGraph, moduleGraph, pageGraph, type GrimoireGraph } from \"./graphs\";\nimport {\n STEP_FILES_PAGE_LIMIT,\n type GrimoireFeatureAnswer,\n type GrimoireCheckFilter,\n type GrimoireCheckGroup,\n type GrimoireCheckGroups,\n type GrimoireCheckPage,\n type GrimoireFlowAnswer,\n type GrimoireStepFilesAnswer,\n type StepFileSet,\n} from \"./answers\";\nimport type { TestResultsInfo } from \"../contracts/test-results\";\n\n/** An error a route answers with a status (devtools turns `statusCode` into the response status). */\nexport class GrimoirePanelError extends Error {\n public readonly statusCode: number;\n\n public constructor(statusCode: number, message: string) {\n super(message);\n this.name = \"GrimoirePanelError\";\n this.statusCode = statusCode;\n }\n}\n\nexport type GrimoireSummary = {\n /**\n * Flow steps by what was checked: `resolved` (`found === true`) and `missing` (`found === false`) were looked up\n * in the code; `unchecked` (`found === null`, no route facts yet) were not, and never count against the health.\n */\n steps: { checked: number; resolved: number; missing: number; unchecked: number };\n routes: RouteFreshness;\n features: FeaturesIndex;\n tasks: TasksIndex;\n counts: GrimoireCheckReport[\"counts\"];\n /** Whether any feature, app, task or release is written, and how big the book is. */\n written: boolean;\n book: { files: number; modules: number; builtAt: string };\n /** How many apps, pages, screens and releases are written (the tab's navigation and overview badges). */\n apps: { apps: number; pages: number; screens: number };\n releases: number;\n /** Whether test results were read, from where, and how many proofs have one. */\n results: TestResultsInfo;\n /** Framework brand and the app's name and version from the adapter; `null` when the adapter reports none. */\n host: BookHost | null;\n};\n\n/** One feature of the listing: the index entry plus what the cards show. */\nexport type GrimoireFeatureRow = Omit<FeaturesIndex[\"features\"][number], \"flows\"> & {\n /** The README paragraph under the heading, or `null`. */\n summary: string | null;\n /** The index flows with their headings. */\n flows: (FeaturesIndex[\"features\"][number][\"flows\"][number] & { heading: string | null })[];\n};\n\nexport type GrimoireFeaturesAnswer = { features: GrimoireFeatureRow[] };\n\n/** One page or screen of an app, as the listing shows it. */\nexport type GrimoireAppRow = {\n id: string;\n type: \"page\" | \"screen\";\n /** The page route or the screen name, or `null` when the file gives none. */\n route: string | null;\n heading: string | null;\n /** `confirmed` or `inferred` when the file says so, otherwise `null`. */\n origin: \"confirmed\" | \"inferred\" | null;\n layout: string | null;\n /** How many block rows the page lists itself. */\n blocks: number;\n};\n\nexport type GrimoireAppsAnswer = {\n apps: {\n id: string;\n type: string;\n root: string;\n pages: string[];\n screens: string[];\n /** Every page and screen with what the listing needs. */\n rows: GrimoireAppRow[];\n }[];\n};\n\nexport type GrimoirePageAnswer = {\n page: WrittenPage;\n layout: WrittenLayout | null;\n book: BookPage | BookScreen | null;\n};\n\nexport type GrimoireReleasesAnswer = {\n releases: { release: string; date: string; file: string }[];\n};\n\n/** `scry()` with its not-found codes turned into a 404 and the rest into a 400. */\nfunction ask<Result>(snapshot: GrimoireSnapshot, query: Parameters<typeof scry>[1]): Result {\n try {\n return scry(snapshot, query) as Result;\n } catch (error) {\n const code = (error as { code?: unknown }).code;\n\n if (typeof code === \"string\" && isGrimoireCode(code)) {\n throw new GrimoirePanelError(code === \"GR9006\" ? 400 : 404, (error as Error).message);\n }\n\n throw error;\n }\n}\n\nfunction required(value: string | undefined, name: string): string {\n if (value === undefined || value === \"\") throw new GrimoirePanelError(400, `Missing \"${name}\".`);\n\n return value;\n}\n\nexport function summary(snapshot: GrimoireSnapshot): GrimoireSummary {\n const files = snapshot.book.facts.files;\n const written = snapshot.written;\n\n const steps = Object.values(snapshot.collected.flows).flatMap((flow) => flow.steps);\n const resolved = steps.filter((step) => step.found === true).length;\n const missing = steps.filter((step) => step.found === false).length;\n\n return {\n steps: {\n checked: resolved + missing,\n resolved,\n missing,\n unchecked: steps.length - resolved - missing,\n },\n routes: snapshot.routes,\n features: snapshot.collected.featuresIndex,\n tasks: snapshot.collected.tasksIndex,\n counts: checkGrimoire(snapshot).counts,\n written: [written.features, written.apps, written.tasks, written.releases].some(\n (items) => items.length > 0,\n ),\n book: {\n files: files.length,\n modules: new Set(files.map((file) => file.module)).size,\n builtAt: snapshot.book.manifest.builtAt,\n },\n apps: {\n apps: written.apps.length,\n pages: written.apps.reduce((total, app) => total + app.pages.length, 0),\n screens: written.apps.reduce((total, app) => total + app.screens.length, 0),\n },\n releases: written.releases.length,\n results: testResultsInfo(snapshot),\n host: snapshot.host ?? null,\n };\n}\n\n/** The features listing: the features index with each README summary and flow headings. */\nexport function features(snapshot: GrimoireSnapshot): GrimoireFeaturesAnswer {\n const written = new Map(snapshot.written.features.map((feature) => [feature.id, feature]));\n\n return {\n features: snapshot.collected.featuresIndex.features.map((entry) => {\n const source = written.get(entry.id);\n const headings = new Map(\n (source?.flows ?? []).map((flow) => [flow.id.value, flow.heading?.value ?? null]),\n );\n\n return {\n ...entry,\n summary: source?.readme?.summary ?? null,\n flows: entry.flows.map((flow) => ({ ...flow, heading: headings.get(flow.id) ?? null })),\n };\n }),\n };\n}\n\nexport function search(snapshot: GrimoireSnapshot, text: string, limit?: number): ScrySearchResult {\n return ask<ScrySearchResult>(snapshot, {\n type: \"search\",\n text,\n ...(limit !== undefined && Number.isFinite(limit) && limit > 0\n ? { limit: Math.min(limit, 100) }\n : {}),\n });\n}\n\nexport function file(snapshot: GrimoireSnapshot, path: string | undefined): ScryFileResult {\n return ask(snapshot, { type: \"file\", file: required(path, \"path\") });\n}\n\nexport function impact(snapshot: GrimoireSnapshot, path: string | undefined): ScryImpactResult {\n return ask(snapshot, { type: \"impact\", file: required(path, \"path\") });\n}\n\nexport function route(\n snapshot: GrimoireSnapshot,\n method: string | undefined,\n path: string | undefined,\n): ScryRouteResult {\n return ask(snapshot, {\n type: \"route\",\n method: required(method, \"method\"),\n path: required(path, \"path\"),\n });\n}\n\nexport function feature(snapshot: GrimoireSnapshot, id: string | undefined): GrimoireFeatureAnswer {\n const wanted = required(id, \"feature\");\n const result = ask<ScryFeatureResult>(snapshot, { type: \"feature\", feature: wanted });\n const written = snapshot.written.features.find((item) => item.id === wanted);\n\n if (written === undefined)\n throw new GrimoirePanelError(404, `No feature \"${wanted}\" is written.`);\n\n return {\n ...result,\n map: featureMap(snapshot, written),\n fileGroups: featureFileGroups(snapshot, result.bookmap.own),\n proofs: featureProofs(snapshot, written),\n };\n}\n\nexport function flow(\n snapshot: GrimoireSnapshot,\n featureId: string | undefined,\n flowId: string | undefined,\n): ScryFlowResult {\n return ask(snapshot, {\n type: \"flow\",\n feature: required(featureId, \"feature\"),\n flow: required(flowId, \"flow\"),\n });\n}\n\nexport function apps(snapshot: GrimoireSnapshot): GrimoireAppsAnswer {\n return {\n apps: snapshot.written.apps.map((app) => ({\n id: app.id.value,\n type: app.type.value,\n root: app.root.value,\n pages: app.pages.map((page) => page.id),\n screens: app.screens.map((screen) => screen.id),\n rows: [...app.pages, ...app.screens].map((item) => ({\n id: item.id,\n type: item.type,\n route: item.route?.value ?? item.screen?.value ?? null,\n heading: item.heading?.value ?? null,\n origin: item.origin?.value ?? null,\n layout: item.layout?.value ?? null,\n blocks: item.blocks.length,\n })),\n })),\n };\n}\n\nfunction findApp(snapshot: GrimoireSnapshot, id: string | undefined): WrittenApp {\n const app = snapshot.written.apps.find((candidate) => candidate.id.value === id);\n\n if (app === undefined)\n throw new GrimoirePanelError(404, `No app \"${id ?? \"\"}\" is written in grimoire/apps.`);\n\n return app;\n}\n\n/** A page or screen by its id or its route. */\nexport function findPage(app: WrittenApp, key: string): WrittenPage | undefined {\n return [...app.pages, ...app.screens].find(\n (page) => page.id === key || page.route?.value === key || page.screen?.value === key,\n );\n}\n\nexport function page(\n snapshot: GrimoireSnapshot,\n appId: string | undefined,\n key: string | undefined,\n): GrimoirePageAnswer {\n const app = findApp(snapshot, appId);\n const written = findPage(app, required(key, \"page\"));\n\n if (written === undefined) {\n throw new GrimoirePanelError(\n 404,\n `App \"${app.id.value}\" has no page or screen \"${key ?? \"\"}\".`,\n );\n }\n\n const match = snapshot.apps[app.id.value];\n const route = written.route?.value ?? written.screen?.value ?? null;\n let book: BookPage | BookScreen | null = null;\n\n if (route !== null && match?.site) {\n book =\n snapshot.book.facts.pages.find(\n (candidate) => candidate.site === match.site?.id && candidate.route === route,\n ) ?? null;\n } else if (route !== null && match?.mobile) {\n book = match.mobile.screens.find((screen) => screen.route === route) ?? null;\n }\n\n const layoutId = written.layout?.value ?? null;\n\n return {\n page: written,\n layout:\n layoutId === null ? null : (app.layouts.find((layout) => layout.id === layoutId) ?? null),\n book,\n };\n}\n\nexport function tasks(snapshot: GrimoireSnapshot): TasksIndex {\n return snapshot.collected.tasksIndex;\n}\n\nexport function releases(snapshot: GrimoireSnapshot): GrimoireReleasesAnswer {\n return {\n releases: snapshot.written.releases.map((release) => ({\n release: release.release.value,\n date: release.date.value,\n file: release.file,\n })),\n };\n}\n\nexport function release(snapshot: GrimoireSnapshot, id: string | undefined): WrittenRelease {\n const found = snapshot.written.releases.find((candidate) => candidate.release.value === id);\n\n if (found === undefined)\n throw new GrimoirePanelError(404, `No release \"${id ?? \"\"}\" in grimoire/releases.`);\n\n return found;\n}\n\nexport function check(snapshot: GrimoireSnapshot): GrimoireCheckReport {\n return checkGrimoire(snapshot);\n}\n\nfunction graphOrNotFound(graph: GrimoireGraph | null, what: string): GrimoireGraph {\n if (graph === null) throw new GrimoirePanelError(404, `${what} is not in the book.`);\n\n return graph;\n}\n\nexport function graphOfFile(snapshot: GrimoireSnapshot, path: string | undefined): GrimoireGraph {\n const target = required(path, \"path\");\n\n return graphOrNotFound(fileGraph(snapshot, target), `\"${target}\"`);\n}\n\nexport function graphOfFeature(snapshot: GrimoireSnapshot, id: string | undefined): GrimoireGraph {\n const target = required(id, \"feature\");\n\n return graphOrNotFound(featureGraph(snapshot, target), `Feature \"${target}\"`);\n}\n\nexport function graphOfPage(\n snapshot: GrimoireSnapshot,\n appId: string | undefined,\n key: string | undefined,\n): GrimoireGraph {\n const target = required(key, \"page\");\n\n return graphOrNotFound(pageGraph(snapshot, required(appId, \"app\"), target), `Page \"${target}\"`);\n}\n\nexport function graphOfModules(snapshot: GrimoireSnapshot): GrimoireGraph {\n return moduleGraph(snapshot);\n}\n\n// ── Compact flow, step files, check pages and groups ───────────────────────\n\n/** `GET /flows/:feature/:flow`: the compact flow answer (step counts, direct imports, health, neighbours). */\nexport function flowAnswer(\n snapshot: GrimoireSnapshot,\n featureId: string | undefined,\n flowId: string | undefined,\n): GrimoireFlowAnswer {\n return compactFlow(snapshot, flow(snapshot, featureId, flowId));\n}\n\n/** A whole number from a query value, or a 400 naming the parameter. */\nfunction whole(value: string | undefined, name: string, fallback: number, min: number): number {\n if (value === undefined || value === \"\") return fallback;\n\n const number = Number(value);\n\n if (!Number.isInteger(number) || number < min) {\n throw new GrimoirePanelError(400, `\"${name}\" must be a whole number of ${min} or more.`);\n }\n\n return number;\n}\n\n/** `GET /flows/:feature/:flow/steps/:index/files`: one page of a step's files. */\nexport function stepFiles(\n snapshot: GrimoireSnapshot,\n featureId: string | undefined,\n flowId: string | undefined,\n index: string | undefined,\n query: { set?: string | undefined; offset?: string | undefined; limit?: string | undefined },\n): GrimoireStepFilesAnswer {\n const feature = required(featureId, \"feature\");\n const id = required(flowId, \"flow\");\n const set = query.set === undefined || query.set === \"\" ? \"reachable\" : query.set;\n\n if (!(STEP_FILE_SETS as readonly string[]).includes(set)) {\n throw new GrimoirePanelError(\n 400,\n `Unknown set \"${set}\". Use one of: ${STEP_FILE_SETS.join(\", \")}.`,\n );\n }\n\n const stepIndex = whole(required(index, \"index\"), \"index\", 0, 0);\n const offset = whole(query.offset, \"offset\", 0, 0);\n const limit = Math.min(\n whole(query.limit, \"limit\", STEP_FILES_PAGE_LIMIT, 1),\n STEP_FILES_PAGE_LIMIT,\n );\n const written = snapshot.written.features\n .find((item) => item.id === feature)\n ?.flows.find((item) => item.id.value === id);\n const bookmap = written === undefined ? undefined : snapshot.collected.flows[written.ref];\n\n if (written === undefined || bookmap === undefined) {\n throw new GrimoirePanelError(404, `No flow ${feature}/${id} is written.`);\n }\n\n const step = bookmap.steps.find((item) => item.index === stepIndex);\n\n if (step === undefined) {\n throw new GrimoirePanelError(404, `${written.ref} has no step ${stepIndex}.`);\n }\n\n return stepFilePage(snapshot, bookmap, step, set as StepFileSet, offset, limit);\n}\n\n/** `GET /check?code=&feature=&flow=&severity=&state=&offset=&limit=`: matching findings, paged. */\nexport function checkPage(\n snapshot: GrimoireSnapshot,\n filter: GrimoireCheckFilter,\n): GrimoireCheckPage {\n const report = checkGrimoire(snapshot);\n const limit = Math.min(Math.max(1, Math.floor(filter.limit ?? 100)), 500);\n const offset = Math.max(0, Math.floor(filter.offset ?? 0));\n const code = filter.code?.trim().toUpperCase();\n const matching = report.findings.filter((finding) => {\n if (code !== undefined && code !== \"\" && finding.code !== code) return false;\n if (filter.severity !== undefined && finding.severity !== filter.severity) return false;\n if (filter.state !== undefined && finding.expected !== (filter.state === \"expected\"))\n return false;\n if (filter.flow !== undefined && filter.flow !== \"\" && finding.subject.flow !== filter.flow) {\n return false;\n }\n\n if (filter.feature !== undefined && filter.feature !== \"\") {\n return featureOfFinding(finding) === filter.feature;\n }\n\n return true;\n });\n\n return {\n ...report,\n findings: matching.slice(offset, offset + limit),\n total: matching.length,\n offset,\n limit,\n };\n}\n\n/** The feature a finding belongs to: its subject, else the feature of its flow, else `(none)`. */\nfunction featureOfFinding(finding: GrimoireFinding): string {\n return finding.subject.feature ?? finding.subject.flow?.split(\"/\")[0] ?? \"(none)\";\n}\n\n/** `GET /check/groups`: the check by code, errors first, then by count. */\nexport function checkGroups(snapshot: GrimoireSnapshot): GrimoireCheckGroups {\n const report = checkGrimoire(snapshot);\n const byCode = new Map<string, GrimoireFinding[]>();\n\n for (const finding of report.findings) {\n byCode.set(finding.code, [...(byCode.get(finding.code) ?? []), finding]);\n }\n\n const groups: GrimoireCheckGroup[] = [];\n\n for (const [code, findings] of byCode) {\n const definition = explainGrimoireCode(code);\n const unexpected = findings.filter((finding) => !finding.expected);\n const features = new Map<string, number>();\n\n for (const finding of unexpected) {\n const feature = featureOfFinding(finding);\n\n features.set(feature, (features.get(feature) ?? 0) + 1);\n }\n\n groups.push({\n code,\n severity: findings[0]?.severity ?? definition?.severity ?? \"warning\",\n area: definition?.area ?? \"\",\n title: definition?.title ?? code,\n fix: definition?.fix ?? findings[0]?.hint ?? \"\",\n count: unexpected.length,\n expected: findings.length - unexpected.length,\n features: [...features]\n .map(([feature, count]) => ({ feature, count }))\n .sort((left, right) => right.count - left.count || (left.feature < right.feature ? -1 : 1)),\n });\n }\n\n groups.sort(\n (left, right) =>\n (left.severity === right.severity ? 0 : left.severity === \"error\" ? -1 : 1) ||\n right.count - left.count ||\n (left.code < right.code ? -1 : 1),\n );\n\n return { counts: report.counts, ok: report.ok, groups };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAuCA,IAAa,qBAAb,cAAwC,MAAM;CAC5C,AAAgB;CAEhB,AAAO,YAAY,YAAoB,SAAiB;EACtD,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,aAAa;CACpB;AACF;;AAuEA,SAAS,IAAY,UAA4B,OAA2C;CAC1F,IAAI;EACF,OAAO,KAAK,UAAU,KAAK;CAC7B,SAAS,OAAO;EACd,MAAM,OAAQ,MAA6B;EAE3C,IA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,OAAO,KAAK,KAAK,CAAC;EACxD;EAEA,OAAO,KAAK;GACV;GACA,UAAU,SAAS,EAAE,EAAE,YAAY,YAAY,YAAY;GAC3D,MAAM,YAAY,QAAQ;GAC1B,OAAO,YAAY,SAAS;GAC5B,KAAK,YAAY,OAAO,SAAS,EAAE,EAAE,QAAQ;GAC7C,OAAO,WAAW;GAClB,UAAU,SAAS,SAAS,WAAW;GACvC,UAAU,CAAC,GAAG,QAAQ,CAAC,CACpB,KAAK,CAAC,SAAS,YAAY;IAAE;IAAS;GAAM,EAAE,CAAC,CAC/C,MAAM,MAAM,UAAU,MAAM,QAAQ,KAAK,UAAU,KAAK,UAAU,MAAM,UAAU,KAAK,EAAE;EAC9F,CAAC;CACH;CAEA,OAAO,MACJ,MAAM,WACJ,KAAK,aAAa,MAAM,WAAW,IAAI,KAAK,aAAa,UAAU,KAAK,MACzE,MAAM,QAAQ,KAAK,UAClB,KAAK,OAAO,MAAM,OAAO,KAAK,EACnC;CAEA,OAAO;EAAE,QAAQ,OAAO;EAAQ,IAAI,OAAO;EAAI;CAAO;AACxD"}
@@ -0,0 +1,149 @@
1
+ import { normalizeRoutePath } from "../bookmap/steps.mjs";
2
+ import "../bookmap/index.mjs";
3
+ import { flowOrder } from "../scry/compact.mjs";
4
+
5
+ //#region ../../packages/grimoire/src/devtools/feature-map.ts
6
+ /**
7
+ * What the tabbed feature page draws beyond the scry answer: the feature map
8
+ * (flows by the places they run), the own files by module and the proof of
9
+ * each flow. Built from the step matches the book maps already hold; no step
10
+ * is resolved again.
11
+ */
12
+ const byText = (left, right) => left < right ? -1 : left > right ? 1 : 0;
13
+ const BACKGROUND = /* @__PURE__ */ new Set([
14
+ "mail",
15
+ "job",
16
+ "event",
17
+ "notification"
18
+ ]);
19
+ /** Which written app each page, setup or screen file belongs to (only the apps asked for). */
20
+ function fileApps(snapshot, wanted) {
21
+ const owners = /* @__PURE__ */ new Map();
22
+ for (const [appId, match] of Object.entries(snapshot.apps)) {
23
+ if (!wanted.has(appId)) continue;
24
+ if (match.site) for (const page of snapshot.book.facts.pages) {
25
+ if (page.site !== match.site.id) continue;
26
+ owners.set(page.file, appId);
27
+ if (page.setupFile !== null) owners.set(page.setupFile, appId);
28
+ }
29
+ for (const screen of match.mobile?.screens ?? []) owners.set(screen.file, appId);
30
+ }
31
+ return owners;
32
+ }
33
+ function writtenPage(app, route) {
34
+ if (app === void 0) return void 0;
35
+ const wanted = normalizeRoutePath(route);
36
+ return [...app.pages, ...app.screens].find((page) => {
37
+ const own = page.route?.value ?? page.screen?.value ?? null;
38
+ return own !== null && normalizeRoutePath(own) === wanted;
39
+ });
40
+ }
41
+ /** The feature map of one feature. */
42
+ function featureMap(snapshot, feature) {
43
+ const apps = new Map(snapshot.written.apps.map((app) => [app.id.value, app]));
44
+ const appIds = new Set((feature.readme?.apps ?? []).map((app) => app.value));
45
+ for (const flow of feature.flows) for (const step of flow.steps) if (step.app) appIds.add(step.app);
46
+ const owners = fileApps(snapshot, appIds);
47
+ const firstSite = [...appIds].find((id) => apps.get(id)?.type.value === "site") ?? null;
48
+ const columns = /* @__PURE__ */ new Map();
49
+ const rows = [];
50
+ const columnOf = (id, title, type) => {
51
+ if (!columns.has(id)) columns.set(id, {
52
+ id,
53
+ title,
54
+ type
55
+ });
56
+ return id;
57
+ };
58
+ const appColumn = (appId) => {
59
+ const app = apps.get(appId);
60
+ return columnOf(`app:${appId}`, app?.heading?.value ?? appId, app?.type.value ?? snapshot.apps[appId]?.type ?? "site");
61
+ };
62
+ for (const flow of flowOrder(feature)) {
63
+ const steps = snapshot.collected.flows[flow.ref]?.steps ?? [];
64
+ const written = new Map(flow.steps.map((step) => [step.index, step]));
65
+ const cells = {};
66
+ const add = (column, chip) => {
67
+ const cell = cells[column] ??= [];
68
+ if (!cell.some((item) => item.label === chip.label && item.type === chip.type)) cell.push(chip);
69
+ };
70
+ for (const step of steps) {
71
+ const source = written.get(step.index);
72
+ const entry = step.entry ?? null;
73
+ const base = {
74
+ step: step.index,
75
+ type: step.type,
76
+ found: step.found,
77
+ file: entry
78
+ };
79
+ if (step.type === "route") {
80
+ const method = source?.route?.method ?? null;
81
+ const path = source?.route?.path ?? null;
82
+ add(columnOf("api", "API", "api"), {
83
+ ...base,
84
+ label: method === null || path === null ? step.target : `${method} ${path}`,
85
+ app: null,
86
+ page: null,
87
+ method,
88
+ path
89
+ });
90
+ } else if (step.type === "page") {
91
+ const route = source?.target ?? step.target;
92
+ const scoped = source?.app ?? null;
93
+ const matched = step.entries.map((file) => owners.get(file)).find((id) => id !== void 0);
94
+ const appId = scoped ?? matched ?? firstSite;
95
+ add(appId === null ? columnOf("other", "Not placed", "other") : appColumn(appId), {
96
+ ...base,
97
+ label: route,
98
+ app: appId,
99
+ page: appId === null ? null : writtenPage(apps.get(appId), route)?.id ?? null,
100
+ method: null,
101
+ path: null
102
+ });
103
+ } else if (BACKGROUND.has(step.type)) add(columnOf("background", "Background", "background"), {
104
+ ...base,
105
+ label: source?.target ?? step.target,
106
+ app: null,
107
+ page: null,
108
+ method: null,
109
+ path: null
110
+ });
111
+ }
112
+ rows.push({
113
+ flow: flow.id.value,
114
+ heading: flow.heading?.value ?? null,
115
+ status: flow.status.value,
116
+ cells
117
+ });
118
+ }
119
+ const rank = (column) => column.type === "site" ? 0 : column.type === "mobile" ? 1 : column.type === "api" ? 2 : column.type === "background" ? 3 : 4;
120
+ return {
121
+ columns: [...columns.values()].sort((left, right) => rank(left) - rank(right) || byText(left.title, right.title)),
122
+ rows
123
+ };
124
+ }
125
+ /** The feature's own files grouped by module (modules and files sorted). */
126
+ function featureFileGroups(snapshot, own) {
127
+ const modules = new Map(snapshot.book.facts.files.map((item) => [item.file, item.module]));
128
+ const groups = /* @__PURE__ */ new Map();
129
+ for (const file of own) {
130
+ const module = modules.get(file) ?? "";
131
+ groups.set(module, [...groups.get(module) ?? [], file]);
132
+ }
133
+ return [...groups.entries()].sort(([left], [right]) => byText(left, right)).map(([module, files]) => ({
134
+ module,
135
+ files: [...files].sort(byText)
136
+ }));
137
+ }
138
+ /** The criteria of each flow with the tests behind them, in the README's flow order. */
139
+ function featureProofs(snapshot, feature) {
140
+ return flowOrder(feature).map((flow) => ({
141
+ flow: flow.id.value,
142
+ heading: flow.heading?.value ?? null,
143
+ criteria: snapshot.collected.flows[flow.ref]?.criteria ?? []
144
+ }));
145
+ }
146
+
147
+ //#endregion
148
+ export { featureFileGroups, featureMap, featureProofs };
149
+ //# sourceMappingURL=feature-map.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature-map.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/devtools/feature-map.ts"],"sourcesContent":["/**\n * What the tabbed feature page draws beyond the scry answer: the feature map\n * (flows by the places they run), the own files by module and the proof of\n * each flow. Built from the step matches the book maps already hold; no step\n * is resolved again.\n */\nimport { normalizeRoutePath } from \"../bookmap\";\nimport type { FlowBookmapStep } from \"../contracts/bookmap\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\nimport type { WrittenApp, WrittenFeature, WrittenPage, WrittenStep } from \"../contracts/written\";\nimport { flowOrder } from \"../scry/compact\";\nimport type {\n GrimoireFeatureFileGroup,\n GrimoireFeatureMap,\n GrimoireFeatureMapChip,\n GrimoireFeatureMapColumn,\n GrimoireFeatureProof,\n} from \"./answers\";\n\nconst byText = (left: string, right: string): number => (left < right ? -1 : left > right ? 1 : 0);\n\nconst BACKGROUND = new Set([\"mail\", \"job\", \"event\", \"notification\"]);\n\n/** Which written app each page, setup or screen file belongs to (only the apps asked for). */\nfunction fileApps(snapshot: GrimoireSnapshot, wanted: ReadonlySet<string>): Map<string, string> {\n const owners = new Map<string, string>();\n\n for (const [appId, match] of Object.entries(snapshot.apps)) {\n if (!wanted.has(appId)) continue;\n\n if (match.site) {\n for (const page of snapshot.book.facts.pages) {\n if (page.site !== match.site.id) continue;\n\n owners.set(page.file, appId);\n if (page.setupFile !== null) owners.set(page.setupFile, appId);\n }\n }\n\n for (const screen of match.mobile?.screens ?? []) owners.set(screen.file, appId);\n }\n\n return owners;\n}\n\nfunction writtenPage(app: WrittenApp | undefined, route: string): WrittenPage | undefined {\n if (app === undefined) return undefined;\n\n const wanted = normalizeRoutePath(route);\n\n return [...app.pages, ...app.screens].find((page) => {\n const own = page.route?.value ?? page.screen?.value ?? null;\n\n return own !== null && normalizeRoutePath(own) === wanted;\n });\n}\n\n/** The feature map of one feature. */\nexport function featureMap(\n snapshot: GrimoireSnapshot,\n feature: WrittenFeature,\n): GrimoireFeatureMap {\n const apps = new Map(snapshot.written.apps.map((app) => [app.id.value, app]));\n const appIds = new Set((feature.readme?.apps ?? []).map((app) => app.value));\n\n for (const flow of feature.flows)\n for (const step of flow.steps) if (step.app) appIds.add(step.app);\n\n const owners = fileApps(snapshot, appIds);\n const firstSite = [...appIds].find((id) => apps.get(id)?.type.value === \"site\") ?? null;\n const columns = new Map<string, GrimoireFeatureMapColumn>();\n const rows: GrimoireFeatureMap[\"rows\"] = [];\n\n const columnOf = (id: string, title: string, type: GrimoireFeatureMapColumn[\"type\"]): string => {\n if (!columns.has(id)) columns.set(id, { id, title, type });\n\n return id;\n };\n\n const appColumn = (appId: string): string => {\n const app = apps.get(appId);\n\n return columnOf(\n `app:${appId}`,\n app?.heading?.value ?? appId,\n app?.type.value ?? snapshot.apps[appId]?.type ?? \"site\",\n );\n };\n\n for (const flow of flowOrder(feature)) {\n const steps: readonly FlowBookmapStep[] = snapshot.collected.flows[flow.ref]?.steps ?? [];\n const written = new Map<number, WrittenStep>(flow.steps.map((step) => [step.index, step]));\n const cells: Record<string, GrimoireFeatureMapChip[]> = {};\n const add = (column: string, chip: GrimoireFeatureMapChip): void => {\n const cell = (cells[column] ??= []);\n\n if (!cell.some((item) => item.label === chip.label && item.type === chip.type))\n cell.push(chip);\n };\n\n for (const step of steps) {\n const source = written.get(step.index);\n const entry = step.entry ?? null;\n const base = { step: step.index, type: step.type, found: step.found, file: entry };\n\n if (step.type === \"route\") {\n const method = source?.route?.method ?? null;\n const path = source?.route?.path ?? null;\n\n add(columnOf(\"api\", \"API\", \"api\"), {\n ...base,\n label: method === null || path === null ? step.target : `${method} ${path}`,\n app: null,\n page: null,\n method,\n path,\n });\n } else if (step.type === \"page\") {\n const route = source?.target ?? step.target;\n const scoped = source?.app ?? null;\n const matched = step.entries.map((file) => owners.get(file)).find((id) => id !== undefined);\n const appId = scoped ?? matched ?? firstSite;\n const column = appId === null ? columnOf(\"other\", \"Not placed\", \"other\") : appColumn(appId);\n\n add(column, {\n ...base,\n label: route,\n app: appId,\n page: appId === null ? null : (writtenPage(apps.get(appId), route)?.id ?? null),\n method: null,\n path: null,\n });\n } else if (BACKGROUND.has(step.type)) {\n add(columnOf(\"background\", \"Background\", \"background\"), {\n ...base,\n label: source?.target ?? step.target,\n app: null,\n page: null,\n method: null,\n path: null,\n });\n }\n }\n\n rows.push({\n flow: flow.id.value,\n heading: flow.heading?.value ?? null,\n status: flow.status.value,\n cells,\n });\n }\n\n const rank = (column: GrimoireFeatureMapColumn): number =>\n column.type === \"site\"\n ? 0\n : column.type === \"mobile\"\n ? 1\n : column.type === \"api\"\n ? 2\n : column.type === \"background\"\n ? 3\n : 4;\n\n return {\n columns: [...columns.values()].sort(\n (left, right) => rank(left) - rank(right) || byText(left.title, right.title),\n ),\n rows,\n };\n}\n\n/** The feature's own files grouped by module (modules and files sorted). */\nexport function featureFileGroups(\n snapshot: GrimoireSnapshot,\n own: readonly string[],\n): GrimoireFeatureFileGroup[] {\n const modules = new Map(snapshot.book.facts.files.map((item) => [item.file, item.module]));\n const groups = new Map<string, string[]>();\n\n for (const file of own) {\n const module = modules.get(file) ?? \"\";\n\n groups.set(module, [...(groups.get(module) ?? []), file]);\n }\n\n return [...groups.entries()]\n .sort(([left], [right]) => byText(left, right))\n .map(([module, files]) => ({ module, files: [...files].sort(byText) }));\n}\n\n/** The criteria of each flow with the tests behind them, in the README's flow order. */\nexport function featureProofs(\n snapshot: GrimoireSnapshot,\n feature: WrittenFeature,\n): GrimoireFeatureProof[] {\n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AS,QACd,IACA,OAAO,SAAS,eACd,IACA;CAEZ,OAAO;EACL,SAAS,CAAC,GAAG,QAAQ,OAAO,CAAC,CAAC,CAAC,MAC5B,MAAM,UAAU,KAAK,IAAI,IAAI,KAAK,KAAK,KAAK,OAAO,KAAK,OAAO,MAAM,KAAK,CAC7E;EACA;CACF;AACF;;AAGA,SAAgB,kBACd,UACA,KAC4B;CAC5B,MAAM,UAAU,IAAI,IAAI,SAAS,KAAK,MAAM,MAAM,KAAK,SAAS,CAAC,KAAK,MAAM,KAAK,MAAM,CAAC,CAAC;CACzF,MAAM,yBAAS,IAAI,IAAsB;CAEzC,KAAK,MAAM,QAAQ,KAAK;EACtB,MAAM,SAAS,QAAQ,IAAI,IAAI,KAAK;EAEpC,OAAO,IAAI,QAAQ,CAAC,GAAI,OAAO,IAAI,MAAM,KAAK,CAAC,GAAI,IAAI,CAAC;CAC1D;CAEA,OAAO,CAAC,GAAG,OAAO,QAAQ,CAAC,CAAC,CACzB,MAAM,CAAC,OAAO,CAAC,WAAW,OAAO,MAAM,KAAK,CAAC,CAAC,CAC9C,KAAK,CAAC,QAAQ,YAAY;EAAE;EAAQ,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,KAAK,MAAM;CAAE,EAAE;AAC1E;;AAGA,SAAgB,cACd,UACA,SACwB;CACxB,OAAO,UAAU,OAAO,CAAC,CAAC,KAAK,UAAU;EACvC,MAAM,KAAK,GAAG;EACd,SAAS,KAAK,SAAS,SAAS;EAChC,UAAU,SAAS,UAAU,MAAM,KAAK,IAAI,EAAE,YAAY,CAAC;CAC7D,EAAE;AACJ"}
@@ -1,6 +1,6 @@
1
1
  import { BookAdapter } from "../contracts/adapter.mjs";
2
2
  import { ProductErrorSummary } from "./product-map.mjs";
3
- import { ExportGrimoireSiteOptions, exportGrimoireSite } from "./site.mjs";
3
+ import { ExportGrimoireSiteOptions, GrimoireSiteExport, buildProductSiteData, exportGrimoireSite, exportGrimoireSiteDetailed } from "./site.mjs";
4
4
  //#region ../../packages/grimoire/src/devtools/index.d.ts
5
5
  /** The parts of devtools' `DevtoolsPanelRequest` the routes read. */
6
6
  export type GrimoirePanelRequest = {
@@ -68,5 +68,5 @@ export type GrimoirePanelContext = {
68
68
  /** Build the panel for the app at `root`. */
69
69
  export declare function grimoireDevtoolsPanel(context: GrimoirePanelContext): Promise<GrimoireDevtoolsPanel>;
70
70
  //#endregion
71
- export { type ExportGrimoireSiteOptions, grimoireDevtoolsPanel as default, exportGrimoireSite };
71
+ export { type ExportGrimoireSiteOptions, type GrimoireSiteExport, buildProductSiteData, grimoireDevtoolsPanel as default, exportGrimoireSite, exportGrimoireSiteDetailed };
72
72
  //# sourceMappingURL=index.d.mts.map
@@ -1,7 +1,7 @@
1
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
2
  import { productFeature, productFlow, productMap } from "./product-map.mjs";
3
3
  import { createSnapshotSource } from "./snapshot-source.mjs";
4
- import { exportGrimoireSite } from "./site.mjs";
4
+ import { buildProductSiteData, exportGrimoireSite, exportGrimoireSiteDetailed } from "./site.mjs";
5
5
  import path from "node:path";
6
6
 
7
7
  //#region ../../packages/grimoire/src/devtools/index.ts
@@ -50,13 +50,34 @@ async function grimoireDevtoolsPanel(context) {
50
50
  const offset = number(one(query, "offset"));
51
51
  const limit = number(one(query, "limit"));
52
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;
53
+ if (code) {
54
+ filter.code = code;
55
+ any = true;
56
+ }
57
+ if (feature) {
58
+ filter.feature = feature;
59
+ any = true;
60
+ }
61
+ if (flow) {
62
+ filter.flow = flow;
63
+ any = true;
64
+ }
65
+ if (severity === "error" || severity === "warning") {
66
+ filter.severity = severity;
67
+ any = true;
68
+ }
69
+ if (state === "expected" || state === "unexpected") {
70
+ filter.state = state;
71
+ any = true;
72
+ }
73
+ if (offset !== void 0) {
74
+ filter.offset = offset;
75
+ any = true;
76
+ }
77
+ if (limit !== void 0) {
78
+ filter.limit = limit;
79
+ any = true;
80
+ }
60
81
  return any ? filter : null;
61
82
  };
62
83
  return {
@@ -188,5 +209,5 @@ async function grimoireDevtoolsPanel(context) {
188
209
  }
189
210
 
190
211
  //#endregion
191
- export { grimoireDevtoolsPanel as default, grimoireDevtoolsPanel, exportGrimoireSite };
212
+ export { buildProductSiteData, grimoireDevtoolsPanel as default, grimoireDevtoolsPanel, exportGrimoireSite, exportGrimoireSiteDetailed };
192
213
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
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,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;EAC9D,GAAI,QAAQ,oBAAoB,SAAY,CAAC,IAAI,EAAE,iBAAiB,QAAQ,gBAAgB;CAC9F,CAAC;CAGD,IAAI,QAAQ,SAAS,cAAc,OAAO,KAAK;CAE/C,MAAM,UACK,SACT,OAAO,YACL,KAAK,MAAM,OAAO,IAAI,GAAG,OAAO;;CAGpC,MAAM,WAEF,SAMF,OAAO,YAAmD;EACxD,MAAM,WAAW,MAAM,OAAO,IAAI;EAClC,IAAI,SAAgD;EAEpD,IAAI;GACF,SAAU,MAAM,QAAQ,SAAS,KAAM;EACzC,QAAQ;GACN,SAAS;EACX;EAEA,OAAO,KAAK,UAAU,SAAS;GAAE,QAAQ,QAAQ,WAAW;GAAM;EAAO,CAAC;CAC5E;CAEF,MAAM,UAAU,UAAkD;EAChE,IAAI,UAAU,UAAa,UAAU,IAAI,OAAO;EAEhD,MAAM,SAAS,OAAO,KAAK;EAE3B,OAAO,OAAO,SAAS,MAAM,IAAI,SAAS;CAC5C;CAEA,MAAM,eAAe,UAAqE;EACxF,MAAM,SAA8B,CAAC;EACrC,MAAM,OAAO,IAAI,OAAO,MAAM;EAC9B,M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SAAS,UAAU,EAAE,UAAU,YACtC,YAAY,UAAU,OAAO,SAAS,OAAO,MAAM,OAAO,CAC5D;GACF;GACA;IAAE,MAAM;IAAS,SAAS,QAAQ,aAAaC,KAAU,QAAQ,CAAC;GAAE;GACpE;IACE,MAAM;IACN,SAAS,QAAQ,UAAU,EAAE,aAAaC,KAAU,UAAU,OAAO,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"}
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 { buildProductSiteData, exportGrimoireSite, exportGrimoireSiteDetailed } from \"./site\";\nexport type { ExportGrimoireSiteOptions, GrimoireSiteExport } 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 // The panel runs inside the app's own process. Collecting route facts there boots every connector and\n // re-imports the route and event modules, which would register them twice in the live app. So the tab\n // reads the cached facts and says \"missing\" or \"stale\" until `warlock grimoire build` runs elsewhere.\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) {\n filter.code = code;\n any = true;\n }\n if (feature) {\n filter.feature = feature;\n any = true;\n }\n if (flow) {\n filter.flow = flow;\n any = true;\n }\n if (severity === \"error\" || severity === \"warning\") {\n filter.severity = severity;\n any = true;\n }\n if (state === \"expected\" || state === \"unexpected\") {\n filter.state = state;\n any = true;\n }\n if (offset !== undefined) {\n filter.offset = offset;\n any = true;\n }\n if (limit !== undefined) {\n filter.limit = limit;\n any = true;\n }\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 {\n path: \"/product\",\n handler: product((snapshot, _request, options) => productMap(snapshot, options)),\n },\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,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;EAItB,GAAI,QAAQ,YAAY,SAAY,CAAC,IAAI,EAAE,S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AAU,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"}
@@ -1 +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"}
1
+ {"version":3,"file":"product-map.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/devtools/product-map.ts"],"mappings":";;YAqCY;;EAEV;EACA;EACA;EACA;EACA;EACA;EACA"}