musora-content-services 1.0.35 → 1.0.36

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/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.35",
3
+ "version": "1.0.36",
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
@@ -21,7 +21,13 @@ let contentTypeConfig = {
21
21
  'challenge_state',
22
22
  'challenge_state_text',
23
23
  ]
24
- }
24
+ },
25
+ 'course': {
26
+ 'fields': [
27
+ '"lesson_count": child_count',
28
+ '"instructors": instructor[]->name'
29
+ ]
30
+ },
25
31
  }
26
32
 
27
33
 
package/src/index.d.ts CHANGED
@@ -20,7 +20,8 @@ import {
20
20
  fetchRelatedLessons,
21
21
  fetchPackAll,
22
22
  fetchPackChildren,
23
- fetchLessonContent
23
+ fetchLessonContent,
24
+ fetchCourseOverview
24
25
  } from './services/sanity.js';
25
26
 
26
27
  import { initializeService } from './services/config.js';
@@ -48,7 +49,8 @@ declare module 'musora-content-services' {
48
49
  fetchRelatedLessons,
49
50
  fetchPackAll,
50
51
  fetchPackChildren,
51
- fetchLessonContent
52
+ fetchLessonContent,
53
+ fetchCourseOverview,
52
54
  }
53
55
 
54
56
  }
package/src/index.js CHANGED
@@ -22,7 +22,8 @@ import {
22
22
  fetchRelatedLessons,
23
23
  fetchPackAll,
24
24
  fetchPackChildren,
25
- fetchLessonContent
25
+ fetchLessonContent,
26
+ fetchCourseOverview,
26
27
  } from './services/sanity.js';
27
28
 
28
29
  import {
@@ -58,5 +59,6 @@ export {
58
59
  fetchLessonContent,
59
60
  fetchCurrentSongComplete,
60
61
  fetchAllCompletedStates,
61
- fetchContentInProgress
62
+ fetchContentInProgress,
63
+ fetchCourseOverview,
62
64
  }
@@ -809,6 +809,43 @@ export async function fetchPackChildren(railcontentId) {
809
809
  return fetchChildren(railcontentId, 'pack');
810
810
  }
811
811
 
812
+ /**
813
+ * Fetch the data needed for the Course Overview screen.
814
+ * @param {string} id - The Railcontent ID of the course
815
+ * @returns {Promise<Object|null>} - The course information and lessons or null if not found.
816
+ *
817
+ * @example
818
+ * fetchCourseOverview('course123')
819
+ * .then(course => console.log(course))
820
+ * .catch(error => console.error(error));
821
+ */
822
+ export async function fetchCourseOverview(id) {
823
+ // WIP
824
+ const query = `*[railcontent_id == ${id}]{
825
+ "id": railcontent_id,
826
+ railcontent_id,
827
+ title,
828
+ "image": thumbnail.asset->url,
829
+ "instructors": instructor[]->name,
830
+ difficulty,
831
+ difficulty_string,
832
+ web_url_path,
833
+ published_on,
834
+ "type": _type,
835
+ total_xp,
836
+ xp,
837
+ "description": description[0]->children[0]->text,
838
+ "lessons": child[]->{
839
+ "id": railcontent_id,
840
+ title,
841
+ "image": thumbnail.asset->url,
842
+ "instructors": instructor[]->name,
843
+ length_in_seconds,
844
+ }
845
+ }`
846
+ return fetchSanity(query, false);
847
+ }
848
+
812
849
  /**
813
850
  * Fetch data from the Sanity API based on a provided query.
814
851
  *