musora-content-services 1.0.165 → 1.0.167

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,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.167](https://github.com/railroadmedia/musora-content-services/compare/v1.0.166...v1.0.167) (2024-11-11)
6
+
7
+ ### [1.0.166](https://github.com/railroadmedia/musora-content-services/compare/v1.0.165...v1.0.166) (2024-11-11)
8
+
5
9
  ### [1.0.165](https://github.com/railroadmedia/musora-content-services/compare/v1.0.164...v1.0.165) (2024-11-11)
6
10
 
7
11
  ### [1.0.164](https://github.com/railroadmedia/musora-content-services/compare/v1.0.163...v1.0.164) (2024-11-09)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "1.0.165",
3
+ "version": "1.0.167",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/index.d.ts CHANGED
@@ -83,6 +83,7 @@ import {
83
83
  fetchChallengeOverview,
84
84
  fetchChildren,
85
85
  fetchCoachLessons,
86
+ fetchCommentModContentData,
86
87
  fetchCourseOverview,
87
88
  fetchFoundation,
88
89
  fetchGenreLessons,
@@ -152,6 +153,7 @@ declare module 'musora-content-services' {
152
153
  fetchChallengeOverview,
153
154
  fetchChildren,
154
155
  fetchCoachLessons,
156
+ fetchCommentModContentData,
155
157
  fetchCompletedContent,
156
158
  fetchCompletedState,
157
159
  fetchContentInProgress,
package/src/index.js CHANGED
@@ -83,6 +83,7 @@ import {
83
83
  fetchChallengeOverview,
84
84
  fetchChildren,
85
85
  fetchCoachLessons,
86
+ fetchCommentModContentData,
86
87
  fetchCourseOverview,
87
88
  fetchFoundation,
88
89
  fetchGenreLessons,
@@ -151,6 +152,7 @@ export {
151
152
  fetchChallengeOverview,
152
153
  fetchChildren,
153
154
  fetchCoachLessons,
155
+ fetchCommentModContentData,
154
156
  fetchCompletedContent,
155
157
  fetchCompletedState,
156
158
  fetchContentInProgress,
@@ -1436,6 +1436,27 @@ function populateHierarchyLookups(currentLevel, data, parentId) {
1436
1436
  }
1437
1437
  }
1438
1438
 
1439
+ /**
1440
+ * Fetch data for comment mod page
1441
+ *
1442
+ * @param {array} ids - List of ids get data for
1443
+ * @returns {Promise<Object|null>} - A promise that resolves to an object containing the data
1444
+ */
1445
+ export async function fetchCommentModContentData(ids) {
1446
+ const idsString = ids.join(',');
1447
+ const fields = `"id": railcontent_id, "type": _type, title, "parent": *[^._id in child[]._ref]{"id": railcontent_id, title}`;
1448
+ const query = await buildQuery(`railcontent_id in [${idsString}]`,
1449
+ {bypassPermissions: true},
1450
+ fields,
1451
+ {});
1452
+ let data = await fetchSanity(query, true);
1453
+ let mapped = {};
1454
+ data.forEach(function (content) {
1455
+ mapped[content.id] = {"id": content.id, "type": content.type,"title": content.title, "parentTitle": content.parent[0].title};
1456
+ });
1457
+ return mapped;
1458
+ }
1459
+
1439
1460
 
1440
1461
  /**
1441
1462
  *
@@ -1,5 +1,5 @@
1
1
  import {getFieldsForContentType} from "../src/contentTypeConfig";
2
- import {fetchSanity} from "../src/services/sanity";
2
+ import {fetchCommentModContentData, fetchSanity} from "../src/services/sanity";
3
3
  import {log} from './log.js';
4
4
  import {initializeTestService} from "./initializeTests";
5
5
 
@@ -572,6 +572,14 @@ describe('Sanity Queries', function () {
572
572
  expect(hierarchy.children[243085]).toStrictEqual([243170, 243171, 243172, 243174, 243176]);
573
573
  });
574
574
 
575
+ test('fetchCommentData', async()=>{
576
+ let data = await fetchCommentModContentData([241251,241252]);
577
+ expect(data[241251].title).toBe("Setting Up Your Space");
578
+ expect(data[241251].type).toBe("learning-path-lesson");
579
+ expect(data[241251].parentTitle).toBe("Gear");
580
+ expect(data[241252].title).toBe("Setting Up Your Pedals & Throne");
581
+ });
582
+
575
583
  });
576
584
 
577
585
  describe('Filter Builder', function () {