Skip to content

Data Model Reference

Data Model Reference

FlowDelta turns Salesforce Flow metadata into a few normalized types. You need to know them to extend FlowDelta or debug a diff.

Type hierarchy

ParsedFlow (from parser)
↓ (build-model.ts)
GraphModel
├─ GraphNode[] (normalized)
└─ GraphEdge[] (with kind: normal | fault)
↓ (diff-model.ts)
FlowDiff
├─ NodeDiff[] (added/deleted/modified/unchanged/present)
└─ EdgeDiff[] (added/deleted/unchanged/present)

GraphModel

The graph after parsing and canonicalization.

interface GraphModel {
flowName: string; // Metadata fullName when present, otherwise the label or "(unknown)"
label: string; // Display label
processType?: string; // Automation type (e.g., "Flow", "CloudFlow")
nodes: GraphNode[]; // All nodes in the graph
edges: GraphEdge[]; // All connections
}

GraphNode

One node, after canonicalization.

interface GraphNode {
id: string; // Unique identifier (the element <name>)
type: NodeType; // Element type (decision, assignment, etc.)
label: string; // Display label
properties: Record<string, unknown>;
// Canonicalized properties (stripped of coordinates, connectors, etc.)
// See architecture.md for canonicalization rules
}

NodeType (union)

Every supported Salesforce Flow element type:

type NodeType =
| "start" // Flow entry point (synthetic)
| "end" // Flow exit point (synthetic)
| "assignment" // Assignment element
| "decision" // Decision (if/else branch)
| "loop" // Loop element
| "recordLookup" // SOQL lookup
| "recordCreate" // DML create
| "recordUpdate" // DML update
| "recordDelete" // DML delete
| "screen" // Lightning screen
| "subflow" // Subflow call
| "actionCall" // Action invocation
| "apexPluginCall" // Apex plug-in
| "wait" // Wait element
| "step" // Step (deprecated, treated as action)
| "orchestratedStage" // Orchestration stage
| "transform" // Transform element
| "collectionProcessor" // Collection processor
| "customError" // Custom error
| "recordRollback" // Rollback
| "unknown"; // Unmapped or unrecognized type

GraphEdge

A directed edge connecting two nodes.

interface GraphEdge {
id: string; // Composite: `${source}->${target}#${kind}#${label}`
source: string; // Source node id
target: string; // Target node id
kind: "normal" | "fault"; // Connection type (includes kind in identity)
label?: string; // Optional label (outcome name for decisions)
}

Note: Edge identity includes kind (fault or normal), because two nodes can have more than one edge of different kinds.

FlowDiff

The semantic diff. It can be rendered or serialized to JSON.

interface FlowDiff {
flowName: string;
summary: {
addedNodes: number;
removedNodes: number;
modifiedNodes: number;
unchangedNodes: number;
addedEdges: number;
removedEdges: number;
changedFlowAttributes: number;
};
nodes: NodeDiff[];
edges: EdgeDiff[];
mode?: "diff" | "snapshot";
snapshotMeta?: SnapshotMeta;
}
interface SnapshotMeta {
flowName?: string;
label: string;
status?: string;
processType?: string;
apiVersion?: string;
runInMode?: string;
versionNumber?: number;
source: string;
generatedAt: string;
toolVersion: string;
}

NodeDiff

A node’s change status, plus its property deltas.

interface NodeDiff {
id: string;
type: NodeType;
label: string;
status: "added" | "deleted" | "modified" | "unchanged" | "present";
summary?: string;
// One-line card caption. Modified nodes summarize property changes.
// Other statuses describe the element from its current or last known properties.
changes?: PropertyChange[];
// Per-property deltas. Only for "modified".
// Example: { path: "rules[0].conditions[1].value", before: "x", after: "y" }
before?: Record<string, unknown>;
// Full property snapshot from the old version (modified or deleted)
// Renderer uses this for context (faint sibling columns in tables)
after?: Record<string, unknown>;
// Full property snapshot from the new version (modified, added, or present)
}
interface PropertyChange {
path: string; // Dot-path to the changed property (array-indexed if needed)
before: unknown; // Old value
after: unknown; // New value
}

