musora-content-services 1.0.76 → 1.0.78

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#.fetchContentInProgress">fetchContentInProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCurrentSongComplete">fetchCurrentSongComplete</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchSongsInProgress">fetchSongsInProgress</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#.fetchAllSongs">fetchAllSongs</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#.fetchCatalogMetadata">fetchCatalogMetadata</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#.fetchCourseOverview">fetchCourseOverview</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#.fetchContentInProgress">fetchContentInProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCurrentSongComplete">fetchCurrentSongComplete</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchSongsInProgress">fetchSongsInProgress</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#.fetchAllSongs">fetchAllSongs</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#.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#.fetchCourseOverview">fetchCourseOverview</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>
33
33
 
34
34
  </nav>
35
35
 
@@ -201,7 +201,7 @@ export async function fetchContentInProgress(type="all", brand) {
201
201
  <br class="clear">
202
202
 
203
203
  <footer>
204
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Tue Aug 27 2024 20:09:43 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
204
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Tue Sep 03 2024 21:48:28 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
205
205
  </footer>
206
206
 
207
207
  <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#.fetchContentInProgress">fetchContentInProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCurrentSongComplete">fetchCurrentSongComplete</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchSongsInProgress">fetchSongsInProgress</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#.fetchAllSongs">fetchAllSongs</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#.fetchCatalogMetadata">fetchCatalogMetadata</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#.fetchCourseOverview">fetchCourseOverview</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#.fetchContentInProgress">fetchContentInProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCurrentSongComplete">fetchCurrentSongComplete</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchSongsInProgress">fetchSongsInProgress</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#.fetchAllSongs">fetchAllSongs</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#.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#.fetchCourseOverview">fetchCourseOverview</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>
33
33
 
34
34
  </nav>
35
35
 
@@ -48,7 +48,16 @@
48
48
  <pre class="prettyprint source linenums"><code>/**
49
49
  * @module Sanity-Services
50
50
  */
51
- import {assignmentsField, contentTypeConfig, DEFAULT_FIELDS, getFieldsForContentType} from "../contentTypeConfig";
51
+ import {
52
+ artistOrInstructorName,
53
+ artistOrInstructorNameAsArray,
54
+ assignmentsField,
55
+ descriptionField,
56
+ contentTypeConfig,
57
+ DEFAULT_FIELDS,
58
+ getFieldsForContentType,
59
+ filtersToGroq
60
+ } from "../contentTypeConfig";
52
61
  import {globalConfig} from "./config";
53
62
 
54
63
  import { fetchAllCompletedStates, fetchCurrentSongComplete } from './railcontent.js';
@@ -279,18 +288,9 @@ export async function fetchSongCount(brand) {
279
288
  * .catch(error => console.error(error));
280
289
  */
281
290
  export async function fetchWorkouts(brand) {
291
+ const fields = getFieldsForContentType('workout');
282
292
  const query = `*[_type == 'workout' &amp;&amp; brand == '${brand}'] [0...5] {
283
- "id": railcontent_id,
284
- title,
285
- "image": thumbnail.asset->url,
286
- "artist_name": instructor[0]->name,
287
- "artists": instructor[]->name,
288
- difficulty,
289
- difficulty_string,
290
- length_in_seconds,
291
- published_on,
292
- "type": _type,
293
- web_url_path,
293
+ ${fields.toString()}
294
294
  } | order(published_on desc)[0...5]`
295
295
  return fetchSanity(query, true);
296
296
  }
@@ -348,8 +348,7 @@ export async function fetchUpcomingEvents(brand) {
348
348
  };
349
349
  const typesString = arrayJoinWithQuotes(liveTypes[brand] ?? liveTypes['default']);
350
350
  const now = getSanityDate(new Date());
351
- //TODO: status = 'scheduled' is this handled in sanity?
352
- const query = `*[_type in [${typesString}] &amp;&amp; brand == '${brand}' &amp;&amp; published_on > '${now}']{
351
+ const query = `*[_type in [${typesString}] &amp;&amp; brand == '${brand}' &amp;&amp; published_on > '${now}' &amp;&amp; status == 'scheduled']{
353
352
  "id": railcontent_id,
354
353
  title,
355
354
  "image": thumbnail.asset->url,
@@ -377,6 +376,7 @@ export async function fetchUpcomingEvents(brand) {
377
376
  * .catch(error => console.error(error));
378
377
  */
379
378
  export async function fetchByRailContentId(id, contentType) {
379
+ console.log('contentType', contentType)
380
380
  const query = `*[railcontent_id == ${id}]{
381
381
  ${getFieldsForContentType(contentType)}
382
382
  }`
@@ -451,13 +451,7 @@ export async function fetchAll(brand, type, {
451
451
 
452
452
  // Construct the included fields filter, replacing 'difficulty' with 'difficulty_string'
453
453
  const includedFieldsFilter = includedFields.length > 0
454
- ? includedFields.map(field => {
455
- let [key, value] = field.split(',');
456
- if (key === 'difficulty') {
457
- key = 'difficulty_string';
458
- }
459
- return `&amp;&amp; ${key} == "${value}"`;
460
- }).join(' ')
454
+ ? filtersToGroq(includedFields)
461
455
  : "";
462
456
 
463
457
  // Determine the sort order
@@ -571,16 +565,9 @@ export async function fetchAllFilterOptions(
571
565
  contentType,
572
566
  term
573
567
  ) {
574
- const filtersToGroq = filters?.length > 0 ? filters.map(field => {
575
- let [key, value] = field.split(',');
576
- if (key === 'difficulty') {
577
- key = 'difficulty_string';
578
- }
579
- return `&amp;&amp; ${key} == "${value}"`;
580
- }).join(' ')
581
- : undefined;
568
+ const includedFieldsFilter = filters?.length > 0 ? filtersToGroq(filters) : undefined;
582
569
 
583
- const commonFilter = `_type == '${contentType}' &amp;&amp; brand == "${brand}"${style ? ` &amp;&amp; '${style}' in genre[]->name` : ''}${artist ? ` &amp;&amp; artist->name == '${artist}'` : ''} ${filtersToGroq ? filtersToGroq : ''}`;
570
+ const commonFilter = `_type == '${contentType}' &amp;&amp; brand == "${brand}"${style ? ` &amp;&amp; '${style}' in genre[]->name` : ''}${artist ? ` &amp;&amp; artist->name == '${artist}'` : ''} ${includedFieldsFilter ? includedFieldsFilter : ''}`;
584
571
  const query = `
585
572
  {
586
573
  "meta": {
@@ -616,6 +603,8 @@ export async function fetchAllFilterOptions(
616
603
  */
617
604
  export async function fetchChildren(railcontentId, contentType) {
618
605
  const query = `*[railcontent_id == ${railcontentId}]{
606
+ title,
607
+
619
608
  'children': child[]->{
620
609
  ${getFieldsForContentType(contentType)}
621
610
  },
@@ -647,11 +636,8 @@ export async function fetchParentByRailContentId(railcontentId) {
647
636
  * @returns {Promise&lt;Object|null>} - The fetched methods data or null if not found.
648
637
  */
649
638
  export async function fetchMethods(brand) {
650
- //TODOS
651
- //ADD INSTRUCTORS AND POSITION
652
639
  const query = `*[_type == 'learning-path' &amp;&amp; brand == '${brand}'] {
653
- ${ getFieldsForContentType() },
654
- "position": count(*[_type == 'learning-path' &amp;&amp; brand == '${brand}' &amp;&amp; (published_on &lt; ^.published_on || (published_on == ^.published_on &amp;&amp; _id &lt; ^._id))]) + 1
640
+ ${ getFieldsForContentType() }
655
641
  } | order(published_on asc)`
656
642
  return fetchSanity(query, true);
657
643
  }
@@ -664,7 +650,7 @@ export async function fetchMethods(brand) {
664
650
  */
665
651
  export async function fetchMethod(brand, slug) {
666
652
  const query = `*[_type == 'learning-path' &amp;&amp; brand == "${brand}" &amp;&amp; slug.current == "${slug}"] {
667
- "description": description[0].children[0].text,
653
+ "description": ${descriptionField},
668
654
  "instructors":instructor[]->name,
669
655
  published_on,
670
656
  "id": railcontent_id,
@@ -678,12 +664,14 @@ export async function fetchMethod(brand, slug) {
678
664
  {
679
665
  "id": railcontent_id,
680
666
  published_on,
667
+ child_count,
681
668
  difficulty,
669
+ difficulty_string,
682
670
  "thumbnail_url": thumbnail.asset->url,
683
671
  "instructor": instructor[]->{name},
684
672
  title,
685
673
  "type": _type,
686
- "description": description[0].children[0].text,
674
+ "description": ${descriptionField},
687
675
  "url": web_url_path,
688
676
  xp,
689
677
  }
@@ -697,7 +685,17 @@ return fetchSanity(query, false);
697
685
  * @returns {Promise&lt;Object|null>} - The fetched next lesson data or null if not found.
698
686
  */
699
687
  export async function fetchMethodChildren(railcontentId) {
700
- return fetchChildren(railcontentId, 'method');
688
+ const query = `*[railcontent_id == ${railcontentId}]{
689
+ child_count,
690
+ "id": railcontent_id,
691
+ "description": ${descriptionField},
692
+ title,
693
+ xp,
694
+ 'children': child[]->{
695
+ ${getFieldsForContentType('method')}
696
+ },
697
+ }[0..1]`;
698
+ return fetchSanity(query, true);
701
699
  }
702
700
 
703
701
  /**
@@ -803,8 +801,23 @@ export async function fetchNextPreviousLesson(railcontentId) {
803
801
  * .catch(error => console.error(error));
804
802
  */
805
803
  export async function fetchLessonContent(railContentId) {
806
- const query = `*[railcontent_id == ${railContentId} ]
807
- {title, published_on,"type":_type, "resources": resource, difficulty, difficulty_string, brand, soundslice, instrumentless, railcontent_id, "id":railcontent_id, slug, artist->,"thumbnail_url":thumbnail.asset->url, "url": web_url_path, soundslice_slug,description,
804
+ const query = `*[railcontent_id == ${railContentId} ]{
805
+ title,
806
+ published_on,
807
+ "type":_type,
808
+ "resources": resource,
809
+ difficulty,
810
+ difficulty_string,
811
+ brand,
812
+ soundslice,
813
+ instrumentless,
814
+ railcontent_id,
815
+ "id":railcontent_id,
816
+ slug, artist->,
817
+ "thumbnail_url":thumbnail.asset->url,
818
+ "url": web_url_path,
819
+ soundslice_slug,
820
+ description,
808
821
  "chapters": chapter[]{
809
822
  chapter_description,
810
823
  chapter_timecode,
@@ -851,8 +864,9 @@ export async function fetchRelatedLessons(railContentId, brand) {
851
864
  */
852
865
  export async function fetchPackAll(railcontentId) {
853
866
  //TODO: Implement getPacks
854
- const query = `*[_railcontent_id == ${railcontentId}]{
867
+ const query = `*[railcontent_id == ${railcontentId}]{
855
868
  railcontent_id,
869
+ "id": railcontent_id,
856
870
  title,
857
871
  "image": thumbnail.asset->url,
858
872
  "artist_name": artist->name,
@@ -865,6 +879,49 @@ export async function fetchPackAll(railcontentId) {
865
879
  return fetchSanity(query, true);
866
880
  }
867
881
 
882
+ export async function fetchLiveEvent(brand) {
883
+ //calendarIDs taken from addevent.php
884
+ // TODO import instructor calendars to Sanity
885
+ let defaultCalendarID = '';
886
+ switch(brand) {
887
+ case ('drumeo'):
888
+ defaultCalendarID = 'GP142387';
889
+ break;
890
+ case ('pianote'):
891
+ defaultCalendarID = 'be142408';
892
+ break;
893
+ case ('guitareo'):
894
+ defaultCalendarID = 'IJ142407';
895
+ break;
896
+ case ('singeo'):
897
+ defaultCalendarID = 'bk354284';
898
+ break;
899
+ default:
900
+ break;
901
+ }
902
+ let dateTemp = new Date();
903
+ dateTemp.setDate(dateTemp.getDate() - 1);
904
+
905
+ // See LiveStreamEventService.getCurrentOrNextLiveEvent for some nice complicated logic which I don't think is actually importart
906
+ // this has some +- on times
907
+ // But this query just finds the first scheduled event (sorted by start_time) that ends after now()
908
+ const query = `*[status == 'scheduled' &amp;&amp; defined(live_event_start_time) &amp;&amp; published_on > '${getSanityDate(dateTemp)}' &amp;&amp; live_event_end_time >= '${getSanityDate(new Date())}']{
909
+ 'slug': slug.current,
910
+ 'id': railcontent_id,
911
+ live_event_start_time,
912
+ live_event_end_time,
913
+ railcontent_id,
914
+ published_on,
915
+ 'event_coach_url' : instructor[0]->web_url_path,
916
+ 'event_coach_calendar_id': coalesce(calendar_id, '${defaultCalendarID}'),
917
+ title,
918
+ "image": thumbnail.asset->url,
919
+ "instructors": instructor[]->name,
920
+ 'videoId': coalesce(live_event_youtube_id, video.external_id),
921
+ } | order(live_event_start_time)[0...1]`;
922
+ return await fetchSanity(query, false);
923
+ }
924
+
868
925
  /**
869
926
  * Fetch all children of a specific pack by Railcontent ID.
870
927
  * @param {string} railcontentId - The Railcontent ID of the pack.
@@ -879,6 +936,34 @@ export async function fetchPackChildren(railcontentId) {
879
936
  return fetchChildren(railcontentId, 'pack');
880
937
  }
881
938
 
939
+ /**
940
+ * Fetch the data needed for the Challenge Overview screen.
941
+ * @param {string} id - The Railcontent ID of the course
942
+ * @returns {Promise&lt;Object|null>} - The challenge information and lessons or null if not found.
943
+ *
944
+ * @example
945
+ * fetchChallengeOverview('challenge123')
946
+ * .then(challenge => console.log(challenge))
947
+ * .catch(error => console.error(error));
948
+ */
949
+ export async function fetchChallengeOverview(id) {
950
+ // WIP
951
+ const query = `*[railcontent_id == ${id}]{
952
+ ${getFieldsForContentType("challenge", true)}
953
+ "lessons": child[]->{
954
+ "id": railcontent_id,
955
+ title,
956
+ "image": thumbnail.asset->url,
957
+ "instructors": instructor[]->name,
958
+ length_in_seconds,
959
+ difficulty_string,
960
+ difficulty,
961
+ "type": _type,
962
+ }
963
+ }`;
964
+ return fetchSanity(query, false);
965
+ }
966
+
882
967
  /**
883
968
  * Fetch the data needed for the Course Overview screen.
884
969
  * @param {string} id - The Railcontent ID of the course
@@ -1040,7 +1125,7 @@ function checkSanityConfig(config) {
1040
1125
  <br class="clear">
1041
1126
 
1042
1127
  <footer>
1043
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Tue Aug 27 2024 20:09:43 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1128
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Tue Sep 03 2024 21:48:28 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1044
1129
  </footer>
1045
1130
 
1046
1131
  <script>prettyPrint();</script>
package/link_mcs.sh CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "1.0.76",
3
+ "version": "1.0.78",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/publish.sh CHANGED
File without changes
@@ -31,6 +31,18 @@ const assignmentsField = `"assignments":assignment[]{
31
31
  "description": assignment_description
32
32
  },`
33
33
 
34
+ const contentWithInstructorsField = {
35
+ 'fields': [
36
+ '"instructors": instructor[]->name',
37
+ ]
38
+ }
39
+
40
+ const contentWithSortField = {
41
+ 'fields': [
42
+ 'sort',
43
+ ]
44
+ }
45
+
34
46
  let contentTypeConfig = {
35
47
  'song': {
36
48
  'fields': [
@@ -44,7 +56,7 @@ let contentTypeConfig = {
44
56
  }
45
57
  },
46
58
  'challenge':{
47
- 'fields':[
59
+ 'fields': [
48
60
  'enrollment_start_time',
49
61
  'enrollment_end_time',
50
62
  'registration_url',
@@ -52,6 +64,12 @@ let contentTypeConfig = {
52
64
  '"primary_cta_text": select(dateTime(published_on) > dateTime(now()) && dateTime(enrollment_start_time) > dateTime(now()) => "Notify Me", "Start Challenge")',
53
65
  'challenge_state',
54
66
  'challenge_state_text',
67
+ `"description": ${descriptionField}`,
68
+ 'total_xp',
69
+ 'xp',
70
+ '"instructors": instructor[]->name',
71
+ '"header_image_url": header_image_url.asset->url',
72
+ '"logo_image_url": logo_image_url.asset->url',
55
73
  ]
56
74
  },
57
75
  'course': {
@@ -60,11 +78,7 @@ let contentTypeConfig = {
60
78
  '"instructors": instructor[]->name'
61
79
  ]
62
80
  },
63
- 'student-focus': {
64
- 'fields': [
65
- '"instructors": instructor[]->name'
66
- ]
67
- },
81
+
68
82
  'method': {
69
83
  'fields': [
70
84
  `"description": ${descriptionField}`,
@@ -90,126 +104,6 @@ let contentTypeConfig = {
90
104
  artistOrInstructorNameAsArray(),
91
105
  ]
92
106
  },
93
- 'quick-tips': {
94
- 'fields': [
95
- '"instructors": instructor[]->name'
96
- ]
97
- },
98
- 'rudiment': {
99
- 'fields': [
100
- 'sheet_music_thumbnail_url',
101
- ]
102
- },
103
- 'drum-fest-international-aa2022': {
104
- 'fields': [
105
- '"instructors": instructor[]->name'
106
- ]
107
- },
108
- 'spotlight': {
109
- 'fields': [
110
- '"instructors": instructor[]->name'
111
- ]
112
- },
113
- 'the-history-of-electronic-drums': {
114
- 'fields': [
115
- '"instructors": instructor[]->name'
116
- ]
117
- },
118
- 'backstage-secrets': {
119
- 'fields': [
120
- '"instructors": instructor[]->name'
121
- ]
122
- },
123
- 'question-and-answer': {
124
- 'fields': [
125
- '"instructors": instructor[]->name'
126
- ]
127
- },
128
- 'student-collaborations': {
129
- 'fields': [
130
- '"instructors": instructor[]->name'
131
- ]
132
- },
133
- 'live': {
134
- 'fields': [
135
- '"instructors": instructor[]->name'
136
- ]
137
- },
138
- 'podcasts': {
139
- 'fields': [
140
- 'sort',
141
- ]
142
- },
143
- 'solos': {
144
- 'fields': [
145
- '"instructors": instructor[]->name'
146
- ]
147
- },
148
- 'boot-camps': {
149
- 'fields': [
150
- '"instructors": instructor[]->name'
151
- ]
152
- },
153
- 'gear-guids': {
154
- 'fields': [
155
- '"instructors": instructor[]->name'
156
- ]
157
- },
158
- 'performances': {
159
- 'fields': [
160
- '"instructors": instructor[]->name'
161
- ]
162
- },
163
- 'in-rhythm': {
164
- 'fields': [
165
- 'sort',
166
- ]
167
- },
168
- 'challenges': {
169
- 'fields': [
170
- '"instructors": instructor[]->name'
171
- ]
172
- },
173
- 'on-the-road': {
174
- 'fields': [
175
- '"instructors": instructor[]->name'
176
- ]
177
- },
178
- 'diy-drum-experiments': {
179
- 'fields': [
180
- 'sort',
181
- ]
182
- },
183
- 'rhythmic-adventures-of-captain-carson': {
184
- 'fields': [
185
- 'sort',
186
- ]
187
- },
188
- 'study-the-greats': {
189
- 'fields': [
190
- 'sort',
191
- ]
192
- },
193
- 'rhythms-from-another-planet': {
194
- 'fields': [
195
- 'sort',
196
- ]
197
- },
198
- 'paiste-cymbals': {
199
- 'fields': [
200
- '"instructors": instructor[]->name'
201
- ]
202
- },
203
- 'behind-the-scenes': {
204
- 'fields': [
205
- 'sort',
206
- ]
207
- },
208
- 'exploring-beats': {
209
- 'fields': [
210
- 'sort',
211
- ]
212
- },
213
107
  'play-along': {
214
108
  'fields': [
215
109
  '"style": genre[]->name',
@@ -224,10 +118,63 @@ let contentTypeConfig = {
224
118
  'fields': [
225
119
  '"lesson_count": child_count',
226
120
  'xp',
227
- `"description": ${descriptionField}`,
228
- '"instructors": instructor[]->name'
121
+ `"description": ${descriptionField}`,
122
+ '"instructors": instructor[]->name'
229
123
  ],
230
- }
124
+ },
125
+ 'rudiment': {
126
+ 'fields': [
127
+ 'sheet_music_thumbnail_url',
128
+ ]
129
+ },
130
+ 'routine':{
131
+ 'fields': [
132
+ `"description": ${descriptionField}`,
133
+ 'high_soundslice_slug',
134
+ 'low_soundslice_slug'
135
+ ]
136
+ },
137
+ 'pack-bundle': {
138
+ 'fields': [
139
+ 'child_count',
140
+ `"children": child[]->{
141
+ "description": ${descriptionField},
142
+ ${getFieldsForContentType()}
143
+ }`,
144
+ '"image": logo_image_url.asset->url',
145
+ '"thumbnail": thumbnail.asset->url',
146
+ '"light_logo": light_mode_logo_url.asset->url',
147
+ '"dark_logo": dark_mode_logo_url.asset->url',
148
+ `"description": ${descriptionField}`,
149
+ 'total_xp',
150
+ ]
151
+ },
152
+ // content with just the added 'instructors' Field
153
+ 'student-focus': contentWithInstructorsField,
154
+ 'quick-tips': contentWithInstructorsField,
155
+ 'drum-fest-international-aa2022': contentWithInstructorsField,
156
+ 'spotlight': contentWithInstructorsField,
157
+ 'the-history-of-electronic-drums': contentWithInstructorsField,
158
+ 'backstage-secrets': contentWithInstructorsField,
159
+ 'question-and-answer': contentWithInstructorsField,
160
+ 'student-collaborations': contentWithInstructorsField,
161
+ 'live': contentWithInstructorsField,
162
+ 'solos': contentWithInstructorsField,
163
+ 'boot-camps': contentWithInstructorsField,
164
+ 'gear-guids': contentWithInstructorsField,
165
+ 'performances': contentWithInstructorsField,
166
+ 'challenges': contentWithInstructorsField,
167
+ 'on-the-road': contentWithInstructorsField,
168
+ // content with just the added 'sort' field
169
+ 'podcasts': contentWithSortField,
170
+ 'in-rhythm': contentWithSortField,
171
+ 'diy-drum-experiments': contentWithSortField,
172
+ 'rhythmic-adventures-of-captain-carson': contentWithSortField,
173
+ 'study-the-greats': contentWithSortField,
174
+ 'rhythms-from-another-planet': contentWithSortField,
175
+ 'paiste-cymbals': contentWithInstructorsField,
176
+ 'behind-the-scenes': contentWithSortField,
177
+ 'exploring-beats': contentWithSortField,
231
178
  }
232
179
 
233
180
  function artistOrInstructorName(key='artist_name') {
@@ -239,7 +186,6 @@ function artistOrInstructorNameAsArray(key='artists') {
239
186
  }
240
187
 
241
188
  function getFieldsForContentType(contentType, asQueryString=true) {
242
- console.log('this was called, ', contentType)
243
189
  const fields = contentType ? DEFAULT_FIELDS.concat(contentTypeConfig?.[contentType]?.fields ?? []) : DEFAULT_FIELDS;
244
190
  return asQueryString ? fields.toString() + ',' : fields;
245
191
  }
package/src/index.d.ts CHANGED
@@ -16,6 +16,7 @@ import {
16
16
  fetchAllFilterOptions,
17
17
  fetchMethods,
18
18
  fetchMethod,
19
+ fetchMethodChildren,
19
20
  fetchMethodNextLesson,
20
21
  fetchMethodChildrenIds,
21
22
  fetchNextPreviousLesson,
@@ -23,10 +24,15 @@ import {
23
24
  fetchPackAll,
24
25
  fetchPackChildren,
25
26
  fetchLessonContent,
26
- fetchCourseOverview
27
+ fetchCourseOverview,
28
+ fetchChallengeOverview,
27
29
  } from './services/sanity.js';
28
-
29
- import { initializeService } from './services/config.js';
30
+
31
+ import {
32
+ fetchVimeoData,
33
+ } from "./services/railcontent";
34
+
35
+ import { initializeService } from './services/config.js';
30
36
 
31
37
  declare module 'musora-content-services' {
32
38
  export {
@@ -48,6 +54,7 @@ declare module 'musora-content-services' {
48
54
  fetchMethods,
49
55
  fetchMethod,
50
56
  fetchMethodNextLesson,
57
+ fetchMethodChildren,
51
58
  fetchMethodChildrenIds,
52
59
  fetchNextPreviousLesson,
53
60
  fetchRelatedLessons,
@@ -55,6 +62,9 @@ declare module 'musora-content-services' {
55
62
  fetchPackChildren,
56
63
  fetchLessonContent,
57
64
  fetchCourseOverview,
65
+ fetchLiveEvent,
66
+ fetchChallengeOverview,
67
+ fetchVimeoData,
58
68
  }
59
69
 
60
70
  }