musora-content-services 1.0.101 → 1.0.104

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.
@@ -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#.fetchAllCompletedStates">fetchAllCompletedStates</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#.fetchSongsInProgress">fetchSongsInProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchVimeoData">fetchVimeoData</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#.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#.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#.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#.fetchParentByRailContentId">fetchParentByRailContentId</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#.fetchSanity">fetchSanity</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#.fetchAllCompletedStates">fetchAllCompletedStates</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#.fetchSongsInProgress">fetchSongsInProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchVimeoData">fetchVimeoData</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#.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#.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#.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#.fetchParentByRailContentId">fetchParentByRailContentId</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#.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>
33
33
 
34
34
  </nav>
35
35
 
@@ -308,6 +308,56 @@ function fetchAbsolute(url, params) {
308
308
  }
309
309
  }
310
310
  return fetch(url, params);
311
+ }
312
+
313
+ export async function fetchUserContext() {
314
+ let url = `/content/user_data_all`;
315
+ const headers = {
316
+ 'Content-Type': 'application/json',
317
+ 'X-CSRF-TOKEN': globalConfig.railcontentConfig.token
318
+ };
319
+ try {
320
+ const response = await fetch(url, {headers});
321
+ const result = await response.json();
322
+ if (result) {
323
+ console.log('fetchUserContext', result);
324
+ return result;
325
+ } else {
326
+ console.log('result not json');
327
+ }
328
+ } catch (error) {
329
+ console.error('Fetch error:', error);
330
+ return null;
331
+ }
332
+ }
333
+
334
+ export async function fetchHandler(url, method = "get") {
335
+ const headers = {
336
+ 'Content-Type': 'application/json',
337
+ 'X-CSRF-TOKEN': globalConfig.railcontentConfig.token
338
+ };
339
+ try {
340
+ const response = await fetch(url, {method, headers});
341
+ const result = await response.json();
342
+ if (result) {
343
+ return result;
344
+ } else {
345
+ console.log('result not json');
346
+ }
347
+ } catch (error) {
348
+ console.error('Fetch error:', error);
349
+ return null;
350
+ }
351
+ }
352
+
353
+ export async function fetchLikeContent(contentId) {
354
+ let url = `/content/${contentId}/like`;
355
+ return await fetchHandler(url, "post");
356
+ }
357
+
358
+ export async function fetchUnlikeContent(contentId) {
359
+ let url = `/content/${contentId}/unlike`;
360
+ return await fetchHandler(url, "post");
311
361
  }</code></pre>
312
362
  </article>
313
363
  </section>
