musora-content-services 1.0.139 → 1.0.140

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.
Files changed (57) hide show
  1. package/.github/workflows/node.js.yml +0 -0
  2. package/CHANGELOG.md +2 -0
  3. package/README.md +0 -0
  4. package/babel.config.js +0 -0
  5. package/docs/config.js.html +1 -1
  6. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  7. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  8. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  9. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  10. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  11. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  12. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  13. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  14. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  15. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +0 -0
  16. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  17. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  18. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  19. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  20. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +0 -0
  21. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  22. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  23. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  24. package/docs/index.html +1 -1
  25. package/docs/module-Config.html +1 -1
  26. package/docs/module-Railcontent-Services.html +1 -1
  27. package/docs/module-Sanity-Services.html +19 -19
  28. package/docs/railcontent.js.html +1 -1
  29. package/docs/sanity.js.html +68 -39
  30. package/docs/scripts/collapse.js +0 -0
  31. package/docs/scripts/commonNav.js +0 -0
  32. package/docs/scripts/linenumber.js +0 -0
  33. package/docs/scripts/nav.js +0 -0
  34. package/docs/scripts/polyfill.js +0 -0
  35. package/docs/scripts/prettify/Apache-License-2.0.txt +0 -0
  36. package/docs/scripts/prettify/lang-css.js +0 -0
  37. package/docs/scripts/prettify/prettify.js +0 -0
  38. package/docs/scripts/search.js +0 -0
  39. package/docs/styles/jsdoc.css +0 -0
  40. package/docs/styles/prettify.css +0 -0
  41. package/jest.config.js +0 -0
  42. package/jsdoc.json +0 -0
  43. package/package.json +1 -1
  44. package/src/contentMetaData.js +0 -0
  45. package/src/contentTypeConfig.js +0 -0
  46. package/src/filterBuilder.js +0 -0
  47. package/src/index.d.ts +0 -0
  48. package/src/index.js +0 -0
  49. package/src/services/config.js +0 -0
  50. package/src/services/contentLikes.js +0 -0
  51. package/src/services/dataContext.js +0 -0
  52. package/src/services/railcontent.js +0 -0
  53. package/src/services/sanity.js +31 -18
  54. package/test/contentLikes.test.js +0 -0
  55. package/test/localStorageMock.js +0 -0
  56. package/test/log.js +0 -0
  57. package/tools/generate-index.js +0 -0
