musora-content-services 1.3.21 → 2.0.5

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 (96) hide show
  1. package/.editorconfig +16 -0
  2. package/.github/workflows/node.js.yml +0 -0
  3. package/.prettierignore +0 -0
  4. package/.prettierrc +0 -0
  5. package/CHANGELOG.md +4 -4
  6. package/README.md +0 -0
  7. package/babel.config.cjs +0 -0
  8. package/docs/Content-Organization.html +245 -0
  9. package/docs/Playlists.html +192 -0
  10. package/docs/config.js.html +14 -5
  11. package/docs/content-org_playlists-types.js.html +109 -0
  12. package/docs/content-org_playlists.js.html +194 -0
  13. package/docs/content-org_types.js.html +112 -0
  14. package/docs/content.js.html +443 -0
  15. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  16. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  17. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  18. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  19. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  20. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  21. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  22. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  23. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  24. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +0 -0
  25. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  26. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  27. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  28. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  29. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +0 -0
  30. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  31. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  32. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  33. package/docs/global.html +3878 -0
  34. package/docs/index.html +2 -2
  35. package/docs/module-Config.html +60 -7
  36. package/docs/module-Content-Organization-Playlists.html +194 -0
  37. package/docs/module-Content-Organization.html +976 -0
  38. package/docs/module-Content-Services-V2.html +2433 -0
  39. package/docs/module-Playlists.html +969 -0
  40. package/docs/module-Railcontent-Services.html +3052 -1991
  41. package/docs/module-Sanity-Services.html +57 -43
  42. package/docs/module-Session-Management.html +575 -0
  43. package/docs/module-User-Permissions.html +406 -0
  44. package/docs/module-playlists.html +1878 -0
  45. package/docs/module-playlists_.html +108 -0
  46. package/docs/railcontent.js.html +149 -112
  47. package/docs/sanity.js.html +297 -109
  48. package/docs/scripts/collapse.js +0 -0
  49. package/docs/scripts/commonNav.js +0 -0
  50. package/docs/scripts/linenumber.js +0 -0
  51. package/docs/scripts/nav.js +0 -0
  52. package/docs/scripts/polyfill.js +0 -0
  53. package/docs/scripts/prettify/Apache-License-2.0.txt +0 -0
  54. package/docs/scripts/prettify/lang-css.js +0 -0
  55. package/docs/scripts/prettify/prettify.js +0 -0
  56. package/docs/scripts/search.js +0 -0
  57. package/docs/styles/jsdoc.css +0 -0
  58. package/docs/styles/prettify.css +0 -0
  59. package/docs/user_permissions.js.html +110 -0
  60. package/docs/user_sessions.js.html +139 -0
  61. package/docs/user_types.js.html +188 -0
  62. package/jest.config.js +0 -0
  63. package/jsdoc.json +3 -0
  64. package/package.json +1 -1
  65. package/publish.sh +2 -2
  66. package/src/contentMetaData.js +307 -1088
  67. package/src/contentTypeConfig.js +108 -4
  68. package/src/filterBuilder.js +6 -6
  69. package/src/index.d.ts +67 -9
  70. package/src/index.js +67 -9
  71. package/src/{services → lib}/lastUpdated.js +17 -1
  72. package/src/services/content-org/playlists-types.js +37 -0
  73. package/src/services/content-org/playlists.js +122 -0
  74. package/src/services/content.js +371 -0
  75. package/src/services/contentLikes.js +0 -0
  76. package/src/services/contentProgress.js +0 -0
  77. package/src/services/forum.js +57 -0
  78. package/src/services/railcontent.js +122 -122
  79. package/src/services/recommendations.js +19 -0
  80. package/src/services/sanity.js +278 -104
  81. package/src/services/{userPermissions.js → user/permissions.js} +16 -2
  82. package/src/services/user/sessions.js +67 -0
  83. package/src/services/user/types.js +116 -0
  84. package/src/services/userActivity.js +32 -0
  85. package/test/content.test.js +116 -0
  86. package/test/contentProgress.test.js +83 -5
  87. package/test/forum.test.js +18 -0
  88. package/test/initializeTests.js +6 -1
  89. package/test/{lastUpdated.test.js → lib/lastUpdated.test.js} +2 -5
  90. package/test/live/contentProgressLive.test.js +0 -0
  91. package/test/live/railcontentLive.test.js +0 -0
  92. package/test/localStorageMock.js +0 -0
  93. package/test/log.js +0 -0
  94. package/test/sanityQueryService.test.js +66 -18
  95. package/test/{userPermissions.test.js → user/permissions.test.js} +3 -3
  96. package/tools/generate-index.cjs +16 -3
