feat(topology): scan-based creation wizard option (Pro contract + wiring)

Adds the @pro ScanImport contract (ProScanImportProps/ProScanImport) and
a null community stub, and slots a third SCAN-BASED card into
CreateTopologyWizard, gated on the pro panel being present so it
tree-shakes out of the community build. The scan->topology importer
itself ships in decnet/pro v1.2.0. CHANGELOG updated under [1.2.0].
This commit is contained in:
2026-06-18 20:35:35 -04:00
parent d7a2b5b9cf
commit b0bf31a31e
5 changed files with 103 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { proRoutes } from '@pro';
import { proRoutes, ScanImport } from '@pro';
// In the community build, `@pro` resolves to the stub: no Professional pages,
// so App's route map and Layout's nav group both tree-shake to nothing.
@@ -7,4 +7,10 @@ describe('pro tier — community build', () => {
it('ships no pro routes', () => {
expect(proRoutes).toEqual([]);
});
// null tree-shakes the wizard's third "SCAN-BASED" card out of the community
// bundle — the scan→topology importer is Professional-only.
it('ships no scan importer', () => {
expect(ScanImport).toBeNull();
});
});

View File

@@ -3,6 +3,10 @@
// sets VITE_DECNET_PRO=1 with decnet/pro/web/ present, in which case Vite
// aliases `@pro` to the real registry. proRoutes being empty lets the router
// and nav tree-shake the pro surface out of the community bundle.
import type { ProRoute } from './types';
import type { ProRoute, ProScanImport } from './types';
export const proRoutes: ProRoute[] = [];
// No scan-based topology creation in the community build — the wizard's third
// card tree-shakes out when this is null.
export const ScanImport: ProScanImport = null;

View File

@@ -1,7 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
// Contract for Professional-tier UI pages. The pro build aliases `@pro` to the
// real registry in decnet/pro/web/; the community build resolves it to ./stub.
import type { ReactElement, ReactNode } from 'react';
import type { ComponentType, ReactElement, ReactNode } from 'react';
export interface ProRoute {
/** Router path, e.g. "/pro/intel". Convention: prefix pro routes with /pro. */
@@ -13,3 +13,35 @@ export interface ProRoute {
/** Page element rendered at `path`. May be a lazy component (App wraps Suspense). */
element: ReactElement;
}
/** Created-topology summary handed back to the wizard. Mirrors the wizard's own
* TopologySummary (and GET /topologies rows) structurally so the wizard's
* onCreated handler is assignable without a cross-tree type import. */
export interface ProTopologySummary {
id: string;
name: string;
mode: string;
target_host_uuid: string | null;
status: string;
version: number;
needs_resync?: boolean;
created_at: string;
status_changed_at: string | null;
}
/** Props the CreateTopologyWizard passes to the pro scan-import panel. The pro
* build owns the entire scan→topology flow (file pick, parse, preview, create)
* and signals completion through `onCreated`; the community build never sees
* this surface. Kept structural — the pro tree implements the shape without
* importing it, mirroring how `ProRoute` crosses the trust boundary. */
export interface ProScanImportProps {
/** "unihost" | "agent" — chosen in the wizard's TARGET step. */
mode: string;
/** Agent host UUID, or null for local. */
targetHostUuid: string | null;
/** Fires with the created topology summary; the wizard closes and navigates. */
onCreated: (row: ProTopologySummary) => void;
}
/** `null` in the community build (no scan import); a component in the pro build. */
export type ProScanImport = ComponentType<ProScanImportProps> | null;