musora-content-services 1.0.34 → 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/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.0.35](https://github.com/railroadmedia/musora-content-services/compare/v1.0.34...v1.0.35) (2024-08-15)
6
+
5
7
  ### [1.0.34](https://github.com/railroadmedia/musora-content-services/compare/v1.0.32...v1.0.34) (2024-08-15)
6
8
 
7
9
  ### [1.0.32](https://github.com/railroadmedia/musora-content-services/compare/v1.0.31...v1.0.32) (2024-08-14)
package/README.md CHANGED
@@ -26,6 +26,20 @@ To publish a new version to NPM run,
26
26
  ./publish.sh
27
27
  ```
28
28
 
29
+ ## Symlinking
30
+
31
+ To link this package to the MWP repo for local development run,
32
+
33
+ ```bash
34
+ ./link_mcs.sh
35
+ ```
36
+
37
+ If either of these commands fail due to permissions,
38
+
39
+ ```
40
+ chmod +x <command>
41
+ ```
42
+
29
43
  ## Publish Documentation
30
44
 
31
45
  This repo uses JSDoc to generate API documention. To update the docs, run:
@@ -111,7 +111,7 @@ module.exports = {
111
111
  <br class="clear">
112
112
 
113
113
  <footer>
114
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Thu Aug 15 2024 19:44:49 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
114
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Thu Aug 15 2024 22:11:38 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
115
115
  </footer>
116
116
 
117
117
  <script>prettyPrint();</script>
package/docs/index.html CHANGED
@@ -78,6 +78,13 @@
78
78
  <p>To publish a new version to NPM run,</p>
79
79
  <pre class="prettyprint source lang-bash"><code>./publish.sh
80
80
  </code></pre>
81
+ <h2>Symlinking</h2>
82
+ <p>To link this package to the MWP repo for local development run,</p>
83
+ <pre class="prettyprint source lang-bash"><code>./link_mcs.sh
84
+ </code></pre>
85
+ <p>If either of these commands fail due to permissions,</p>
86
+ <pre class="prettyprint source"><code>chmod +x &lt;command>
87
+ </code></pre>
81
88
  <h2>Publish Documentation</h2>
82
89
  <p>This repo uses JSDoc to generate API documention. To update the docs, run:</p>
83
90
  <pre class="prettyprint source lang-bash"><code>npm run doc
@@ -103,7 +110,7 @@ Run the following to execute the tests</p>
103
110
  <br class="clear">
104
111
 
105
112
  <footer>
106
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Thu Aug 15 2024 19:44:49 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
113
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Thu Aug 15 2024 22:11:38 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
107
114
  </footer>
108
115
 
109
116
  <script>prettyPrint();</script>
@@ -656,7 +656,7 @@ initializeService({
656
656
  <br class="clear">
657
657
 
658
658
  <footer>
659
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Thu Aug 15 2024 19:44:49 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
659
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Thu Aug 15 2024 22:11:38 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
660
660
  </footer>
661
661
 
662
662
  <script>prettyPrint();</script>
@@ -783,7 +783,7 @@
783
783
  <br class="clear">
784
784
 
785
785
  <footer>
786
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Thu Aug 15 2024 19:44:49 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
786
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Thu Aug 15 2024 22:11:38 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
787
787
  </footer>
788
788
 
789
789
  <script>prettyPrint();</script>
@@ -4881,7 +4881,7 @@ This function retrieves the latest workout content for a given brand, fetching u
4881
4881
  <br class="clear">
4882
4882
 
4883
4883
  <footer>
4884
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Thu Aug 15 2024 19:44:49 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
4884
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Thu Aug 15 2024 22:11:38 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
4885
4885
  </footer>
4886
4886
 
4887
4887
  <script>prettyPrint();</script>
@@ -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 Thu Aug 15 2024 19:44:49 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 Thu Aug 15 2024 22:11:38 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>
@@ -516,7 +516,7 @@ export async function fetchAll(brand, type, {
516
516
  sort = "-published_on",
517
517
  includedFields = [],
518
518
  groupBy = ""
519
- }) {
519
+ } = {}) {
520
520
  let config = contentTypeConfig[type] ?? {};
521
521
  let additionalFields = config?.fields ?? [];
522
522
  let isGroupByOneToOne = (groupBy ? config?.relationships[groupBy]?.isOneToOne : false) ?? false;
@@ -951,7 +951,7 @@ function checkSanityConfig(config) {
951
951
  <br class="clear">
952
952
 
953
953
  <footer>
954
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Thu Aug 15 2024 19:44:49 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
954
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Thu Aug 15 2024 22:11:38 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
955
955
  </footer>
956
956
 
957
957
  <script>prettyPrint();</script>
package/link_mcs.sh ADDED
@@ -0,0 +1,20 @@
1
+ #!/bin/bash
2
+
3
+ # Define the paths (edit these paths according to your directory structure)
4
+ MUSORA_CONTENT_SERVICES_DIR="../musora-content-services"
5
+ MUSORA_WEB_PLATFORM_DIR="../musora-web-platform"
6
+
7
+ # Navigate to the musora-content-services directory and create a symlink
8
+ echo "Linking musora-content-services..."
9
+ cd "$MUSORA_CONTENT_SERVICES_DIR" || { echo "Directory not found: $MUSORA_CONTENT_SERVICES_DIR"; exit 1; }
10
+ npm link
11
+
12
+ # Navigate to the musora-web-platform directory and link the package
13
+ echo "Linking musora-content-services to musora-web-platform..."
14
+ cd "$MUSORA_WEB_PLATFORM_DIR" || { echo "Directory not found: $MUSORA_WEB_PLATFORM_DIR"; exit 1; }
15
+ npm link musora-content-services
16
+
17
+ echo "Symlink created successfully. You can now test your changes locally."
18
+
19
+ # Optional: List the linked packages to verify
20
+ npm ls musora-content-services
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "1.0.34",
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
  }
@@ -469,7 +469,7 @@ export async function fetchAll(brand, type, {
469
469
  sort = "-published_on",
470
470
  includedFields = [],
471
471
  groupBy = ""
472
- }) {
472
+ } = {}) {
473
473
  let config = contentTypeConfig[type] ?? {};
474
474
  let additionalFields = config?.fields ?? [];
475
475
  let isGroupByOneToOne = (groupBy ? config?.relationships[groupBy]?.isOneToOne : false) ?? false;
@@ -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
  *