Skip to content

Commit

Permalink
Add test for duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
jackson-at-bentley committed Sep 5, 2022
1 parent a55b3d2 commit 89cec07
Show file tree
Hide file tree
Showing 26 changed files with 154 additions and 43 deletions.
2 changes: 1 addition & 1 deletion docs/assets/main.js

Large diffs are not rendered by default.

58 changes: 41 additions & 17 deletions docs/classes/sync.Sync.html

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion docs/functions/sync.toElement.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ <h1>Function toElement</h1></div>
<li class="tsd-description">
<div class="tsd-type-parameters">
<h4 class="tsd-type-parameters-title">Type Parameters</h4>
<section class="tsd-panel tsd-type-parameters">
<h4>Type Parameters</h4>
<ul class="tsd-type-parameters">
<li>
<h4>E<span class="tsd-signature-symbol"> extends </span><a href="../types/nodes.Element.html" class="tsd-signature-type" data-tsd-kind="Type alias">Element</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">ElementProps</span><span class="tsd-signature-symbol">&gt;</span></h4></li></ul></div>
<h4>E<span class="tsd-signature-symbol"> extends </span><a href="../types/nodes.Element.html" class="tsd-signature-type" data-tsd-kind="Type alias">Element</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">ElementProps</span><span class="tsd-signature-symbol">&gt;</span></h4></li></ul></section></div>
<div class="tsd-parameters">
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameter-list">
Expand Down
4 changes: 3 additions & 1 deletion docs/functions/sync.toModel.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ <h1>Function toModel</h1></div>
<li class="tsd-description">
<div class="tsd-type-parameters">
<h4 class="tsd-type-parameters-title">Type Parameters</h4>
<section class="tsd-panel tsd-type-parameters">
<h4>Type Parameters</h4>
<ul class="tsd-type-parameters">
<li>
<h4>M<span class="tsd-signature-symbol"> extends </span><a href="../types/nodes.Model.html" class="tsd-signature-type" data-tsd-kind="Type alias">Model</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">ModelProps</span><span class="tsd-signature-symbol">&gt;</span></h4></li></ul></div>
<h4>M<span class="tsd-signature-symbol"> extends </span><a href="../types/nodes.Model.html" class="tsd-signature-type" data-tsd-kind="Type alias">Model</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">ModelProps</span><span class="tsd-signature-symbol">&gt;</span></h4></li></ul></section></div>
<div class="tsd-parameters">
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameter-list">
Expand Down
4 changes: 3 additions & 1 deletion docs/functions/sync.toSource.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ <h1>Function toSource</h1></div>
<li class="tsd-description">
<div class="tsd-type-parameters">
<h4 class="tsd-type-parameters-title">Type Parameters</h4>
<section class="tsd-panel tsd-type-parameters">
<h4>Type Parameters</h4>
<ul class="tsd-type-parameters">
<li>
<h4>S<span class="tsd-signature-symbol"> extends </span><a href="../types/nodes.Source.html" class="tsd-signature-type" data-tsd-kind="Type alias">Source</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">ExternalSourceProps</span><span class="tsd-signature-symbol">&gt;</span></h4></li></ul></div>
<h4>S<span class="tsd-signature-symbol"> extends </span><a href="../types/nodes.Source.html" class="tsd-signature-type" data-tsd-kind="Type alias">Source</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">ExternalSourceProps</span><span class="tsd-signature-symbol">&gt;</span></h4></li></ul></section></div>
<div class="tsd-parameters">
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameter-list">
Expand Down
7 changes: 5 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ <h2>Getting started 🌱</h2>
</a>
<pre><code class="language-text">npm install --save fir-for-connectors
</code></pre>
<p>If you&#39;re doing your own imports of the iTwin libraries you may encounter a duplicate native library. I need to do more testing to figure out how to properly package <code>fir</code>, for example, so it can be used in <code>connector-framework</code>. If you&#39;re just using <code>fir</code> without <code>connector-framework</code> everything should work fine.</p>
<p>Now install <code>fir</code>&#39;s peer dependency.</p>
<pre><code class="language-text">npm install @itwin/core-common
</code></pre>
<p>You&#39;ll only need <code>@itwin/core-common</code> because <code>fir</code> makes use of those types in its own types.</p>
<pre><code class="language-ts"><span class="hl-7">import</span><span class="hl-1"> </span><span class="hl-7">type</span><span class="hl-1"> { </span><span class="hl-4">Element</span><span class="hl-1">, </span><span class="hl-4">Meta</span><span class="hl-1">, </span><span class="hl-4">Model</span><span class="hl-1"> } </span><span class="hl-7">from</span><span class="hl-1"> </span><span class="hl-6">&#39;fir-for-connectors&#39;</span><span class="hl-1">;</span><br/><span class="hl-7">import</span><span class="hl-1"> { </span><span class="hl-4">Sync</span><span class="hl-1">, </span><span class="hl-4">toElement</span><span class="hl-1">, </span><span class="hl-4">toModel</span><span class="hl-1"> } </span><span class="hl-7">from</span><span class="hl-1"> </span><span class="hl-6">&#39;fir-for-connectors&#39;</span><span class="hl-1">;</span>
</code></pre>
<p>Let&#39;s say we want to add <a href="https://www.itwinjs.org/bis/domains/biscore.ecschema/#urllink">a link</a> to our iModel. We know that the corresponding BIS element is a <code>BisCore:UrlLink</code>. We search the <a href="https://www.itwinjs.org/reference">iTwin API</a> for <em>url link</em> and see <a href="https://www.itwinjs.org/reference/core-common/entities/urllinkprops"><code>UrlLinkProps</code></a>. <code>UrlLinkProps</code> extends <code>ElementProps</code>, so we can use it with <code>fir</code>. Generally, anything with a <em>props</em> at the end is fair game. We&#39;re adding an element, so we define an object of type <code>Element</code> and feed it the props we found.</p>
Expand Down Expand Up @@ -140,7 +143,7 @@ <h3>More iModel things</h3>
<li>Elements with the <code>Element</code> type.</li>
<li>Models with the <code>Model</code> type.</li>
<li>Aspects with the <code>Aspect</code> type. Use <code>Meta</code> for external source aspects. Note the <code>aspects</code> property on <code>Element</code>. The caveat is that aspects cannot have navigation properties until the iTwin API allows you to get their ID.</li>
<li>Link-table relationships with the <code>Relationship</code> type. These take a little bit of care. They have an <code>anchor</code> property for provenance. You can&#39;t feed them to <code>sync</code> because if any part of a relationship changes it&#39;s considered a different relationship: anchor, class, source, or target. Use <code>put</code> instead.</li>
<li>Link-table relationships with the <code>Relationship</code> type. These take a little bit of care. They have an <code>anchor</code> property for provenance. You can&#39;t feed them to <code>sync</code> because if any part of a relationship changes it&#39;s considered a different relationship: anchor, class, source, or target. Use <code>put</code> instead. If a property besides these on a relationship changes, like one specified in a custom schema, <code>put</code> will not update the relationship because it must compare unknown properties between two link-table relationships. This is a limitation that should be addressed if the library is ever updated.</li>
<li>Navigation properties by <a href="#extending-fir-">extending or escaping the library</a>. <code>fir</code> comes with the common ones, like parent-child relationships and element-model relationships.</li>
</ul>

