musora-content-services 1.0.82 → 1.0.84

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 (41) hide show
  1. package/.github/workflows/node.js.yml +0 -0
  2. package/CHANGELOG.md +4 -0
  3. package/README.md +0 -0
  4. package/babel.config.js +0 -0
  5. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  6. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  7. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  8. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  9. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  10. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  11. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  12. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  13. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  14. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +0 -0
  15. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  16. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  17. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  18. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  19. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +0 -0
  20. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  21. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  22. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  23. package/docs/scripts/collapse.js +0 -0
  24. package/docs/scripts/commonNav.js +0 -0
  25. package/docs/scripts/linenumber.js +0 -0
  26. package/docs/scripts/nav.js +0 -0
  27. package/docs/scripts/polyfill.js +0 -0
  28. package/docs/scripts/prettify/Apache-License-2.0.txt +0 -0
  29. package/docs/scripts/prettify/lang-css.js +0 -0
  30. package/docs/scripts/prettify/prettify.js +0 -0
  31. package/docs/scripts/search.js +0 -0
  32. package/docs/styles/jsdoc.css +0 -0
  33. package/docs/styles/prettify.css +0 -0
  34. package/jest.config.js +0 -0
  35. package/jsdoc.json +0 -0
  36. package/package.json +1 -1
  37. package/src/contentTypeConfig.js +15 -11
  38. package/src/index.js +2 -0
  39. package/src/services/config.js +0 -0
  40. package/src/services/sanity.js +31 -0
  41. package/test/sanityQueryService.test.js +8 -2
File without changes
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
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.84](https://github.com/railroadmedia/musora-content-services/compare/v1.0.83...v1.0.84) (2024-09-06)
6
+
7
+ ### [1.0.83](https://github.com/railroadmedia/musora-content-services/compare/v1.0.82...v1.0.83) (2024-09-06)
8
+
5
9
  ### [1.0.82](https://github.com/railroadmedia/musora-content-services/compare/v1.0.81...v1.0.82) (2024-09-06)
6
10
 
7
11
  ### [1.0.81](https://github.com/railroadmedia/musora-content-services/compare/v1.0.80...v1.0.81) (2024-09-05)
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
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "1.0.82",
3
+ "version": "1.0.84",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -225,18 +225,22 @@ function getFieldsForContentType(contentType, asQueryString=true) {
225
225
  function filtersToGroq(filters) {
226
226
  const groq = filters.map(field => {
227
227
  let [key, value] = field.split(',');
228
- switch (key) {
229
- case 'difficulty':
230
- return `&& difficulty_string == "${value}"`;
231
- case 'genre':
232
- return `&& genre[]->name match "${value}"`;
233
- case 'topic':
234
- return `&& topic[]->name match "${value}"`;
235
- case 'instrumentless':
236
- return `&& instrumentless == ${value}`;
237
- default:
238
- return `&& ${key} == ${/^\d+$/.test(value) ? value : `"$${value}"`}`;
228
+ if(key && value){
229
+ switch (key) {
230
+ case 'difficulty':
231
+ return `&& difficulty_string == "${value}"`;
232
+ case 'genre':
233
+ return `&& genre[]->name match "${value}"`;
234
+ case 'topic':
235
+ return `&& topic[]->name match "${value}"`;
236
+ case 'instrumentless':
237
+ return `&& instrumentless == ${value}`;
238
+ default:
239
+ return `&& ${key} == ${/^\d+$/.test(value) ? value : `"$${value}"`}`;
240
+ }
239
241
  }
242
+
243
+ return field;
240
244
  }).join(' ');
241
245
  return groq;
242
246
  }
package/src/index.js CHANGED
@@ -32,6 +32,7 @@ import {
32
32
  fetchMethodPreviousNextLesson,
33
33
  fetchLiveEvent,
34
34
  fetchChallengeOverview,
35
+ fetchCoachLessons,
35
36
  } from './services/sanity.js';
36
37
 
37
38
  import {
@@ -81,4 +82,5 @@ export {
81
82
  fetchChallengeOverview,
82
83
  fetchVimeoData,
83
84
  fetchContentPageUserData,
85
+ fetchCoachLessons,
84
86
  }
File without changes
@@ -948,6 +948,37 @@ export async function fetchChallengeOverview(id) {
948
948
  return fetchSanity(query, false);
949
949
  }
950
950
 
951
+ /**
952
+ * Fetch the data needed for the coach screen.
953
+ * @param {string} id - The Railcontent ID of the coach
954
+ * @returns {Promise<Object|null>} - The lessons for the instructor or null if not found.
955
+ *
956
+ * @example
957
+ * fetchCoachLessons('coach123')
958
+ * .then(lessons => console.log(lessons))
959
+ * .catch(error => console.error(error));
960
+ */
961
+ export async function fetchCoachLessons(brand, id, {
962
+ sortOrder = '-published_on',
963
+ searchTerm = '',
964
+ page = 1,
965
+ limit = 20,
966
+ } = {}) {
967
+ const fieldsString = DEFAULT_FIELDS.join(',');
968
+ const start = (page - 1) * limit;
969
+ const end = start + limit;
970
+ const searchFilter = searchTerm ? `&& title match "${searchTerm}*"`: ''
971
+
972
+ const query = `{
973
+ "entity": *[brand == '${brand}' ${searchFilter} && references(*[_type=='instructor' && railcontent_id == ${id}]._id)] | order(${sortOrder}) [${start}...${end}]
974
+ {
975
+ ${fieldsString}
976
+ },
977
+ "total": count(*[brand == '${brand}' && references(*[_type=='instructor' && railcontent_id == ${id}]._id)])
978
+ }`;
979
+ return fetchSanity(query, true);
980
+ }
981
+
951
982
  /**
952
983
  * Fetch the data needed for the Course Overview screen.
953
984
  * @param {string} id - The Railcontent ID of the course
@@ -28,6 +28,7 @@ const {
28
28
  fetchMethod,
29
29
  fetchMethods,
30
30
  fetchFoundation,
31
+ fetchCoachLessons,
31
32
  } = require('../src/services/sanity.js');
32
33
 
33
34
  describe('Sanity Queries', function () {
@@ -212,7 +213,7 @@ describe('Sanity Queries', function () {
212
213
 
213
214
  test('fetchMethods', async () => {
214
215
  const response = await fetchMethods('drumeo');
215
- //console.log(response);
216
+ console.log(response);
216
217
  expect(response.length).toBeGreaterThan(0);
217
218
  expect(response[0].type).toBe('learning-path');
218
219
  });
@@ -246,8 +247,13 @@ describe('Sanity Queries', function () {
246
247
 
247
248
  test('fetchFoundation', async () => {
248
249
  const response = await fetchFoundation('foundations-2019');
249
- //console.log(response);
250
+ console.log(response);
250
251
  expect(response.units.length).toBeGreaterThan(0);
251
252
  expect(response.type).toBe('foundation');
252
253
  });
254
+
255
+ test('fetchCoachLessons', async () => {
256
+ const response = await fetchCoachLessons('drumeo',233797);
257
+ expect(response.entity.length).toBeGreaterThan(0);
258
+ });
253
259
  });