musora-content-services 1.0.182 → 1.0.183

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.183](https://github.com/railroadmedia/musora-content-services/compare/v1.0.182...v1.0.183) (2024-11-25)
6
+
5
7
  ### [1.0.182](https://github.com/railroadmedia/musora-content-services/compare/v1.0.181...v1.0.182) (2024-11-25)
6
8
 
7
9
  ### [1.0.181](https://github.com/railroadmedia/musora-content-services/compare/v1.0.180...v1.0.181) (2024-11-25)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "1.0.182",
3
+ "version": "1.0.183",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -499,7 +499,8 @@ export async function fetchAll(brand, type, {
499
499
  progressIds,
500
500
  useDefaultFields,
501
501
  customFields,
502
- progress});
502
+ progress
503
+ });
503
504
  if (customResults) {
504
505
  return customResults;
505
506
  }
@@ -579,7 +580,11 @@ export async function fetchAll(brand, type, {
579
580
  entityFieldsString = fieldsString;
580
581
  }
581
582
 
582
- const filterWithRestrictions = await new FilterBuilder(filter,{bypassStatuses:bypassStatusAndPublishedValidation, bypassPermissions: bypassStatusAndPublishedValidation, bypassPublishedDateRestriction: bypassStatusAndPublishedValidation} ).buildFilter();
583
+ const filterWithRestrictions = await new FilterBuilder(filter, {
584
+ bypassStatuses: bypassStatusAndPublishedValidation,
585
+ bypassPermissions: bypassStatusAndPublishedValidation,
586
+ bypassPublishedDateRestriction: bypassStatusAndPublishedValidation
587
+ }).buildFilter();
583
588
  query = buildEntityAndTotalQuery(
584
589
  filterWithRestrictions,
585
590
  entityFieldsString,
@@ -624,7 +629,7 @@ async function handleCustomFetchAll(brand, type, {
624
629
  if (type === 'challenge') {
625
630
  if (groupBy === 'completed') {
626
631
  return fetchCompletedChallenges(brand, page, limit);
627
- } else if(groupBy === 'owned') {
632
+ } else if (groupBy === 'owned') {
628
633
  return fetchOwnedChallenges(brand, page, limit);
629
634
  }
630
635
  }
@@ -909,7 +914,10 @@ export async function fetchMethodPreviousNextLesson(railcontentId, methodId) {
909
914
  const index = sortedChildren.indexOf(Number(railcontentId));
910
915
  let nextId = sortedChildren[index + 1];
911
916
  let previousId = sortedChildren[index - 1];
912
- let nextPrev = await fetchByRailContentIds([nextId, previousId]);
917
+ let ids = [];
918
+ if (nextId) ids.push(nextId);
919
+ if (previousId) ids.push(previousId);
920
+ let nextPrev = await fetchByRailContentIds(ids);
913
921
  const nextLesson = nextPrev.find((elem) => {
914
922
  return elem['id'] === nextId
915
923
  });
@@ -996,7 +1004,7 @@ export async function fetchNextPreviousLesson(railcontentId) {
996
1004
  * .catch(error => console.error(error));
997
1005
  */
998
1006
  export async function fetchLessonContent(railContentId) {
999
- const filterParams = {isSingle:true};
1007
+ const filterParams = {isSingle: true};
1000
1008
  // Format changes made to the `fields` object may also need to be reflected in Musora-web-platform SanityGateway.php $fields object
1001
1009
  // Currently only for challenges and challenge lessons
1002
1010
  // If you're unsure, message Adrian, or just add them.
@@ -1,5 +1,10 @@
1
1
  import {getFieldsForContentType} from "../src/contentTypeConfig";
2
- import {fetchAssignments, fetchCommentModContentData, fetchSanity} from "../src/services/sanity";
2
+ import {
3
+ fetchAssignments,
4
+ fetchCommentModContentData,
5
+ fetchMethodPreviousNextLesson,
6
+ fetchSanity
7
+ } from "../src/services/sanity";
3
8
  import {log} from './log.js';
4
9
  import {initializeTestService} from "./initializeTests";
5
10
  import {dataContext} from "../src/services/contentProgress";
@@ -555,6 +560,17 @@ describe('Sanity Queries', function () {
555
560
  expect(response.nextLesson.sort).toBeGreaterThanOrEqual(document.sort);
556
561
  });
557
562
 
563
+ test('fetchMethodNextPreviousLesson-Last', async () => {
564
+ const id = 396234;
565
+ const methodId = 396229;
566
+ const response = await fetchMethodPreviousNextLesson(id, methodId);
567
+ log(response);
568
+ expect(response.prevLesson).toBeDefined();
569
+ expect(response.prevLesson.id).toBe(396233);
570
+ expect(response.prevLesson.type).toBe('course-part');
571
+ expect(response.nextLesson).not.toBeDefined();
572
+ });
573
+
558
574
  test('fetchNextPreviousLesson-Method-Lesson', async () => {
559
575
  const id = 241265;
560
576
  const response = await fetchNextPreviousLesson(id);