@bjornharrtell/json-api 5.2.0 → 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 +171 -175
- 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,240 +1,236 @@
|
|
|
1
|
-
function
|
|
2
|
-
return new URL(
|
|
1
|
+
function O(...o) {
|
|
2
|
+
return new URL(o.join("/")).href;
|
|
3
3
|
}
|
|
4
|
-
class
|
|
5
|
-
constructor(t,
|
|
6
|
-
super(t), this.status =
|
|
4
|
+
class P extends Error {
|
|
5
|
+
constructor(t, n, d) {
|
|
6
|
+
super(t), this.status = n, this.body = d, this.name = "HttpError";
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
async function U(
|
|
10
|
-
if (n.ok) return;
|
|
11
|
-
let t = `HTTP error! status: ${n.status} ${n.statusText}`, e;
|
|
9
|
+
async function U(o) {
|
|
12
10
|
try {
|
|
13
|
-
|
|
14
|
-
const r = e.errors[0];
|
|
15
|
-
t += ` - ${r.title}: ${r.detail ?? ""}`;
|
|
16
|
-
}
|
|
11
|
+
return await o.json();
|
|
17
12
|
} catch {
|
|
18
13
|
}
|
|
19
|
-
throw new B(t, n.status, e);
|
|
20
14
|
}
|
|
21
|
-
async function
|
|
22
|
-
const { headers:
|
|
23
|
-
method:
|
|
24
|
-
headers:
|
|
25
|
-
signal:
|
|
26
|
-
body:
|
|
27
|
-
});
|
|
28
|
-
|
|
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,
|
|
18
|
+
headers: n,
|
|
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;
|
|
29
24
|
}
|
|
30
|
-
async function C(
|
|
31
|
-
const { signal:
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
method:
|
|
35
|
-
headers:
|
|
36
|
-
signal:
|
|
37
|
-
body:
|
|
38
|
-
});
|
|
39
|
-
|
|
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,
|
|
31
|
+
signal: n,
|
|
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;
|
|
40
36
|
}
|
|
41
|
-
class
|
|
37
|
+
class J {
|
|
42
38
|
constructor(t) {
|
|
43
39
|
this.endpoint = t;
|
|
44
40
|
}
|
|
45
|
-
createOptions(t = {},
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
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 };
|
|
49
45
|
if (t.fields)
|
|
50
|
-
for (const [
|
|
51
|
-
t.page?.size &&
|
|
52
|
-
for (const [
|
|
53
|
-
return
|
|
54
|
-
}
|
|
55
|
-
async fetchDocument(t,
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
return await
|
|
60
|
-
}
|
|
61
|
-
async fetchAll(t,
|
|
62
|
-
const
|
|
63
|
-
return (await
|
|
64
|
-
}
|
|
65
|
-
async fetchOne(t,
|
|
66
|
-
const
|
|
67
|
-
return (await
|
|
68
|
-
}
|
|
69
|
-
async fetchHasMany(t,
|
|
70
|
-
const
|
|
71
|
-
return await
|
|
72
|
-
}
|
|
73
|
-
async fetchBelongsTo(t,
|
|
74
|
-
const
|
|
75
|
-
return await
|
|
76
|
-
}
|
|
77
|
-
async post(t,
|
|
78
|
-
const
|
|
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;
|
|
50
|
+
}
|
|
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));
|
|
56
|
+
}
|
|
57
|
+
async fetchAll(t, n, d) {
|
|
58
|
+
const r = O(this.endpoint, t);
|
|
59
|
+
return (await T(r, this.createOptions(n, d))).data;
|
|
60
|
+
}
|
|
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;
|
|
64
|
+
}
|
|
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));
|
|
68
|
+
}
|
|
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));
|
|
72
|
+
}
|
|
73
|
+
async post(t, n) {
|
|
74
|
+
const d = O(this.endpoint, t.type), u = JSON.stringify({
|
|
79
75
|
data: t
|
|
80
|
-
}),
|
|
81
|
-
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);
|
|
82
78
|
}
|
|
83
|
-
async postAtomic(t,
|
|
84
|
-
const
|
|
85
|
-
return
|
|
79
|
+
async postAtomic(t, n = {}) {
|
|
80
|
+
const d = new URL([this.endpoint, "operations"].join("/")).href;
|
|
81
|
+
return n.body = JSON.stringify(t), await C(d, n);
|
|
86
82
|
}
|
|
87
83
|
}
|
|
88
|
-
function
|
|
89
|
-
return
|
|
84
|
+
function F(o) {
|
|
85
|
+
return o.replace(/[-][a-z\u00E0-\u00F6\u00F8-\u00FE]/g, (t) => t.slice(1).toUpperCase());
|
|
90
86
|
}
|
|
91
|
-
var L = /* @__PURE__ */ ((
|
|
92
|
-
function
|
|
93
|
-
|
|
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;
|
|
94
90
|
}
|
|
95
|
-
function A(
|
|
96
|
-
const t = { type:
|
|
97
|
-
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;
|
|
98
94
|
}
|
|
99
|
-
function I(
|
|
100
|
-
const
|
|
101
|
-
for (const
|
|
102
|
-
|
|
103
|
-
function
|
|
104
|
-
return
|
|
105
|
-
}
|
|
106
|
-
function
|
|
107
|
-
const s =
|
|
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);
|
|
108
104
|
l.attributes = {}, s && (l.relationships = {});
|
|
109
|
-
for (const [
|
|
110
|
-
if (!(
|
|
111
|
-
if (s &&
|
|
112
|
-
const
|
|
113
|
-
if (
|
|
114
|
-
const
|
|
115
|
-
l.relationships[
|
|
116
|
-
data:
|
|
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)
|
|
117
113
|
};
|
|
118
|
-
} else if (
|
|
119
|
-
const
|
|
120
|
-
l.relationships[
|
|
121
|
-
data: A(
|
|
114
|
+
} else if (w.relationshipType === 1) {
|
|
115
|
+
const f = c;
|
|
116
|
+
l.relationships[a] = {
|
|
117
|
+
data: A(f)
|
|
122
118
|
};
|
|
123
119
|
} else
|
|
124
|
-
throw new Error(`Unknown relationship type for ${
|
|
120
|
+
throw new Error(`Unknown relationship type for ${a}`);
|
|
125
121
|
} else
|
|
126
|
-
l.attributes[
|
|
122
|
+
l.attributes[a] = c;
|
|
127
123
|
return l;
|
|
128
124
|
}
|
|
129
|
-
function
|
|
130
|
-
if (!
|
|
131
|
-
const
|
|
132
|
-
if (
|
|
133
|
-
const
|
|
134
|
-
for (const [
|
|
135
|
-
|
|
136
|
-
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;
|
|
137
133
|
}
|
|
138
|
-
return
|
|
134
|
+
return c;
|
|
139
135
|
}
|
|
140
|
-
function g(
|
|
141
|
-
function l(
|
|
142
|
-
return
|
|
143
|
-
id:
|
|
144
|
-
...
|
|
136
|
+
function g(e, s) {
|
|
137
|
+
function l(i) {
|
|
138
|
+
return y(i.type, {
|
|
139
|
+
id: i.id,
|
|
140
|
+
...i.attributes
|
|
145
141
|
});
|
|
146
142
|
}
|
|
147
|
-
function i
|
|
148
|
-
|
|
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);
|
|
149
145
|
}
|
|
150
|
-
function
|
|
146
|
+
function c(i, h) {
|
|
151
147
|
if (h.id === void 0) throw new Error("Resource identifier must have an id");
|
|
152
|
-
return
|
|
148
|
+
return i.has(h.type) || i.set(h.type, /* @__PURE__ */ new Map()), i.get(h.type)?.get(h.id);
|
|
153
149
|
}
|
|
154
|
-
const
|
|
155
|
-
if (s) for (const
|
|
156
|
-
const
|
|
157
|
-
for (const
|
|
158
|
-
function
|
|
159
|
-
const h =
|
|
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);
|
|
160
156
|
if (!h) throw new Error("Unexpected not found record");
|
|
161
|
-
if (!
|
|
162
|
-
const
|
|
163
|
-
if (
|
|
164
|
-
for (const [
|
|
165
|
-
const
|
|
166
|
-
if (!
|
|
167
|
-
const
|
|
168
|
-
|
|
157
|
+
if (!i.relationships) return;
|
|
158
|
+
const R = r.get(i.type);
|
|
159
|
+
if (R)
|
|
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(
|
|
169
165
|
h,
|
|
170
|
-
|
|
171
|
-
|
|
166
|
+
k,
|
|
167
|
+
M.relationshipType === 0 ? z : z[0]
|
|
172
168
|
);
|
|
173
169
|
}
|
|
174
170
|
}
|
|
175
171
|
if (s) {
|
|
176
|
-
for (const
|
|
177
|
-
for (const
|
|
172
|
+
for (const i of e) D(i);
|
|
173
|
+
for (const i of s) D(i);
|
|
178
174
|
}
|
|
179
|
-
return
|
|
175
|
+
return f;
|
|
180
176
|
}
|
|
181
|
-
async function
|
|
182
|
-
const
|
|
183
|
-
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 };
|
|
184
180
|
}
|
|
185
|
-
async function
|
|
186
|
-
const
|
|
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];
|
|
187
183
|
if (!m) throw new Error(`Record with id ${s} not found`);
|
|
188
184
|
return m;
|
|
189
185
|
}
|
|
190
|
-
async function
|
|
191
|
-
const
|
|
192
|
-
if (!
|
|
193
|
-
const
|
|
194
|
-
if (!
|
|
195
|
-
if (
|
|
196
|
-
const h = await
|
|
197
|
-
id:
|
|
198
|
-
...
|
|
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, {
|
|
193
|
+
id: R.id,
|
|
194
|
+
...R.attributes
|
|
199
195
|
});
|
|
200
|
-
return
|
|
196
|
+
return x(e, s, E), h;
|
|
201
197
|
}
|
|
202
|
-
const m = await
|
|
203
|
-
(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, {
|
|
204
200
|
id: h.id,
|
|
205
201
|
...h.attributes
|
|
206
202
|
})
|
|
207
203
|
);
|
|
208
|
-
return
|
|
209
|
-
|
|
204
|
+
return x(
|
|
205
|
+
e,
|
|
210
206
|
s,
|
|
211
|
-
|
|
207
|
+
f.relationshipType === 0 ? i : i[0]
|
|
212
208
|
), m;
|
|
213
209
|
}
|
|
214
|
-
async function
|
|
215
|
-
const l =
|
|
216
|
-
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];
|
|
217
213
|
}
|
|
218
|
-
async function
|
|
219
|
-
const
|
|
220
|
-
"atomic:operations":
|
|
221
|
-
},
|
|
222
|
-
if (!
|
|
223
|
-
const
|
|
224
|
-
return { doc:
|
|
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);
|
|
218
|
+
if (!c) return;
|
|
219
|
+
const w = c["atomic:results"] ? g(c["atomic:results"].map((f) => f.data)) : [];
|
|
220
|
+
return { doc: c, records: w };
|
|
225
221
|
}
|
|
226
222
|
return {
|
|
227
|
-
findAll:
|
|
228
|
-
findRecord:
|
|
229
|
-
findRelated:
|
|
230
|
-
createRecord:
|
|
231
|
-
saveRecord:
|
|
232
|
-
saveAtomic:
|
|
223
|
+
findAll: b,
|
|
224
|
+
findRecord: j,
|
|
225
|
+
findRelated: H,
|
|
226
|
+
createRecord: y,
|
|
227
|
+
saveRecord: S,
|
|
228
|
+
saveAtomic: B
|
|
233
229
|
};
|
|
234
230
|
}
|
|
235
231
|
export {
|
|
236
232
|
L as RelationshipType,
|
|
237
|
-
|
|
233
|
+
F as camel,
|
|
238
234
|
I as useJsonApi
|
|
239
235
|
};
|
|
240
236
|
//# sourceMappingURL=lib.js.map
|