@@ -322,7 +372,7 @@ function fetchAbsolute(url, params) {
322
372
  <br class="clear">
323
373
 
324
374
  <footer>
325
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Thu Sep 12 2024 18:08:47 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
375
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Wed Sep 18 2024 16:11:26 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
326
376
  </footer>
327
377
 
328
378
  <script>prettyPrint();</script>
@@ -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#.fetchAllCompletedStates">fetchAllCompletedStates</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#.fetchSongsInProgress">fetchSongsInProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchVimeoData">fetchVimeoData</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#.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#.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#.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#.fetchParentByRailContentId">fetchParentByRailContentId</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#.fetchSanity">fetchSanity</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#.fetchAllCompletedStates">fetchAllCompletedStates</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#.fetchSongsInProgress">fetchSongsInProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchVimeoData">fetchVimeoData</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#.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#.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#.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#.fetchParentByRailContentId">fetchParentByRailContentId</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#.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>
33
33
 
34
34
  </nav>
35
35
 
@@ -56,7 +56,9 @@ import {
56
56
  contentTypeConfig,
57
57
  DEFAULT_FIELDS,
58
58
  getFieldsForContentType,
59
- filtersToGroq
59
+ filtersToGroq,
60
+ getUpcomingEventsTypes,
61
+ getNewReleasesTypes,
60
62
  } from "../contentTypeConfig";
61
63
  import {globalConfig} from "./config";
62
64
 
@@ -135,6 +137,7 @@ export async function fetchRelatedSongs(brand, songId) {
135
137
  "url": web_url_path,
136
138
  "published_on": published_on,
137
139
  status,
140
+ "image": thumbnail.asset->url,
138
141
  "fields": [
139
142
  {
140
143
  "key": "title",
@@ -153,10 +156,6 @@ export async function fetchRelatedSongs(brand, songId) {
153
156
  "value": soundslice[0].soundslice_length_in_second
154
157
  }
155
158
  ],
156
- "data": [{
157
- "key": "thumbnail_url",
158
- "value": thumbnail.asset->url
159
- }]
160
159
  }[0...10]),
161
160
  ...(*[_type == "song" &amp;&amp; brand == "${brand}" &amp;&amp; railcontent_id != ${songId} &amp;&amp; references(^.genre[]->_id)]{
162
161
  "type": _type,
@@ -285,7 +284,7 @@ export async function fetchSongCount(brand) {
285
284
  * @example
286
285
  * fetchWorkouts('drumeo')
287
286
  * .then(workouts => console.log(workouts))
288
- * .catch(error => console.error(error));
287
+ * .catch(error => console.error(error));
289
288
  */
290
289
  export async function fetchWorkouts(brand) {
291
290
  const fields = getFieldsForContentType('workout');
@@ -301,14 +300,8 @@ export async function fetchWorkouts(brand) {
301
300
  * @returns {Promise&lt;Object|null>} - The fetched new releases data or null if not found.
302
301
  */
303
302
  export async function fetchNewReleases(brand, { page = 1, limit = 10, sort="-published_on" } = {}) {
304
- const newTypes = {
305
- 'drumeo': ["drum-fest-international-2022", "spotlight", "the-history-of-electronic-drums", "backstage-secrets", "quick-tips", "question-and-answer", "student-collaborations", "live-streams", "live", "podcasts", "solos", "boot-camps", "gear-guides", "performances", "in-rhythm", "challenges", "on-the-road", "diy-drum-experiments", "rhythmic-adventures-of-captain-carson", "study-the-greats", "rhythms-from-another-planet", "tama-drums", "paiste-cymbals", "behind-the-scenes", "exploring-beats", "sonor-drums", "course", "play-along", "student-focus", "coach-stream", "learning-path-level", "unit", "quick-tips", "live", "question-and-answer", "student-review", "boot-camps", "song", "chords-and-scales", "pack", "podcasts", "workout", "challenge", "challenge-part"],
306
- 'pianote': ["student-review", "student-reviews", "question-and-answer", "course", "play-along", "student-focus", "coach-stream", "learning-path-level", "unit", "quick-tips", "live", "question-and-answer", "student-review", "boot-camps", "song", "chords-and-scales", "pack", "podcasts", "workout", "challenge", "challenge-part"],
307
- 'guitareo': ["student-review", "student-reviews", "question-and-answer", "archives", "recording", "course", "play-along", "student-focus", "coach-stream", "learning-path-level", "unit", "quick-tips", "live", "question-and-answer", "student-review", "boot-camps", "song", "chords-and-scales", "pack", "podcasts", "workout", "challenge", "challenge-part"],
308
- 'singeo': ["student-review", "student-reviews", "question-and-answer", "course", "play-along", "student-focus", "coach-stream", "learning-path-level", "unit", "quick-tips", "live", "question-and-answer", "student-review", "boot-camps", "song", "chords-and-scales", "pack", "podcasts", "workout", "challenge", "challenge-part"],
309
- 'default': ["student-review", "student-reviews", "question-and-answer", "course", "play-along", "student-focus", "coach-stream", "learning-path-level", "unit", "quick-tips", "live", "question-and-answer", "student-review", "boot-camps", "song", "chords-and-scales", "pack", "podcasts", "workout", "challenge", "challenge-part"]
310
- };
311
- const typesString = arrayJoinWithQuotes(newTypes[brand] ?? newTypes['default']);
303
+ const newTypes = getNewReleasesTypes(brand);
304
+ const typesString = arrayJoinWithQuotes(newTypes);
312
305
  const start = (page - 1) * limit;
313
306
  const end = start + limit;
314
307
  const sortOrder = getSortOrder(sort);
@@ -344,15 +337,8 @@ export async function fetchNewReleases(brand, { page = 1, limit = 10, sort="-pub
344
337
  * .catch(error => console.error(error));
345
338
  */
346
339
  export async function fetchUpcomingEvents(brand, { page = 1, limit = 10 } = {}) {
347
- const baseLiveTypes = ["student-review", "student-reviews", "student-focus", "coach-stream", "live", "question-and-answer", "student-review", "boot-camps", "recording", "pack-bundle-lesson"];
348
- const liveTypes = {
349
- 'drumeo': [...baseLiveTypes, "drum-fest-international-2022", "spotlight", "the-history-of-electronic-drums", "backstage-secrets", "quick-tips", "student-collaborations", "live-streams", "podcasts", "solos", "gear-guides", "performances", "in-rhythm", "challenges", "on-the-road", "diy-drum-experiments", "rhythmic-adventures-of-captain-carson", "study-the-greats", "rhythms-from-another-planet", "tama-drums", "paiste-cymbals", "behind-the-scenes", "exploring-beats", "sonor-drums"],
350
- 'pianote': baseLiveTypes,
351
- 'guitareo': [...baseLiveTypes, "archives"],
352
- 'singeo': baseLiveTypes,
353
- 'default': baseLiveTypes
354
- };
355
- const typesString = arrayJoinWithQuotes(liveTypes[brand] ?? liveTypes['default']);
340
+ const liveTypes = getUpcomingEventsTypes(brand);
341
+ const typesString = arrayJoinWithQuotes(liveTypes);
356
342
  const now = getSanityDate(new Date());
357
343
  const start = (page - 1) * limit;
358
344
  const end = start + limit;
@@ -372,6 +358,45 @@ export async function fetchUpcomingEvents(brand, { page = 1, limit = 10 } = {})
372
358
  return fetchSanity(query, true);
373
359
  }
374
360
 
361
+ /**
362
+ * Fetch scheduled releases for a specific brand.
363
+ *
364
+ * @param {string} brand - The brand for which to fetch scheduled releasess.
365
+ * @returns {Promise&lt;Object|null>} - A promise that resolves to an array of scheduled release objects or null if not found.
366
+ *
367
+ * @example
368
+ * fetchScheduledReleases('drumeo', {
369
+ * page: 2,
370
+ * limit: 20,
371
+ * })
372
+ * .then(content => console.log(content))
373
+ * .catch(error => console.error(error));
374
+ */
375
+ export async function fetchScheduledReleases(brand, { page = 1, limit = 10 }) {
376
+ const upcomingTypes = getUpcomingEventsTypes(brand);
377
+ const newTypes = getNewReleasesTypes(brand);
378
+
379
+ const scheduledTypes = merge(upcomingTypes, newTypes)
380
+ const typesString = arrayJoinWithQuotes(scheduledTypes);
381
+ const now = getSanityDate(new Date());
382
+ const start = (page - 1) * limit;
383
+ const end = start + limit;
384
+ const query = `*[_type in [${typesString}] &amp;&amp; brand == '${brand}' &amp;&amp; status in ['published','scheduled'] &amp;&amp; published_on > '${now}']{
385
+ "id": railcontent_id,
386
+ title,
387
+ "image": thumbnail.asset->url,
388
+ "artist_name": instructor[0]->name,
389
+ "artists": instructor[]->name,
390
+ difficulty,
391
+ difficulty_string,
392
+ length_in_seconds,
393
+ published_on,
394
+ "type": _type,
395
+ web_url_path,
396
+ } | order(published_on asc)[${start}...${end}]`;
397
+ return fetchSanity(query, true);
398
+ }
399
+
375
400
  /**
376
401
  * Fetch content by a specific Railcontent ID.
377
402
  *
@@ -462,7 +487,7 @@ export async function fetchAll(brand, type, {
462
487
  const searchFilter = searchTerm
463
488
  ? groupBy !== "" ?
464
489
  `&amp;&amp; (^.name match "${searchTerm}*" || title match "${searchTerm}*")`
465
- : `&amp;&amp; (artist->name match "${searchTerm}*" || instructor[]->name match "${searchTerm}*" || title match "${searchTerm}*")`
490
+ : `&amp;&amp; (artist->name match "${searchTerm}*" || instructor[]->name match "${searchTerm}*" || title match "${searchTerm}*" || name match "${searchTerm}*")`
466
491
  : "";
467
492
 
468
493
  // Construct the included fields filter, replacing 'difficulty' with 'difficulty_string'
@@ -546,8 +571,9 @@ export function getSortOrder(sort= '-published_on', groupBy)
546
571
  case "slug":
547
572
  sortOrder = groupBy ? 'name' : "title";
548
573
  break;
574
+ case "name":
549
575
  case "popularity":
550
- sortOrder = "popularity";
576
+ sortOrder = sort;
551
577
  break;
552
578
  case "published_on":
553
579
  default:
@@ -711,6 +737,7 @@ export async function fetchMethod(brand, slug) {
711
737
  "type": _type,
712
738
  "description": ${descriptionField},
713
739
  "url": web_url_path,
740
+ web_url_path,
714
741
  xp,
715
742
  }
716
743
  } | order(published_on asc)`
@@ -750,7 +777,6 @@ export async function fetchMethodNextLesson(railcontentId, methodId) {
750
777
  return childIndex ? await fetchByRailContentId(childIndex) : null;
751
778
  }
752
779
 
753
-
754
780
  /**
755
781
  * Fetch the next lesson for a specific method by Railcontent ID.
756
782
  * @param {string} railcontentId - The Railcontent ID of the current lesson.
@@ -868,7 +894,13 @@ export async function fetchLessonContent(railContentId) {
868
894
  "coach_profile_image":thumbnail_url.asset->url
869
895
  },
870
896
  "instructors":instructor[]->name,
871
- instructor[]->,
897
+ "instructor": instructor[]->{
898
+ "id":_id,
899
+ name,
900
+ short_bio,
901
+ web_url_path,
902
+ "coach_card_image": coach_card_image.asset->url,
903
+ },
872
904
  ${assignmentsField}
873
905
  video,
874
906
  length_in_seconds
@@ -898,6 +930,30 @@ export async function fetchRelatedLessons(railContentId, brand) {
898
930
  return fetchSanity(query, false);
899
931
  }
900
932
 
933
+ /**
934
+ * Fetch related method lessons for a specific lesson by RailContent ID and type.
935
+ * @param {string} railContentId - The RailContent ID of the current lesson.
936
+ * @param {string} brand - The current brand.
937
+ * @returns {Promise&lt;Object>|null>} - The fetched related lessons
938
+ */
939
+ export async function fetchRelatedMethodLessons(railContentId, brand) {
940
+ const query = `*[railcontent_id == ${railContentId} &amp;&amp; brand == "${brand}"]{
941
+ "id":_id,
942
+ "related_lessons": *[references(^._id)][0].child[]->{
943
+ "id": railcontent_id,
944
+ "type": _type,
945
+ title,
946
+ "description": description[0].children[0].text, // Extraer texto plano
947
+ "thumbnail_url": thumbnail.asset->url,
948
+ "url": web_url_path,
949
+ difficulty,
950
+ difficulty_string,
951
+ }
952
+ }
953
+ }`
954
+ return fetchSanity(query, false);
955
+ }
956
+
901
957
  /**
902
958
  * Fetch all packs.
903
959
  * @param {string} brand - The brand for which to fetch packs.
@@ -1271,6 +1327,13 @@ function getSanityDate(date) {
1271
1327
  return date.toISOString();
1272
1328
  }
1273
1329
 
1330
+ const merge = (a, b, predicate = (a, b) => a === b) => {
1331
+ const c = [...a]; // copy to avoid side effects
1332
+ // add all items from B to copy C if they're not already present
1333
+ b.forEach((bItem) => (c.some((cItem) => predicate(bItem, cItem)) ? null : c.push(bItem)))
1334
+ return c;
1335
+ }
1336
+
1274
1337
  function checkSanityConfig(config) {
1275
1338
  if (!config.sanityConfig.token) {
1276
1339
  console.warn('fetchSanity: The "token" property is missing in the config object.');
@@ -1306,7 +1369,7 @@ function checkSanityConfig(config) {
1306
1369
  <br class="clear">
1307
1370
 
1308
1371
  <footer>
1309
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Thu Sep 12 2024 18:08:47 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1372
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Wed Sep 18 2024 16:11:26 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1310
1373
  </footer>
1311
1374
 
1312
1375
  <script>prettyPrint();</script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "1.0.101",
3
+ "version": "1.0.104",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -56,6 +56,11 @@ let contentTypeConfig = {
56
56
  }
57
57
  }
58
58
  },
59
+ 'song-tutorial': {
60
+ 'fields': [
61
+ '"lesson_count": child_count',
62
+ ]
63
+ },
59
64
  'challenge':{
60
65
  'fields': [
61
66
  'enrollment_start_time',
@@ -286,6 +291,14 @@ function filtersToGroq(filters) {
286
291
  return `&& topic[]->name match "${value}"`;
287
292
  case 'instrumentless':
288
293
  return `&& instrumentless == ${value}`;
294
+ case 'creativity':
295
+ return `&& creativity[]->name match "${value}"`;
296
+ case 'theory':
297
+ return `&& theory[]->name match "${value}"`;
298
+ case 'essentials':
299
+ return `&& essential[]->name match "${value}"`;
300
+ case 'lifestyle':
301
+ return `&& lifestyle[]->name match "${value}"`;
289
302
  default:
290
303
  return `&& ${key} == ${/^\d+$/.test(value) ? value : `"$${value}"`}`;
291
304
  }
package/src/index.js CHANGED
@@ -38,6 +38,7 @@ import {
38
38
  fetchScheduledReleases,
39
39
  fetchArtistLessons,
40
40
  fetchGenreLessons,
41
+ fetchRelatedMethodLessons,
41
42
  } from './services/sanity.js';
42
43
 
43
44
  import {
@@ -95,4 +96,5 @@ export {
95
96
  fetchScheduledReleases,
96
97
  fetchArtistLessons,
97
98
  fetchGenreLessons,
99
+ fetchRelatedMethodLessons,
98
100
  }
@@ -90,6 +90,7 @@ export async function fetchRelatedSongs(brand, songId) {
90
90
  "url": web_url_path,
91
91
  "published_on": published_on,
92
92
  status,
93
+ "image": thumbnail.asset->url,
93
94
  "fields": [
94
95
  {
95
96
  "key": "title",
@@ -108,10 +109,6 @@ export async function fetchRelatedSongs(brand, songId) {
108
109
  "value": soundslice[0].soundslice_length_in_second
109
110
  }
110
111
  ],
111
- "data": [{
112
- "key": "thumbnail_url",
113
- "value": thumbnail.asset->url
114
- }]
115
112
  }[0...10]),
116
113
  ...(*[_type == "song" && brand == "${brand}" && railcontent_id != ${songId} && references(^.genre[]->_id)]{
117
114
  "type": _type,
@@ -733,7 +730,6 @@ export async function fetchMethodNextLesson(railcontentId, methodId) {
733
730
  return childIndex ? await fetchByRailContentId(childIndex) : null;
734
731
  }
735
732
 
736
-
737
733
  /**
738
734
  * Fetch the next lesson for a specific method by Railcontent ID.
739
735
  * @param {string} railcontentId - The Railcontent ID of the current lesson.
@@ -37,14 +37,14 @@ const {
37
37
 
38
38
  describe('Sanity Queries', function () {
39
39
  beforeEach(() => {
40
- const config = {
40
+ const config = {
41
41
  sanityConfig: {
42
42
  token: process.env.SANITY_API_TOKEN,
43
43
  projectId: process.env.SANITY_PROJECT_ID,
44
44
  dataset: process.env.SANITY_DATASET,
45
- useCachedAPI: process.env.SANITY_USE_CACHED_API || true,
45
+ useCachedAPI: process.env.SANITY_USE_CACHED_API === 'true' || true,
46
46
  version: '2021-06-07',
47
- debug: process.env.DEBUG || false
47
+ debug: process.env.DEBUG === 'true' || false
48
48
  }
49
49
  };
50
50
  initializeService(config);
@@ -66,7 +66,7 @@ describe('Sanity Queries', function () {
66
66
 
67
67
  test('fetchSongArtistCount', async () => {
68
68
  const response = await fetchSongArtistCount('drumeo');
69
- console.log(response);
69
+ // console.log(response);
70
70
  expect(response).toBeGreaterThan(1000);
71
71
  });
72
72
 
@@ -95,7 +95,7 @@ describe('Sanity Queries', function () {
95
95
 
96
96
  test('fetchAllSongs', async () => {
97
97
  const response = await fetchAllSongs('drumeo', {});
98
- console.log(response);
98
+ // console.log(response);
99
99
  expect(response.entity[0].soundslice).toBeDefined();
100
100
  expect(response.entity[0].artist_name).toBeDefined();
101
101
  expect(response.entity[0].instrumentless).toBeDefined();
@@ -111,20 +111,20 @@ describe('Sanity Queries', function () {
111
111
 
112
112
  test('fetchAllWorkouts', async () => {
113
113
  const response = await fetchAll('drumeo', 'workout',{});
114
- console.log(response);
114
+ // console.log(response);
115
115
  expect(response.entity[0].id).toBeDefined();
116
116
  });
117
117
 
118
118
  test('fetchAllInstructorField', async () => {
119
119
  const response = await fetchAll('drumeo', 'quick-tips',{searchTerm: 'Domino Santantonio'});
120
- console.log(response);
120
+ // console.log(response);
121
121
  expect(response.entity[0].id).toBeDefined();
122
122
  expect(response.entity[0].instructors).toBeTruthy();
123
123
  });
124
124
 
125
125
  test('fetchAllSortField', async () => {
126
126
  const response = await fetchAll('drumeo', 'rhythmic-adventures-of-captain-carson',{});
127
- console.log(response);
127
+ // console.log(response);
128
128
  expect(response.entity[0].id).toBeDefined();
129
129
  expect(response.entity[0].sort).toBeDefined();
130
130
  });
@@ -132,7 +132,7 @@ describe('Sanity Queries', function () {
132
132
 
133
133
  test('fetchAllChallenges', async () => {
134
134
  const response = await fetchAll('drumeo', 'challenge',{});
135
- console.log(response);
135
+ // console.log(response);
136
136
  expect(response.entity[0].registration_url).toBeDefined();
137
137
  expect(response.entity[0].enrollment_start_time).toBeDefined();
138
138
  expect(response.entity[0].enrollment_end_time).toBeDefined();
@@ -146,12 +146,12 @@ describe('Sanity Queries', function () {
146
146
 
147
147
  test('fetchAll-CustomFields', async () => {
148
148
  let response = await fetchAll('drumeo', 'challenge',{customFields:['garbage']});
149
- console.log(response);
149
+ // console.log(response);
150
150
  expect(response.entity[0].garbage).toBeDefined();
151
151
  expect(response.entity[0].id).toBeDefined();
152
152
 
153
153
  response = await fetchAll('drumeo', 'challenge',{useDefaultFields: false, customFields:['garbage']});
154
- console.log(response);
154
+ // console.log(response);
155
155
  expect(response.entity[0].garbage).toBeDefined();
156
156
  expect.not.objectContaining(response.entity[0].id);
157
157
  });
@@ -177,8 +177,8 @@ describe('Sanity Queries', function () {
177
177
  const id = 191338; ////https://web-staging-one.musora.com/admin/studio/publishing/structure/play-along;play-along_191338
178
178
  const expectedChildID = 191492;
179
179
  const response = await fetchChildren(id);
180
- console.log('num children', response.length);
181
- console.log(response);
180
+ // console.log('num children', response.length);
181
+ // console.log(response);
182
182
 
183
183
  expect(response.length > 0).toBeTruthy();
184
184
  const foundExpectedChild = response.some((child) => {
@@ -217,7 +217,7 @@ describe('Sanity Queries', function () {
217
217
 
218
218
  test('fetchMethods', async () => {
219
219
  const response = await fetchMethods('drumeo');
220
- console.log(response);
220
+ // console.log(response);
221
221
  expect(response.length).toBeGreaterThan(0);
222
222
  expect(response[0].type).toBe('learning-path');
223
223
  });
@@ -266,8 +266,9 @@ describe('Sanity Queries', function () {
266
266
  let response = await fetchAllPacks('drumeo');
267
267
  response = await fetchAllPacks('drumeo', 'slug');
268
268
  const titles = response.map((doc) => doc.title);
269
- const sortedTitles = [...titles].sort((a, b) => a.localeCompare(b));
270
- // This fails for upper/lower case compare and I couldn't figure it out. Sanity sorts with case sensativity, and localeCompare should do the same but doesn't
269
+
270
+ const sortedTitles = [...titles].sort((a, b) => a === b ? 0 : a > b ? 1 : -1);
271
+
271
272
  expect(titles).toStrictEqual(sortedTitles);
272
273
  response = await fetchAllPacks('drumeo', 'slug', 'Creative Control');
273
274
  expect(response[0].id).toBe(212899);