musora-content-services 1.0.77 → 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.
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.77",
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
package/src/index.d.ts CHANGED
@@ -27,8 +27,12 @@ import {
27
27
  fetchCourseOverview,
28
28
  fetchChallengeOverview,
29
29
  } from './services/sanity.js';
30
-
31
- import { initializeService } from './services/config.js';
30
+
31
+ import {
32
+ fetchVimeoData,
33
+ } from "./services/railcontent";
34
+
35
+ import { initializeService } from './services/config.js';
32
36
 
33
37
  declare module 'musora-content-services' {
34
38
  export {
@@ -60,6 +64,7 @@ declare module 'musora-content-services' {
60
64
  fetchCourseOverview,
61
65
  fetchLiveEvent,
62
66
  fetchChallengeOverview,
67
+ fetchVimeoData,
63
68
  }
64
69
 
65
70
  }
package/src/index.js CHANGED
@@ -36,7 +36,8 @@ import {
36
36
  import {
37
37
  fetchCompletedState,
38
38
  fetchAllCompletedStates,
39
- fetchContentInProgress
39
+ fetchContentInProgress,
40
+ fetchVimeoData,
40
41
  } from './services/railcontent.js';
41
42
 
42
43
 
@@ -75,4 +76,5 @@ export {
75
76
  fetchMethodPreviousNextLesson,
76
77
  fetchLiveEvent,
77
78
  fetchChallengeOverview,
79
+ fetchVimeoData,
78
80
  }
@@ -37,6 +37,40 @@ export async function fetchCompletedState(content_id) {
37
37
  }
38
38
  }
39
39
 
40
+ /**
41
+ * Fetches the vimeo meta-data
42
+ *
43
+ * @param {string} vimeo_id - The vimeo id, found in the <document>.video.external_id field for lessons
44
+ * @returns {Promise<Object|null>} - Returns the
45
+ * @example
46
+ * fetchVimeoData('642900215')
47
+ * .then(vimeoData => console.log(vimeoData))
48
+ * .catch(error => console.error(error));
49
+ */
50
+ export async function fetchVimeoData(vimeo_id) {
51
+ const url = `/content/vimeo-data/${vimeo_id}`;
52
+
53
+ const headers = {
54
+ 'Content-Type': 'application/json',
55
+ 'X-CSRF-TOKEN': globalConfig.railcontentConfig.token
56
+ };
57
+
58
+ try {
59
+ const response = await fetch(url, { headers });
60
+ const result = await response.json();
61
+
62
+ if (result) {
63
+ return result; // Return the correct object
64
+ } else {
65
+ console.log('Invalid result structure', result);
66
+ return null; // Handle unexpected structure
67
+ }
68
+ } catch (error) {
69
+ console.error('Fetch error:', error);
70
+ return null;
71
+ }
72
+ }
73
+
40
74
 
41
75
  /**
42
76
  * Fetches the completion status for multiple songs for the current user.
@@ -138,4 +172,36 @@ export async function fetchContentInProgress(type="all", brand) {
138
172
  console.error('Fetch error:', error);
139
173
  return null;
140
174
  }
175
+ }
176
+
177
+
178
+ /**
179
+ * Fetches user context data for a specific piece of content.
180
+ *
181
+ * @param {int} contentId - The content id.
182
+ * @returns {Promise<Object|null>} - Returns an object containing user context data if found, otherwise null.
183
+ * @example
184
+ * fetchContentPageUserData(406548)
185
+ * .then(data => console.log(data))
186
+ * .catch(error => console.error(error));
187
+ */
188
+ export async function fetchContentPageUserData(contentId) {
189
+ let url = `/content/${contentId}/user_data/${globalConfig.railcontentConfig.userId}`;
190
+ const headers = {
191
+ 'Content-Type': 'application/json',
192
+ 'X-CSRF-TOKEN': globalConfig.railcontentConfig.token
193
+ };
194
+ try {
195
+ const response = await fetch(url, { headers });
196
+ const result = await response.json();
197
+ if(result){
198
+ console.log('fetchContentPageUserData', result);
199
+ return result;
200
+ } else {
201
+ console.log('result not json');
202
+ }
203
+ } catch (error) {
204
+ console.error('Fetch error:', error);
205
+ return null;
206
+ }
141
207
  }
@@ -56,7 +56,7 @@ describe('Sanity Queries', function () {
56
56
  const artistNames = response.map((x) => x.name);
57
57
  expect(artistNames).toContain("Arctic Monkeys");
58
58
 
59
- });
59
+ }, 10000);
60
60
 
61
61
  test('fetchSongArtistCount', async () => {
62
62
  const response = await fetchSongArtistCount('drumeo');