@bjornharrtell/json-api 5.1.1 → 5.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs/enums/RelationshipType.html +2 -2
- package/dist/docs/functions/camel.html +1 -1
- package/dist/docs/functions/useJsonApi.html +1 -1
- package/dist/docs/interfaces/AtomicOperation.html +2 -2
- package/dist/docs/interfaces/BaseEntity.html +2 -2
- package/dist/docs/interfaces/FetchOptions.html +2 -2
- package/dist/docs/interfaces/FetchParams.html +1 -1
- package/dist/docs/interfaces/JsonApiAtomicDocument.html +2 -2
- package/dist/docs/interfaces/JsonApiAtomicOperation.html +2 -2
- package/dist/docs/interfaces/JsonApiAtomicResult.html +2 -2
- package/dist/docs/interfaces/JsonApiConfig.html +4 -4
- package/dist/docs/interfaces/JsonApiDocument.html +2 -2
- package/dist/docs/interfaces/JsonApiError.html +2 -2
- package/dist/docs/interfaces/JsonApiLinkObject.html +2 -2
- package/dist/docs/interfaces/JsonApiLinks.html +2 -2
- package/dist/docs/interfaces/JsonApiMeta.html +2 -2
- package/dist/docs/interfaces/JsonApiRelationship.html +2 -2
- package/dist/docs/interfaces/JsonApiResource.html +2 -2
- package/dist/docs/interfaces/JsonApiResourceIdentifier.html +2 -2
- package/dist/docs/interfaces/ModelDefinition.html +3 -3
- package/dist/docs/interfaces/PageOption.html +2 -2
- package/dist/docs/interfaces/Relationship.html +3 -3
- package/dist/docs/types/JsonApi.html +1 -1
- package/dist/docs/types/JsonApiFetcher.html +1 -1
- package/dist/docs/types/JsonApiLink.html +1 -1
- package/dist/lib.js +166 -155
- package/dist/lib.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>Relationship | @bjornharrtell/json-api</title><meta name="description" content="Documentation for @bjornharrtell/json-api"/><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(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">@bjornharrtell/json-api</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="" aria-current="page">Relationship</a></li></ul><h1>Interface Relationship</h1></div><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><p>Relationship definition</p>
|
|
2
|
-
</div></section><div class="tsd-signature"><span class="tsd-signature-keyword">interface</span> <span class="tsd-kind-interface">Relationship</span> <span class="tsd-signature-symbol">{</span><br/> <a class="tsd-kind-property" href="#relationshiptype">relationshipType</a><span class="tsd-signature-symbol">:</span> <a href="../enums/RelationshipType.html" class="tsd-signature-type tsd-kind-enum">RelationshipType</a><span class="tsd-signature-symbol">;</span><br/> <a class="tsd-kind-property" href="#type">type</a><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</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/bjornharrtell/json-api/blob/
|
|
2
|
+
</div></section><div class="tsd-signature"><span class="tsd-signature-keyword">interface</span> <span class="tsd-kind-interface">Relationship</span> <span class="tsd-signature-symbol">{</span><br/> <a class="tsd-kind-property" href="#relationshiptype">relationshipType</a><span class="tsd-signature-symbol">:</span> <a href="../enums/RelationshipType.html" class="tsd-signature-type tsd-kind-enum">RelationshipType</a><span class="tsd-signature-symbol">;</span><br/> <a class="tsd-kind-property" href="#type">type</a><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</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/bjornharrtell/json-api/blob/35b59820d4c25064f7bde1ee8fea07c1d8268d0d/src/json-api.ts#L146">json-api.ts:146</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"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h5 class="tsd-index-heading uppercase">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="#relationshiptype" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>relationship<wbr/>Type</span></a>
|
|
3
3
|
<a href="#type" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>type</span></a>
|
|
4
4
|
</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"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h2>Properties</h2></summary><section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="relationshiptype"><span>relationship<wbr/>Type</span><a href="#relationshiptype" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">relationshipType</span><span class="tsd-signature-symbol">:</span> <a href="../enums/RelationshipType.html" class="tsd-signature-type tsd-kind-enum">RelationshipType</a></div><div class="tsd-comment tsd-typography"><p>The relationship type</p>
|
|
5
|
-
</div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/bjornharrtell/json-api/blob/
|
|
6
|
-
</div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/bjornharrtell/json-api/blob/
|
|
5
|
+
</div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/bjornharrtell/json-api/blob/35b59820d4c25064f7bde1ee8fea07c1d8268d0d/src/json-api.ts#L150">json-api.ts:150</a></li></ul></aside></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="type"><span>type</span><a href="#type" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">type</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div><div class="tsd-comment tsd-typography"><p>The JSON:API type name of the related model</p>
|
|
6
|
+
</div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/bjornharrtell/json-api/blob/35b59820d4c25064f7bde1ee8fea07c1d8268d0d/src/json-api.ts#L148">json-api.ts:148</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"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>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"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>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" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Properties</summary><div><a href="#relationshiptype"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>relationship<wbr/>Type</span></a><a href="#type"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>type</span></a></div></details></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">@bjornharrtell/json-api</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>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>JsonApi | @bjornharrtell/json-api</title><meta name="description" content="Documentation for @bjornharrtell/json-api"/><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(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">@bjornharrtell/json-api</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="" aria-current="page">JsonApi</a></li></ul><h1>Type Alias JsonApi</h1></div><div class="tsd-signature"><span class="tsd-kind-type-alias">JsonApi</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">ReturnType</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-keyword">typeof</span> <a href="../functions/useJsonApi.html" class="tsd-signature-type tsd-kind-function">useJsonApi</a><span class="tsd-signature-symbol">></span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/bjornharrtell/json-api/blob/
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>JsonApi | @bjornharrtell/json-api</title><meta name="description" content="Documentation for @bjornharrtell/json-api"/><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(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">@bjornharrtell/json-api</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="" aria-current="page">JsonApi</a></li></ul><h1>Type Alias JsonApi</h1></div><div class="tsd-signature"><span class="tsd-kind-type-alias">JsonApi</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">ReturnType</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-keyword">typeof</span> <a href="../functions/useJsonApi.html" class="tsd-signature-type tsd-kind-function">useJsonApi</a><span class="tsd-signature-symbol">></span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/bjornharrtell/json-api/blob/35b59820d4c25064f7bde1ee8fea07c1d8268d0d/src/json-api.ts#L157">json-api.ts:157</a></li></ul></aside></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>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></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">@bjornharrtell/json-api</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>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>JsonApiFetcher | @bjornharrtell/json-api</title><meta name="description" content="Documentation for @bjornharrtell/json-api"/><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(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">@bjornharrtell/json-api</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="" aria-current="page">JsonApiFetcher</a></li></ul><h1>Type Alias JsonApiFetcher</h1></div><div class="tsd-signature"><span class="tsd-kind-type-alias">JsonApiFetcher</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">InstanceType</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-keyword">typeof</span> <span class="tsd-signature-type">JsonApiFetcherImpl</span><span class="tsd-signature-symbol">></span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/bjornharrtell/json-api/blob/
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>JsonApiFetcher | @bjornharrtell/json-api</title><meta name="description" content="Documentation for @bjornharrtell/json-api"/><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(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">@bjornharrtell/json-api</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="" aria-current="page">JsonApiFetcher</a></li></ul><h1>Type Alias JsonApiFetcher</h1></div><div class="tsd-signature"><span class="tsd-kind-type-alias">JsonApiFetcher</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">InstanceType</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-keyword">typeof</span> <span class="tsd-signature-type">JsonApiFetcherImpl</span><span class="tsd-signature-symbol">></span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/bjornharrtell/json-api/blob/35b59820d4c25064f7bde1ee8fea07c1d8268d0d/src/json-api-fetcher.ts#L88">json-api-fetcher.ts:88</a></li></ul></aside></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>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></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">@bjornharrtell/json-api</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>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>JsonApiLink | @bjornharrtell/json-api</title><meta name="description" content="Documentation for @bjornharrtell/json-api"/><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(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">@bjornharrtell/json-api</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="" aria-current="page">JsonApiLink</a></li></ul><h1>Type Alias JsonApiLink</h1></div><div class="tsd-signature"><span class="tsd-kind-type-alias">JsonApiLink</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">null</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">string</span> <span class="tsd-signature-symbol">|</span> <a href="../interfaces/JsonApiLinkObject.html" class="tsd-signature-type tsd-kind-interface">JsonApiLinkObject</a></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/bjornharrtell/json-api/blob/
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>JsonApiLink | @bjornharrtell/json-api</title><meta name="description" content="Documentation for @bjornharrtell/json-api"/><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(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">@bjornharrtell/json-api</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="" aria-current="page">JsonApiLink</a></li></ul><h1>Type Alias JsonApiLink</h1></div><div class="tsd-signature"><span class="tsd-kind-type-alias">JsonApiLink</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">null</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">string</span> <span class="tsd-signature-symbol">|</span> <a href="../interfaces/JsonApiLinkObject.html" class="tsd-signature-type tsd-kind-interface">JsonApiLinkObject</a></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/bjornharrtell/json-api/blob/35b59820d4c25064f7bde1ee8fea07c1d8268d0d/src/json-api.ts#L48">json-api.ts:48</a></li></ul></aside></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>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></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">@bjornharrtell/json-api</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>
|
package/dist/lib.js
CHANGED
|
@@ -1,225 +1,236 @@
|
|
|
1
|
-
function O(...
|
|
2
|
-
return new URL(
|
|
1
|
+
function O(...o) {
|
|
2
|
+
return new URL(o.join("/")).href;
|
|
3
3
|
}
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
class P extends Error {
|
|
5
|
+
constructor(t, n, d) {
|
|
6
|
+
super(t), this.status = n, this.body = d, this.name = "HttpError";
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
async function U(o) {
|
|
10
|
+
try {
|
|
11
|
+
return await o.json();
|
|
12
|
+
} catch {
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
async function T(o, t) {
|
|
16
|
+
const { headers: n, searchParams: d, method: r, signal: u, body: p } = t, y = d ? `?${d}` : "", g = o.replace(/(?:\?.*?)?(?=#|$)/, y), b = await fetch(g, {
|
|
17
|
+
method: r,
|
|
7
18
|
headers: n,
|
|
8
|
-
signal:
|
|
9
|
-
body:
|
|
10
|
-
});
|
|
11
|
-
if (!b.ok) throw new
|
|
12
|
-
return
|
|
19
|
+
signal: u,
|
|
20
|
+
body: p
|
|
21
|
+
}), j = await U(b);
|
|
22
|
+
if (!b.ok) throw new P(`HTTP error! status: ${b.status} ${b.statusText}`, b.status, j);
|
|
23
|
+
return j;
|
|
13
24
|
}
|
|
14
|
-
async function
|
|
15
|
-
const { signal: n, body:
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
method:
|
|
19
|
-
headers:
|
|
25
|
+
async function C(o, t) {
|
|
26
|
+
const { signal: n, body: d } = t, r = "POST", u = new Headers(t.headers ?? {});
|
|
27
|
+
u.append("Accept", 'application/vnd.api+json; ext="https://jsonapi.org/ext/atomic"'), u.append("Content-Type", 'application/vnd.api+json; ext="https://jsonapi.org/ext/atomic"');
|
|
28
|
+
const p = await fetch(o, {
|
|
29
|
+
method: r,
|
|
30
|
+
headers: u,
|
|
20
31
|
signal: n,
|
|
21
|
-
body:
|
|
22
|
-
});
|
|
23
|
-
if (!
|
|
24
|
-
return
|
|
32
|
+
body: d
|
|
33
|
+
}), y = await U(p);
|
|
34
|
+
if (!p.ok) throw new P(`HTTP error! status: ${p.status} ${p.statusText}`, p.status, y);
|
|
35
|
+
return p.status === 204 ? void 0 : y;
|
|
25
36
|
}
|
|
26
|
-
class
|
|
37
|
+
class J {
|
|
27
38
|
constructor(t) {
|
|
28
39
|
this.endpoint = t;
|
|
29
40
|
}
|
|
30
|
-
createOptions(t = {}, n = {},
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
const
|
|
41
|
+
createOptions(t = {}, n = {}, d) {
|
|
42
|
+
const r = new URLSearchParams(), u = new Headers(t.headers ?? {});
|
|
43
|
+
u.append("Accept", "application/vnd.api+json");
|
|
44
|
+
const p = { searchParams: r, headers: u, body: d };
|
|
34
45
|
if (t.fields)
|
|
35
|
-
for (const [
|
|
36
|
-
t.page?.size &&
|
|
37
|
-
for (const [
|
|
38
|
-
return
|
|
46
|
+
for (const [y, g] of Object.entries(t.fields)) r.append(`fields[${y}]`, g.join(","));
|
|
47
|
+
t.page?.size && r.append("page[size]", t.page.size.toString()), t.page?.number && r.append("page[number]", t.page.number.toString()), t.include && r.append("include", t.include.join(",")), t.filter && r.append("filter", t.filter);
|
|
48
|
+
for (const [y, g] of Object.entries(n)) r.append(y, g);
|
|
49
|
+
return p;
|
|
39
50
|
}
|
|
40
|
-
async fetchDocument(t, n,
|
|
41
|
-
const
|
|
42
|
-
n &&
|
|
43
|
-
const
|
|
44
|
-
return await T(
|
|
51
|
+
async fetchDocument(t, n, d, r) {
|
|
52
|
+
const u = [this.endpoint, t];
|
|
53
|
+
n && u.push(n);
|
|
54
|
+
const p = O(...u);
|
|
55
|
+
return await T(p, this.createOptions(d, r));
|
|
45
56
|
}
|
|
46
|
-
async fetchAll(t, n,
|
|
47
|
-
const
|
|
48
|
-
return (await T(
|
|
57
|
+
async fetchAll(t, n, d) {
|
|
58
|
+
const r = O(this.endpoint, t);
|
|
59
|
+
return (await T(r, this.createOptions(n, d))).data;
|
|
49
60
|
}
|
|
50
|
-
async fetchOne(t, n,
|
|
51
|
-
const
|
|
52
|
-
return (await T(
|
|
61
|
+
async fetchOne(t, n, d, r) {
|
|
62
|
+
const u = O(this.endpoint, t, n);
|
|
63
|
+
return (await T(u, this.createOptions(d, r))).data;
|
|
53
64
|
}
|
|
54
|
-
async fetchHasMany(t, n,
|
|
55
|
-
const
|
|
56
|
-
return await T(
|
|
65
|
+
async fetchHasMany(t, n, d, r, u) {
|
|
66
|
+
const p = O(this.endpoint, t, n, d);
|
|
67
|
+
return await T(p, this.createOptions(r, u));
|
|
57
68
|
}
|
|
58
|
-
async fetchBelongsTo(t, n,
|
|
59
|
-
const
|
|
60
|
-
return await T(
|
|
69
|
+
async fetchBelongsTo(t, n, d, r, u) {
|
|
70
|
+
const p = O(this.endpoint, t, n, d);
|
|
71
|
+
return await T(p, this.createOptions(r, u));
|
|
61
72
|
}
|
|
62
73
|
async post(t, n) {
|
|
63
|
-
const
|
|
74
|
+
const d = O(this.endpoint, t.type), u = JSON.stringify({
|
|
64
75
|
data: t
|
|
65
|
-
}),
|
|
66
|
-
return
|
|
76
|
+
}), p = this.createOptions(n, {}, u);
|
|
77
|
+
return p.method = "POST", p.headers.set("Content-Type", "application/vnd.api+json"), await T(d, p);
|
|
67
78
|
}
|
|
68
79
|
async postAtomic(t, n = {}) {
|
|
69
|
-
const
|
|
70
|
-
return n.body = JSON.stringify(t), await
|
|
80
|
+
const d = new URL([this.endpoint, "operations"].join("/")).href;
|
|
81
|
+
return n.body = JSON.stringify(t), await C(d, n);
|
|
71
82
|
}
|
|
72
83
|
}
|
|
73
|
-
function
|
|
74
|
-
return
|
|
84
|
+
function F(o) {
|
|
85
|
+
return o.replace(/[-][a-z\u00E0-\u00F6\u00F8-\u00FE]/g, (t) => t.slice(1).toUpperCase());
|
|
75
86
|
}
|
|
76
|
-
var
|
|
77
|
-
function
|
|
78
|
-
|
|
87
|
+
var L = /* @__PURE__ */ ((o) => (o[o.HasMany = 0] = "HasMany", o[o.BelongsTo = 1] = "BelongsTo", o))(L || {});
|
|
88
|
+
function x(o, t, n) {
|
|
89
|
+
o[t] = n;
|
|
79
90
|
}
|
|
80
|
-
function A(
|
|
81
|
-
const t = { type:
|
|
82
|
-
return
|
|
91
|
+
function A(o) {
|
|
92
|
+
const t = { type: o.type };
|
|
93
|
+
return o.lid ? t.lid = o.lid : o.id && (t.id = o.id), t;
|
|
83
94
|
}
|
|
84
|
-
function
|
|
85
|
-
const n = t ?? new
|
|
86
|
-
for (const e of
|
|
87
|
-
|
|
88
|
-
function
|
|
89
|
-
return
|
|
90
|
-
}
|
|
91
|
-
function
|
|
92
|
-
const
|
|
93
|
-
l.attributes = {},
|
|
94
|
-
for (const [
|
|
95
|
-
if (!(
|
|
96
|
-
if (
|
|
97
|
-
const
|
|
98
|
-
if (
|
|
99
|
-
const
|
|
100
|
-
l.relationships[
|
|
101
|
-
data:
|
|
95
|
+
function I(o, t) {
|
|
96
|
+
const n = t ?? new J(o.endpoint), d = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
97
|
+
for (const e of o.modelDefinitions)
|
|
98
|
+
d.set(e.type, e), e.relationships && r.set(e.type, e.relationships);
|
|
99
|
+
function u(e) {
|
|
100
|
+
return o.kebabCase ? F(e) : e;
|
|
101
|
+
}
|
|
102
|
+
function p(e) {
|
|
103
|
+
const s = r.get(e.type), l = A(e);
|
|
104
|
+
l.attributes = {}, s && (l.relationships = {});
|
|
105
|
+
for (const [a, c] of Object.entries(e))
|
|
106
|
+
if (!(a === "id" || a === "lid" || a === "type" || c === void 0))
|
|
107
|
+
if (s && a in s && l.relationships) {
|
|
108
|
+
const w = s[a];
|
|
109
|
+
if (w.relationshipType === 0) {
|
|
110
|
+
const f = c;
|
|
111
|
+
l.relationships[a] = {
|
|
112
|
+
data: f.map(A)
|
|
102
113
|
};
|
|
103
|
-
} else if (
|
|
104
|
-
const
|
|
105
|
-
l.relationships[
|
|
106
|
-
data: A(
|
|
114
|
+
} else if (w.relationshipType === 1) {
|
|
115
|
+
const f = c;
|
|
116
|
+
l.relationships[a] = {
|
|
117
|
+
data: A(f)
|
|
107
118
|
};
|
|
108
119
|
} else
|
|
109
|
-
throw new Error(`Unknown relationship type for ${
|
|
120
|
+
throw new Error(`Unknown relationship type for ${a}`);
|
|
110
121
|
} else
|
|
111
|
-
l.attributes[
|
|
122
|
+
l.attributes[a] = c;
|
|
112
123
|
return l;
|
|
113
124
|
}
|
|
114
|
-
function
|
|
115
|
-
if (!
|
|
116
|
-
const
|
|
117
|
-
if (
|
|
118
|
-
const
|
|
119
|
-
for (const [
|
|
120
|
-
|
|
121
|
-
return
|
|
125
|
+
function y(e, s) {
|
|
126
|
+
if (!d.get(e)) throw new Error(`Model type ${e} not defined`);
|
|
127
|
+
const a = s.id ?? crypto.randomUUID(), c = { id: a, type: e, ...s };
|
|
128
|
+
if (o.kebabCase) {
|
|
129
|
+
const w = { id: a, type: e };
|
|
130
|
+
for (const [f, m] of Object.entries(s))
|
|
131
|
+
f !== "id" && m !== void 0 && (w[u(f)] = m);
|
|
132
|
+
return w;
|
|
122
133
|
}
|
|
123
134
|
return c;
|
|
124
135
|
}
|
|
125
|
-
function g(e,
|
|
126
|
-
function l(
|
|
127
|
-
return
|
|
128
|
-
id:
|
|
129
|
-
...
|
|
136
|
+
function g(e, s) {
|
|
137
|
+
function l(i) {
|
|
138
|
+
return y(i.type, {
|
|
139
|
+
id: i.id,
|
|
140
|
+
...i.attributes
|
|
130
141
|
});
|
|
131
142
|
}
|
|
132
|
-
function
|
|
133
|
-
|
|
143
|
+
function a(i, h) {
|
|
144
|
+
i.has(h.type) || i.set(h.type, /* @__PURE__ */ new Map()), i.get(h.type)?.set(h.id, h);
|
|
134
145
|
}
|
|
135
|
-
function c(
|
|
146
|
+
function c(i, h) {
|
|
136
147
|
if (h.id === void 0) throw new Error("Resource identifier must have an id");
|
|
137
|
-
return
|
|
148
|
+
return i.has(h.type) || i.set(h.type, /* @__PURE__ */ new Map()), i.get(h.type)?.get(h.id);
|
|
138
149
|
}
|
|
139
|
-
const
|
|
140
|
-
if (
|
|
141
|
-
const
|
|
142
|
-
for (const
|
|
143
|
-
function
|
|
144
|
-
const h = c(m,
|
|
150
|
+
const w = /* @__PURE__ */ new Map();
|
|
151
|
+
if (s) for (const i of s) a(w, l(i));
|
|
152
|
+
const f = e.map(l), m = /* @__PURE__ */ new Map();
|
|
153
|
+
for (const i of f) a(m, i);
|
|
154
|
+
function D(i) {
|
|
155
|
+
const h = c(m, i) ?? c(w, i);
|
|
145
156
|
if (!h) throw new Error("Unexpected not found record");
|
|
146
|
-
if (!
|
|
147
|
-
const R =
|
|
157
|
+
if (!i.relationships) return;
|
|
158
|
+
const R = r.get(i.type);
|
|
148
159
|
if (R)
|
|
149
|
-
for (const [
|
|
150
|
-
const
|
|
151
|
-
if (!
|
|
152
|
-
const z = (
|
|
153
|
-
|
|
160
|
+
for (const [E, $] of Object.entries(i.relationships)) {
|
|
161
|
+
const k = u(E), M = R[k];
|
|
162
|
+
if (!M || !$.data) continue;
|
|
163
|
+
const z = (M.relationshipType === 0 ? $.data : [$.data]).filter((v) => v && v.type === M.type).map((v) => c(w, v) || c(m, v)).filter(Boolean);
|
|
164
|
+
x(
|
|
154
165
|
h,
|
|
155
|
-
|
|
156
|
-
|
|
166
|
+
k,
|
|
167
|
+
M.relationshipType === 0 ? z : z[0]
|
|
157
168
|
);
|
|
158
169
|
}
|
|
159
170
|
}
|
|
160
|
-
if (
|
|
161
|
-
for (const
|
|
162
|
-
for (const
|
|
171
|
+
if (s) {
|
|
172
|
+
for (const i of e) D(i);
|
|
173
|
+
for (const i of s) D(i);
|
|
163
174
|
}
|
|
164
|
-
return
|
|
175
|
+
return f;
|
|
165
176
|
}
|
|
166
|
-
async function b(e,
|
|
167
|
-
const
|
|
168
|
-
return { doc:
|
|
177
|
+
async function b(e, s, l) {
|
|
178
|
+
const a = await n.fetchDocument(e, void 0, s, l), c = a.data, w = g(c, a.included);
|
|
179
|
+
return { doc: a, records: w };
|
|
169
180
|
}
|
|
170
|
-
async function
|
|
171
|
-
const c = await n.fetchDocument(e,
|
|
172
|
-
if (!m) throw new Error(`Record with id ${
|
|
181
|
+
async function j(e, s, l, a) {
|
|
182
|
+
const c = await n.fetchDocument(e, s, l, a), w = c.data, m = g([w], c.included)[0];
|
|
183
|
+
if (!m) throw new Error(`Record with id ${s} not found`);
|
|
173
184
|
return m;
|
|
174
185
|
}
|
|
175
|
-
async function
|
|
176
|
-
const c = e.type,
|
|
177
|
-
if (!
|
|
178
|
-
const
|
|
179
|
-
if (!
|
|
180
|
-
if (
|
|
181
|
-
const h = await n.fetchBelongsTo(c, e.id,
|
|
186
|
+
async function H(e, s, l, a) {
|
|
187
|
+
const c = e.type, w = r.get(c);
|
|
188
|
+
if (!w) throw new Error(`Model ${c} has no relationships`);
|
|
189
|
+
const f = w[s];
|
|
190
|
+
if (!f) throw new Error(`Relationship ${s} not defined`);
|
|
191
|
+
if (f.relationshipType === 1) {
|
|
192
|
+
const h = await n.fetchBelongsTo(c, e.id, s, l, a), R = h.data, E = y(f.type, {
|
|
182
193
|
id: R.id,
|
|
183
194
|
...R.attributes
|
|
184
195
|
});
|
|
185
|
-
return
|
|
196
|
+
return x(e, s, E), h;
|
|
186
197
|
}
|
|
187
|
-
const m = await n.fetchHasMany(c, e.id,
|
|
188
|
-
(h) =>
|
|
198
|
+
const m = await n.fetchHasMany(c, e.id, s, l, a), i = (f.relationshipType === 0 ? m.data : [m.data]).map(
|
|
199
|
+
(h) => y(f.type, {
|
|
189
200
|
id: h.id,
|
|
190
201
|
...h.attributes
|
|
191
202
|
})
|
|
192
203
|
);
|
|
193
|
-
return
|
|
204
|
+
return x(
|
|
194
205
|
e,
|
|
195
|
-
|
|
196
|
-
|
|
206
|
+
s,
|
|
207
|
+
f.relationshipType === 0 ? i : i[0]
|
|
197
208
|
), m;
|
|
198
209
|
}
|
|
199
|
-
async function
|
|
200
|
-
const l =
|
|
201
|
-
return g([
|
|
210
|
+
async function S(e, s) {
|
|
211
|
+
const l = p(e), a = await n.post(l, s);
|
|
212
|
+
return g([a.data])[0];
|
|
202
213
|
}
|
|
203
|
-
async function
|
|
204
|
-
const
|
|
205
|
-
"atomic:operations": e.map((
|
|
206
|
-
}, c = await n.postAtomic(
|
|
214
|
+
async function B(e, s) {
|
|
215
|
+
const a = {
|
|
216
|
+
"atomic:operations": e.map((f) => ({ op: f.op, data: p(f.data) }))
|
|
217
|
+
}, c = await n.postAtomic(a, s);
|
|
207
218
|
if (!c) return;
|
|
208
|
-
const
|
|
209
|
-
return { doc: c, records:
|
|
219
|
+
const w = c["atomic:results"] ? g(c["atomic:results"].map((f) => f.data)) : [];
|
|
220
|
+
return { doc: c, records: w };
|
|
210
221
|
}
|
|
211
222
|
return {
|
|
212
223
|
findAll: b,
|
|
213
|
-
findRecord:
|
|
214
|
-
findRelated:
|
|
215
|
-
createRecord:
|
|
216
|
-
saveRecord:
|
|
217
|
-
saveAtomic:
|
|
224
|
+
findRecord: j,
|
|
225
|
+
findRelated: H,
|
|
226
|
+
createRecord: y,
|
|
227
|
+
saveRecord: S,
|
|
228
|
+
saveAtomic: B
|
|
218
229
|
};
|
|
219
230
|
}
|
|
220
231
|
export {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
232
|
+
L as RelationshipType,
|
|
233
|
+
F as camel,
|
|
234
|
+
I as useJsonApi
|
|
224
235
|
};
|
|
225
236
|
//# sourceMappingURL=lib.js.map
|