@datarails-ai/dr-appspace-cli 0.12.66 → 0.12.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +155 -43
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -13,7 +13,7 @@ import { fileURLToPath as fileURLToPath6 } from "url";
|
|
|
13
13
|
// package.json
|
|
14
14
|
var package_default = {
|
|
15
15
|
name: "@datarails-ai/dr-appspace-cli",
|
|
16
|
-
version: "0.12.
|
|
16
|
+
version: "0.12.67",
|
|
17
17
|
description: "Datarails App Space CLI \u2014 build, try, push and publish App Space apps",
|
|
18
18
|
type: "module",
|
|
19
19
|
engines: {
|
|
@@ -57,7 +57,7 @@ var package_default = {
|
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
// src/buildInfo.ts
|
|
60
|
-
var BUILD_TIME = "2026-11-
|
|
60
|
+
var BUILD_TIME = "2026-11-05T08:07:56.103Z";
|
|
61
61
|
function formatBuildTime(iso) {
|
|
62
62
|
if (iso === "") return "";
|
|
63
63
|
const d = new Date(iso);
|
|
@@ -9269,6 +9269,7 @@ __export(workflow_exports, {
|
|
|
9269
9269
|
unconfirmedStateChanges: () => unconfirmedStateChanges,
|
|
9270
9270
|
unliftableRefusals: () => unliftableRefusals,
|
|
9271
9271
|
unreachablePages: () => unreachablePages,
|
|
9272
|
+
unreachableTabs: () => unreachableTabs,
|
|
9272
9273
|
unreadReasons: () => unreadReasons
|
|
9273
9274
|
});
|
|
9274
9275
|
var isPlainObject3 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -9317,13 +9318,18 @@ var ANCHOR = /<a\b([^>]*)>/gi;
|
|
|
9317
9318
|
var HREF = /\bhref\s*=\s*["']([^"']*)["']/i;
|
|
9318
9319
|
var ROLE_ATTR2 = /\bdata-dr-role\s*=\s*["']([^"']*)["']/i;
|
|
9319
9320
|
var PAGE_LITERAL = /["'`](?:\.\/)?([A-Za-z0-9_-]+\.html)(?:[?#][^"'`]*)?["'`]/g;
|
|
9320
|
-
function targetOf(href) {
|
|
9321
|
+
function targetOf(href, from = "ui/index.html") {
|
|
9321
9322
|
if (!named3(href) || /^(?:[a-z]+:)?\/\//i.test(href) || href.startsWith("/") || href.startsWith("#")) return null;
|
|
9322
|
-
const
|
|
9323
|
-
|
|
9324
|
-
|
|
9323
|
+
const parts = from.split("/").slice(0, -1);
|
|
9324
|
+
for (const part of href.replace(/[?#].*$/, "").split("/")) {
|
|
9325
|
+
if (part === "" || part === ".") continue;
|
|
9326
|
+
if (part === "..") parts.pop();
|
|
9327
|
+
else parts.push(part);
|
|
9328
|
+
}
|
|
9329
|
+
const path3 = parts.join("/");
|
|
9330
|
+
return /^ui\/(?:[A-Za-z0-9_-]+\/)*[A-Za-z0-9_-]+\.html$/.test(path3) ? path3 : null;
|
|
9325
9331
|
}
|
|
9326
|
-
function navLinks(html, { owned = false } = {}) {
|
|
9332
|
+
function navLinks(html, { owned = false, from } = {}) {
|
|
9327
9333
|
const text4 = String(html ?? "");
|
|
9328
9334
|
const regions = [];
|
|
9329
9335
|
if (owned) regions.push(text4);
|
|
@@ -9337,7 +9343,7 @@ function navLinks(html, { owned = false } = {}) {
|
|
|
9337
9343
|
const out = [];
|
|
9338
9344
|
for (const region of regions) {
|
|
9339
9345
|
for (const anchor of region.matchAll(ANCHOR)) {
|
|
9340
|
-
const target = targetOf(HREF.exec(anchor[1])?.[1]);
|
|
9346
|
+
const target = targetOf(HREF.exec(anchor[1])?.[1], from);
|
|
9341
9347
|
if (target === null) continue;
|
|
9342
9348
|
out.push({ target, gate: gateRoles(ROLE_ATTR2.exec(anchor[1])?.[1]) });
|
|
9343
9349
|
}
|
|
@@ -9387,7 +9393,7 @@ function reachByRole(contract, { pageSource = () => void 0, moduleSource = () =>
|
|
|
9387
9393
|
if (linksCache.has(path3)) return linksCache.get(path3);
|
|
9388
9394
|
const html = pageSource(path3);
|
|
9389
9395
|
if (typeof html !== "string") return null;
|
|
9390
|
-
const links = navLinks(html, { owned: byPath.get(path3)?.owned === true });
|
|
9396
|
+
const links = navLinks(html, { owned: byPath.get(path3)?.owned === true, from: path3 });
|
|
9391
9397
|
for (const module of modulesOn.get(path3) ?? []) {
|
|
9392
9398
|
const source = moduleSource(module);
|
|
9393
9399
|
if (typeof source !== "string") return null;
|
|
@@ -9432,7 +9438,7 @@ function unreachablePages(contract, files = {}) {
|
|
|
9432
9438
|
for (const other of pagesOf(contract)) {
|
|
9433
9439
|
if (other.path === page.path) continue;
|
|
9434
9440
|
const html = (files.pageSource ?? (() => void 0))(other.path);
|
|
9435
|
-
for (const link of navLinks(html, { owned: other.owned === true })) {
|
|
9441
|
+
for (const link of navLinks(html, { owned: other.owned === true, from: other.path })) {
|
|
9436
9442
|
if (link.target !== page.path) continue;
|
|
9437
9443
|
linked = true;
|
|
9438
9444
|
const gate = link.gate.join(" ");
|
|
@@ -9449,10 +9455,18 @@ function unreachablePages(contract, files = {}) {
|
|
|
9449
9455
|
else why = "the only pages that link to it are pages no role reaches";
|
|
9450
9456
|
const problem6 = `${page.path} is a page of the app, and no role reaches it from the nav \u2014 ${why} \u2014 so only a typed URL opens it.`;
|
|
9451
9457
|
const fix = roles.length > 0 || gates.length > 0 ? `Gate its nav entry to a role that should open it (pages[].roles on the page, a role's home, or the element's role), or drop the page.` : "Give the pages a nav (a nav element on each page), or drop the page.";
|
|
9452
|
-
out.push({ page: page.path, problem: problem6, fix, message: `${problem6} ${fix}` });
|
|
9458
|
+
out.push({ page: page.path, why, problem: problem6, fix, message: `${problem6} ${fix}` });
|
|
9453
9459
|
}
|
|
9454
9460
|
return out;
|
|
9455
9461
|
}
|
|
9462
|
+
function unreachableTabs(contract, files = {}) {
|
|
9463
|
+
const tabsOnly = { ...contract, pages: pagesOf(contract).map((page) => ({ ...page, owned: false })) };
|
|
9464
|
+
return unreachablePages(tabsOnly, { pageSource: files.pageSource, moduleSource: () => "" }).map((found) => {
|
|
9465
|
+
const problem6 = `${found.page} is a page of the dashboard, and no tab leads to it from the landing page \u2014 ${found.why} \u2014 so only a typed URL opens it.`;
|
|
9466
|
+
const fix = "Every page's tab bar must list it: delete the nav on the pages that miss it so the compile writes one tab per route, or drop the page.";
|
|
9467
|
+
return { page: found.page, problem: problem6, fix, message: `${problem6} ${fix}` };
|
|
9468
|
+
});
|
|
9469
|
+
}
|
|
9456
9470
|
var STATE_WORDS = Object.freeze([
|
|
9457
9471
|
"approve",
|
|
9458
9472
|
"approved",
|
|
@@ -11237,6 +11251,8 @@ function compileDashboard(contract, { kit = null, extra = {}, uiKit, charts, fmt
|
|
|
11237
11251
|
const problems = [];
|
|
11238
11252
|
const refuse2 = (code, pointer2, message) => problems.push({ code, pointer: pointer2, message });
|
|
11239
11253
|
const note = (code, where2, message) => problems.push({ code, where: where2, lossy: false, message });
|
|
11254
|
+
const warnings = [];
|
|
11255
|
+
const warn = (code, pointer2, message) => warnings.push({ code, pointer: pointer2, message });
|
|
11240
11256
|
const refused = (restated2 = contract) => ({ files: {}, problems, contract: restated2, warnings: [] });
|
|
11241
11257
|
const source = isPlainObject7(contract) ? contract : {};
|
|
11242
11258
|
const assistant = named5(kit?.assistant) ? kit.assistant : ASSISTANT;
|
|
@@ -11273,7 +11289,7 @@ function compileDashboard(contract, { kit = null, extra = {}, uiKit, charts, fmt
|
|
|
11273
11289
|
for (const problem6 of handler.refusals) refuse2(problem6.code, problem6.where, problem6.message);
|
|
11274
11290
|
return refused();
|
|
11275
11291
|
}
|
|
11276
|
-
const restated = restateDashboard(composed, pages, handlerName, handler, { refuse: refuse2, note, stated: Array.isArray(source.pages) ? source.pages : [] });
|
|
11292
|
+
const restated = restateDashboard(composed, pages, handlerName, handler, { refuse: refuse2, note, warn, stated: Array.isArray(source.pages) ? source.pages : [] });
|
|
11277
11293
|
const whole = canonical({
|
|
11278
11294
|
...composed.v !== void 0 ? { v: composed.v } : {},
|
|
11279
11295
|
...composed.generated_by !== void 0 ? { generated_by: composed.generated_by } : {},
|
|
@@ -11305,12 +11321,12 @@ function compileDashboard(contract, { kit = null, extra = {}, uiKit, charts, fmt
|
|
|
11305
11321
|
files[handlerPath(composed, handlerName)] = handler.text;
|
|
11306
11322
|
const shelf2 = { runtime: DASHBOARD_RUNTIME, widgets: DASHBOARD_WIDGETS, bar: DASHBOARD_BAR, assistant, markdown, uiKit, charts, fmt, appComponents, appControls };
|
|
11307
11323
|
for (const page of whole.pages) files[page.path] = pageHtml(whole, page, elements, tree, shelf2);
|
|
11308
|
-
return { files, problems, contract: whole, order: order2, warnings: narrativeOrderWarnings(composed, applied) };
|
|
11324
|
+
return { files, problems, contract: whole, order: order2, warnings: [...warnings, ...narrativeOrderWarnings(composed, applied)] };
|
|
11309
11325
|
}
|
|
11310
11326
|
function isRefusal(problem6) {
|
|
11311
11327
|
return problem6.lossy !== false;
|
|
11312
11328
|
}
|
|
11313
|
-
function restateDashboard(composed, pages, handlerName, handler, { refuse: refuse2, note, stated: stated2 }) {
|
|
11329
|
+
function restateDashboard(composed, pages, handlerName, handler, { refuse: refuse2, note, warn, stated: stated2 }) {
|
|
11314
11330
|
const app = isPlainObject7(composed.app) ? composed.app : {};
|
|
11315
11331
|
const typed = isPlainObject7(composed.elements) ? composed.elements : {};
|
|
11316
11332
|
const spec = specRows(composed);
|
|
@@ -11321,6 +11337,7 @@ function restateDashboard(composed, pages, handlerName, handler, { refuse: refus
|
|
|
11321
11337
|
for (const problem6 of placementProblems(unplaced, pages, declared, [])) refuse2(problem6.code, problem6.pointer, problem6.message);
|
|
11322
11338
|
const elements = {};
|
|
11323
11339
|
const outPages = [];
|
|
11340
|
+
const bars = tabBars(pages, typed);
|
|
11324
11341
|
for (const page of pages) {
|
|
11325
11342
|
const path3 = page.path;
|
|
11326
11343
|
const own2 = Object.keys(typed).filter((uid) => typed[uid]?.page === path3).sort(natural3);
|
|
@@ -11369,24 +11386,21 @@ function restateDashboard(composed, pages, handlerName, handler, { refuse: refus
|
|
|
11369
11386
|
elements[uid] = region(uid, HEADER_CHROME[index], "section", [], header);
|
|
11370
11387
|
});
|
|
11371
11388
|
let nav = onlyOne(own2.filter((uid) => typed[uid].type === "nav"), "nav");
|
|
11372
|
-
const
|
|
11389
|
+
const bar = bars.get(path3);
|
|
11373
11390
|
let tabs = [];
|
|
11374
|
-
if (
|
|
11375
|
-
tabs =
|
|
11376
|
-
const props = isPlainObject7(typed[uid].props) ? typed[uid].props : {};
|
|
11377
|
-
return { uid, href: named5(props.href) ? props.href : "", label: named5(props.label) ? props.label : "", current: props.current === true };
|
|
11378
|
-
});
|
|
11391
|
+
if (bar.kind === "declared") {
|
|
11392
|
+
tabs = bar.tabs.map((tab) => ({ uid: tab.uid, href: tab.href, label: tab.label, current: tab.current }));
|
|
11379
11393
|
} else if (pages.length >= 2) {
|
|
11380
|
-
tabs = pages.map((
|
|
11381
|
-
|
|
11382
|
-
|
|
11383
|
-
|
|
11384
|
-
|
|
11385
|
-
|
|
11386
|
-
note("layout_composed", path3, `${path3} gets a tab per route, labelled from each page's heading; the contract declared no tab bar (nav.tabs)`);
|
|
11394
|
+
tabs = composedTabs(path3, pages).map((tab) => ({ uid: null, ...tab }));
|
|
11395
|
+
note(
|
|
11396
|
+
"layout_composed",
|
|
11397
|
+
path3,
|
|
11398
|
+
bar.kind === "recomposed" ? `${path3}'s tab bar was the kit's own, written for ${bar.tabs.length} page${bar.tabs.length === 1 ? "" : "s"}; the dashboard has ${pages.length} now, so it is written again, a tab per route labelled from each page's heading (a tab bar you edit is kept as you wrote it)` : `${path3} gets a tab per route, labelled from each page's heading; the contract declared no tab bar (nav.tabs)`
|
|
11399
|
+
);
|
|
11387
11400
|
}
|
|
11388
11401
|
if (tabs.length === 0) nav = void 0;
|
|
11389
11402
|
else if (nav === void 0) nav = fresh();
|
|
11403
|
+
if (bar.problem !== null) warn("tab_bar_misses_page", nav === void 0 ? "/pages" : `/elements/${escapePointer3(nav)}`, bar.problem);
|
|
11390
11404
|
if (nav !== void 0) {
|
|
11391
11405
|
const navProps = isPlainObject7(typed[nav]?.props) ? typed[nav].props : {};
|
|
11392
11406
|
const tabUids = tabs.map((tab) => tab.uid ?? fresh());
|
|
@@ -11654,6 +11668,71 @@ function uidOfPointer(pointer2) {
|
|
|
11654
11668
|
function orderOf(element) {
|
|
11655
11669
|
return Number.isInteger(element?.order) ? element.order : Number.MAX_SAFE_INTEGER;
|
|
11656
11670
|
}
|
|
11671
|
+
function headingOf(page) {
|
|
11672
|
+
return String(page.header?.title ?? page.title ?? page.path);
|
|
11673
|
+
}
|
|
11674
|
+
function composedTabs(path3, pages) {
|
|
11675
|
+
return pages.map((other) => ({ href: relativeTo(path3, other.path), label: headingOf(other), current: other.path === path3 }));
|
|
11676
|
+
}
|
|
11677
|
+
function tabTarget(from, href) {
|
|
11678
|
+
if (typeof href !== "string" || /^(?:[a-z][a-z0-9+.-]*:|\/)/i.test(href)) return null;
|
|
11679
|
+
const parts = from.split("/").slice(0, -1);
|
|
11680
|
+
for (const part of href.replace(/[?#].*$/, "").split("/")) {
|
|
11681
|
+
if (part === "" || part === ".") continue;
|
|
11682
|
+
if (part === "..") parts.pop();
|
|
11683
|
+
else parts.push(part);
|
|
11684
|
+
}
|
|
11685
|
+
return parts.join("/");
|
|
11686
|
+
}
|
|
11687
|
+
function tabBars(pages, typed) {
|
|
11688
|
+
const byPath = new Map(pages.map((page) => [page.path, page]));
|
|
11689
|
+
const stored = /* @__PURE__ */ new Map();
|
|
11690
|
+
for (const page of pages) {
|
|
11691
|
+
const tabs = Object.keys(typed).filter((uid) => typed[uid]?.page === page.path && typed[uid].type === "tab").sort((a, b) => orderOf(typed[a]) - orderOf(typed[b]) || natural3(a, b)).map((uid) => {
|
|
11692
|
+
const props = isPlainObject7(typed[uid].props) ? typed[uid].props : {};
|
|
11693
|
+
const href = named5(props.href) ? props.href : "";
|
|
11694
|
+
return { uid, href, label: named5(props.label) ? props.label : "", current: props.current === true, target: tabTarget(page.path, href) };
|
|
11695
|
+
});
|
|
11696
|
+
if (tabs.length > 0) stored.set(page.path, tabs);
|
|
11697
|
+
}
|
|
11698
|
+
const targetsOf = (path3) => stored.has(path3) ? new Set(stored.get(path3).map((tab) => tab.target)) : null;
|
|
11699
|
+
const same5 = (a, b) => a !== null && b !== null && a.size === b.size && [...a].every((one) => b.has(one));
|
|
11700
|
+
const carries = (path3, listed) => same5(targetsOf(path3), listed) && stored.get(path3).every((tab) => !tab.current);
|
|
11701
|
+
const out = /* @__PURE__ */ new Map();
|
|
11702
|
+
for (const page of pages) {
|
|
11703
|
+
const tabs = stored.get(page.path);
|
|
11704
|
+
if (tabs === void 0) {
|
|
11705
|
+
out.set(page.path, { kind: "composed", tabs: [], problem: null });
|
|
11706
|
+
continue;
|
|
11707
|
+
}
|
|
11708
|
+
const listed = targetsOf(page.path);
|
|
11709
|
+
const dead = [...listed].filter((target) => target === null || !byPath.has(target));
|
|
11710
|
+
const missing = pages.map((other) => other.path).filter((path3) => !listed.has(path3));
|
|
11711
|
+
let last = null;
|
|
11712
|
+
const kitShaped = listed.size === tabs.length && listed.has(page.path) && tabs.every((tab) => {
|
|
11713
|
+
const ascending = last === null || tab.target !== null && natural3(last, tab.target) < 0;
|
|
11714
|
+
last = tab.target;
|
|
11715
|
+
const target = byPath.get(tab.target);
|
|
11716
|
+
return tab.target !== null && // The href as `composedTabs` writes it: a `?view=monthly` or `#sales` the author added is theirs.
|
|
11717
|
+
tab.href === relativeTo(page.path, tab.target) && ascending && tab.current === (tab.target === page.path) && (target === void 0 || tab.label === headingOf(target));
|
|
11718
|
+
});
|
|
11719
|
+
const stale = kitShaped && (dead.length > 0 || missing.length > 0 && !missing.every((path3) => carries(path3, listed)));
|
|
11720
|
+
if (stale) {
|
|
11721
|
+
out.set(page.path, { kind: "recomposed", tabs, problem: null });
|
|
11722
|
+
continue;
|
|
11723
|
+
}
|
|
11724
|
+
const gaps = [
|
|
11725
|
+
...missing.length > 0 ? [`no tab for ${missing.join(", ")}`] : [],
|
|
11726
|
+
...dead.length > 0 ? [`a tab to ${dead.map((target) => target ?? "somewhere outside the app").join(", ")}, which the dashboard does not have`] : []
|
|
11727
|
+
];
|
|
11728
|
+
out.set(page.path, {
|
|
11729
|
+
kind: "declared",
|
|
11730
|
+
tabs,
|
|
11731
|
+
problem: gaps.length === 0 ? null : `${page.path} keeps the tab bar it declares, and that bar has ${gaps.join(" and ")}; add the tab, or delete the nav and the kit writes one tab per route`
|
|
11732
|
+
});
|
|
11733
|
+
}
|
|
11734
|
+
return out;
|
|
11735
|
+
}
|
|
11657
11736
|
function routeOf2(app, path3) {
|
|
11658
11737
|
for (const route of Array.isArray(app.routes) ? app.routes.map(String) : []) {
|
|
11659
11738
|
const clean = route.replace(/^\//, "");
|
|
@@ -25137,11 +25216,11 @@ function documentOrder(elements, uids, page) {
|
|
|
25137
25216
|
};
|
|
25138
25217
|
const widgets = uids.filter((uid) => elements[uid]?.type === "widget");
|
|
25139
25218
|
const cards = widgets.length > 0 || sections.length === 0 ? widgets : rootsAmong(elements, uids);
|
|
25140
|
-
const
|
|
25219
|
+
const headingOf2 = /* @__PURE__ */ new Map();
|
|
25141
25220
|
for (const uid of uids) {
|
|
25142
25221
|
const element = elements[uid];
|
|
25143
25222
|
if (element?.type === "region" && element?.role === "band" && sections.some((entry) => entry.id === element.id)) {
|
|
25144
|
-
|
|
25223
|
+
headingOf2.set(element.id, uid);
|
|
25145
25224
|
}
|
|
25146
25225
|
}
|
|
25147
25226
|
const bucketOf = (uid) => {
|
|
@@ -25155,12 +25234,12 @@ function documentOrder(elements, uids, page) {
|
|
|
25155
25234
|
for (const list3 of buckets.values()) list3.sort((a, b) => a.order - b.order || natural3(a.uid, b.uid));
|
|
25156
25235
|
const moved = /* @__PURE__ */ new Set();
|
|
25157
25236
|
for (const uid of cards) for (const member of subtree(uid)) moved.add(member);
|
|
25158
|
-
for (const uid of
|
|
25237
|
+
for (const uid of headingOf2.values()) moved.add(uid);
|
|
25159
25238
|
if (moved.size === 0) return uids;
|
|
25160
25239
|
const reordered = [];
|
|
25161
25240
|
for (const entry of buckets.get(-1)) reordered.push(...subtree(entry.uid));
|
|
25162
25241
|
for (let i = 0; i < sections.length; i += 1) {
|
|
25163
|
-
const heading =
|
|
25242
|
+
const heading = headingOf2.get(sections[i].id);
|
|
25164
25243
|
if (heading !== void 0) reordered.push(heading);
|
|
25165
25244
|
for (const entry of buckets.get(i)) reordered.push(...subtree(entry.uid));
|
|
25166
25245
|
}
|
|
@@ -26277,6 +26356,21 @@ function checkManifest(app) {
|
|
|
26277
26356
|
return violations;
|
|
26278
26357
|
}
|
|
26279
26358
|
|
|
26359
|
+
// ../flows/insights-builder/kit/checks/rules/navigation.mjs
|
|
26360
|
+
var RULE = "R2.9";
|
|
26361
|
+
function checkNavigation(app, contract, contractError) {
|
|
26362
|
+
if (contract === null) {
|
|
26363
|
+
return {
|
|
26364
|
+
violations: [],
|
|
26365
|
+
skipped: [{ rule: RULE, reason: `the contract could not be extracted (${contractError ?? "no reason given"}), so the tabs are not knowable here` }]
|
|
26366
|
+
};
|
|
26367
|
+
}
|
|
26368
|
+
const inUi = (path3) => app.ui.find((file) => file.path === path3)?.text ?? app.pages.find((page) => page.path === path3)?.text;
|
|
26369
|
+
const files = { pageSource: inUi, moduleSource: (module) => inUi(`ui/${module}`) };
|
|
26370
|
+
const violations = unreachableTabs(contract, files).map((found) => ({ rule: RULE, where: found.page, message: found.message }));
|
|
26371
|
+
return { violations, skipped: [] };
|
|
26372
|
+
}
|
|
26373
|
+
|
|
26280
26374
|
// ../flows/insights-builder/kit/checks/rules/figures.mjs
|
|
26281
26375
|
function checkFigures(contract, { handlerWhere = "handlers" } = {}) {
|
|
26282
26376
|
const warnings = figuresOf(contract).filter((one) => one.kind === APP_COMPUTED).map((one) => ({
|
|
@@ -26548,6 +26642,7 @@ function verify({ app: appRef, catalog, agent, describe: describe7, load }, { ex
|
|
|
26548
26642
|
const agentCheck = checkAgent(agent);
|
|
26549
26643
|
const formatting = checkFormatting(frontend, KIT);
|
|
26550
26644
|
const theme = checkTheme(app);
|
|
26645
|
+
const navigation = checkNavigation(app, contract, contractError);
|
|
26551
26646
|
const liveness2 = checkLiveness(contract, load, {
|
|
26552
26647
|
handlerWhere: app.handlers[0]?.file || app.handlersSource
|
|
26553
26648
|
});
|
|
@@ -26562,13 +26657,15 @@ function verify({ app: appRef, catalog, agent, describe: describe7, load }, { ex
|
|
|
26562
26657
|
...sources.violations,
|
|
26563
26658
|
...agentCheck.violations,
|
|
26564
26659
|
...formatting.violations,
|
|
26565
|
-
...liveness2.violations
|
|
26660
|
+
...liveness2.violations,
|
|
26661
|
+
...navigation.violations
|
|
26566
26662
|
].sort(byRuleThenWhere);
|
|
26567
26663
|
const skipped = [
|
|
26568
26664
|
...sources.skipped,
|
|
26569
26665
|
...agentCheck.skipped,
|
|
26570
26666
|
...formatting.skipped,
|
|
26571
|
-
...liveness2.skipped
|
|
26667
|
+
...liveness2.skipped,
|
|
26668
|
+
...navigation.skipped
|
|
26572
26669
|
].sort(byRuleThenWhere);
|
|
26573
26670
|
return {
|
|
26574
26671
|
ok: violations.length === 0,
|
|
@@ -31794,13 +31891,18 @@ var ANCHOR2 = /<a\b([^>]*)>/gi;
|
|
|
31794
31891
|
var HREF2 = /\bhref\s*=\s*["']([^"']*)["']/i;
|
|
31795
31892
|
var ROLE_ATTR4 = /\bdata-dr-role\s*=\s*["']([^"']*)["']/i;
|
|
31796
31893
|
var PAGE_LITERAL2 = /["'`](?:\.\/)?([A-Za-z0-9_-]+\.html)(?:[?#][^"'`]*)?["'`]/g;
|
|
31797
|
-
function targetOf2(href) {
|
|
31894
|
+
function targetOf2(href, from = "ui/index.html") {
|
|
31798
31895
|
if (!named11(href) || /^(?:[a-z]+:)?\/\//i.test(href) || href.startsWith("/") || href.startsWith("#")) return null;
|
|
31799
|
-
const
|
|
31800
|
-
|
|
31801
|
-
|
|
31896
|
+
const parts = from.split("/").slice(0, -1);
|
|
31897
|
+
for (const part of href.replace(/[?#].*$/, "").split("/")) {
|
|
31898
|
+
if (part === "" || part === ".") continue;
|
|
31899
|
+
if (part === "..") parts.pop();
|
|
31900
|
+
else parts.push(part);
|
|
31901
|
+
}
|
|
31902
|
+
const path3 = parts.join("/");
|
|
31903
|
+
return /^ui\/(?:[A-Za-z0-9_-]+\/)*[A-Za-z0-9_-]+\.html$/.test(path3) ? path3 : null;
|
|
31802
31904
|
}
|
|
31803
|
-
function navLinks2(html, { owned = false } = {}) {
|
|
31905
|
+
function navLinks2(html, { owned = false, from } = {}) {
|
|
31804
31906
|
const text4 = String(html ?? "");
|
|
31805
31907
|
const regions = [];
|
|
31806
31908
|
if (owned) regions.push(text4);
|
|
@@ -31814,7 +31916,7 @@ function navLinks2(html, { owned = false } = {}) {
|
|
|
31814
31916
|
const out = [];
|
|
31815
31917
|
for (const region of regions) {
|
|
31816
31918
|
for (const anchor of region.matchAll(ANCHOR2)) {
|
|
31817
|
-
const target = targetOf2(HREF2.exec(anchor[1])?.[1]);
|
|
31919
|
+
const target = targetOf2(HREF2.exec(anchor[1])?.[1], from);
|
|
31818
31920
|
if (target === null) continue;
|
|
31819
31921
|
out.push({ target, gate: gateRoles2(ROLE_ATTR4.exec(anchor[1])?.[1]) });
|
|
31820
31922
|
}
|
|
@@ -31864,7 +31966,7 @@ function reachByRole2(contract, { pageSource = () => void 0, moduleSource = () =
|
|
|
31864
31966
|
if (linksCache.has(path3)) return linksCache.get(path3);
|
|
31865
31967
|
const html = pageSource(path3);
|
|
31866
31968
|
if (typeof html !== "string") return null;
|
|
31867
|
-
const links = navLinks2(html, { owned: byPath.get(path3)?.owned === true });
|
|
31969
|
+
const links = navLinks2(html, { owned: byPath.get(path3)?.owned === true, from: path3 });
|
|
31868
31970
|
for (const module of modulesOn.get(path3) ?? []) {
|
|
31869
31971
|
const source = moduleSource(module);
|
|
31870
31972
|
if (typeof source !== "string") return null;
|
|
@@ -31909,7 +32011,7 @@ function unreachablePages2(contract, files = {}) {
|
|
|
31909
32011
|
for (const other of pagesOf2(contract)) {
|
|
31910
32012
|
if (other.path === page.path) continue;
|
|
31911
32013
|
const html = (files.pageSource ?? (() => void 0))(other.path);
|
|
31912
|
-
for (const link of navLinks2(html, { owned: other.owned === true })) {
|
|
32014
|
+
for (const link of navLinks2(html, { owned: other.owned === true, from: other.path })) {
|
|
31913
32015
|
if (link.target !== page.path) continue;
|
|
31914
32016
|
linked = true;
|
|
31915
32017
|
const gate = link.gate.join(" ");
|
|
@@ -31926,7 +32028,7 @@ function unreachablePages2(contract, files = {}) {
|
|
|
31926
32028
|
else why = "the only pages that link to it are pages no role reaches";
|
|
31927
32029
|
const problem6 = `${page.path} is a page of the app, and no role reaches it from the nav \u2014 ${why} \u2014 so only a typed URL opens it.`;
|
|
31928
32030
|
const fix = roles.length > 0 || gates.length > 0 ? `Gate its nav entry to a role that should open it (pages[].roles on the page, a role's home, or the element's role), or drop the page.` : "Give the pages a nav (a nav element on each page), or drop the page.";
|
|
31929
|
-
out.push({ page: page.path, problem: problem6, fix, message: `${problem6} ${fix}` });
|
|
32031
|
+
out.push({ page: page.path, why, problem: problem6, fix, message: `${problem6} ${fix}` });
|
|
31930
32032
|
}
|
|
31931
32033
|
return out;
|
|
31932
32034
|
}
|
|
@@ -39940,7 +40042,17 @@ function leverFindings(contract, bundle, handlerCode) {
|
|
|
39940
40042
|
];
|
|
39941
40043
|
}
|
|
39942
40044
|
function workflowFindings(contract, bundle, handlerCode) {
|
|
39943
|
-
if (contract === null
|
|
40045
|
+
if (contract === null) return [];
|
|
40046
|
+
if (!isAppContract3(contract)) {
|
|
40047
|
+
if (contract.app?.kind !== "dashboard") return [];
|
|
40048
|
+
return WORKFLOW.unreachableTabs(contract, pushedFiles(bundle, handlerCode)).map((found) => ({
|
|
40049
|
+
code: "page-unreachable",
|
|
40050
|
+
where: found.page ?? "pages",
|
|
40051
|
+
message: found.problem,
|
|
40052
|
+
fix: found.fix,
|
|
40053
|
+
see: SEE.pages
|
|
40054
|
+
}));
|
|
40055
|
+
}
|
|
39944
40056
|
const files = pushedFiles(bundle, handlerCode);
|
|
39945
40057
|
return [
|
|
39946
40058
|
// A role that opens the app on a 404: counted, like the unreachable page
|