blueprint-graph-api

Graph-only Blueprint browser API.

This module is emitted as -verso-data/api/graph.mjs in generated sites. It exposes URL helpers, graph data readers, and graph-block render helpers. Data-only calls do not load the interactive graph renderer; render helpers lazy-load it when called.

Use the data helpers when a dashboard needs finalized graph records from the manifest or graph JSON embedded beside a rendered graph block. Use renderGraphData to create the standard graph UI from a finalized manifest graph record, or renderGraphs / renderGraphBlock when the page already contains generated graph-block markup. Rendering graph blocks requires an explicit preview renderer from api/preview.mjs so graph popovers and nested previews use the same manifest/cache loader and hydration path as the rest of the page.

Description:
  • Graph-only Blueprint browser API.

    This module is emitted as -verso-data/api/graph.mjs in generated sites. It exposes URL helpers, graph data readers, and graph-block render helpers. Data-only calls do not load the interactive graph renderer; render helpers lazy-load it when called.

    Use the data helpers when a dashboard needs finalized graph records from the manifest or graph JSON embedded beside a rendered graph block. Use renderGraphData to create the standard graph UI from a finalized manifest graph record, or renderGraphs / renderGraphBlock when the page already contains generated graph-block markup. Rendering graph blocks requires an explicit preview renderer from api/preview.mjs so graph popovers and nested previews use the same manifest/cache loader and hydration path as the rest of the page.

Members

(static, constant) dataUrl

Description:
  • Resolve a generated data filename under -verso-data/.

Resolve a generated data filename under -verso-data/.

(static, constant) graphApiModuleUrl

Description:
  • Resolve the generated graph API module URL.

Resolve the generated graph API module URL.

(static, constant) loadGraphs

Description:
  • Load finalized graph records from this generated site's default manifest.

    This is the simplest graph-data entry point for dashboards and audits that need graph records but do not need to render graph blocks.

Load finalized graph records from this generated site's default manifest.

This is the simplest graph-data entry point for dashboards and audits that need graph records but do not need to render graph blocks.

Example
// Import graph data helpers when no graph rendering is needed.
import { loadGraphs } from "./-verso-data/api/graph.mjs";

// Load finalized graph records from the generated manifest.
const graphs = await loadGraphs();
for (const graph of graphs) {
  console.log(graph.key, graph.nodes.length, graph.edges.length);
}

(static, constant) loadManifestGraphs

Description:
  • Load finalized graph records from a manifest URL.

Load finalized graph records from a manifest URL.

(static, constant) version

Description:
  • Graph API schema/runtime version.

Graph API schema/runtime version.

Methods

(static) createGraphBlock(graphData, optionsopt) → {Promise.<(Element|null)>}

Description:
  • Create standard Blueprint graph-block markup from finalized graph data.

    This is useful when a custom browser client loaded graph records with loadGraphs and wants to insert the same graph block shape used by generated pages. The returned element is not rendered until it is inserted and passed to renderGraphBlock, or until renderGraphData is used. Returns null when the graph record does not contain precomputed render variants and no options.variants override is supplied.

Parameters:
Name Type Attributes Description
graphData BlueprintGraphData

Finalized graph record.

options BlueprintGraphRenderOptions <optional>

Graph render options.

Returns:

Standard graph block, or null when no render variants are available.

Type
Promise.<(Element|null)>

(static) getGraphData(rootopt) → {BlueprintGraphData|null}

Description:
  • Read embedded graph data from the current graph page or supplied root.

    This is for pages that already contain generated graph-block markup. Use loadGraphs when the current document does not contain the graph you want to inspect.

Parameters:
Name Type Attributes Description
root ParentNode | Element | Document | DocumentFragment <optional>

Search root.

Returns:
Type
BlueprintGraphData | null

(static) getGraphVariants(rootopt) → {Array.<BlueprintGraphVariant>}

Description:
  • Read embedded graph variants from the current graph page or supplied root.

Parameters:
Name Type Attributes Description
root ParentNode | Element | Document | DocumentFragment <optional>

Search root.

Returns:
Type
Array.<BlueprintGraphVariant>

(static) renderGraphBlock(graphBlock, optionsopt) → {Promise.<(BlueprintGraphController|null)>}

Description:
  • Render one standard .bp_graph_fullwidth graph block.

    The block must be generated Blueprint graph markup. Pass previewUtils from createPreview() so node preview panels use the same renderer as the rest of the client.

Example
// Graph rendering needs a preview renderer for popovers and hydration.
import { createPreview } from "./-verso-data/api/preview.mjs";
import { renderGraphBlock } from "./-verso-data/api/graph.mjs";

// Create one preview renderer for graph node previews.
const previewUtils = createPreview();

// Initialize one generated graph block and force an immediate render.
await renderGraphBlock(document.querySelector(".bp_graph_fullwidth"), {
  previewUtils,
  refresh: true
});
Parameters:
Name Type Attributes Description
graphBlock Element

Standard graph block.

options BlueprintGraphRenderOptions <optional>

Graph render options.

Returns:
Type
Promise.<(BlueprintGraphController|null)>

(static) renderGraphData(host, graphData, optionsopt) → {Promise.<(BlueprintGraphController|null)>}

Description:
  • Render finalized graph data into a host element.

    This constructs the standard .bp_graph_fullwidth block, inserts it into host, lazy-loads the graph renderer, and returns the same controller as renderGraphBlock. Pass replace: false to append instead of replacing the host's existing children. Returns null without changing host when the graph record does not contain precomputed render variants and no options.variants override is supplied.

Example
import { createPreview } from "./-verso-data/api/preview.mjs";
import { loadGraphs, renderGraphData } from "./-verso-data/api/graph.mjs";

const previewUtils = createPreview();
const [graph] = await loadGraphs();
await renderGraphData(document.querySelector("#graph-host"), graph, {
  previewUtils,
  layout: "fill"
});
Parameters:
Name Type Attributes Description
host Element

Element that will contain the graph block.

graphData BlueprintGraphData

Finalized graph record, typically from loadGraphs.

options BlueprintGraphRenderOptions <optional>

Graph render options.

Returns:

Graph controller, or null when no graph block can be built.

Type
Promise.<(BlueprintGraphController|null)>

(static) renderGraphs(rootopt, optionsopt) → {Promise.<Array.<BlueprintGraphController>>}

Description:
  • Render every standard graph block under a document, element, or fragment.

    This initializes the same interactive graph UI used by generated Blueprint pages. It does not create graph markup from raw graph data; the root must already contain generated .bp_graph_fullwidth blocks.

Example
// Graph rendering needs a preview renderer for popovers and hydration.
import { createPreview } from "./-verso-data/api/preview.mjs";
import { renderGraphs } from "./-verso-data/api/graph.mjs";

// Create one preview renderer and initialize every graph under a custom root.
const previewUtils = createPreview();
await renderGraphs(document.querySelector("#slide"), {
  previewUtils,
  layout: "fill",
  refresh: true
});
Parameters:
Name Type Attributes Description
root ParentNode | Element | Document | DocumentFragment <optional>

Search root.

options BlueprintGraphRenderOptions <optional>

Graph render options.

Returns:
Type
Promise.<Array.<BlueprintGraphController>>