musora-content-services 1.0.141 → 1.0.142

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.
Files changed (59) hide show
  1. package/.github/workflows/node.js.yml +0 -0
  2. package/CHANGELOG.md +2 -0
  3. package/README.md +0 -0
  4. package/babel.config.js +0 -0
  5. package/docs/config.js.html +0 -0
  6. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  7. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  8. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  9. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  10. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  11. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  12. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  13. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  14. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  15. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +0 -0
  16. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  17. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  18. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  19. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  20. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +0 -0
  21. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  22. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  23. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  24. package/docs/index.html +0 -0
  25. package/docs/module-Config.html +0 -0
  26. package/docs/module-Railcontent-Services.html +0 -0
  27. package/docs/module-Sanity-Services.html +0 -0
  28. package/docs/railcontent.js.html +0 -0
  29. package/docs/sanity.js.html +0 -0
  30. package/docs/scripts/collapse.js +0 -0
  31. package/docs/scripts/commonNav.js +0 -0
  32. package/docs/scripts/linenumber.js +0 -0
  33. package/docs/scripts/nav.js +0 -0
  34. package/docs/scripts/polyfill.js +0 -0
  35. package/docs/scripts/prettify/Apache-License-2.0.txt +0 -0
  36. package/docs/scripts/prettify/lang-css.js +0 -0
  37. package/docs/scripts/prettify/prettify.js +0 -0
  38. package/docs/scripts/search.js +0 -0
  39. package/docs/styles/jsdoc.css +0 -0
  40. package/docs/styles/prettify.css +0 -0
  41. package/jest.config.js +0 -0
  42. package/jsdoc.json +0 -0
  43. package/link_mcs.sh +0 -0
  44. package/package.json +1 -1
  45. package/src/contentMetaData.js +0 -0
  46. package/src/contentTypeConfig.js +43 -0
  47. package/src/filterBuilder.js +0 -0
  48. package/src/index.d.ts +3 -1
  49. package/src/index.js +3 -1
  50. package/src/services/config.js +0 -0
  51. package/src/services/contentLikes.js +0 -0
  52. package/src/services/dataContext.js +3 -1
  53. package/src/services/sanity.js +22 -0
  54. package/test/contentLikes.test.js +0 -0
  55. package/test/localStorageMock.js +0 -0
  56. package/test/log.js +0 -0
  57. package/test/playlists.test.js +86 -0
  58. package/test/sanityQueryService.test.js +0 -0
  59. package/tools/generate-index.js +0 -0
File without changes
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.142](https://github.com/railroadmedia/musora-content-services/compare/v1.0.141...v1.0.142) (2024-10-22)
6
+
5
7
  ### [1.0.141](https://github.com/railroadmedia/musora-content-services/compare/v1.0.140...v1.0.141) (2024-10-17)
6
8
 
7
9
  ### [1.0.140](https://github.com/railroadmedia/musora-content-services/compare/v1.0.139...v1.0.140) (2024-10-16)
package/README.md CHANGED
File without changes
package/babel.config.js CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/docs/index.html CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/jest.config.js CHANGED
File without changes
package/jsdoc.json CHANGED
File without changes
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.141",
3
+ "version": "1.0.142",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
File without changes
@@ -135,6 +135,49 @@ let contentTypeConfig = {
135
135
  ],
136
136
  'slug':'courses',
137
137
  },
