musora-content-services 1.6.2 → 1.6.4

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 (47) hide show
  1. package/.github/workflows/node.js.yml +0 -0
  2. package/.prettierignore +0 -0
  3. package/.prettierrc +0 -0
  4. package/CHANGELOG.md +4 -0
  5. package/README.md +0 -0
  6. package/babel.config.cjs +0 -0
  7. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  8. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  9. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  10. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  11. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  12. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  13. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  14. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  15. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  16. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +0 -0
  17. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  18. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  19. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  20. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  21. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +0 -0
  22. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  23. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  24. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  25. package/docs/scripts/collapse.js +0 -0
  26. package/docs/scripts/commonNav.js +0 -0
  27. package/docs/scripts/linenumber.js +0 -0
  28. package/docs/scripts/nav.js +0 -0
  29. package/docs/scripts/polyfill.js +0 -0
  30. package/docs/scripts/prettify/Apache-License-2.0.txt +0 -0
  31. package/docs/scripts/prettify/lang-css.js +0 -0
  32. package/docs/scripts/prettify/prettify.js +0 -0
  33. package/docs/scripts/search.js +0 -0
  34. package/docs/styles/jsdoc.css +0 -0
  35. package/docs/styles/prettify.css +0 -0
  36. package/jest.config.js +0 -0
  37. package/package.json +1 -1
  38. package/src/contentTypeConfig.js +1 -0
  39. package/src/services/sanity.js +5 -2
  40. package/src/services/userPermissions.js +1 -1
  41. package/test/initializeTests.js +0 -1
  42. package/test/lastUpdated.test.js +3 -3
  43. package/test/live/contentProgressLive.test.js +0 -0
  44. package/test/live/railcontentLive.test.js +0 -0
  45. package/test/localStorageMock.js +0 -0
  46. package/test/log.js +0 -0
  47. package/test/sanityQueryService.test.js +26 -8
