musora-content-services 1.0.10 → 1.0.11

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/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.0.11](https://github.com/railroadmedia/musora-content-services/compare/v1.0.10...v1.0.11) (2024-08-12)
6
+
5
7
  ### [1.0.10](https://github.com/railroadmedia/musora-content-services/compare/v1.0.9...v1.0.10) (2024-08-12)
6
8
 
7
9
  ### [1.0.9](https://github.com/railroadmedia/musora-content-services/compare/v1.0.7...v1.0.9) (2024-08-12)
package/docs/global.html CHANGED
@@ -146,7 +146,7 @@
146
146
 
147
147
  <dt class="tag-source">Source:</dt>
148
148
  <dd class="tag-source"><ul class="dummy"><li>
149
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line463">line 463</a>
149
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line530">line 530</a>
150
150
  </li></ul></dd>
151
151
 
152
152
 
@@ -191,6 +191,20 @@
191
191
 
192
192
 
193
193
 
194
+ <h5 class="h5-examples">Example</h5>
195
+
196
+ <pre class="prettyprint"><code>fetchAll('drumeo', 'song', {
197
+ page: 2,
198
+ limit: 20,
199
+ searchTerm: 'jazz',
200
+ sort: '-popularity',
201
+ includedFields: ['difficulty,Intermediate'],
202
+ groupBy: 'artist'
203
+ })
204
+ .then(content => console.log(content))
205
+ .catch(error => console.error(error));</code></pre>
206
+
207
+
194
208
 
195
209
 
196
210
  <h5 class="h5-parameters">Parameters:</h5>
@@ -625,7 +639,7 @@ The filter options are dynamically generated based on the provided filters, styl
625
639
 
626
640
  <dt class="tag-source">Source:</dt>
627
641
  <dd class="tag-source"><ul class="dummy"><li>
628
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line607">line 607</a>
642
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line674">line 674</a>
629
643
  </li></ul></dd>
630
644
 
631
645
 
@@ -967,7 +981,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
967
981
 
968
982
  <dt class="tag-source">Source:</dt>
969
983
  <dd class="tag-source"><ul class="dummy"><li>
970
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line164">line 164</a>
984
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line195">line 195</a>
971
985
  </li></ul></dd>
972
986
 
973
987
 
@@ -1012,6 +1026,20 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
1012
1026
 
1013
1027
 
1014
1028
 
1029
+ <h5 class="h5-examples">Example</h5>
1030
+
1031
+ <pre class="prettyprint"><code>fetchAllSongs('drumeo', {
1032
+ page: 2,
1033
+ limit: 20,
1034
+ searchTerm: 'rock',
1035
+ sort: 'published_on',
1036
+ includedFields: ['difficulty', 'style'],
1037
+ groupBy: 'artist'
1038
+ })
1039
+ .then(result => console.log(result))
1040
+ .catch(error => console.error(error));</code></pre>
1041
+
1042
+
1015
1043
 
1016
1044
 
1017
1045
  <h5 class="h5-parameters">Parameters:</h5>
@@ -1419,7 +1447,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
1419
1447
 
1420
1448
  <dt class="tag-source">Source:</dt>
1421
1449
  <dd class="tag-source"><ul class="dummy"><li>
1422
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line59">line 59</a>
1450
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line72">line 72</a>
1423
1451
  </li></ul></dd>
1424
1452
 
1425
1453
 
@@ -1464,6 +1492,13 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
1464
1492
 
1465
1493
 
1466
1494
 
1495
+ <h5 class="h5-examples">Example</h5>
1496
+
1497
+ <pre class="prettyprint"><code>fetchArtists('drumeo')
1498
+ .then(artists => console.log(artists))
1499
+ .catch(error => console.error(error));</code></pre>
1500
+
1501
+
1467
1502
 
1468
1503
 
1469
1504
  <h5 class="h5-parameters">Parameters:</h5>
@@ -1534,7 +1569,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
1534
1569
 
1535
1570
 
1536
1571
  <div class="param-desc">
1537
- - The fetched artist data or null if not found.
1572
+ - A promise that resolves to an array of artist objects or null if not found.
1538
1573
  </div>
1539
1574
 
1540
1575
 
@@ -1577,7 +1612,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
1577
1612
 
1578
1613
  <dt class="tag-source">Source:</dt>
1579
1614
  <dd class="tag-source"><ul class="dummy"><li>
1580
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line414">line 414</a>
1615
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line463">line 463</a>
1581
1616
  </li></ul></dd>
1582
1617
 
1583
1618
 
@@ -1622,6 +1657,13 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
1622
1657
 
1623
1658
 
1624
1659
 
1660
+ <h5 class="h5-examples">Example</h5>
1661
+
1662
+ <pre class="prettyprint"><code>fetchByRailContentId('abc123')
1663
+ .then(content => console.log(content))
1664
+ .catch(error => console.error(error));</code></pre>
1665
+
1666
+
1625
1667
 
1626
1668
 
1627
1669
  <h5 class="h5-parameters">Parameters:</h5>
@@ -1692,7 +1734,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
1692
1734
 
1693
1735
 
1694
1736
  <div class="param-desc">
1695
- - The fetched content data or null if not found.
1737
+ - A promise that resolves to the content object or null if not found.
1696
1738
  </div>
1697
1739
 
1698
1740
 
@@ -1735,7 +1777,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
1735
1777
 
1736
1778
  <dt class="tag-source">Source:</dt>
1737
1779
  <dd class="tag-source"><ul class="dummy"><li>
1738
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line434">line 434</a>
1780
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line489">line 489</a>
1739
1781
  </li></ul></dd>
1740
1782
 
1741
1783
 
@@ -1780,6 +1822,13 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
1780
1822
 
1781
1823
 
1782
1824
 
1825
+ <h5 class="h5-examples">Example</h5>
1826
+
1827
+ <pre class="prettyprint"><code>fetchByRailContentIds(['abc123', 'def456', 'ghi789'])
1828
+ .then(contents => console.log(contents))
1829
+ .catch(error => console.error(error));</code></pre>
1830
+
1831
+
1783
1832
 
1784
1833
 
1785
1834
  <h5 class="h5-parameters">Parameters:</h5>
@@ -1850,7 +1899,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
1850
1899
 
1851
1900
 
1852
1901
  <div class="param-desc">
1853
- - The fetched content data or null if not found.
1902
+ - A promise that resolves to an array of content objects or null if not found.
1854
1903
  </div>
1855
1904
 
1856
1905
 
@@ -1893,7 +1942,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
1893
1942
 
1894
1943
  <dt class="tag-source">Source:</dt>
1895
1944
  <dd class="tag-source"><ul class="dummy"><li>
1896
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line649">line 649</a>
1945
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line716">line 716</a>
1897
1946
  </li></ul></dd>
1898
1947
 
1899
1948
 
@@ -2051,7 +2100,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
2051
2100
 
2052
2101
  <dt class="tag-source">Source:</dt>
2053
2102
  <dd class="tag-source"><ul class="dummy"><li>
2054
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line722">line 722</a>
2103
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line794">line 794</a>
2055
2104
  </li></ul></dd>
2056
2105
 
2057
2106
 
@@ -2096,6 +2145,13 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
2096
2145
 
2097
2146
 
2098
2147
 
2148
+ <h5 class="h5-examples">Example</h5>
2149
+
2150
+ <pre class="prettyprint"><code>fetchLessonContent('lesson123')
2151
+ .then(data => console.log(data))
2152
+ .catch(error => console.error(error));</code></pre>
2153
+
2154
+
2099
2155
 
2100
2156
 
2101
2157
  <h5 class="h5-parameters">Parameters:</h5>
@@ -2209,7 +2265,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
2209
2265
 
2210
2266
  <dt class="tag-source">Source:</dt>
2211
2267
  <dd class="tag-source"><ul class="dummy"><li>
2212
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line691">line 691</a>
2268
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line758">line 758</a>
2213
2269
  </li></ul></dd>
2214
2270
 
2215
2271
 
@@ -2367,7 +2423,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
2367
2423
 
2368
2424
  <dt class="tag-source">Source:</dt>
2369
2425
  <dd class="tag-source"><ul class="dummy"><li>
2370
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line670">line 670</a>
2426
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line737">line 737</a>
2371
2427
  </li></ul></dd>
2372
2428
 
2373
2429
 
@@ -2525,7 +2581,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
2525
2581
 
2526
2582
  <dt class="tag-source">Source:</dt>
2527
2583
  <dd class="tag-source"><ul class="dummy"><li>
2528
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line356">line 356</a>
2584
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line393">line 393</a>
2529
2585
  </li></ul></dd>
2530
2586
 
2531
2587
 
@@ -2683,7 +2739,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
2683
2739
 
2684
2740
  <dt class="tag-source">Source:</dt>
2685
2741
  <dd class="tag-source"><ul class="dummy"><li>
2686
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line701">line 701</a>
2742
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line768">line 768</a>
2687
2743
  </li></ul></dd>
2688
2744
 
2689
2745
 
@@ -2841,7 +2897,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
2841
2897
 
2842
2898
  <dt class="tag-source">Source:</dt>
2843
2899
  <dd class="tag-source"><ul class="dummy"><li>
2844
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line776">line 776</a>
2900
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line848">line 848</a>
2845
2901
  </li></ul></dd>
2846
2902
 
2847
2903
 
@@ -2999,7 +3055,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
2999
3055
 
3000
3056
  <dt class="tag-source">Source:</dt>
3001
3057
  <dd class="tag-source"><ul class="dummy"><li>
3002
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line797">line 797</a>
3058
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line874">line 874</a>
3003
3059
  </li></ul></dd>
3004
3060
 
3005
3061
 
@@ -3044,6 +3100,13 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
3044
3100
 
3045
3101
 
3046
3102
 
3103
+ <h5 class="h5-examples">Example</h5>
3104
+
3105
+ <pre class="prettyprint"><code>fetchPackChildren('pack123')
3106
+ .then(children => console.log(children))
3107
+ .catch(error => console.error(error));</code></pre>
3108
+
3109
+
3047
3110
 
3048
3111
 
3049
3112
  <h5 class="h5-parameters">Parameters:</h5>
@@ -3157,7 +3220,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
3157
3220
 
3158
3221
  <dt class="tag-source">Source:</dt>
3159
3222
  <dd class="tag-source"><ul class="dummy"><li>
3160
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line755">line 755</a>
3223
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line827">line 827</a>
3161
3224
  </li></ul></dd>
3162
3225
 
3163
3226
 
@@ -3339,7 +3402,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
3339
3402
 
3340
3403
  <dt class="tag-source">Source:</dt>
3341
3404
  <dd class="tag-source"><ul class="dummy"><li>
3342
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line84">line 84</a>
3405
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line103">line 103</a>
3343
3406
  </li></ul></dd>
3344
3407
 
3345
3408
 
@@ -3384,6 +3447,13 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
3384
3447
 
3385
3448
 
3386
3449
 
3450
+ <h5 class="h5-examples">Example</h5>
3451
+
3452
+ <pre class="prettyprint"><code>fetchRelatedSongs('drumeo', '12345')
3453
+ .then(relatedSongs => console.log(relatedSongs))
3454
+ .catch(error => console.error(error));</code></pre>
3455
+
3456
+
3387
3457
 
3388
3458
 
3389
3459
  <h5 class="h5-parameters">Parameters:</h5>
@@ -3478,7 +3548,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
3478
3548
 
3479
3549
 
3480
3550
  <div class="param-desc">
3481
- - The fetched related songs data or null if not found.
3551
+ - A promise that resolves to an array of related song objects or null if not found.
3482
3552
  </div>
3483
3553
 
3484
3554
 
@@ -3521,7 +3591,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
3521
3591
 
3522
3592
  <dt class="tag-source">Source:</dt>
3523
3593
  <dd class="tag-source"><ul class="dummy"><li>
3524
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line807">line 807</a>
3594
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line891">line 891</a>
3525
3595
  </li></ul></dd>
3526
3596
 
3527
3597
 
@@ -3566,6 +3636,14 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
3566
3636
 
3567
3637
 
3568
3638
 
3639
+ <h5 class="h5-examples">Example</h5>
3640
+
3641
+ <pre class="prettyprint"><code>const query = `*[_type == "song"]{title, artist->name}`;
3642
+ fetchSanity(query, true)
3643
+ .then(data => console.log(data))
3644
+ .catch(error => console.error(error));</code></pre>
3645
+
3646
+
3569
3647
 
3570
3648
 
3571
3649
  <h5 class="h5-parameters">Parameters:</h5>
@@ -3634,7 +3712,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
3634
3712
 
3635
3713
 
3636
3714
 
3637
- <td class="description last">Whether to return an array or single result</td>
3715
+ <td class="description last">Whether to return an array or a single result.</td>
3638
3716
  </tr>
3639
3717
 
3640
3718
 
@@ -3660,7 +3738,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
3660
3738
 
3661
3739
 
3662
3740
  <div class="param-desc">
3663
- - The first result from the query, or null if an error occurs or no results are found.
3741
+ - A promise that resolves to the fetched data or null if an error occurs or no results are found.
3664
3742
  </div>
3665
3743
 
3666
3744
 
@@ -3703,7 +3781,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
3703
3781
 
3704
3782
  <dt class="tag-source">Source:</dt>
3705
3783
  <dd class="tag-source"><ul class="dummy"><li>
3706
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line73">line 73</a>
3784
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line86">line 86</a>
3707
3785
  </li></ul></dd>
3708
3786
 
3709
3787
 
@@ -3861,7 +3939,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
3861
3939
 
3862
3940
  <dt class="tag-source">Source:</dt>
3863
3941
  <dd class="tag-source"><ul class="dummy"><li>
3864
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line34">line 34</a>
3942
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line41">line 41</a>
3865
3943
  </li></ul></dd>
3866
3944
 
3867
3945
 
@@ -3906,6 +3984,13 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
3906
3984
 
3907
3985
 
3908
3986
 
3987
+ <h5 class="h5-examples">Example</h5>
3988
+
3989
+ <pre class="prettyprint"><code>fetchSongById('abc123')
3990
+ .then(song => console.log(song))
3991
+ .catch(error => console.error(error));</code></pre>
3992
+
3993
+
3909
3994
 
3910
3995
 
3911
3996
  <h5 class="h5-parameters">Parameters:</h5>
@@ -3976,7 +4061,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
3976
4061
 
3977
4062
 
3978
4063
  <div class="param-desc">
3979
- - The fetched song data or null if not found.
4064
+ - A promise that resolves to an object containing the song data or null if not found.
3980
4065
  </div>
3981
4066
 
3982
4067
 
@@ -4019,7 +4104,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
4019
4104
 
4020
4105
  <dt class="tag-source">Source:</dt>
4021
4106
  <dd class="tag-source"><ul class="dummy"><li>
4022
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line326">line 326</a>
4107
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line363">line 363</a>
4023
4108
  </li></ul></dd>
4024
4109
 
4025
4110
 
@@ -4177,7 +4262,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
4177
4262
 
4178
4263
  <dt class="tag-source">Source:</dt>
4179
4264
  <dd class="tag-source"><ul class="dummy"><li>
4180
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line297">line 297</a>
4265
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line334">line 334</a>
4181
4266
  </li></ul></dd>
4182
4267
 
4183
4268
 
@@ -4222,6 +4307,13 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
4222
4307
 
4223
4308
 
4224
4309
 
4310
+ <h5 class="h5-examples">Example</h5>
4311
+
4312
+ <pre class="prettyprint"><code>fetchSongFilterOptions('drumeo')
4313
+ .then(options => console.log(options))
4314
+ .catch(error => console.error(error));</code></pre>
4315
+
4316
+
4225
4317
 
4226
4318
 
4227
4319
  <h5 class="h5-parameters">Parameters:</h5>
@@ -4292,7 +4384,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
4292
4384
 
4293
4385
 
4294
4386
  <div class="param-desc">
4295
- - The fetched filter options or null if not found.
4387
+ - A promise that resolves to an object containing filter options or null if not found.
4296
4388
  </div>
4297
4389
 
4298
4390
 
@@ -4335,7 +4427,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
4335
4427
 
4336
4428
  <dt class="tag-source">Source:</dt>
4337
4429
  <dd class="tag-source"><ul class="dummy"><li>
4338
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line384">line 384</a>
4430
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line427">line 427</a>
4339
4431
  </li></ul></dd>
4340
4432
 
4341
4433
 
@@ -4380,6 +4472,13 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
4380
4472
 
4381
4473
 
4382
4474
 
4475
+ <h5 class="h5-examples">Example</h5>
4476
+
4477
+ <pre class="prettyprint"><code>fetchUpcomingEvents('drumeo')
4478
+ .then(events => console.log(events))
4479
+ .catch(error => console.error(error));</code></pre>
4480
+
4481
+
4383
4482
 
4384
4483
 
4385
4484
  <h5 class="h5-parameters">Parameters:</h5>
@@ -4450,7 +4549,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
4450
4549
 
4451
4550
 
4452
4551
  <div class="param-desc">
4453
- - The fetched upcoming events data or null if not found.
4552
+ - A promise that resolves to an array of upcoming event objects or null if not found.
4454
4553
  </div>
4455
4554
 
4456
4555
 
@@ -4493,7 +4592,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
4493
4592
 
4494
4593
  <dt class="tag-source">Source:</dt>
4495
4594
  <dd class="tag-source"><ul class="dummy"><li>
4496
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line336">line 336</a>
4595
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line373">line 373</a>
4497
4596
  </li></ul></dd>
4498
4597
 
4499
4598
 
@@ -4652,7 +4751,7 @@ This function must be called before using any other functions in this library.</
4652
4751
 
4653
4752
  <dt class="tag-source">Source:</dt>
4654
4753
  <dd class="tag-source"><ul class="dummy"><li>
4655
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line25">line 25</a>
4754
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line26">line 26</a>
4656
4755
  </li></ul></dd>
4657
4756
 
4658
4757
 
@@ -4705,7 +4804,7 @@ initializeSanityService({
4705
4804
  projectId: 'your-sanity-project-id',
4706
4805
  dataset: 'your-dataset-name',
4707
4806
  version: '2021-06-07',
4708
- debug: true // Optional: Enable debug mode
4807
+ debug: true, // Optional: Enable debug mode
4709
4808
  useCachedAPI: true // Optional: Use cached API
4710
4809
  });</code></pre>
4711
4810
 
@@ -5001,7 +5100,7 @@ initializeSanityService({
5001
5100
  </td>
5002
5101
 
5003
5102
 
5004
- <td class="description last">Optional flag to disable cached API. *</td>
5103
+ <td class="description last">Optional flag to disable cached API.</td>
5005
5104
  </tr>
5006
5105
 
5007
5106
 
@@ -5053,7 +5152,7 @@ initializeSanityService({
5053
5152
  <br class="clear">
5054
5153
 
5055
5154
  <footer>
5056
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Mon Aug 12 2024 14:00:38 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
5155
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Mon Aug 12 2024 15:31:44 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
5057
5156
  </footer>
5058
5157
 
5059
5158
  <script>prettyPrint();</script>
package/docs/index.html CHANGED
@@ -103,7 +103,7 @@ Run the following to execute the tests</p>
103
103
  <br class="clear">
104
104
 
105
105
  <footer>
106
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Mon Aug 12 2024 14:00:38 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
106
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Mon Aug 12 2024 15:31:44 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
107
107
  </footer>
108
108
 
109
109
  <script>prettyPrint();</script>
@@ -57,7 +57,8 @@
57
57
  * @param {string} config.dataset - The dataset name in Sanity.
58
58
  * @param {string} config.version - The API version to use.
59
59
  * @param {boolean} [config.debug=false] - Optional flag to enable debug mode, which logs the query and results.
60
- * @param {boolean} [config.useCachedAPI=true] - Optional flag to disable cached API. *
60
+ * @param {boolean} [config.useCachedAPI=true] - Optional flag to disable cached API.
61
+ *
61
62
  * @example
62
63
  * // Initialize the Sanity service in your app.js
63
64
  * initializeSanityService({
@@ -65,7 +66,7 @@
65
66
  * projectId: 'your-sanity-project-id',
66
67
  * dataset: 'your-dataset-name',
67
68
  * version: '2021-06-07',
68
- * debug: true // Optional: Enable debug mode
69
+ * debug: true, // Optional: Enable debug mode
69
70
  * useCachedAPI: true // Optional: Use cached API
70
71
  * });
71
72
  */
@@ -75,8 +76,14 @@ function initializeSanityService(config) {
75
76
 
76
77
  /**
77
78
  * Fetch a song by its document ID from Sanity.
79
+ *
78
80
  * @param {string} documentId - The ID of the document to fetch.
79
- * @returns {Promise&lt;Object|null>} - The fetched song data or null if not found.
81
+ * @returns {Promise&lt;Object|null>} - A promise that resolves to an object containing the song data or null if not found.
82
+ *
83
+ * @example
84
+ * fetchSongById('abc123')
85
+ * .then(song => console.log(song))
86
+ * .catch(error => console.error(error));
80
87
  */
81
88
  async function fetchSongById(documentId) {
82
89
  const fields = [
@@ -100,8 +107,14 @@ async function fetchSongById(documentId) {
100
107
 
101
108
  /**
102
109
  * Fetch all artists with lessons available for a specific brand.
110
+ *
103
111
  * @param {string} brand - The brand for which to fetch artists.
104
- * @returns {Promise&lt;Object|null>} - The fetched artist data or null if not found.
112
+ * @returns {Promise&lt;Object|null>} - A promise that resolves to an array of artist objects or null if not found.
113
+ *
114
+ * @example
115
+ * fetchArtists('drumeo')
116
+ * .then(artists => console.log(artists))
117
+ * .catch(error => console.error(error));
105
118
  */
106
119
  async function fetchArtists(brand) {
107
120
  const query = `
@@ -124,9 +137,15 @@ async function fetchSongArtistCount(brand) {
124
137
 
125
138
  /**
126
139
  * Fetch related songs for a specific brand and song ID.
140
+ *
127
141
  * @param {string} brand - The brand for which to fetch related songs.
128
142
  * @param {string} songId - The ID of the song to find related songs for.
129
- * @returns {Promise&lt;Object|null>} - The fetched related songs data or null if not found.
143
+ * @returns {Promise&lt;Object|null>} - A promise that resolves to an array of related song objects or null if not found.
144
+ *
145
+ * @example
146
+ * fetchRelatedSongs('drumeo', '12345')
147
+ * .then(relatedSongs => console.log(relatedSongs))
148
+ * .catch(error => console.error(error));
130
149
  */
131
150
  async function fetchRelatedSongs(brand, songId) {
132
151
  const query = `
@@ -207,6 +226,18 @@ async function fetchRelatedSongs(brand, songId) {
207
226
  * @param {Array&lt;string>} [params.includedFields=[]] - The fields to include in the query.
208
227
  * @param {string} [params.groupBy=""] - The field to group the results by.
209
228
  * @returns {Promise&lt;Object|null>} - The fetched song data or null if not found.
229
+ *
230
+ * @example
231
+ * fetchAllSongs('drumeo', {
232
+ * page: 2,
233
+ * limit: 20,
234
+ * searchTerm: 'rock',
235
+ * sort: 'published_on',
236
+ * includedFields: ['difficulty', 'style'],
237
+ * groupBy: 'artist'
238
+ * })
239
+ * .then(result => console.log(result))
240
+ * .catch(error => console.error(error));
210
241
  */
211
242
  async function fetchAllSongs(brand, {
212
243
  page = 1,
@@ -338,8 +369,14 @@ async function fetchAllSongs(brand, {
338
369
 
339
370
  /**
340
371
  * Fetch filter options for a specific brand.
372
+ *
341
373
  * @param {string} brand - The brand for which to fetch filter options.
342
- * @returns {Promise&lt;Object|null>} - The fetched filter options or null if not found.
374
+ * @returns {Promise&lt;Object|null>} - A promise that resolves to an object containing filter options or null if not found.
375
+ *
376
+ * @example
377
+ * fetchSongFilterOptions('drumeo')
378
+ * .then(options => console.log(options))
379
+ * .catch(error => console.error(error));
343
380
  */
344
381
  async function fetchSongFilterOptions(brand) {
345
382
  const query = `
@@ -425,8 +462,14 @@ async function fetchNewReleases(brand) {
425
462
 
426
463
  /**
427
464
  * Fetch upcoming events for a specific brand.
465
+ *
428
466
  * @param {string} brand - The brand for which to fetch upcoming events.
429
- * @returns {Promise&lt;Object|null>} - The fetched upcoming events data or null if not found.
467
+ * @returns {Promise&lt;Object|null>} - A promise that resolves to an array of upcoming event objects or null if not found.
468
+ *
469
+ * @example
470
+ * fetchUpcomingEvents('drumeo')
471
+ * .then(events => console.log(events))
472
+ * .catch(error => console.error(error));
430
473
  */
431
474
  async function fetchUpcomingEvents(brand) {
432
475
  const liveTypes = {
@@ -455,8 +498,14 @@ async function fetchUpcomingEvents(brand) {
455
498
 
456
499
  /**
457
500
  * Fetch content by a specific Railcontent ID.
501
+ *
458
502
  * @param {string} id - The Railcontent ID of the content to fetch.
459
- * @returns {Promise&lt;Object|null>} - The fetched content data or null if not found.
503
+ * @returns {Promise&lt;Object|null>} - A promise that resolves to the content object or null if not found.
504
+ *
505
+ * @example
506
+ * fetchByRailContentId('abc123')
507
+ * .then(content => console.log(content))
508
+ * .catch(error => console.error(error));
460
509
  */
461
510
  async function fetchByRailContentId(id) {
462
511
  const query = `*[railcontent_id == ${id}]{
@@ -475,8 +524,14 @@ async function fetchByRailContentId(id) {
475
524
 
476
525
  /**
477
526
  * Fetch content by an array of Railcontent IDs.
527
+ *
478
528
  * @param {Array&lt;string>} ids - The array of Railcontent IDs of the content to fetch.
479
- * @returns {Promise&lt;Array&lt;Object>|null>} - The fetched content data or null if not found.
529
+ * @returns {Promise&lt;Array&lt;Object>|null>} - A promise that resolves to an array of content objects or null if not found.
530
+ *
531
+ * @example
532
+ * fetchByRailContentIds(['abc123', 'def456', 'ghi789'])
533
+ * .then(contents => console.log(contents))
534
+ * .catch(error => console.error(error));
480
535
  */
481
536
  async function fetchByRailContentIds(ids) {
482
537
  const idsString = ids.join(',');
@@ -506,6 +561,18 @@ async function fetchByRailContentIds(ids) {
506
561
  * @param {Array&lt;string>} [params.includedFields=[]] - The fields to include in the query.
507
562
  * @param {string} [params.groupBy=""] - The field to group the results by (e.g., 'artist', 'genre').
508
563
  * @returns {Promise&lt;Object|null>} - The fetched content data or null if not found.
564
+ *
565
+ * @example
566
+ * fetchAll('drumeo', 'song', {
567
+ * page: 2,
568
+ * limit: 20,
569
+ * searchTerm: 'jazz',
570
+ * sort: '-popularity',
571
+ * includedFields: ['difficulty,Intermediate'],
572
+ * groupBy: 'artist'
573
+ * })
574
+ * .then(content => console.log(content))
575
+ * .catch(error => console.error(error));
509
576
  */
510
577
  async function fetchAll(brand, type, {
511
578
  page = 1,
@@ -765,6 +832,11 @@ async function fetchNextPreviousLesson(railcontentId) {
765
832
  * Fetch the page data for a specific lesson by Railcontent ID.
766
833
  * @param {string} railContentId - The Railcontent ID of the current lesson.
767
834
  * @returns {Promise&lt;Object|null>} - The fetched page data or null if found.
835
+ *
836
+ * @example
837
+ * fetchLessonContent('lesson123')
838
+ * .then(data => console.log(data))
839
+ * .catch(error => console.error(error));
768
840
  */
769
841
  async function fetchLessonContent(railContentId) {
770
842
  const query = `*[railcontent_id == ${railContentId} ]
@@ -840,6 +912,11 @@ async function fetchPackAll(railcontentId) {
840
912
  * Fetch all children of a specific pack by Railcontent ID.
841
913
  * @param {string} railcontentId - The Railcontent ID of the pack.
842
914
  * @returns {Promise&lt;Array&lt;Object>|null>} - The fetched pack children data or null if not found.
915
+ *
916
+ * @example
917
+ * fetchPackChildren('pack123')
918
+ * .then(children => console.log(children))
919
+ * .catch(error => console.error(error));
843
920
  */
844
921
  async function fetchPackChildren(railcontentId) {
845
922
  return fetchChildren(railcontentId, 'pack');
@@ -847,43 +924,50 @@ async function fetchPackChildren(railcontentId) {
847
924
 
848
925
  /**
849
926
  * Fetch data from the Sanity API based on a provided query.
927
+ *
850
928
  * @param {string} query - The GROQ query to execute against the Sanity API.
851
- * @param {boolean} isList - Whether to return an array or single result
852
- * @returns {Promise&lt;Object|null>} - The first result from the query, or null if an error occurs or no results are found.
929
+ * @param {boolean} isList - Whether to return an array or a single result.
930
+ * @returns {Promise&lt;Object|null>} - A promise that resolves to the fetched data or null if an error occurs or no results are found.
931
+ *
932
+ * @example
933
+ * const query = `*[_type == "song"]{title, artist->name}`;
934
+ * fetchSanity(query, true)
935
+ * .then(data => console.log(data))
936
+ * .catch(error => console.error(error));
853
937
  */
854
938
  async function fetchSanity(query, isList) {
855
- // Check the config object before proceeding
856
- if (!checkConfig(globalConfig)) {
857
- return null;
858
- }
859
-
860
- if (globalConfig.debug) {
861
- console.log("fetchSanity Query:", query);
862
- }
863
-
864
- const encodedQuery = encodeURIComponent(query);
865
- const api = globalConfig.useCachedAPI ? 'apicdn' : 'api'
866
- const url = `https://${globalConfig.projectId}.${api}.sanity.io/v${globalConfig.version}/data/query/${globalConfig.dataset}?query=${encodedQuery}`;
867
- const headers = {
868
- 'Authorization': `Bearer ${globalConfig.token}`,
869
- 'Content-Type': 'application/json'
870
- };
871
-
872
- try {
873
- const response = await fetch(url, {headers});
874
- const result = await response.json();
875
- if (result.result) {
876
- if (globalConfig.debug) {
877
- console.log("fetchSanity Results:", result);
878
- }
879
- return isList ? result.result : result.result[0];
880
- } else {
881
- throw new Error('No results found');
882
- }
883
- } catch (error) {
884
- console.error('fetchSanity: Fetch error:', error);
885
- return null;
886
- }
939
+ // Check the config object before proceeding
940
+ if (!checkConfig(globalConfig)) {
941
+ return null;
942
+ }
943
+
944
+ if (globalConfig.debug) {
945
+ console.log("fetchSanity Query:", query);
946
+ }
947
+
948
+ const encodedQuery = encodeURIComponent(query);
949
+ const api = globalConfig.useCachedAPI ? 'apicdn' : 'api'
950
+ const url = `https://${globalConfig.projectId}.${api}.sanity.io/v${globalConfig.version}/data/query/${globalConfig.dataset}?query=${encodedQuery}`;
951
+ const headers = {
952
+ 'Authorization': `Bearer ${globalConfig.token}`,
953
+ 'Content-Type': 'application/json'
954
+ };
955
+
956
+ try {
957
+ const response = await fetch(url, {headers});
958
+ const result = await response.json();
959
+ if (result.result) {
960
+ if (globalConfig.debug) {
961
+ console.log("fetchSanity Results:", result);
962
+ }
963
+ return isList ? result.result : result.result[0];
964
+ } else {
965
+ throw new Error('No results found');
966
+ }
967
+ } catch (error) {
968
+ console.error('fetchSanity: Fetch error:', error);
969
+ return null;
970
+ }
887
971
  }
888
972
 
889
973
 
@@ -958,7 +1042,7 @@ module.exports = {
958
1042
  <br class="clear">
959
1043
 
960
1044
  <footer>
961
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Mon Aug 12 2024 14:00:38 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1045
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Mon Aug 12 2024 15:31:44 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
962
1046
  </footer>
963
1047
 
964
1048
  <script>prettyPrint();</script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -10,7 +10,8 @@ let globalConfig = {};
10
10
  * @param {string} config.dataset - The dataset name in Sanity.
11
11
  * @param {string} config.version - The API version to use.
12
12
  * @param {boolean} [config.debug=false] - Optional flag to enable debug mode, which logs the query and results.
13
- * @param {boolean} [config.useCachedAPI=true] - Optional flag to disable cached API. *
13
+ * @param {boolean} [config.useCachedAPI=true] - Optional flag to disable cached API.
14
+ *
14
15
  * @example
15
16
  * // Initialize the Sanity service in your app.js
16
17
  * initializeSanityService({
@@ -18,7 +19,7 @@ let globalConfig = {};
18
19
  * projectId: 'your-sanity-project-id',
19
20
  * dataset: 'your-dataset-name',
20
21
  * version: '2021-06-07',
21
- * debug: true // Optional: Enable debug mode
22
+ * debug: true, // Optional: Enable debug mode
22
23
  * useCachedAPI: true // Optional: Use cached API
23
24
  * });
24
25
  */
@@ -28,8 +29,14 @@ function initializeSanityService(config) {
28
29
 
29
30
  /**
30
31
  * Fetch a song by its document ID from Sanity.
32
+ *
31
33
  * @param {string} documentId - The ID of the document to fetch.
32
- * @returns {Promise<Object|null>} - The fetched song data or null if not found.
34
+ * @returns {Promise<Object|null>} - A promise that resolves to an object containing the song data or null if not found.
35
+ *
36
+ * @example
37
+ * fetchSongById('abc123')
38
+ * .then(song => console.log(song))
39
+ * .catch(error => console.error(error));
33
40
  */
34
41
  async function fetchSongById(documentId) {
35
42
  const fields = [
@@ -53,8 +60,14 @@ async function fetchSongById(documentId) {
53
60
 
54
61
  /**
55
62
  * Fetch all artists with lessons available for a specific brand.
63
+ *
56
64
  * @param {string} brand - The brand for which to fetch artists.
57
- * @returns {Promise<Object|null>} - The fetched artist data or null if not found.
65
+ * @returns {Promise<Object|null>} - A promise that resolves to an array of artist objects or null if not found.
66
+ *
67
+ * @example
68
+ * fetchArtists('drumeo')
69
+ * .then(artists => console.log(artists))
70
+ * .catch(error => console.error(error));
58
71
  */
59
72
  async function fetchArtists(brand) {
60
73
  const query = `
@@ -77,9 +90,15 @@ async function fetchSongArtistCount(brand) {
77
90
 
78
91
  /**
79
92
  * Fetch related songs for a specific brand and song ID.
93
+ *
80
94
  * @param {string} brand - The brand for which to fetch related songs.
81
95
  * @param {string} songId - The ID of the song to find related songs for.
82
- * @returns {Promise<Object|null>} - The fetched related songs data or null if not found.
96
+ * @returns {Promise<Object|null>} - A promise that resolves to an array of related song objects or null if not found.
97
+ *
98
+ * @example
99
+ * fetchRelatedSongs('drumeo', '12345')
100
+ * .then(relatedSongs => console.log(relatedSongs))
101
+ * .catch(error => console.error(error));
83
102
  */
84
103
  async function fetchRelatedSongs(brand, songId) {
85
104
  const query = `
@@ -160,6 +179,18 @@ async function fetchRelatedSongs(brand, songId) {
160
179
  * @param {Array<string>} [params.includedFields=[]] - The fields to include in the query.
161
180
  * @param {string} [params.groupBy=""] - The field to group the results by.
162
181
  * @returns {Promise<Object|null>} - The fetched song data or null if not found.
182
+ *
183
+ * @example
184
+ * fetchAllSongs('drumeo', {
185
+ * page: 2,
186
+ * limit: 20,
187
+ * searchTerm: 'rock',
188
+ * sort: 'published_on',
189
+ * includedFields: ['difficulty', 'style'],
190
+ * groupBy: 'artist'
191
+ * })
192
+ * .then(result => console.log(result))
193
+ * .catch(error => console.error(error));
163
194
  */
164
195
  async function fetchAllSongs(brand, {
165
196
  page = 1,
@@ -291,8 +322,14 @@ async function fetchAllSongs(brand, {
291
322
 
292
323
  /**
293
324
  * Fetch filter options for a specific brand.
325
+ *
294
326
  * @param {string} brand - The brand for which to fetch filter options.
295
- * @returns {Promise<Object|null>} - The fetched filter options or null if not found.
327
+ * @returns {Promise<Object|null>} - A promise that resolves to an object containing filter options or null if not found.
328
+ *
329
+ * @example
330
+ * fetchSongFilterOptions('drumeo')
331
+ * .then(options => console.log(options))
332
+ * .catch(error => console.error(error));
296
333
  */
297
334
  async function fetchSongFilterOptions(brand) {
298
335
  const query = `
@@ -378,8 +415,14 @@ async function fetchNewReleases(brand) {
378
415
 
379
416
  /**
380
417
  * Fetch upcoming events for a specific brand.
418
+ *
381
419
  * @param {string} brand - The brand for which to fetch upcoming events.
382
- * @returns {Promise<Object|null>} - The fetched upcoming events data or null if not found.
420
+ * @returns {Promise<Object|null>} - A promise that resolves to an array of upcoming event objects or null if not found.
421
+ *
422
+ * @example
423
+ * fetchUpcomingEvents('drumeo')
424
+ * .then(events => console.log(events))
425
+ * .catch(error => console.error(error));
383
426
  */
384
427
  async function fetchUpcomingEvents(brand) {
385
428
  const liveTypes = {
@@ -408,8 +451,14 @@ async function fetchUpcomingEvents(brand) {
408
451
 
409
452
  /**
410
453
  * Fetch content by a specific Railcontent ID.
454
+ *
411
455
  * @param {string} id - The Railcontent ID of the content to fetch.
412
- * @returns {Promise<Object|null>} - The fetched content data or null if not found.
456
+ * @returns {Promise<Object|null>} - A promise that resolves to the content object or null if not found.
457
+ *
458
+ * @example
459
+ * fetchByRailContentId('abc123')
460
+ * .then(content => console.log(content))
461
+ * .catch(error => console.error(error));
413
462
  */
414
463
  async function fetchByRailContentId(id) {
415
464
  const query = `*[railcontent_id == ${id}]{
@@ -428,8 +477,14 @@ async function fetchByRailContentId(id) {
428
477
 
429
478
  /**
430
479
  * Fetch content by an array of Railcontent IDs.
480
+ *
431
481
  * @param {Array<string>} ids - The array of Railcontent IDs of the content to fetch.
432
- * @returns {Promise<Array<Object>|null>} - The fetched content data or null if not found.
482
+ * @returns {Promise<Array<Object>|null>} - A promise that resolves to an array of content objects or null if not found.
483
+ *
484
+ * @example
485
+ * fetchByRailContentIds(['abc123', 'def456', 'ghi789'])
486
+ * .then(contents => console.log(contents))
487
+ * .catch(error => console.error(error));
433
488
  */
434
489
  async function fetchByRailContentIds(ids) {
435
490
  const idsString = ids.join(',');
@@ -459,6 +514,18 @@ async function fetchByRailContentIds(ids) {
459
514
  * @param {Array<string>} [params.includedFields=[]] - The fields to include in the query.
460
515
  * @param {string} [params.groupBy=""] - The field to group the results by (e.g., 'artist', 'genre').
461
516
  * @returns {Promise<Object|null>} - The fetched content data or null if not found.
517
+ *
518
+ * @example
519
+ * fetchAll('drumeo', 'song', {
520
+ * page: 2,
521
+ * limit: 20,
522
+ * searchTerm: 'jazz',
523
+ * sort: '-popularity',
524
+ * includedFields: ['difficulty,Intermediate'],
525
+ * groupBy: 'artist'
526
+ * })
527
+ * .then(content => console.log(content))
528
+ * .catch(error => console.error(error));
462
529
  */
463
530
  async function fetchAll(brand, type, {
464
531
  page = 1,
@@ -718,6 +785,11 @@ async function fetchNextPreviousLesson(railcontentId) {
718
785
  * Fetch the page data for a specific lesson by Railcontent ID.
719
786
  * @param {string} railContentId - The Railcontent ID of the current lesson.
720
787
  * @returns {Promise<Object|null>} - The fetched page data or null if found.
788
+ *
789
+ * @example
790
+ * fetchLessonContent('lesson123')
791
+ * .then(data => console.log(data))
792
+ * .catch(error => console.error(error));
721
793
  */
722
794
  async function fetchLessonContent(railContentId) {
723
795
  const query = `*[railcontent_id == ${railContentId} ]
@@ -793,6 +865,11 @@ async function fetchPackAll(railcontentId) {
793
865
  * Fetch all children of a specific pack by Railcontent ID.
794
866
  * @param {string} railcontentId - The Railcontent ID of the pack.
795
867
  * @returns {Promise<Array<Object>|null>} - The fetched pack children data or null if not found.
868
+ *
869
+ * @example
870
+ * fetchPackChildren('pack123')
871
+ * .then(children => console.log(children))
872
+ * .catch(error => console.error(error));
796
873
  */
797
874
  async function fetchPackChildren(railcontentId) {
798
875
  return fetchChildren(railcontentId, 'pack');
@@ -800,43 +877,50 @@ async function fetchPackChildren(railcontentId) {
800
877
 
801
878
  /**
802
879
  * Fetch data from the Sanity API based on a provided query.
880
+ *
803
881
  * @param {string} query - The GROQ query to execute against the Sanity API.
804
- * @param {boolean} isList - Whether to return an array or single result
805
- * @returns {Promise<Object|null>} - The first result from the query, or null if an error occurs or no results are found.
882
+ * @param {boolean} isList - Whether to return an array or a single result.
883
+ * @returns {Promise<Object|null>} - A promise that resolves to the fetched data or null if an error occurs or no results are found.
884
+ *
885
+ * @example
886
+ * const query = `*[_type == "song"]{title, artist->name}`;
887
+ * fetchSanity(query, true)
888
+ * .then(data => console.log(data))
889
+ * .catch(error => console.error(error));
806
890
  */
807
891
  async function fetchSanity(query, isList) {
808
- // Check the config object before proceeding
809
- if (!checkConfig(globalConfig)) {
810
- return null;
811
- }
812
-
813
- if (globalConfig.debug) {
814
- console.log("fetchSanity Query:", query);
815
- }
816
-
817
- const encodedQuery = encodeURIComponent(query);
818
- const api = globalConfig.useCachedAPI ? 'apicdn' : 'api'
819
- const url = `https://${globalConfig.projectId}.${api}.sanity.io/v${globalConfig.version}/data/query/${globalConfig.dataset}?query=${encodedQuery}`;
820
- const headers = {
821
- 'Authorization': `Bearer ${globalConfig.token}`,
822
- 'Content-Type': 'application/json'
823
- };
824
-
825
- try {
826
- const response = await fetch(url, {headers});
827
- const result = await response.json();
828
- if (result.result) {
829
- if (globalConfig.debug) {
830
- console.log("fetchSanity Results:", result);
831
- }
832
- return isList ? result.result : result.result[0];
833
- } else {
834
- throw new Error('No results found');
835
- }
836
- } catch (error) {
837
- console.error('fetchSanity: Fetch error:', error);
838
- return null;
839
- }
892
+ // Check the config object before proceeding
893
+ if (!checkConfig(globalConfig)) {
894
+ return null;
895
+ }
896
+
897
+ if (globalConfig.debug) {
898
+ console.log("fetchSanity Query:", query);
899
+ }
900
+
901
+ const encodedQuery = encodeURIComponent(query);
902
+ const api = globalConfig.useCachedAPI ? 'apicdn' : 'api'
903
+ const url = `https://${globalConfig.projectId}.${api}.sanity.io/v${globalConfig.version}/data/query/${globalConfig.dataset}?query=${encodedQuery}`;
904
+ const headers = {
905
+ 'Authorization': `Bearer ${globalConfig.token}`,
906
+ 'Content-Type': 'application/json'
907
+ };
908
+
909
+ try {
910
+ const response = await fetch(url, {headers});
911
+ const result = await response.json();
912
+ if (result.result) {
913
+ if (globalConfig.debug) {
914
+ console.log("fetchSanity Results:", result);
915
+ }
916
+ return isList ? result.result : result.result[0];
917
+ } else {
918
+ throw new Error('No results found');
919
+ }
920
+ } catch (error) {
921
+ console.error('fetchSanity: Fetch error:', error);
922
+ return null;
923
+ }
840
924
  }
841
925
 
842
926