138
+ 'parent-download': {
139
+ 'fields': [
140
+ '"lesson_count": child_count',
141
+ '"instructors": instructor[]->name',
142
+ `"description": ${descriptionField}`,
143
+ 'resource',
144
+ 'xp',
145
+ 'total_xp',
146
+ `"lessons": child[]->{
147
+ "id": railcontent_id,
148
+ title,
149
+ published_on,
150
+ "type":_type,
151
+ "image": thumbnail.asset->url,
152
+ "instructors": instructor[]->name,
153
+ length_in_seconds,
154
+ "resources": resource,
155
+ difficulty,
156
+ difficulty_string,
157
+ artist->,
158
+ "thumbnail_url":thumbnail.asset->url,
159
+ "description": description[0].children[0].text,
160
+ "chapters": chapter[]{
161
+ chapter_description,
162
+ chapter_timecode,
163
+ "chapter_thumbnail_url": chapter_thumbnail_url.asset->url
164
+ },
165
+ "instructors":instructor[]->name,
166
+ "instructor": instructor[]->{
167
+ "id":railcontent_id,
168
+ name,
169
+ short_bio,
170
+ "biography": short_bio[0].children[0].text,
171
+ web_url_path,
172
+ "coach_card_image": coach_card_image.asset->url,
173
+ "coach_profile_image":thumbnail_url.asset->url
174
+ },
175
+ ${assignmentsField}
176
+ video,
177
+ parent_content_data,
178
+ }`,
179
+ ],
180
+ },
138
181
  'method': {
139
182
  'fields': [
140
183
  `"description": ${descriptionField}`,
File without changes
package/src/index.d.ts CHANGED
@@ -73,7 +73,8 @@ import {
73
73
  fetchSongFilterOptions,
74
74
  fetchUpcomingEvents,
75
75
  fetchWorkouts,
76
- getSortOrder
76
+ getSortOrder,
77
+ fetchParentForDownload,
77
78
  } from './services/sanity.js';
78
79
 
79
80
  declare module 'musora-content-services' {
@@ -142,5 +143,6 @@ declare module 'musora-content-services' {
142
143
  postChallengesSetStartDate,
143
144
  postChallengesUnlock,
144
145
  unlikeContent,
146
+ fetchParentForDownload,
145
147
  }
146
148
  }
package/src/index.js CHANGED
@@ -73,7 +73,8 @@ import {
73
73
  fetchSongFilterOptions,
74
74
  fetchUpcomingEvents,
75
75
  fetchWorkouts,
76
- getSortOrder
76
+ getSortOrder,
77
+ fetchParentForDownload,
77
78
  } from './services/sanity.js';
78
79
 
79
80
  export {
@@ -141,4 +142,5 @@ export {
141
142
  postChallengesSetStartDate,
142
143
  postChallengesUnlock,
143
144
  unlikeContent,
145
+ fetchParentForDownload,
144
146
  };
File without changes
File without changes
@@ -24,7 +24,9 @@ export class DataContext {
24
24
 
25
25
  async getData() {
26
26
  await this.ensureLocalContextLoaded();
27
- if (!this.context || this.shouldVerifyServerVerions()) {
27
+ const shouldVerify = await this.shouldVerifyServerVerions();
28
+
29
+ if ((!this.context) || shouldVerify) {
28
30
  let version = this.version();
29
31
  let data = await this.fetchData(version);
30
32
  if (data.version !== "No Change") {
@@ -1211,6 +1211,28 @@ export async function fetchCourseOverview(id) {
1211
1211
  return fetchByRailContentId(id, 'course');
1212
1212
  }
1213
1213
 
1214
+ /**
1215
+ * Fetch the data needed for the Course Overview screen.
1216
+ * @param {string} id - The Railcontent ID of the course
1217
+ * @returns {Promise<Object|null>} - The course information and lessons or null if not found.
1218
+ *
1219
+ * @example
1220
+ * fetchParentForDownload('course123')
1221
+ * .then(course => console.log(course))
1222
+ * .catch(error => console.error(error));
1223
+ */
1224
+ export async function fetchParentForDownload(id) {
1225
+ const query = buildRawQuery(
1226
+ `railcontent_id == ${id}`,
1227
+ getFieldsForContentType('parent-download'),
1228
+ {
1229
+ isSingle: true,
1230
+ },
1231
+ );
1232
+
1233
+ return fetchSanity(query, false);
1234
+ }
1235
+
1214
1236
  /**
1215
1237
  * Fetch the data needed for the coach screen.
1216
1238
  * @param {string} id - The Railcontent ID of the coach
File without changes
File without changes
package/test/log.js CHANGED
File without changes
@@ -0,0 +1,86 @@
1
+ import {isContentLiked, dataContext, likeContent, unlikeContent} from "../src/services/contentLikes";
2
+ import {LocalStorageMock} from "./localStorageMock";
3
+ import {initializeService} from "../src";
4
+
5
+ const railContentModule = require('../src/services/railcontent.js')
6
+
7
+ describe('playlistsContext', function () {
8
+ let mock = null;
9
+ const testVersion = 1;
10
+
11
+ beforeEach(() => {
12
+ initializeService({localStorage: new LocalStorageMock()});
13
+ mock = jest.spyOn(dataContext, 'fetchData');
14
+ var json = JSON.parse(`{"version":${testVersion},"data":[308516,308515,308514,308518]}`);
15
+ mock.mockImplementation(() => json);
16
+ });
17
+
18
+ test('contentLiked', async () => {
19
+ let result = await isContentLiked(308516);
20
+ expect(result).toBe(true);
21
+ });
22
+
23
+ test('contentNotLiked', async () => {
24
+ let result = await isContentLiked(121111);
25
+ expect(result).toBe(false);
26
+ });
27
+
28
+ test('ensureOnlyOneServerFetchRequest', async () => {
29
+ dataContext.clearCache();
30
+ await isContentLiked(308516);
31
+ await isContentLiked(308514);
32
+ await isContentLiked(121111);
33
+ expect(dataContext.fetchData).toHaveBeenCalledTimes(1);
34
+ });
35
+
36
+ test('ensureDataPulledFromLocalCache', async () => {
37
+ dataContext.clearCache();
38
+ await isContentLiked(308516);
39
+ dataContext.clearContext();
40
+ await isContentLiked(308514);
41
+ expect(dataContext.fetchData).toHaveBeenCalledTimes(1);
42
+ });
43
+
44
+ test('likeContent', async () => {
45
+ mock = jest.spyOn(railContentModule, 'postContentLiked');
46
+ var json = JSON.parse(`{"version":${testVersion + 1}}`);
47
+ mock.mockImplementation(() => json);
48
+
49
+ dataContext.clearCache();
50
+ let isLiked = await isContentLiked(111111);
51
+ expect(isLiked).toBe(false);
52
+
53
+ await likeContent(111111);
54
+ isLiked = await isContentLiked(111111);
55
+ expect(isLiked).toBe(true);
56
+
57
+ dataContext.clearContext();
58
+ isLiked = await isContentLiked(111111);
59
+ expect(isLiked).toBe(true);
60
+
61
+ expect(dataContext.version()).toBe(testVersion + 1);
62
+ });
63
+
64
+
65
+ test('unlikeContent', async () => {
66
+ mock = jest.spyOn(railContentModule, 'postContentUnliked');
67
+ var json = JSON.parse(`{"version":${testVersion + 1}}`);
68
+ mock.mockImplementation(() => json);
69
+
70
+ dataContext.clearCache();
71
+ let isLiked = await isContentLiked(308516);
72
+ expect(isLiked).toBe(true);
73
+
74
+ await unlikeContent(308516);
75
+ console.log(dataContext.context);
76
+ isLiked = await isContentLiked(308516);
77
+ expect(isLiked).toBe(false);
78
+
79
+ dataContext.clearContext();
80
+ isLiked = await isContentLiked(308516);
81
+ expect(isLiked).toBe(false);
82
+
83
+ expect(dataContext.version()).toBe(testVersion + 1);
84
+ });
85
+
86
+ });
File without changes
File without changes