Expand Down
4 changes: 3 additions & 1 deletion docs/types/nodes.Aspect.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
<h1>Type alias Aspect&lt;P&gt;</h1></div>
<div class="tsd-signature">Aspect<span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">P</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">:</span> <a href="nodes.AspectNode.html" class="tsd-signature-type" data-tsd-kind="Type alias">AspectNode</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">P</span><span class="tsd-signature-symbol">&gt;</span></div>
<h4 class="tsd-type-parameters-title">Type Parameters</h4>
<section class="tsd-panel tsd-type-parameters">
<h4>Type Parameters</h4>
<ul class="tsd-type-parameters">
<li>
<h4>P<span class="tsd-signature-symbol"> extends </span><span class="tsd-signature-type">common.ElementAspectProps</span> = <span class="tsd-signature-type">common.ElementAspectProps</span></h4></li></ul><aside class="tsd-sources">
<h4>P<span class="tsd-signature-symbol"> extends </span><span class="tsd-signature-type">common.ElementAspectProps</span> = <span class="tsd-signature-type">common.ElementAspectProps</span></h4></li></ul></section><aside class="tsd-sources">
<ul>
<li>Defined in src/nodes.ts:92</li></ul></aside></div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
Expand Down
4 changes: 3 additions & 1 deletion docs/types/nodes.AspectNode.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
<h1>Type alias AspectNode&lt;P&gt;</h1></div>
<div class="tsd-signature">Aspect<wbr/>Node<span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">P</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Omit</span><span class="tsd-signature-symbol">&lt;</span><a href="nodes.EntityNode.html" class="tsd-signature-type" data-tsd-kind="Type alias">EntityNode</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">P</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">&quot;identifier&quot;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">&quot;element&quot;</span><span class="tsd-signature-symbol">&gt;</span></div>
<h4 class="tsd-type-parameters-title">Type Parameters</h4>
<section class="tsd-panel tsd-type-parameters">
<h4>Type Parameters</h4>
<ul class="tsd-type-parameters">
<li>
<h4>P<span class="tsd-signature-symbol"> extends </span><span class="tsd-signature-type">common.ElementAspectProps</span></h4></li></ul><aside class="tsd-sources">
<h4>P<span class="tsd-signature-symbol"> extends </span><span class="tsd-signature-type">common.ElementAspectProps</span></h4></li></ul></section><aside class="tsd-sources">
<ul>
<li>Defined in src/nodes.ts:23</li></ul></aside></div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
Expand Down
4 changes: 3 additions & 1 deletion docs/types/nodes.Element.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
<h1>Type alias Element&lt;P&gt;</h1></div>
<div class="tsd-signature">Element<span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">P</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">:</span> <a href="nodes.ElementNode.html" class="tsd-signature-type" data-tsd-kind="Type alias">ElementNode</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">P</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">&quot;root subject&quot;</span></div>
<h4 class="tsd-type-parameters-title">Type Parameters</h4>
<section class="tsd-panel tsd-type-parameters">
<h4>Type Parameters</h4>
<ul class="tsd-type-parameters">
<li>
<h4>P<span class="tsd-signature-symbol"> extends </span><span class="tsd-signature-type">common.ElementProps</span> = <span class="tsd-signature-type">common.ElementProps</span></h4></li></ul><aside class="tsd-sources">
<h4>P<span class="tsd-signature-symbol"> extends </span><span class="tsd-signature-type">common.ElementProps</span> = <span class="tsd-signature-type">common.ElementProps</span></h4></li></ul></section><aside class="tsd-sources">
<ul>
<li>Defined in src/nodes.ts:86</li></ul></aside></div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
Expand Down
4 changes: 3 additions & 1 deletion docs/types/nodes.ElementNode.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
<h1>Type alias ElementNode&lt;P&gt;</h1></div>
<div class="tsd-signature">Element<wbr/>Node<span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">P</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Omit</span><span class="tsd-signature-symbol">&lt;</span><a href="nodes.EntityNode.html" class="tsd-signature-type" data-tsd-kind="Type alias">EntityNode</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">P</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-symbol">keyof </span><a href="nodes.ElementPatch.html" class="tsd-signature-type" data-tsd-kind="Type alias">ElementPatch</a><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol"> &amp; </span><a href="nodes.ElementPatch.html" class="tsd-signature-type" data-tsd-kind="Type alias">ElementPatch</a></div>
<h4 class="tsd-type-parameters-title">Type Parameters</h4>
<section class="tsd-panel tsd-type-parameters">
<h4>Type Parameters</h4>
<ul class="tsd-type-parameters">
<li>
<h4>P<span class="tsd-signature-symbol"> extends </span><span class="tsd-signature-type">common.ElementProps</span></h4></li></ul><aside class="tsd-sources">
<h4>P<span class="tsd-signature-symbol"> extends </span><span class="tsd-signature-type">common.ElementProps</span></h4></li></ul></section><aside class="tsd-sources">
<ul>
<li>Defined in src/nodes.ts:15</li></ul></aside></div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
Expand Down
4 changes: 3 additions & 1 deletion docs/types/nodes.Entity.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
<h1>Type alias Entity&lt;P&gt;</h1></div>
<div class="tsd-signature">Entity<span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">P</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">:</span> <a href="nodes.EntityNode.html" class="tsd-signature-type" data-tsd-kind="Type alias">EntityNode</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">P</span><span class="tsd-signature-symbol">&gt;</span></div>
<h4 class="tsd-type-parameters-title">Type Parameters</h4>
<section class="tsd-panel tsd-type-parameters">
<h4>Type Parameters</h4>
<ul class="tsd-type-parameters">
<li>
<h4>P<span class="tsd-signature-symbol"> extends </span><span class="tsd-signature-type">common.EntityProps</span> = <span class="tsd-signature-type">common.EntityProps</span></h4></li></ul><aside class="tsd-sources">
<h4>P<span class="tsd-signature-symbol"> extends </span><span class="tsd-signature-type">common.EntityProps</span> = <span class="tsd-signature-type">common.EntityProps</span></h4></li></ul></section><aside class="tsd-sources">
<ul>
<li>Defined in src/nodes.ts:83</li></ul></aside></div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
Expand Down
4 changes: 3 additions & 1 deletion docs/types/nodes.EntityNode.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
<h1>Type alias EntityNode&lt;P&gt;</h1></div>
<div class="tsd-signature">Entity<wbr/>Node<span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">P</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Omit</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">P</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">&quot;id&quot;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">&quot;isInstanceOfEntity&quot;</span><span class="tsd-signature-symbol">&gt;</span></div>
<h4 class="tsd-type-parameters-title">Type Parameters</h4>
<section class="tsd-panel tsd-type-parameters">
<h4>Type Parameters</h4>
<ul class="tsd-type-parameters">
<li>
<h4>P<span class="tsd-signature-symbol"> extends </span><span class="tsd-signature-type">common.EntityProps</span></h4></li></ul><aside class="tsd-sources">
<h4>P<span class="tsd-signature-symbol"> extends </span><span class="tsd-signature-type">common.EntityProps</span></h4></li></ul></section><aside class="tsd-sources">
<ul>
<li>Defined in src/nodes.ts:12</li></ul></aside></div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
Expand Down
4 changes: 3 additions & 1 deletion docs/types/nodes.ExternalSourceAspectNode.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
<h1>Type alias ExternalSourceAspectNode&lt;P&gt;</h1></div>
<div class="tsd-signature">External<wbr/>Source<wbr/>Aspect<wbr/>Node<span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">P</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Omit</span><span class="tsd-signature-symbol">&lt;</span><a href="nodes.AspectNode.html" class="tsd-signature-type" data-tsd-kind="Type alias">AspectNode</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">P</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-symbol">keyof </span><a href="nodes.ExternalSourceAspectPatch.html" class="tsd-signature-type" data-tsd-kind="Type alias">ExternalSourceAspectPatch</a><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol"> &amp; </span><a href="nodes.ExternalSourceAspectPatch.html" class="tsd-signature-type" data-tsd-kind="Type alias">ExternalSourceAspectPatch</a></div>
<h4 class="tsd-type-parameters-title">Type Parameters</h4>
<section class="tsd-panel tsd-type-parameters">
<h4>Type Parameters</h4>
<ul class="tsd-type-parameters">
<li>
<h4>P<span class="tsd-signature-symbol"> extends </span><span class="tsd-signature-type">common.ExternalSourceAspectProps</span></h4></li></ul><aside class="tsd-sources">
<h4>P<span class="tsd-signature-symbol"> extends </span><span class="tsd-signature-type">common.ExternalSourceAspectProps</span></h4></li></ul></section><aside class="tsd-sources">
<ul>
<li>Defined in src/nodes.ts:26</li></ul></aside></div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
Expand Down
4 changes: 3 additions & 1 deletion docs/types/nodes.ExternalSourceNode.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
<h1>Type alias ExternalSourceNode&lt;P&gt;</h1></div>
<div class="tsd-signature">External<wbr/>Source<wbr/>Node<span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">P</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Omit</span><span class="tsd-signature-symbol">&lt;</span><a href="nodes.ElementNode.html" class="tsd-signature-type" data-tsd-kind="Type alias">ElementNode</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">P</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-symbol">keyof </span><a href="nodes.ExternalSourcePatch.html" class="tsd-signature-type" data-tsd-kind="Type alias">ExternalSourcePatch</a><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol"> &amp; </span><a href="nodes.ExternalSourcePatch.html" class="tsd-signature-type" data-tsd-kind="Type alias">ExternalSourcePatch</a></div>
<h4 class="tsd-type-parameters-title">Type Parameters</h4>
<section class="tsd-panel tsd-type-parameters">
<h4>Type Parameters</h4>
<ul class="tsd-type-parameters">
<li>
<h4>P<span class="tsd-signature-symbol"> extends </span><span class="tsd-signature-type">common.ExternalSourceProps</span></h4></li></ul><aside class="tsd-sources">
<h4>P<span class="tsd-signature-symbol"> extends </span><span class="tsd-signature-type">common.ExternalSourceProps</span></h4></li></ul></section><aside class="tsd-sources">
<ul>
<li>Defined in src/nodes.ts:30</li></ul></aside></div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
Expand Down
Loading

0 comments on commit 89cec07

Please sign in to comment.