diffModel(oldModel, newModel) produces the comparison statuses.

For an as-built artifact, buildSnapshotDiff(model, snapshotMeta) produces one FlowDiff with mode: "snapshot". Every node and edge has status present, and the current node properties are in after. The comparison counters in the summary stay at zero. The renderer computes the element inventory from the node types.

EdgeDiff

An edge change. Edges have no internal structure to diff, so this holds little data.

interface EdgeDiff {
id: string;
source: string;
target: string;
label?: string;
kind: "normal" | "fault";
status: "added" | "deleted" | "unchanged" | "present";
}

Canonicalization (build-model.ts)

Before diffing, GraphNode.properties are normalized in three steps:

  1. TOP_LEVEL_KEYS removed:

    • name, label, locationX, locationY, elementSubtype, diffStatus
    • Coordinates are the main noise. Removing them means a no-op save produces zero diff
  2. EDGE_KEYS removed at all levels:

    • connector, faultConnector, defaultConnector, nextValueConnector, noMoreValuesConnector
    • Connectors become GraphEdge objects instead
  3. UNORDERED_ARRAY_KEYS sorted stably:

    • capabilityTypes, choiceReferences, dataTypeMappings, filters, inputParameters, outputParameters, processMetadataValues
    • Order-insensitive collections don’t produce false diffs.
    • Array keys not in this list stay positional (for example decision rules and assignment items).

Common property shapes

Decision (decision nodes)

After canonicalization, a decision looks like this:

{
rules: [
{
name: "MyOutcome",
conditions: [
{
leftValueReference: "...",
operator: "Equals",
rightValue: { ... }
}
]
}
],
defaultConnectorLabel: "DefaultOutcome"
}

Assignment (assignment nodes)

{
assignmentItems: [
{
assignToReference: "myVar",
operator: "Assign",
value: { ... }
}
]
}

Record operations (create, update, lookup, delete)

Record Create/Update typically have:

{
inputAssignments: [
{
field: "Phone",
value: { ... }
}
]
}

Record Lookup/Delete typically have:

{
filters: [
{
field: "Id",
operator: "Equals",
value: { ... }
}
]
}

Typed values

Properties often wrap scalars in type discriminators:

{
stringValue: "hello";
}
// or
{
booleanValue: "true";
}
// or
{
numberValue: 42;
}

The renderer unwraps these for display.

Synthetic nodes

FlowDelta adds two virtual nodes:

  • start node (id: FLOW_START, type: "start")

    • The flow entry point
    • Has edges to the actual start node(s) in the parsed flow
  • end node (id: END, type: "end")

    • A terminal node
    • Every leaf edge targets it, so rendering is consistent

This keeps the graph well-formed (one entry, one exit) even when the source XML has several start or end paths.

deepDiff algorithm

src/diff/deep-diff.ts compares two values recursively and returns the property changes:

interface PropertyChange {
path: string; // Dot-notated, array-indexed path
before: unknown;
after: unknown;
}
function deepDiff(oldValue: unknown, newValue: unknown): PropertyChange[];

Example outputs:

// Scalar change
{ path: "rules[0].name", before: "OldName", after: "NewName" }
// Nested object change
{ path: "inputParameters[0].value.stringValue", before: "x", after: "y" }
// Array addition
{ path: "conditions[2]", before: undefined, after: {...} }

The diff is structural. It recurses into every level and reports each leaf change. Adds and removes aren’t special cases: they show up as undefined → value or value → undefined.

Data flow through the pipeline

Flow XML
↓ parser (flow_parser.ts)
ParsedFlow
{ elements: [...], transitions: [...], label, fullName }
↓ build-model (buildGraphModel)
GraphModel
{ nodes: [...], edges: [...], label, flowName }
↓ diff-model (diffModel)
FlowDiff
{ nodes: [NodeDiff...], edges: [EdgeDiff...], summary: {...} }
↓ layout (layoutFlow)
LayoutedFlow (GraphModel + position data)
↓ renderHTML (renderHtml)
Self-contained HTML artifact

Each stage treats its input as read-only. Later stages only add to it (position data, diff status, property changes). They never destroy anything.