musora-content-services 1.0.126 → 1.0.128

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 (57) 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/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/package.json +1 -1
  44. package/src/contentMetaData.js +0 -0
  45. package/src/contentTypeConfig.js +0 -0
  46. package/src/filterBuilder.js +0 -0
  47. package/src/index.d.ts +0 -0
  48. package/src/index.js +0 -0
  49. package/src/services/config.js +0 -0
  50. package/src/services/contentLikes.js +0 -0
  51. package/src/services/dataContext.js +0 -0
  52. package/src/services/railcontent.js +0 -4
  53. package/src/services/sanity.js +22 -11
  54. package/test/contentLikes.test.js +0 -0
  55. package/test/localStorageMock.js +0 -0
  56. package/test/log.js +0 -0
  57. package/tools/generate-index.js +0 -0
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.128](https://github.com/railroadmedia/musora-content-services/compare/v1.0.127...v1.0.128) (2024-10-03)
6
+
7
+ ### [1.0.127](https://github.com/railroadmedia/musora-content-services/compare/v1.0.123...v1.0.127) (2024-10-03)
8
+
5
9
  ### [1.0.126](https://github.com/railroadmedia/musora-content-services/compare/v1.0.124...v1.0.126) (2024-10-02)
6
10
 
7
11
  ### [1.0.125](https://github.com/railroadmedia/musora-content-services/compare/v1.0.124...v1.0.125) (2024-10-02)
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "1.0.126",
3
+ "version": "1.0.128",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
File without changes
File without changes
File without changes
package/src/index.d.ts CHANGED
File without changes
package/src/index.js CHANGED
File without changes
File without changes
File without changes
File without changes
@@ -257,10 +257,6 @@ export async function fetchContentPageUserData(contentId) {
257
257
 
258
258
  export async function fetchUserPermissions() {
259
259
  let url = `/content/user_data_permissions`;
260
- const headers = {
261
- 'Content-Type': 'application/json',
262
- 'X-CSRF-TOKEN': globalConfig.railcontentConfig.token
263
- };
264
260
  // in the case of an unauthorized user, we return empty permissions
265
261
  return fetchHandler(url, 'get') ?? [];
266
262
  }
@@ -67,7 +67,7 @@ export async function fetchArtists(brand) {
67
67
  name,
68
68
  "lessonsCount": count(*[${filter}])
69
69
  }[lessonsCount > 0]`;
70
- return fetchSanity(query, true);
70
+ return fetchSanity(query, true, {processNeedAccess:false});
71
71
  }
72
72
 
73
73
  /**
@@ -77,7 +77,7 @@ export async function fetchArtists(brand) {
77
77
  */
78
78
  export async function fetchSongArtistCount(brand) {
79
79
  const query = `count(*[_type == 'artist']{'lessonsCount': count(*[_type == 'song' && brand == '${brand}' && references(^._id)]._id)}[lessonsCount > 0])`;
80
- return fetchSanity(query, true);
80
+ return fetchSanity(query, true, {processNeedAccess:false});
81
81
  }
82
82
 
83
83
  /**
@@ -234,7 +234,7 @@ export async function fetchSongFilterOptions(brand) {
234
234
  */
235
235
  export async function fetchSongCount(brand) {
236
236
  const query = `count(*[_type == 'song' && brand == "${brand}"])`;
237
- return fetchSanity(query, true);
237
+ return fetchSanity(query, true, {processNeedAccess:false});
238
238
  }
239
239
 
240
240
  /**
@@ -243,7 +243,8 @@ export async function fetchSongCount(brand) {
243
243
  * It also includes completion status and progress percentage for each workout by fetching additional data about user progress.
244
244
  *
245
245
  * @param {string} brand - The brand for which to fetch workouts (e.g., 'drumeo', 'pianote').
246
- * @returns {Promise<Array<Object>|null>} - A promise that resolves to an array of workout data objects with additional properties for completion status and progress percentage, or null if no workouts are found.
246
+ * @returns {Promise<Array<Object>|null>} - A promise that resolves to an array of workout data objects with additional properties for completion status and progress percentage,
247
+ * or null if no workouts are found.
247
248
  *
248
249
  * @example
249
250
  * fetchWorkouts('drumeo')
@@ -281,7 +282,9 @@ export async function fetchNewReleases(brand, { page = 1, limit = 20, sort="-pub
281
282
  length_in_seconds,
282
283
  published_on,
283
284
  "type": _type,
284
- web_url_path,`;
285
+ web_url_path,
286
+ "permission_id": permission[]->railcontent_id,
287
+ `;
285
288
  const filterParams = {};
286
289
  const query = buildQuery(
287
290
  filter,
@@ -326,7 +329,8 @@ export async function fetchUpcomingEvents(brand, { page = 1, limit = 10 } = {})
326
329
  length_in_seconds,
327
330
  published_on,
328
331
  "type": _type,
329
- web_url_path,`;
332
+ web_url_path,
333
+ "permission_id": permission[]->railcontent_id,`;
330
334
  const query = buildRawQuery(
331
335
  `_type in ${typesString} && brand == '${brand}' && published_on > '${now}' && status == 'scheduled'`,
332
336
  fields,
@@ -374,6 +378,7 @@ export async function fetchScheduledReleases(brand, { page = 1, limit = 10 }) {
374
378
  published_on,
375
379
  "type": _type,
376
380
  web_url_path,
381
+ "permission_id": permission[]->railcontent_id,
377
382
  } | order(published_on asc)[${start}...${end}]`;
378
383
  return fetchSanity(query, true);
379
384
  }
@@ -613,6 +618,7 @@ export async function fetchAllFilterOptions(
613
618
  progressIds = undefined,
614
619
  coachId = undefined, // New parameter for coach ID
615
620
  ) {
621
+ console.log('brand', brand)
616
622
  if (coachId && contentType !== 'coach-lessons') {
617
623
  throw new Error(`Invalid contentType: '${contentType}' for coachId. It must be 'coach-lessons'.`);
618
624
  }
@@ -664,7 +670,7 @@ export async function fetchAllFilterOptions(
664
670
  }
665
671
  }
666
672
  }`;
667
- return fetchSanity(query, true);
673
+ return fetchSanity(query, true, {processNeedAccess:false});
668
674
  }
669
675
 
670
676
  /**
@@ -752,6 +758,7 @@ export async function fetchMethod(brand, slug) {
752
758
  video,
753
759
  length_in_seconds,
754
760
  "type": _type,
761
+ "permission_id": permission[]->railcontent_id,
755
762
  "levels": child[]->
756
763
  {
757
764
  "id": railcontent_id,
@@ -962,8 +969,8 @@ export async function fetchRelatedLessons(railContentId, brand) {
962
969
  //TODO: Implement $this->contentService->getFiltered
963
970
  const query = `*[railcontent_id == ${railContentId} && brand == "${brand}" && references(*[_type=='permission']._id)]{
964
971
  "related_lessons" : array::unique([
965
- ...(*[_type=="song" && brand == "${brand}" && references(^.artist->_id)]{_id, "id":railcontent_id, published_on, title, "thumbnail_url":thumbnail.asset->url, difficulty_string, railcontent_id, artist->}[0...11]),
966
- ...(*[_type=="song" && brand == "${brand}" && references(^.genre[]->_id)]{_id, "id":railcontent_id, published_on, title, "thumbnail_url":thumbnail.asset->url, difficulty_string, railcontent_id, artist->}[0...11])
972
+ ...(*[_type=="song" && brand == "${brand}" && references(^.artist->_id)]{_id, "id":railcontent_id, published_on, title, "thumbnail_url":thumbnail.asset->url, difficulty_string, railcontent_id, artist->,"permission_id": permission[]->railcontent_id,}[0...11]),
973
+ ...(*[_type=="song" && brand == "${brand}" && references(^.genre[]->_id)]{_id, "id":railcontent_id, published_on, title, "thumbnail_url":thumbnail.asset->url, difficulty_string, railcontent_id, artist->,"permission_id": permission[]->railcontent_id,}[0...11])
967
974
  ])|order(published_on, railcontent_id)[0...11]}`;
968
975
  return fetchSanity(query, false);
969
976
  }
@@ -1364,6 +1371,10 @@ async function needsAccessDecorator(results)
1364
1371
  results.forEach((result) => {
1365
1372
  result['need_access'] = doesUserNeedAccessToContent(result, userPermissions);
1366
1373
  });
1374
+ }else if (results.entity && Array.isArray(results.entity)) {
1375
+ results.entity.forEach((result) => {
1376
+ result['need_access'] = doesUserNeedAccessToContent(result, userPermissions);
1377
+ });
1367
1378
  } else {
1368
1379
  results['need_access'] = doesUserNeedAccessToContent(results, userPermissions);
1369
1380
  }
@@ -1372,7 +1383,7 @@ async function needsAccessDecorator(results)
1372
1383
 
1373
1384
  function doesUserNeedAccessToContent(result, userPermissions)
1374
1385
  {
1375
- const permissions = new Set(result.permission_id ?? []);
1386
+ const permissions = new Set(result?.permission_id ?? []);
1376
1387
  if (permissions.length === 0) {
1377
1388
  return false;
1378
1389
  }
@@ -1413,7 +1424,7 @@ export async function fetchCatalogMetadata(contentType)
1413
1424
  modal_text,
1414
1425
  sort_by,
1415
1426
  }`
1416
- return fetchSanity(query, false);
1427
+ return fetchSanity(query, false, {processNeedAccess:false});
1417
1428
  }
1418
1429
 
1419
1430
  /**
File without changes
File without changes
package/test/log.js CHANGED
File without changes
File without changes