@wastech-mdlint/viewer 0.0.0-stage → 0.4.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 (189) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +86 -2
  3. package/assets/favicon.ico +0 -0
  4. package/assets/viewer.css +4184 -0
  5. package/dist/asset-routes.d.ts +4 -0
  6. package/dist/asset-routes.js +107 -0
  7. package/dist/blame.d.ts +8 -0
  8. package/dist/blame.js +54 -0
  9. package/dist/branch-changes.d.ts +8 -0
  10. package/dist/branch-changes.js +49 -0
  11. package/dist/candidate-lint-worker.d.ts +1 -0
  12. package/dist/candidate-lint-worker.js +67 -0
  13. package/dist/candidate-lint.d.ts +39 -0
  14. package/dist/candidate-lint.js +115 -0
  15. package/dist/change-banner.d.ts +38 -0
  16. package/dist/change-banner.js +108 -0
  17. package/dist/change-diff.d.ts +23 -0
  18. package/dist/change-diff.js +140 -0
  19. package/dist/change-marks.d.ts +32 -0
  20. package/dist/change-marks.js +363 -0
  21. package/dist/changes-article.d.ts +15 -0
  22. package/dist/changes-article.js +244 -0
  23. package/dist/changes-routes.d.ts +12 -0
  24. package/dist/changes-routes.js +271 -0
  25. package/dist/changes.d.ts +113 -0
  26. package/dist/changes.js +324 -0
  27. package/dist/cli-args.d.ts +21 -0
  28. package/dist/cli-args.js +93 -0
  29. package/dist/client/banner-height.d.ts +1 -0
  30. package/dist/client/banner-height.js +33 -0
  31. package/dist/client/change-marks.d.ts +1 -0
  32. package/dist/client/change-marks.js +56 -0
  33. package/dist/client/changes.d.ts +1 -0
  34. package/dist/client/changes.js +183 -0
  35. package/dist/client/chart-option.d.ts +3 -0
  36. package/dist/client/chart-option.js +76 -0
  37. package/dist/client/charts.d.ts +1 -0
  38. package/dist/client/charts.js +54 -0
  39. package/dist/client/clipboard.d.ts +1 -0
  40. package/dist/client/clipboard.js +43 -0
  41. package/dist/client/code-copy.d.ts +1 -0
  42. package/dist/client/code-copy.js +29 -0
  43. package/dist/client/column-resize.d.ts +1 -0
  44. package/dist/client/column-resize.js +120 -0
  45. package/dist/client/config-dom.d.ts +13 -0
  46. package/dist/client/config-dom.js +47 -0
  47. package/dist/client/config-draft.d.ts +73 -0
  48. package/dist/client/config-draft.js +218 -0
  49. package/dist/client/config-editor.d.ts +3 -0
  50. package/dist/client/config-editor.js +677 -0
  51. package/dist/client/config-fields.d.ts +35 -0
  52. package/dist/client/config-fields.js +339 -0
  53. package/dist/client/config-json.d.ts +18 -0
  54. package/dist/client/config-json.js +96 -0
  55. package/dist/client/config-preview.d.ts +9 -0
  56. package/dist/client/config-preview.js +91 -0
  57. package/dist/client/config-rules.d.ts +14 -0
  58. package/dist/client/config-rules.js +202 -0
  59. package/dist/client/config-types.d.ts +91 -0
  60. package/dist/client/config-types.js +4 -0
  61. package/dist/client/copy-path.d.ts +1 -0
  62. package/dist/client/copy-path.js +32 -0
  63. package/dist/client/dashboard-requests.d.ts +11 -0
  64. package/dist/client/dashboard-requests.js +28 -0
  65. package/dist/client/dashboard.d.ts +1 -0
  66. package/dist/client/dashboard.js +119 -0
  67. package/dist/client/diagnostics.d.ts +1 -0
  68. package/dist/client/diagnostics.js +164 -0
  69. package/dist/client/diagrams.d.ts +1 -0
  70. package/dist/client/diagrams.js +81 -0
  71. package/dist/client/diff-expand.d.ts +1 -0
  72. package/dist/client/diff-expand.js +42 -0
  73. package/dist/client/display-settings-model.d.ts +74 -0
  74. package/dist/client/display-settings-model.js +229 -0
  75. package/dist/client/display-settings.d.ts +1 -0
  76. package/dist/client/display-settings.js +411 -0
  77. package/dist/client/echarts.d.ts +30 -0
  78. package/dist/client/echarts.js +14 -0
  79. package/dist/client/graph-layout.d.ts +88 -0
  80. package/dist/client/graph-layout.js +198 -0
  81. package/dist/client/graph.d.ts +2 -0
  82. package/dist/client/graph.js +566 -0
  83. package/dist/client/history.d.ts +21 -0
  84. package/dist/client/history.js +86 -0
  85. package/dist/client/live-reload-model.d.ts +28 -0
  86. package/dist/client/live-reload-model.js +52 -0
  87. package/dist/client/live-reload.d.ts +9 -0
  88. package/dist/client/live-reload.js +138 -0
  89. package/dist/client/menu.d.ts +14 -0
  90. package/dist/client/menu.js +176 -0
  91. package/dist/client/navigation-feedback.d.ts +1 -0
  92. package/dist/client/navigation-feedback.js +141 -0
  93. package/dist/client/open-config.d.ts +1 -0
  94. package/dist/client/open-config.js +48 -0
  95. package/dist/client/outline-spy.d.ts +1 -0
  96. package/dist/client/outline-spy.js +60 -0
  97. package/dist/client/prompts.d.ts +7 -0
  98. package/dist/client/prompts.js +65 -0
  99. package/dist/client/review.d.ts +1 -0
  100. package/dist/client/review.js +379 -0
  101. package/dist/client/search.d.ts +1 -0
  102. package/dist/client/search.js +199 -0
  103. package/dist/client/segmented.d.ts +13 -0
  104. package/dist/client/segmented.js +70 -0
  105. package/dist/client/source-lines.d.ts +16 -0
  106. package/dist/client/source-lines.js +47 -0
  107. package/dist/client/theme-toggle.d.ts +10 -0
  108. package/dist/client/theme-toggle.js +100 -0
  109. package/dist/client/theme.d.ts +0 -0
  110. package/dist/client/theme.js +50 -0
  111. package/dist/client/tree-marks.d.ts +31 -0
  112. package/dist/client/tree-marks.js +102 -0
  113. package/dist/client/tree-state.d.ts +0 -0
  114. package/dist/client/tree-state.js +179 -0
  115. package/dist/client/viewer.d.ts +1 -0
  116. package/dist/client/viewer.js +53 -0
  117. package/dist/config-editor.d.ts +166 -0
  118. package/dist/config-editor.js +378 -0
  119. package/dist/config-routes.d.ts +18 -0
  120. package/dist/config-routes.js +213 -0
  121. package/dist/context-view.d.ts +41 -0
  122. package/dist/context-view.js +295 -0
  123. package/dist/corpus-routes.d.ts +31 -0
  124. package/dist/corpus-routes.js +258 -0
  125. package/dist/corpus.d.ts +134 -0
  126. package/dist/corpus.js +653 -0
  127. package/dist/dashboard-article.d.ts +14 -0
  128. package/dist/dashboard-article.js +290 -0
  129. package/dist/dashboard.d.ts +94 -0
  130. package/dist/dashboard.js +468 -0
  131. package/dist/diagnostics.d.ts +23 -0
  132. package/dist/diagnostics.js +44 -0
  133. package/dist/document-routes.d.ts +39 -0
  134. package/dist/document-routes.js +396 -0
  135. package/dist/event-hub.d.ts +39 -0
  136. package/dist/event-hub.js +120 -0
  137. package/dist/findings-panel.d.ts +4 -0
  138. package/dist/findings-panel.js +74 -0
  139. package/dist/folder-page.d.ts +8 -0
  140. package/dist/folder-page.js +74 -0
  141. package/dist/graph-view.d.ts +66 -0
  142. package/dist/graph-view.js +236 -0
  143. package/dist/highlight.d.ts +24 -0
  144. package/dist/highlight.js +100 -0
  145. package/dist/http-send.d.ts +9 -0
  146. package/dist/http-send.js +53 -0
  147. package/dist/index.d.ts +2 -0
  148. package/dist/index.js +72 -0
  149. package/dist/open-file.d.ts +36 -0
  150. package/dist/open-file.js +87 -0
  151. package/dist/page-tree.d.ts +3 -0
  152. package/dist/page-tree.js +105 -0
  153. package/dist/page.d.ts +73 -0
  154. package/dist/page.js +478 -0
  155. package/dist/prompts.d.ts +25 -0
  156. package/dist/prompts.js +82 -0
  157. package/dist/render-cache.d.ts +23 -0
  158. package/dist/render-cache.js +38 -0
  159. package/dist/render-document.d.ts +60 -0
  160. package/dist/render-document.js +440 -0
  161. package/dist/request-path.d.ts +17 -0
  162. package/dist/request-path.js +51 -0
  163. package/dist/review-context.d.ts +24 -0
  164. package/dist/review-context.js +109 -0
  165. package/dist/review-queries.d.ts +26 -0
  166. package/dist/review-queries.js +69 -0
  167. package/dist/review-state.d.ts +106 -0
  168. package/dist/review-state.js +251 -0
  169. package/dist/review-store.d.ts +145 -0
  170. package/dist/review-store.js +530 -0
  171. package/dist/router.d.ts +28 -0
  172. package/dist/router.js +294 -0
  173. package/dist/search.d.ts +22 -0
  174. package/dist/search.js +164 -0
  175. package/dist/security.d.ts +95 -0
  176. package/dist/security.js +196 -0
  177. package/dist/server.d.ts +21 -0
  178. package/dist/server.js +224 -0
  179. package/dist/speculation-rules.d.ts +4 -0
  180. package/dist/speculation-rules.js +49 -0
  181. package/dist/state-dir.d.ts +6 -0
  182. package/dist/state-dir.js +31 -0
  183. package/dist/tree-marks.d.ts +49 -0
  184. package/dist/tree-marks.js +108 -0
  185. package/dist/viewer-context.d.ts +37 -0
  186. package/dist/viewer-context.js +74 -0
  187. package/dist/watch.d.ts +41 -0
  188. package/dist/watch.js +135 -0
  189. package/package.json +57 -4
