# deriveMapping

Canonical: https://docs.shumoku.dev/en/library/api/deriveMapping
Language: en

@shumoku/core · 0.6.1 · function

# deriveMapping

[Source](https://github.com/konoe-akitoshi/shumoku/blob/main/libs/@shumoku/core/src/libs/@shumoku/core/src/observation/metrics-binding.ts#L57)

Derive a legacy \`MetricsMapping\` from the bindings in an observation record, keyed by the drawn graph's element ids (the record is keyed by the same ids). - Node host binding → \`mapping.nodes\[node.id\]\`. - Link interface binding lives on a port's record; we attribute it to the link whose endpoint references that port, keyed \`link.id || link-${i}\` to match the rest of the server (server.ts / topologies.ts). Pure; never mutates the input.

```
deriveMapping(graph: Pick<NetworkGraph, "nodes" | "links">, observation: ObservationLayer | undefined, activeSourceIds?: ReadonlySet<string>): MetricsMapping
```

## Parameters

| Parameter | Type | Description | Default |
| --- | --- | --- | --- |
| `graph` | `Pick<NetworkGraph, "nodes" | "links">` | No additional description. | `—` |
| `observation` | `ObservationLayer | undefined` | No additional description. | `—` |
| `activeSourceIds` | `ReadonlySet<string>` | No additional description. | `—` |

## Returns

```
MetricsMapping
```

[`libs/@shumoku/core/src/libs/@shumoku/core/src/observation/metrics-binding.ts:57`](https://github.com/konoe-akitoshi/shumoku/blob/main/libs/@shumoku/core/src/libs/@shumoku/core/src/observation/metrics-binding.ts#L57)
