musora-content-services 1.0.126 → 1.0.127

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.127](https://github.com/railroadmedia/musora-content-services/compare/v1.0.123...v1.0.127) (2024-10-03)
6
+
5
7
  ### [1.0.126](https://github.com/railroadmedia/musora-content-services/compare/v1.0.124...v1.0.126) (2024-10-02)
6
8
 
7
9
  ### [1.0.125](https://github.com/railroadmedia/musora-content-services/compare/v1.0.124...v1.0.125) (2024-10-02)
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.127",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -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
  }
@@ -664,7 +669,7 @@ export async function fetchAllFilterOptions(
664
669
  }
665
670
  }
666
671
  }`;
667
- return fetchSanity(query, true);
672
+ return fetchSanity(query, true, {processNeedAccess:false});
668
673
  }
669
674
 
670
675
  /**
@@ -752,6 +757,7 @@ export async function fetchMethod(brand, slug) {
752
757
  video,
753
758
  length_in_seconds,
754
759
  "type": _type,
760
+ "permission_id": permission[]->railcontent_id,
755
761
  "levels": child[]->
756
762
  {
757
763
  "id": railcontent_id,
@@ -962,8 +968,8 @@ export async function fetchRelatedLessons(railContentId, brand) {
962
968
  //TODO: Implement $this->contentService->getFiltered
963
969
  const query = `*[railcontent_id == ${railContentId} && brand == "${brand}" && references(*[_type=='permission']._id)]{
964
970
  "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])
971
+ ...(*[_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]),
972
+ ...(*[_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
973
  ])|order(published_on, railcontent_id)[0...11]}`;
968
974
  return fetchSanity(query, false);
969
975
  }
@@ -1364,6 +1370,10 @@ async function needsAccessDecorator(results)
1364
1370
  results.forEach((result) => {
1365
1371
  result['need_access'] = doesUserNeedAccessToContent(result, userPermissions);
1366
1372
  });
1373
+ }else if (results.entity && Array.isArray(results.entity)) {
1374
+ results.entity.forEach((result) => {
1375
+ result['need_access'] = doesUserNeedAccessToContent(result, userPermissions);
1376
+ });
1367
1377
  } else {
1368
1378
  results['need_access'] = doesUserNeedAccessToContent(results, userPermissions);
1369
1379
  }
@@ -1373,7 +1383,8 @@ async function needsAccessDecorator(results)
1373
1383
  function doesUserNeedAccessToContent(result, userPermissions)
1374
1384
  {
1375
1385
  const permissions = new Set(result.permission_id ?? []);
1376
- if (permissions.length === 0) {
1386
+
1387
+ if (permissions.size === 0) {
1377
1388
  return false;
1378
1389
  }
1379
1390
  for (let permission of permissions) {
@@ -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
  /**