musora-content-services 1.0.11 → 1.0.13

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.
@@ -0,0 +1,39 @@
1
+ # This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2
+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
3
+
4
+ name: Node.js CI
5
+
6
+ on:
7
+ push:
8
+ branches: [ "main" ]
9
+ pull_request:
10
+ branches: [ "main" ]
11
+
12
+ jobs:
13
+ build:
14
+
15
+ runs-on: ubuntu-latest
16
+
17
+ strategy:
18
+ matrix:
19
+ node-version: [20.x]
20
+ # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
21
+
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+ - name: Use Node.js ${{ matrix.node-version }}
25
+ uses: actions/setup-node@v4
26
+ with:
27
+ node-version: ${{ matrix.node-version }}
28
+ cache: 'npm'
29
+ - run: npm ci
30
+ - run: npm run build --if-present
31
+ - name: 'Create env file'
32
+ run: |
33
+ touch .env
34
+ echo SANITY_API_TOKEN=${{ secrets.SANITY_API_TOKEN }} >> .env
35
+ echo SANITY_PROJECT_ID=4032r8py >> .env
36
+ echo SANITY_DATASET=staging >> .env
37
+ echo SANITY_USE_CACHED_API=false >> .env
38
+ cat .env
39
+ - run: npm test
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
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.13](https://github.com/railroadmedia/musora-content-services/compare/v1.0.12...v1.0.13) (2024-08-13)
6
+
7
+ ### [1.0.12](https://github.com/railroadmedia/musora-content-services/compare/v1.0.11...v1.0.12) (2024-08-12)
8
+
5
9
  ### [1.0.11](https://github.com/railroadmedia/musora-content-services/compare/v1.0.10...v1.0.11) (2024-08-12)
6
10
 
7
11
  ### [1.0.10](https://github.com/railroadmedia/musora-content-services/compare/v1.0.9...v1.0.10) (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#line530">line 530</a>
149
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line536">line 536</a>
150
150
  </li></ul></dd>
151
151
 
152
152
 
@@ -639,7 +639,7 @@ The filter options are dynamically generated based on the provided filters, styl
639
639
 
640
640
  <dt class="tag-source">Source:</dt>
641
641
  <dd class="tag-source"><ul class="dummy"><li>
642
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line674">line 674</a>
642
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line680">line 680</a>
643
643
  </li></ul></dd>
644
644
 
645
645
 
@@ -1612,7 +1612,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
1612
1612
 
1613
1613
  <dt class="tag-source">Source:</dt>
1614
1614
  <dd class="tag-source"><ul class="dummy"><li>
1615
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line463">line 463</a>
1615
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line469">line 469</a>
1616
1616
  </li></ul></dd>
1617
1617
 
1618
1618
 
@@ -1777,7 +1777,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
1777
1777
 
1778
1778
  <dt class="tag-source">Source:</dt>
1779
1779
  <dd class="tag-source"><ul class="dummy"><li>
1780
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line489">line 489</a>
1780
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line495">line 495</a>
1781
1781
  </li></ul></dd>
1782
1782
 
1783
1783
 
@@ -1942,7 +1942,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
1942
1942
 
1943
1943
  <dt class="tag-source">Source:</dt>
1944
1944
  <dd class="tag-source"><ul class="dummy"><li>
1945
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line716">line 716</a>
1945
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line722">line 722</a>
1946
1946
  </li></ul></dd>
1947
1947
 
1948
1948
 
@@ -2100,7 +2100,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
2100
2100
 
2101
2101
  <dt class="tag-source">Source:</dt>
2102
2102
  <dd class="tag-source"><ul class="dummy"><li>
2103
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line794">line 794</a>
2103
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line800">line 800</a>
2104
2104
  </li></ul></dd>
2105
2105
 
2106
2106
 
@@ -2265,7 +2265,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
2265
2265
 
2266
2266
  <dt class="tag-source">Source:</dt>
2267
2267
  <dd class="tag-source"><ul class="dummy"><li>
2268
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line758">line 758</a>
2268
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line764">line 764</a>
2269
2269
  </li></ul></dd>
2270
2270
 
2271
2271
 
@@ -2423,7 +2423,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
2423
2423
 
2424
2424
  <dt class="tag-source">Source:</dt>
2425
2425
  <dd class="tag-source"><ul class="dummy"><li>
2426
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line737">line 737</a>
2426
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line743">line 743</a>
2427
2427
  </li></ul></dd>
2428
2428
 
2429
2429
 
@@ -2581,7 +2581,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
2581
2581
 
2582
2582
  <dt class="tag-source">Source:</dt>
2583
2583
  <dd class="tag-source"><ul class="dummy"><li>
2584
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line393">line 393</a>
2584
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line399">line 399</a>
2585
2585
  </li></ul></dd>
2586
2586
 
2587
2587
 
@@ -2739,7 +2739,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
2739
2739
 
2740
2740
  <dt class="tag-source">Source:</dt>
2741
2741
  <dd class="tag-source"><ul class="dummy"><li>
2742
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line768">line 768</a>
2742
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line774">line 774</a>
2743
2743
  </li></ul></dd>
2744
2744
 
2745
2745
 
@@ -2897,7 +2897,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
2897
2897
 
2898
2898
  <dt class="tag-source">Source:</dt>
2899
2899
  <dd class="tag-source"><ul class="dummy"><li>
2900
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line848">line 848</a>
2900
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line854">line 854</a>
2901
2901
  </li></ul></dd>
2902
2902
 
2903
2903
 
@@ -3055,7 +3055,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
3055
3055
 
3056
3056
  <dt class="tag-source">Source:</dt>
3057
3057
  <dd class="tag-source"><ul class="dummy"><li>
3058
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line874">line 874</a>
3058
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line880">line 880</a>
3059
3059
  </li></ul></dd>
3060
3060
 
3061
3061
 
@@ -3220,7 +3220,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
3220
3220
 
3221
3221
  <dt class="tag-source">Source:</dt>
3222
3222
  <dd class="tag-source"><ul class="dummy"><li>
3223
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line827">line 827</a>
3223
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line833">line 833</a>
3224
3224
  </li></ul></dd>
3225
3225
 
3226
3226
 
@@ -3591,7 +3591,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'song', 'Love')
3591
3591
 
