musora-content-services 2.69.0 → 2.69.1
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 +7 -0
- package/package.json +1 -1
- package/src/contentTypeConfig.js +5 -0
- package/src/services/imageSRCVerify.js +0 -0
- package/src/services/sanity.js +21 -10
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
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
|
+
### [2.69.1](https://github.com/railroadmedia/musora-content-services/compare/v2.69.0...v2.69.1) (2025-11-04)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* Add is_content and page_type to all content ([#507](https://github.com/railroadmedia/musora-content-services/issues/507)) ([174706b](https://github.com/railroadmedia/musora-content-services/commit/174706b736540b9d24ceaee11539df9203d2d135))
|
|
11
|
+
|
|
5
12
|
## [2.69.0](https://github.com/railroadmedia/musora-content-services/compare/v2.67.2...v2.69.0) (2025-11-04)
|
|
6
13
|
|
|
7
14
|
|
package/package.json
CHANGED
package/src/contentTypeConfig.js
CHANGED
|
@@ -5,7 +5,12 @@ import {FilterBuilder} from "./filterBuilder.js";
|
|
|
5
5
|
export const AWSUrl = 'https://s3.us-east-1.amazonaws.com/musora-web-platform'
|
|
6
6
|
export const CloudFrontURl = 'https://d3fzm1tzeyr5n3.cloudfront.net'
|
|
7
7
|
|
|
8
|
+
// This is used to pull related content by license, so we only show "consumable" content
|
|
8
9
|
export const SONG_TYPES = ['song', 'play-along', 'jam-track', 'song-tutorial-children']
|
|
10
|
+
// Oct 2025: It turns out content-meta categories are not really clear
|
|
11
|
+
// THis is used for the page_type field as a post processor so we include parents and children
|
|
12
|
+
// Duplicated in SanityGateway.php if you update this, update that
|
|
13
|
+
export const SONG_TYPES_WITH_CHILDREN = ['song', 'song-part', 'play-along', 'play-along-part', 'jam-track', 'song-tutorial', 'song-tutorial-children']
|
|
9
14
|
// Single hierarchy refers to only one element in the hierarchy has video lessons, not that they have a single parent
|
|
10
15
|
export const SINGLE_PARENT_TYPES = ['course-part', 'pack-bundle-lesson', 'song-tutorial-children']
|
|
11
16
|
|
|
File without changes
|
package/src/services/sanity.js
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
getFieldsForContentTypeWithFilteredChildren,
|
|
21
21
|
getChildFieldsForContentType,
|
|
22
22
|
SONG_TYPES,
|
|
23
|
+
SONG_TYPES_WITH_CHILDREN,
|
|
23
24
|
} from '../contentTypeConfig.js'
|
|
24
25
|
import {fetchSimilarItems, recommendations} from './recommendations.js'
|
|
25
26
|
import { processMetadata, typeWithSortOrder } from '../contentMetaData.js'
|
|
@@ -1821,6 +1822,7 @@ export async function fetchSanity(
|
|
|
1821
1822
|
results = processNeedAccess
|
|
1822
1823
|
? await needsAccessDecorator(results, userPermissions, isAdmin)
|
|
1823
1824
|
: results
|
|
1825
|
+
results = pageTypeDecorator(results)
|
|
1824
1826
|
return customPostProcess ? customPostProcess(results) : results
|
|
1825
1827
|
} else {
|
|
1826
1828
|
throw new Error('No results found')
|
|
@@ -1831,37 +1833,46 @@ export async function fetchSanity(
|
|
|
1831
1833
|
}
|
|
1832
1834
|
}
|
|
1833
1835
|
|
|
1834
|
-
function
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
userPermissions = new Set(userPermissions)
|
|
1838
|
-
|
|
1836
|
+
function contentResultsDecorator(results, fieldName, callback)
|
|
1837
|
+
{
|
|
1839
1838
|
if (Array.isArray(results)) {
|
|
1840
1839
|
results.forEach((result) => {
|
|
1841
|
-
result[
|
|
1840
|
+
result[fieldName] = callback(result)
|
|
1842
1841
|
})
|
|
1843
1842
|
} else if (results.entity && Array.isArray(results.entity)) {
|
|
1844
1843
|
// Group By
|
|
1845
1844
|
results.entity.forEach((result) => {
|
|
1846
1845
|
if (result.lessons) {
|
|
1847
1846
|
result.lessons.forEach((lesson) => {
|
|
1848
|
-
lesson[
|
|
1847
|
+
lesson[fieldName] = callback(lesson) // Updated to check lesson access
|
|
1849
1848
|
})
|
|
1850
1849
|
} else {
|
|
1851
|
-
result[
|
|
1850
|
+
result[fieldName] = callback(result)
|
|
1852
1851
|
}
|
|
1853
1852
|
})
|
|
1854
1853
|
} else if (results.related_lessons && Array.isArray(results.related_lessons)) {
|
|
1855
1854
|
results.related_lessons.forEach((result) => {
|
|
1856
|
-
result[
|
|
1855
|
+
result[fieldName] = callback(result)
|
|
1857
1856
|
})
|
|
1858
1857
|
} else {
|
|
1859
|
-
results[
|
|
1858
|
+
results[fieldName] = callback(results)
|
|
1860
1859
|
}
|
|
1861
1860
|
|
|
1862
1861
|
return results
|
|
1863
1862
|
}
|
|
1864
1863
|
|
|
1864
|
+
function pageTypeDecorator(results)
|
|
1865
|
+
{
|
|
1866
|
+
return contentResultsDecorator(results, 'page_type', function(content) { return SONG_TYPES_WITH_CHILDREN.includes(content['type']) ? 'song' : 'lesson'})
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
|
|
1870
|
+
function needsAccessDecorator(results, userPermissions, isAdmin) {
|
|
1871
|
+
if (globalConfig.sanityConfig.useDummyRailContentMethods) return results
|
|
1872
|
+
userPermissions = new Set(userPermissions)
|
|
1873
|
+
return contentResultsDecorator(results, 'need_access', function (content) { return doesUserNeedAccessToContent(content, userPermissions, isAdmin) })
|
|
1874
|
+
}
|
|
1875
|
+
|
|
1865
1876
|
function doesUserNeedAccessToContent(result, userPermissions, isAdmin) {
|
|
1866
1877
|
if (isAdmin ?? false) {
|
|
1867
1878
|
return false
|