@@ -0,0 +1,112 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+
5
+ <meta charset="utf-8">
6
+ <title>content-org/types.js - Documentation</title>
7
+
8
+
9
+ <script src="scripts/prettify/prettify.js"></script>
10
+ <script src="scripts/prettify/lang-css.js"></script>
11
+ <!--[if lt IE 9]>
12
+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
13
+ <![endif]-->
14
+ <link type="text/css" rel="stylesheet" href="styles/prettify.css">
15
+ <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
16
+ <script src="scripts/nav.js" defer></script>
17
+
18
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
19
+ </head>
20
+ <body>
21
+
22
+ <input type="checkbox" id="nav-trigger" class="nav-trigger" />
23
+ <label for="nav-trigger" class="navicon-button x">
24
+ <div class="navicon"></div>
25
+ </label>
26
+
27
+ <label for="nav-trigger" class="overlay"></label>
28
+
29
+ <nav >
30
+
31
+
32
+ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Config.html">Config</a><ul class='methods'><li data-type='method'><a href="module-Config.html#.initializeService">initializeService</a></li></ul></li><li><a href="module-Content-Services-V2.html">Content-Services-V2</a><ul class='methods'><li data-type='method'><a href="module-Content-Services-V2.html#.getContentRows">getContentRows</a></li><li data-type='method'><a href="module-Content-Services-V2.html#.getNewAndUpcoming">getNewAndUpcoming</a></li><li data-type='method'><a href="module-Content-Services-V2.html#.getRecent">getRecent</a></li><li data-type='method'><a href="module-Content-Services-V2.html#.getRecommendedForYou">getRecommendedForYou</a></li><li data-type='method'><a href="module-Content-Services-V2.html#.getScheduleContentRows">getScheduleContentRows</a></li><li data-type='method'><a href="module-Content-Services-V2.html#.getTabResults">getTabResults</a></li></ul></li><li><a href="module-Railcontent-Services.html">Railcontent-Services</a><ul class='methods'><li data-type='method'><a href="module-Railcontent-Services.html#.assignModeratorToComment">assignModeratorToComment</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.closeComment">closeComment</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.countAssignmentsAndLessons">countAssignmentsAndLessons</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.createComment">createComment</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.deleteComment">deleteComment</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.deletePlaylist">deletePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.deletePlaylistItem">deletePlaylistItem</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.deletePlaylistLike">deletePlaylistLike</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.duplicatePlaylist">duplicatePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.editComment">editComment</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchAllCompletedStates">fetchAllCompletedStates</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCarouselCardData">fetchCarouselCardData</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchChallengeIndexMetadata">fetchChallengeIndexMetadata</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchChallengeLessonData">fetchChallengeLessonData</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchChallengeMetadata">fetchChallengeMetadata</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchChallengeUserActiveChallenges">fetchChallengeUserActiveChallenges</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCommentRelies">fetchCommentRelies</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchComments">fetchComments</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCompletedChallenges">fetchCompletedChallenges</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCompletedContent">fetchCompletedContent</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCompletedState">fetchCompletedState</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchContentInProgress">fetchContentInProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchContentPageUserData">fetchContentPageUserData</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchNextContentDataForParent">fetchNextContentDataForParent</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchOwnedChallenges">fetchOwnedChallenges</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPinnedPlaylists">fetchPinnedPlaylists</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPlaylist">fetchPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPlaylistItem">fetchPlaylistItem</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPlaylistItems">fetchPlaylistItems</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchSongsInProgress">fetchSongsInProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchTopComment">fetchTopComment</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchUserAward">fetchUserAward</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchUserBadges">fetchUserBadges</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchUserChallengeProgress">fetchUserChallengeProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.likeComment">likeComment</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.likePlaylist">likePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.openComment">openComment</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.pinPlaylist">pinPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesCommunityNotification">postChallengesCommunityNotification</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesCompleteLesson">postChallengesCompleteLesson</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesEnroll">postChallengesEnroll</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesEnrollmentNotification">postChallengesEnrollmentNotification</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesHideCompletedBanner">postChallengesHideCompletedBanner</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesLeave">postChallengesLeave</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesSetStartDate">postChallengesSetStartDate</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesSoloNotification">postChallengesSoloNotification</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesUnlock">postChallengesUnlock</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.replyToComment">replyToComment</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.reportPlaylist">reportPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.setStudentViewForUser">setStudentViewForUser</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.unassignModeratorToComment">unassignModeratorToComment</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.unlikeComment">unlikeComment</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.unpinPlaylist">unpinPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.updatePlaylist">updatePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.updatePlaylistItem">updatePlaylistItem</a></li></ul></li><li><a href="module-Sanity-Services.html">Sanity-Services</a><ul class='methods'><li data-type='method'><a href="module-Sanity-Services.html#.fetchAll">fetchAll</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchAllFilterOptions">fetchAllFilterOptions</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchAllPacks">fetchAllPacks</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchArtistLessons">fetchArtistLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchArtists">fetchArtists</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchByRailContentId">fetchByRailContentId</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchByRailContentIds">fetchByRailContentIds</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchByReference">fetchByReference</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchCoachLessons">fetchCoachLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchComingSoon">fetchComingSoon</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchCommentModContentData">fetchCommentModContentData</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchFoundation">fetchFoundation</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchGenreLessons">fetchGenreLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchLeaving">fetchLeaving</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchLessonContent">fetchLessonContent</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMetadata">fetchMetadata</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethod">fetchMethod</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethodChildren">fetchMethodChildren</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethodChildrenIds">fetchMethodChildrenIds</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethodPreviousNextLesson">fetchMethodPreviousNextLesson</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchNewReleases">fetchNewReleases</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchNextPreviousLesson">fetchNextPreviousLesson</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchPackAll">fetchPackAll</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchPackData">fetchPackData</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchParentForDownload">fetchParentForDownload</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchRelatedLessons">fetchRelatedLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchRelatedSongs">fetchRelatedSongs</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchReturning">fetchReturning</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSanity">fetchSanity</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchScheduledReleases">fetchScheduledReleases</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchShowsData">fetchShowsData</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSongArtistCount">fetchSongArtistCount</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSongById">fetchSongById</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchUpcomingEvents">fetchUpcomingEvents</a></li><li data-type='method'><a href="module-Sanity-Services.html#.jumpToContinueContent">jumpToContinueContent</a></li><li data-type='method'><a href="module-Sanity-Services.html#~getNextAndPreviousQuarterDates">getNextAndPreviousQuarterDates</a></li><li data-type='method'><a href="module-Sanity-Services.html#~getQueryFromPage">getQueryFromPage</a></li><li data-type='method'><a href="module-Sanity-Services.html#~handleCustomFetchAll">handleCustomFetchAll</a></li></ul></li><li><a href="module-Session-Management.html">Session-Management</a><ul class='methods'><li data-type='method'><a href="module-Session-Management.html#.login">login</a></li><li data-type='method'><a href="module-Session-Management.html#.logout">logout</a></li></ul></li><li><a href="module-User-Permissions.html">User-Permissions</a><ul class='methods'><li data-type='method'><a href="module-User-Permissions.html#.fetchUserPermissions">fetchUserPermissions</a></li><li data-type='method'><a href="module-User-Permissions.html#.reset">reset</a></li></ul></li><li><a href="module-playlists.html">playlists</a><ul class='methods'><li data-type='method'><a href="module-playlists.html#.addItemToPlaylist">addItemToPlaylist</a></li><li data-type='method'><a href="module-playlists.html#.createPlaylist">createPlaylist</a></li><li data-type='method'><a href="module-playlists.html#.fetchUserPlaylists">fetchUserPlaylists</a></li></ul></li><li></li></ul><h3>Namespaces</h3><ul><li><a href="Content-Organization.html">Content-Organization</a></li></ul><h3><a href="global.html">Global</a></h3>
33
+
34
+ </nav>
35
+
36
+ <div id="main">
37
+
38
+ <h1 class="page-title">content-org/types.js</h1>
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+ <section>
47
+ <article>
48
+ <pre class="prettyprint source linenums"><code>/**
49
+ * @module playlists
50
+ */
51
+ import '../user/types'
52
+
53
+ /**
54
+ * @typedef CreatePlaylistDTO
55
+ * @property {string} name - The name of the new playlist. (required, max 255 characters)
56
+ * @property {string} description - A description of the playlist. (optional, max 1000 characters)
57
+ * @property {string} category - The category of the playlist.
58
+ * @property {string} thumbnail_url - The URL of the playlist thumbnail. (optional, must be a valid URL)
59
+ * @property {boolean} private - Whether the playlist is private. (optional, defaults to true)
60
+ * @property {string} brand - Brand identifier for the playlist.
61
+ */
62
+
63
+ /**
64
+ * @typedef Playlist
65
+ * @property {number} id
66
+ * @property {string} brand
67
+ * @property {string} name
68
+ * @property {string} description
69
+ * @property {string|null} thumbnail_url
70
+ * @property {string} duration_formated
71
+ * @property {Array&lt;string>} first_4_items_thumbnail_url
72
+ * @property {string|null} url
73
+ * @property {string|null} playback_url
74
+ * @property {number} total_items
75
+ * @property {User} user
76
+ */
77
+
78
+ /**
79
+ * @typedef {Object} AddItemToPlaylistDTO
80
+ * @property {number} content_id - The ID of the content to add to the playlist(s).
81
+ * @property {Array&lt;number>} playlist_id - An array of playlist IDs where the content should be added.
82
+ * @property {boolean} import_full_soundslice_assignment - Flag to include full Soundslice assignments.
83
+ * @property {boolean} import_instrumentless_soundslice_assignment - Flag to include instrumentless Soundslice assignments.
84
+ * @property {boolean} import_high_routine - Flag to include high routine content.
85
+ * @property {boolean} import_low_routine - Flag to include low routine content.
86
+ * @property {boolean} import_all_assignments - Flag to include all Soundslice assignments if true.
87
+ */
88
+ </code></pre>
89
+ </article>
90
+ </section>
91
+
92
+
93
+
94
+
95
+
96
+
97
+ </div>
98
+
99
+ <br class="clear">
100
+
101
+ <footer>
102
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Thu Mar 20 2025 22:03:18 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
103
+ </footer>
104
+
105
+ <script>prettyPrint();</script>
106
+ <script src="scripts/polyfill.js"></script>
107
+ <script src="scripts/linenumber.js"></script>
108
+
109
+
110
+
111
+ </body>
112
+ </html>
@@ -0,0 +1,443 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+
5
+ <meta charset="utf-8">
6
+ <title>content.js - Documentation</title>
7
+
8
+
9
+ <script src="scripts/prettify/prettify.js"></script>
10
+ <script src="scripts/prettify/lang-css.js"></script>
11
+ <!--[if lt IE 9]>
12
+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
13
+ <![endif]-->
14
+ <link type="text/css" rel="stylesheet" href="styles/prettify.css">
15
+ <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
16
+ <script src="scripts/nav.js" defer></script>
17
+
18
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
19
+ </head>
20
+ <body>
21
+
22
+ <input type="checkbox" id="nav-trigger" class="nav-trigger" />
23
+ <label for="nav-trigger" class="navicon-button x">
24
+ <div class="navicon"></div>
25
+ </label>
26
+
27
+ <label for="nav-trigger" class="overlay"></label>
28
+
29
+ <nav >
30
+
31
+
32
+ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Config.html">Config</a><ul class='methods'><li data-type='method'><a href="module-Config.html#.initializeService">initializeService</a></li></ul></li><li><a href="module-Content-Services-V2.html">Content-Services-V2</a><ul class='methods'><li data-type='method'><a href="module-Content-Services-V2.html#.getContentRows">getContentRows</a></li><li data-type='method'><a href="module-Content-Services-V2.html#.getNewAndUpcoming">getNewAndUpcoming</a></li><li data-type='method'><a href="module-Content-Services-V2.html#.getRecent">getRecent</a></li><li data-type='method'><a href="module-Content-Services-V2.html#.getRecommendedForYou">getRecommendedForYou</a></li><li data-type='method'><a href="module-Content-Services-V2.html#.getScheduleContentRows">getScheduleContentRows</a></li><li data-type='method'><a href="module-Content-Services-V2.html#.getTabResults">getTabResults</a></li></ul></li><li><a href="module-Playlists.html">Playlists</a><ul class='methods'><li data-type='method'><a href="module-Playlists.html#.addItemToPlaylist">addItemToPlaylist</a></li><li data-type='method'><a href="module-Playlists.html#.createPlaylist">createPlaylist</a></li><li data-type='method'><a href="module-Playlists.html#.fetchUserPlaylists">fetchUserPlaylists</a></li></ul></li><li><a href="module-Railcontent-Services.html">Railcontent-Services</a><ul class='methods'><li data-type='method'><a href="module-Railcontent-Services.html#.assignModeratorToComment">assignModeratorToComment</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.closeComment">closeComment</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.countAssignmentsAndLessons">countAssignmentsAndLessons</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.createComment">createComment</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.deleteComment">deleteComment</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.deletePlaylist">deletePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.deletePlaylistItem">deletePlaylistItem</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.deletePlaylistLike">deletePlaylistLike</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.duplicatePlaylist">duplicatePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.editComment">editComment</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchAllCompletedStates">fetchAllCompletedStates</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCarouselCardData">fetchCarouselCardData</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchChallengeIndexMetadata">fetchChallengeIndexMetadata</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchChallengeLessonData">fetchChallengeLessonData</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchChallengeMetadata">fetchChallengeMetadata</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchChallengeUserActiveChallenges">fetchChallengeUserActiveChallenges</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCommentRelies">fetchCommentRelies</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchComments">fetchComments</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCompletedChallenges">fetchCompletedChallenges</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCompletedContent">fetchCompletedContent</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCompletedState">fetchCompletedState</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchContentInProgress">fetchContentInProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchContentPageUserData">fetchContentPageUserData</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchNextContentDataForParent">fetchNextContentDataForParent</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchOwnedChallenges">fetchOwnedChallenges</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPinnedPlaylists">fetchPinnedPlaylists</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPlaylist">fetchPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPlaylistItem">fetchPlaylistItem</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPlaylistItems">fetchPlaylistItems</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchSongsInProgress">fetchSongsInProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchTopComment">fetchTopComment</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchUserAward">fetchUserAward</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchUserBadges">fetchUserBadges</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchUserChallengeProgress">fetchUserChallengeProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.likeComment">likeComment</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.likePlaylist">likePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.openComment">openComment</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.pinPlaylist">pinPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesCommunityNotification">postChallengesCommunityNotification</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesCompleteLesson">postChallengesCompleteLesson</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesEnroll">postChallengesEnroll</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesEnrollmentNotification">postChallengesEnrollmentNotification</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesHideCompletedBanner">postChallengesHideCompletedBanner</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesLeave">postChallengesLeave</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesSetStartDate">postChallengesSetStartDate</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesSoloNotification">postChallengesSoloNotification</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesUnlock">postChallengesUnlock</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.replyToComment">replyToComment</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.reportPlaylist">reportPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.setStudentViewForUser">setStudentViewForUser</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.unassignModeratorToComment">unassignModeratorToComment</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.unlikeComment">unlikeComment</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.unpinPlaylist">unpinPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.updatePlaylist">updatePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.updatePlaylistItem">updatePlaylistItem</a></li></ul></li><li><a href="module-Sanity-Services.html">Sanity-Services</a><ul class='methods'><li data-type='method'><a href="module-Sanity-Services.html#.fetchAll">fetchAll</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchAllFilterOptions">fetchAllFilterOptions</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchAllPacks">fetchAllPacks</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchArtistLessons">fetchArtistLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchArtists">fetchArtists</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchByRailContentId">fetchByRailContentId</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchByRailContentIds">fetchByRailContentIds</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchByReference">fetchByReference</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchCoachLessons">fetchCoachLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchComingSoon">fetchComingSoon</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchCommentModContentData">fetchCommentModContentData</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchFoundation">fetchFoundation</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchGenreLessons">fetchGenreLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchLeaving">fetchLeaving</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchLessonContent">fetchLessonContent</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMetadata">fetchMetadata</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethod">fetchMethod</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethodChildren">fetchMethodChildren</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethodChildrenIds">fetchMethodChildrenIds</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethodPreviousNextLesson">fetchMethodPreviousNextLesson</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchNewReleases">fetchNewReleases</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchNextPreviousLesson">fetchNextPreviousLesson</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchPackAll">fetchPackAll</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchPackData">fetchPackData</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchParentForDownload">fetchParentForDownload</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchRelatedLessons">fetchRelatedLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchRelatedSongs">fetchRelatedSongs</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchReturning">fetchReturning</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSanity">fetchSanity</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchScheduledReleases">fetchScheduledReleases</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchShowsData">fetchShowsData</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSongArtistCount">fetchSongArtistCount</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSongById">fetchSongById</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchUpcomingEvents">fetchUpcomingEvents</a></li><li data-type='method'><a href="module-Sanity-Services.html#.jumpToContinueContent">jumpToContinueContent</a></li><li data-type='method'><a href="module-Sanity-Services.html#~getNextAndPreviousQuarterDates">getNextAndPreviousQuarterDates</a></li><li data-type='method'><a href="module-Sanity-Services.html#~getQueryFromPage">getQueryFromPage</a></li><li data-type='method'><a href="module-Sanity-Services.html#~handleCustomFetchAll">handleCustomFetchAll</a></li></ul></li><li><a href="module-Session-Management.html">Session-Management</a><ul class='methods'><li data-type='method'><a href="module-Session-Management.html#.login">login</a></li><li data-type='method'><a href="module-Session-Management.html#.logout">logout</a></li></ul></li><li><a href="module-User-Permissions.html">User-Permissions</a><ul class='methods'><li data-type='method'><a href="module-User-Permissions.html#.fetchUserPermissions">fetchUserPermissions</a></li><li data-type='method'><a href="module-User-Permissions.html#.reset">reset</a></li></ul></li></ul><h3>Namespaces</h3><ul><li><a href="Content-Organization.html">Content-Organization</a></li></ul><h3><a href="global.html">Global</a></h3>
33
+
34
+ </nav>
35
+
36
+ <div id="main">
37
+
38
+ <h1 class="page-title">content.js</h1>
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+ <section>
47
+ <article>
48
+ <pre class="prettyprint source linenums"><code>/**
49
+ * @module Content-Services-V2
50
+ */
51
+
52
+ import {
53
+ fetchAll,
54
+ fetchByRailContentIds,
55
+ fetchMetadata,
56
+ fetchRecent,
57
+ fetchTabData,
58
+ fetchNewReleases,
59
+ fetchUpcomingEvents,
60
+ fetchScheduledReleases,
61
+ fetchReturning,
62
+ fetchLeaving, fetchScheduledAndNewReleases
63
+ } from './sanity.js'
64
+ import {TabResponseType, Tabs, capitalizeFirstLetter} from '../contentMetaData.js'
65
+ import {getAllStartedOrCompleted} from "./contentProgress";
66
+ import {fetchHandler} from "./railcontent";
67
+ import {recommendations} from "./recommendations";
68
+
69
+ export async function getLessonContentRows (brand='drumeo', pageName = 'lessons') {
70
+ let recentContentIds = await fetchRecent(brand, pageName, { progress: 'recent' });
71
+ recentContentIds = recentContentIds.map(item => item.id);
72
+
73
+ let contentRows = await getContentRows(brand, pageName);
74
+ contentRows = Array.isArray(contentRows) ? contentRows : [];
75
+ contentRows.unshift({
76
+ id: 'recent',
77
+ title: 'Recent ' + capitalizeFirstLetter(pageName),
78
+ content: recentContentIds || []
79
+ });
80
+
81
+ const results = await Promise.all(
82
+ contentRows.map(async (row) => {
83
+ if (row.content.length == 0){
84
+ return { id: row.id, title: row.title, items: [] }
85
+ }
86
+ const data = await fetchByRailContentIds(row.content)
87
+ return { id: row.id, title: row.title, items: data }
88
+ })
89
+ )
90
+ return results
91
+ }
92
+
93
+ /**
94
+ * Get data that should be displayed for a specific tab with pagination
95
+ * @param {string} brand - The brand for which to fetch data.
96
+ * @param {string} pageName - The page name (e.g., 'lessons', 'songs','challenges).
97
+ * @param {string} tabName - The name for the selected tab. Should be same name received from fetchMetadata (e.g., 'Individuals', 'Collections','For You').
98
+ * @param {Object} params - Parameters for pagination, sorting, and filter.
99
+ * @param {number} [params.page=1] - The page number for pagination.
100
+ * @param {number} [params.limit=10] - The number of items per page.
101
+ * @param {string} [params.sort="-published_on"] - The field to sort the data by.
102
+ * @param {Array&lt;string>} [params.selectedFilters=[]] - The selected filter.
103
+ * @returns {Promise&lt;Object|null>} - The fetched content data or null if not found.
104
+ *
105
+ * @example
106
+ * getTabResults('drumeo', 'lessons','Singles', {
107
+ * page: 2,
108
+ * limit: 20,
109
+ * sort: '-popularity',
110
+ * includedFields: ['difficulty,Intermediate'],
111
+ * })
112
+ * .then(content => console.log(content))
113
+ * .catch(error => console.error(error));
114
+ */
115
+ export async function getTabResults(brand, pageName, tabName, {
116
+ page = 1,
117
+ limit = 10,
118
+ sort = 'recommended',
119
+ selectedFilters = []
120
+ } = {}) {
121
+
122
+ // Extract and handle 'progress' filter separately
123
+ const progressFilter = selectedFilters.find(f => f.startsWith('progress,')) || 'progress,all';
124
+ const progressValue = progressFilter.split(',')[1].toLowerCase();
125
+ const filteredSelectedFilters = selectedFilters.filter(f => !f.startsWith('progress,'));
126
+
127
+ // Prepare included fields
128
+ const mergedIncludedFields = [...filteredSelectedFilters, `tab,${tabName.toLowerCase()}`];
129
+
130
+ // Fetch data
131
+ const results = tabName === Tabs.ForYou.name
132
+ ? { entity: await getLessonContentRows(brand, pageName) }
133
+ : await fetchTabData(brand, pageName, { page, limit, sort, includedFields: mergedIncludedFields, progress: progressValue });
134
+
135
+ // Fetch metadata
136
+ const metaData = await fetchMetadata(brand, pageName);
137
+
138
+ // Process filters
139
+ const filters = (metaData.filters ?? []).map(filter => ({
140
+ ...filter,
141
+ items: filter.items.map(item => {
142
+ const value = item.value.split(',')[1];
143
+ return {
144
+ ...item,
145
+ selected: selectedFilters.includes(`${filter.key},${value}`) ||
146
+ (filter.key === 'progress' &amp;&amp; value === 'all' &amp;&amp; !selectedFilters.some(f => f.startsWith('progress,')))
147
+ };
148
+ })
149
+ }));
150
+
151
+ // Process sort options
152
+ const sortOptions = {
153
+ title: metaData.sort?.title ?? 'Sort By',
154
+ type: metaData.sort?.type ?? 'radio',
155
+ items: (metaData.sort?.items ?? []).map(option => ({
156
+ ...option,
157
+ selected: option.value === sort
158
+ }))
159
+ };
160
+
161
+ return {
162
+ type: tabName === Tabs.ForYou.name ? TabResponseType.SECTIONS : TabResponseType.CATALOG,
163
+ data: results.entity,
164
+ meta: { filters, sort: sortOptions }
165
+ };
166
+ }
167
+
168
+ /**
169
+ * Fetches recent content for a given brand and page with pagination.
170
+ *
171
+ * @param {string} brand - The brand for which to fetch data.
172
+ * @param {string} pageName - The page name (e.g., 'all', 'incomplete', 'completed').
173
+ * @param {string} [tabName='all'] - The tab name (defaults to 'all' for recent content).
174
+ * @param {Object} params - Parameters for pagination and sorting.
175
+ * @param {number} [params.page=1] - The page number for pagination.
176
+ * @param {number} [params.limit=10] - The number of items per page.
177
+ * @param {string} [params.sort="-published_on"] - The field to sort the data by.
178
+ * @returns {Promise&lt;Object>} - The fetched content data.
179
+ *
180
+ * @example
181
+ * getRecent('drumeo', 'lessons', 'all', {
182
+ * page: 2,
183
+ * limit: 15,
184
+ * sort: '-popularity'
185
+ * })
186
+ * .then(content => console.log(content))
187
+ * .catch(error => console.error(error));
188
+ */
189
+ export async function getRecent(brand, pageName, tabName = 'all', {
190
+ page = 1,
191
+ limit = 10,
192
+ sort = '-published_on',
193
+ } = {}) {
194
+ const progress = tabName.toLowerCase() == 'all' ? 'recent':tabName.toLowerCase();
195
+ const recentContentIds = await fetchRecent(brand, pageName, { page:page, limit:limit, progress: progress });
196
+ const metaData = await fetchMetadata(brand, 'recent');
197
+ return {
198
+ type: TabResponseType.CATALOG,
199
+ data: recentContentIds,
200
+ meta: { tabs: metaData.tabs }
201
+ };
202
+ }
203
+
204
+ /**
205
+ * Fetches content rows for a given brand and page with optional filtering by content row id.
206
+ *
207
+ * @param {string} brand - The brand for which to fetch content rows.
208
+ * @param {string} pageName - The page name (e.g., 'lessons', 'songs', 'challenges').
209
+ * @param {string} [contentRowId] - The specific content row ID to fetch.
210
+ * @param {Object} params - Parameters for pagination.
211
+ * @param {number} [params.page=1] - The page number for pagination.
212
+ * @param {number} [params.limit=10] - The maximum number of content items per row.
213
+ * @returns {Promise&lt;Object>} - The fetched content rows.
214
+ *
215
+ * @example
216
+ * getContentRows('drumeo', 'lessons', 'Your-Daily-Warmup', {
217
+ * page: 1,
218
+ * limit: 5
219
+ * })
220
+ * .then(content => console.log(content))
221
+ * .catch(error => console.error(error));
222
+ */
223
+ export async function getContentRows(brand, pageName, contentRowId , {
224
+ page = 1,
225
+ limit = 10,
226
+ } = {}) {
227
+ const contentRow = contentRowId ? `&amp;content_row_id=${contentRowId}` : ''
228
+ const url = `/api/content/v1/rows?brand=${brand}&amp;page_name=${pageName}${contentRow}&amp;page=${page}&amp;limit=${limit}`;
229
+ return await fetchHandler(url, 'get', null);
230
+ }
231
+
232
+ /**
233
+ * Fetches new and upcoming releases for a given brand with pagination options.
234
+ *
235
+ * @param {string} brand - The brand for which to fetch new and upcoming releases.
236
+ * @param {Object} [params={}] - Pagination parameters.
237
+ * @param {number} [params.page=1] - The page number for pagination.
238
+ * @param {number} [params.limit=10] - The maximum number of content items to fetch.
239
+ * @returns {Promise&lt;{ data: Object[] } | null>} - A promise that resolves to the fetched content data or `null` if no data is found.
240
+ *
241
+ * @example
242
+ * // Fetch the first page with 10 results
243
+ * getNewAndUpcoming('drumeo')
244
+ * .then(response => console.log(response))
245
+ * .catch(error => console.error(error));
246
+ *
247
+ * @example
248
+ * // Fetch the second page with 20 results
249
+ * getNewAndUpcoming('drumeo', { page: 2, limit: 20 })
250
+ * .then(response => console.log(response))
251
+ * .catch(error => console.error(error));
252
+ */
253
+ export async function getNewAndUpcoming(brand, {
254
+ page = 1,
255
+ limit = 10,
256
+ } = {}) {
257
+
258
+ const data = await fetchScheduledAndNewReleases(brand, {page: page, limit: limit});
259
+ if (!data) {
260
+ return null;
261
+ }
262
+
263
+ return {
264
+ data: data,
265
+ };
266
+ }
267
+
268
+ /**
269
+ * Fetches scheduled content rows for a given brand with optional filtering by content row ID.
270
+ *
271
+ * @param {string} brand - The brand for which to fetch content rows.
272
+ * @param {string} [contentRowId=null] - The specific content row ID to fetch (optional).
273
+ * @param {Object} [params={}] - Pagination parameters.
274
+ * @param {number} [params.page=1] - The page number for pagination.
275
+ * @param {number} [params.limit=10] - The maximum number of content items per row.
276
+ * @returns {Promise&lt;Object>} - A promise that resolves to the fetched content rows.
277
+ *
278
+ * @example
279
+ * // Fetch all sections with default pagination
280
+ * getScheduleContentRows('drumeo')
281
+ * .then(content => console.log(content))
282
+ * .catch(error => console.error(error));
283
+ *
284
+ * @example
285
+ * // Fetch only the 'New-Releases' section with custom pagination
286
+ * getScheduleContentRows('drumeo', 'New-Releases', { page: 1, limit: 30 })
287
+ * .then(content => console.log(content))
288
+ * .catch(error => console.error(error));
289
+ *
290
+ * @example
291
+ * // Fetch only the 'Live-Streams' section with unlimited results
292
+ * getScheduleContentRows('drumeo', 'Live-Streams')
293
+ * .then(content => console.log(content))
294
+ * .catch(error => console.error(error));
295
+ */
296
+ export async function getScheduleContentRows(brand, contentRowId = null, { page = 1, limit = 10 } = {}) {
297
+ const sections = {
298
+ 'New-Releases': {
299
+ title: 'New Releases',
300
+ fetchMethod: fetchNewReleases
301
+ },
302
+ 'Live-Streams': {
303
+ title: 'Live Streams',
304
+ fetchMethod: fetchUpcomingEvents
305
+ },
306
+ 'Upcoming-Releases': {
307
+ title: 'Upcoming Releases',
308
+ fetchMethod: fetchScheduledReleases
309
+ },
310
+ 'Returning-Soon': {
311
+ title: 'Returning Soon',
312
+ fetchMethod: fetchReturning
313
+ },
314
+ 'Leaving-Soon': {
315
+ title: 'Leaving Soon',
316
+ fetchMethod: fetchLeaving
317
+ }
318
+ };
319
+
320
+ if (contentRowId) {
321
+ if (!sections[contentRowId]) {
322
+ return null; // Return null if the requested section does not exist
323
+ }
324
+
325
+ const items = await sections[contentRowId].fetchMethod(brand, { page, limit });
326
+
327
+ // Fetch only the requested section
328
+ const result = {
329
+ id: contentRowId,
330
+ title: sections[contentRowId].title,
331
+ // TODO: Remove content after FE/MA updates the existing code to use items
332
+ content: items,
333
+ items: items
334
+ };
335
+
336
+ return {
337
+ type: TabResponseType.CATALOG,
338
+ data: result,
339
+ meta: {}
340
+ };
341
+ }
342
+
343
+ // If no specific contentRowId, fetch all sections
344
+ const results = await Promise.all(
345
+ Object.entries(sections).map(async ([id, section]) => {
346
+ // Apply special pagination rules
347
+ const isNewReleases = id === 'New-Releases';
348
+ const pagination = isNewReleases ? { page: 1, limit: 30 } : { page: 1, limit: Number.MAX_SAFE_INTEGER };
349
+
350
+ return {
351
+ id,
352
+ title: section.title,
353
+ content: await section.fetchMethod(brand, pagination)
354
+ };
355
+ })
356
+ );
357
+
358
+ return {
359
+ type: TabResponseType.SECTIONS,
360
+ data: results,
361
+ meta: {}
362
+ };
363
+ }
364
+
365
+ /**
366
+ * Fetches recommended content for a given brand with pagination support.
367
+ *
368
+ * @param {string} brand - The brand for which to fetch recommended content.
369
+ * @param {Object} [params={}] - Pagination parameters.
370
+ * @param {number} [params.page=1] - The page number for pagination.
371
+ * @param {number} [params.limit=10] - The maximum number of recommended content items per page.
372
+ * @returns {Promise&lt;Object>} - A promise that resolves to an object containing recommended content.
373
+ *
374
+ * @example
375
+ * // Fetch recommended content for a brand with default pagination
376
+ * getRecommendedForYou('drumeo')
377
+ * .then(content => console.log(content))
378
+ * .catch(error => console.error(error));
379
+ *
380
+ * @example
381
+ * // Fetch recommended content for a brand with custom pagination
382
+ * getRecommendedForYou('drumeo', { page: 2, limit: 5 })
383
+ * .then(content => console.log(content))
384
+ * .catch(error => console.error(error));
385
+ */
386
+ export async function getRecommendedForYou(brand, rowId = null, {
387
+ page = 1,
388
+ limit = 10,
389
+ } = {}) {
390
+ const requiredItems = page * limit;
391
+ const data = await recommendations(brand, {limit: requiredItems});
392
+ if (!data || !data.length) {
393
+ return { id: 'recommended', title: 'Recommended For You', items: [] };
394
+ }
395
+
396
+ // Apply pagination before calling fetchByRailContentIds
397
+ const startIndex = (page - 1) * limit;
398
+ const paginatedData = data.slice(startIndex, startIndex + limit);
399
+
400
+ const contents = await fetchByRailContentIds(paginatedData);
401
+ const result = {
402
+ id: 'recommended',
403
+ title: 'Recommended For You',
404
+ items: contents
405
+ };
406
+
407
+ if (rowId) {
408
+ return {
409
+ type: TabResponseType.CATALOG,
410
+ data: contents,
411
+ meta: {}
412
+ };
413
+ }
414
+
415
+ return { id: 'recommended', title: 'Recommended For You', items: contents }
416
+ }
417
+
418
+
419
+ </code></pre>
420
+ </article>
421
+ </section>
422
+
423
+
424
+
425
+
426
+
427
+
428
+ </div>
429
+
430
+ <br class="clear">
431
+
432
+ <footer>
433
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Thu Mar 20 2025 22:08:57 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
434
+ </footer>
435
+
436
+ <script>prettyPrint();</script>
437
+ <script src="scripts/polyfill.js"></script>
438
+ <script src="scripts/linenumber.js"></script>
439
+
440
+
441
+
442
+ </body>
443
+ </html>
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes