mirror of
https://github.com/kc4x4sar/d4h-typescript.git
synced 2026-07-12 17:21:05 -07:00
Separate classes for groups of methods (#1)
* added resourcetype interface that's imported and reused * added membergroupmembership; comments formatting typedoc output; updated types * separate classes for groups of methods * additional methods added, suggested changes made, typedoc documentation improved
This commit is contained in:
@@ -1 +1 @@
|
||||
window.navigationData = "eJyV1l1P2zAUBuD/kms0tA4Q4q5A+ZCK2FrQLtCETuNTatUfme0A1cR/n4fX1inOsbl+Xz9xbKfuw5/K4aurTqqz1jotLzgKdrdqsNqrGnALH6Bqpd3fib8snBS+s+SKVSfHb3sbh+EcWuG242sB1qLd/x90R34dxGOHjBm09lrN9XY8Vw7NHGpPRHmXGRwexYziEkRaeI+owdGLJoUoL2TuGwYOc1ho5ckblDM0UweutYQZ1yh0JIGL3gXfpCTxu+WNROXGugbHtUpTuy2KvEQXdsreNv+66Tf90MqQl0a3TU7slDLgtao586+UIXdqGTTs3PAFDMvNNVEtwosWIlEtwovYz4BlEy2c448WBJ/zcAQzcKpL8et9TnrrsAQgP6Td0mfAU62XEsyyCF6XSx5w+6LQkOp7o4SaaOsyVqiUYHfwREo+pxhyI0o2IJzN5PAQ5QeHz5sgQoGC5PZTTjpRnp9P0VlKV/M4ca+V3mhxbwwzTP8R+NDKk8Q9Hhco6PtCK+y9bTcpSRh/45nVSKJ5QlWvzrRyUKd/c3q6FN/5zUuinQZFTdDq1tTpFVuHNOC4QTZBsD1z6TRISoueefiAGjjFWitWuuC9beoRP9E7aHqPRZRTzPnB1ePpcDp6vJ+Mt84zGA4z4Zk47zrfBm+//gKy3ChR"
|
||||
window.navigationData = "eJyN1F1PwjAUBuC/QnZNRDGShTtC1JBgjESuCCGlK+zEfixtpxjDf7eu7AvpGbc973l2tp1t9RNZdrDROJpJYwnnIPdRP8qITd1ZomgumLRmUFdvUiu4i3yATKJxfB/Ho9v42K+cpXGhnk1Zbw5bTfT3Ja4IbVxocwp1qY8HIjLOzCWsrHUZUyWthm1uA/fYrHdZ7pgdakSoJHcTDIrjdu+wH9EUeKKZjMarCphQqnJ31dqgnBhTGWW9jd0Nm0NMqIVPsMAQpUygjgRBeBjxZUyY5sYq8QSMJ0GmmcGshO1Izm2IOZUx4VmrPAvO4atY/0xSSBjycqoAprwwsWU6aJzKmPCq90SCIRaUDDqtEKa95YTDDijOtVOYt1A8vHhFEet+Z0QEu4ti98bW7SAt0ztCz3b27Et8GF1eWcRppDBs/7dTpzeaQoaAZ0kMLbcM0crINcxCGdd9BeaDGDlXfj8QrIxgjH8MCOID3cTki+jmjycA+RjGiSJX/CEQrZHqnm2ZJcSyztl8DONaXybitXL/wfVx/Qu4KLXE"
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html><html class="default" lang="en" data-base=".."><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>Accounts | d4h-typescript</title><meta name="description" content="Documentation for d4h-typescript"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search"><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">d4h-typescript</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">d4h-typescript</a></li><li><a href="../modules/index.html">index</a></li><li><a href="index.Accounts.html">Accounts</a></li></ul><h1>Class Accounts</h1></div><aside class="tsd-sources"><ul><li>Defined in src/api/accounts.ts:5</li></ul></aside><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><h5 class="tsd-index-heading uppercase" role="button" aria-expanded="false" tabIndex="0"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-chevronSmall"></use></svg> Index</h5></summary><div class="tsd-accordion-details"><section class="tsd-index-section"><h3 class="tsd-index-heading">Constructors</h3><div class="tsd-index-list"><a href="index.Accounts.html#constructor" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a>
|
||||
</div></section><section class="tsd-index-section"><h3 class="tsd-index-heading">Methods</h3><div class="tsd-index-list"><a href="index.Accounts.html#whoami" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>who<wbr/>AmI</span></a>
|
||||
<a href="index.Accounts.html#whoamiall" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>who<wbr/>AmIAll</span></a>
|
||||
</div></section></div></details></section></section><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Constructors"><h2><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg> Constructors</h2></summary><section><section class="tsd-panel tsd-member"><a id="constructor" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>constructor</span><a href="#constructor" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="constructoraccounts" class="tsd-anchor"></a><span class="tsd-signature-keyword">new</span> <span class="tsd-kind-constructor-signature">Accounts</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">d4hInstance</span><span class="tsd-signature-symbol">:</span> <a href="index.default.html" class="tsd-signature-type tsd-kind-class">default</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a href="index.Accounts.html" class="tsd-signature-type tsd-kind-class">Accounts</a><a href="#constructoraccounts" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">d4hInstance</span>: <a href="index.default.html" class="tsd-signature-type tsd-kind-class">default</a></span></li></ul></div><h4 class="tsd-returns-title">Returns <a href="index.Accounts.html" class="tsd-signature-type tsd-kind-class">Accounts</a></h4><aside class="tsd-sources"><ul><li>Defined in src/api/accounts.ts:8</li></ul></aside></li></ul></section></section></details><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Methods"><h2><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg> Methods</h2></summary><section><section class="tsd-panel tsd-member"><a id="whoami" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>who<wbr/>AmI</span><a href="#whoami" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="whoami-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">whoAmI</span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">context</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">"team"</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"organisation"</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"admin"</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">contextId</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">WhoAmIType</span><span class="tsd-signature-symbol">></span><a href="#whoami-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">context</span>: <span class="tsd-signature-type">"team"</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"organisation"</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"admin"</span></span><div class="tsd-comment tsd-typography"><p>The point of view from where the request takes place</p>
|
||||
</div><div class="tsd-comment tsd-typography"></div></li><li><span><span class="tsd-kind-parameter">contextId</span>: <span class="tsd-signature-type">number</span></span><div class="tsd-comment tsd-typography"><p>Either a team, organisation or admin's id</p>
|
||||
</div><div class="tsd-comment tsd-typography"></div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">WhoAmIType</span><span class="tsd-signature-symbol">></span></h4><ul>
|
||||
<li>Access details of credentials for a specific context</li>
|
||||
</ul>
|
||||
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in src/api/accounts.ts:18</li></ul></aside></li></ul></section><section class="tsd-panel tsd-member"><a id="whoamiall" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>who<wbr/>AmIAll</span><a href="#whoamiall" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="whoamiall-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">whoAmIAll</span><span class="tsd-signature-symbol">()</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">WhoAmIType</span><span class="tsd-signature-symbol">></span><a href="#whoamiall-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">WhoAmIType</span><span class="tsd-signature-symbol">></span></h4><ul>
|
||||
<li>Access details of credentials for all available contexts</li>
|
||||
</ul>
|
||||
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in src/api/accounts.ts:32</li></ul></aside></li></ul></section></section></details></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>On This Page</h3></summary><div class="tsd-accordion-details"><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Constructors"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Constructors</summary><div><a href="#constructor" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a></div></details><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Methods"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Methods</summary><div><a href="#whoami" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>who<wbr/>AmI</span></a><a href="#whoamiall" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>who<wbr/>AmIAll</span></a></div></details></div></details></div><div class="site-menu"><nav id="tsd-sidebar-links" class="tsd-navigation"><a href="https://github.com/kc4x4sar/d4h-typescript">Github Repo</a></nav><nav class="tsd-navigation"><a href="../modules.html">d4h-typescript</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html><html class="default" lang="en" data-base=".."><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>Roles | d4h-typescript</title><meta name="description" content="Documentation for d4h-typescript"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search"><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">d4h-typescript</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">d4h-typescript</a></li><li><a href="../modules/index.html">index</a></li><li><a href="index.Roles.html">Roles</a></li></ul><h1>Class Roles</h1></div><aside class="tsd-sources"><ul><li>Defined in src/api/roles.ts:9</li></ul></aside><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><h5 class="tsd-index-heading uppercase" role="button" aria-expanded="false" tabIndex="0"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-chevronSmall"></use></svg> Index</h5></summary><div class="tsd-accordion-details"><section class="tsd-index-section"><h3 class="tsd-index-heading">Constructors</h3><div class="tsd-index-list"><a href="index.Roles.html#constructor" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a>
|
||||
</div></section><section class="tsd-index-section"><h3 class="tsd-index-heading">Methods</h3><div class="tsd-index-list"><a href="index.Roles.html#getmemberqualification" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>get<wbr/>Member<wbr/>Qualification</span></a>
|
||||
</div></section></div></details></section></section><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Constructors"><h2><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg> Constructors</h2></summary><section><section class="tsd-panel tsd-member"><a id="constructor" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>constructor</span><a href="#constructor" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="constructorroles" class="tsd-anchor"></a><span class="tsd-signature-keyword">new</span> <span class="tsd-kind-constructor-signature">Roles</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">d4hInstance</span><span class="tsd-signature-symbol">:</span> <a href="index.default.html" class="tsd-signature-type tsd-kind-class">default</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a href="index.Roles.html" class="tsd-signature-type tsd-kind-class">Roles</a><a href="#constructorroles" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">d4hInstance</span>: <a href="index.default.html" class="tsd-signature-type tsd-kind-class">default</a></span></li></ul></div><h4 class="tsd-returns-title">Returns <a href="index.Roles.html" class="tsd-signature-type tsd-kind-class">Roles</a></h4><aside class="tsd-sources"><ul><li>Defined in src/api/roles.ts:12</li></ul></aside></li></ul></section></section></details><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Methods"><h2><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg> Methods</h2></summary><section><section class="tsd-panel tsd-member"><a id="getmemberqualification" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>get<wbr/>Member<wbr/>Qualification</span><a href="#getmemberqualification" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="getmemberqualification-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">getMemberQualification</span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">context</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">"team"</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"organisation"</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"admin"</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">contextId</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">roleId</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"me"</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">Role</span><span class="tsd-signature-symbol">></span><a href="#getmemberqualification-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">context</span>: <span class="tsd-signature-type">"team"</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"organisation"</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"admin"</span></span><div class="tsd-comment tsd-typography"><p>The point of view from where the request takes place</p>
|
||||
</div><div class="tsd-comment tsd-typography"></div></li><li><span><span class="tsd-kind-parameter">contextId</span>: <span class="tsd-signature-type">number</span></span><div class="tsd-comment tsd-typography"><p>Either a team, organisation or admin's id</p>
|
||||
</div><div class="tsd-comment tsd-typography"></div></li><li><span><span class="tsd-kind-parameter">roleId</span>: <span class="tsd-signature-type">number</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"me"</span></span><div class="tsd-comment tsd-typography"><p>A role id</p>
|
||||
</div><div class="tsd-comment tsd-typography"></div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">Role</span><span class="tsd-signature-symbol">></span></h4><ul>
|
||||
<li>A role</li>
|
||||
</ul>
|
||||
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in src/api/roles.ts:23</li></ul></aside></li></ul></section></section></details></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>On This Page</h3></summary><div class="tsd-accordion-details"><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Constructors"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Constructors</summary><div><a href="#constructor" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a></div></details><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Methods"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Methods</summary><div><a href="#getmemberqualification" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>get<wbr/>Member<wbr/>Qualification</span></a></div></details></div></details></div><div class="site-menu"><nav id="tsd-sidebar-links" class="tsd-navigation"><a href="https://github.com/kc4x4sar/d4h-typescript">Github Repo</a></nav><nav class="tsd-navigation"><a href="../modules.html">d4h-typescript</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,8 @@
|
||||
<!DOCTYPE html><html class="default" lang="en" data-base=".."><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>Contributing | d4h-typescript</title><meta name="description" content="Documentation for d4h-typescript"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search"><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">d4h-typescript</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">d4h-typescript</a></li><li><a href="Contributing.html">Contributing</a></li></ul></div><div class="tsd-panel tsd-typography"><a id="contributing" class="tsd-anchor"></a><h1 class="tsd-anchor-link">Contributing<a href="#contributing" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h1><a id="updating-documentation" class="tsd-anchor"></a><h2 class="tsd-anchor-link">Updating Documentation<a href="#updating-documentation" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h2><p>Documentation is setup to be hosted on github pages, it is generated using typedoc.</p>
|
||||
<p>Typedoc documentation can be found here: <a href="https://typedoc.org/">https://typedoc.org/</a></p>
|
||||
<a id="guides" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Guides<a href="#guides" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><p>The files for the guides are located in the documentation folder, they are written in markdown</p>
|
||||
<a id="module-documentation" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Module Documentation<a href="#module-documentation" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><p>To update the typedoc generated documentation for the module, run the following commands in the root of the repo:</p>
|
||||
<pre><code>npm install # Install only needs to be run first time.
|
||||
npm run docs
|
||||
</code></pre>
|
||||
</div></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>On This Page</h3></summary><div class="tsd-accordion-details"><a href="#contributing"><span>Contributing</span></a><ul><li><a href="#updating-documentation"><span>Updating <wbr/>Documentation</span></a></li><li><ul><li><a href="#guides"><span>Guides</span></a></li><li><a href="#module-documentation"><span>Module <wbr/>Documentation</span></a></li></ul></li></ul></div></details></div><div class="site-menu"><nav id="tsd-sidebar-links" class="tsd-navigation"><a href="https://github.com/kc4x4sar/d4h-typescript">Github Repo</a></nav><nav class="tsd-navigation"><a href="../modules.html">d4h-typescript</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html><html class="default" lang="en" data-base=".."><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>Installing | d4h-typescript</title><meta name="description" content="Documentation for d4h-typescript"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search"><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">d4h-typescript</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">d4h-typescript</a></li><li><a href="Installing.html">Installing</a></li></ul></div><div class="tsd-panel tsd-typography"><a id="installing" class="tsd-anchor"></a><h1 class="tsd-anchor-link">Installing<a href="#installing" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h1><p>This library is not in NPM. As a result, you need to add it to your project and build it locally.</p>
|
||||
<a id="adding-library-source-to-project" class="tsd-anchor"></a><h2 class="tsd-anchor-link">Adding library source to project<a href="#adding-library-source-to-project" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h2><p>To do so, you have three options:</p>
|
||||
<ul>
|
||||
<li>Add the repository to the consuming repository as a Git submodule.</li>
|
||||
<li>Clone the repository locally.</li>
|
||||
<li>Copy the files locally, without maintaining a Git repository.</li>
|
||||
</ul>
|
||||
<p>Regardless of which option you choose, the following steps all apply.</p>
|
||||
<a id="building-the-library" class="tsd-anchor"></a><h2 class="tsd-anchor-link">Building the library<a href="#building-the-library" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h2><p>Enter the lib directory for the library and run the following commands:</p>
|
||||
<pre><code>npm install
|
||||
npm run build
|
||||
</code></pre>
|
||||
<a id="installing-the-library-to-project" class="tsd-anchor"></a><h2 class="tsd-anchor-link">Installing the Library to Project<a href="#installing-the-library-to-project" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h2><p>In your project directory, run the following:</p>
|
||||
<pre><code>npm i /path/to/package/d4h-typescript/lib
|
||||
</code></pre>
|
||||
<p>Using a relative path will also work without issue.</p>
|
||||
</div></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>On This Page</h3></summary><div class="tsd-accordion-details"><a href="#installing"><span>Installing</span></a><ul><li><a href="#adding-library-source-to-project"><span>Adding library source to project</span></a></li><li><a href="#building-the-library"><span>Building the library</span></a></li><li><a href="#installing-the-library-to-project"><span>Installing the <wbr/>Library to <wbr/>Project</span></a></li></ul></div></details></div><div class="site-menu"><nav id="tsd-sidebar-links" class="tsd-navigation"><a href="https://github.com/kc4x4sar/d4h-typescript">Github Repo</a></nav><nav class="tsd-navigation"><a href="../modules.html">d4h-typescript</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2
-2
@@ -27,7 +27,7 @@
|
||||
</ul>
|
||||
<p>Build simply builds the test project, while launch both builds and runs it. If you've made changes to lib, be sure to build there first.</p>
|
||||
<p>Before launching, you should setup environment variables. <code>sample.env</code> shows you what variables are necessary. Copy the contents to a new file, <code>.env</code>, in the same folder and populate it appropriately.</p>
|
||||
<a id="contributing" class="tsd-anchor"></a><h2 class="tsd-anchor-link">Contributing<a href="#contributing" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><a id="updating-docs" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Updating Docs<a href="#updating-docs" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>To update typedoc docs after changes to code, run in the root of the repo:</p>
|
||||
<a id="contributing-1" class="tsd-anchor"></a><h2 class="tsd-anchor-link">Contributing<a href="#contributing-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><a id="updating-docs" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Updating Docs<a href="#updating-docs" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>To update typedoc docs after changes to code, run in the root of the repo:</p>
|
||||
<p><code>npm install</code></p>
|
||||
<p><code>npm run docs</code></p>
|
||||
</div></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="assets/icons.svg#icon-chevronDown"></use></svg>On This Page</h3></summary><div class="tsd-accordion-details"><a href="#d4h-typescript"><span>d4h-<wbr/>typescript</span></a><ul><li><a href="#documentation"><span>Documentation</span></a></li><li><a href="#how-to-consume"><span>How to <wbr/>Consume</span></a></li><li><a href="#structure"><span>Structure</span></a></li><li><ul><li><a href="#lib"><span>lib</span></a></li><li><a href="#test"><span>test</span></a></li></ul></li><li><a href="#contributing"><span>Contributing</span></a></li><li><ul><li><a href="#updating-docs"><span>Updating <wbr/>Docs</span></a></li></ul></li></ul></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="modules.html">d4h-typescript</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
|
||||
</div></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="assets/icons.svg#icon-chevronDown"></use></svg>On This Page</h3></summary><div class="tsd-accordion-details"><a href="#d4h-typescript"><span>d4h-<wbr/>typescript</span></a><ul><li><a href="#documentation"><span>Documentation</span></a></li><li><a href="#how-to-consume"><span>How to <wbr/>Consume</span></a></li><li><a href="#structure"><span>Structure</span></a></li><li><ul><li><a href="#lib"><span>lib</span></a></li><li><a href="#test"><span>test</span></a></li></ul></li><li><a href="#contributing-1"><span>Contributing</span></a></li><li><ul><li><a href="#updating-docs"><span>Updating <wbr/>Docs</span></a></li></ul></li></ul></div></details></div><div class="site-menu"><nav id="tsd-sidebar-links" class="tsd-navigation"><a href="https://github.com/kc4x4sar/d4h-typescript">Github Repo</a></nav><nav class="tsd-navigation"><a href="modules.html">d4h-typescript</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,2 +0,0 @@
|
||||
<!DOCTYPE html><html class="default" lang="en" data-base=".."><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>GetMemberOptions | d4h-typescript</title><meta name="description" content="Documentation for d4h-typescript"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search"><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">d4h-typescript</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">d4h-typescript</a></li><li><a href="GetMemberOptions.html">GetMemberOptions</a></li></ul><h1>Interface GetMemberOptions</h1></div><div class="tsd-signature"><span class="tsd-signature-keyword">interface</span> <span class="tsd-kind-interface">GetMemberOptions</span> <span class="tsd-signature-symbol">{</span><br/> <a class="tsd-kind-property" href="GetMemberOptions.html#includedetails">includeDetails</a><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">;</span><br/><span class="tsd-signature-symbol">}</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/kc4x4sar/d4h-typescript/blob/bd252c3aed375da86f49c6ce7f5b7e6fe24b9abe/lib/src/d4h.ts#L19">d4h.ts:19</a></li></ul></aside><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><h5 class="tsd-index-heading uppercase" role="button" aria-expanded="false" tabIndex="0"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-chevronSmall"></use></svg> Index</h5></summary><div class="tsd-accordion-details"><section class="tsd-index-section"><h3 class="tsd-index-heading">Properties</h3><div class="tsd-index-list"><a href="GetMemberOptions.html#includedetails" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>include<wbr/>Details?</span></a>
|
||||
</div></section></div></details></section></section><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Properties"><h2><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg> Properties</h2></summary><section><section class="tsd-panel tsd-member"><a id="includedetails" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>include<wbr/>Details</span><a href="#includedetails" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">includeDetails</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/kc4x4sar/d4h-typescript/blob/bd252c3aed375da86f49c6ce7f5b7e6fe24b9abe/lib/src/d4h.ts#L20">d4h.ts:20</a></li></ul></aside></section></section></details></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>On This Page</h3></summary><div class="tsd-accordion-details"><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Properties"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Properties</summary><div><a href="#includedetails" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>include<wbr/>Details</span></a></div></details></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">d4h-typescript</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,23 @@
|
||||
---
|
||||
title: Contributing
|
||||
group: Contributing
|
||||
---
|
||||
|
||||
# Contributing
|
||||
|
||||
## Updating Documentation
|
||||
|
||||
Documentation is setup to be hosted on github pages, it is generated using typedoc.
|
||||
|
||||
Typedoc documentation can be found here: <https://typedoc.org/>
|
||||
|
||||
### Guides
|
||||
|
||||
The files for the guides are located in the documentation folder, they are written in markdown
|
||||
|
||||
### Module Documentation
|
||||
|
||||
To update the typedoc generated documentation for the module, run the following commands in the root of the repo:
|
||||
|
||||
npm install # Install only needs to be run first time.
|
||||
npm run docs
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
title: Examples
|
||||
group: Examples
|
||||
---
|
||||
|
||||
# Examples
|
||||
@@ -0,0 +1,33 @@
|
||||
---
|
||||
title: Installing
|
||||
group: Installing
|
||||
---
|
||||
|
||||
# Installing
|
||||
|
||||
This library is not in NPM. As a result, you need to add it to your project and build it locally.
|
||||
|
||||
## Adding library source to project
|
||||
|
||||
To do so, you have three options:
|
||||
|
||||
- Add the repository to the consuming repository as a Git submodule.
|
||||
- Clone the repository locally.
|
||||
- Copy the files locally, without maintaining a Git repository.
|
||||
|
||||
Regardless of which option you choose, the following steps all apply.
|
||||
|
||||
## Building the library
|
||||
|
||||
Enter the lib directory for the library and run the following commands:
|
||||
|
||||
npm install
|
||||
npm run build
|
||||
|
||||
## Installing the Library to Project
|
||||
|
||||
In your project directory, run the following:
|
||||
|
||||
npm i /path/to/package/d4h-typescript/lib
|
||||
|
||||
Using a relative path will also work without issue.
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
title: Using the Library
|
||||
group: Using
|
||||
---
|
||||
|
||||
# Using the Library
|
||||
@@ -20,6 +20,7 @@
|
||||
"plugins": [
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"ignorePatterns": ["d4hWebClient.ts"],
|
||||
"rules": {
|
||||
"indent": [
|
||||
"error",
|
||||
|
||||
+12
-1
@@ -1,6 +1,17 @@
|
||||
|
||||
import D4H from './src/d4h'
|
||||
export default D4H
|
||||
|
||||
export { Teams, Organisations } from './src/d4h'
|
||||
export { Qualifications } from './src/api/qualifications'
|
||||
export { Members } from './src/api/members'
|
||||
export { Incidents } from './src/api/incidents'
|
||||
export { Groups } from './src/api/groups'
|
||||
export { Animals } from './src/api/animals'
|
||||
export { CustomFields } from './src/api/custom_fields'
|
||||
export { Roles } from './src/api/roles'
|
||||
export { Accounts } from './src/api/accounts'
|
||||
export { Activities } from './src/api/activity'
|
||||
|
||||
export * from './src/types/customField'
|
||||
export * from './src/d4h'
|
||||
export * from './src/types/group'
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import D4HRequest from '../d4hRequest'
|
||||
import D4H, { D4H_BASE_URL } from '../d4h'
|
||||
import { WhoAmIType } from '../types/accounts'
|
||||
|
||||
export class Accounts {
|
||||
private readonly _request: D4HRequest
|
||||
|
||||
constructor(d4hInstance: D4H) {
|
||||
this._request = d4hInstance.request
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param context - The point of view from where the request takes place
|
||||
* @param contextId - Either a team, organisation or admin's id
|
||||
* @returns - Access details of credentials for a specific context
|
||||
*/
|
||||
async whoAmI(context: 'admin' | 'organisation' | 'team', contextId: number): Promise<WhoAmIType> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/whoami`)
|
||||
|
||||
try {
|
||||
const whoami = await this._request.getAsync<WhoAmIType>(url)
|
||||
return whoami
|
||||
} catch (error) {
|
||||
throw new Error('Data not found or improperly formatted.')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns - Access details of credentials for all available contexts
|
||||
*/
|
||||
async whoAmIAll(): Promise<WhoAmIType> {
|
||||
const url = new URL(`${D4H_BASE_URL}/v3/whoami`)
|
||||
|
||||
try {
|
||||
const whoami = await this._request.getAsync<WhoAmIType>(url)
|
||||
return whoami
|
||||
} catch (error) {
|
||||
throw new Error('Data not found or improperly formatted.')
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
import D4HRequest from '../d4hRequest'
|
||||
import { EntityType } from '../entity'
|
||||
import D4H, { D4H_BASE_URL } from '../d4h'
|
||||
import { Activity } from '../types/activity';
|
||||
|
||||
|
||||
/** @ignore @inline */
|
||||
export interface GetActivityAttendOptions {
|
||||
activity_id?: number | number[];
|
||||
activity_resource_type?: string;
|
||||
deleted?: boolean;
|
||||
ends_after?: string;
|
||||
ends_before?: string;
|
||||
id?: number | number[];
|
||||
member_id?: number | number[];
|
||||
order?: 'asc' | 'desc'; // default: 'asc'
|
||||
page?: number;
|
||||
role_id?: number | number[];
|
||||
size?: number;
|
||||
sort?: 'createdAt' | 'id' | 'updatedAt'; // default: 'id'
|
||||
starts_after?: string;
|
||||
starts_before?: string;
|
||||
status?: string; // list of ids or null
|
||||
}
|
||||
|
||||
export class Activities {
|
||||
private readonly _request: D4HRequest
|
||||
|
||||
constructor(d4hInstance: D4H) {
|
||||
this._request = d4hInstance.request
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param context - The point of view from where the request takes place
|
||||
* @param contextId - Either a team, organisation or admin's id
|
||||
* @param attendanceId - The numeric identifier for a resource
|
||||
* @returns - An animal item
|
||||
*/
|
||||
async getActivityAttendance(context: 'admin' | 'organisation' | 'team', contextId: number, attendanceId: number): Promise<Activity> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/attendance/${attendanceId}`)
|
||||
|
||||
try {
|
||||
const activity = await this._request.getAsync<Activity>(url)
|
||||
activity.entityType = EntityType.Activity
|
||||
return activity
|
||||
} catch (error) {
|
||||
throw new Error('Attendance data not found or improperly formatted.')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param context - The point of view from where the request takes place
|
||||
* @param contextId - Either a team, organisation or admin's id
|
||||
* @param options.activity_id - One or more activity resource identifiers
|
||||
* @param options.activity_resource_type - One or more attendance statuses
|
||||
* @param options.deleted - Return only attendances from deleted activities
|
||||
* @param options.ends_after - Return only resources ending after this datetime
|
||||
* @param options.ends_before - Return only resources ending before this datetime
|
||||
* @param options.id - A list of ids
|
||||
* @param options.member_id - One or more member resource identifiers
|
||||
* @param options.order - Default: "asc"
|
||||
* @param options.page - Page number
|
||||
* @param options.role_id - One or more role resource identifiers
|
||||
* @param options.size - Items per page
|
||||
* @param options.sort - Default: "id"
|
||||
* @param options.starts_after - Return only resources starting after this datetime
|
||||
* @param options.starts_before - Return only resources starting before this datetime
|
||||
* @param options.status - One or more attendance statuses
|
||||
*/
|
||||
async getActivityAttendances(context: 'admin' | 'organisation' | 'team', contextId: number, options?: GetActivityAttendOptions): Promise<Activity[]> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/attendance`)
|
||||
|
||||
if (options !== undefined) {
|
||||
const optionsList = url.searchParams
|
||||
|
||||
if (options.activity_id !== undefined) {
|
||||
optionsList.append('activity_id', options.activity_id.toString())
|
||||
}
|
||||
if (options.activity_resource_type !== undefined) {
|
||||
optionsList.append('activity_resource_type', options.activity_resource_type.toString())
|
||||
}
|
||||
if (options.ends_after !== undefined) {
|
||||
optionsList.append('ends_after', options.ends_after.toString())
|
||||
}
|
||||
if (options.ends_before !== undefined) {
|
||||
optionsList.append('ends_before', options.ends_before.toString())
|
||||
}
|
||||
if (options.id !== undefined) {
|
||||
optionsList.append('id', options.id.toString())
|
||||
}
|
||||
if (options.member_id !== undefined) {
|
||||
optionsList.append('member_id', options.member_id.toString())
|
||||
}
|
||||
if (options.order !== undefined) {
|
||||
optionsList.append('order', options.order)
|
||||
}
|
||||
|
||||
if (options.page !== undefined) {
|
||||
optionsList.append('page', options.page.toString())
|
||||
}
|
||||
if (options.role_id !== undefined) {
|
||||
optionsList.append('role_id', options.role_id.toString())
|
||||
}
|
||||
if (options.size !== undefined) {
|
||||
optionsList.append('size', options.size.toString())
|
||||
}
|
||||
|
||||
if (options.sort !== undefined) {
|
||||
if (Array.isArray(options.sort)) {
|
||||
options.sort.forEach(sortField => {
|
||||
if (typeof sortField === 'string') {
|
||||
optionsList.append('sort', sortField)
|
||||
} else {
|
||||
console.warn('Skipping invalid sort field: ', sortField)
|
||||
}
|
||||
})
|
||||
} else if (typeof options.sort === 'string') {
|
||||
optionsList.append('sort', options.sort)
|
||||
} else {
|
||||
console.warn('Invalid sort field type:', typeof options.sort)
|
||||
}
|
||||
}
|
||||
|
||||
if (options.starts_before !== undefined) {
|
||||
optionsList.append('starts_before', options.starts_before.toString())
|
||||
}
|
||||
if (options.starts_after !== undefined) {
|
||||
optionsList.append('starts_after', options.starts_after.toString())
|
||||
}
|
||||
if (options.status !== undefined) {
|
||||
optionsList.append('status', options.status)
|
||||
}
|
||||
}
|
||||
|
||||
const activity = await this._request.getManyAsync<Activity>(url)
|
||||
activity.forEach(m => m.entityType = EntityType.Activity)
|
||||
|
||||
return activity
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
import D4HRequest from '../d4hRequest'
|
||||
import { EntityType } from '../entity'
|
||||
import type { Animal } from '../types/animal'
|
||||
import D4H, { D4H_BASE_URL } from '../d4h'
|
||||
|
||||
|
||||
/** @ignore @inline */
|
||||
export interface GetAnimalsOptions {
|
||||
handler_member_id?: number | number[];
|
||||
id?: number | number[];
|
||||
order?: 'asc' | 'desc'; // default: 'asc'
|
||||
page?: number;
|
||||
size?: number;
|
||||
sort?: 'createdAt' | 'id' | 'updatedAt'; // default: 'id'
|
||||
status?: 'NON_OPERATIONAL' | 'OPERATIONAL'; // list of ids or null
|
||||
team_id?: number; // the numeric identifier for a team resource
|
||||
}
|
||||
|
||||
export class Animals {
|
||||
private readonly _request: D4HRequest
|
||||
|
||||
constructor(d4hInstance: D4H) {
|
||||
this._request = d4hInstance.request
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param context - The point of view from where the request takes place
|
||||
* @param contextId - Either a team, organisation or admin's id
|
||||
* @param animalId - An animal id
|
||||
* @returns - An animal item
|
||||
*/
|
||||
async getAnimal(context: 'admin' | 'organisation' | 'team', contextId: number, animalId: number | 'me'): Promise<Animal> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/animals/${animalId}`)
|
||||
|
||||
try {
|
||||
const animal = await this._request.getAsync<Animal>(url)
|
||||
animal.entityType = EntityType.Animal
|
||||
return animal
|
||||
} catch (error) {
|
||||
throw new Error('Animal data not found or improperly formatted.')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param context - The point of view from where the request takes place
|
||||
* @param contextId - Either a team, organisation or admin's id
|
||||
* @param options.handler_member_id - The member id or ids of the animal's handler(s)
|
||||
* @param options.id - A list of ids
|
||||
* @param options.order - Default: "asc"
|
||||
* @param options.page - Page number
|
||||
* @param options.size - Items per page
|
||||
* @param options.sort - Default: "id"
|
||||
* @param options.status - The status of the animal
|
||||
* @param options.team_id - The numeric identifier for a resource
|
||||
* @returns - A list of animals
|
||||
*/
|
||||
async getAnimals(context: 'admin' | 'organisation' | 'team', contextId: number, options?: GetAnimalsOptions): Promise<Animal[]> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/animals`)
|
||||
|
||||
if (options !== undefined) {
|
||||
const optionsList = url.searchParams
|
||||
|
||||
if (options.handler_member_id !== undefined) {
|
||||
optionsList.append('handler_member_id', options.handler_member_id.toString())
|
||||
}
|
||||
|
||||
if (options.id !== undefined) {
|
||||
optionsList.append('id', options.id.toString())
|
||||
}
|
||||
if (options.order !== undefined) {
|
||||
optionsList.append('order', options.order)
|
||||
}
|
||||
|
||||
if (options.page !== undefined) {
|
||||
optionsList.append('page', options.page.toString())
|
||||
}
|
||||
|
||||
if (options.size !== undefined) {
|
||||
optionsList.append('size', options.size.toString())
|
||||
}
|
||||
|
||||
if (options.sort !== undefined) {
|
||||
if (Array.isArray(options.sort)) {
|
||||
options.sort.forEach(sortField => {
|
||||
if (typeof sortField === 'string') {
|
||||
optionsList.append('sort', sortField)
|
||||
} else {
|
||||
console.warn('Skipping invalid sort field: ', sortField)
|
||||
}
|
||||
})
|
||||
} else if (typeof options.sort === 'string') {
|
||||
optionsList.append('sort', options.sort)
|
||||
} else {
|
||||
console.warn('Invalid sort field type:', typeof options.sort)
|
||||
}
|
||||
}
|
||||
|
||||
if (options.status !== undefined) {
|
||||
optionsList.append('status', options.status)
|
||||
}
|
||||
|
||||
if (options.team_id !== undefined) {
|
||||
optionsList.append('team_id', options.team_id.toString())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const animals = await this._request.getManyAsync<Animal>(url)
|
||||
animals.forEach(m => m.entityType = EntityType.Animal)
|
||||
|
||||
return animals
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
import D4HRequest from '../d4hRequest'
|
||||
import { EntityType } from '../entity'
|
||||
import type { Animal } from '../types/animal'
|
||||
import { GetAnimalsOptions, D4H_BASE_URL } from '../d4h'
|
||||
|
||||
export class animalsApi {
|
||||
|
||||
|
||||
static async getAnimal(request: D4HRequest, context: string, contextId: number, animalId: number | 'me'): Promise<Animal> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/animals/${animalId}`)
|
||||
|
||||
const animal = await request.getAsync<Animal>(url)
|
||||
|
||||
if (!animal) {
|
||||
throw new Error('Animal data not found or improperly formatted.')
|
||||
}
|
||||
animal.entityType = EntityType.Animal
|
||||
|
||||
return animal
|
||||
}
|
||||
|
||||
static async getAnimals(request: D4HRequest, context: string, contextId: number, options?: GetAnimalsOptions): Promise<Animal[]> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/animals`)
|
||||
|
||||
if (options !== undefined) {
|
||||
const optionsList = url.searchParams
|
||||
|
||||
if (options.handler_member_id !== undefined) {
|
||||
optionsList.append('handler_member_id', options.handler_member_id.toString())
|
||||
}
|
||||
|
||||
if (options.id !== undefined) {
|
||||
optionsList.append('id', options.id.toString())
|
||||
}
|
||||
if (options.order !== undefined) {
|
||||
optionsList.append('order', options.order)
|
||||
}
|
||||
|
||||
if (options.page !== undefined) {
|
||||
optionsList.append('page', options.page.toString())
|
||||
}
|
||||
|
||||
if (options.size !== undefined) {
|
||||
optionsList.append('size', options.size.toString())
|
||||
}
|
||||
|
||||
if (options.sort !== undefined) {
|
||||
if (Array.isArray(options.sort)) {
|
||||
options.sort.forEach(sortField => optionsList.append('sort', sortField))
|
||||
} else {
|
||||
optionsList.append('sort', options.sort)
|
||||
}
|
||||
}
|
||||
|
||||
if (options.status !== undefined) {
|
||||
optionsList.append('status', options.status)
|
||||
}
|
||||
|
||||
if (options.team_id !== undefined) {
|
||||
optionsList.append('team_id', options.team_id.toString())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const animals = await request.getManyAsync<Animal>(url)
|
||||
animals.forEach(m => m.entityType = EntityType.Animal)
|
||||
|
||||
return animals
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
import { CustomFieldUpdate } from '../types/customField'
|
||||
import { Entity } from '../entity'
|
||||
import D4H, { D4H_BASE_URL } from '../d4h'
|
||||
import D4HRequest from '../d4hRequest'
|
||||
|
||||
class CustomFields {
|
||||
private readonly _request: D4HRequest
|
||||
|
||||
constructor(d4hInstance: D4H) {
|
||||
this._request = d4hInstance.request
|
||||
}
|
||||
|
||||
updateCustomFields(entity: Entity, updates: CustomFieldUpdate[], onlyMemberEditOwn: boolean): Promise<void> {
|
||||
// If no updates, no need to actually make a request. Exit early.
|
||||
if (updates.length === 0) {
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
const url = new URL(`${D4H_BASE_URL}/team/custom-fields/${entity.entityType}/${entity.id}`)
|
||||
|
||||
// From the documentation:
|
||||
// https://api.d4h.org/v2/documentation#operation/putTeamCustomfieldsEntity_typeEntity_id
|
||||
// The PUT action for fields is distinguished by Bundle. If you include one field's value
|
||||
// from a bundle (or an unbundled field's value) you must include values for all fields
|
||||
// of that bundle (or all unbundled fields)
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// To ensure a mistake doesn't occur, let's ensure that *all* unbundled custom fields from the original
|
||||
// entity are in the list of updates.
|
||||
//
|
||||
// At this time we don't actively use any custom fields in a bundle. To save on the additional complexity,
|
||||
// bundled custom fields are not supported and will result in an error if attempting to update them.
|
||||
|
||||
// At this time all entities we're working with have custom fields. As a result, throw an
|
||||
// error if none are found. This most likely indicates the original request was made without
|
||||
// including custom fields.
|
||||
const originalCustomFields = entity.custom_fields
|
||||
if (!originalCustomFields) {
|
||||
throw new Error('Cannot update custom fields for an entity with no custom fields. Ensure your original request included custom fields.')
|
||||
|
||||
}
|
||||
|
||||
// For any fields not being changed, back fill from the original entity to ensure
|
||||
// they retain the same value.
|
||||
for (const field of originalCustomFields) {
|
||||
const update = updates.find((u) => u.id == field.id)
|
||||
if (update) {
|
||||
if (onlyMemberEditOwn && !field.member_edit_own) {
|
||||
throw new Error('onlyMemberEditOwn specified, but attempting to update non-memberEditOwn field.')
|
||||
} else if (field.bundle) {
|
||||
throw new Error('One or more custom fields being updated are part of a bundle. Updating fields in a bundle is not supported.')
|
||||
}
|
||||
} else {
|
||||
let include = true
|
||||
if (field.bundle || (onlyMemberEditOwn && !field.member_edit_own)) {
|
||||
include = false
|
||||
}
|
||||
|
||||
if (include) {
|
||||
updates.push({
|
||||
id: field.id,
|
||||
value: field.value
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this._request.putAsync(url, { fields: updates })
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { CustomFields }
|
||||
@@ -0,0 +1,205 @@
|
||||
import D4HRequest from '../d4hRequest'
|
||||
import { EntityType } from '../entity'
|
||||
import D4H, { D4H_BASE_URL } from '../d4h'
|
||||
import type { groupMembership, memberGroup } from '../types/group'
|
||||
|
||||
/** @ignore @inline */
|
||||
export interface GetMemberGroupsOptions {
|
||||
id?: number;
|
||||
order?: 'asc' | 'desc'; // default: 'asc'
|
||||
page?: number;
|
||||
size?: number;
|
||||
sort?: 'createdAt' | 'id' | 'updatedAt'; // default: 'id'
|
||||
team_id?: number | number[];
|
||||
title?: string;
|
||||
}
|
||||
|
||||
/** @ignore @inline */
|
||||
export interface GetMemberGroupMembershipOptions {
|
||||
group_id?: number | number[];
|
||||
id?: number | number[];
|
||||
member_id?: number | number[];
|
||||
order?: 'asc' | 'desc'; // default: 'asc'
|
||||
page?: number;
|
||||
size?: number;
|
||||
sort?: 'createdAt' | 'id' | 'updatedAt'; // default: 'id'
|
||||
team_id?: number | number[];
|
||||
}
|
||||
|
||||
|
||||
export class Groups {
|
||||
private readonly _request: D4HRequest
|
||||
|
||||
constructor(d4hInstance: D4H) {
|
||||
this._request = d4hInstance.request
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param context - The point of view from where the request takes place
|
||||
* @param contextId - Either a team, organisation or admin's id
|
||||
* @param groupId - A group identifier
|
||||
* @returns - A member group
|
||||
*/
|
||||
async getMemberGroup(
|
||||
context: 'admin' | 'organisation' | 'team',
|
||||
contextId: number,
|
||||
groupId: number,
|
||||
): Promise<memberGroup> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/member-groups/${groupId}`)
|
||||
|
||||
try {
|
||||
const group = await this._request.getAsync<memberGroup>(url)
|
||||
group.entityType = EntityType.memberGroup
|
||||
return group
|
||||
} catch (error) {
|
||||
throw new Error('Group data not found or improperly formatted.')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param context - The point of view from where the request takes place
|
||||
* @param contextId - Either a team, organisation or admin's id
|
||||
* @param options.id - A list of ids
|
||||
* @param options.order - Default: "asc"
|
||||
* @param options.page - Page number
|
||||
* @param options.size - Items per page
|
||||
* @param options.sort - Default: "id"
|
||||
* @param options.team_id - One or more team identifiers
|
||||
* @param options.title - A simple text search term, compared against the title
|
||||
* @returns
|
||||
*/
|
||||
async getMemberGroups(
|
||||
context: 'admin' | 'organisation' | 'team',
|
||||
contextId: number,
|
||||
options?: GetMemberGroupsOptions
|
||||
): Promise<memberGroup[]> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/member-groups`)
|
||||
|
||||
if (options !== undefined) {
|
||||
const optionsList = url.searchParams
|
||||
|
||||
if (options.id !== undefined) {
|
||||
optionsList.append('id', options.id.toString())
|
||||
}
|
||||
|
||||
if (options.order !== undefined) {
|
||||
optionsList.append('order', options.order)
|
||||
}
|
||||
|
||||
if (options.page !== undefined) {
|
||||
optionsList.append('page', options.page.toString())
|
||||
}
|
||||
|
||||
if (options.size !== undefined) {
|
||||
optionsList.append('size', options.size.toString())
|
||||
}
|
||||
if (options.sort !== undefined) {
|
||||
if (Array.isArray(options.sort)) {
|
||||
options.sort.forEach(sortField => {
|
||||
if (typeof sortField === 'string') {
|
||||
optionsList.append('sort', sortField)
|
||||
} else {
|
||||
console.warn('Skipping invalid sort field: ', sortField)
|
||||
}
|
||||
})
|
||||
} else if (typeof options.sort === 'string') {
|
||||
optionsList.append('sort', options.sort)
|
||||
} else {
|
||||
console.warn('Invalid sort field type:', typeof options.sort)
|
||||
}
|
||||
}
|
||||
|
||||
if (options.team_id !== undefined) {
|
||||
optionsList.append('team_id', options.team_id.toString())
|
||||
}
|
||||
|
||||
if (options.title !== undefined) {
|
||||
optionsList.append('title', options.title)
|
||||
}
|
||||
}
|
||||
|
||||
const groups = await this._request.getManyAsync<memberGroup>(url)
|
||||
groups.forEach((m) => (m.entityType = EntityType.memberGroup))
|
||||
|
||||
return groups
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param context - The point of view from where the request takes place
|
||||
* @param contextId - Either a team, organisation or admin's id
|
||||
* @param options.group_id - One or more group identifiers
|
||||
* @param options.id - A list of ids
|
||||
* @param options.member_id - One or more member identifiers
|
||||
* @param options.order - Default: "asc"
|
||||
* @param options.page - Page number
|
||||
* @param options.size - Items per page
|
||||
* @param options.sort - Default: "id"
|
||||
* @param options.team_id - One or more team identifiers
|
||||
* @returns - A list of member group memberships
|
||||
*/
|
||||
async getMemberGroupMemberships(
|
||||
context: 'admin' | 'organisation' | 'team',
|
||||
contextId: number,
|
||||
options?: GetMemberGroupMembershipOptions
|
||||
): Promise<groupMembership[]> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/member-group-memberships`)
|
||||
|
||||
if (options !== undefined) {
|
||||
const optionsList = url.searchParams
|
||||
|
||||
if (options.group_id !== undefined) {
|
||||
optionsList.append('group_id', options.group_id.toString())
|
||||
}
|
||||
|
||||
if (options.id !== undefined) {
|
||||
optionsList.append('id_tag', options.id.toString())
|
||||
}
|
||||
|
||||
if (options.member_id !== undefined) {
|
||||
optionsList.append('member_id', options.member_id.toString())
|
||||
}
|
||||
|
||||
if (options.order !== undefined) {
|
||||
optionsList.append('order', options.order)
|
||||
}
|
||||
|
||||
if (options.page !== undefined) {
|
||||
optionsList.append('page', options.page.toString())
|
||||
}
|
||||
|
||||
if (options.size !== undefined) {
|
||||
optionsList.append('size', options.size.toString())
|
||||
}
|
||||
|
||||
if (options.sort !== undefined) {
|
||||
if (Array.isArray(options.sort)) {
|
||||
options.sort.forEach(sortField => {
|
||||
if (typeof sortField === 'string') {
|
||||
optionsList.append('sort', sortField)
|
||||
} else {
|
||||
console.warn('Skipping invalid sort field: ', sortField)
|
||||
}
|
||||
})
|
||||
} else if (typeof options.sort === 'string') {
|
||||
optionsList.append('sort', options.sort)
|
||||
} else {
|
||||
console.warn('Invalid sort field type:', typeof options.sort)
|
||||
}
|
||||
}
|
||||
|
||||
if (options.team_id !== undefined) {
|
||||
optionsList.append('team_id', options.team_id.toString())
|
||||
}
|
||||
}
|
||||
|
||||
const groups = await this._request.getManyAsync<groupMembership>(url)
|
||||
groups.forEach((m) => (m.entityType = EntityType.groupMembership))
|
||||
|
||||
return groups
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
import D4HRequest from '../d4hRequest'
|
||||
import { EntityType } from '../entity'
|
||||
import type { memberGroup } from '../types/group'
|
||||
import { GetMemberGroupsOptions, D4H_BASE_URL } from '../d4h'
|
||||
|
||||
export class groupsApi {
|
||||
static async getMemberGroup(
|
||||
request: D4HRequest,
|
||||
context: string,
|
||||
contextId: number,
|
||||
groupId: number,
|
||||
): Promise<memberGroup> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/member-groups/${groupId}`)
|
||||
|
||||
const group = await request.getAsync<memberGroup>(url)
|
||||
|
||||
if (!group) {
|
||||
throw new Error('Group data not found or improperly formatted.')
|
||||
}
|
||||
group.entityType = EntityType.memberGroup
|
||||
|
||||
return group
|
||||
}
|
||||
|
||||
static async getMemberGroups(
|
||||
request: D4HRequest,
|
||||
context: string,
|
||||
contextId: number,
|
||||
options?: GetMemberGroupsOptions
|
||||
): Promise<memberGroup[]> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/member-groups`)
|
||||
|
||||
if (options !== undefined) {
|
||||
const optionsList = url.searchParams
|
||||
|
||||
if (options.id !== undefined) {
|
||||
optionsList.append('id_tag', options.id.toString())
|
||||
}
|
||||
|
||||
if (options.order !== undefined) {
|
||||
optionsList.append('order', options.order)
|
||||
}
|
||||
|
||||
if (options.page !== undefined) {
|
||||
optionsList.append('page', options.page.toString())
|
||||
}
|
||||
|
||||
if (options.size !== undefined) {
|
||||
optionsList.append('size', options.size.toString())
|
||||
}
|
||||
|
||||
if (options.sort !== undefined) {
|
||||
if (Array.isArray(options.sort)) {
|
||||
options.sort.forEach((sortField) => optionsList.append('sort', sortField))
|
||||
} else {
|
||||
optionsList.append('sort', options.sort)
|
||||
}
|
||||
}
|
||||
|
||||
if (options.team_id !== undefined) {
|
||||
optionsList.append('team_id', options.team_id.toString())
|
||||
}
|
||||
|
||||
if (options.title !== undefined) {
|
||||
optionsList.append('title', options.title)
|
||||
}
|
||||
}
|
||||
|
||||
const groups = await request.getManyAsync<memberGroup>(url)
|
||||
groups.forEach((m) => (m.entityType = EntityType.memberGroup))
|
||||
|
||||
return groups
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
import D4HRequest from '../d4hRequest'
|
||||
import { EntityType } from '../entity'
|
||||
import D4H, { D4H_BASE_URL } from '../d4h'
|
||||
import type { Incident } from '../types/incident'
|
||||
|
||||
/** @ignore @inline */
|
||||
export interface GetIncidentOptions {
|
||||
after?: string;
|
||||
before?: string;
|
||||
deleted?: boolean; // default: 'false'
|
||||
ends_before?: string;
|
||||
id?: number | number[];
|
||||
order?: 'asc' | 'desc'; // default: 'asc'
|
||||
page?: number;
|
||||
published?: boolean;
|
||||
reference?: string;
|
||||
size?: number;
|
||||
sort?: 'createdAt' | 'id' | 'updatedAt'; // default: 'id'
|
||||
starts_after?: string;
|
||||
tag_bundle_id?: number;
|
||||
tag_id?: number;
|
||||
team_id?: number;
|
||||
}
|
||||
|
||||
export class Incidents {
|
||||
private readonly _request: D4HRequest
|
||||
|
||||
constructor(d4hInstance: D4H) {
|
||||
this._request = d4hInstance.request
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param context - The point of view from where the request takes place
|
||||
* @param contextId - Either a team, organisation or admin's id
|
||||
* @param activityId - An activity identifier
|
||||
* @returns - An incident
|
||||
*/
|
||||
async getIncident(context: 'admin' | 'organisation' | 'team', contextId: number, activityId: number): Promise<Incident> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/incidents/${activityId}`)
|
||||
|
||||
|
||||
try {
|
||||
const incident = await this._request.getAsync<Incident>(url)
|
||||
incident.entityType = EntityType.Incident
|
||||
return incident
|
||||
} catch (error) {
|
||||
throw new Error('Incident data not found or improperly formatted.')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param context - The point of view from where the request takes place
|
||||
* @param contextId - Either a team, organisation or admin's id
|
||||
* @param options.after - Return only activities ending after this datetime
|
||||
* @param options.before - Return only activities starting before this datetime
|
||||
* @param options.deleted - Return only deleted activities
|
||||
* @param options.ends_before - Return only activities ending before this datetime
|
||||
* @param options.id - A list of ids
|
||||
* @param options.order - Default: "asc"
|
||||
* @param options.page - Page number
|
||||
* @param options.published - Return only published activities
|
||||
* @param options.reference - A simple text search term, compared against the reference and reference description
|
||||
* @param options.size - Items per page
|
||||
* @param options.sort - Default: "id"
|
||||
* @param options.starts_after - Return only activities starting after this datetime
|
||||
* @param options.tag_bundle_id - Return only activities with this tag bundle id
|
||||
* @param options.tag_id - Return only activities with this tag id
|
||||
* @param options.team_id - Return only activities with this team id
|
||||
* @returns - A list of incidents
|
||||
*/
|
||||
async getIncidents(context: 'admin' | 'organisation' | 'team', contextId: number, options?: GetIncidentOptions): Promise<Incident[]> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/incidents`)
|
||||
|
||||
if (options !== undefined) {
|
||||
const optionsList = url.searchParams
|
||||
|
||||
if (options.after !== undefined) {
|
||||
optionsList.append('after', options.after)
|
||||
}
|
||||
if (options.before !== undefined) {
|
||||
optionsList.append('before', options.before)
|
||||
}
|
||||
if (options.deleted !== undefined) {
|
||||
optionsList.append('deleted', options.deleted.toString())
|
||||
}
|
||||
if (options.ends_before !== undefined) {
|
||||
optionsList.append('ends_before', options.ends_before)
|
||||
}
|
||||
if (options.id !== undefined) {
|
||||
optionsList.append('id', options.id.toString())
|
||||
}
|
||||
if (options.order !== undefined) {
|
||||
optionsList.append('order', options.order)
|
||||
}
|
||||
if (options.page !== undefined) {
|
||||
optionsList.append('page', options.page.toString())
|
||||
}
|
||||
if (options.published !== undefined) {
|
||||
optionsList.append('published', options.published.toString())
|
||||
}
|
||||
if (options.reference !== undefined) {
|
||||
optionsList.append('reference', options.reference)
|
||||
}
|
||||
if (options.size !== undefined) {
|
||||
optionsList.append('size', options.size.toString())
|
||||
}
|
||||
if (options.sort !== undefined) {
|
||||
if (Array.isArray(options.sort)) {
|
||||
options.sort.forEach(sortField => {
|
||||
if (typeof sortField === 'string') {
|
||||
optionsList.append('sort', sortField)
|
||||
} else {
|
||||
console.warn('Skipping invalid sort field: ', sortField)
|
||||
}
|
||||
})
|
||||
} else if (typeof options.sort === 'string') {
|
||||
optionsList.append('sort', options.sort)
|
||||
} else {
|
||||
console.warn('Invalid sort field type:', typeof options.sort)
|
||||
}
|
||||
}
|
||||
if (options.starts_after !== undefined) {
|
||||
optionsList.append('starts_after', options.starts_after)
|
||||
}
|
||||
if (options.tag_bundle_id !== undefined) {
|
||||
optionsList.append('tag_bundle_id', options.tag_bundle_id.toString())
|
||||
}
|
||||
if (options.tag_id !== undefined) {
|
||||
optionsList.append('tag_id', options.tag_id.toString())
|
||||
}
|
||||
if (options.team_id !== undefined) {
|
||||
optionsList.append('team_id', options.team_id.toString())
|
||||
}
|
||||
}
|
||||
|
||||
return this._request.getManyAsync(url)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
import D4HRequest from '../d4hRequest'
|
||||
import { EntityType } from '../entity'
|
||||
import type { Member } from '../types/member'
|
||||
import D4H, { D4H_BASE_URL } from '../d4h'
|
||||
import type { MemberUpdate } from '../types/member'
|
||||
|
||||
|
||||
/** @ignore @inline */
|
||||
export interface GetMemberOptions {
|
||||
includeDetails?: boolean;
|
||||
}
|
||||
|
||||
/** @inline */
|
||||
export interface GetMembersOptions {
|
||||
deleted?: boolean; // default: false
|
||||
id?: number | number[]
|
||||
id_tag?: string;
|
||||
name?: string;
|
||||
order?: 'asc' | 'desc'; /** @defaultValue asc */
|
||||
page?: number;
|
||||
size?: number;
|
||||
sort?: 'createdAt' | 'id' | 'updatedAt'; // default: 'id'
|
||||
statuses?: (number | null)[]; // list of ids or null
|
||||
team_id?: number; // the numeric identifier for a team resource
|
||||
}
|
||||
|
||||
export class Members {
|
||||
private readonly _request: D4HRequest
|
||||
|
||||
constructor(d4hInstance: D4H) {
|
||||
this._request = d4hInstance.request
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param context - The point of view from where the request takes place
|
||||
* @param contextId - Either a team, organisation or admin's id
|
||||
* @param id - Member the resource belongs to. Either an id or "me"
|
||||
* @returns - A member
|
||||
*/
|
||||
async getMember(
|
||||
context: 'admin' | 'organisation' | 'team',
|
||||
contextId: number,
|
||||
id: number | 'me',
|
||||
options?: GetMemberOptions
|
||||
): Promise<Member> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/members/${id}`)
|
||||
|
||||
if (options !== undefined) {
|
||||
const optionsList = url.searchParams
|
||||
|
||||
if (options.includeDetails !== undefined) {
|
||||
optionsList.append('include_details', 'true')
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const member = await this._request.getAsync<Member>(url)
|
||||
member.entityType = EntityType.Member
|
||||
return member
|
||||
} catch (error) {
|
||||
throw new Error('Member data not found or improperly formatted.')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param context - The point of view from where the request takes place
|
||||
* @param contextId - Either a team, organisation or admin's id
|
||||
* @param options.deleted - Return only deleted members
|
||||
* @param options.id - A list of ids
|
||||
* @param options.id_tag - RFID tag or barcode
|
||||
* @param options.name - The member's name
|
||||
* @param options.order -
|
||||
* @param options.page - Page number
|
||||
* @param options.size - Items per page
|
||||
* @param options.sort -
|
||||
* @param options.statuses - One or more member statuses. Some statuses require extra permissions.
|
||||
* @param options.team_id - The numeric identifier for a resource
|
||||
* @returns - A list of members
|
||||
*/
|
||||
async getMembers(
|
||||
context: 'admin' | 'organisation' | 'team',
|
||||
contextId: number,
|
||||
options?: GetMembersOptions
|
||||
): Promise<Member[]> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/members`)
|
||||
|
||||
if (options !== undefined) {
|
||||
const optionsList = url.searchParams
|
||||
|
||||
if (options.deleted !== undefined) {
|
||||
optionsList.append('deleted', options.deleted.toString())
|
||||
}
|
||||
|
||||
if (options.id !== undefined) {
|
||||
optionsList.append('id', options.id.toString())
|
||||
}
|
||||
|
||||
if (options.id_tag !== undefined) {
|
||||
optionsList.append('id_tag', options.id_tag)
|
||||
}
|
||||
|
||||
if (options.name !== undefined) {
|
||||
optionsList.append('name', options.name)
|
||||
}
|
||||
|
||||
if (options.order !== undefined) {
|
||||
optionsList.append('order', options.order)
|
||||
}
|
||||
|
||||
if (options.page !== undefined) {
|
||||
optionsList.append('page', options.page.toString())
|
||||
}
|
||||
|
||||
if (options.size !== undefined) {
|
||||
optionsList.append('size', options.size.toString())
|
||||
}
|
||||
|
||||
if (options.sort !== undefined) {
|
||||
if (Array.isArray(options.sort)) {
|
||||
options.sort.forEach(sortField => {
|
||||
if (typeof sortField === 'string') {
|
||||
optionsList.append('sort', sortField)
|
||||
} else {
|
||||
console.warn('Skipping invalid sort field: ', sortField)
|
||||
}
|
||||
})
|
||||
} else if (typeof options.sort === 'string') {
|
||||
optionsList.append('sort', options.sort)
|
||||
} else {
|
||||
console.warn('Invalid sort field type:', typeof options.sort)
|
||||
}
|
||||
}
|
||||
|
||||
if (options.statuses !== undefined) {
|
||||
options.statuses.forEach((status) => {
|
||||
if (status !== null) {
|
||||
optionsList.append('statuses', status.toString())
|
||||
} else {
|
||||
optionsList.append('statuses', 'null')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (options.team_id !== undefined) {
|
||||
optionsList.append('team_id', options.team_id.toString())
|
||||
}
|
||||
}
|
||||
|
||||
const members = await this._request.getManyAsync<Member>(url)
|
||||
members.forEach((m) => (m.entityType = EntityType.Member))
|
||||
|
||||
return members
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param context
|
||||
* @param contextId
|
||||
* @param id
|
||||
* @param updates
|
||||
* @returns
|
||||
*/
|
||||
updateMember(context: string, contextId: number, id: number, updates: MemberUpdate): Promise<void> {
|
||||
// If no updates, no need to actually make a request. Exit early.
|
||||
if (Object.getOwnPropertyNames(updates).length === 0) {
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/members/${id}`)
|
||||
return this._request.putAsync(url, updates)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
import D4HRequest from '../d4hRequest'
|
||||
import { EntityType } from '../entity'
|
||||
import type { Member } from '../types/member'
|
||||
import { GetMemberOptions, GetMembersOptions, D4H_BASE_URL } from '../d4h'
|
||||
|
||||
export class membersApi {
|
||||
static async getMember(
|
||||
request: D4HRequest,
|
||||
context: string,
|
||||
contextId: number,
|
||||
id: number | 'me',
|
||||
options?: GetMemberOptions
|
||||
): Promise<Member> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/members/${id}`)
|
||||
|
||||
if (options !== undefined) {
|
||||
const optionsList = url.searchParams
|
||||
|
||||
if (options.includeDetails !== undefined) {
|
||||
optionsList.append('include_details', 'true')
|
||||
}
|
||||
}
|
||||
|
||||
const member = await request.getAsync<Member>(url)
|
||||
|
||||
if (!member) {
|
||||
throw new Error('Member data not found or improperly formatted.')
|
||||
}
|
||||
member.entityType = EntityType.Member
|
||||
|
||||
return member
|
||||
}
|
||||
|
||||
static async getMembers(
|
||||
request: D4HRequest,
|
||||
context: string,
|
||||
contextId: number,
|
||||
options?: GetMembersOptions
|
||||
): Promise<Member[]> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/members`)
|
||||
|
||||
if (options !== undefined) {
|
||||
const optionsList = url.searchParams
|
||||
|
||||
if (options.deleted !== undefined) {
|
||||
optionsList.append('deleted', options.deleted.toString())
|
||||
}
|
||||
|
||||
if (options.id_tag !== undefined) {
|
||||
optionsList.append('id_tag', options.id_tag)
|
||||
}
|
||||
|
||||
if (options.name !== undefined) {
|
||||
optionsList.append('name', options.name)
|
||||
}
|
||||
|
||||
if (options.order !== undefined) {
|
||||
optionsList.append('order', options.order)
|
||||
}
|
||||
|
||||
if (options.page !== undefined) {
|
||||
optionsList.append('page', options.page.toString())
|
||||
}
|
||||
|
||||
if (options.size !== undefined) {
|
||||
optionsList.append('size', options.size.toString())
|
||||
}
|
||||
|
||||
if (options.sort !== undefined) {
|
||||
if (Array.isArray(options.sort)) {
|
||||
options.sort.forEach((sortField) => optionsList.append('sort', sortField))
|
||||
} else {
|
||||
optionsList.append('sort', options.sort)
|
||||
}
|
||||
}
|
||||
|
||||
if (options.statuses !== undefined) {
|
||||
options.statuses.forEach((status) => {
|
||||
if (status !== null) {
|
||||
optionsList.append('statuses', status.toString())
|
||||
} else {
|
||||
optionsList.append('statuses', 'null')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (options.team_id !== undefined) {
|
||||
optionsList.append('team_id', options.team_id.toString())
|
||||
}
|
||||
}
|
||||
|
||||
const members = await request.getManyAsync<Member>(url)
|
||||
members.forEach((m) => (m.entityType = EntityType.Member))
|
||||
|
||||
return members
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,401 @@
|
||||
import D4HRequest from '../d4hRequest'
|
||||
import { EntityType } from '../entity'
|
||||
import type { Qualification, MemberAwards } from '../types/qualification'
|
||||
import D4H, { D4H_BASE_URL, D4H_FETCH_LIMIT } from '../d4h'
|
||||
|
||||
console.log(D4H_FETCH_LIMIT)
|
||||
|
||||
/** @ignore @inline */
|
||||
export interface GetOneQualificationOptions {
|
||||
exclude_org_data?: boolean;
|
||||
exclude_teams_data?: boolean;
|
||||
}
|
||||
|
||||
/** @ignore @inline */
|
||||
export interface GetQualificationOptions {
|
||||
exclude_org_data?: boolean; // default: false
|
||||
exclude_teams_data?: boolean; // default: false
|
||||
order?: 'asc' | 'desc'; // default: 'asc'
|
||||
page?: number;
|
||||
size?: number;
|
||||
sort?: 'createdAt' | 'id' | 'updatedAt'; // default: 'id'
|
||||
title?: string;
|
||||
}
|
||||
|
||||
/** @ignore @inline */
|
||||
export interface GetMemberAwardsOptions {
|
||||
exclude_org_data?: boolean; // default: false
|
||||
exclude_teams_data?: boolean; // default: false
|
||||
member_id?: number | 'me';
|
||||
order?: 'asc' | 'desc'; // default: 'asc'
|
||||
page?: number;
|
||||
qualification_id?: number;
|
||||
size?: number;
|
||||
sort?: 'createdAt' | 'id' | 'updatedAt'; // default: 'id'
|
||||
}
|
||||
|
||||
|
||||
export class Qualifications {
|
||||
private readonly _request: D4HRequest
|
||||
|
||||
constructor(d4hInstance: D4H) {
|
||||
this._request = d4hInstance.request
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param context - The point of view from where the request takes place
|
||||
* @param contextId - Either a team, organisation or admin's id
|
||||
* @param qualificationId - The qualification's id
|
||||
* @param options.exclude_org_data - Team context: Exclude entities inherited from the team's org
|
||||
* @param options.exclude_teams_data - Organisation context: Exclude entities belonging to accessible teams
|
||||
* @returns - A member qualification
|
||||
*/
|
||||
async getMemberQualification(context: 'admin' | 'organisation' | 'team', contextId: number, qualificationId: number | 'me', options?: GetOneQualificationOptions): Promise<Qualification> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/member-qualifications/${qualificationId}`)
|
||||
|
||||
if (options !== undefined) {
|
||||
const optionsList = url.searchParams
|
||||
|
||||
if (options.exclude_org_data !== undefined) {
|
||||
optionsList.append('exclude_org_data', options.exclude_org_data.toString())
|
||||
}
|
||||
if (options.exclude_teams_data !== undefined) {
|
||||
optionsList.append('exclude_teams_data', options.exclude_teams_data.toString())
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const qualification = await this._request.getAsync<Qualification>(url)
|
||||
qualification.entityType = EntityType.Incident
|
||||
return qualification
|
||||
} catch (error) {
|
||||
throw new Error('Qualification data not found or improperly formatted.')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param context - The point of view from where the request takes place
|
||||
* @param contextId - Either a team, organisation or admin's id
|
||||
* @param options.exclude_org_data - Team context: Exclude entities inherited from the team's org
|
||||
* @param options.exclude_teams_data - Organisation context: Exclude entities belonging to accessible teams
|
||||
* @param options.order - Default: "asc"
|
||||
* @param options.page - Page number
|
||||
* @param options.size - Items per page
|
||||
* @param options.sort - Default: "id"
|
||||
* @param options.title - The title of a resource
|
||||
* @returns - A list of member qualifications
|
||||
*/
|
||||
async getMemberQualifications(context: 'admin' | 'organisation' | 'team', contextId: number, options?: GetQualificationOptions): Promise<Qualification[]> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/member-qualifications`)
|
||||
|
||||
if (options !== undefined) {
|
||||
const optionsList = url.searchParams
|
||||
|
||||
if (options.exclude_org_data !== undefined) {
|
||||
optionsList.append('exclude_org_data', options.exclude_org_data.toString())
|
||||
}
|
||||
|
||||
if (options.exclude_teams_data !== undefined) {
|
||||
optionsList.append('exclude_teams_data', options.exclude_teams_data.toString())
|
||||
}
|
||||
if (options.order !== undefined) {
|
||||
optionsList.append('order', options.order)
|
||||
}
|
||||
|
||||
if (options.page !== undefined) {
|
||||
optionsList.append('page', options.page.toString())
|
||||
}
|
||||
if (options.size !== undefined) {
|
||||
optionsList.append('size', options.size.toString())
|
||||
}
|
||||
if (options.sort !== undefined) {
|
||||
if (Array.isArray(options.sort)) {
|
||||
options.sort.forEach(sortField => {
|
||||
if (typeof sortField === 'string') {
|
||||
optionsList.append('sort', sortField)
|
||||
} else {
|
||||
console.warn('Skipping invalid sort field: ', sortField)
|
||||
}
|
||||
})
|
||||
} else if (typeof options.sort === 'string') {
|
||||
optionsList.append('sort', options.sort)
|
||||
} else {
|
||||
console.warn('Invalid sort field type:', typeof options.sort)
|
||||
}
|
||||
}
|
||||
|
||||
if (options.title !== undefined) {
|
||||
optionsList.append('title', options.title)
|
||||
}
|
||||
}
|
||||
|
||||
return this._request.getManyAsync(url)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param context - The point of view from where the request takes place
|
||||
* @param contextId - Either a team, organisation or admin's id
|
||||
* @param qualificationId - The qualification's id
|
||||
* @param options.exclude_org_data - Team context: Exclude entities inherited from the team's org
|
||||
* @param options.exclude_teams_data - Organisation context: Exclude entities belonging to accessible teams
|
||||
* @returns - An animal qualification
|
||||
*/
|
||||
async getAnimalQualification(context: 'admin' | 'organisation' | 'team', contextId: number, qualificationId: number, options?: GetOneQualificationOptions): Promise<Qualification> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/animal-qualifications/${qualificationId}`)
|
||||
|
||||
if (options !== undefined) {
|
||||
const optionsList = url.searchParams
|
||||
|
||||
if (options.exclude_org_data !== undefined) {
|
||||
optionsList.append('exclude_org_data', options.exclude_org_data.toString())
|
||||
}
|
||||
if (options.exclude_teams_data !== undefined) {
|
||||
optionsList.append('exclude_teams_data', options.exclude_teams_data.toString())
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const qualification = await this._request.getAsync<Qualification>(url)
|
||||
qualification.entityType = EntityType.Qualification
|
||||
return qualification
|
||||
} catch (error) {
|
||||
throw new Error('Qualification data not found or improperly formatted.')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param context - The point of view from where the request takes place
|
||||
* @param contextId - Either a team, organisation or admin's id
|
||||
* @param options.exclude_org_data - Team context: Exclude entities inherited from the team's org
|
||||
* @param options.exclude_teams_data - Organisation context: Exclude entities belonging to accessible teams
|
||||
* @param options.order - Default: "asc"
|
||||
* @param options.page - Page number
|
||||
* @param options.size - Items per page
|
||||
* @param options.sort - Default: "id"
|
||||
* @param options.title - The title of a resource
|
||||
* @returns - A list of animal qualifications
|
||||
*/
|
||||
async getAnimalQualifications(context: 'admin' | 'organisation' | 'team', contextId: number, options?: GetQualificationOptions): Promise<Qualification[]> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/animal-qualifications`)
|
||||
|
||||
if (options !== undefined) {
|
||||
const optionsList = url.searchParams
|
||||
|
||||
if (options.exclude_org_data !== undefined) {
|
||||
optionsList.append('exclude_org_data', options.exclude_org_data.toString())
|
||||
}
|
||||
|
||||
if (options.exclude_teams_data !== undefined) {
|
||||
optionsList.append('exclude_teams_data', options.exclude_teams_data.toString())
|
||||
}
|
||||
if (options.order !== undefined) {
|
||||
optionsList.append('order', options.order)
|
||||
}
|
||||
|
||||
if (options.page !== undefined) {
|
||||
optionsList.append('page', options.page.toString())
|
||||
}
|
||||
if (options.size !== undefined) {
|
||||
optionsList.append('size', options.size.toString())
|
||||
}
|
||||
if (options.sort !== undefined) {
|
||||
if (Array.isArray(options.sort)) {
|
||||
options.sort.forEach(sortField => {
|
||||
if (typeof sortField === 'string') {
|
||||
optionsList.append('sort', sortField)
|
||||
} else {
|
||||
console.warn('Skipping invalid sort field: ', sortField)
|
||||
}
|
||||
})
|
||||
} else if (typeof options.sort === 'string') {
|
||||
optionsList.append('sort', options.sort)
|
||||
} else {
|
||||
console.warn('Invalid sort field type:', typeof options.sort)
|
||||
}
|
||||
}
|
||||
|
||||
if (options.title !== undefined) {
|
||||
optionsList.append('title', options.title)
|
||||
}
|
||||
}
|
||||
|
||||
const qualifications = await this._request.getManyAsync<Qualification>(url)
|
||||
qualifications.forEach((m) => (m.entityType = EntityType.Qualification))
|
||||
|
||||
return qualifications
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param context - The point of view from where the request takes place
|
||||
* @param contextId - Either a team, organisation or admin's id
|
||||
* @param qualificationId - The qualification's id
|
||||
* @param options.exclude_org_data - Team context: Exclude entities inherited from the team's org
|
||||
* @param options.exclude_teams_data - Organisation context: Exclude entities belonging to accessible teams
|
||||
* @returns - An animal qualification
|
||||
*/
|
||||
async getHandlerQualification(context: 'admin' | 'organisation' | 'team', contextId: number, qualificationId: number, options?: GetOneQualificationOptions): Promise<Qualification> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/handler-qualifications/${qualificationId}`)
|
||||
|
||||
if (options !== undefined) {
|
||||
const optionsList = url.searchParams
|
||||
|
||||
if (options.exclude_org_data !== undefined) {
|
||||
optionsList.append('exclude_org_data', options.exclude_org_data.toString())
|
||||
}
|
||||
if (options.exclude_teams_data !== undefined) {
|
||||
optionsList.append('exclude_teams_data', options.exclude_teams_data.toString())
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const qualification = await this._request.getAsync<Qualification>(url)
|
||||
qualification.entityType = EntityType.Qualification
|
||||
return qualification
|
||||
} catch (error) {
|
||||
throw new Error('Qualification data not found or improperly formatted.')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param context - The point of view from where the request takes place
|
||||
* @param contextId - Either a team, organisation or admin's id
|
||||
* @param options.exclude_org_data - Team context: Exclude entities inherited from the team's org
|
||||
* @param options.exclude_teams_data - Organisation context: Exclude entities belonging to accessible teams
|
||||
* @param options.order - Default: "asc"
|
||||
* @param options.page - Page number
|
||||
* @param options.size - Items per page
|
||||
* @param options.sort - Default: "id"
|
||||
* @param options.title - The title of a resource
|
||||
* @returns - A list of animal qualifications
|
||||
*/
|
||||
async getHandlerQualifications(context: 'admin' | 'organisation' | 'team', contextId: number, options?: GetQualificationOptions): Promise<Qualification[]> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/handler-qualifications`)
|
||||
|
||||
if (options !== undefined) {
|
||||
const optionsList = url.searchParams
|
||||
|
||||
if (options.exclude_org_data !== undefined) {
|
||||
optionsList.append('exclude_org_data', options.exclude_org_data.toString())
|
||||
}
|
||||
|
||||
if (options.exclude_teams_data !== undefined) {
|
||||
optionsList.append('exclude_teams_data', options.exclude_teams_data.toString())
|
||||
}
|
||||
if (options.order !== undefined) {
|
||||
optionsList.append('order', options.order)
|
||||
}
|
||||
|
||||
if (options.page !== undefined) {
|
||||
optionsList.append('page', options.page.toString())
|
||||
}
|
||||
if (options.size !== undefined) {
|
||||
optionsList.append('size', options.size.toString())
|
||||
}
|
||||
if (options.sort !== undefined) {
|
||||
if (Array.isArray(options.sort)) {
|
||||
options.sort.forEach(sortField => {
|
||||
if (typeof sortField === 'string') {
|
||||
optionsList.append('sort', sortField)
|
||||
} else {
|
||||
console.warn('Skipping invalid sort field: ', sortField)
|
||||
}
|
||||
})
|
||||
} else if (typeof options.sort === 'string') {
|
||||
optionsList.append('sort', options.sort)
|
||||
} else {
|
||||
console.warn('Invalid sort field type:', typeof options.sort)
|
||||
}
|
||||
}
|
||||
|
||||
if (options.title !== undefined) {
|
||||
optionsList.append('title', options.title)
|
||||
}
|
||||
}
|
||||
|
||||
const qualifications = await this._request.getManyAsync<Qualification>(url)
|
||||
qualifications.forEach((m) => (m.entityType = EntityType.Qualification))
|
||||
|
||||
return qualifications
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param context - The point of view from where the request takes place
|
||||
* @param contextId - Either a team, organisation or admin's id
|
||||
* @param options.exclude_org_data - Team context: Exclude entities inherited from the team's org
|
||||
* @param options.exclude_teams_data - Organisation context: Exclude entities belonging to accessible teams
|
||||
* @param options.member_id - Qualified member. Either an id or "me"
|
||||
* @param options.order - Default: "asc"
|
||||
* @param options.page - Page number
|
||||
* @param options.qualification_id - The qualification's id
|
||||
* @param options.size - Items per page
|
||||
* @param options.sort - Default: "id"
|
||||
* @returns - A list of member qualification awards
|
||||
*/
|
||||
async getMemberAwards(context: 'admin' | 'organisation' | 'team', contextId: number, options?: GetMemberAwardsOptions): Promise<MemberAwards[]> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/member-qualification-awards`)
|
||||
|
||||
if (options !== undefined) {
|
||||
const optionsList = url.searchParams
|
||||
|
||||
if (options.exclude_org_data !== undefined) {
|
||||
optionsList.append('exclude_org_data', options.exclude_org_data.toString())
|
||||
}
|
||||
|
||||
if (options.exclude_teams_data !== undefined) {
|
||||
optionsList.append('exclude_teams_data', options.exclude_teams_data.toString())
|
||||
}
|
||||
|
||||
if (options.member_id !== undefined) {
|
||||
optionsList.append('member_id', options.member_id.toString())
|
||||
}
|
||||
if (options.order !== undefined) {
|
||||
optionsList.append('order', options.order)
|
||||
}
|
||||
|
||||
if (options.page !== undefined) {
|
||||
optionsList.append('page', options.page.toString())
|
||||
}
|
||||
|
||||
if (options.qualification_id !== undefined) {
|
||||
optionsList.append('qualification_id', options.qualification_id.toString())
|
||||
}
|
||||
if (options.size !== undefined) {
|
||||
optionsList.append('size', options.size.toString())
|
||||
}
|
||||
if (options.sort !== undefined) {
|
||||
if (Array.isArray(options.sort)) {
|
||||
options.sort.forEach(sortField => {
|
||||
if (typeof sortField === 'string') {
|
||||
optionsList.append('sort', sortField)
|
||||
} else {
|
||||
console.warn('Skipping invalid sort field: ', sortField)
|
||||
}
|
||||
})
|
||||
} else if (typeof options.sort === 'string') {
|
||||
optionsList.append('sort', options.sort)
|
||||
} else {
|
||||
console.warn('Invalid sort field type:', typeof options.sort)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const awards = await this._request.getManyAsync<MemberAwards>(url)
|
||||
awards.forEach((m) => (m.entityType = EntityType.Award))
|
||||
|
||||
return awards
|
||||
}
|
||||
}
|
||||
@@ -1,213 +0,0 @@
|
||||
import D4HRequest from '../d4hRequest'
|
||||
import { EntityType } from '../entity'
|
||||
import type { Qualification, MemberAwards } from '../types/qualification'
|
||||
import { D4H_BASE_URL, GetQualificationOptions, GetMemberAwardsOptions } from '../d4h'
|
||||
|
||||
|
||||
|
||||
export class qualificationsApi {
|
||||
|
||||
static async getMemberQualification(request: D4HRequest, context: string, contextId: number, qualificationId: number | 'me'): Promise<Qualification> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/member-qualifications/${qualificationId}`)
|
||||
|
||||
const qualification = await request.getAsync<Qualification>(url)
|
||||
|
||||
if (!qualification) {
|
||||
throw new Error('Qualification data not found or improperly formatted.')
|
||||
}
|
||||
qualification.entityType = EntityType.Incident
|
||||
|
||||
return qualification
|
||||
}
|
||||
|
||||
static async getMemberQualifications(request: D4HRequest, context: string, contextId: number, options?: GetQualificationOptions): Promise<Qualification[]> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/member-qualifications`)
|
||||
|
||||
if (options !== undefined) {
|
||||
const optionsList = url.searchParams
|
||||
|
||||
if (options.exclude_org_data !== undefined) {
|
||||
optionsList.append('exclude_org_data', options.exclude_org_data.toString())
|
||||
}
|
||||
|
||||
if (options.exclude_teams_data !== undefined) {
|
||||
optionsList.append('exclude_teams_data', options.exclude_teams_data.toString())
|
||||
}
|
||||
if (options.order !== undefined) {
|
||||
optionsList.append('order', options.order)
|
||||
}
|
||||
|
||||
if (options.page !== undefined) {
|
||||
optionsList.append('page', options.page.toString())
|
||||
}
|
||||
if (options.size !== undefined) {
|
||||
optionsList.append('size', options.size.toString())
|
||||
}
|
||||
if (options.sort !== undefined) {
|
||||
if (Array.isArray(options.sort)) {
|
||||
options.sort.forEach(sortField => optionsList.append('sort', sortField))
|
||||
} else {
|
||||
optionsList.append('sort', options.sort)
|
||||
}
|
||||
}
|
||||
|
||||
if (options.title !== undefined) {
|
||||
optionsList.append('title', options.title)
|
||||
}
|
||||
}
|
||||
|
||||
return request.getManyAsync(url)
|
||||
}
|
||||
|
||||
|
||||
static async getAnimalQualification(request: D4HRequest, context: string, contextId: number, qualificationId: number): Promise<Qualification> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/animal-qualifications/${qualificationId}`)
|
||||
|
||||
const qualification = await request.getAsync<Qualification>(url)
|
||||
|
||||
if (!qualification) {
|
||||
throw new Error('Qualification data not found or improperly formatted.')
|
||||
}
|
||||
qualification.entityType = EntityType.Qualification
|
||||
|
||||
return qualification
|
||||
}
|
||||
|
||||
static async getAnimalQualifications(request: D4HRequest, context: string, contextId: number, options?: GetQualificationOptions): Promise<Qualification[]> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/animal-qualifications`)
|
||||
|
||||
if (options !== undefined) {
|
||||
const optionsList = url.searchParams
|
||||
|
||||
if (options.exclude_org_data !== undefined) {
|
||||
optionsList.append('exclude_org_data', options.exclude_org_data.toString())
|
||||
}
|
||||
|
||||
if (options.exclude_teams_data !== undefined) {
|
||||
optionsList.append('exclude_teams_data', options.exclude_teams_data.toString())
|
||||
}
|
||||
if (options.order !== undefined) {
|
||||
optionsList.append('order', options.order)
|
||||
}
|
||||
|
||||
if (options.page !== undefined) {
|
||||
optionsList.append('page', options.page.toString())
|
||||
}
|
||||
if (options.size !== undefined) {
|
||||
optionsList.append('size', options.size.toString())
|
||||
}
|
||||
if (options.sort !== undefined) {
|
||||
if (Array.isArray(options.sort)) {
|
||||
options.sort.forEach(sortField => optionsList.append('sort', sortField))
|
||||
} else {
|
||||
optionsList.append('sort', options.sort)
|
||||
}
|
||||
}
|
||||
|
||||
if (options.title !== undefined) {
|
||||
optionsList.append('title', options.title)
|
||||
}
|
||||
}
|
||||
|
||||
return request.getManyAsync(url)
|
||||
}
|
||||
|
||||
static async getHandlerQualification(request: D4HRequest, context: string, contextId: number, qualificationId: number): Promise<Qualification> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/handler-qualifications/${qualificationId}`)
|
||||
|
||||
const qualification = await request.getAsync<Qualification>(url)
|
||||
|
||||
if (!qualification) {
|
||||
throw new Error('Qualification data not found or improperly formatted.')
|
||||
}
|
||||
qualification.entityType = EntityType.Qualification
|
||||
|
||||
return qualification
|
||||
}
|
||||
|
||||
|
||||
static async getHandlerQualifications(request: D4HRequest, context: string, contextId: number, options?: GetQualificationOptions): Promise<Qualification[]> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/handler-qualifications`)
|
||||
|
||||
if (options !== undefined) {
|
||||
const optionsList = url.searchParams
|
||||
|
||||
if (options.exclude_org_data !== undefined) {
|
||||
optionsList.append('exclude_org_data', options.exclude_org_data.toString())
|
||||
}
|
||||
|
||||
if (options.exclude_teams_data !== undefined) {
|
||||
optionsList.append('exclude_teams_data', options.exclude_teams_data.toString())
|
||||
}
|
||||
if (options.order !== undefined) {
|
||||
optionsList.append('order', options.order)
|
||||
}
|
||||
|
||||
if (options.page !== undefined) {
|
||||
optionsList.append('page', options.page.toString())
|
||||
}
|
||||
if (options.size !== undefined) {
|
||||
optionsList.append('size', options.size.toString())
|
||||
}
|
||||
if (options.sort !== undefined) {
|
||||
if (Array.isArray(options.sort)) {
|
||||
options.sort.forEach(sortField => optionsList.append('sort', sortField))
|
||||
} else {
|
||||
optionsList.append('sort', options.sort)
|
||||
}
|
||||
}
|
||||
|
||||
if (options.title !== undefined) {
|
||||
optionsList.append('title', options.title)
|
||||
}
|
||||
}
|
||||
|
||||
return request.getManyAsync(url)
|
||||
}
|
||||
|
||||
static async getMemberAwards(request: D4HRequest, context: string, contextId: number, options?: GetMemberAwardsOptions): Promise<MemberAwards[]> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/member-qualification-awards`)
|
||||
|
||||
if (options !== undefined) {
|
||||
const optionsList = url.searchParams
|
||||
|
||||
if (options.exclude_org_data !== undefined) {
|
||||
optionsList.append('exclude_org_data', options.exclude_org_data.toString())
|
||||
}
|
||||
|
||||
if (options.exclude_teams_data !== undefined) {
|
||||
optionsList.append('exclude_teams_data', options.exclude_teams_data.toString())
|
||||
}
|
||||
|
||||
if (options.member_id !== undefined) {
|
||||
optionsList.append('member_id', options.member_id.toString())
|
||||
}
|
||||
if (options.order !== undefined) {
|
||||
optionsList.append('order', options.order)
|
||||
}
|
||||
|
||||
if (options.page !== undefined) {
|
||||
optionsList.append('page', options.page.toString())
|
||||
}
|
||||
|
||||
if (options.qualification_id !== undefined) {
|
||||
optionsList.append('qualification_id', options.qualification_id.toString())
|
||||
}
|
||||
if (options.size !== undefined) {
|
||||
optionsList.append('size', options.size.toString())
|
||||
}
|
||||
if (options.sort !== undefined) {
|
||||
if (Array.isArray(options.sort)) {
|
||||
options.sort.forEach(sortField => optionsList.append('sort', sortField))
|
||||
} else {
|
||||
optionsList.append('sort', options.sort)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const awards = await request.getManyAsync<MemberAwards>(url)
|
||||
awards.forEach((m) => (m.entityType = EntityType.Award))
|
||||
|
||||
return awards
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import D4HRequest from '../d4hRequest'
|
||||
import { EntityType } from '../entity'
|
||||
import D4H, { D4H_BASE_URL, D4H_FETCH_LIMIT } from '../d4h'
|
||||
import { Role } from '../types/role'
|
||||
|
||||
console.log(D4H_FETCH_LIMIT)
|
||||
|
||||
|
||||
export class Roles {
|
||||
private readonly _request: D4HRequest
|
||||
|
||||
constructor(d4hInstance: D4H) {
|
||||
this._request = d4hInstance.request
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param context - The point of view from where the request takes place
|
||||
* @param contextId - Either a team, organisation or admin's id
|
||||
* @param roleId - A role id
|
||||
* @returns - A role
|
||||
*/
|
||||
async getMemberQualification(context: 'admin' | 'organisation' | 'team', contextId: number, roleId: number | 'me'): Promise<Role> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/roles/${roleId}`)
|
||||
|
||||
try {
|
||||
const role = await this._request.getAsync<Role>(url)
|
||||
role.entityType = EntityType.Role
|
||||
return role
|
||||
} catch (error) {
|
||||
throw new Error('Role data not found or improperly formatted.')
|
||||
}
|
||||
}
|
||||
}
|
||||
+75
-364
@@ -1,383 +1,94 @@
|
||||
import { CustomFieldUpdate } from './types/customField'
|
||||
import D4HRequest from './d4hRequest'
|
||||
import { Entity, EntityType } from './entity'
|
||||
import type { memberGroup } from './types/group'
|
||||
import type { Member, MemberUpdate } from './types/member'
|
||||
import type { Qualification, MemberAwards } from './types/qualification'
|
||||
import type { Incident } from './types/incident'
|
||||
import type { Animal } from './types/animal'
|
||||
import { membersApi } from './api/membersApi'
|
||||
import { animalsApi } from './api/animalsApi'
|
||||
import { qualificationsApi } from './api/qualificationsApi'
|
||||
import { groupsApi } from './api/groupsApi'
|
||||
import { Team } from './types/team'
|
||||
import { Organisation } from './types/organisation'
|
||||
import { EntityType } from './entity'
|
||||
|
||||
|
||||
/** @ignore */
|
||||
const D4H_FETCH_LIMIT = 250
|
||||
|
||||
/** @ignore */
|
||||
const D4H_BASE_URL = 'https://api.team-manager.us.d4h.com/v3' // Multiple API endpoints now, probably should handle multiple
|
||||
|
||||
export { D4H_BASE_URL }
|
||||
export { D4H_BASE_URL, D4H_FETCH_LIMIT }
|
||||
|
||||
export interface GetMemberOptions {
|
||||
includeDetails?: boolean;
|
||||
}
|
||||
|
||||
export interface GetMembersOptions {
|
||||
deleted?: boolean; // default: false
|
||||
id_tag?: string;
|
||||
name?: string;
|
||||
order?: 'asc' | 'desc'; // default: 'asc'
|
||||
page?: number;
|
||||
size?: number;
|
||||
sort?: string | string[]; // default: 'id'
|
||||
statuses?: (number | null)[]; // list of ids or null
|
||||
team_id?: number; // the numeric identifier for a team resource
|
||||
}
|
||||
|
||||
export interface GetAnimalsOptions {
|
||||
handler_member_id?: number | number[];
|
||||
id?: number | number[];
|
||||
order?: 'asc' | 'desc'; // default: 'asc'
|
||||
page?: number;
|
||||
size?: number;
|
||||
sort?: string | string[]; // default: 'id'
|
||||
status?: string; // list of ids or null
|
||||
team_id?: number; // the numeric identifier for a team resource
|
||||
}
|
||||
|
||||
export interface GetGroupsOptions {
|
||||
memberId?: number;
|
||||
title?: string;
|
||||
}
|
||||
|
||||
export interface GetIncidentOptions {
|
||||
after?: string;
|
||||
before?: string;
|
||||
deleted?: boolean; // default: 'false'
|
||||
ends_before?: string;
|
||||
id?: number | number[];
|
||||
order?: 'asc' | 'desc'; // default: 'asc'
|
||||
page?: number;
|
||||
published?: boolean;
|
||||
reference?: string;
|
||||
size?: number;
|
||||
sort?: string | string[]; // default: 'id'
|
||||
starts_after?: string;
|
||||
tag_bundle_id?: number;
|
||||
tag_id?: number;
|
||||
team_id?: number;
|
||||
}
|
||||
|
||||
export interface GetQualificationOptions {
|
||||
exclude_org_data?: boolean; // default: false
|
||||
exclude_teams_data?: boolean; // default: false
|
||||
order?: 'asc' | 'desc'; // default: 'asc'
|
||||
page?: number;
|
||||
size?: number;
|
||||
sort?: string | string[]; // default: 'id'
|
||||
title?: string;
|
||||
}
|
||||
|
||||
export interface GetMemberAwardsOptions {
|
||||
exclude_org_data?: boolean; // default: false
|
||||
exclude_teams_data?: boolean; // default: false
|
||||
member_id?: number | 'me';
|
||||
order?: 'asc' | 'desc'; // default: 'asc'
|
||||
page?: number;
|
||||
qualification_id?: number;
|
||||
size?: number;
|
||||
sort?: string | string[]; // default: 'id'
|
||||
}
|
||||
|
||||
export interface GetMemberGroupsOptions {
|
||||
id: number;
|
||||
order?: 'asc' | 'desc'; // default: 'asc'
|
||||
page?: number;
|
||||
size?: number;
|
||||
sort?: string | string[]; // default: 'id'
|
||||
team_id?: number | number[];
|
||||
title?: string;
|
||||
}
|
||||
|
||||
export default class D4H {
|
||||
class D4H {
|
||||
private readonly _request: D4HRequest
|
||||
|
||||
constructor(token: string) {
|
||||
this._request = new D4HRequest(token, D4H_FETCH_LIMIT)
|
||||
}
|
||||
|
||||
/********************************************/
|
||||
/**************** MEMBERS *******************/
|
||||
/********************************************/
|
||||
|
||||
async getMember(
|
||||
context: string,
|
||||
contextId: number,
|
||||
id: number | 'me',
|
||||
options?: GetMemberOptions
|
||||
): Promise<Member> {
|
||||
return membersApi.getMember(this._request, context, contextId, id, options)
|
||||
|
||||
get request(): D4HRequest {
|
||||
return this._request
|
||||
}
|
||||
|
||||
async getMembers(
|
||||
context: string,
|
||||
contextId: number,
|
||||
options?: GetMembersOptions
|
||||
): Promise<Member[]> {
|
||||
return membersApi.getMembers(this._request, context, contextId, options)
|
||||
|
||||
}
|
||||
|
||||
class Teams {
|
||||
private readonly _request: D4HRequest
|
||||
|
||||
constructor(d4hInstance: D4H) {
|
||||
this._request = d4hInstance.request
|
||||
}
|
||||
|
||||
updateMember(context: string, contextId: number, id: number, updates: MemberUpdate): Promise<void> {
|
||||
// If no updates, no need to actually make a request. Exit early.
|
||||
if (Object.getOwnPropertyNames(updates).length === 0) {
|
||||
return Promise.resolve()
|
||||
/**
|
||||
* @param context - The point of view from where the request takes place
|
||||
* @param contextId - Either a team, organisation or admin's id
|
||||
* @param teamId - A team's id
|
||||
* @returns - A team
|
||||
*/
|
||||
async getTeam(
|
||||
context: 'admin' | 'organisation' | 'team',
|
||||
contextId: number,
|
||||
teamId: number,
|
||||
): Promise<Team> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/teams/${teamId}`)
|
||||
|
||||
try {
|
||||
const team = await this._request.getAsync<Team>(url)
|
||||
team.entityType = EntityType.Team
|
||||
return team
|
||||
} catch (error) {
|
||||
throw new Error('Team data not found or improperly formatted.')
|
||||
}
|
||||
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/members/${id}`)
|
||||
return this._request.putAsync(url, updates)
|
||||
}
|
||||
|
||||
/********************************************/
|
||||
/**************** ANIMALS *******************/
|
||||
/********************************************/
|
||||
|
||||
async getAnimal(
|
||||
context: string,
|
||||
contextId: number,
|
||||
id: number | 'me',
|
||||
): Promise<Animal> {
|
||||
return animalsApi.getAnimal(this._request, context, contextId, id)
|
||||
}
|
||||
|
||||
async getAnimals(
|
||||
context: string,
|
||||
contextId: number,
|
||||
options?: GetAnimalsOptions
|
||||
): Promise<Animal[]> {
|
||||
return animalsApi.getAnimals(this._request, context, contextId, options)
|
||||
}
|
||||
|
||||
/********************************************/
|
||||
/*********** EMERGENCY CONTACTS *************/
|
||||
/********************************************/
|
||||
|
||||
// Emergency Contacts no longer have specific endpoint
|
||||
|
||||
/********************************************/
|
||||
/***************** GROUPS *******************/
|
||||
/********************************************/
|
||||
|
||||
async getMemberGroup(
|
||||
context: string,
|
||||
contextId: number,
|
||||
groupId: number,
|
||||
): Promise<memberGroup> {
|
||||
return groupsApi.getMemberGroup(this._request, context, contextId, groupId)
|
||||
}
|
||||
|
||||
async getMemberGroups(
|
||||
context: string,
|
||||
contextId: number,
|
||||
options?: GetMemberGroupsOptions
|
||||
): Promise<memberGroup[]> {
|
||||
return groupsApi.getMemberGroups(this._request, context, contextId, options)
|
||||
}
|
||||
|
||||
/********************************************/
|
||||
/**************** INCIDENTS *****************/
|
||||
/********************************************/
|
||||
|
||||
async getIncident(context: string, contextId: number, activityId: number): Promise<Incident> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/incidents/${activityId}`)
|
||||
|
||||
const incident = await this._request.getAsync<Incident>(url)
|
||||
|
||||
if (!incident) {
|
||||
throw new Error('Incident data not found or improperly formatted.')
|
||||
}
|
||||
incident.entityType = EntityType.Incident
|
||||
|
||||
return incident
|
||||
}
|
||||
|
||||
async getIncidents(context: string, contextId: number, options?: GetIncidentOptions): Promise<Incident[]> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/incidents`)
|
||||
|
||||
if (options !== undefined) {
|
||||
const optionsList = url.searchParams
|
||||
|
||||
if (options.after !== undefined) {
|
||||
optionsList.append('after', options.after)
|
||||
}
|
||||
if (options.before !== undefined) {
|
||||
optionsList.append('before', options.before)
|
||||
}
|
||||
if (options.deleted !== undefined) {
|
||||
optionsList.append('order', options.deleted.toString())
|
||||
}
|
||||
if (options.ends_before !== undefined) {
|
||||
optionsList.append('ends_before', options.ends_before)
|
||||
}
|
||||
if (options.id !== undefined) {
|
||||
optionsList.append('id', options.id.toString())
|
||||
}
|
||||
if (options.order !== undefined) {
|
||||
optionsList.append('order', options.order)
|
||||
}
|
||||
if (options.page !== undefined) {
|
||||
optionsList.append('page', options.page.toString())
|
||||
}
|
||||
if (options.published !== undefined) {
|
||||
optionsList.append('published', options.published.toString())
|
||||
}
|
||||
if (options.reference !== undefined) {
|
||||
optionsList.append('reference', options.reference)
|
||||
}
|
||||
if (options.size !== undefined) {
|
||||
optionsList.append('size', options.size.toString())
|
||||
}
|
||||
if (options.sort !== undefined) {
|
||||
if (Array.isArray(options.sort)) {
|
||||
options.sort.forEach(sortField => optionsList.append('sort', sortField))
|
||||
} else {
|
||||
optionsList.append('sort', options.sort)
|
||||
}
|
||||
}
|
||||
if (options.starts_after !== undefined) {
|
||||
optionsList.append('starts_after', options.starts_after)
|
||||
}
|
||||
if (options.tag_bundle_id !== undefined) {
|
||||
optionsList.append('tag_bundle_id', options.tag_bundle_id.toString())
|
||||
}
|
||||
if (options.tag_id !== undefined) {
|
||||
optionsList.append('tag_id', options.tag_id.toString())
|
||||
}
|
||||
if (options.team_id !== undefined) {
|
||||
optionsList.append('team_id', options.team_id.toString())
|
||||
}
|
||||
}
|
||||
|
||||
return this._request.getManyAsync(url)
|
||||
}
|
||||
|
||||
/********************************************/
|
||||
/************* QUALIFICATIONS ***************/
|
||||
/********************************************/
|
||||
|
||||
async getMemberQualification(
|
||||
context: string,
|
||||
contextId: number,
|
||||
id: number | 'me',
|
||||
): Promise<Qualification> {
|
||||
return qualificationsApi.getMemberQualification(this._request, context, contextId, id)
|
||||
}
|
||||
|
||||
async getMemberQualifications(
|
||||
context: string,
|
||||
contextId: number,
|
||||
options?: GetQualificationOptions
|
||||
): Promise<Qualification[]> {
|
||||
return qualificationsApi.getMemberQualifications(this._request, context, contextId, options)
|
||||
}
|
||||
|
||||
async getAnimalQualification(
|
||||
context: string,
|
||||
contextId: number,
|
||||
id: number,
|
||||
): Promise<Qualification> {
|
||||
return qualificationsApi.getAnimalQualification(this._request, context, contextId, id)
|
||||
}
|
||||
|
||||
async getAnimalQualifications(
|
||||
context: string,
|
||||
contextId: number,
|
||||
options?: GetQualificationOptions
|
||||
): Promise<Qualification[]> {
|
||||
return qualificationsApi.getAnimalQualifications(this._request, context, contextId, options)
|
||||
}
|
||||
|
||||
async getHandlerQualification(
|
||||
context: string,
|
||||
contextId: number,
|
||||
id: number,
|
||||
): Promise<Qualification> {
|
||||
return qualificationsApi.getHandlerQualification(this._request, context, contextId, id)
|
||||
}
|
||||
|
||||
async getHandlerQualifications(
|
||||
context: string,
|
||||
contextId: number,
|
||||
options?: GetQualificationOptions
|
||||
): Promise<Qualification[]> {
|
||||
return qualificationsApi.getHandlerQualifications(this._request, context, contextId, options)
|
||||
}
|
||||
|
||||
async getMemberAwards(
|
||||
context: string,
|
||||
contextId: number,
|
||||
options?: GetMemberAwardsOptions
|
||||
): Promise<MemberAwards[]> {
|
||||
return qualificationsApi.getMemberAwards(this._request, context, contextId, options)
|
||||
}
|
||||
|
||||
/********************************************/
|
||||
/************** CUSTOM FIELDS ***************/
|
||||
/********************************************/
|
||||
|
||||
|
||||
|
||||
updateCustomFields(entity: Entity, updates: CustomFieldUpdate[], onlyMemberEditOwn: boolean): Promise<void> {
|
||||
// If no updates, no need to actually make a request. Exit early.
|
||||
if (updates.length === 0) {
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
const url = new URL(`${D4H_BASE_URL}/team/custom-fields/${entity.entityType}/${entity.id}`)
|
||||
|
||||
// From the documentation:
|
||||
// https://api.d4h.org/v2/documentation#operation/putTeamCustomfieldsEntity_typeEntity_id
|
||||
// The PUT action for fields is distinguished by Bundle. If you include one field's value
|
||||
// from a bundle (or an unbundled field's value) you must include values for all fields
|
||||
// of that bundle (or all unbundled fields)
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// To ensure a mistake doesn't occur, let's ensure that *all* unbundled custom fields from the original
|
||||
// entity are in the list of updates.
|
||||
//
|
||||
// At this time we don't actively use any custom fields in a bundle. To save on the additional complexity,
|
||||
// bundled custom fields are not supported and will result in an error if attempting to update them.
|
||||
|
||||
// At this time all entities we're working with have custom fields. As a result, throw an
|
||||
// error if none are found. This most likely indicates the original request was made without
|
||||
// including custom fields.
|
||||
const originalCustomFields = entity.custom_fields
|
||||
if (!originalCustomFields) {
|
||||
throw new Error('Cannot update custom fields for an entity with no custom fields. Ensure your original request included custom fields.')
|
||||
|
||||
}
|
||||
|
||||
// For any fields not being changed, back fill from the original entity to ensure
|
||||
// they retain the same value.
|
||||
for (const field of originalCustomFields) {
|
||||
const update = updates.find((u) => u.id == field.id)
|
||||
if (update) {
|
||||
if (onlyMemberEditOwn && !field.member_edit_own) {
|
||||
throw new Error('onlyMemberEditOwn specified, but attempting to update non-memberEditOwn field.')
|
||||
} else if (field.bundle) {
|
||||
throw new Error('One or more custom fields being updated are part of a bundle. Updating fields in a bundle is not supported.')
|
||||
}
|
||||
} else {
|
||||
let include = true
|
||||
if (field.bundle || (onlyMemberEditOwn && !field.member_edit_own)) {
|
||||
include = false
|
||||
}
|
||||
|
||||
if (include) {
|
||||
updates.push({
|
||||
id: field.id,
|
||||
value: field.value
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this._request.putAsync(url, { fields: updates })
|
||||
}
|
||||
}
|
||||
|
||||
class Organisations {
|
||||
private readonly _request: D4HRequest
|
||||
|
||||
constructor(d4hInstance: D4H) {
|
||||
this._request = d4hInstance.request
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context - The point of view from where the request takes place
|
||||
* @param contextId - Either a team, organisation or admin's id
|
||||
* @param organisationId - An organisation's id
|
||||
* @returns - A organisation
|
||||
*/
|
||||
async getOrganisation(
|
||||
context: 'admin' | 'organisation' | 'team',
|
||||
contextId: number,
|
||||
organisationId: number,
|
||||
): Promise<Organisation> {
|
||||
const url = new URL(`${D4H_BASE_URL}/${context}/${contextId}/organisations/${organisationId}`)
|
||||
|
||||
try {
|
||||
const organisation = await this._request.getAsync<Organisation>(url)
|
||||
organisation.entityType = EntityType.Organisation
|
||||
return organisation
|
||||
} catch (error) {
|
||||
throw new Error('Organisation data not found or improperly formatted.')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
Teams,
|
||||
Organisations,
|
||||
}
|
||||
export default D4H
|
||||
@@ -58,33 +58,32 @@ export default class D4HRequest {
|
||||
return this.requestAsync<never, DataType>(url, HttpMethod.Get)
|
||||
}
|
||||
|
||||
async getManyAsync<DataType>(url: URL, paginate: boolean = false): Promise<DataType[]> {
|
||||
async getManyAsync<DataType>(url: URL, paginate = false): Promise<DataType[]> {
|
||||
let results: DataType[] = []
|
||||
|
||||
|
||||
if (paginate) {
|
||||
let offset = 0
|
||||
|
||||
let hasMore = true
|
||||
|
||||
// Pagination loop
|
||||
while (true) {
|
||||
while (hasMore) {
|
||||
const urlWithOffset = new URL(url)
|
||||
urlWithOffset.searchParams.append('offset', offset.toString())
|
||||
urlWithOffset.searchParams.append('limit', this._fetchLimit.toString())
|
||||
|
||||
|
||||
const newResults = await this.getAsync<DataType[]>(urlWithOffset)
|
||||
results = results.concat(newResults)
|
||||
offset += this._fetchLimit
|
||||
|
||||
if (newResults.length < this._fetchLimit) {
|
||||
break
|
||||
}
|
||||
|
||||
hasMore = newResults.length === this._fetchLimit
|
||||
}
|
||||
} else {
|
||||
// Fetch without pagination
|
||||
const newResults = await this.getAsync<DataType[]>(url)
|
||||
results = results.concat(newResults)
|
||||
}
|
||||
|
||||
|
||||
return results
|
||||
}
|
||||
|
||||
|
||||
+6
-1
@@ -14,8 +14,13 @@ export interface Entity {
|
||||
export enum EntityType {
|
||||
Member = 'member',
|
||||
memberGroup = 'membergroup',
|
||||
groupMembership = 'groupmembership',
|
||||
Incident = 'incident',
|
||||
Qualification = 'qualification',
|
||||
Award = 'award',
|
||||
Animal = 'animal'
|
||||
Animal = 'animal',
|
||||
Team = 'team',
|
||||
Organisation = 'organisation',
|
||||
Role = 'role',
|
||||
Activity = 'activity'
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
export interface Account {
|
||||
id: number;
|
||||
resourceType: string;
|
||||
}
|
||||
|
||||
export interface ContextOwner {
|
||||
resourceType: string;
|
||||
id: number;
|
||||
title?: string;
|
||||
owner?: ContextOwner;
|
||||
}
|
||||
|
||||
export interface Permissions {
|
||||
[key: string]: {
|
||||
[action: string]: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export interface Context {
|
||||
id: number;
|
||||
owner: ContextOwner;
|
||||
name: string;
|
||||
hasAccess: boolean;
|
||||
resourceType: string;
|
||||
permissions: Permissions;
|
||||
}
|
||||
|
||||
export interface WhoAmIType {
|
||||
account: Account;
|
||||
context: Context;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { Entity } from '../entity'
|
||||
import { resourceType } from './generic';
|
||||
|
||||
export interface Activity extends Entity {
|
||||
|
||||
activity: resourceType;
|
||||
createdAt: string;
|
||||
duration: number;
|
||||
endsAt: string;
|
||||
id: number;
|
||||
member: resourceType;
|
||||
owner: resourceType;
|
||||
startsAt: string;
|
||||
status: string;
|
||||
resourceType: string;
|
||||
role: resourceType;
|
||||
updatedAt: string;
|
||||
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
/** @ignore @inline */
|
||||
export enum CustomFieldType {
|
||||
Number = 'number',
|
||||
Text = 'text',
|
||||
@@ -14,6 +15,7 @@ export interface CustomField {
|
||||
member_edit_own: boolean;
|
||||
}
|
||||
|
||||
/** @ignore @inline */
|
||||
export interface CustomFieldUpdate {
|
||||
id: number;
|
||||
value: string | null;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
|
||||
/** @ignore */
|
||||
export interface EmergencyContact {
|
||||
name: string | null
|
||||
relation: string | null
|
||||
@@ -5,6 +7,7 @@ export interface EmergencyContact {
|
||||
alt_phone: string | null
|
||||
}
|
||||
|
||||
/** @ignore */
|
||||
export interface EmergencyContacts {
|
||||
primary: EmergencyContact
|
||||
secondary: EmergencyContact
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
//generic.ts
|
||||
|
||||
// Reusable interface, used in many other interfaces
|
||||
|
||||
/** @ignore @inline */
|
||||
export interface resourceType {
|
||||
resourceType: string | null;
|
||||
id: number | null;
|
||||
}
|
||||
@@ -1,4 +1,11 @@
|
||||
import { Entity } from '../entity'
|
||||
import { resourceType } from './generic'
|
||||
|
||||
|
||||
|
||||
/********************************************/
|
||||
/**************** GROUPS ********************/
|
||||
/********************************************/
|
||||
|
||||
export interface memberGroup extends Entity{
|
||||
id: number;
|
||||
@@ -8,4 +15,18 @@ export interface memberGroup extends Entity{
|
||||
resourceType: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/********************************************/
|
||||
/*********** GROUP MEMBERSHIP ***************/
|
||||
/********************************************/
|
||||
|
||||
export interface groupMembership extends Entity{
|
||||
id: number;
|
||||
owner: resourceType;
|
||||
group: resourceType;
|
||||
member: resourceType;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user