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