# core/converters/layer.reference.converter.ts

> 37 lines of code and 6 definitions.

Tree: Bane's Lab Build Scripts
Language: typescript
Layer: processing
Canonical: https://banes-lab.com/anatomy/build-scripts#file-build-scripts-core-converters-layer-reference-converter-ts
Source text: https://banes-lab.com/source/build-scripts/core/converters/layer.reference.converter.ts.txt

Listed in [core/converters](https://banes-lab.com/api/source/build-scripts/core/converters.md), after [core/converters/layer.converter.ts](https://banes-lab.com/source/build-scripts/core/converters/layer.converter.ts.md) and before [core/converters/learning.catalog.converter.ts](https://banes-lab.com/source/build-scripts/core/converters/learning.catalog.converter.ts.md).

## Definitions

- `layerRecord` (lexical_declaration, line 11, exported)
- `tensionRecord` (lexical_declaration, line 28, exported)
- `PAIR_JOINER` (lexical_declaration, line 6)
- `TENSION_KIND` (lexical_declaration, line 7)
- `LAYER_KIND` (lexical_declaration, line 8)
- `MECHANISM_RELATION` (lexical_declaration, line 9)

## Contained in

- [core/converters](https://banes-lab.com/anatomy/build-scripts/folder-build-scripts-core-converters.md)

## Uses

- [core/factories/reference.factory.ts](https://banes-lab.com/source/build-scripts/core/factories/reference.factory.ts.md)

## Used by

- [core/converters/reference.converter.ts](https://banes-lab.com/source/build-scripts/core/converters/reference.converter.ts.md)

## Linked from

- [core/converters](https://banes-lab.com/anatomy/build-scripts/folder-build-scripts-core-converters.md)
- [core/factories](https://banes-lab.com/anatomy/build-scripts/folder-build-scripts-core-factories.md)

## Source

```typescript
import { CONTRACT_RELATION, REFERENCED_BY_RELATION, TENSIONS_WITH_RELATION } from "@govlab/constants";
import type { LayerNodeView, TensionView } from "@banes-lab/web/types/ontology.types.js";
import { relationOf, singleRelation } from "#core/factories/reference.factory";
import type { ReferenceRecord } from "@banes-lab/web/types/reference.types.js";

const PAIR_JOINER = " / ";
const TENSION_KIND = "tension";
const LAYER_KIND = "layer";
const MECHANISM_RELATION = "mechanism";

export const layerRecord = function layerRecord(
    view: LayerNodeView,
    intents: ReadonlyMap<string, string>,
): ReferenceRecord {
    return {
        code: null,
        kind: LAYER_KIND,
        layer: null,
        name: view.label,
        relations: [
            ...singleRelation(CONTRACT_RELATION, view.contract),
            ...relationOf(REFERENCED_BY_RELATION, view.members),
        ],
        summary: intents.get(view.contract.ref ?? "") ?? null,
    };
};

export const tensionRecord = function tensionRecord(view: TensionView): ReferenceRecord {
    return {
        code: null,
        kind: TENSION_KIND,
        layer: null,
        name: view.a.label + PAIR_JOINER + view.b.label,
        relations: [
            { edges: [view.a, view.b], relation: TENSIONS_WITH_RELATION },
            ...singleRelation(MECHANISM_RELATION, view.mechanism),
        ],
        summary: view.rule,
    };
};
```
