musora-content-services 1.3.18 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +16 -0
- package/CHANGELOG.md +1 -1
- package/docs/config.js.html +14 -5
- package/docs/content.js.html +425 -0
- package/docs/global.html +3026 -0
- package/docs/index.html +2 -2
- package/docs/module-Config.html +60 -7
- package/docs/module-Content-Services-V2.html +2433 -0
- package/docs/module-Railcontent-Services.html +522 -2
- package/docs/module-Sanity-Services.html +57 -43
- package/docs/module-Session-Management.html +575 -0
- package/docs/module-User-Permissions.html +406 -0
- package/docs/railcontent.js.html +42 -5
- package/docs/sanity.js.html +290 -103
- package/docs/user_permissions.js.html +110 -0
- package/docs/user_sessions.js.html +139 -0
- package/docs/user_types.js.html +188 -0
- package/jsdoc.json +2 -0
- package/package.json +1 -1
- package/publish.sh +2 -2
- package/src/contentMetaData.js +307 -1088
- package/src/contentTypeConfig.js +108 -4
- package/src/filterBuilder.js +6 -6
- package/src/index.d.ts +41 -6
- package/src/index.js +41 -6
- package/src/{services → lib}/lastUpdated.js +17 -1
- package/src/services/config.js +0 -0
- package/src/services/content.js +371 -0
- package/src/services/dataContext.js +0 -0
- package/src/services/forum.js +57 -0
- package/src/services/railcontent.js +3 -3
- package/src/services/recommendations.js +19 -0
- package/src/services/sanity.js +278 -104
- package/src/services/{userPermissions.js → user/permissions.js} +16 -2
- package/src/services/user/sessions.js +67 -0
- package/src/services/user/types.js +116 -0
- package/src/services/userActivity.js +32 -0
- package/test/content.test.js +116 -0
- package/test/contentLikes.test.js +0 -0
- package/test/contentProgress.test.js +83 -5
- package/test/forum.test.js +18 -0
- package/test/initializeTests.js +6 -1
- package/test/{lastUpdated.test.js → lib/lastUpdated.test.js} +2 -5
- package/test/sanityQueryService.test.js +66 -18
- package/test/{userPermissions.test.js → user/permissions.test.js} +3 -3
- package/tools/generate-index.cjs +16 -3
package/docs/sanity.js.html
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
<nav >
|
|
30
30
|
|
|
31
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-Railcontent-Services.html">Railcontent-Services</a><ul class='methods'><li data-type='method'><a href="module-Railcontent-Services.html#.addItemToPlaylist">addItemToPlaylist</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#.createPlaylist">createPlaylist</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#.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#.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#.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#.fetchUserPlaylists">fetchUserPlaylists</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#.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#.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#.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></ul>
|
|
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#.addItemToPlaylist">addItemToPlaylist</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#.createPlaylist">createPlaylist</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#.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#.fetchUserPlaylists">fetchUserPlaylists</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#.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#.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#.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><a href="global.html">Global</a></h3>
|
|
33
33
|
|
|
34
34
|
</nav>
|
|
35
35
|
|
|
@@ -50,7 +50,6 @@
|
|
|
50
50
|
*/
|
|
51
51
|
import {
|
|
52
52
|
artistOrInstructorName,
|
|
53
|
-
artistOrInstructorNameAsArray,
|
|
54
53
|
assignmentsField,
|
|
55
54
|
descriptionField,
|
|
56
55
|
resourcesField,
|
|
@@ -70,14 +69,13 @@ import { processMetadata, typeWithSortOrder } from '../contentMetaData.js'
|
|
|
70
69
|
import { globalConfig } from './config.js'
|
|
71
70
|
|
|
72
71
|
import {
|
|
73
|
-
fetchAllCompletedStates,
|
|
74
72
|
fetchCompletedChallenges,
|
|
75
73
|
fetchOwnedChallenges,
|
|
76
74
|
fetchNextContentDataForParent,
|
|
77
75
|
fetchHandler,
|
|
78
76
|
} from './railcontent.js'
|
|
79
77
|
import { arrayToStringRepresentation, FilterBuilder } from '../filterBuilder.js'
|
|
80
|
-
import { fetchUserPermissions } from './
|
|
78
|
+
import { fetchUserPermissions } from './user/permissions.js'
|
|
81
79
|
import { getAllCompleted, getAllStarted, getAllStartedOrCompleted } from './contentProgress.js'
|
|
82
80
|
|
|
83
81
|
/**
|
|
@@ -120,15 +118,22 @@ export async function fetchSongById(documentId) {
|
|
|
120
118
|
* @number contentPerPage
|
|
121
119
|
* @returns {Promise<Object|null>}
|
|
122
120
|
*/
|
|
123
|
-
export async function fetchLeaving(
|
|
124
|
-
|
|
125
|
-
{ pageNumber = 1, contentPerPage = 20 } = {}) {
|
|
126
|
-
const nextQuarter = getNextAndPreviousQuarterDates()['next'];
|
|
121
|
+
export async function fetchLeaving(brand, { pageNumber = 1, contentPerPage = 20 } = {}) {
|
|
122
|
+
const nextQuarter = getNextAndPreviousQuarterDates()['next']
|
|
127
123
|
const filterString = `brand == '${brand}' && quarter_removed == '${nextQuarter}'`
|
|
128
|
-
const startEndOrder = getQueryFromPage(pageNumber, contentPerPage)
|
|
129
|
-
const sortOrder = {
|
|
130
|
-
|
|
131
|
-
|
|
124
|
+
const startEndOrder = getQueryFromPage(pageNumber, contentPerPage)
|
|
125
|
+
const sortOrder = {
|
|
126
|
+
sortOrder: 'published_on desc, id desc',
|
|
127
|
+
start: startEndOrder['start'],
|
|
128
|
+
end: startEndOrder['end'],
|
|
129
|
+
}
|
|
130
|
+
const query = await buildQuery(
|
|
131
|
+
filterString,
|
|
132
|
+
{ pullFutureContent: false, availableContentStatuses: ['published'] },
|
|
133
|
+
getFieldsForContentType(),
|
|
134
|
+
sortOrder
|
|
135
|
+
)
|
|
136
|
+
return fetchSanity(query, true)
|
|
132
137
|
}
|
|
133
138
|
|
|
134
139
|
/**
|
|
@@ -139,16 +144,23 @@ export async function fetchLeaving(
|
|
|
139
144
|
* @number contentPerPage
|
|
140
145
|
* @returns {Promise<Object|null>}
|
|
141
146
|
*/
|
|
142
|
-
export async function fetchReturning(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
147
|
+
export async function fetchReturning(brand, { pageNumber = 1, contentPerPage = 20 } = {}) {
|
|
148
|
+
const nextQuarter = getNextAndPreviousQuarterDates()['next']
|
|
149
|
+
const filterString = `brand == '${brand}' && quarter_published == '${nextQuarter}'`
|
|
150
|
+
const startEndOrder = getQueryFromPage(pageNumber, contentPerPage)
|
|
151
|
+
const sortOrder = {
|
|
152
|
+
sortOrder: 'published_on desc, id desc',
|
|
153
|
+
start: startEndOrder['start'],
|
|
154
|
+
end: startEndOrder['end'],
|
|
155
|
+
}
|
|
156
|
+
const query = await buildQuery(
|
|
157
|
+
filterString,
|
|
158
|
+
{ pullFutureContent: true, availableContentStatuses: ['draft'] },
|
|
159
|
+
getFieldsForContentType('returning'),
|
|
160
|
+
sortOrder
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
return fetchSanity(query, true)
|
|
152
164
|
}
|
|
153
165
|
|
|
154
166
|
/**
|
|
@@ -159,14 +171,21 @@ export async function fetchReturning(
|
|
|
159
171
|
* @number contentPerPage
|
|
160
172
|
* @returns {Promise<Object|null>}
|
|
161
173
|
*/
|
|
162
|
-
export async function fetchComingSoon(
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
174
|
+
export async function fetchComingSoon(brand, { pageNumber = 1, contentPerPage = 20 } = {}) {
|
|
175
|
+
const filterString = `brand == '${brand}' && _type == 'song'`
|
|
176
|
+
const startEndOrder = getQueryFromPage(pageNumber, contentPerPage)
|
|
177
|
+
const sortOrder = {
|
|
178
|
+
sortOrder: 'published_on desc, id desc',
|
|
179
|
+
start: startEndOrder['start'],
|
|
180
|
+
end: startEndOrder['end'],
|
|
181
|
+
}
|
|
182
|
+
const query = await buildQuery(
|
|
183
|
+
filterString,
|
|
184
|
+
{ getFutureContentOnly: true },
|
|
185
|
+
getFieldsForContentType(),
|
|
186
|
+
sortOrder
|
|
187
|
+
)
|
|
188
|
+
return fetchSanity(query, true)
|
|
170
189
|
}
|
|
171
190
|
|
|
172
191
|
/**
|
|
@@ -175,47 +194,47 @@ export async function fetchComingSoon(
|
|
|
175
194
|
* @returns {number[]}
|
|
176
195
|
*/
|
|
177
196
|
function getQueryFromPage(pageNumber, contentPerPage) {
|
|
178
|
-
const start = contentPerPage*(pageNumber-1)
|
|
179
|
-
const end = contentPerPage*pageNumber
|
|
180
|
-
let result = []
|
|
181
|
-
result['start'] = start
|
|
182
|
-
result['end'] = end
|
|
183
|
-
return result
|
|
197
|
+
const start = contentPerPage * (pageNumber - 1)
|
|
198
|
+
const end = contentPerPage * pageNumber
|
|
199
|
+
let result = []
|
|
200
|
+
result['start'] = start
|
|
201
|
+
result['end'] = end
|
|
202
|
+
return result
|
|
184
203
|
}
|
|
185
204
|
|
|
186
205
|
/**
|
|
187
206
|
* returns array of next and previous quarter dates as strings
|
|
188
207
|
*
|
|
189
|
-
* @returns {
|
|
208
|
+
* @returns {string[]}
|
|
190
209
|
*/
|
|
191
210
|
function getNextAndPreviousQuarterDates() {
|
|
192
|
-
const january = 1
|
|
193
|
-
const april = 4
|
|
194
|
-
const july = 7
|
|
195
|
-
const october = 10
|
|
196
|
-
const month = new Date().getMonth()
|
|
197
|
-
let year = new Date().getFullYear()
|
|
198
|
-
let nextQuarter = ''
|
|
199
|
-
let prevQuarter = ''
|
|
211
|
+
const january = 1
|
|
212
|
+
const april = 4
|
|
213
|
+
const july = 7
|
|
214
|
+
const october = 10
|
|
215
|
+
const month = new Date().getMonth()
|
|
216
|
+
let year = new Date().getFullYear()
|
|
217
|
+
let nextQuarter = ''
|
|
218
|
+
let prevQuarter = ''
|
|
200
219
|
if (month < april) {
|
|
201
|
-
nextQuarter = `${year}-0${april}-01
|
|
202
|
-
prevQuarter = `${year}-0${january}-01
|
|
220
|
+
nextQuarter = `${year}-0${april}-01`
|
|
221
|
+
prevQuarter = `${year}-0${january}-01`
|
|
203
222
|
} else if (month < july) {
|
|
204
|
-
nextQuarter = `${year}-0${july}-01
|
|
205
|
-
prevQuarter = `${year}-0${april}-01
|
|
223
|
+
nextQuarter = `${year}-0${july}-01`
|
|
224
|
+
prevQuarter = `${year}-0${april}-01`
|
|
206
225
|
} else if (month < october) {
|
|
207
|
-
nextQuarter = `${year}-${october}-01
|
|
208
|
-
prevQuarter = `${year}-0${july}-01
|
|
226
|
+
nextQuarter = `${year}-${october}-01`
|
|
227
|
+
prevQuarter = `${year}-0${july}-01`
|
|
209
228
|
} else {
|
|
210
|
-
prevQuarter = `${year}-${october}-01
|
|
211
|
-
year
|
|
212
|
-
nextQuarter = `${year}-0${january}-01
|
|
229
|
+
prevQuarter = `${year}-${october}-01`
|
|
230
|
+
year++
|
|
231
|
+
nextQuarter = `${year}-0${january}-01`
|
|
213
232
|
}
|
|
214
233
|
|
|
215
|
-
let result = []
|
|
216
|
-
result['next'] = nextQuarter
|
|
217
|
-
result['previous'] = prevQuarter
|
|
218
|
-
return result
|
|
234
|
+
let result = []
|
|
235
|
+
result['next'] = nextQuarter
|
|
236
|
+
result['previous'] = prevQuarter
|
|
237
|
+
return result
|
|
219
238
|
}
|
|
220
239
|
|
|
221
240
|
/**
|
|
@@ -249,8 +268,8 @@ export async function fetchArtists(brand) {
|
|
|
249
268
|
*/
|
|
250
269
|
export async function fetchSongArtistCount(brand) {
|
|
251
270
|
const filter = await new FilterBuilder(
|
|
252
|
-
|
|
253
|
-
|
|
271
|
+
`_type == "song" && brand == "${brand}" && references(^._id)`,
|
|
272
|
+
{ bypassPermissions: true }
|
|
254
273
|
).buildFilter()
|
|
255
274
|
const query = `
|
|
256
275
|
count(*[_type == "artist"]{
|
|
@@ -260,13 +279,13 @@ export async function fetchSongArtistCount(brand) {
|
|
|
260
279
|
return fetchSanity(query, true, { processNeedAccess: false })
|
|
261
280
|
}
|
|
262
281
|
|
|
263
|
-
export async function fetchPlayAlongsCount(
|
|
264
|
-
|
|
265
|
-
includedFields,
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
|
|
282
|
+
export async function fetchPlayAlongsCount(
|
|
283
|
+
brand,
|
|
284
|
+
{ searchTerm, includedFields, progressIds, progress }
|
|
285
|
+
) {
|
|
286
|
+
const searchFilter = searchTerm
|
|
287
|
+
? `&& (artist->name match "${searchTerm}*" || instructor[]->name match "${searchTerm}*" || title match "${searchTerm}*" || name match "${searchTerm}*")`
|
|
288
|
+
: ''
|
|
270
289
|
|
|
271
290
|
// Construct the included fields filter, replacing 'difficulty' with 'difficulty_string'
|
|
272
291
|
const includedFieldsFilter = includedFields.length > 0 ? filtersToGroq(includedFields) : ''
|
|
@@ -302,6 +321,7 @@ export async function fetchRelatedSongs(brand, songId) {
|
|
|
302
321
|
"published_on": published_on,
|
|
303
322
|
status,
|
|
304
323
|
"image": thumbnail.asset->url,
|
|
324
|
+
"permission_id": permission[]->railcontent_id,
|
|
305
325
|
"fields": [
|
|
306
326
|
{
|
|
307
327
|
"key": "title",
|
|
@@ -327,6 +347,7 @@ export async function fetchRelatedSongs(brand, songId) {
|
|
|
327
347
|
"id": railcontent_id,
|
|
328
348
|
"url": web_url_path,
|
|
329
349
|
"published_on": published_on,
|
|
350
|
+
"permission_id": permission[]->railcontent_id,
|
|
330
351
|
status,
|
|
331
352
|
"fields": [
|
|
332
353
|
{
|
|
@@ -372,7 +393,8 @@ export async function fetchNewReleases(
|
|
|
372
393
|
const start = (page - 1) * limit
|
|
373
394
|
const end = start + limit
|
|
374
395
|
const sortOrder = getSortOrder(sort, brand)
|
|
375
|
-
const
|
|
396
|
+
const nextQuarter = getNextAndPreviousQuarterDates()['next']
|
|
397
|
+
const filter = `_type in ${typesString} && brand == '${brand}' && show_in_new_feed == true && (!defined(quarter_published) || quarter_published != '${nextQuarter}')`
|
|
376
398
|
const fields = `
|
|
377
399
|
"id": railcontent_id,
|
|
378
400
|
title,
|
|
@@ -534,7 +556,7 @@ export async function fetchByRailContentId(id, contentType) {
|
|
|
534
556
|
*/
|
|
535
557
|
export async function fetchByRailContentIds(ids, contentType = undefined) {
|
|
536
558
|
if (!ids) {
|
|
537
|
-
return []
|
|
559
|
+
return []
|
|
538
560
|
}
|
|
539
561
|
const idsString = ids.join(',')
|
|
540
562
|
|
|
@@ -635,6 +657,8 @@ export async function fetchAll(
|
|
|
635
657
|
if (type === 'archives') {
|
|
636
658
|
typeFilter = `&& status == "archived"`
|
|
637
659
|
bypassStatusAndPublishedValidation = true
|
|
660
|
+
} else if (type === 'lessons' || type === 'songs') {
|
|
661
|
+
typeFilter = ``
|
|
638
662
|
} else if (type === 'pack') {
|
|
639
663
|
typeFilter = `&& (_type == 'pack' || _type == 'semester-pack')`
|
|
640
664
|
} else {
|
|
@@ -902,6 +926,14 @@ async function getProgressFilter(progress, progressIds) {
|
|
|
902
926
|
const ids = await getAllStartedOrCompleted()
|
|
903
927
|
return `&& !(railcontent_id in [${ids.join(',')}])`
|
|
904
928
|
}
|
|
929
|
+
case 'recent': {
|
|
930
|
+
const ids = await getAllStartedOrCompleted()
|
|
931
|
+
return `&& (railcontent_id in [${ids.join(',')}])`
|
|
932
|
+
}
|
|
933
|
+
case 'incomplete': {
|
|
934
|
+
const ids = await getAllStarted()
|
|
935
|
+
return `&& railcontent_id in [${ids.join(',')}]`
|
|
936
|
+
}
|
|
905
937
|
default:
|
|
906
938
|
throw new Error(`'${progress}' progress option not implemented`)
|
|
907
939
|
}
|
|
@@ -977,6 +1009,13 @@ export async function fetchAllFilterOptions(
|
|
|
977
1009
|
coachId,
|
|
978
1010
|
includeTabs = false
|
|
979
1011
|
) {
|
|
1012
|
+
if (contentType == 'lessons' || contentType == 'songs') {
|
|
1013
|
+
const metaData = processMetadata(brand, contentType, true)
|
|
1014
|
+
return {
|
|
1015
|
+
meta: metaData,
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
|
|
980
1019
|
if (coachId && contentType !== 'coach-lessons') {
|
|
981
1020
|
throw new Error(
|
|
982
1021
|
`Invalid contentType: '${contentType}' for coachId. It must be 'coach-lessons'.`
|
|
@@ -1255,26 +1294,26 @@ export async function fetchLessonContent(railContentId) {
|
|
|
1255
1294
|
// Format changes made to the `fields` object may also need to be reflected in Musora-web-platform SanityGateway.php $fields object
|
|
1256
1295
|
// Currently only for challenges and challenge lessons
|
|
1257
1296
|
// If you're unsure, message Adrian, or just add them.
|
|
1258
|
-
const fields = `title,
|
|
1297
|
+
const fields = `title,
|
|
1259
1298
|
published_on,
|
|
1260
|
-
"type":_type,
|
|
1299
|
+
"type":_type,
|
|
1261
1300
|
"resources": ${resourcesField},
|
|
1262
|
-
difficulty,
|
|
1263
|
-
difficulty_string,
|
|
1264
|
-
brand,
|
|
1301
|
+
difficulty,
|
|
1302
|
+
difficulty_string,
|
|
1303
|
+
brand,
|
|
1265
1304
|
status,
|
|
1266
|
-
soundslice,
|
|
1267
|
-
instrumentless,
|
|
1268
|
-
railcontent_id,
|
|
1269
|
-
"id":railcontent_id,
|
|
1305
|
+
soundslice,
|
|
1306
|
+
instrumentless,
|
|
1307
|
+
railcontent_id,
|
|
1308
|
+
"id":railcontent_id,
|
|
1270
1309
|
slug, artist->,
|
|
1271
|
-
"thumbnail_url":thumbnail.asset->url,
|
|
1272
|
-
"url": web_url_path,
|
|
1310
|
+
"thumbnail_url":thumbnail.asset->url,
|
|
1311
|
+
"url": web_url_path,
|
|
1273
1312
|
soundslice_slug,
|
|
1274
1313
|
"description": description[0].children[0].text,
|
|
1275
1314
|
"chapters": chapter[]{
|
|
1276
1315
|
chapter_description,
|
|
1277
|
-
chapter_timecode,
|
|
1316
|
+
chapter_timecode,
|
|
1278
1317
|
"chapter_thumbnail_url": chapter_thumbnail_url.asset->url
|
|
1279
1318
|
},
|
|
1280
1319
|
"instructors":instructor[]->name,
|
|
@@ -1282,7 +1321,7 @@ export async function fetchLessonContent(railContentId) {
|
|
|
1282
1321
|
"id":railcontent_id,
|
|
1283
1322
|
name,
|
|
1284
1323
|
short_bio,
|
|
1285
|
-
"biography": short_bio[0].children[0].text,
|
|
1324
|
+
"biography": short_bio[0].children[0].text,
|
|
1286
1325
|
web_url_path,
|
|
1287
1326
|
"coach_card_image": coach_card_image.asset->url,
|
|
1288
1327
|
"coach_profile_image":thumbnail_url.asset->url
|
|
@@ -1303,11 +1342,22 @@ export async function fetchLessonContent(railContentId) {
|
|
|
1303
1342
|
"type": *[railcontent_id == ^.id][0]._type,
|
|
1304
1343
|
},
|
|
1305
1344
|
sort,
|
|
1306
|
-
xp
|
|
1345
|
+
xp,
|
|
1346
|
+
stbs,ds2stbs, bdsStbs`
|
|
1307
1347
|
const query = await buildQuery(`railcontent_id == ${railContentId}`, filterParams, fields, {
|
|
1308
1348
|
isSingle: true,
|
|
1309
1349
|
})
|
|
1310
|
-
|
|
1350
|
+
const chapterProcess = (result) => {
|
|
1351
|
+
const chapters = result.chapters ?? []
|
|
1352
|
+
if (chapters.length == 0) return result
|
|
1353
|
+
result.chapters = chapters.map((chapter, index) => ({
|
|
1354
|
+
...chapter,
|
|
1355
|
+
chapter_thumbnail_url: `https://musora-web-platform.s3.amazonaws.com/chapters/${result.brand}/Chapter${index + 1}.jpg`,
|
|
1356
|
+
}))
|
|
1357
|
+
return result
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
return fetchSanity(query, false, { customPostProcess: chapterProcess })
|
|
1311
1361
|
}
|
|
1312
1362
|
|
|
1313
1363
|
/**
|
|
@@ -1386,7 +1436,7 @@ export async function fetchPackAll(railcontentId, type = 'pack') {
|
|
|
1386
1436
|
return fetchByRailContentId(railcontentId, type)
|
|
1387
1437
|
}
|
|
1388
1438
|
|
|
1389
|
-
export async function fetchLiveEvent(brand) {
|
|
1439
|
+
export async function fetchLiveEvent(brand, forcedContentId = null) {
|
|
1390
1440
|
//calendarIDs taken from addevent.php
|
|
1391
1441
|
// TODO import instructor calendars to Sanity
|
|
1392
1442
|
let defaultCalendarID = ''
|
|
@@ -1414,7 +1464,9 @@ export async function fetchLiveEvent(brand) {
|
|
|
1414
1464
|
// See LiveStreamEventService.getCurrentOrNextLiveEvent for some nice complicated logic which I don't think is actually importart
|
|
1415
1465
|
// this has some +- on times
|
|
1416
1466
|
// But this query just finds the first scheduled event (sorted by start_time) that ends after now()
|
|
1417
|
-
const query =
|
|
1467
|
+
const query =
|
|
1468
|
+
forcedContentId !== null
|
|
1469
|
+
? `*[railcontent_id == ${forcedContentId} ]{
|
|
1418
1470
|
'slug': slug.current,
|
|
1419
1471
|
'id': railcontent_id,
|
|
1420
1472
|
live_event_start_time,
|
|
@@ -1425,13 +1477,36 @@ export async function fetchLiveEvent(brand) {
|
|
|
1425
1477
|
'event_coach_url' : instructor[0]->web_url_path,
|
|
1426
1478
|
'event_coach_calendar_id': coalesce(calendar_id, '${defaultCalendarID}'),
|
|
1427
1479
|
title,
|
|
1428
|
-
"
|
|
1480
|
+
"thumbnail": thumbnail.asset->url,
|
|
1481
|
+
${artistOrInstructorName()},
|
|
1482
|
+
difficulty_string,
|
|
1483
|
+
"instructors": instructor[]->{
|
|
1484
|
+
name,
|
|
1485
|
+
web_url_path,
|
|
1486
|
+
},
|
|
1487
|
+
'videoId': coalesce(live_event_youtube_id, video.external_id),
|
|
1488
|
+
} | order(live_event_start_time)[0...1]`
|
|
1489
|
+
: `*[status == 'scheduled' && brand == '${brand}' && defined(live_event_start_time) && live_event_start_time <= '${getSanityDate(startDateTemp, false)}' && live_event_end_time >= '${getSanityDate(endDateTemp, false)}']{
|
|
1490
|
+
'slug': slug.current,
|
|
1491
|
+
'id': railcontent_id,
|
|
1492
|
+
live_event_start_time,
|
|
1493
|
+
live_event_end_time,
|
|
1494
|
+
live_event_youtube_id,
|
|
1495
|
+
railcontent_id,
|
|
1496
|
+
published_on,
|
|
1497
|
+
'event_coach_url' : instructor[0]->web_url_path,
|
|
1498
|
+
'event_coach_calendar_id': coalesce(calendar_id, '${defaultCalendarID}'),
|
|
1499
|
+
title,
|
|
1500
|
+
"thumbnail": thumbnail.asset->url,
|
|
1501
|
+
${artistOrInstructorName()},
|
|
1502
|
+
difficulty_string,
|
|
1429
1503
|
"instructors": instructor[]->{
|
|
1430
1504
|
name,
|
|
1431
1505
|
web_url_path,
|
|
1432
1506
|
},
|
|
1433
1507
|
'videoId': coalesce(live_event_youtube_id, video.external_id),
|
|
1434
1508
|
} | order(live_event_start_time)[0...1]`
|
|
1509
|
+
|
|
1435
1510
|
return await fetchSanity(query, false, { processNeedAccess: false })
|
|
1436
1511
|
}
|
|
1437
1512
|
|
|
@@ -1594,10 +1669,10 @@ export async function fetchArtistLessons(
|
|
|
1594
1669
|
progressIds !== undefined ? `&& railcontent_id in [${progressIds.join(',')}]` : ''
|
|
1595
1670
|
const now = getSanityDate(new Date())
|
|
1596
1671
|
const query = `{
|
|
1597
|
-
"entity":
|
|
1672
|
+
"entity":
|
|
1598
1673
|
*[_type == 'artist' && name == '${name}']
|
|
1599
|
-
{'type': _type, name, 'thumbnail_url':thumbnail_url.asset->url,
|
|
1600
|
-
'lessons_count': count(*[${addType} brand == '${brand}' && references(^._id)]),
|
|
1674
|
+
{'type': _type, name, 'thumbnail_url':thumbnail_url.asset->url,
|
|
1675
|
+
'lessons_count': count(*[${addType} brand == '${brand}' && references(^._id)]),
|
|
1601
1676
|
'lessons': *[${addType} brand == '${brand}' && references(^._id) && (status in ['published'] || (status == 'scheduled' && defined(published_on) && published_on >= '${now}')) ${searchFilter} ${includedFieldsFilter} ${progressFilter}]{${fieldsString}}
|
|
1602
1677
|
[${start}...${end}]}
|
|
1603
1678
|
|order(${sortOrder})
|
|
@@ -1648,10 +1723,10 @@ export async function fetchGenreLessons(
|
|
|
1648
1723
|
progressIds !== undefined ? `&& railcontent_id in [${progressIds.join(',')}]` : ''
|
|
1649
1724
|
const now = getSanityDate(new Date())
|
|
1650
1725
|
const query = `{
|
|
1651
|
-
"entity":
|
|
1726
|
+
"entity":
|
|
1652
1727
|
*[_type == 'genre' && name == '${name}']
|
|
1653
|
-
{'type': _type, name, 'thumbnail_url':thumbnail_url.asset->url,
|
|
1654
|
-
'lessons_count': count(*[${addType} brand == '${brand}' && references(^._id)]),
|
|
1728
|
+
{'type': _type, name, 'thumbnail_url':thumbnail_url.asset->url,
|
|
1729
|
+
'lessons_count': count(*[${addType} brand == '${brand}' && references(^._id)]),
|
|
1655
1730
|
'lessons': *[${addType} brand == '${brand}' && references(^._id) && (status in ['published'] || (status == 'scheduled' && defined(published_on) && published_on >= '${now}')) ${searchFilter} ${includedFieldsFilter} ${progressFilter}]{${fieldsString}}
|
|
1656
1731
|
[${start}...${end}]}
|
|
1657
1732
|
|order(${sortOrder})
|
|
@@ -1671,8 +1746,8 @@ export async function fetchTopLevelParentId(railcontentId) {
|
|
|
1671
1746
|
'parents': *[^._id in child[]._ref ${statusFilter}]{
|
|
1672
1747
|
railcontent_id,
|
|
1673
1748
|
'parents': *[^._id in child[]._ref ${statusFilter}]{
|
|
1674
|
-
railcontent_id,
|
|
1675
|
-
}
|
|
1749
|
+
railcontent_id,
|
|
1750
|
+
}
|
|
1676
1751
|
}
|
|
1677
1752
|
}
|
|
1678
1753
|
}
|
|
@@ -1706,8 +1781,8 @@ export async function fetchHierarchy(railcontentId) {
|
|
|
1706
1781
|
railcontent_id,
|
|
1707
1782
|
'assignments': assignment[]{railcontent_id},
|
|
1708
1783
|
'children': child[${childrenFilter}]->{
|
|
1709
|
-
railcontent_id,
|
|
1710
|
-
}
|
|
1784
|
+
railcontent_id,
|
|
1785
|
+
}
|
|
1711
1786
|
}
|
|
1712
1787
|
}
|
|
1713
1788
|
},
|
|
@@ -1923,6 +1998,7 @@ export async function fetchShowsData(brand) {
|
|
|
1923
1998
|
|
|
1924
1999
|
/**
|
|
1925
2000
|
* Fetch metadata from the contentMetaData.js based on brand and type.
|
|
2001
|
+
* For v2 you need to provide page type('lessons' or 'songs') in type parameter
|
|
1926
2002
|
*
|
|
1927
2003
|
* @param {string} brand - The brand for which to fetch metadata.
|
|
1928
2004
|
* @param {string} type - The type for which to fetch metadata.
|
|
@@ -2007,7 +2083,7 @@ function checkSanityConfig(config) {
|
|
|
2007
2083
|
function buildRawQuery(
|
|
2008
2084
|
filter = '',
|
|
2009
2085
|
fields = '...',
|
|
2010
|
-
{ sortOrder = 'published_on desc', start = 0, end = 10, isSingle = false}
|
|
2086
|
+
{ sortOrder = 'published_on desc', start = 0, end = 10, isSingle = false }
|
|
2011
2087
|
) {
|
|
2012
2088
|
const sortString = sortOrder ? `order(${sortOrder})` : ''
|
|
2013
2089
|
const countString = isSingle ? '[0...1]' : `[${start}...${end}]`
|
|
@@ -2021,10 +2097,10 @@ async function buildQuery(
|
|
|
2021
2097
|
baseFilter = '',
|
|
2022
2098
|
filterParams = { pullFutureContent: false },
|
|
2023
2099
|
fields = '...',
|
|
2024
|
-
{ sortOrder = 'published_on desc', start = 0, end = 10, isSingle = false}
|
|
2100
|
+
{ sortOrder = 'published_on desc', start = 0, end = 10, isSingle = false }
|
|
2025
2101
|
) {
|
|
2026
2102
|
const filter = await new FilterBuilder(baseFilter, filterParams).buildFilter()
|
|
2027
|
-
return buildRawQuery(filter, fields, { sortOrder, start, end, isSingle})
|
|
2103
|
+
return buildRawQuery(filter, fields, { sortOrder, start, end, isSingle })
|
|
2028
2104
|
}
|
|
2029
2105
|
|
|
2030
2106
|
function buildEntityAndTotalQuery(
|
|
@@ -2035,7 +2111,7 @@ function buildEntityAndTotalQuery(
|
|
|
2035
2111
|
const sortString = sortOrder ? `order(${sortOrder})` : ''
|
|
2036
2112
|
const countString = isSingle ? '[0...1]' : `[${start}...${end}]`
|
|
2037
2113
|
const query = `{
|
|
2038
|
-
"entity": *[${filter}] | ${sortString}${countString}
|
|
2114
|
+
"entity": *[${filter}] | ${sortString}${countString}
|
|
2039
2115
|
{
|
|
2040
2116
|
${fields}
|
|
2041
2117
|
},
|
|
@@ -2050,7 +2126,7 @@ function getFilterOptions(option, commonFilter, contentType, brand) {
|
|
|
2050
2126
|
|
|
2051
2127
|
switch (option) {
|
|
2052
2128
|
case 'difficulty':
|
|
2053
|
-
filterGroq = `
|
|
2129
|
+
filterGroq = `
|
|
2054
2130
|
"difficulty": [
|
|
2055
2131
|
{"type": "All", "count": count(*[${commonFilter} && difficulty_string == "All"])},
|
|
2056
2132
|
{"type": "Introductory", "count": count(*[${commonFilter} && (difficulty_string == "Novice" || difficulty_string == "Introductory")])},
|
|
@@ -2137,6 +2213,117 @@ function cleanUpGroq(query) {
|
|
|
2137
2213
|
|
|
2138
2214
|
return cleanedQuery
|
|
2139
2215
|
}
|
|
2216
|
+
|
|
2217
|
+
// V2 methods
|
|
2218
|
+
|
|
2219
|
+
export async function fetchTabData(
|
|
2220
|
+
brand,
|
|
2221
|
+
pageName,
|
|
2222
|
+
{
|
|
2223
|
+
page = 1,
|
|
2224
|
+
limit = 10,
|
|
2225
|
+
sort = '-published_on',
|
|
2226
|
+
includedFields = [],
|
|
2227
|
+
progressIds = undefined,
|
|
2228
|
+
progress = 'all',
|
|
2229
|
+
} = {}
|
|
2230
|
+
) {
|
|
2231
|
+
const start = (page - 1) * limit
|
|
2232
|
+
const end = start + limit
|
|
2233
|
+
|
|
2234
|
+
// Construct the included fields filter, replacing 'difficulty' with 'difficulty_string'
|
|
2235
|
+
const includedFieldsFilter =
|
|
2236
|
+
includedFields.length > 0 ? filtersToGroq(includedFields, [], pageName) : ''
|
|
2237
|
+
|
|
2238
|
+
// limits the results to supplied progressIds for started & completed filters
|
|
2239
|
+
const progressFilter = await getProgressFilter(progress, progressIds)
|
|
2240
|
+
|
|
2241
|
+
// Determine the sort order
|
|
2242
|
+
const sortOrder = getSortOrder(sort, brand, '')
|
|
2243
|
+
|
|
2244
|
+
let fields = DEFAULT_FIELDS
|
|
2245
|
+
let fieldsString = fields.join(',')
|
|
2246
|
+
|
|
2247
|
+
// Determine the group by clause
|
|
2248
|
+
let query = ''
|
|
2249
|
+
let entityFieldsString = ''
|
|
2250
|
+
let filter = ''
|
|
2251
|
+
|
|
2252
|
+
filter = `brand == "${brand}" ${includedFieldsFilter} ${progressFilter}`
|
|
2253
|
+
const childrenFilter = await new FilterBuilder(``, { isChildrenFilter: true }).buildFilter()
|
|
2254
|
+
entityFieldsString = ` ${fieldsString},
|
|
2255
|
+
'lesson_count': coalesce(count(child[${childrenFilter}]->), 0) ,
|
|
2256
|
+
'length_in_seconds': coalesce(
|
|
2257
|
+
math::sum(
|
|
2258
|
+
select(
|
|
2259
|
+
child[${childrenFilter}]->length_in_seconds
|
|
2260
|
+
)
|
|
2261
|
+
),
|
|
2262
|
+
length_in_seconds
|
|
2263
|
+
),`
|
|
2264
|
+
|
|
2265
|
+
const filterWithRestrictions = await new FilterBuilder(filter, {}).buildFilter()
|
|
2266
|
+
query = buildEntityAndTotalQuery(filterWithRestrictions, entityFieldsString, {
|
|
2267
|
+
sortOrder: sortOrder,
|
|
2268
|
+
start: start,
|
|
2269
|
+
end: end,
|
|
2270
|
+
})
|
|
2271
|
+
|
|
2272
|
+
return fetchSanity(query, true)
|
|
2273
|
+
}
|
|
2274
|
+
|
|
2275
|
+
export async function fetchRecent(
|
|
2276
|
+
brand,
|
|
2277
|
+
pageName,
|
|
2278
|
+
{ page = 1, limit = 10, sort = '-published_on', includedFields = [], progress = 'recent' } = {}
|
|
2279
|
+
) {
|
|
2280
|
+
const mergedIncludedFields = [...includedFields, `tab,all`]
|
|
2281
|
+
const results = await fetchTabData(brand, pageName, {
|
|
2282
|
+
page,
|
|
2283
|
+
limit,
|
|
2284
|
+
sort,
|
|
2285
|
+
includedFields: mergedIncludedFields,
|
|
2286
|
+
progress: progress.toLowerCase(),
|
|
2287
|
+
})
|
|
2288
|
+
return results.entity
|
|
2289
|
+
}
|
|
2290
|
+
|
|
2291
|
+
export async function fetchScheduledAndNewReleases(
|
|
2292
|
+
brand,
|
|
2293
|
+
{ page = 1, limit = 20, sort = '-published_on' } = {}
|
|
2294
|
+
) {
|
|
2295
|
+
const upcomingTypes = getUpcomingEventsTypes(brand)
|
|
2296
|
+
const newTypes = getNewReleasesTypes(brand)
|
|
2297
|
+
|
|
2298
|
+
const scheduledTypes = merge(upcomingTypes, newTypes)
|
|
2299
|
+
const typesString = arrayJoinWithQuotes(scheduledTypes)
|
|
2300
|
+
const now = getSanityDate(new Date())
|
|
2301
|
+
|
|
2302
|
+
const start = (page - 1) * limit
|
|
2303
|
+
const end = start + limit
|
|
2304
|
+
const sortOrder = getSortOrder(sort, brand)
|
|
2305
|
+
|
|
2306
|
+
const query = `
|
|
2307
|
+
*[_type in [${typesString}] && brand == '${brand}' && ((status in ['published','scheduled'] && published_on > '${now}')||(show_in_new_feed == true)) ]
|
|
2308
|
+
[${start}...${end}]
|
|
2309
|
+
| order(published_on asc) {
|
|
2310
|
+
"id": railcontent_id,
|
|
2311
|
+
title,
|
|
2312
|
+
"image": thumbnail.asset->url,
|
|
2313
|
+
${artistOrInstructorName()},
|
|
2314
|
+
"artists": instructor[]->name,
|
|
2315
|
+
difficulty,
|
|
2316
|
+
difficulty_string,
|
|
2317
|
+
length_in_seconds,
|
|
2318
|
+
published_on,
|
|
2319
|
+
"type": _type,
|
|
2320
|
+
show_in_new_feed,
|
|
2321
|
+
web_url_path,
|
|
2322
|
+
"permission_id": permission[]->railcontent_id
|
|
2323
|
+
}`
|
|
2324
|
+
|
|
2325
|
+
return fetchSanity(query, true)
|
|
2326
|
+
}
|
|
2140
2327
|
</code></pre>
|
|
2141
2328
|
</article>
|
|
2142
2329
|
</section>
|
|
@@ -2151,7 +2338,7 @@ function cleanUpGroq(query) {
|
|
|
2151
2338
|
<br class="clear">
|
|
2152
2339
|
|
|
2153
2340
|
<footer>
|
|
2154
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on
|
|
2341
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Thu Mar 13 2025 09:07:06 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
2155
2342
|
</footer>
|
|
2156
2343
|
|
|
2157
2344
|
<script>prettyPrint();</script>
|