File without changes
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.140](https://github.com/railroadmedia/musora-content-services/compare/v1.0.139...v1.0.140) (2024-10-16)
6
+
5
7
  ### [1.0.139](https://github.com/railroadmedia/musora-content-services/compare/v1.0.137...v1.0.139) (2024-10-16)
6
8
 
7
9
  ### [1.0.138](https://github.com/railroadmedia/musora-content-services/compare/v1.0.137...v1.0.138) (2024-10-15)
package/README.md CHANGED
File without changes
package/babel.config.js CHANGED
File without changes
@@ -126,7 +126,7 @@ module.exports = {
126
126
  <br class="clear">
127
127
 
128
128
  <footer>
129
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Tue Oct 15 2024 11:28:17 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
129
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Wed Oct 16 2024 19:36:10 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
130
130
  </footer>
131
131
 
132
132
  <script>prettyPrint();</script>
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/docs/index.html CHANGED
@@ -155,7 +155,7 @@ with <code>npm test -- -t=&quot;userContext&quot;</code> or just the contentLike
155
155
  <br class="clear">
156
156
 
157
157
  <footer>
158
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Tue Oct 15 2024 11:28:17 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
158
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Wed Oct 16 2024 19:36:10 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
159
159
  </footer>
160
160
 
161
161
  <script>prettyPrint();</script>
@@ -828,7 +828,7 @@ initializeService({
828
828
  <br class="clear">
829
829
 
830
830
  <footer>
831
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Tue Oct 15 2024 11:28:17 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
831
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Wed Oct 16 2024 19:36:10 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
832
832
  </footer>
833
833
 
834
834
  <script>prettyPrint();</script>
@@ -1435,7 +1435,7 @@
1435
1435
  <br class="clear">
1436
1436
 
1437
1437
  <footer>
1438
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Tue Oct 15 2024 11:28:17 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1438
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Wed Oct 16 2024 19:36:10 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1439
1439
  </footer>
1440
1440
 
1441
1441
  <script>prettyPrint();</script>
@@ -1242,7 +1242,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'coach-lessons', 'Love'
1242
1242
 
1243
1243
  <dt class="tag-source">Source:</dt>
1244
1244
  <dd class="tag-source"><ul class="dummy"><li>
1245
- <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line1012">line 1012</a>
1245
+ <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line1028">line 1028</a>
1246
1246
  </li></ul></dd>
1247
1247
 
1248
1248
 
@@ -2042,7 +2042,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'coach-lessons', 'Love'
2042
2042
 
2043
2043
  <dt class="tag-source">Source:</dt>
2044
2044
  <dd class="tag-source"><ul class="dummy"><li>
2045
- <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line1255">line 1255</a>
2045
+ <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line1271">line 1271</a>
2046
2046
  </li></ul></dd>
2047
2047
 
2048
2048
 
@@ -3110,7 +3110,7 @@ fetchAllFilterOptions('myBrand', '', 'Rock', 'John Doe', 'coach-lessons', 'Love'
3110
3110
 
3111
3111
  <dt class="tag-source">Source:</dt>
3112
3112
  <dd class="tag-source"><ul class="dummy"><li>
3113
- <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line1209">line 1209</a>
3113
+ <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line1225">line 1225</a>
3114
3114
  </li></ul></dd>
3115
3115
 
3116
3116
 
@@ -3276,7 +3276,7 @@ It's an ongoing discussion (Aug 2024), but it's been included here if necessary<
3276
3276
 
3277
3277
  <dt class="tag-source">Source:</dt>
3278
3278
  <dd class="tag-source"><ul class="dummy"><li>
3279
- <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line1451">line 1451</a>
3279
+ <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line1480">line 1480</a>
3280
3280
  </li></ul></dd>
3281
3281
 
3282
3282
 
@@ -3441,7 +3441,7 @@ It's an ongoing discussion (Aug 2024), but it's been included here if necessary<
3441
3441
 
3442
3442
  <dt class="tag-source">Source:</dt>
3443
3443
  <dd class="tag-source"><ul class="dummy"><li>
3444
- <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line1130">line 1130</a>
3444
+ <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line1146">line 1146</a>
3445
3445
  </li></ul></dd>
3446
3446
 
3447
3447
 
@@ -3808,7 +3808,7 @@ It's an ongoing discussion (Aug 2024), but it's been included here if necessary<
3808
3808
 
3809
3809
  <dt class="tag-source">Source:</dt>
3810
3810
  <dd class="tag-source"><ul class="dummy"><li>
3811
- <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line1155">line 1155</a>
3811
+ <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line1171">line 1171</a>
3812
3812
  </li></ul></dd>
3813
3813
 
3814
3814
 
@@ -4251,7 +4251,7 @@ It's an ongoing discussion (Aug 2024), but it's been included here if necessary<
4251
4251
 
4252
4252
  <dt class="tag-source">Source:</dt>
4253
4253
  <dd class="tag-source"><ul class="dummy"><li>
4254
- <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line1194">line 1194</a>
4254
+ <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line1210">line 1210</a>
4255
4255
  </li></ul></dd>
4256
4256
 
4257
4257
 
@@ -4574,7 +4574,7 @@ It's an ongoing discussion (Aug 2024), but it's been included here if necessary<
4574
4574
 
4575
4575
  <dt class="tag-source">Source:</dt>
4576
4576
  <dd class="tag-source"><ul class="dummy"><li>
4577
- <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line1307">line 1307</a>
4577
+ <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line1323">line 1323</a>
4578
4578
  </li></ul></dd>
4579
4579
 
4580
4580
 
@@ -5055,7 +5055,7 @@ It's an ongoing discussion (Aug 2024), but it's been included here if necessary<
5055
5055
 
5056
5056
  <dt class="tag-source">Source:</dt>
5057
5057
  <dd class="tag-source"><ul class="dummy"><li>
5058
- <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line908">line 908</a>
5058
+ <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line921">line 921</a>
5059
5059
  </li></ul></dd>
5060
5060
 
5061
5061
 
@@ -5220,7 +5220,7 @@ It's an ongoing discussion (Aug 2024), but it's been included here if necessary<
5220
5220
 
5221
5221
  <dt class="tag-source">Source:</dt>
5222
5222
  <dd class="tag-source"><ul class="dummy"><li>
5223
- <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line1501">line 1501</a>
5223
+ <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line1530">line 1530</a>
5224
5224
  </li></ul></dd>
5225
5225
 
5226
5226
 
@@ -6590,7 +6590,7 @@ It's an ongoing discussion (Aug 2024), but it's been included here if necessary<
6590
6590
 
6591
6591
  <dt class="tag-source">Source:</dt>
6592
6592
  <dd class="tag-source"><ul class="dummy"><li>
6593
- <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line882">line 882</a>
6593
+ <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line887">line 887</a>
6594
6594
  </li></ul></dd>
6595
6595
 
6596
6596
 
@@ -6748,7 +6748,7 @@ It's an ongoing discussion (Aug 2024), but it's been included here if necessary<
6748
6748
 
6749
6749
  <dt class="tag-source">Source:</dt>
6750
6750
  <dd class="tag-source"><ul class="dummy"><li>
6751
- <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line1039">line 1039</a>
6751
+ <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line1055">line 1055</a>
6752
6752
  </li></ul></dd>
6753
6753
 
6754
6754
 
@@ -6906,7 +6906,7 @@ It's an ongoing discussion (Aug 2024), but it's been included here if necessary<
6906
6906
 
6907
6907
  <dt class="tag-source">Source:</dt>
6908
6908
  <dd class="tag-source"><ul class="dummy"><li>
6909
- <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line1099">line 1099</a>
6909
+ <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line1115">line 1115</a>
6910
6910
  </li></ul></dd>
6911
6911
 
6912
6912
 
@@ -7071,7 +7071,7 @@ It's an ongoing discussion (Aug 2024), but it's been included here if necessary<
7071
7071
 
7072
7072
  <dt class="tag-source">Source:</dt>
7073
7073
  <dd class="tag-source"><ul class="dummy"><li>
7074
- <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line1113">line 1113</a>
7074
+ <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line1129">line 1129</a>
7075
7075
  </li></ul></dd>
7076
7076
 
7077
7077
 
@@ -7385,7 +7385,7 @@ It's an ongoing discussion (Aug 2024), but it's been included here if necessary<
7385
7385
 
7386
7386
  <dt class="tag-source">Source:</dt>
7387
7387
  <dd class="tag-source"><ul class="dummy"><li>
7388
- <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line966">line 966</a>
7388
+ <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line982">line 982</a>
7389
7389
  </li></ul></dd>
7390
7390
 
7391
7391
 
@@ -7567,7 +7567,7 @@ It's an ongoing discussion (Aug 2024), but it's been included here if necessary<
7567
7567
 
7568
7568
  <dt class="tag-source">Source:</dt>
7569
7569
  <dd class="tag-source"><ul class="dummy"><li>
7570
- <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line985">line 985</a>
7570
+ <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line1001">line 1001</a>
7571
7571
  </li></ul></dd>
7572
7572
 
7573
7573
 
@@ -7935,7 +7935,7 @@ It's an ongoing discussion (Aug 2024), but it's been included here if necessary<
7935
7935
 
7936
7936
  <dt class="tag-source">Source:</dt>
7937
7937
  <dd class="tag-source"><ul class="dummy"><li>
7938
- <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line1355">line 1355</a>
7938
+ <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line1371">line 1371</a>
7939
7939
  </li></ul></dd>
7940
7940
 
7941
7941
 
@@ -8401,7 +8401,7 @@ fetchSanity(query, true)
8401
8401
 
8402
8402
  <dt class="tag-source">Source:</dt>
8403
8403
  <dd class="tag-source"><ul class="dummy"><li>
8404
- <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line1476">line 1476</a>
8404
+ <a href="sanity.js.html">sanity.js</a>, <a href="sanity.js.html#line1505">line 1505</a>
8405
8405
  </li></ul></dd>
8406
8406
 
8407
8407
 
@@ -9537,7 +9537,7 @@ It also includes completion status and progress percentage for each workout by f
9537
9537
  <br class="clear">
9538
9538
 
9539
9539
  <footer>
9540
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Tue Oct 15 2024 11:28:17 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
9540
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Wed Oct 16 2024 19:36:10 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
9541
9541
  </footer>
9542
9542
 
9543
9543
  <script>prettyPrint();</script>
@@ -376,7 +376,7 @@ function fetchAbsolute(url, params) {
376
376
  <br class="clear">
377
377
 
378
378
  <footer>
379
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Tue Oct 15 2024 11:28:17 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
379
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Wed Oct 16 2024 19:36:10 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
380
380
  </footer>
381
381
 
382
382
  <script>prettyPrint();</script>
@@ -149,7 +149,7 @@ export async function fetchSongArtistCount(brand) {
149
149
  export async function fetchRelatedSongs(brand, songId) {
150
150
  const query = `
151
151
  *[_type == "song" &amp;&amp; railcontent_id == ${songId}]{
152
- "data": array::unique([
152
+ "entity": array::unique([
153
153
  ...(*[_type == "song" &amp;&amp; brand == "${brand}" &amp;&amp; railcontent_id != ${songId} &amp;&amp; references(^.artist->_id)]{
154
154
  "type": _type,
155
155
  "id": railcontent_id,
@@ -879,7 +879,7 @@ export async function fetchMethodNextLesson(railcontentId, methodId) {
879
879
  */
880
880
  export async function fetchMethodPreviousNextLesson(railcontentId, methodId) {
881
881
  const sortedChildren = await fetchMethodChildrenIds(methodId);
882
- const index = sortedChildren.indexOf(railcontentId);
882
+ const index = sortedChildren.indexOf(Number(railcontentId));
883
883
  let nextId = sortedChildren[index + 1];
884
884
  let previousId = sortedChildren[index -1];
885
885
  let nextPrev = await fetchByRailContentIds([nextId, previousId]);
@@ -894,13 +894,16 @@ export async function fetchMethodPreviousNextLesson(railcontentId, methodId) {
894
894
  * @returns {Promise&lt;Array&lt;Object>|null>} - The fetched children data or null if not found.
895
895
  */
896
896
  export async function fetchMethodChildrenIds(railcontentId) {
897
- const query = `*[_type == 'learning-path' &amp;&amp; railcontent_id == ${railcontentId}]{
897
+ const query = `*[ railcontent_id == ${railcontentId}]{
898
898
  'children': child[]-> {
899
899
  'id': railcontent_id,
900
+ 'type' : _type,
900
901
  'children': child[]-> {
901
- 'id': railcontent_id,
902
- 'children': child[]-> {
903
902
  'id': railcontent_id,
903
+ 'type' : _type,
904
+ 'children': child[]-> {
905
+ 'id': railcontent_id,
906
+ 'type' : _type,
904
907
  }
905
908
  }
906
909
  }
@@ -912,9 +915,11 @@ export async function fetchMethodChildrenIds(railcontentId) {
912
915
  function getChildrenToDepth(parent, depth = 1)
913
916
  {
914
917
  let allChildrenIds = [];
915
- if (parent['children']) {
918
+ if (parent &amp;&amp; parent['children'] &amp;&amp; depth > 0) {
916
919
  parent['children'].forEach((child) => {
917
- allChildrenIds.push(child['id']);
920
+ if(!child['children']) {
921
+ allChildrenIds.push(child['id']);
922
+ }
918
923
  allChildrenIds = allChildrenIds.concat(getChildrenToDepth(child, depth-1));
919
924
  })
920
925
  }
@@ -927,19 +932,27 @@ function getChildrenToDepth(parent, depth = 1)
927
932
  * @returns {Promise&lt;Object|null>} - The fetched next and previous lesson data or null if found.
928
933
  */
929
934
  export async function fetchNextPreviousLesson(railcontentId) {
930
- //TODO: Implement getTypeNeighbouringSiblings/getNextAndPreviousLessons
931
- const query = `*[_railcontent_id == ${railcontentId}]{
932
- railcontent_id,
933
- title,
934
- "image": thumbnail.asset->url,
935
- "artist_name": artist->name,
936
- artist,
937
- difficulty,
938
- difficulty_string,
939
- web_url_path,
940
- published_on
941
- }`
942
- return fetchSanity(query, false);
935
+ const document = await fetchLessonContent(railcontentId);
936
+ if (document.parent_content_data &amp;&amp; document.parent_content_data.length > 0) {
937
+ const lastElement = document.parent_content_data[document.parent_content_data.length - 1];
938
+ const results = await fetchMethodPreviousNextLesson(railcontentId, lastElement.id);
939
+ return results;
940
+ }
941
+ const processedData = processMetadata(document.brand, document.type, true);
942
+ let sortBy = processedData?.sortBy ?? 'published_on';
943
+ const isDesc = sortBy.startsWith('-');
944
+ sortBy = isDesc ? sortBy.substring(1) : sortBy;
945
+ const sortValue = document[sortBy];
946
+ const isNumeric = !isNaN(sortValue);
947
+ let prevComparison = isNumeric ? `${sortBy} &lt;= ${sortValue}` : `${sortBy} &lt;= "${sortValue}"`;
948
+ let nextComparison = isNumeric ? `${sortBy} >= ${sortValue}` : `${sortBy} >= "${sortValue}"`;
949
+ const fields = getFieldsForContentType(document.type);
950
+ const query = `{
951
+ "prevLesson": *[brand == "${document.brand}" &amp;&amp; status == "${document.status}" &amp;&amp; _type == "${document.type}" &amp;&amp; ${prevComparison} &amp;&amp; railcontent_id != ${railcontentId}] | order(${sortBy} desc){${fields}}[0...1][0],
952
+ "nextLesson": *[brand == "${document.brand}" &amp;&amp; status == "${document.status}" &amp;&amp; _type == "${document.type}" &amp;&amp; ${nextComparison} &amp;&amp; railcontent_id != ${railcontentId}] | order(${sortBy} asc){${fields}}[0...1][0]
953
+ }`;
954
+
955
+ return await fetchSanity(query, true);
943
956
  }
944
957
 
945
958
  /**
@@ -961,6 +974,7 @@ export async function fetchLessonContent(railContentId) {
961
974
  difficulty,
962
975
  difficulty_string,
963
976
  brand,
977
+ status,
964
978
  soundslice,
965
979
  instrumentless,
966
980
  railcontent_id,
@@ -992,7 +1006,9 @@ export async function fetchLessonContent(railContentId) {
992
1006
  mp3_no_drums_yes_click_url,
993
1007
  mp3_yes_drums_no_click_url,
994
1008
  mp3_yes_drums_yes_click_url,
995
- "permission_id": permission[]->railcontent_id,`;
1009
+ "permission_id": permission[]->railcontent_id,
1010
+ parent_content_data,
1011
+ sort`;
996
1012
  const query = buildQuery(
997
1013
  `railcontent_id == ${railContentId}`,
998
1014
  filterParams,
@@ -1443,23 +1459,36 @@ export async function fetchSanity(query,
1443
1459
  }
1444
1460
  }
1445
1461
 
1446
- async function needsAccessDecorator(results)
1447
- {
1448
- if (globalConfig.sanityConfig.useDummyRailContentMethods) return results;
1449
- let userPermissions = await getUserPermissions();
1450
- userPermissions = new Set(userPermissions);
1451
- if (Array.isArray(results)) {
1452
- results.forEach((result) => {
1453
- result['need_access'] = doesUserNeedAccessToContent(result, userPermissions);
1454
- });
1455
- }else if (results.entity &amp;&amp; Array.isArray(results.entity)) {
1456
- results.entity.forEach((result) => {
1457
- result['need_access'] = doesUserNeedAccessToContent(result, userPermissions);
1458
- });
1459
- } else {
1460
- results['need_access'] = doesUserNeedAccessToContent(results, userPermissions);
1461
- }
1462
- return results;
1462
+ async function needsAccessDecorator(results) {
1463
+ if (globalConfig.sanityConfig.useDummyRailContentMethods) return results;
1464
+
1465
+ let userPermissions = await getUserPermissions();
1466
+ userPermissions = new Set(userPermissions);
1467
+
1468
+ if (Array.isArray(results)) {
1469
+ results.forEach((result) => {
1470
+ result['need_access'] = doesUserNeedAccessToContent(result, userPermissions);
1471
+ });
1472
+ } else if (results.entity &amp;&amp; Array.isArray(results.entity)) {
1473
+ // Group By
1474
+ results.entity.forEach((result) => {
1475
+ if (result.lessons) {
1476
+ result.lessons.forEach((lesson) => {
1477
+ lesson['need_access'] = doesUserNeedAccessToContent(lesson, userPermissions); // Updated to check lesson access
1478
+ });
1479
+ } else {
1480
+ result['need_access'] = doesUserNeedAccessToContent(result, userPermissions);
1481
+ }
1482
+ });
1483
+ } else if (results.related_lessons &amp;&amp; Array.isArray(results.related_lessons)) {
1484
+ results.related_lessons.forEach((result) => {
1485
+ result['need_access'] = doesUserNeedAccessToContent(result, userPermissions);
1486
+ })
1487
+ } else {
1488
+ results['need_access'] = doesUserNeedAccessToContent(results, userPermissions);
1489
+ }
1490
+
1491
+ return results;
1463
1492
  }
1464
1493
 
1465
1494
  function doesUserNeedAccessToContent(result, userPermissions)
@@ -1754,7 +1783,7 @@ function cleanUpGroq(query) {
1754
1783
  <br class="clear">
1755
1784
 
1756
1785
  <footer>
1757
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Tue Oct 15 2024 11:28:17 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1786
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Wed Oct 16 2024 19:36:10 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1758
1787
  </footer>
1759
1788
 
1760
1789
  <script>prettyPrint();</script>
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/jest.config.js CHANGED
File without changes
package/jsdoc.json CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "1.0.139",
3
+ "version": "1.0.140",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
File without changes
File without changes
File without changes
package/src/index.d.ts CHANGED
File without changes
package/src/index.js CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -102,7 +102,7 @@ export async function fetchSongArtistCount(brand) {
102
102
  export async function fetchRelatedSongs(brand, songId) {
103
103
  const query = `
104
104
  *[_type == "song" && railcontent_id == ${songId}]{
105
- "data": array::unique([
105
+ "entity": array::unique([
106
106
  ...(*[_type == "song" && brand == "${brand}" && railcontent_id != ${songId} && references(^.artist->_id)]{
107
107
  "type": _type,
108
108
  "id": railcontent_id,
@@ -1412,23 +1412,36 @@ export async function fetchSanity(query,
1412
1412
  }
1413
1413
  }
1414
1414
 
1415
- async function needsAccessDecorator(results)
1416
- {
1417
- if (globalConfig.sanityConfig.useDummyRailContentMethods) return results;
1418
- let userPermissions = await getUserPermissions();
1419
- userPermissions = new Set(userPermissions);
1420
- if (Array.isArray(results)) {
1421
- results.forEach((result) => {
1422
- result['need_access'] = doesUserNeedAccessToContent(result, userPermissions);
1423
- });
1424
- }else if (results.entity && Array.isArray(results.entity)) {
1425
- results.entity.forEach((result) => {
1426
- result['need_access'] = doesUserNeedAccessToContent(result, userPermissions);
1427
- });
1428
- } else {
1429
- results['need_access'] = doesUserNeedAccessToContent(results, userPermissions);
1430
- }
1431
- return results;
1415
+ async function needsAccessDecorator(results) {
1416
+ if (globalConfig.sanityConfig.useDummyRailContentMethods) return results;
1417
+
1418
+ let userPermissions = await getUserPermissions();
1419
+ userPermissions = new Set(userPermissions);
1420
+
1421
+ if (Array.isArray(results)) {
1422
+ results.forEach((result) => {
1423
+ result['need_access'] = doesUserNeedAccessToContent(result, userPermissions);
1424
+ });
1425
+ } else if (results.entity && Array.isArray(results.entity)) {
1426
+ // Group By
1427
+ results.entity.forEach((result) => {
1428
+ if (result.lessons) {
1429
+ result.lessons.forEach((lesson) => {
1430
+ lesson['need_access'] = doesUserNeedAccessToContent(lesson, userPermissions); // Updated to check lesson access
1431
+ });
1432
+ } else {
1433
+ result['need_access'] = doesUserNeedAccessToContent(result, userPermissions);
1434
+ }
1435
+ });
1436
+ } else if (results.related_lessons && Array.isArray(results.related_lessons)) {
1437
+ results.related_lessons.forEach((result) => {
1438
+ result['need_access'] = doesUserNeedAccessToContent(result, userPermissions);
1439
+ })
1440
+ } else {
1441
+ results['need_access'] = doesUserNeedAccessToContent(results, userPermissions);
1442
+ }
1443
+
1444
+ return results;
1432
1445
  }
1433
1446
 
1434
1447
  function doesUserNeedAccessToContent(result, userPermissions)
File without changes
File without changes
package/test/log.js CHANGED
File without changes
File without changes