# AssemblyManager

Auto-generated from the @jbrowse/mobx-state-tree model in the source — see the [developer guide](https://jbrowse.org/jb2/docs/developer_guide/) for concepts. Built into JBrowse core. [View source](https://github.com/GMOD/jbrowse-components/blob/main/packages/core/src/assemblyManager/assemblyManager.ts).

Keeps an `Assembly` for each assembly in the config and the session, and
looks one up by name or alias.

## Properties

| Member | Description |
| --- | --- |
| **assemblies**<br><code>assemblies: types.array(assemblyFactory(conf, pm))</code> | this is automatically managed by an autorun which looks in the parent session.assemblies, session.sessionAssemblies, and session.temporaryAssemblies |

## Volatiles

| Member | Description |
| --- | --- |
| **unrecognizedReports**<br><code>{ report(session: unknown, name: string, handlerCount: number, fire: () =&gt; unknown): void; reportFor(session: unknown, name: string): { handled: boolean; claim?: Promise&lt;void&gt; &#124; undefined; } &#124; undefined; }</code> | rate limiter for `get`'s `Core-handleUnrecognizedAssembly` reports, so each unknown name reaches the extension point once per session |

## Getters

| Member | Description |
| --- | --- |
| **assemblyNameMap**<br><code>Record&lt;…&gt;</code> |  |
| **assemblyNamesList**<br><code>string[]</code> | the canonical name of every configured assembly, read the way the afterAttach autorun names the models it builds |
| **confByName**<br><code>Map&lt;string, AnyConfigurationModel&gt;</code> | Every name the *configs* answer to — each assembly's `name` and its `aliases` — mapped to its config, which exists before the assembly's model does. What has knows before the models exist, and resolved by the same precedence as `assemblyNameMap`. |
| **assemblyList**<br><code>AnyConfigurationModel[]</code> | combined jbrowse.assemblies, session.sessionAssemblies, and session.temporaryAssemblies |
| **rpcManager**<br><code>RpcManager</code> |  |

## Methods

| Member | Description |
| --- | --- |
| **getCanonicalAssemblyName**<br><code>(asmName: string) =&gt; string</code> |  |
| **getDisplayName**<br><code>(asmName: string) =&gt; string</code> |  |
| **get**<br><code>(asmName: string) =&gt; (ModelInstanceTypeProps&lt;…&gt; &amp; {…} &amp; {…} &amp; {…} &amp; {…} &amp; {…} &amp; {…} &amp; {…} &amp; {…} &amp; {…} &amp; {…} &amp; {…} &amp; {…} &amp; { getCanonicalRefName2(refName: string): string; isValidRefName(refName: string): boolean; } &amp; { isCircularRefName(refName: string): boolean; getRefNamePosition(refName: string): number &#124; undefined; getAliasesForRefName(refName: string): string[]; getRefNameMapForAdapter(adapterConf: AdapterConf, options: BaseOptions): Promise&lt;…&gt;; getRefNameMismatch(adapterCacheKey: string): RefNameMismatch &#124; undefined; } &amp; IStateTreeNode&lt;…&gt;) &#124; undefined</code> | The assembly `asmName` names, or undefined. Reports a name it doesn't know to `Core-handleUnrecognizedAssembly` so a plugin can go supply it, which is a side effect: a caller only asking *whether* the session has the assembly wants has instead. Each name is reported at most once per session, since a handler resolves it out of band and the assembly turning up is itself the reactive signal. |
| **has**<br><code>(asmName: string) =&gt; boolean</code> | Whether the session knows this assembly. Use this, not `get`, to ask only whether the assembly is present: `!has(name)` is exactly the condition under which `get` reports `name` to `Core-handleUnrecognizedAssembly`, so probing with `get` tells every installed plugin to go resolve a name that a caller supplying the assembly itself (a hub connection, MAF row navigation) is about to create. |
| **loadingAssembly**<br><code>(asmNames: string[]) =&gt; (ModelInstanceTypeProps&lt;…&gt; &amp; {…} &amp; {…} &amp; {…} &amp; {…} &amp; {…} &amp; {…} &amp; {…} &amp; {…} &amp; {…} &amp; {…} &amp; {…} &amp; {…} &amp; { getCanonicalRefName2(refName: string): string; isValidRefName(refName: string): boolean; } &amp; { isCircularRefName(refName: string): boolean; getRefNamePosition(refName: string): number &#124; undefined; getAliasesForRefName(refName: string): string[]; getRefNameMapForAdapter(adapterConf: AdapterConf, options: BaseOptions): Promise&lt;…&gt;; getRefNameMismatch(adapterCacheKey: string): RefNameMismatch &#124; undefined; } &amp; IStateTreeNode&lt;…&gt;) &#124; undefined</code> | The first of `asmNames` that hasn't finished loading — the one a view blocked on them is waiting for, and whose `statusMessage` / `statusProgress` its spinner should show. Returns the assembly itself (a stable reference, so a consuming getter doesn't invalidate on every read) or undefined once they are all loaded. |
| **settleAssemblyResolution**<br><code>(assemblyName: string) =&gt; Promise&lt;void&gt;</code> | Wait out whatever might still be about to supply `assemblyName`, and resolve once nothing is.<br><br>Resolution is a chain of events, not a duration: a handler probes and adds a connection, the connection fetches a config, the config's assemblies land in the session. Each link is observable, so each is waited on rather than guessed at.<br><br>- the handler's own promise, if it returned one, covers the part before the session gains anything to watch (the hubs plugin's HEAD probe) - any connection still fetching could be carrying the assembly, so its `loading` flag going false is the next event. Every loading connection counts, not just one naming this assembly: a connection config need not declare what it will turn out to provide, and waiting for one connection too many costs a moment while missing one returns the wrong answer.<br><br>A handler that returned nothing gets UNDECLARED_HANDLER_GRACE_MS instead, because it left nothing to wait on. |
| **waitForAssembly**<br><code>(assemblyName: string) =&gt; Promise&lt;…&gt;</code> | use this method instead of assemblyManager.get(assemblyName) to get an assembly with regions loaded |
| **requireAssembly**<br><code>(assemblyName: string) =&gt; Promise&lt;…&gt;</code> | waitForAssembly, but a name that cannot be resolved is an error rather than an `undefined` for the caller to interpret.<br><br>Use it where a missing assembly produces a wrong result with no error. A refName map is one case: an empty map means an adapter gets queried with un-renamed refNames, finds nothing, and the track draws blank. Throwing here shows the assembly name to the user, who can add the assembly or fix the track.<br><br>`waitForAssembly` returns only once every handler and connection that could supply the name has finished, so an unresolved name here is final and throwing does not race a late load. |
| **getRefNameMapForAdapter**<br><code>(adapterConf: AdapterConf, assemblyName: string &#124; undefined, opts: AssemblyBaseOpts) =&gt; Promise&lt;RefNameAliases&gt;</code> | The refName map for an adapter under `assemblyName`. Throws if the assembly cannot be resolved — see requireAssembly. No `assemblyName` at all is not a failure, just nothing to rename. |
| **isValidRefName**<br><code>(refName: string, assemblyName: string) =&gt; boolean</code> |  |

## Actions

| Member | Description |
| --- | --- |
| **removeAssembly**<br><code>(asm: ModelInstanceTypeProps&lt;…&gt; &amp; {…} &amp; {…} &amp; {…} &amp; {…} &amp; {…} &amp; {…} &amp; {…} &amp; {…} &amp; {…} &amp; {…} &amp; {…} &amp; {…} &amp; { getCanonicalRefName2(refName: string): string; isValidRefName(refName: string): boolean; } &amp; { isCircularRefName(refName: string): boolean; getRefNamePosition(refName: string): number &#124; undefined; getAliasesForRefName(refName: string): string[]; getRefNameMapForAdapter(adapterConf: AdapterConf, options: BaseOptions): Promise&lt;…&gt;; getRefNameMismatch(adapterCacheKey: string): RefNameMismatch &#124; undefined; } &amp; IStateTreeNode&lt;…&gt;) =&gt; void</code> | private: you would generally want to add to manipulate jbrowse.assemblies, session.sessionAssemblies, or session.temporaryAssemblies instead of using this directly |
| **addAssembly**<br><code>(configuration: any) =&gt; void</code> | private: you would generally want to add to manipulate jbrowse.assemblies, session.sessionAssemblies, or session.temporaryAssemblies instead of using this directly<br><br>this can take an active instance of an assembly, in which case it is referred to, or it can take an identifier e.g. assembly name, which is used as a reference. snapshots cannot be used |

