Constructor
new AppModel(optionsopt)
Creates an empty model.
Parameters:
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
Model options. Properties
|
- Source:
Members
__edgeKeys :Set:.<string:>
Type:
- Source:
__in :Map:.<string:, Array:.<object:>>|null
Type:
- Source:
__out :Map:.<string:, Array:.<object:>>|null
Adjacency indexes, invalidated whenever an edge is added.
Type:
- Source:
__unresolvedKeys :Set:.<string:>
Type:
- Source:
edges :Array:.<object:>
Every edge, in insertion order. Deduplicated by AppModel#edgeKey.
Type:
- Source:
errors :Array:.<{phase:: string:, code:: string:, message:: string:}>
Phases that failed while the model was being built.
A query command analyses a project that may not compile — that is often exactly why it is being run — so a phase is allowed to fail without losing the rest of the model. What failed is recorded here so the answer can say which part of the project is missing from it.
Type:
- Source:
nodes :Map:.<string:, object:>
Nodes by id.
Type:
- Source:
requireNodes :boolean
Whether an edge requires both of its endpoints to exist.
Type:
- boolean
- Source:
unresolved :Array:.<object:>
Relationships analysis could not resolve.
Type:
- Source:
Methods
addEdge(edge) → {boolean}
Adds an edge between two nodes.
An edge naming a node that does not exist is dropped rather than creating a phantom: every query walks this graph, and a dangling target would print as a relationship to nothing.
Parameters:
| Name | Type | Description |
|---|---|---|
edge |
object |
|
- Source:
Returns:
True when the edge was stored.
- Type
- boolean
addNode(node) → {object}
Adds a node, merging into an existing one with the same id.
Merging matters because a node can be discovered twice from two directions — a bridge is created when it is analysed and referenced again when a component imports it — and the second sighting must not erase the first one's location or metadata.
Parameters:
| Name | Type | Description |
|---|---|---|
node |
object | The node. Must carry |
- Source:
Returns:
The stored node.
- Type
- object
addUnresolved(entry) → {boolean}
Records something analysis could not resolve.
Parameters:
| Name | Type | Description |
|---|---|---|
entry |
object |
|
- Source:
Returns:
True when the entry was stored.
- Type
- boolean
counts() → {Object:.<string:, number:>}
A count of each node kind, for the avenx atlas summary.
- Source:
Returns:
Counts keyed by kind.
edgeKey(edge) → {string}
The deduplication key for an edge.
Location is part of the key so two distinct call sites of the same action
stay two edges — avenx impact prints them as separate lines, which is
the point.
Parameters:
| Name | Type | Description |
|---|---|---|
edge |
object | The edge. |
- Source:
Returns:
The key.
- Type
- string
getNode(id) → {object|undefined}
Looks a node up by id.
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string | The node id. |
- Source:
Returns:
The node.
- Type
- object | undefined
hasNode(id) → {boolean}
Whether a node id is present.
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string | The node id. |
- Source:
Returns:
True when the node exists.
- Type
- boolean
incoming(id) → {Array:.<object:>}
Edges entering a node — what depends on it.
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string | The node id. |
- Source:
Returns:
The edges.
merge(fragment) → {void}
Merges a fragment produced against another model into this one.
Node and edge ids are absolute, so a fragment built in isolation slots in without rewriting. This model's own edge rules apply during the merge, which is what lets a fragment be captured leniently and still be checked when it lands.
Parameters:
| Name | Type | Description |
|---|---|---|
fragment |
Object | What to merge. |
- Source:
Returns:
- Type
- void
nodesOfKind(kind) → {Array:.<object:>}
Every node of a given kind.
Parameters:
| Name | Type | Description |
|---|---|---|
kind |
string | One of AtlasNodeKind. |
- Source:
Returns:
The nodes, ordered by id.
outgoing(id) → {Array:.<object:>}
Edges leaving a node — what it depends on.
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string | The node id. |
- Source:
Returns:
The edges.
toJSON() → {object}
Serializes the model.
Nodes, edges and unresolved entries are sorted rather than emitted in discovery order, so two builds of unchanged sources produce byte-identical output and the artifact can be diffed in review.
- Source:
Returns:
The serializable model.
- Type
- object
unresolvedFor(owner) → {Array:.<object:>}
The unresolved entries recorded against one owner.
Parameters:
| Name | Type | Description |
|---|---|---|
owner |
string | An owner node id. |
- Source:
Returns:
The entries.