Skip to content
PACKAGES

withBlueprintHash()

Attach a content hash to a graph blueprint.

import { withBlueprintHash } from "@graphrefly/ts/graph";
function withBlueprintHash(
blueprint: GraphBlueprint,
options: GraphBlueprintHashOptions,
): GraphBlueprint | Promise<GraphBlueprint>
ParameterTypeDescription
blueprintGraphBlueprintBlueprint to augment.
optionsGraphBlueprintHashOptionsHash algorithm and hashing function.

The blueprint with a computed hash field, or a Promise for one.

import { GRAPH_BLUEPRINT_VERSION, normalizeTopology, withBlueprintHash } from "@graphrefly/ts/graph";
const blueprint = {
version: GRAPH_BLUEPRINT_VERSION,
topology: normalizeTopology({ nodes: [], edges: [] }),
};
await withBlueprintHash(blueprint, {
algorithm: "sha256",
hash: async () => "abc123",
});

packages/ts/src/graph/blueprint.ts