File without changes
package/.prettierignore CHANGED
File without changes
package/.prettierrc CHANGED
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.6.4](https://github.com/railroadmedia/musora-content-services/compare/v1.6.3...v1.6.4) (2025-06-13)
6
+
7
+ ### [1.6.3](https://github.com/railroadmedia/musora-content-services/compare/v1.6.2...v1.6.3) (2025-06-12)
8
+
5
9
  ### [1.6.2](https://github.com/railroadmedia/musora-content-services/compare/v1.6.1...v1.6.2) (2025-06-11)
6
10
 
7
11
  ### [1.6.1](https://github.com/railroadmedia/musora-content-services/compare/v1.6.0...v1.6.1) (2025-06-11)
package/README.md CHANGED
File without changes
package/babel.config.cjs 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "1.6.2",
3
+ "version": "1.6.4",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -32,6 +32,7 @@ export const DEFAULT_CHILD_FIELDS = [
32
32
  `"image": thumbnail.asset->url`,
33
33
  `"instructors": instructor[]->name`,
34
34
  `length_in_seconds`,
35
+ `'permission_id': permission[]->railcontent_id`,
35
36
  ]
36
37
 
37
38
  export const descriptionField = 'description[0].children[0].text'
@@ -1956,8 +1956,6 @@ export async function fetchSanity(
1956
1956
  }
1957
1957
 
1958
1958
  function needsAccessDecorator(results, userPermissions, isAdmin) {
1959
- if (globalConfig.sanityConfig.useDummyRailContentMethods) return results
1960
-
1961
1959
  userPermissions = new Set(userPermissions)
1962
1960
 
1963
1961
  if (Array.isArray(results)) {
@@ -1979,6 +1977,11 @@ function needsAccessDecorator(results, userPermissions, isAdmin) {
1979
1977
  result['need_access'] = doesUserNeedAccessToContent(result, userPermissions, isAdmin)
1980
1978
  })
1981
1979
  } else {
1980
+ if (results.lessons) {
1981
+ results.lessons.forEach((lesson) => {
1982
+ lesson['need_access'] = doesUserNeedAccessToContent(lesson, userPermissions, isAdmin) // Updated to check lesson access
1983
+ })
1984
+ }
1982
1985
  results['need_access'] = doesUserNeedAccessToContent(results, userPermissions, isAdmin)
1983
1986
  }
1984
1987
 
@@ -15,7 +15,7 @@ let userPermissionsPromise = null
15
15
  let lastUpdatedKey = `userPermissions_lastUpdated`
16
16
 
17
17
  export async function fetchUserPermissions() {
18
- if (!userPermissionsPromise || wasLastUpdateOlderThanXSeconds(10, lastUpdatedKey)) {
18
+ if (!userPermissionsPromise || (await wasLastUpdateOlderThanXSeconds(10, lastUpdatedKey))) {
19
19
  userPermissionsPromise = fetchUserPermissionsData()
20
20
  setLastUpdatedTime(lastUpdatedKey)
21
21
  }
@@ -23,7 +23,6 @@ export async function initializeTestService(useLive = false) {
23
23
  useCachedAPI: process.env.SANITY_USE_CACHED_API === 'true' || true,
24
24
  version: '2021-06-07',
25
25
  debug: process.env.DEBUG === 'true' || false,
26
- useDummyRailContentMethods: true,
27
26
  },
28
27
  railcontentConfig: {
29
28
  baseUrl: process.env.RAILCONTENT_BASE_URL,
@@ -11,11 +11,11 @@ describe('lastUpdated', function () {
11
11
 
12
12
  test('lastUpdated', async () => {
13
13
  setLastUpdatedTime('testKey')
14
- let test1 = wasLastUpdateOlderThanXSeconds(1, 'testKey')
14
+ let test1 = await wasLastUpdateOlderThanXSeconds(1, 'testKey')
15
15
  await new Promise((r) => setTimeout(r, 800))
16
- let test2 = wasLastUpdateOlderThanXSeconds(1, 'testKey')
16
+ let test2 = await wasLastUpdateOlderThanXSeconds(1, 'testKey')
17
17
  await new Promise((r) => setTimeout(r, 500))
18
- let test3 = wasLastUpdateOlderThanXSeconds(1, 'testKey')
18
+ let test3 = await wasLastUpdateOlderThanXSeconds(1, 'testKey')
19
19
 
20
20
  expect(test1).toEqual(false)
21
21
  expect(test2).toEqual(false)
File without changes
File without changes
File without changes
package/test/log.js CHANGED
File without changes
@@ -137,10 +137,10 @@ describe('Sanity Queries', function () {
137
137
  expect(returnedIds.length).toBe(2)
138
138
  })
139
139
 
140
- test('fetchUpcomingEvents', async () => {
141
- const response = await fetchUpcomingEvents('drumeo', {})
142
- expect(response.length).toBeGreaterThan(0)
143
- })
140
+ // test('fetchUpcomingEvents', async () => {
141
+ // const response = await fetchUpcomingEvents('drumeo', {})
142
+ // expect(response.length).toBeGreaterThan(0)
143
+ // })
144
144
 
145
145
  test('fetchUpcomingNewReleases', async () => {
146
146
  const response = await fetchNewReleases('drumeo')
@@ -508,10 +508,10 @@ describe('Sanity Queries', function () {
508
508
  expect(response.entity.length).toBeGreaterThan(0)
509
509
  })
510
510
 
511
- test('fetchScheduledReleases', async () => {
512
- const response = await fetchScheduledReleases('drumeo', {})
513
- expect(response.length).toBeGreaterThan(0)
514
- })
511
+ // test('fetchScheduledReleases', async () => {
512
+ // const response = await fetchScheduledReleases('drumeo', {})
513
+ // expect(response.length).toBeGreaterThan(0)
514
+ // })
515
515
 
516
516
  test('fetchAll-GroupBy-Genre', async () => {
517
517
  let response = await fetchAll('drumeo', 'solo', { groupBy: 'genre' })
@@ -619,6 +619,24 @@ describe('Sanity Queries', function () {
619
619
  expect(documentPublishedOn.getTime()).toBeLessThanOrEqual(nextDocumentPublishedOn.getTime())
620
620
  })
621
621
 
622
+ test('fetchByRailContentId_Children', async () => {
623
+ const id = 235968
624
+ const document = await fetchByRailContentId(id, 'song-tutorial')
625
+
626
+ // Verify document has lessons array
627
+ expect(document.lessons).toBeDefined()
628
+ expect(Array.isArray(document.lessons)).toBe(true)
629
+
630
+ // If there are lessons, verify each lesson has the required fields
631
+ if (document.lessons.length > 0) {
632
+ document.lessons.forEach((lesson) => {
633
+ expect(lesson.need_access).toBeDefined()
634
+ expect(lesson.permission_id).toBeDefined()
635
+ expect(Array.isArray(lesson.permission_id)).toBe(true)
636
+ })
637
+ }
638
+ })
639
+
622
640
  test('fetchTopLevelParentId', async () => {
623
641
  let contentId = await fetchTopLevelParentId(241250)
624
642
  expect(contentId).toBe(241247)