@@ -0,0 +1,290 @@
1
+ import { h } from "hastscript";
2
+ import { dashboardHref, dashboardSearchParams, DEFAULT_SORT, defaultDirection, LINK_FLAGS, } from "./dashboard.js";
3
+ import { FIRST_SCREEN_ID } from "./page.js";
4
+ import { documentHref } from "./render-document.js";
5
+ // The dashboard page's article: the filter form, the summary line and the table of rows `dashboard.ts`
6
+ // selected and ordered. Nothing here filters or counts; it lays out what it is given.
7
+ const LINK_FLAG_LABELS = {
8
+ orphan: "Orphan: nothing links here",
9
+ "dead-end": "Dead end: links nowhere",
10
+ cycle: "In a link cycle",
11
+ detached: "Detached: outside the main group",
12
+ };
13
+ const LINK_FLAG_NAMES = {
14
+ orphan: "orphan",
15
+ "dead-end": "dead end",
16
+ cycle: "cycle",
17
+ detached: "detached",
18
+ };
19
+ export function renderDashboardArticle(page) {
20
+ return [
21
+ h("h1", "Dashboard"),
22
+ renderFilters(page.params, page.source, page.ok ? page.query : undefined),
23
+ h("p.dashboard-summary", { role: "status" }, page.ok ? summaryText(page.result) : "These filters cannot be applied."),
24
+ h("div.dashboard-results", page.ok
25
+ ? renderResults(page.query, page.result, page.source.changes !== undefined)
26
+ : [h("p.dashboard-error", page.message)]),
27
+ ];
28
+ }
29
+ // The form's controls, each showing back the value the address carries, as written.
30
+ class FilterControls {
31
+ params;
32
+ constructor(params) {
33
+ this.params = params;
34
+ }
35
+ first(key) {
36
+ return this.params.get(key) ?? "";
37
+ }
38
+ checkbox(name, value, label) {
39
+ return h("label.filter-check", [
40
+ h("input", {
41
+ type: "checkbox",
42
+ name,
43
+ value,
44
+ checked: this.params.getAll(name).includes(value),
45
+ }),
46
+ " ",
47
+ label,
48
+ ]);
49
+ }
50
+ range(label, min, max, step) {
51
+ return h("div.filter-range", [
52
+ h("span.filter-range-label", label),
53
+ h("label", [
54
+ h("span.visually-hidden", `${label} from`),
55
+ this.bound(min, step, "from"),
56
+ ]),
57
+ h("span.filter-range-dash", { ariaHidden: "true" }, "–"),
58
+ h("label", [
59
+ h("span.visually-hidden", `${label} to`),
60
+ this.bound(max, step, "to"),
61
+ ]),
62
+ ]);
63
+ }
64
+ bound(name, step, placeholder) {
65
+ return h("input", {
66
+ type: "number",
67
+ name,
68
+ value: this.first(name),
69
+ min: "0",
70
+ step,
71
+ inputMode: "decimal",
72
+ placeholder,
73
+ });
74
+ }
75
+ }
76
+ function renderFilters(params, source, query) {
77
+ const controls = new FilterControls(params);
78
+ return h("form.dashboard-filters", { action: "/dashboard", method: "get", ariaLabel: "Filters" }, [
79
+ h("fieldset.filter-group", [
80
+ h("legend", "Findings"),
81
+ h("div.filter-options", [
82
+ controls.checkbox("severity", "error", "Errors"),
83
+ controls.checkbox("severity", "warning", "Warnings"),
84
+ ]),
85
+ source.ruleIds.length === 0
86
+ ? undefined
87
+ : h("div.filter-options.filter-rules", source.ruleIds.map((id) => controls.checkbox("rule", id, h("code", id)))),
88
+ ]),
89
+ h("fieldset.filter-group", [
90
+ h("legend", "Size"),
91
+ controls.range("KB", "minKb", "maxKb", "any"),
92
+ controls.range("Lines", "minLines", "maxLines", "1"),
93
+ controls.range("Tokens", "minTokens", "maxTokens", "1"),
94
+ ]),
95
+ h("fieldset.filter-group", [
96
+ h("legend", "Graph"),
97
+ h("div.filter-options.filter-options-column", LINK_FLAGS.map((flag) => controls.checkbox("flag", flag, LINK_FLAG_LABELS[flag]))),
98
+ ]),
99
+ renderWhere(controls, source),
100
+ ...sortInputs(controls, query),
101
+ h("div.filter-actions", [
102
+ h("button", { type: "submit" }, "Apply"),
103
+ h("a", { href: "/dashboard" }, "Reset"),
104
+ ]),
105
+ ]);
106
+ }
107
+ function renderWhere(controls, source) {
108
+ const folder = controls.first("folder");
109
+ return h("fieldset.filter-group", [
110
+ h("legend", "Where"),
111
+ h("label.filter-field", [
112
+ "Folder",
113
+ h("select", { name: "folder" }, [
114
+ h("option", { value: "", selected: folder === "" }, "All documents"),
115
+ ...source.folders.map((value) => h("option", { value, selected: folder === value }, value)),
116
+ ]),
117
+ ]),
118
+ source.changes === undefined
119
+ ? undefined
120
+ : controls.checkbox("changed", "1", "Changed in this branch"),
121
+ h("label.filter-field", [
122
+ "Path contains",
123
+ h("input", {
124
+ type: "search",
125
+ name: "path",
126
+ value: controls.first("path"),
127
+ autoComplete: "off",
128
+ spellCheck: false,
129
+ }),
130
+ ]),
131
+ ]);
132
+ }
133
+ // Kept across a filter change, so narrowing the list does not also undo the reader's sort.
134
+ function sortInputs(controls, query) {
135
+ const sort = query?.sort ?? controls.first("sort");
136
+ const dir = query?.dir ?? controls.first("dir");
137
+ const sortIsDefault = query === undefined
138
+ ? sort === "" && dir === ""
139
+ : query.sort === DEFAULT_SORT &&
140
+ query.dir === defaultDirection(query.sort);
141
+ if (sortIsDefault) {
142
+ return [undefined, undefined];
143
+ }
144
+ return [
145
+ h("input", { type: "hidden", name: "sort", value: sort }),
146
+ h("input", { type: "hidden", name: "dir", value: dir }),
147
+ ];
148
+ }
149
+ function summaryText(result) {
150
+ const parts = [
151
+ `${result.totals.documents} of ${plural(result.corpusSize, "document")}`,
152
+ ];
153
+ if (result.findings === "ready") {
154
+ parts.push(plural(result.totals.errors, "error"), plural(result.totals.warnings, "warning"));
155
+ }
156
+ parts.push(`${kilobytes(result.totals.bytes)} KB`, plural(result.totals.lines, "line"));
157
+ return parts.join(" · ");
158
+ }
159
+ const COLUMNS = [
160
+ { key: "path", label: "Document", numeric: false },
161
+ { key: "errors", label: "Errors", numeric: true },
162
+ { key: "warnings", label: "Warnings", numeric: true },
163
+ { key: "rules", label: "Rules", numeric: false },
164
+ { key: "bytes", label: "KB", numeric: true },
165
+ { key: "lines", label: "Lines", numeric: true },
166
+ { key: "tokens", label: "Tokens", numeric: true },
167
+ { key: "linkedFrom", label: "Linked from", numeric: true },
168
+ { key: "linksTo", label: "Links to", numeric: true },
169
+ { key: "flags", label: "Graph", numeric: false },
170
+ ];
171
+ const OPPOSITE = {
172
+ asc: "desc",
173
+ desc: "asc",
174
+ };
175
+ const ARIA_SORT = {
176
+ asc: "ascending",
177
+ desc: "descending",
178
+ };
179
+ // A column's header links to the table sorted by it: the other way round when it is the sorted
180
+ // column already, else in the column's own first direction.
181
+ function sortHeader(query, column) {
182
+ const active = query.sort === column.key;
183
+ const dir = active ? OPPOSITE[query.dir] : defaultDirection(column.key);
184
+ return h(column.numeric ? "th.is-numeric" : "th", { scope: "col", ariaSort: active ? ARIA_SORT[query.dir] : undefined }, h("a.dashboard-sort", { href: dashboardHref({ ...query, sort: column.key, dir }) }, column.label));
185
+ }
186
+ function renderResults(query, result, branch) {
187
+ const exportParams = (format) => {
188
+ const params = dashboardSearchParams(query);
189
+ params.set("format", format);
190
+ return `/api/dashboard?${params.toString()}`;
191
+ };
192
+ return [
193
+ h("p.dashboard-export", [
194
+ "Download this selection: ",
195
+ h("a", { href: exportParams("csv"), download: "" }, "CSV"),
196
+ " · ",
197
+ h("a", { href: exportParams("json"), download: "" }, "JSON"),
198
+ ]),
199
+ result.findings === "pending" &&
200
+ (query.severity.length > 0 || query.rule.length > 0)
201
+ ? h("p.dashboard-notice", "The linter is still checking the corpus, so the finding filters are not applied yet.")
202
+ : undefined,
203
+ h("div.dashboard-table-wrap", renderTable(query, result, branch)),
204
+ ];
205
+ }
206
+ function renderTable(query, result, branch) {
207
+ const header = (column) => sortHeader(query, column);
208
+ return h("table.dashboard-table", [
209
+ h("thead", [
210
+ h("tr", [
211
+ ...COLUMNS.slice(0, 1).map(header),
212
+ branch
213
+ ? h("th", {
214
+ scope: "col",
215
+ title: "What this branch did to the document",
216
+ }, "Branch")
217
+ : undefined,
218
+ ...COLUMNS.slice(1).map(header),
219
+ ]),
220
+ ]),
221
+ h("tbody", result.rows.length === 0
222
+ ? [
223
+ h("tr", [
224
+ h("td.dashboard-empty", { colSpan: COLUMNS.length + (branch ? 1 : 0) }, "No documents match these filters."),
225
+ ]),
226
+ ]
227
+ : result.rows.map((row, index) => renderRow(row, index === FIRST_SCREEN_ROWS))),
228
+ ]);
229
+ }
230
+ // The rows a first screen holds, on the tallest of screens, below the filters: the page is drawn once
231
+ // they are read, and the row after them carries the id that says so. The other rows of a corpus of
232
+ // hundreds follow out of sight.
233
+ const FIRST_SCREEN_ROWS = 40;
234
+ function renderRow(row, belowFirstScreen) {
235
+ const count = (value, className) => h(value !== null && value > 0
236
+ ? `td.is-numeric.${className}`
237
+ : "td.is-numeric", value === null ? "—" : String(value));
238
+ return h("tr", belowFirstScreen ? { id: FIRST_SCREEN_ID } : {}, [
239
+ h("td.dashboard-path", h("a", { href: documentHref(row.path) }, row.path)),
240
+ row.change === undefined ? undefined : renderChange(row.change),
241
+ count(row.errors, "has-errors"),
242
+ count(row.warnings, "has-warnings"),
243
+ h("td.dashboard-rules", [
244
+ ...row.rules.flatMap((id, index) => index === 0 ? [h("code", id)] : [" ", h("code", id)]),
245
+ // Copies a prompt that answers every finding in the document; its menu is the page script's,
246
+ // so it is hidden without it.
247
+ row.rules.length === 0
248
+ ? undefined
249
+ : h("button.prompt-menu", {
250
+ type: "button",
251
+ hidden: true,
252
+ dataPath: row.path,
253
+ title: "Copy a prompt that answers this document's findings",
254
+ }, "Prompt"),
255
+ ]),
256
+ h("td.is-numeric", { title: `${row.bytes} bytes` }, kilobytes(row.bytes)),
257
+ h("td.is-numeric", String(row.lines)),
258
+ h("td.is-numeric", String(row.tokens)),
259
+ h("td.is-numeric", String(row.linkedFrom)),
260
+ h("td.is-numeric", String(row.linksTo)),
261
+ h("td.dashboard-flags", row.flags.map((flag) => LINK_FLAG_NAMES[flag]).join(", ")),
262
+ ]);
263
+ }
264
+ // The branch's column: the document's letter, then the findings it gained and lost, as the Changes
265
+ // page words them.
266
+ function renderChange(change) {
267
+ if (change === null) {
268
+ return h("td.dashboard-change");
269
+ }
270
+ const findings = [
271
+ change.findingsAdded > 0 ? `+${change.findingsAdded}` : undefined,
272
+ change.findingsRemoved > 0 ? `−${change.findingsRemoved}` : undefined,
273
+ ]
274
+ .filter((part) => part !== undefined)
275
+ .join(" ");
276
+ return h("td.dashboard-change", [
277
+ change.status === undefined
278
+ ? undefined
279
+ : h(`span.change-status.change-status-${change.status}`, change.status),
280
+ findings === ""
281
+ ? undefined
282
+ : h("span.change-findings", { title: "Findings this branch added and removed" }, findings),
283
+ ]);
284
+ }
285
+ function kilobytes(bytes) {
286
+ return (bytes / 1024).toFixed(1);
287
+ }
288
+ function plural(count, noun) {
289
+ return `${count} ${noun}${count === 1 ? "" : "s"}`;
290
+ }
@@ -0,0 +1,94 @@
1
+ import { type GitChange, type ContextGraph, type LintMessage, type ParsedDocument, type Severity } from "@wastech-mdlint/core";
2
+ export declare const LINK_FLAGS: readonly ["orphan", "dead-end", "cycle", "detached"];
3
+ export type LinkFlag = (typeof LINK_FLAGS)[number];
4
+ export declare const SORT_KEYS: readonly ["path", "errors", "warnings", "rules", "bytes", "lines", "tokens", "linkedFrom", "linksTo", "flags"];
5
+ export type SortKey = (typeof SORT_KEYS)[number];
6
+ export type SortDirection = "asc" | "desc";
7
+ declare const NUMERIC_PARAMS: readonly ["minKb", "maxKb", "minLines", "maxLines", "minTokens", "maxTokens"];
8
+ export type NumericParam = (typeof NUMERIC_PARAMS)[number];
9
+ export type DashboardQuery = {
10
+ severity: Severity[];
11
+ rule: string[];
12
+ folder: string;
13
+ path: string;
14
+ flag: LinkFlag[];
15
+ sort: SortKey;
16
+ dir: SortDirection;
17
+ changed?: boolean;
18
+ } & Partial<Record<NumericParam, number>>;
19
+ /**
20
+ * What the branch did to a document: its letter, when the branch changed it, and the findings the
21
+ * change gave it and took from it — which an unchanged document can have too, when a link of its
22
+ * broke.
23
+ */
24
+ export type DashboardChange = {
25
+ status?: GitChange["status"];
26
+ findingsAdded: number;
27
+ findingsRemoved: number;
28
+ };
29
+ export type DashboardRow = {
30
+ path: string;
31
+ errors: number | null;
32
+ warnings: number | null;
33
+ rules: string[];
34
+ bytes: number;
35
+ lines: number;
36
+ tokens: number;
37
+ linkedFrom: number;
38
+ linksTo: number;
39
+ flags: LinkFlag[];
40
+ change?: DashboardChange | null;
41
+ };
42
+ export type DashboardTotals = {
43
+ documents: number;
44
+ errors: number;
45
+ warnings: number;
46
+ bytes: number;
47
+ lines: number;
48
+ tokens: number;
49
+ };
50
+ export type DashboardResult = {
51
+ findings: "pending" | "ready";
52
+ corpusSize: number;
53
+ totals: DashboardTotals;
54
+ rows: DashboardRow[];
55
+ };
56
+ export type DashboardSource = {
57
+ documents: ReadonlyMap<string, ParsedDocument>;
58
+ graph: ContextGraph;
59
+ findings: ReadonlyMap<string, readonly LintMessage[]> | undefined;
60
+ ruleIds: readonly string[];
61
+ folders: readonly string[];
62
+ changes?: ReadonlyMap<string, DashboardChange>;
63
+ };
64
+ export type ParsedDashboardQuery = {
65
+ ok: true;
66
+ query: DashboardQuery;
67
+ } | {
68
+ ok: false;
69
+ message: string;
70
+ };
71
+ export declare const DEFAULT_SORT: SortKey;
72
+ export declare function defaultDirection(sort: SortKey): SortDirection;
73
+ /**
74
+ * Read a dashboard query from the address.
75
+ *
76
+ * Strict, the way the config is: an unknown parameter, value or rule is refused with a message
77
+ * rather than dropped, because a filter that silently does nothing reads as "no document matches".
78
+ * An empty value is "not set", since that is what a GET form sends for an empty field. `allowed` names
79
+ * extra parameters a caller handles itself, such as the API's `format`.
80
+ */
81
+ export declare function parseDashboardQuery(params: URLSearchParams, source: Pick<DashboardSource, "ruleIds" | "folders" | "changes">, allowed?: readonly string[]): ParsedDashboardQuery;
82
+ /** The query as URL parameters, in a fixed order and without the defaults, for links to share. */
83
+ export declare function dashboardSearchParams(query: DashboardQuery): URLSearchParams;
84
+ export declare function dashboardHref(query: DashboardQuery): string;
85
+ export declare function buildDashboard(source: DashboardSource, query: DashboardQuery): DashboardResult;
86
+ /**
87
+ * The selection as CSV: RFC 4180 quoting and CRLF rows, sizes in bytes as measured.
88
+ *
89
+ * A cell a spreadsheet would read as a formula — one starting with `=`, `+`, `-` or `@`, or with a
90
+ * tab or carriage return that some of them skip first — gets a leading apostrophe. A file name is
91
+ * the repository's to choose, and opening an export must not run what someone named a file.
92
+ */
93
+ export declare function dashboardCsv(result: DashboardResult): string;
94
+ export {};