@topogram/cli 0.3.63 → 0.3.65
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/package.json +1 -1
- package/src/adoption/plan/index.js +703 -0
- package/src/adoption/plan.d.ts +6 -0
- package/src/adoption/plan.js +12 -703
- package/src/adoption/reporting.d.ts +10 -0
- package/src/adoption/review-groups.d.ts +6 -0
- package/src/agent-brief.d.ts +3 -0
- package/src/agent-brief.js +495 -0
- package/src/agent-ops/query-builders/auth.js +375 -0
- package/src/agent-ops/query-builders/change-risk/change-plan.js +123 -0
- package/src/agent-ops/query-builders/change-risk/import-plan.js +49 -0
- package/src/agent-ops/query-builders/change-risk/maintained.js +286 -0
- package/src/agent-ops/query-builders/change-risk/review-packets.js +123 -0
- package/src/agent-ops/query-builders/change-risk/risk.js +189 -0
- package/src/agent-ops/query-builders/change-risk.js +25 -0
- package/src/agent-ops/query-builders/common.js +149 -0
- package/src/agent-ops/query-builders/maintained-risk.js +539 -0
- package/src/agent-ops/query-builders/maintained-shared.js +120 -0
- package/src/agent-ops/query-builders/multi-agent.js +547 -0
- package/src/agent-ops/query-builders/projection-impacts.js +514 -0
- package/src/agent-ops/query-builders/work-packets.js +417 -0
- package/src/agent-ops/query-builders/workflow-context-shared.js +300 -0
- package/src/agent-ops/query-builders/workflow-context.js +398 -0
- package/src/agent-ops/query-builders/workflow-presets-core.js +676 -0
- package/src/agent-ops/query-builders/workflow-presets.js +341 -0
- package/src/agent-ops/query-builders.d.ts +26 -0
- package/src/agent-ops/query-builders.js +42 -5021
- package/src/archive/archive.d.ts +2 -0
- package/src/archive/compact.d.ts +1 -0
- package/src/archive/unarchive.d.ts +1 -0
- package/src/catalog/constants.js +10 -0
- package/src/catalog/copy.js +60 -0
- package/src/catalog/diagnostics.js +15 -0
- package/src/catalog/entries.js +42 -0
- package/src/catalog/files.js +67 -0
- package/src/catalog/provenance.js +122 -0
- package/src/catalog/source.js +150 -0
- package/src/catalog/validation.js +252 -0
- package/src/catalog.d.ts +12 -0
- package/src/catalog.js +18 -750
- package/src/cli/catalog-alias.d.ts +1 -0
- package/src/cli/command-parser.js +38 -0
- package/src/cli/command-parsers/core.js +102 -0
- package/src/cli/command-parsers/generator.js +39 -0
- package/src/cli/command-parsers/import.js +44 -0
- package/src/cli/command-parsers/legacy-workflow.js +21 -0
- package/src/cli/command-parsers/project.js +47 -0
- package/src/cli/command-parsers/sdlc.js +47 -0
- package/src/cli/command-parsers/shared.js +51 -0
- package/src/cli/command-parsers/template.js +48 -0
- package/src/cli/commands/agent.js +47 -0
- package/src/cli/commands/catalog/check.js +31 -0
- package/src/cli/commands/catalog/copy.js +59 -0
- package/src/cli/commands/catalog/doctor.js +248 -0
- package/src/cli/commands/catalog/help.js +21 -0
- package/src/cli/commands/catalog/list.js +52 -0
- package/src/cli/commands/catalog/runner.js +92 -0
- package/src/cli/commands/catalog/shared.js +17 -0
- package/src/cli/commands/catalog/show.js +134 -0
- package/src/cli/commands/catalog.js +32 -0
- package/src/cli/commands/check.js +268 -0
- package/src/cli/commands/doctor.js +268 -0
- package/src/cli/commands/emit.js +149 -0
- package/src/cli/commands/generate.js +96 -0
- package/src/cli/commands/generator-policy/package-info.js +162 -0
- package/src/cli/commands/generator-policy/payloads.js +372 -0
- package/src/cli/commands/generator-policy/printers.js +159 -0
- package/src/cli/commands/generator-policy/runner.js +81 -0
- package/src/cli/commands/generator-policy/shared.js +39 -0
- package/src/cli/commands/generator-policy.js +17 -0
- package/src/cli/commands/generator.js +443 -0
- package/src/cli/commands/import/adopt.js +170 -0
- package/src/cli/commands/import/check.js +91 -0
- package/src/cli/commands/import/diff.js +84 -0
- package/src/cli/commands/import/help.js +47 -0
- package/src/cli/commands/import/paths.js +277 -0
- package/src/cli/commands/import/plan.js +284 -0
- package/src/cli/commands/import/refresh.js +470 -0
- package/src/cli/commands/import/status-history.js +196 -0
- package/src/cli/commands/import/workspace.js +230 -0
- package/src/cli/commands/import-runner.js +157 -0
- package/src/cli/commands/import.js +35 -0
- package/src/cli/commands/inspect.js +55 -0
- package/src/cli/commands/new.js +94 -0
- package/src/cli/commands/package/constants.js +17 -0
- package/src/cli/commands/package/doctor.js +240 -0
- package/src/cli/commands/package/help.js +27 -0
- package/src/cli/commands/package/lockfile.js +135 -0
- package/src/cli/commands/package/npm.js +97 -0
- package/src/cli/commands/package/reporting.js +35 -0
- package/src/cli/commands/package/runner.js +33 -0
- package/src/cli/commands/package/shared.js +9 -0
- package/src/cli/commands/package/update-cli.js +252 -0
- package/src/cli/commands/package/versions.js +35 -0
- package/src/cli/commands/package.js +31 -0
- package/src/cli/commands/query/change-plan.js +68 -0
- package/src/cli/commands/query/definitions.js +202 -0
- package/src/cli/commands/query/import-adopt.js +121 -0
- package/src/cli/commands/query/runner/artifacts.js +102 -0
- package/src/cli/commands/query/runner/boundaries.js +211 -0
- package/src/cli/commands/query/runner/change.js +182 -0
- package/src/cli/commands/query/runner/import-adopt.js +111 -0
- package/src/cli/commands/query/runner/index.js +31 -0
- package/src/cli/commands/query/runner/output.js +12 -0
- package/src/cli/commands/query/runner/workflow.js +241 -0
- package/src/cli/commands/query/runner.js +3 -0
- package/src/cli/commands/query/workflow-context.js +5 -0
- package/src/cli/commands/query/workspace.js +274 -0
- package/src/cli/commands/query.js +11 -0
- package/src/cli/commands/release-rollout.js +257 -0
- package/src/cli/commands/release-shared.js +528 -0
- package/src/cli/commands/release-status.js +429 -0
- package/src/cli/commands/release.js +107 -0
- package/src/cli/commands/sdlc.js +168 -0
- package/src/cli/commands/setup.js +76 -0
- package/src/cli/commands/source.js +291 -0
- package/src/cli/commands/template/baseline.js +100 -0
- package/src/cli/commands/template/check.js +466 -0
- package/src/cli/commands/template/constants.js +8 -0
- package/src/cli/commands/template/diagnostics.js +26 -0
- package/src/cli/commands/template/help.js +28 -0
- package/src/cli/commands/template/lifecycle.js +404 -0
- package/src/cli/commands/template/list-show.js +287 -0
- package/src/cli/commands/template/policy.js +422 -0
- package/src/cli/commands/template/shared.js +127 -0
- package/src/cli/commands/template/updates.js +352 -0
- package/src/cli/commands/template-runner.js +198 -0
- package/src/cli/commands/template.js +43 -0
- package/src/cli/commands/trust.js +219 -0
- package/src/cli/commands/version.js +40 -0
- package/src/cli/commands/widget.js +168 -0
- package/src/cli/commands/workflow.js +63 -0
- package/src/cli/dispatcher.js +392 -0
- package/src/cli/help-dispatch.js +188 -0
- package/src/cli/help.js +296 -0
- package/src/cli/migration-guidance.js +59 -0
- package/src/cli/options.js +96 -0
- package/src/cli/output-safety.js +107 -0
- package/src/cli/path-normalization.js +29 -0
- package/src/cli.js +47 -11711
- package/src/example-implementation.d.ts +2 -0
- package/src/format.d.ts +1 -0
- package/src/generator/api/contracts.js +497 -0
- package/src/generator/api/metadata.js +221 -0
- package/src/generator/api/openapi.js +559 -0
- package/src/generator/api/schema.js +124 -0
- package/src/generator/api/types.d.ts +98 -0
- package/src/generator/api.js +3 -1195
- package/src/generator/check.d.ts +1 -0
- package/src/generator/context/bundle.d.ts +1 -0
- package/src/generator/context/shared/domain-sdlc.js +282 -0
- package/src/generator/context/shared/maintained-boundary.js +665 -0
- package/src/generator/context/shared/metrics.js +85 -0
- package/src/generator/context/shared/primitives.js +64 -0
- package/src/generator/context/shared/relationships.js +453 -0
- package/src/generator/context/shared/summaries.js +263 -0
- package/src/generator/context/shared/types.d.ts +207 -0
- package/src/generator/context/shared.d.ts +44 -0
- package/src/generator/context/shared.js +80 -1390
- package/src/generator/context/slice/core.js +397 -0
- package/src/generator/context/slice/sdlc.js +417 -0
- package/src/generator/context/slice/ui-packets.js +183 -0
- package/src/generator/context/slice.js +2 -859
- package/src/generator/native/parity-bundle.js +2 -1
- package/src/generator/registry/index.js +507 -0
- package/src/generator/registry.js +18 -504
- package/src/generator/runtime/environment/index.js +666 -0
- package/src/generator/runtime/environment.js +4 -666
- package/src/generator/runtime/runtime-check/index.js +554 -0
- package/src/generator/runtime/runtime-check.js +4 -554
- package/src/generator/runtime/shared/index.js +572 -0
- package/src/generator/runtime/shared.js +19 -570
- package/src/generator/shared.d.ts +2 -0
- package/src/generator/surfaces/shared.d.ts +3 -0
- package/src/generator/surfaces/web/html-escape.js +22 -0
- package/src/generator/surfaces/web/react.js +10 -8
- package/src/generator/surfaces/web/sveltekit.js +7 -5
- package/src/generator/surfaces/web/vanilla.js +8 -4
- package/src/generator/widget-conformance/behavior-report.js +258 -0
- package/src/generator/widget-conformance/checks.js +371 -0
- package/src/generator/widget-conformance/projection-context.js +200 -0
- package/src/generator/widget-conformance/report.js +166 -0
- package/src/generator/widget-conformance/types.d.ts +121 -0
- package/src/generator/widget-conformance.js +3 -824
- package/src/generator.d.ts +2 -0
- package/src/github-client.js +520 -0
- package/src/import/core/context.d.ts +3 -0
- package/src/import/core/contracts.d.ts +1 -0
- package/src/import/core/registry.d.ts +4 -0
- package/src/import/core/runner/candidates.js +217 -0
- package/src/import/core/runner/options.js +22 -0
- package/src/import/core/runner/reports.js +50 -0
- package/src/import/core/runner/run.js +79 -0
- package/src/import/core/runner/tracks.js +150 -0
- package/src/import/core/runner/ui-drafts.js +337 -0
- package/src/import/core/runner.js +3 -698
- package/src/import/core/shared/api-routes.js +221 -0
- package/src/import/core/shared/candidates.js +97 -0
- package/src/import/core/shared/files.js +177 -0
- package/src/import/core/shared/next-app.js +389 -0
- package/src/import/core/shared/types.d.ts +51 -0
- package/src/import/core/shared/ui-routes.js +230 -0
- package/src/import/core/shared.js +67 -910
- package/src/import/extractors/api/flutter-dio.js +4 -8
- package/src/import/extractors/api/react-native-repository.js +4 -8
- package/src/import/index.d.ts +4 -0
- package/src/import/provenance.d.ts +4 -0
- package/src/new-project/constants.js +128 -0
- package/src/new-project/create.js +83 -0
- package/src/new-project/json.js +28 -0
- package/src/new-project/metadata.js +96 -0
- package/src/new-project/package-spec.js +161 -0
- package/src/new-project/project-files.js +348 -0
- package/src/new-project/template-policy.js +269 -0
- package/src/new-project/template-resolution.js +368 -0
- package/src/new-project/template-snapshots.js +430 -0
- package/src/new-project/template-updates.js +512 -0
- package/src/new-project/types.d.ts +83 -0
- package/src/new-project.js +6 -2188
- package/src/npm-safety.js +79 -0
- package/src/parser.d.ts +87 -0
- package/src/parser.js +118 -0
- package/src/path-helpers.d.ts +1 -0
- package/src/path-helpers.js +20 -0
- package/src/policy/review-boundaries.d.ts +15 -0
- package/src/project-config/index.js +564 -0
- package/src/project-config.js +19 -560
- package/src/reconcile/docs.d.ts +8 -0
- package/src/reconcile/journeys.d.ts +1 -0
- package/src/resolver/enrich/acceptance-criterion.js +2 -0
- package/src/resolver/enrich/bug.js +2 -0
- package/src/resolver/enrich/pitch.js +2 -0
- package/src/resolver/enrich/requirement.js +2 -0
- package/src/resolver/enrich/task.js +2 -0
- package/src/resolver/index.js +19 -2089
- package/src/resolver/normalize.js +384 -1
- package/src/resolver/plans.js +168 -0
- package/src/resolver/projections-api.js +494 -0
- package/src/resolver/projections-db.js +133 -0
- package/src/resolver/projections-ui.js +317 -0
- package/src/resolver/shapes.js +251 -0
- package/src/resolver/shared.js +278 -0
- package/src/resolver/widgets.js +132 -0
- package/src/resolver.d.ts +1 -0
- package/src/runtime-support.js +29 -0
- package/src/sdlc/adopt.d.ts +1 -0
- package/src/sdlc/check.d.ts +1 -0
- package/src/sdlc/explain.d.ts +1 -0
- package/src/sdlc/release.d.ts +1 -0
- package/src/sdlc/scaffold.d.ts +1 -0
- package/src/sdlc/transition.d.ts +1 -0
- package/src/template-trust/constants.js +62 -0
- package/src/template-trust/content.js +258 -0
- package/src/template-trust/diff.js +92 -0
- package/src/template-trust/policy.js +61 -0
- package/src/template-trust/record.js +90 -0
- package/src/template-trust/status.js +182 -0
- package/src/template-trust.js +24 -687
- package/src/text-helpers.d.ts +7 -0
- package/src/text-helpers.js +245 -0
- package/src/topogram-config.js +306 -0
- package/src/topogram-types.d.ts +69 -0
- package/src/validator/common.js +488 -0
- package/src/validator/data-model.js +237 -0
- package/src/validator/docs.js +167 -0
- package/src/validator/expressions.js +146 -1
- package/src/validator/index.d.ts +23 -0
- package/src/validator/index.js +32 -3585
- package/src/validator/kinds.d.ts +41 -0
- package/src/validator/kinds.js +2 -0
- package/src/validator/model-helpers.js +46 -0
- package/src/validator/per-kind/acceptance-criterion.js +5 -0
- package/src/validator/per-kind/bug.js +6 -0
- package/src/validator/per-kind/domain.js +15 -2
- package/src/validator/per-kind/pitch.js +7 -0
- package/src/validator/per-kind/requirement.js +5 -0
- package/src/validator/per-kind/task.js +7 -0
- package/src/validator/per-kind/widget.js +14 -0
- package/src/validator/projections/api-http-async.js +410 -0
- package/src/validator/projections/api-http-authz.js +88 -0
- package/src/validator/projections/api-http-core.js +205 -0
- package/src/validator/projections/api-http-policies.js +339 -0
- package/src/validator/projections/api-http-responses.js +233 -0
- package/src/validator/projections/api-http.js +44 -0
- package/src/validator/projections/db.js +353 -0
- package/src/validator/projections/generator-defaults.js +45 -0
- package/src/validator/projections/helpers.js +87 -0
- package/src/validator/projections/ui-helpers.js +214 -0
- package/src/validator/projections/ui-navigation.js +344 -0
- package/src/validator/projections/ui-structure.js +364 -0
- package/src/validator/projections/ui-widgets.js +493 -0
- package/src/validator/projections/ui.js +46 -0
- package/src/validator/registry.js +48 -1
- package/src/validator/utils.d.ts +20 -0
- package/src/validator/utils.js +115 -12
- package/src/validator.d.ts +2 -0
- package/src/widget-behavior.d.ts +1 -0
- package/src/workflows/adoption/index.js +26 -0
- package/src/workflows/docs-generate.js +262 -0
- package/src/workflows/docs-scan.js +703 -0
- package/src/workflows/docs.js +15 -0
- package/src/workflows/import-app/api/collect.js +221 -0
- package/src/workflows/import-app/api/openapi.js +257 -0
- package/src/workflows/import-app/api/routes.js +327 -0
- package/src/workflows/import-app/api/sources.js +22 -0
- package/src/workflows/import-app/api.js +4 -0
- package/src/workflows/import-app/db.js +538 -0
- package/src/workflows/import-app/index.js +30 -0
- package/src/workflows/import-app/shared.js +218 -0
- package/src/workflows/import-app/ui.js +443 -0
- package/src/workflows/import-app/workflow.js +159 -0
- package/src/workflows/reconcile/adoption-plan/build.js +208 -0
- package/src/workflows/reconcile/adoption-plan/dependencies.js +75 -0
- package/src/workflows/reconcile/adoption-plan/outputs.js +143 -0
- package/src/workflows/reconcile/adoption-plan/paths.js +58 -0
- package/src/workflows/reconcile/adoption-plan/projection-patches.js +177 -0
- package/src/workflows/reconcile/adoption-plan/reasons.js +107 -0
- package/src/workflows/reconcile/adoption-plan.js +32 -0
- package/src/workflows/reconcile/auth/closures.js +115 -0
- package/src/workflows/reconcile/auth/formatters.js +142 -0
- package/src/workflows/reconcile/auth/inference.js +330 -0
- package/src/workflows/reconcile/auth/roles.js +122 -0
- package/src/workflows/reconcile/auth.js +37 -0
- package/src/workflows/reconcile/bundle-core/index.js +600 -0
- package/src/workflows/reconcile/bundle-core.js +14 -0
- package/src/workflows/reconcile/bundle-shared.js +75 -0
- package/src/workflows/reconcile/candidate-model.js +477 -0
- package/src/workflows/reconcile/canonical-surface.js +264 -0
- package/src/workflows/reconcile/gap-report.js +333 -0
- package/src/workflows/reconcile/ids.js +6 -0
- package/src/workflows/reconcile/impacts/adoption-plan.js +192 -0
- package/src/workflows/reconcile/impacts/indexes.js +101 -0
- package/src/workflows/reconcile/impacts/patches.js +252 -0
- package/src/workflows/reconcile/impacts/reports.js +80 -0
- package/src/workflows/reconcile/impacts.js +16 -0
- package/src/workflows/reconcile/index.js +7 -0
- package/src/workflows/reconcile/renderers.js +461 -0
- package/src/workflows/reconcile/summary.js +90 -0
- package/src/workflows/reconcile/workflow.js +309 -0
- package/src/workflows/shared.js +189 -0
- package/src/workflows/types.d.ts +93 -0
- package/src/workflows.d.ts +1 -0
- package/src/workflows.js +10 -7652
- package/src/workspace-docs.d.ts +29 -0
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
renderReactWidgetRegion
|
|
6
6
|
} from "./react-widgets.js";
|
|
7
7
|
import { buildDesignIntentCoverage, renderDesignIntentCss } from "./design-intent.js";
|
|
8
|
+
import { escapeAttr, escapeHtml } from "./html-escape.js";
|
|
8
9
|
import { renderApiClientModule, renderLookupModule, renderVisibilityModule } from "./shared.js";
|
|
9
10
|
|
|
10
11
|
function componentNameForScreen(screenId) {
|
|
@@ -309,25 +310,26 @@ function assertGenerationCoverage(coverage) {
|
|
|
309
310
|
function buildAppTsx(contract, webReference) {
|
|
310
311
|
const navLinks = resolveNavLinks(contract, webReference);
|
|
311
312
|
const brandName = contract.appShell?.brand || webReference.brandName;
|
|
313
|
+
const safeBrandName = escapeHtml(brandName);
|
|
312
314
|
const footerEnabled = contract.appShell?.footer && contract.appShell.footer !== "none";
|
|
313
315
|
const shellMode = contract.appShell?.shell || "topbar";
|
|
314
316
|
const windowingMode = contract.appShell?.windowing || "single_window";
|
|
315
317
|
const navigationPatterns = (contract.navigation?.patterns || []).join(" ");
|
|
316
318
|
const hasCommandPalette = (contract.navigation?.patterns || []).includes("command_palette");
|
|
317
|
-
const navItems = navLinks.map((link) => ` <Link to="${link.route}">${link.label}</Link>`).join("\n");
|
|
319
|
+
const navItems = navLinks.map((link) => ` <Link to="${escapeAttr(link.route)}">${escapeHtml(link.label)}</Link>`).join("\n");
|
|
318
320
|
const routeScreens = contract.screens.filter((screen) => screen.route && componentNameForScreen(screen.id) !== "EditorialSettingsPage");
|
|
319
321
|
const importLines = routeScreens
|
|
320
322
|
.map((screen) => `import { ${componentNameForScreen(screen.id)} } from "./pages/${componentNameForScreen(screen.id)}";`)
|
|
321
323
|
.join("\n");
|
|
322
324
|
const routeLines = routeScreens
|
|
323
|
-
.map((screen) => ` <Route path="${screen.route}" element={<${componentNameForScreen(screen.id)} />} />`)
|
|
325
|
+
.map((screen) => ` <Route path="${escapeAttr(screen.route)}" element={<${componentNameForScreen(screen.id)} />} />`)
|
|
324
326
|
.join("\n");
|
|
325
327
|
|
|
326
328
|
const shellFrame =
|
|
327
329
|
shellMode === "split_view"
|
|
328
330
|
? ` <div className="app-workspace">
|
|
329
331
|
<aside className="app-sidebar">
|
|
330
|
-
<Link className="brand" to="/">${
|
|
332
|
+
<Link className="brand" to="/">${safeBrandName}</Link>
|
|
331
333
|
<nav className="app-nav-links">
|
|
332
334
|
${navItems}
|
|
333
335
|
</nav>
|
|
@@ -335,7 +337,7 @@ ${hasCommandPalette ? ` <button className="command-palette-button" ty
|
|
|
335
337
|
</aside>
|
|
336
338
|
<div className="app-main-shell">
|
|
337
339
|
<header className="app-nav compact">
|
|
338
|
-
<div className="brand-mark">${
|
|
340
|
+
<div className="brand-mark">${safeBrandName}</div>
|
|
339
341
|
${hasCommandPalette ? ` <button className="command-palette-button" type="button">Command Palette</button>` : ""}
|
|
340
342
|
</header>
|
|
341
343
|
<main>
|
|
@@ -348,7 +350,7 @@ ${routeLines}
|
|
|
348
350
|
</div>`
|
|
349
351
|
: shellMode === "bottom_tabs"
|
|
350
352
|
? ` <header className="app-nav">
|
|
351
|
-
<Link className="brand" to="/">${
|
|
353
|
+
<Link className="brand" to="/">${safeBrandName}</Link>
|
|
352
354
|
${hasCommandPalette ? ` <button className="command-palette-button" type="button">Command Palette</button>` : ""}
|
|
353
355
|
</header>
|
|
354
356
|
<main>
|
|
@@ -361,7 +363,7 @@ ${routeLines}
|
|
|
361
363
|
${navItems}
|
|
362
364
|
</nav>`
|
|
363
365
|
: ` <header className="app-nav${shellMode === "menu_bar" ? " menu-bar" : ""}">
|
|
364
|
-
<Link className="brand" to="/">${
|
|
366
|
+
<Link className="brand" to="/">${safeBrandName}</Link>
|
|
365
367
|
<nav className="app-nav-links">
|
|
366
368
|
${navItems}
|
|
367
369
|
</nav>
|
|
@@ -381,7 +383,7 @@ ${importLines}
|
|
|
381
383
|
export default function App() {
|
|
382
384
|
return (
|
|
383
385
|
<BrowserRouter>
|
|
384
|
-
<div className="app-shell" data-shell="${shellMode}" data-windowing="${windowingMode}" data-navigation-patterns="${navigationPatterns}">
|
|
386
|
+
<div className="app-shell" data-shell="${escapeAttr(shellMode)}" data-windowing="${escapeAttr(windowingMode)}" data-navigation-patterns="${escapeAttr(navigationPatterns)}">
|
|
385
387
|
${shellFrame}
|
|
386
388
|
${footerEnabled ? ` <footer className="app-footer">
|
|
387
389
|
<span>Generated from Topogram</span>
|
|
@@ -463,7 +465,7 @@ export default defineConfig({
|
|
|
463
465
|
<head>
|
|
464
466
|
<meta charset="UTF-8" />
|
|
465
467
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
466
|
-
<title>${webReference.brandName}</title>
|
|
468
|
+
<title>${escapeHtml(webReference.brandName)}</title>
|
|
467
469
|
</head>
|
|
468
470
|
<body>
|
|
469
471
|
<div id="root"></div>
|
|
@@ -3,6 +3,7 @@ import { lookupRouteSegment } from "../services/runtime-helpers.js";
|
|
|
3
3
|
import { getExampleImplementation } from "../../../example-implementation.js";
|
|
4
4
|
import { renderApiClientModule, renderLookupModule, renderVisibilityModule } from "./shared.js";
|
|
5
5
|
import { buildDesignIntentCoverage, renderDesignIntentCss } from "./design-intent.js";
|
|
6
|
+
import { escapeAttr, escapeHtml } from "./html-escape.js";
|
|
6
7
|
import {
|
|
7
8
|
renderSvelteKitWidgetRegion,
|
|
8
9
|
svelteKitWidgetUsageSupport
|
|
@@ -324,6 +325,7 @@ function buildSvelteKitScaffold(contract, apiContracts, options = {}) {
|
|
|
324
325
|
const files = {};
|
|
325
326
|
|
|
326
327
|
const brandName = contract.appShell?.brand || webReference.brandName;
|
|
328
|
+
const safeBrandName = escapeHtml(brandName);
|
|
327
329
|
const navLinks = resolveNavLinks(contract, webReference);
|
|
328
330
|
const footerEnabled = contract.appShell?.footer && contract.appShell.footer !== "none";
|
|
329
331
|
const shellMode = contract.appShell?.shell || "topbar";
|
|
@@ -384,14 +386,14 @@ function buildSvelteKitScaffold(contract, apiContracts, options = {}) {
|
|
|
384
386
|
files["src/app.css"] =
|
|
385
387
|
`${renderDesignIntentCss(contract.designTokens)}\n` +
|
|
386
388
|
":root {\n font-family: system-ui, sans-serif;\n color: var(--topogram-text-color);\n background: var(--topogram-surface-background);\n}\nbody {\n margin: 0;\n}\na {\n color: var(--topogram-action-primary-background);\n text-decoration: none;\n}\na:hover {\n text-decoration: underline;\n}\nmain {\n max-width: 72rem;\n margin: 0 auto;\n padding: var(--topogram-page-padding);\n}\n.app-shell {\n min-height: 100vh;\n}\n.app-workspace {\n display: grid;\n grid-template-columns: 18rem minmax(0, 1fr);\n min-height: 100vh;\n}\n.app-main-shell {\n min-width: 0;\n}\n.app-sidebar {\n position: sticky;\n top: 0;\n align-self: start;\n min-height: 100vh;\n display: grid;\n align-content: start;\n gap: var(--topogram-space-unit);\n padding: 1.25rem 1rem;\n border-right: 1px solid rgba(24, 32, 38, 0.08);\n background: rgba(255, 255, 255, 0.86);\n backdrop-filter: blur(12px);\n}\n.app-nav {\n position: sticky;\n top: 0;\n z-index: 10;\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--topogram-space-unit);\n padding: 1rem 1.25rem;\n border-bottom: 1px solid rgba(24, 32, 38, 0.08);\n background: rgba(255, 255, 255, 0.9);\n backdrop-filter: blur(12px);\n}\n.app-nav-links,\n.app-nav nav,\n.app-tabbar {\n display: flex;\n gap: 0.75rem;\n flex-wrap: wrap;\n}\n.app-nav.menu-bar {\n border-bottom-style: dashed;\n}\n.app-nav.compact {\n justify-content: flex-end;\n}\n.app-tabbar {\n position: sticky;\n bottom: 0;\n z-index: 10;\n justify-content: space-around;\n padding: 0.85rem 1rem calc(0.85rem + env(safe-area-inset-bottom, 0px));\n border-top: 1px solid rgba(24, 32, 38, 0.08);\n background: rgba(255, 255, 255, 0.92);\n backdrop-filter: blur(12px);\n}\n.brand {\n font-weight: 700;\n letter-spacing: 0.01em;\n}\n.brand-mark {\n font-weight: 700;\n color: var(--topogram-muted-color);\n}\n.command-palette-button {\n background: var(--topogram-text-color);\n color: white;\n border: none;\n border-radius: var(--topogram-radius-pill);\n padding: var(--topogram-control-padding);\n font: inherit;\n cursor: pointer;\n}\n.app-footer {\n max-width: 72rem;\n margin: 0 auto;\n padding: 0 1.25rem 2rem;\n color: var(--topogram-muted-color);\n}\n.card {\n background: var(--topogram-surface-card);\n border-radius: var(--topogram-radius-card);\n padding: 1.25rem;\n box-shadow: 0 12px 30px rgba(24, 32, 38, 0.08);\n}\n.hero {\n display: grid;\n gap: var(--topogram-space-unit);\n}\n.grid {\n display: grid;\n gap: var(--topogram-space-unit);\n}\n.grid.two {\n grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));\n}\n.filters {\n display: grid;\n gap: 0.75rem;\n grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));\n margin: 1rem 0 1.25rem;\n}\nlabel {\n display: grid;\n gap: 0.35rem;\n font-size: 0.95rem;\n}\ninput,\ntextarea,\nbutton,\nselect {\n font: inherit;\n}\ninput,\ntextarea,\nselect {\n width: 100%;\n box-sizing: border-box;\n border: 1px solid #c9d4e2;\n border-radius: var(--topogram-radius-control);\n padding: var(--topogram-control-padding);\n background: white;\n}\ntextarea {\n min-height: 8rem;\n resize: vertical;\n}\nbutton,\n.button-link {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 0.35rem;\n border: none;\n border-radius: var(--topogram-radius-pill);\n padding: var(--topogram-control-padding);\n background: var(--topogram-action-primary-background);\n color: var(--topogram-action-primary-color);\n font-weight: 600;\n cursor: pointer;\n}\nbutton:focus-visible,\n.button-link:focus-visible,\na:focus-visible,\ninput:focus-visible,\ntextarea:focus-visible,\nselect:focus-visible {\n outline: var(--topogram-focus-outline);\n outline-offset: 2px;\n}\n.button-link.secondary {\n background: #e9eef6;\n color: var(--topogram-text-color);\n}\n.button-row {\n display: flex;\n gap: 0.75rem;\n flex-wrap: wrap;\n align-items: center;\n}\n.stack {\n display: grid;\n gap: var(--topogram-space-unit);\n}\n\n.resource-list {\n list-style: none;\n padding: 0;\n margin: 1rem 0 0;\n display: grid;\n gap: 0.75rem;\n}\n\n.resource-list li {\n display: flex;\n justify-content: space-between;\n align-items: flex-start;\n gap: var(--topogram-space-unit);\n padding: 1rem;\n border: 1px solid #e0e8f1;\n border-radius: var(--topogram-radius-card);\n background: var(--topogram-surface-subtle);\n}\n.table-wrap {\n margin-top: 1rem;\n overflow-x: auto;\n border: 1px solid var(--topogram-border-color);\n border-radius: var(--topogram-radius-card);\n background: white;\n}\n.resource-table {\n width: 100%;\n border-collapse: collapse;\n min-width: 42rem;\n}\n.resource-table th,\n.resource-table td {\n padding: 0.85rem 1rem;\n text-align: left;\n border-bottom: 1px solid #e7edf5;\n vertical-align: top;\n}\n.resource-table th {\n font-size: 0.85rem;\n letter-spacing: 0.04em;\n text-transform: uppercase;\n color: #516173;\n background: #f8fbff;\n}\n.resource-table tbody tr:hover {\n background: #fbfdff;\n}\n.data-grid {\n min-width: 64rem;\n font-size: 0.95rem;\n}\n.data-grid thead th {\n position: sticky;\n top: 0;\n z-index: 1;\n background: #eef5ff;\n}\n.data-grid-shell {\n box-shadow: inset 0 0 0 1px rgba(15, 92, 192, 0.04);\n}\n.cell-stack,\n.resource-meta,\n.definition-list {\n display: grid;\n gap: 0.5rem;\n}\n.cell-secondary {\n color: var(--topogram-muted-color);\n font-size: 0.92rem;\n}\n.definition-list {\n grid-template-columns: minmax(8rem, 12rem) 1fr;\n align-items: start;\n}\n.definition-list dt {\n font-weight: 600;\n color: #516173;\n}\n.definition-list dd {\n margin: 0;\n}\n.badge {\n display: inline-flex;\n align-items: center;\n padding: 0.25rem 0.6rem;\n border-radius: var(--topogram-radius-pill);\n background: #eef4ff;\n color: var(--topogram-action-primary-background);\n font-size: 0.85rem;\n font-weight: 600;\n}\n.muted {\n color: var(--topogram-muted-color);\n}\n.empty-state {\n padding: 1rem 0;\n}\n.widget-card {\n border: 1px solid var(--topogram-border-color);\n border-radius: var(--topogram-radius-card);\n background: var(--topogram-surface-subtle);\n padding: 1rem;\n margin-top: 1rem;\n}\n.widget-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--topogram-space-unit);\n flex-wrap: wrap;\n}\n.widget-eyebrow {\n margin: 0 0 0.25rem;\n color: var(--topogram-muted-color);\n font-size: 0.75rem;\n font-weight: 700;\n letter-spacing: 0.08em;\n text-transform: uppercase;\n}\n.widget-card h2,\n.widget-card h3 {\n margin: 0;\n}\n.widget-table-wrap {\n margin-top: 1rem;\n}\n.summary-grid {\n display: grid;\n grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));\n gap: 0.75rem;\n}\n.summary-grid div,\n.board-column {\n border: 1px solid #e0e8f1;\n border-radius: var(--topogram-radius-control);\n background: white;\n padding: 0.85rem;\n}\n.summary-grid strong {\n display: block;\n font-size: 1.5rem;\n}\n.summary-grid span,\n.calendar-list span {\n color: var(--topogram-muted-color);\n font-size: 0.9rem;\n}\n.board-grid {\n display: grid;\n grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));\n gap: 0.75rem;\n margin-top: 1rem;\n}\n.board-card,\n.calendar-card {\n display: grid;\n gap: 0.25rem;\n border: 1px solid #e0e8f1;\n border-radius: var(--topogram-radius-control);\n background: #f8fbff;\n padding: 0.75rem;\n}\n.calendar-list {\n display: grid;\n gap: 0.75rem;\n margin-top: 1rem;\n}\nsmall.route-hint {\n display: block;\n color: var(--topogram-muted-color);\n margin-top: 0.25rem;\n}\n@media (max-width: 900px) {\n .app-workspace {\n grid-template-columns: 1fr;\n }\n .app-sidebar {\n position: static;\n min-height: auto;\n border-right: none;\n border-bottom: 1px solid rgba(24, 32, 38, 0.08);\n }\n}\n@media (max-width: 640px) {\n .definition-list {\n grid-template-columns: 1fr;\n }\n .resource-list li {\n flex-direction: column;\n }\n .resource-table {\n min-width: 36rem;\n }\n .app-nav {\n flex-wrap: wrap;\n }\n}\n";
|
|
387
|
-
const navMarkup = navLinks.map((link) => ` <a href="${link.route}">${link.label}</a>`).join("\n");
|
|
389
|
+
const navMarkup = navLinks.map((link) => ` <a href="${escapeAttr(link.route)}">${escapeHtml(link.label)}</a>`).join("\n");
|
|
388
390
|
const shellLayout =
|
|
389
391
|
shellMode === "split_view"
|
|
390
|
-
? `<div class="app-workspace">\n <aside class="app-sidebar">\n <a class="brand" href="/">${
|
|
392
|
+
? `<div class="app-workspace">\n <aside class="app-sidebar">\n <a class="brand" href="/">${safeBrandName}</a>\n <nav class="app-nav-links">\n${navMarkup}\n </nav>\n${hasCommandPalette ? ` <button class="command-palette-button" type="button">Command Palette</button>\n` : ""} </aside>\n <div class="app-main-shell">\n <header class="app-nav compact">\n <div class="brand-mark">${safeBrandName}</div>\n${hasCommandPalette ? ` <button class="command-palette-button" type="button">Command Palette</button>\n` : ""} </header>\n\n <slot />\n </div>\n</div>`
|
|
391
393
|
: shellMode === "bottom_tabs"
|
|
392
|
-
? `<header class="app-nav">\n <a class="brand" href="/">${
|
|
393
|
-
: `<header class="app-nav${shellMode === "menu_bar" ? " menu-bar" : ""}">\n <a class="brand" href="/">${
|
|
394
|
-
files["src/routes/+layout.svelte"] = `<script${useTypescript ? ' lang="ts"' : ""}>\n import "../app.css";\n</script>\n\n<div class="app-shell" data-shell="${shellMode}" data-windowing="${windowingMode}" data-navigation-patterns="${navigationPatterns}">\n ${shellLayout}\n${footerEnabled ? `\n <footer class="app-footer">\n <span>Generated from Topogram</span>\n </footer>` : ""}\n</div>\n`;
|
|
394
|
+
? `<header class="app-nav">\n <a class="brand" href="/">${safeBrandName}</a>\n${hasCommandPalette ? ` <button class="command-palette-button" type="button">Command Palette</button>\n` : ""}</header>\n\n<slot />\n\n<nav class="app-tabbar">\n${navMarkup}\n</nav>`
|
|
395
|
+
: `<header class="app-nav${shellMode === "menu_bar" ? " menu-bar" : ""}">\n <a class="brand" href="/">${safeBrandName}</a>\n <nav class="app-nav-links">\n${navMarkup}\n </nav>\n${hasCommandPalette ? ` <button class="command-palette-button" type="button">Command Palette</button>\n` : ""}</header>\n\n<slot />`;
|
|
396
|
+
files["src/routes/+layout.svelte"] = `<script${useTypescript ? ' lang="ts"' : ""}>\n import "../app.css";\n</script>\n\n<div class="app-shell" data-shell="${escapeAttr(shellMode)}" data-windowing="${escapeAttr(windowingMode)}" data-navigation-patterns="${escapeAttr(navigationPatterns)}">\n ${shellLayout}\n${footerEnabled ? `\n <footer class="app-footer">\n <span>Generated from Topogram</span>\n </footer>` : ""}\n</div>\n`;
|
|
395
397
|
files["src/routes/+page.svelte"] = webRenderers.renderHomePage({
|
|
396
398
|
useTypescript,
|
|
397
399
|
demoPrimaryEnvVar,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { buildWebRealization } from "../../../realization/ui/index.js";
|
|
4
4
|
import { buildDesignIntentCoverage, renderDesignIntentCss } from "./design-intent.js";
|
|
5
|
+
import { escapeAttr, escapeHtml } from "./html-escape.js";
|
|
5
6
|
|
|
6
7
|
function slugify(value) {
|
|
7
8
|
return String(value || "page")
|
|
@@ -26,19 +27,20 @@ function routeFileName(routePath) {
|
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
function renderHtml({ title, nav, body }) {
|
|
30
|
+
const safeTitle = escapeHtml(title);
|
|
29
31
|
return `<!doctype html>
|
|
30
32
|
<html lang="en">
|
|
31
33
|
<head>
|
|
32
34
|
<meta charset="utf-8" />
|
|
33
35
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
34
|
-
<title>${
|
|
36
|
+
<title>${safeTitle}</title>
|
|
35
37
|
<link rel="stylesheet" href="./styles.css" />
|
|
36
38
|
</head>
|
|
37
39
|
<body>
|
|
38
40
|
<header class="app-header">
|
|
39
41
|
<a class="brand" href="./index.html">Topogram Hello</a>
|
|
40
42
|
<nav>
|
|
41
|
-
${nav.map((item) => ` <a href="./${item.file}">${item.title}</a>`).join("\n")}
|
|
43
|
+
${nav.map((item) => ` <a href="./${escapeAttr(item.file)}">${escapeHtml(item.title)}</a>`).join("\n")}
|
|
42
44
|
</nav>
|
|
43
45
|
</header>
|
|
44
46
|
<main>
|
|
@@ -285,13 +287,15 @@ export function generateVanillaWebApp(graph, options = {}) {
|
|
|
285
287
|
};
|
|
286
288
|
|
|
287
289
|
routes.forEach((route, index) => {
|
|
290
|
+
const safeTitle = escapeHtml(route.title);
|
|
291
|
+
const safeProjectionId = escapeHtml(contract.projection.id);
|
|
288
292
|
files[route.file] = renderHtml({
|
|
289
293
|
title: route.title,
|
|
290
294
|
nav,
|
|
291
295
|
body: ` <section class="panel">
|
|
292
296
|
<p class="muted">Page ${index + 1} of ${routes.length}</p>
|
|
293
|
-
<h1>${
|
|
294
|
-
<p>This page was generated from the <code>${
|
|
297
|
+
<h1>${safeTitle}</h1>
|
|
298
|
+
<p>This page was generated from the <code>${safeProjectionId}</code> Topogram web projection.</p>
|
|
295
299
|
<p class="muted">Generated timestamp: <span data-generated-at>pending</span></p>
|
|
296
300
|
</section>`
|
|
297
301
|
});
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import { stableUnique } from "./projection-context.js";
|
|
4
|
+
import { generateWidgetConformanceReport } from "./report.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @param {import("./types.d.ts").WidgetUsageReport} usage
|
|
8
|
+
* @param {import("./types.d.ts").WidgetBehavior} behavior
|
|
9
|
+
* @param {any} index
|
|
10
|
+
* @returns {any}
|
|
11
|
+
*/
|
|
12
|
+
export function behaviorReportKey(usage, behavior, index) {
|
|
13
|
+
return [usage.key, behavior.kind || "behavior", String(index)].join(":");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param {import("./types.d.ts").WidgetBehavior} behavior
|
|
18
|
+
* @returns {any}
|
|
19
|
+
*/
|
|
20
|
+
export function capabilityIdsFromBehavior(behavior) {
|
|
21
|
+
const ids = /** @type {string[]} */ ([]);
|
|
22
|
+
for (const dependency of behavior.dataDependencies || []) {
|
|
23
|
+
if (dependency.source?.kind === "capability" && dependency.source.id) {
|
|
24
|
+
ids.push(dependency.source.id);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
for (const action of behavior.actions || []) {
|
|
28
|
+
if (action.capability?.id) {
|
|
29
|
+
ids.push(action.capability.id);
|
|
30
|
+
}
|
|
31
|
+
for (const effect of action.effects || []) {
|
|
32
|
+
if (effect.capability?.id) {
|
|
33
|
+
ids.push(effect.capability.id);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
for (const effect of behavior.effects || []) {
|
|
38
|
+
if (effect.capability?.id) {
|
|
39
|
+
ids.push(effect.capability.id);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return stableUnique(ids);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @param {import("./types.d.ts").WidgetBehavior} behavior
|
|
47
|
+
* @returns {any}
|
|
48
|
+
*/
|
|
49
|
+
export function effectTypesFromBehavior(behavior) {
|
|
50
|
+
const effects = behavior.effects || [];
|
|
51
|
+
if (effects.length === 0) {
|
|
52
|
+
return ["none"];
|
|
53
|
+
}
|
|
54
|
+
return stableUnique(effects.map(/** @param {any} effect */ (effect) => effect.type || "unknown"));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @param {import("./types.d.ts").WidgetConformanceReport} conformanceReport
|
|
59
|
+
* @param {import("./types.d.ts").WidgetUsageReport} usage
|
|
60
|
+
* @param {import("./types.d.ts").WidgetBehavior} behavior
|
|
61
|
+
* @returns {any}
|
|
62
|
+
*/
|
|
63
|
+
export function checksForBehavior(conformanceReport, usage, behavior) {
|
|
64
|
+
return (conformanceReport.checks || [])
|
|
65
|
+
.filter(/** @param {any} check */ (check) =>
|
|
66
|
+
check.code?.startsWith("widget_behavior_") &&
|
|
67
|
+
check.projection === usage.projection?.id &&
|
|
68
|
+
check.widget === usage.widget?.id &&
|
|
69
|
+
check.screen === usage.screen?.id &&
|
|
70
|
+
check.region === usage.region &&
|
|
71
|
+
(!check.behavior || check.behavior === behavior.kind)
|
|
72
|
+
)
|
|
73
|
+
.map(/** @param {any} check */ (check) => ({
|
|
74
|
+
code: check.code,
|
|
75
|
+
severity: check.severity,
|
|
76
|
+
message: check.message,
|
|
77
|
+
event: check.event || null,
|
|
78
|
+
behavior: check.behavior || behavior.kind || null,
|
|
79
|
+
suggested_fix: check.suggested_fix || null
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @param {import("./types.d.ts").WidgetUsageReport[]} behaviorRows
|
|
85
|
+
* @returns {any}
|
|
86
|
+
*/
|
|
87
|
+
export function behaviorHighlights(behaviorRows) {
|
|
88
|
+
const highlights = /** @type {any[]} */ ([]);
|
|
89
|
+
for (const row of behaviorRows) {
|
|
90
|
+
if (row.behavior.status === "partial") {
|
|
91
|
+
highlights.push({
|
|
92
|
+
severity: "warning",
|
|
93
|
+
code: "widget_behavior_partial",
|
|
94
|
+
message: `Behavior '${row.behavior.kind}' is partially realized for widget '${row.widget.id}' on screen '${row.screen.id}'.`,
|
|
95
|
+
projection: row.projection.id,
|
|
96
|
+
widget: row.widget.id,
|
|
97
|
+
screen: row.screen.id,
|
|
98
|
+
region: row.region,
|
|
99
|
+
behavior: row.behavior.kind,
|
|
100
|
+
suggested_fix: "Bind the required behavior data, events, or capability actions in the projection widget_bindings entry."
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
for (const emittedEvent of row.emits || []) {
|
|
104
|
+
if (!emittedEvent.bound) {
|
|
105
|
+
highlights.push({
|
|
106
|
+
severity: "warning",
|
|
107
|
+
code: "widget_behavior_event_unbound",
|
|
108
|
+
message: `Behavior '${row.behavior.kind}' emits event '${emittedEvent.event}', but this widget usage does not bind it.`,
|
|
109
|
+
projection: row.projection.id,
|
|
110
|
+
widget: row.widget.id,
|
|
111
|
+
screen: row.screen.id,
|
|
112
|
+
region: row.region,
|
|
113
|
+
event: emittedEvent.event || null,
|
|
114
|
+
behavior: row.behavior.kind,
|
|
115
|
+
suggested_fix: `Add 'event ${emittedEvent.event} navigate <screen>' or 'event ${emittedEvent.event} action <capability>' to the projection widget_bindings entry.`
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
for (const action of row.actions || []) {
|
|
120
|
+
if (!action.bound) {
|
|
121
|
+
const target = action.capability?.id || action.event || "(unknown)";
|
|
122
|
+
highlights.push({
|
|
123
|
+
severity: "warning",
|
|
124
|
+
code: "widget_behavior_action_unbound",
|
|
125
|
+
message: `Behavior '${row.behavior.kind}' declares action '${target}', but this widget usage does not bind it.`,
|
|
126
|
+
projection: row.projection.id,
|
|
127
|
+
widget: row.widget.id,
|
|
128
|
+
screen: row.screen.id,
|
|
129
|
+
region: row.region,
|
|
130
|
+
event: action.event || null,
|
|
131
|
+
capability: action.capability?.id || null,
|
|
132
|
+
behavior: row.behavior.kind,
|
|
133
|
+
suggested_fix: action.capability?.id
|
|
134
|
+
? `Add 'event <widget_event> action ${action.capability.id}' to the projection widget_bindings entry.`
|
|
135
|
+
: `Add 'event ${action.event} action <capability>' or 'event ${action.event} navigate <screen>' to the projection widget_bindings entry.`
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return highlights;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @param {any} rows
|
|
145
|
+
* @param {any} keyFn
|
|
146
|
+
* @param {any} itemFn
|
|
147
|
+
* @returns {any}
|
|
148
|
+
*/
|
|
149
|
+
export function groupBehaviorRows(rows, keyFn, itemFn = null) {
|
|
150
|
+
const groups = new Map();
|
|
151
|
+
for (const row of rows) {
|
|
152
|
+
for (const key of keyFn(row)) {
|
|
153
|
+
if (!groups.has(key)) {
|
|
154
|
+
groups.set(key, []);
|
|
155
|
+
}
|
|
156
|
+
groups.get(key).push(row);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return [...groups.entries()]
|
|
160
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
161
|
+
.map(([id, entries]) => ({
|
|
162
|
+
id,
|
|
163
|
+
total_behaviors: entries.length,
|
|
164
|
+
realized: entries.filter(/** @param {any} entry */ (entry) => entry.behavior.status === "realized").length,
|
|
165
|
+
partial: entries.filter(/** @param {any} entry */ (entry) => entry.behavior.status === "partial").length,
|
|
166
|
+
declared: entries.filter(/** @param {any} entry */ (entry) => entry.behavior.status === "declared").length,
|
|
167
|
+
behaviors: entries.map(/** @param {any} entry */ (entry) => itemFn ? itemFn(entry) : entry.key).sort()
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* @param {import("./types.d.ts").WidgetGraph} graph
|
|
173
|
+
* @param {import("./types.d.ts").WidgetOptions} options
|
|
174
|
+
* @returns {any}
|
|
175
|
+
*/
|
|
176
|
+
export function generateWidgetBehaviorReport(graph, options = {}) {
|
|
177
|
+
const conformanceReport = generateWidgetConformanceReport(graph, options);
|
|
178
|
+
const behaviorRows = /** @type {any[]} */ ([]);
|
|
179
|
+
|
|
180
|
+
for (const usage of conformanceReport.projection_usages || []) {
|
|
181
|
+
for (const [index, behavior] of (usage.behavior_realizations || []).entries()) {
|
|
182
|
+
const diagnostics = checksForBehavior(conformanceReport, usage, behavior);
|
|
183
|
+
behaviorRows.push({
|
|
184
|
+
key: behaviorReportKey(usage, behavior, index),
|
|
185
|
+
projection: usage.projection,
|
|
186
|
+
source_projection: usage.source_projection,
|
|
187
|
+
screen: usage.screen,
|
|
188
|
+
region: usage.region,
|
|
189
|
+
widget: usage.widget,
|
|
190
|
+
behavior: {
|
|
191
|
+
kind: behavior.kind || null,
|
|
192
|
+
source: behavior.source || null,
|
|
193
|
+
status: behavior.status || "declared",
|
|
194
|
+
directives: behavior.directives || {}
|
|
195
|
+
},
|
|
196
|
+
data_dependencies: behavior.dataDependencies || [],
|
|
197
|
+
emits: behavior.emits || [],
|
|
198
|
+
actions: behavior.actions || [],
|
|
199
|
+
effects: behavior.effects || [],
|
|
200
|
+
capabilities: capabilityIdsFromBehavior(behavior),
|
|
201
|
+
effect_types: effectTypesFromBehavior(behavior),
|
|
202
|
+
diagnostics,
|
|
203
|
+
check_codes: diagnostics.map(/** @param {any} check */ (check) => check.code)
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const highlights = behaviorHighlights(behaviorRows);
|
|
209
|
+
const affectedCapabilities = stableUnique(behaviorRows.flatMap(/** @param {any} row */ (row) => row.capabilities));
|
|
210
|
+
|
|
211
|
+
return {
|
|
212
|
+
type: "widget_behavior_report",
|
|
213
|
+
filters: conformanceReport.filters,
|
|
214
|
+
summary: {
|
|
215
|
+
total_usages: conformanceReport.summary.total_usages,
|
|
216
|
+
total_behaviors: behaviorRows.length,
|
|
217
|
+
realized: behaviorRows.filter(/** @param {any} row */ (row) => row.behavior.status === "realized").length,
|
|
218
|
+
partial: behaviorRows.filter(/** @param {any} row */ (row) => row.behavior.status === "partial").length,
|
|
219
|
+
declared: behaviorRows.filter(/** @param {any} row */ (row) => row.behavior.status === "declared").length,
|
|
220
|
+
warnings: conformanceReport.summary.warnings,
|
|
221
|
+
errors: conformanceReport.summary.errors,
|
|
222
|
+
affected_widgets: conformanceReport.summary.affected_widgets,
|
|
223
|
+
affected_projections: conformanceReport.summary.affected_projections,
|
|
224
|
+
affected_capabilities: affectedCapabilities
|
|
225
|
+
},
|
|
226
|
+
groups: {
|
|
227
|
+
widgets: groupBehaviorRows(
|
|
228
|
+
behaviorRows,
|
|
229
|
+
/** @param {any} row */ (row) => [row.widget.id].filter(Boolean),
|
|
230
|
+
/** @param {any} row */ (row) => row.key
|
|
231
|
+
),
|
|
232
|
+
screens: groupBehaviorRows(
|
|
233
|
+
behaviorRows,
|
|
234
|
+
/** @param {any} row */ (row) => [row.screen.id].filter(Boolean),
|
|
235
|
+
/** @param {any} row */ (row) => row.key
|
|
236
|
+
),
|
|
237
|
+
capabilities: groupBehaviorRows(
|
|
238
|
+
behaviorRows,
|
|
239
|
+
/** @param {any} row */ (row) => row.capabilities,
|
|
240
|
+
/** @param {any} row */ (row) => row.key
|
|
241
|
+
),
|
|
242
|
+
effects: groupBehaviorRows(
|
|
243
|
+
behaviorRows,
|
|
244
|
+
/** @param {any} row */ (row) => row.effect_types,
|
|
245
|
+
/** @param {any} row */ (row) => row.key
|
|
246
|
+
)
|
|
247
|
+
},
|
|
248
|
+
behaviors: behaviorRows,
|
|
249
|
+
highlights,
|
|
250
|
+
checks: conformanceReport.checks.filter(/** @param {any} check */ (check) => check.code?.startsWith("widget_behavior_")),
|
|
251
|
+
write_scope: conformanceReport.write_scope,
|
|
252
|
+
impact: {
|
|
253
|
+
projections: conformanceReport.impact.projections,
|
|
254
|
+
widgets: conformanceReport.impact.widgets,
|
|
255
|
+
capabilities: affectedCapabilities
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
}
|