3592
3592
  <dt class="tag-source">Source:</dt>
3593
3593
  <dd class="tag-source"><ul class="dummy"><li>
3594
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line891">line 891</a>
3594
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line897">line 897</a>
3595
3595
  </li></ul></dd>
3596
3596
 
3597
3597
 
@@ -4427,7 +4427,7 @@ fetchSanity(query, true)
4427
4427
 
4428
4428
  <dt class="tag-source">Source:</dt>
4429
4429
  <dd class="tag-source"><ul class="dummy"><li>
4430
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line427">line 427</a>
4430
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line433">line 433</a>
4431
4431
  </li></ul></dd>
4432
4432
 
4433
4433
 
@@ -4576,7 +4576,7 @@ fetchSanity(query, true)
4576
4576
 
4577
4577
 
4578
4578
 
4579
- <h4 class="name" id="fetchWorkouts"><span class="type-signature type-signature-async">(async) </span>fetchWorkouts<span class="signature">(brand)</span><span class="type-signature"> &rarr; {Promise.&lt;(Object|null)>}</span></h4>
4579
+ <h4 class="name" id="fetchWorkouts"><span class="type-signature type-signature-async">(async) </span>fetchWorkouts<span class="signature">(brand)</span><span class="type-signature"> &rarr; {Promise.&lt;(Array.&lt;Object>|null)>}</span></h4>
4580
4580
 
4581
4581
 
4582
4582
 
@@ -4586,13 +4586,14 @@ fetchSanity(query, true)
4586
4586
  <dl class="details">
4587
4587
 
4588
4588
  <dt class="tag-description">Description:</dt>
4589
- <dd class="tag-description"><ul class="dummy"><li>Fetch the latest workouts for the home page of a specific brand.</li></ul></dd>
4589
+ <dd class="tag-description"><ul class="dummy"><li>Fetch the latest workouts for the home page of a specific brand.
4590
+ This function retrieves the latest workout content for a given brand, fetching up to five workouts. The workouts are sorted in descending order by their publication date.</li></ul></dd>
4590
4591
 
4591
4592
 
4592
4593
 
4593
4594
  <dt class="tag-source">Source:</dt>
4594
4595
  <dd class="tag-source"><ul class="dummy"><li>
4595
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line373">line 373</a>
4596
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line379">line 379</a>
4596
4597
  </li></ul></dd>
