musora-content-services 1.0.206 → 1.0.208
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/docs/config.js.html +2 -2
- package/docs/index.html +2 -2
- package/docs/module-Config.html +2 -2
- package/docs/module-Railcontent-Services.html +1703 -866
- package/docs/module-Sanity-Services.html +682 -48
- package/docs/railcontent.js.html +88 -7
- package/docs/sanity.js.html +217 -36
- package/link_mcs.sh +0 -0
- package/package.json +1 -1
- package/src/contentMetaData.js +0 -0
- package/src/filterBuilder.js +1 -2
- package/src/index.d.ts +2 -0
- package/src/index.js +2 -0
- package/src/services/contentProgress.js +0 -0
- package/src/services/dataContext.js +0 -0
- package/src/services/railcontent.js +13 -0
- package/src/services/sanity.js +1 -1
- package/test/contentProgress.test.js +0 -0
- package/test/live/contentProgressLive.test.js +0 -0
- package/test/live/railcontentLive.test.js +0 -0
- package/test/sanityQueryService.test.js +7 -6
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#.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#.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#.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#.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#.postChallengesUnlock">postChallengesUnlock</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#.fetchAllSongs">fetchAllSongs</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#.fetchAssignments">fetchAssignments</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#.fetchCatalogMetadata">fetchCatalogMetadata</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchChallengeOverview">fetchChallengeOverview</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchChildren">fetchChildren</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#.fetchCommentModContentData">fetchCommentModContentData</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchCourseOverview">fetchCourseOverview</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#.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#.fetchMethodNextLesson">fetchMethodNextLesson</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#.fetchMethods">fetchMethods</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#.fetchPackChildren">fetchPackChildren</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#.fetchParentByRailContentId">fetchParentByRailContentId</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#.fetchRelatedMethodLessons">fetchRelatedMethodLessons</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#.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#.fetchSongCount">fetchSongCount</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSongFilterOptions">fetchSongFilterOptions</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#.fetchWorkouts">fetchWorkouts</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-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#.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#.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#.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#.fetchAllSongs">fetchAllSongs</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#.fetchAssignments">fetchAssignments</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#.fetchCatalogMetadata">fetchCatalogMetadata</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchChallengeOverview">fetchChallengeOverview</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchChildren">fetchChildren</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#.fetchCommentModContentData">fetchCommentModContentData</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchCourseOverview">fetchCourseOverview</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#.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#.fetchMethodNextLesson">fetchMethodNextLesson</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#.fetchMethods">fetchMethods</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#.fetchPackChildren">fetchPackChildren</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#.fetchParentByRailContentId">fetchParentByRailContentId</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#.fetchRelatedMethodLessons">fetchRelatedMethodLessons</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#.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#.fetchSongCount">fetchSongCount</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSongFilterOptions">fetchSongFilterOptions</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#.fetchWorkouts">fetchWorkouts</a></li><li data-type='method'><a href="module-Sanity-Services.html#~handleCustomFetchAll">handleCustomFetchAll</a></li></ul></li></ul>
|
|
33
33
|
|
|
34
34
|
</nav>
|
|
35
35
|
|
|
@@ -70,7 +70,12 @@ import {
|
|
|
70
70
|
|
|
71
71
|
import {globalConfig} from "./config";
|
|
72
72
|
|
|
73
|
-
import {
|
|
73
|
+
import {
|
|
74
|
+
fetchAllCompletedStates,
|
|
75
|
+
fetchCompletedChallenges,
|
|
76
|
+
fetchCurrentSongComplete,
|
|
77
|
+
fetchOwnedChallenges
|
|
78
|
+
} from './railcontent.js';
|
|
74
79
|
import {arrayToStringRepresentation, FilterBuilder} from "../filterBuilder";
|
|
75
80
|
import {fetchUserPermissions} from "./userPermissions";
|
|
76
81
|
import {getAllCompleted, getAllStarted, getAllStartedOrCompleted} from "./contentProgress";
|
|
@@ -80,7 +85,7 @@ import {getAllCompleted, getAllStarted, getAllStartedOrCompleted} from "./conten
|
|
|
80
85
|
*
|
|
81
86
|
* @type {string[]}
|
|
82
87
|
*/
|
|
83
|
-
const excludeFromGeneratedIndex = [];
|
|
88
|
+
const excludeFromGeneratedIndex = ['handleCustomFetchAll'];
|
|
84
89
|
|
|
85
90
|
/**
|
|
86
91
|
* Fetch a song by its document ID from Sanity.
|
|
@@ -326,7 +331,7 @@ export async function fetchNewReleases(brand, {page = 1, limit = 20, sort = "-pu
|
|
|
326
331
|
const typesString = arrayToStringRepresentation(newTypes);
|
|
327
332
|
const start = (page - 1) * limit;
|
|
328
333
|
const end = start + limit;
|
|
329
|
-
const sortOrder = getSortOrder(sort);
|
|
334
|
+
const sortOrder = getSortOrder(sort, brand);
|
|
330
335
|
const filter = `_type in ${typesString} && brand == '${brand}'`;
|
|
331
336
|
const fields = `
|
|
332
337
|
"id": railcontent_id,
|
|
@@ -531,12 +536,29 @@ export async function fetchAll(brand, type, {
|
|
|
531
536
|
customFields = [],
|
|
532
537
|
progress = "all"
|
|
533
538
|
} = {}) {
|
|
539
|
+
let customResults = await handleCustomFetchAll(brand, type, {
|
|
540
|
+
page,
|
|
541
|
+
limit,
|
|
542
|
+
searchTerm,
|
|
543
|
+
sort,
|
|
544
|
+
includedFields,
|
|
545
|
+
groupBy,
|
|
546
|
+
progressIds,
|
|
547
|
+
useDefaultFields,
|
|
548
|
+
customFields,
|
|
549
|
+
progress
|
|
550
|
+
});
|
|
551
|
+
if (customResults) {
|
|
552
|
+
return customResults;
|
|
553
|
+
}
|
|
554
|
+
|
|
534
555
|
let config = contentTypeConfig[type] ?? {};
|
|
535
556
|
let additionalFields = config?.fields ?? [];
|
|
536
557
|
let isGroupByOneToOne = (groupBy ? config?.relationships?.[groupBy]?.isOneToOne : false) ?? false;
|
|
537
558
|
let webUrlPathType = config?.slug ?? type;
|
|
538
559
|
const start = (page - 1) * limit;
|
|
539
560
|
const end = start + limit;
|
|
561
|
+
let bypassStatusAndPublishedValidation = (type == 'instructor' || groupBy == 'artist' || groupBy == 'genre' || groupBy == 'instructor');
|
|
540
562
|
|
|
541
563
|
// Construct the type filter
|
|
542
564
|
const typeFilter = type ? `&& _type == '${type}'` : "";
|
|
@@ -557,26 +579,31 @@ export async function fetchAll(brand, type, {
|
|
|
557
579
|
const progressFilter = await getProgressFilter(progress, progressIds);
|
|
558
580
|
|
|
559
581
|
// Determine the sort order
|
|
560
|
-
const sortOrder = getSortOrder(sort);
|
|
582
|
+
const sortOrder = getSortOrder(sort, brand, groupBy);
|
|
561
583
|
|
|
562
584
|
let fields = useDefaultFields ? customFields.concat(DEFAULT_FIELDS, additionalFields) : customFields;
|
|
563
585
|
let fieldsString = fields.join(',');
|
|
564
586
|
|
|
587
|
+
let customFilter = '';
|
|
588
|
+
if (type == 'instructor') {
|
|
589
|
+
customFilter = '&& coach_card_image != null'
|
|
590
|
+
}
|
|
565
591
|
// Determine the group by clause
|
|
566
592
|
let query = "";
|
|
567
593
|
let entityFieldsString = "";
|
|
568
594
|
let filter = "";
|
|
569
595
|
if (groupBy !== "" && isGroupByOneToOne) {
|
|
570
596
|
const webUrlPath = 'artists';
|
|
571
|
-
const lessonsFilter = `_type == '${type}' && brand == '${brand}' && ^._id == ${groupBy}._ref ${searchFilter} ${includedFieldsFilter} ${progressFilter}`;
|
|
597
|
+
const lessonsFilter = `_type == '${type}' && brand == '${brand}' && ^._id == ${groupBy}._ref ${searchFilter} ${includedFieldsFilter} ${progressFilter} ${customFilter}`;
|
|
598
|
+
const lessonsFilterWithRestrictions = await new FilterBuilder(lessonsFilter).buildFilter();
|
|
572
599
|
entityFieldsString = `
|
|
573
600
|
'id': railcontent_id,
|
|
574
601
|
'type': _type,
|
|
575
602
|
name,
|
|
576
603
|
'head_shot_picture_url': thumbnail_url.asset->url,
|
|
577
604
|
'web_url_path': '/${brand}/${webUrlPath}/'+name+'?included_fieds[]=type,${type}',
|
|
578
|
-
'all_lessons_count': count(*[${
|
|
579
|
-
'lessons': *[${
|
|
605
|
+
'all_lessons_count': count(*[${lessonsFilterWithRestrictions}]._id),
|
|
606
|
+
'lessons': *[${lessonsFilterWithRestrictions}]{
|
|
580
607
|
${fieldsString},
|
|
581
608
|
${groupBy}
|
|
582
609
|
}[0...20]
|
|
@@ -584,25 +611,33 @@ export async function fetchAll(brand, type, {
|
|
|
584
611
|
filter = `_type == '${groupBy}' && count(*[brand == '${brand}' && ^._id == ${groupBy}._ref ${typeFilter} ${searchFilter} ${includedFieldsFilter} ${progressFilter}]._id) > 0`;
|
|
585
612
|
} else if (groupBy !== "") {
|
|
586
613
|
const webUrlPath = (groupBy == 'genre') ? '/genres' : '';
|
|
587
|
-
const lessonsFilter = `brand == '${brand}' && ^._id in ${groupBy}[]._ref ${typeFilter} ${searchFilter} ${includedFieldsFilter} ${progressFilter}`;
|
|
614
|
+
const lessonsFilter = `brand == '${brand}' && ^._id in ${groupBy}[]._ref ${typeFilter} ${searchFilter} ${includedFieldsFilter} ${progressFilter} ${customFilter}`;
|
|
615
|
+
const lessonsFilterWithRestrictions = await new FilterBuilder(lessonsFilter).buildFilter();
|
|
616
|
+
|
|
588
617
|
entityFieldsString = `
|
|
589
618
|
'id': railcontent_id,
|
|
590
619
|
'type': _type,
|
|
591
620
|
name,
|
|
592
621
|
'head_shot_picture_url': thumbnail_url.asset->url,
|
|
593
622
|
'web_url_path': select(defined(web_url_path)=> web_url_path +'?included_fieds[]=type,${type}',!defined(web_url_path)=> '/${brand}${webUrlPath}/'+name+'/${webUrlPathType}'),
|
|
594
|
-
'all_lessons_count': count(*[${
|
|
595
|
-
'lessons': *[${
|
|
623
|
+
'all_lessons_count': count(*[${lessonsFilterWithRestrictions}]._id),
|
|
624
|
+
'lessons': *[${lessonsFilterWithRestrictions}]{
|
|
596
625
|
${fieldsString},
|
|
597
626
|
${groupBy}
|
|
598
627
|
}[0...20]`;
|
|
599
628
|
filter = `_type == '${groupBy}' && count(*[brand == '${brand}' && ^._id in ${groupBy}[]._ref ${typeFilter} ${searchFilter} ${includedFieldsFilter} ${progressFilter}]._id) > 0`;
|
|
600
629
|
} else {
|
|
601
|
-
filter = `brand == "${brand}" ${typeFilter} ${searchFilter} ${includedFieldsFilter} ${progressFilter}`
|
|
630
|
+
filter = `brand == "${brand}" ${typeFilter} ${searchFilter} ${includedFieldsFilter} ${progressFilter} ${customFilter}`
|
|
602
631
|
entityFieldsString = fieldsString;
|
|
603
632
|
}
|
|
633
|
+
|
|
634
|
+
const filterWithRestrictions = await new FilterBuilder(filter, {
|
|
635
|
+
bypassStatuses: bypassStatusAndPublishedValidation,
|
|
636
|
+
bypassPermissions: bypassStatusAndPublishedValidation,
|
|
637
|
+
bypassPublishedDateRestriction: bypassStatusAndPublishedValidation
|
|
638
|
+
}).buildFilter();
|
|
604
639
|
query = buildEntityAndTotalQuery(
|
|
605
|
-
|
|
640
|
+
filterWithRestrictions,
|
|
606
641
|
entityFieldsString,
|
|
607
642
|
{
|
|
608
643
|
sortOrder: sortOrder,
|
|
@@ -613,6 +648,125 @@ export async function fetchAll(brand, type, {
|
|
|
613
648
|
return fetchSanity(query, true);
|
|
614
649
|
}
|
|
615
650
|
|
|
651
|
+
/**
|
|
652
|
+
* Fetch all content that requires custom handling or a distinct external call
|
|
653
|
+
* @param {string} brand - The brand for which to fetch content.
|
|
654
|
+
* @param {string} type - The content type to fetch (e.g., 'song', 'artist').
|
|
655
|
+
* @param {Object} params - Parameters for pagination, filtering, sorting, and grouping.
|
|
656
|
+
* @param {number} [params.page=1] - The page number for pagination.
|
|
657
|
+
* @param {number} [params.limit=10] - The number of items per page.
|
|
658
|
+
* @param {string} [params.searchTerm=""] - The search term to filter content by title or artist.
|
|
659
|
+
* @param {string} [params.sort="-published_on"] - The field to sort the content by.
|
|
660
|
+
* @param {Array<string>} [params.includedFields=[]] - The fields to include in the query.
|
|
661
|
+
* @param {string} [params.groupBy=""] - The field to group the results by (e.g., 'artist', 'genre').
|
|
662
|
+
* @param {Array<string>} [params.progressIds=undefined] - An array of railcontent IDs to filter the results by. Used for filtering by progress.
|
|
663
|
+
* @param {boolean} [params.useDefaultFields=true] - use the default sanity fields for content Type
|
|
664
|
+
* @param {Array<string>} [params.customFields=[]] - An array of sanity fields to include in the request
|
|
665
|
+
* @param {string} [params.progress="all"] - An string representing which progress filter to use ("all", "in progress", "complete", "not started").
|
|
666
|
+
* @returns {Promise<Object|null>} - The fetched content data or null if not found.
|
|
667
|
+
*/
|
|
668
|
+
async function handleCustomFetchAll(brand, type, {
|
|
669
|
+
page = 1,
|
|
670
|
+
limit = 10,
|
|
671
|
+
searchTerm = "",
|
|
672
|
+
sort = "-published_on",
|
|
673
|
+
includedFields = [],
|
|
674
|
+
groupBy = "",
|
|
675
|
+
progressIds = undefined,
|
|
676
|
+
useDefaultFields = true,
|
|
677
|
+
customFields = [],
|
|
678
|
+
progress = "all"
|
|
679
|
+
} = {}) {
|
|
680
|
+
if (type === 'challenge') {
|
|
681
|
+
if (groupBy === 'completed') {
|
|
682
|
+
const completedIds = await fetchCompletedChallenges(brand, page, limit);
|
|
683
|
+
return fetchAll(brand, type,
|
|
684
|
+
{
|
|
685
|
+
page,
|
|
686
|
+
limit,
|
|
687
|
+
searchTerm,
|
|
688
|
+
sort,
|
|
689
|
+
includedFields,
|
|
690
|
+
groupBy: '',
|
|
691
|
+
progressIds: completedIds,
|
|
692
|
+
useDefaultFields,
|
|
693
|
+
customFields,
|
|
694
|
+
progress
|
|
695
|
+
});
|
|
696
|
+
} else if (groupBy === 'owned') {
|
|
697
|
+
const ownedIds = await fetchOwnedChallenges(brand, page, limit);
|
|
698
|
+
return fetchAll(brand, type,
|
|
699
|
+
{
|
|
700
|
+
page,
|
|
701
|
+
limit,
|
|
702
|
+
searchTerm,
|
|
703
|
+
sort,
|
|
704
|
+
includedFields,
|
|
705
|
+
groupBy: '',
|
|
706
|
+
progressIds: ownedIds,
|
|
707
|
+
useDefaultFields,
|
|
708
|
+
customFields,
|
|
709
|
+
progress
|
|
710
|
+
});
|
|
711
|
+
} else if (groupBy === 'difficulty_string') {
|
|
712
|
+
return fetchChallengesByDifficulty(brand, type, page, limit, searchTerm, sort, includedFields, groupBy, progressIds, useDefaultFields, customFields, progress);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
return null;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
async function fetchChallengesByDifficulty(brand, type, page, limit, searchTerm, sort, includedFields, groupBy, progressIds, useDefaultFields, customFields, progress) {
|
|
719
|
+
let config = contentTypeConfig['challenge'] ?? {};
|
|
720
|
+
let additionalFields = config?.fields ?? [];
|
|
721
|
+
|
|
722
|
+
// Construct the search filter
|
|
723
|
+
const searchFilter = searchTerm
|
|
724
|
+
? groupBy !== "" ?
|
|
725
|
+
`&& (^.name match "${searchTerm}*" || title match "${searchTerm}*")`
|
|
726
|
+
: `&& (artist->name match "${searchTerm}*" || instructor[]->name match "${searchTerm}*" || title match "${searchTerm}*" || name match "${searchTerm}*")`
|
|
727
|
+
: "";
|
|
728
|
+
|
|
729
|
+
// Construct the included fields filter, replacing 'difficulty' with 'difficulty_string'
|
|
730
|
+
const includedFieldsFilter = includedFields.length > 0
|
|
731
|
+
? filtersToGroq(includedFields)
|
|
732
|
+
: "";
|
|
733
|
+
|
|
734
|
+
// limits the results to supplied progressIds for started & completed filters
|
|
735
|
+
const progressFilter = await getProgressFilter(progress, progressIds);
|
|
736
|
+
|
|
737
|
+
let fields = useDefaultFields ? customFields.concat(DEFAULT_FIELDS, additionalFields) : customFields;
|
|
738
|
+
let fieldsString = fields.join(',');
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
const lessonsFilter = `_type == 'challenge' && brand == '${brand}' && ^.name == difficulty_string ${searchFilter} ${includedFieldsFilter} ${progressFilter}`;
|
|
742
|
+
const lessonsFilterWithRestrictions = await new FilterBuilder(lessonsFilter).buildFilter();
|
|
743
|
+
|
|
744
|
+
const query = `{
|
|
745
|
+
"entity": [
|
|
746
|
+
{"name": "All"},
|
|
747
|
+
{"name": "Novice"},
|
|
748
|
+
{"name": "Beginner"},
|
|
749
|
+
{"name": "Intermediate"},
|
|
750
|
+
{"name": "Advanced"},
|
|
751
|
+
{"name": "Expert"}]
|
|
752
|
+
{
|
|
753
|
+
'id': 0,
|
|
754
|
+
name,
|
|
755
|
+
'all_lessons_count': count(*[${lessonsFilterWithRestrictions}]._id),
|
|
756
|
+
'lessons': *[${lessonsFilterWithRestrictions}]{
|
|
757
|
+
${fieldsString},
|
|
758
|
+
name
|
|
759
|
+
}[0...20]
|
|
760
|
+
},
|
|
761
|
+
"total": 0
|
|
762
|
+
}`;
|
|
763
|
+
let data = await fetchSanity(query, true);
|
|
764
|
+
data.entity = data.entity.filter(function (difficulty) {
|
|
765
|
+
return difficulty.lessons.length > 0;
|
|
766
|
+
});
|
|
767
|
+
return data;
|
|
768
|
+
}
|
|
769
|
+
|
|
616
770
|
async function getProgressFilter(progress, progressIds) {
|
|
617
771
|
switch (progress) {
|
|
618
772
|
case "all":
|
|
@@ -635,7 +789,7 @@ async function getProgressFilter(progress, progressIds) {
|
|
|
635
789
|
}
|
|
636
790
|
}
|
|
637
791
|
|
|
638
|
-
export function getSortOrder(sort = '-published_on', groupBy) {
|
|
792
|
+
export function getSortOrder(sort = '-published_on', brand, groupBy) {
|
|
639
793
|
// Determine the sort order
|
|
640
794
|
let sortOrder = '';
|
|
641
795
|
const isDesc = sort.startsWith('-');
|
|
@@ -645,9 +799,15 @@ export function getSortOrder(sort = '-published_on', groupBy) {
|
|
|
645
799
|
sortOrder = groupBy ? 'name' : "title";
|
|
646
800
|
break;
|
|
647
801
|
case "name":
|
|
648
|
-
case "popularity":
|
|
649
802
|
sortOrder = sort;
|
|
650
803
|
break;
|
|
804
|
+
case "popularity":
|
|
805
|
+
if (groupBy == "artist" || groupBy == "genre") {
|
|
806
|
+
sortOrder = isDesc ? `coalesce(popularity.${brand}, -1)` : "popularity";
|
|
807
|
+
} else {
|
|
808
|
+
sortOrder = isDesc ? "coalesce(popularity, -1)" : "popularity";
|
|
809
|
+
}
|
|
810
|
+
break;
|
|
651
811
|
case "published_on":
|
|
652
812
|
default:
|
|
653
813
|
sortOrder = "published_on";
|
|
@@ -838,6 +998,7 @@ export async function fetchMethod(brand, slug) {
|
|
|
838
998
|
"url": web_url_path,
|
|
839
999
|
web_url_path,
|
|
840
1000
|
xp,
|
|
1001
|
+
total_xp
|
|
841
1002
|
}
|
|
842
1003
|
} | order(published_on asc)`
|
|
843
1004
|
return fetchSanity(query, false);
|
|
@@ -891,7 +1052,10 @@ export async function fetchMethodPreviousNextLesson(railcontentId, methodId) {
|
|
|
891
1052
|
const index = sortedChildren.indexOf(Number(railcontentId));
|
|
892
1053
|
let nextId = sortedChildren[index + 1];
|
|
893
1054
|
let previousId = sortedChildren[index - 1];
|
|
894
|
-
let
|
|
1055
|
+
let ids = [];
|
|
1056
|
+
if (nextId) ids.push(nextId);
|
|
1057
|
+
if (previousId) ids.push(previousId);
|
|
1058
|
+
let nextPrev = await fetchByRailContentIds(ids);
|
|
895
1059
|
const nextLesson = nextPrev.find((elem) => {
|
|
896
1060
|
return elem['id'] === nextId
|
|
897
1061
|
});
|
|
@@ -978,7 +1142,7 @@ export async function fetchNextPreviousLesson(railcontentId) {
|
|
|
978
1142
|
* .catch(error => console.error(error));
|
|
979
1143
|
*/
|
|
980
1144
|
export async function fetchLessonContent(railContentId) {
|
|
981
|
-
const filterParams = {};
|
|
1145
|
+
const filterParams = {isSingle: true, pullFutureContent: true};
|
|
982
1146
|
// Format changes made to the `fields` object may also need to be reflected in Musora-web-platform SanityGateway.php $fields object
|
|
983
1147
|
// Currently only for challenges and challenge lessons
|
|
984
1148
|
// If you're unsure, message Adrian, or just add them.
|
|
@@ -1089,7 +1253,7 @@ export async function fetchRelatedMethodLessons(railContentId, brand) {
|
|
|
1089
1253
|
* @returns {Promise<Array<Object>|null>} - The fetched pack content data or null if not found.
|
|
1090
1254
|
*/
|
|
1091
1255
|
export async function fetchAllPacks(brand, sort = "-published_on", searchTerm = "", page = 1, limit = 10) {
|
|
1092
|
-
const sortOrder = getSortOrder(sort);
|
|
1256
|
+
const sortOrder = getSortOrder(sort, brand);
|
|
1093
1257
|
const filter = `_type == 'pack' && brand == '${brand}' && title match "${searchTerm}*"`
|
|
1094
1258
|
const filterParams = {};
|
|
1095
1259
|
const fields = getFieldsForContentType('pack');
|
|
@@ -1145,7 +1309,7 @@ export async function fetchLiveEvent(brand) {
|
|
|
1145
1309
|
// See LiveStreamEventService.getCurrentOrNextLiveEvent for some nice complicated logic which I don't think is actually importart
|
|
1146
1310
|
// this has some +- on times
|
|
1147
1311
|
// But this query just finds the first scheduled event (sorted by start_time) that ends after now()
|
|
1148
|
-
const query = `*[status == 'scheduled' && defined(live_event_start_time) && published_on > '${getSanityDate(dateTemp)}' && live_event_end_time >= '${getSanityDate(new Date())}']{
|
|
1312
|
+
const query = `*[status == 'scheduled' && defined(live_event_start_time) && published_on > '${getSanityDate(dateTemp, false)}' && live_event_end_time >= '${getSanityDate(new Date(), false)}']{
|
|
1149
1313
|
'slug': slug.current,
|
|
1150
1314
|
'id': railcontent_id,
|
|
1151
1315
|
live_event_start_time,
|
|
@@ -1247,7 +1411,7 @@ export async function fetchCoachLessons(brand, id, {
|
|
|
1247
1411
|
: "";
|
|
1248
1412
|
const filter = `brand == '${brand}' ${searchFilter} ${includedFieldsFilter} && references(*[_type=='instructor' && railcontent_id == ${id}]._id)`;
|
|
1249
1413
|
|
|
1250
|
-
sortOrder = getSortOrder(sortOrder);
|
|
1414
|
+
sortOrder = getSortOrder(sortOrder, brand);
|
|
1251
1415
|
const query = buildEntityAndTotalQuery(
|
|
1252
1416
|
filter,
|
|
1253
1417
|
fieldsString,
|
|
@@ -1321,12 +1485,14 @@ export async function fetchByReference(brand, {
|
|
|
1321
1485
|
const includedFieldsFilter = includedFields.length > 0
|
|
1322
1486
|
? includedFields.join(' && ')
|
|
1323
1487
|
: "";
|
|
1488
|
+
|
|
1324
1489
|
const filter = `brand == '${brand}' ${searchFilter} && references(*[${includedFieldsFilter}]._id)`;
|
|
1490
|
+
const filterWithRestrictions = await new FilterBuilder(filter).buildFilter();
|
|
1325
1491
|
const query = buildEntityAndTotalQuery(
|
|
1326
|
-
|
|
1492
|
+
filterWithRestrictions,
|
|
1327
1493
|
fieldsString,
|
|
1328
1494
|
{
|
|
1329
|
-
sortOrder: getSortOrder(sortOrder),
|
|
1495
|
+
sortOrder: getSortOrder(sortOrder, brand),
|
|
1330
1496
|
start: start,
|
|
1331
1497
|
end: end,
|
|
1332
1498
|
},
|
|
@@ -1366,7 +1532,7 @@ export async function fetchArtistLessons(brand, name, contentType, {
|
|
|
1366
1532
|
const start = (page - 1) * limit;
|
|
1367
1533
|
const end = start + limit;
|
|
1368
1534
|
const searchFilter = searchTerm ? `&& title match "${searchTerm}*"` : ''
|
|
1369
|
-
const sortOrder = getSortOrder(sort);
|
|
1535
|
+
const sortOrder = getSortOrder(sort, brand);
|
|
1370
1536
|
const addType = contentType && Array.isArray(contentType) ? `_type in ['${contentType.join("', '")}'] &&` : contentType ? `_type == '${contentType}' && ` : ''
|
|
1371
1537
|
const includedFieldsFilter = includedFields.length > 0
|
|
1372
1538
|
? filtersToGroq(includedFields)
|
|
@@ -1417,7 +1583,7 @@ export async function fetchGenreLessons(brand, name, contentType, {
|
|
|
1417
1583
|
const start = (page - 1) * limit;
|
|
1418
1584
|
const end = start + limit;
|
|
1419
1585
|
const searchFilter = searchTerm ? `&& title match "${searchTerm}*"` : ''
|
|
1420
|
-
const sortOrder = getSortOrder(sort);
|
|
1586
|
+
const sortOrder = getSortOrder(sort, brand);
|
|
1421
1587
|
const addType = contentType ? `_type == '${contentType}' && ` : ''
|
|
1422
1588
|
const includedFieldsFilter = includedFields.length > 0
|
|
1423
1589
|
? filtersToGroq(includedFields)
|
|
@@ -1617,6 +1783,7 @@ export async function fetchSanity(query,
|
|
|
1617
1783
|
]);
|
|
1618
1784
|
const response = promisesResult[0];
|
|
1619
1785
|
const userPermissions = promisesResult[1]?.permissions;
|
|
1786
|
+
const isAdmin = promisesResult[1]?.isAdmin;
|
|
1620
1787
|
|
|
1621
1788
|
if (!response.ok) {
|
|
1622
1789
|
throw new Error(`Sanity API error: ${response.status} - ${response.statusText}`);
|
|
@@ -1627,7 +1794,7 @@ export async function fetchSanity(query,
|
|
|
1627
1794
|
console.log("fetchSanity Results:", result);
|
|
1628
1795
|
}
|
|
1629
1796
|
let results = isList ? result.result : result.result[0];
|
|
1630
|
-
results = processNeedAccess ? await needsAccessDecorator(results, userPermissions) : results;
|
|
1797
|
+
results = processNeedAccess ? await needsAccessDecorator(results, userPermissions, isAdmin) : results;
|
|
1631
1798
|
return customPostProcess ? customPostProcess(results) : results;
|
|
1632
1799
|
} else {
|
|
1633
1800
|
throw new Error('No results found');
|
|
@@ -1638,38 +1805,41 @@ export async function fetchSanity(query,
|
|
|
1638
1805
|
}
|
|
1639
1806
|
}
|
|
1640
1807
|
|
|
1641
|
-
function needsAccessDecorator(results, userPermissions) {
|
|
1808
|
+
function needsAccessDecorator(results, userPermissions, isAdmin) {
|
|
1642
1809
|
if (globalConfig.sanityConfig.useDummyRailContentMethods) return results;
|
|
1643
1810
|
|
|
1644
1811
|
userPermissions = new Set(userPermissions);
|
|
1645
1812
|
|
|
1646
1813
|
if (Array.isArray(results)) {
|
|
1647
1814
|
results.forEach((result) => {
|
|
1648
|
-
result['need_access'] = doesUserNeedAccessToContent(result, userPermissions);
|
|
1815
|
+
result['need_access'] = doesUserNeedAccessToContent(result, userPermissions, isAdmin);
|
|
1649
1816
|
});
|
|
1650
1817
|
} else if (results.entity && Array.isArray(results.entity)) {
|
|
1651
1818
|
// Group By
|
|
1652
1819
|
results.entity.forEach((result) => {
|
|
1653
1820
|
if (result.lessons) {
|
|
1654
1821
|
result.lessons.forEach((lesson) => {
|
|
1655
|
-
lesson['need_access'] = doesUserNeedAccessToContent(lesson, userPermissions); // Updated to check lesson access
|
|
1822
|
+
lesson['need_access'] = doesUserNeedAccessToContent(lesson, userPermissions, isAdmin); // Updated to check lesson access
|
|
1656
1823
|
});
|
|
1657
1824
|
} else {
|
|
1658
|
-
result['need_access'] = doesUserNeedAccessToContent(result, userPermissions);
|
|
1825
|
+
result['need_access'] = doesUserNeedAccessToContent(result, userPermissions, isAdmin);
|
|
1659
1826
|
}
|
|
1660
1827
|
});
|
|
1661
1828
|
} else if (results.related_lessons && Array.isArray(results.related_lessons)) {
|
|
1662
1829
|
results.related_lessons.forEach((result) => {
|
|
1663
|
-
result['need_access'] = doesUserNeedAccessToContent(result, userPermissions);
|
|
1830
|
+
result['need_access'] = doesUserNeedAccessToContent(result, userPermissions, isAdmin);
|
|
1664
1831
|
})
|
|
1665
1832
|
} else {
|
|
1666
|
-
results['need_access'] = doesUserNeedAccessToContent(results, userPermissions);
|
|
1833
|
+
results['need_access'] = doesUserNeedAccessToContent(results, userPermissions, isAdmin);
|
|
1667
1834
|
}
|
|
1668
1835
|
|
|
1669
1836
|
return results;
|
|
1670
1837
|
}
|
|
1671
1838
|
|
|
1672
|
-
function doesUserNeedAccessToContent(result, userPermissions) {
|
|
1839
|
+
function doesUserNeedAccessToContent(result, userPermissions, isAdmin) {
|
|
1840
|
+
if (isAdmin ?? false) {
|
|
1841
|
+
return false;
|
|
1842
|
+
}
|
|
1673
1843
|
const permissions = new Set(result?.permission_id ?? []);
|
|
1674
1844
|
if (permissions.size === 0) {
|
|
1675
1845
|
return false;
|
|
@@ -1757,7 +1927,18 @@ function arrayJoinWithQuotes(array, delimiter = ',') {
|
|
|
1757
1927
|
return wrapped.join(delimiter)
|
|
1758
1928
|
}
|
|
1759
1929
|
|
|
1760
|
-
function getSanityDate(date) {
|
|
1930
|
+
function getSanityDate(date, roundToHourForCaching = true) {
|
|
1931
|
+
if (roundToHourForCaching) {
|
|
1932
|
+
// We need to set the published on filter date to be a round time so that it doesn't bypass the query cache
|
|
1933
|
+
// with every request by changing the filter date every second. I've set it to one minute past the current hour
|
|
1934
|
+
// because publishing usually publishes content on the hour exactly which means it should still skip the cache
|
|
1935
|
+
// when the new content is available.
|
|
1936
|
+
// Round to the start of the current hour
|
|
1937
|
+
const roundedDate = new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours());
|
|
1938
|
+
|
|
1939
|
+
return roundedDate.toISOString();
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1761
1942
|
return date.toISOString();
|
|
1762
1943
|
}
|
|
1763
1944
|
|
|
@@ -1810,7 +1991,7 @@ function buildRawQuery(
|
|
|
1810
1991
|
|
|
1811
1992
|
async function buildQuery(
|
|
1812
1993
|
baseFilter = '',
|
|
1813
|
-
filterParams = {},
|
|
1994
|
+
filterParams = {pullFutureContent: false},
|
|
1814
1995
|
fields = '...',
|
|
1815
1996
|
{
|
|
1816
1997
|
sortOrder = 'published_on desc',
|
|
@@ -1840,7 +2021,7 @@ function buildEntityAndTotalQuery(
|
|
|
1840
2021
|
{
|
|
1841
2022
|
${fields}
|
|
1842
2023
|
},
|
|
1843
|
-
"total":
|
|
2024
|
+
"total": 0
|
|
1844
2025
|
}`;
|
|
1845
2026
|
return query;
|
|
1846
2027
|
}
|
|
@@ -1954,7 +2135,7 @@ function cleanUpGroq(query) {
|
|
|
1954
2135
|
<br class="clear">
|
|
1955
2136
|
|
|
1956
2137
|
<footer>
|
|
1957
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on
|
|
2138
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Mon Dec 02 2024 10:19:36 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
1958
2139
|
</footer>
|
|
1959
2140
|
|
|
1960
2141
|
<script>prettyPrint();</script>
|
package/link_mcs.sh
CHANGED
|
File without changes
|
package/package.json
CHANGED
package/src/contentMetaData.js
CHANGED
|
File without changes
|
package/src/filterBuilder.js
CHANGED
|
@@ -86,8 +86,7 @@ export class FilterBuilder {
|
|
|
86
86
|
_applyPermissions() {
|
|
87
87
|
if (this.bypassPermissions || this.userData.isAdmin) return this;
|
|
88
88
|
const requiredPermissions = this._getUserPermissions();
|
|
89
|
-
|
|
90
|
-
this._andWhere(`references(*[_type == 'permission' && railcontent_id in ${arrayToRawRepresentation(requiredPermissions)}]._id)`);
|
|
89
|
+
this._andWhere(`(!defined(permission) || references(*[_type == 'permission' && railcontent_id in ${arrayToRawRepresentation(requiredPermissions)}]._id))`);
|
|
91
90
|
return this;
|
|
92
91
|
}
|
|
93
92
|
|
package/src/index.d.ts
CHANGED
|
@@ -75,6 +75,7 @@ import {
|
|
|
75
75
|
postContentReset,
|
|
76
76
|
postContentUnliked,
|
|
77
77
|
postRecordWatchSession,
|
|
78
|
+
reportPlaylist,
|
|
78
79
|
unpinPlaylist,
|
|
79
80
|
updatePlaylist,
|
|
80
81
|
updatePlaylistItem
|
|
@@ -253,6 +254,7 @@ declare module 'musora-content-services' {
|
|
|
253
254
|
postContentUnliked,
|
|
254
255
|
postRecordWatchSession,
|
|
255
256
|
recordWatchSession,
|
|
257
|
+
reportPlaylist,
|
|
256
258
|
reset,
|
|
257
259
|
unlikeContent,
|
|
258
260
|
unpinPlaylist,
|
package/src/index.js
CHANGED
|
@@ -75,6 +75,7 @@ import {
|
|
|
75
75
|
postContentReset,
|
|
76
76
|
postContentUnliked,
|
|
77
77
|
postRecordWatchSession,
|
|
78
|
+
reportPlaylist,
|
|
78
79
|
unpinPlaylist,
|
|
79
80
|
updatePlaylist,
|
|
80
81
|
updatePlaylistItem
|
|
@@ -252,6 +253,7 @@ export {
|
|
|
252
253
|
postContentUnliked,
|
|
253
254
|
postRecordWatchSession,
|
|
254
255
|
recordWatchSession,
|
|
256
|
+
reportPlaylist,
|
|
255
257
|
reset,
|
|
256
258
|
unlikeContent,
|
|
257
259
|
unpinPlaylist,
|
|
File without changes
|
|
File without changes
|
|
@@ -1090,6 +1090,19 @@ export async function fetchPinnedPlaylists(brand) {
|
|
|
1090
1090
|
return await fetchHandler(url, "GET");
|
|
1091
1091
|
}
|
|
1092
1092
|
|
|
1093
|
+
/**
|
|
1094
|
+
* Report playlist endpoint
|
|
1095
|
+
*
|
|
1096
|
+
* @param playlistId
|
|
1097
|
+
* @param issue
|
|
1098
|
+
* @returns {Promise<any|null>}
|
|
1099
|
+
*/
|
|
1100
|
+
export async function reportPlaylist(playlistId, {issue} = {}) {
|
|
1101
|
+
const issueString = issue ? `?issue=${issue}` : '';
|
|
1102
|
+
const url = `/playlists/report/${playlistId}${issueString}`;
|
|
1103
|
+
return await fetchHandler(url, "PUT");
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1093
1106
|
function fetchAbsolute(url, params) {
|
|
1094
1107
|
if (globalConfig.railcontentConfig.baseUrl) {
|
|
1095
1108
|
if (url.startsWith('/')) {
|
package/src/services/sanity.js
CHANGED
|
@@ -1160,7 +1160,7 @@ export async function fetchLessonContent(railContentId) {
|
|
|
1160
1160
|
* @returns {Promise<Array<Object>|null>} - The fetched related lessons data or null if not found.
|
|
1161
1161
|
*/
|
|
1162
1162
|
export async function fetchRelatedLessons(railContentId, brand) {
|
|
1163
|
-
const query = `*[railcontent_id == ${railContentId} && brand == "${brand}" && references(*[_type=='permission']._id)]{
|
|
1163
|
+
const query = `*[railcontent_id == ${railContentId} && brand == "${brand}" && (!defined(permission) || references(*[_type=='permission']._id))]{
|
|
1164
1164
|
_type, parent_type, railcontent_id,
|
|
1165
1165
|
"related_lessons" : array::unique([
|
|
1166
1166
|
...(*[references(^._id)][0].child[]->{_id, "id":railcontent_id, published_on, "instructor": instructor[0]->name, title, "thumbnail_url":thumbnail.asset->url, length_in_seconds, web_url_path, "type": _type, difficulty, difficulty_string, railcontent_id, artist->,"permission_id": permission[]->railcontent_id,_type}),
|
|
File without changes
|
|
File without changes
|