4597
4598
 
4598
4599
 
@@ -4637,6 +4638,13 @@ fetchSanity(query, true)
4637
4638
 
4638
4639
 
4639
4640
 
4641
+ <h5 class="h5-examples">Example</h5>
4642
+
4643
+ <pre class="prettyprint"><code>fetchWorkouts('drumeo')
4644
+ .then(workouts => console.log(workouts))
4645
+ .catch(error => console.error(error));</code></pre>
4646
+
4647
+
4640
4648
 
4641
4649
 
4642
4650
  <h5 class="h5-parameters">Parameters:</h5>
@@ -4681,7 +4689,7 @@ fetchSanity(query, true)
4681
4689
 
4682
4690
 
4683
4691
 
4684
- <td class="description last">The brand for which to fetch workouts.</td>
4692
+ <td class="description last">The brand for which to fetch workouts (e.g., 'drumeo', 'pianote').</td>
4685
4693
  </tr>
4686
4694
 
4687
4695
 
@@ -4707,7 +4715,7 @@ fetchSanity(query, true)
4707
4715
 
4708
4716
 
4709
4717
  <div class="param-desc">
4710
- - The fetched workout data or null if not found.
4718
+ - A promise that resolves to an array of workout data objects or null if no workouts are found.
4711
4719
  </div>
4712
4720
 
4713
4721
 
@@ -4718,7 +4726,7 @@ fetchSanity(query, true)
4718
4726
  </dt>
4719
4727
  <dd>
4720
4728
 
4721
- <span class="param-type">Promise.&lt;(Object|null)></span>
4729
+ <span class="param-type">Promise.&lt;(Array.&lt;Object>|null)></span>
4722
4730
 
4723
4731
 
4724
4732
 
@@ -5152,7 +5160,7 @@ initializeSanityService({
5152
5160
  <br class="clear">
5153
5161
 
5154
5162
  <footer>
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.
5163
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Tue Aug 13 2024 02:40:03 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
5156
5164
  </footer>
5157
5165
 
5158
5166
  <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 15:31:44 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 Tue Aug 13 2024 02:40:03 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>
@@ -132,7 +132,7 @@ async function fetchArtists(brand) {
132
132
  */
133
133
  async function fetchSongArtistCount(brand) {
134
134
  const query = `count(*[_type == 'artist']{'lessonsCount': count(*[_type == 'song' &amp;&amp; brand == '${brand}' &amp;&amp; references(^._id)]._id)}[lessonsCount > 0])`;
135
- return fetchSanity(query, false);
135
+ return fetchSanity(query, true);
136
136
  }
137
137
 
138
138
  /**
@@ -304,21 +304,21 @@ async function fetchAllSongs(brand, {
304
304
  'head_shot_picture_url': thumbnail_url.asset->url,
305
305
  'all_lessons_count': count(*[_type == 'song' &amp;&amp; brand == '${brand}' &amp;&amp; ^._id == artist._ref ]._id),
306
306
  'lessons': *[_type == 'song' &amp;&amp; brand == '${brand}' &amp;&amp; ^._id == artist._ref ]{
307
- railcontent_id,
307
+ "id": railcontent_id,
308
+ "type": _type,
308
309
  title,
309
- "image": thumbnail.asset->url,
310
+ "thumbnail_url": thumbnail.asset->url,
310
311
  "artist_name": artist->name,
311
- artist,
312
- difficulty,
313
312
  difficulty_string,
314
- web_url_path,
315
- published_on
313
+ published_on,
314
+ soundslice,
315
+ instrumentless,
316
316
  }[0...10]
317
317
  }
318
318
  |order(${sortOrder})
319
319
  [${start}...${end}]
320
320
  }`;
321
- } else if (groupBy === "genre") {
321
+ } else if (groupBy === "style") {
322
322
  query = `
323
323
  {
324
324
  "total": count(*[_type == 'genre' &amp;&amp; count(*[_type == 'song' &amp;&amp; brand == '${brand}' &amp;&amp; ^._id in genre[]._ref ]._id) > 0]),
@@ -331,15 +331,15 @@ async function fetchAllSongs(brand, {
331
331
  'head_shot_picture_url': thumbnail_url.asset->url,
332
332
  'all_lessons_count': count(*[_type == 'song' &amp;&amp; brand == '${brand}' &amp;&amp; ^._id in genre[]._ref ]._id),
333
333
  'lessons': *[_type == 'song' &amp;&amp; brand == '${brand}' &amp;&amp; ^._id in genre[]._ref ]{
334
- railcontent_id,
334
+ "id": railcontent_id,
335
+ "type": _type,
335
336
  title,
336
- "image": thumbnail.asset->url,
337
+ "thumbnail_url": thumbnail.asset->url,
337
338
  "artist_name": artist->name,
338
- artist,
339
- difficulty,
340
339
  difficulty_string,
341
- web_url_path,
342
- published_on
340
+ published_on,
341
+ soundslice,
342
+ instrumentless,
343
343
  }[0...10]
344
344
  }
345
345
  |order(${sortOrder})
@@ -349,22 +349,22 @@ async function fetchAllSongs(brand, {
349
349
  query = `
350
350
  {
351
351
  "entity": *[_type == 'song' &amp;&amp; brand == "${brand}" ${searchFilter} ${includedFieldsFilter}] | order(${sortOrder}) [${start}...${end}] {
352
- railcontent_id,
352
+ "id": railcontent_id,
353
+ "type": _type,
353
354
  title,
354
- "image": thumbnail.asset->url,
355
+ "thumbnail_url": thumbnail.asset->url,
355
356
  "artist_name": artist->name,
356
- artist,
357
- difficulty,
358
357
  difficulty_string,
359
- web_url_path,
360
- published_on
358
+ published_on,
359
+ soundslice,
360
+ instrumentless,
361
361
  },
362
362
  "total": count(*[_type == 'song' &amp;&amp; brand == "${brand}" ${searchFilter} ${includedFieldsFilter}])
363
363
  }
364
364
  `;
365
365
  }
366
366
 
367
- return fetchSanity(query, false);
367
+ return fetchSanity(query, true);
368
368
  }
369
369
 
370
370
  /**
@@ -382,24 +382,24 @@ async function fetchSongFilterOptions(brand) {
382
382
  const query = `
383
383
  {
384
384
  "difficulty": [
385
- {"type": "Introductory", "count": count(*[_type == 'song' &amp;&amp; brand == ${brand} &amp;&amp; difficulty_string == "Introductory"]._id)},
386
- {"type": "Beginner", "count": count(*[_type == 'song' &amp;&amp; brand == ${brand} &amp;&amp; difficulty_string == "Beginner"]._id)},
387
- {"type": "Intermediate", "count": count(*[_type == 'song' &amp;&amp; brand == ${brand} &amp;&amp; difficulty_string == "Intermediate"]._id)},
388
- {"type": "Advanced", "count": count(*[_type == 'song' &amp;&amp; brand == ${brand} &amp;&amp; difficulty_string == "Advanced"]._id)},
389
- {"type": "Expert", "count": count(*[_type == 'song' &amp;&amp; brand == ${brand} &amp;&amp; difficulty_string == "Expert"]._id)}
385
+ {"type": "Introductory", "count": count(*[_type == 'song' &amp;&amp; brand == '${brand}' &amp;&amp; difficulty_string == "Introductory"]._id)},
386
+ {"type": "Beginner", "count": count(*[_type == 'song' &amp;&amp; brand == '${brand}' &amp;&amp; difficulty_string == "Beginner"]._id)},
387
+ {"type": "Intermediate", "count": count(*[_type == 'song' &amp;&amp; brand == '${brand}' &amp;&amp; difficulty_string == "Intermediate"]._id)},
388
+ {"type": "Advanced", "count": count(*[_type == 'song' &amp;&amp; brand == '${brand}' &amp;&amp; difficulty_string == "Advanced"]._id)},
389
+ {"type": "Expert", "count": count(*[_type == 'song' &amp;&amp; brand == '${brand}' &amp;&amp; difficulty_string == "Expert"]._id)}
390
390
  ],
391
391
  "genre": *[_type == 'genre' &amp;&amp; 'song' in filter_types] {
392
392
  "type": name,
393
- "count": count(*[_type == 'song' &amp;&amp; brand == ${brand} &amp;&amp; references(^._id)]._id)
393
+ "count": count(*[_type == 'song' &amp;&amp; brand == '${brand}' &amp;&amp; references(^._id)]._id)
394
394
  },
395
395
  "instrumentless": [
396
- {"type": "Full Song Only", "count": count(*[_type == 'song' &amp;&amp; brand == ${brand} &amp;&amp; instrumentless == false]._id)},
397
- {"type": "Instrument Removed", "count": count(*[_type == 'song' &amp;&amp; brand == ${brand} &amp;&amp; instrumentless == true]._id)}
396
+ {"type": "Full Song Only", "count": count(*[_type == 'song' &amp;&amp; brand == '${brand}' &amp;&amp; instrumentless == false]._id)},
397
+ {"type": "Instrument Removed", "count": count(*[_type == 'song' &amp;&amp; brand == '${brand}' &amp;&amp; instrumentless == true]._id)}
398
398
  ]
399
399
  }
400
400
  `;
401
401
 
402
- return fetchSanity(query, false);
402
+ return fetchSanity(query, true);
403
403
  }
404
404
 
405
405
  /**
@@ -414,16 +414,22 @@ async function fetchSongCount(brand) {
414
414
 
415
415
  /**
416
416
  * Fetch the latest workouts for the home page of a specific brand.
417
- * @param {string} brand - The brand for which to fetch workouts.
418
- * @returns {Promise&lt;Object|null>} - The fetched workout data or null if not found.
417
+ * This function retrieves the latest workout content for a given brand, fetching up to five workouts. The workouts are sorted in descending order by their publication date.
418
+ * @param {string} brand - The brand for which to fetch workouts (e.g., 'drumeo', 'pianote').
419
+ * @returns {Promise&lt;Array&lt;Object>|null>} - A promise that resolves to an array of workout data objects or null if no workouts are found.
420
+ *
421
+ * @example
422
+ * fetchWorkouts('drumeo')
423
+ * .then(workouts => console.log(workouts))
424
+ * .catch(error => console.error(error));
419
425
  */
420
426
  async function fetchWorkouts(brand) {
421
427
  const query = `*[_type == 'workout' &amp;&amp; brand == '${brand}'] [0...5] {
422
428
  railcontent_id,
423
429
  title,
424
430
  "image": thumbnail.asset->url,
425
- "artist_name": artist->name,
426
- artist,
431
+ "artist_name": instructor[0]->name,
432
+ "artists": instructor[]->name,
427
433
  difficulty,
428
434
  difficulty_string,
429
435
  web_url_path,
@@ -1027,7 +1033,6 @@ module.exports = {
1027
1033
  fetchPackChildren,
1028
1034
  fetchLessonContent
1029
1035
  };
1030
-
1031
1036
  </code></pre>
1032
1037
  </article>
1033
1038
  </section>
@@ -1042,7 +1047,7 @@ module.exports = {
1042
1047
  <br class="clear">
1043
1048
 
1044
1049
  <footer>
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.
1050
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Tue Aug 13 2024 02:40:03 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1046
1051
  </footer>
1047
1052
 
1048
1053
  <script>prettyPrint();</script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/index.d.ts ADDED
@@ -0,0 +1,52 @@
1
+ import {
2
+ initializeSanityService,
3
+ fetchSongById,
4
+ fetchArtists,
5
+ fetchSongArtistCount,
6
+ fetchRelatedSongs,
7
+ fetchAllSongs,
8
+ fetchSongFilterOptions,
9
+ fetchSongCount,
10
+ fetchWorkouts,
11
+ fetchNewReleases,
12
+ fetchUpcomingEvents,
13
+ fetchByRailContentId,
14
+ fetchByRailContentIds,
15
+ fetchAll,
16
+ fetchAllFilterOptions,
17
+ fetchMethodNextLesson,
18
+ fetchMethodChildren,
19
+ fetchNextPreviousLesson,
20
+ fetchRelatedLessons,
21
+ fetchPackAll,
22
+ fetchPackChildren,
23
+ fetchLessonContent
24
+ } from './index.js';
25
+
26
+ declare module 'musora-content-services' {
27
+ export {
28
+ initializeSanityService,
29
+ fetchSongById,
30
+ fetchArtists,
31
+ fetchSongArtistCount,
32
+ fetchRelatedSongs,
33
+ fetchAllSongs,
34
+ fetchSongFilterOptions,
35
+ fetchSongCount,
36
+ fetchWorkouts,
37
+ fetchNewReleases,
38
+ fetchUpcomingEvents,
39
+ fetchByRailContentId,
40
+ fetchByRailContentIds,
41
+ fetchAll,
42
+ fetchAllFilterOptions,
43
+ fetchMethodNextLesson,
44
+ fetchMethodChildren,
45
+ fetchNextPreviousLesson,
46
+ fetchRelatedLessons,
47
+ fetchPackAll,
48
+ fetchPackChildren,
49
+ fetchLessonContent
50
+ }
51
+
52
+ }
package/src/index.js CHANGED
@@ -85,7 +85,7 @@ async function fetchArtists(brand) {
85
85
  */
86
86
  async function fetchSongArtistCount(brand) {
87
87
  const query = `count(*[_type == 'artist']{'lessonsCount': count(*[_type == 'song' && brand == '${brand}' && references(^._id)]._id)}[lessonsCount > 0])`;
88
- return fetchSanity(query, false);
88
+ return fetchSanity(query, true);
89
89
  }
90
90
 
91
91
  /**
@@ -257,21 +257,21 @@ async function fetchAllSongs(brand, {
257
257
  'head_shot_picture_url': thumbnail_url.asset->url,
258
258
  'all_lessons_count': count(*[_type == 'song' && brand == '${brand}' && ^._id == artist._ref ]._id),
259
259
  'lessons': *[_type == 'song' && brand == '${brand}' && ^._id == artist._ref ]{
260
- railcontent_id,
260
+ "id": railcontent_id,
261
+ "type": _type,
261
262
  title,
262
- "image": thumbnail.asset->url,
263
+ "thumbnail_url": thumbnail.asset->url,
263
264
  "artist_name": artist->name,
264
- artist,
265
- difficulty,
266
265
  difficulty_string,
267
- web_url_path,
268
- published_on
266
+ published_on,
267
+ soundslice,
268
+ instrumentless,
269
269
  }[0...10]
270
270
  }
271
271
  |order(${sortOrder})
272
272
  [${start}...${end}]
273
273
  }`;
274
- } else if (groupBy === "genre") {
274
+ } else if (groupBy === "style") {
275
275
  query = `
276
276
  {
277
277
  "total": count(*[_type == 'genre' && count(*[_type == 'song' && brand == '${brand}' && ^._id in genre[]._ref ]._id) > 0]),
@@ -284,15 +284,15 @@ async function fetchAllSongs(brand, {
284
284
  'head_shot_picture_url': thumbnail_url.asset->url,
285
285
  'all_lessons_count': count(*[_type == 'song' && brand == '${brand}' && ^._id in genre[]._ref ]._id),
286
286
  'lessons': *[_type == 'song' && brand == '${brand}' && ^._id in genre[]._ref ]{
287
- railcontent_id,
287
+ "id": railcontent_id,
288
+ "type": _type,
288
289
  title,
289
- "image": thumbnail.asset->url,
290
+ "thumbnail_url": thumbnail.asset->url,
290
291
  "artist_name": artist->name,
291
- artist,
292
- difficulty,
293
292
  difficulty_string,
294
- web_url_path,
295
- published_on
293
+ published_on,
294
+ soundslice,
295
+ instrumentless,
296
296
  }[0...10]
297
297
  }
298
298
  |order(${sortOrder})
@@ -302,22 +302,22 @@ async function fetchAllSongs(brand, {
302
302
  query = `
303
303
  {
304
304
  "entity": *[_type == 'song' && brand == "${brand}" ${searchFilter} ${includedFieldsFilter}] | order(${sortOrder}) [${start}...${end}] {
305
- railcontent_id,
305
+ "id": railcontent_id,
306
+ "type": _type,
306
307
  title,
307
- "image": thumbnail.asset->url,
308
+ "thumbnail_url": thumbnail.asset->url,
308
309
  "artist_name": artist->name,
309
- artist,
310
- difficulty,
311
310
  difficulty_string,
312
- web_url_path,
313
- published_on
311
+ published_on,
312
+ soundslice,
313
+ instrumentless,
314
314
  },
315
315
  "total": count(*[_type == 'song' && brand == "${brand}" ${searchFilter} ${includedFieldsFilter}])
316
316
  }
317
317
  `;
318
318
  }
319
319
 
320
- return fetchSanity(query, false);
320
+ return fetchSanity(query, true);
321
321
  }
322
322
 
323
323
  /**
@@ -335,24 +335,24 @@ async function fetchSongFilterOptions(brand) {
335
335
  const query = `
336
336
  {
337
337
  "difficulty": [
338
- {"type": "Introductory", "count": count(*[_type == 'song' && brand == ${brand} && difficulty_string == "Introductory"]._id)},
339
- {"type": "Beginner", "count": count(*[_type == 'song' && brand == ${brand} && difficulty_string == "Beginner"]._id)},
340
- {"type": "Intermediate", "count": count(*[_type == 'song' && brand == ${brand} && difficulty_string == "Intermediate"]._id)},
341
- {"type": "Advanced", "count": count(*[_type == 'song' && brand == ${brand} && difficulty_string == "Advanced"]._id)},
342
- {"type": "Expert", "count": count(*[_type == 'song' && brand == ${brand} && difficulty_string == "Expert"]._id)}
338
+ {"type": "Introductory", "count": count(*[_type == 'song' && brand == '${brand}' && difficulty_string == "Introductory"]._id)},
339
+ {"type": "Beginner", "count": count(*[_type == 'song' && brand == '${brand}' && difficulty_string == "Beginner"]._id)},
340
+ {"type": "Intermediate", "count": count(*[_type == 'song' && brand == '${brand}' && difficulty_string == "Intermediate"]._id)},
341
+ {"type": "Advanced", "count": count(*[_type == 'song' && brand == '${brand}' && difficulty_string == "Advanced"]._id)},
342
+ {"type": "Expert", "count": count(*[_type == 'song' && brand == '${brand}' && difficulty_string == "Expert"]._id)}
343
343
  ],
344
344
  "genre": *[_type == 'genre' && 'song' in filter_types] {
345
345
  "type": name,
346
- "count": count(*[_type == 'song' && brand == ${brand} && references(^._id)]._id)
346
+ "count": count(*[_type == 'song' && brand == '${brand}' && references(^._id)]._id)
347
347
  },
348
348
  "instrumentless": [
349
- {"type": "Full Song Only", "count": count(*[_type == 'song' && brand == ${brand} && instrumentless == false]._id)},
350
- {"type": "Instrument Removed", "count": count(*[_type == 'song' && brand == ${brand} && instrumentless == true]._id)}
349
+ {"type": "Full Song Only", "count": count(*[_type == 'song' && brand == '${brand}' && instrumentless == false]._id)},
350
+ {"type": "Instrument Removed", "count": count(*[_type == 'song' && brand == '${brand}' && instrumentless == true]._id)}
351
351
  ]
352
352
  }
353
353
  `;
354
354
 
355
- return fetchSanity(query, false);
355
+ return fetchSanity(query, true);
356
356
  }
357
357
 
358
358
  /**
@@ -367,16 +367,22 @@ async function fetchSongCount(brand) {
367
367
 
368
368
  /**
369
369
  * Fetch the latest workouts for the home page of a specific brand.
370
- * @param {string} brand - The brand for which to fetch workouts.
371
- * @returns {Promise<Object|null>} - The fetched workout data or null if not found.
370
+ * This function retrieves the latest workout content for a given brand, fetching up to five workouts. The workouts are sorted in descending order by their publication date.
371
+ * @param {string} brand - The brand for which to fetch workouts (e.g., 'drumeo', 'pianote').
372
+ * @returns {Promise<Array<Object>|null>} - A promise that resolves to an array of workout data objects or null if no workouts are found.
373
+ *
374
+ * @example
375
+ * fetchWorkouts('drumeo')
376
+ * .then(workouts => console.log(workouts))
377
+ * .catch(error => console.error(error));
372
378
  */
373
379
  async function fetchWorkouts(brand) {
374
380
  const query = `*[_type == 'workout' && brand == '${brand}'] [0...5] {
375
381
  railcontent_id,
376
382
  title,
377
383
  "image": thumbnail.asset->url,
378
- "artist_name": artist->name,
379
- artist,
384
+ "artist_name": instructor[0]->name,
385
+ "artists": instructor[]->name,
380
386
  difficulty,
381
387
  difficulty_string,
382
388
  web_url_path,
@@ -980,4 +986,3 @@ module.exports = {
980
986
  fetchPackChildren,
981
987
  fetchLessonContent
982
988
  };
983
-