musora-content-services 1.0.236 → 1.0.238
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/.github/workflows/node.js.yml +0 -0
- package/CHANGELOG.md +4 -0
- package/README.md +0 -0
- package/babel.config.js +0 -0
- package/docs/config.js.html +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
- package/docs/index.html +0 -0
- package/docs/module-Config.html +0 -0
- package/docs/module-Railcontent-Services.html +0 -0
- package/docs/module-Sanity-Services.html +0 -0
- package/docs/railcontent.js.html +0 -0
- package/docs/sanity.js.html +0 -0
- package/docs/scripts/collapse.js +0 -0
- package/docs/scripts/commonNav.js +0 -0
- package/docs/scripts/linenumber.js +0 -0
- package/docs/scripts/nav.js +0 -0
- package/docs/scripts/polyfill.js +0 -0
- package/docs/scripts/prettify/Apache-License-2.0.txt +0 -0
- package/docs/scripts/prettify/lang-css.js +0 -0
- package/docs/scripts/prettify/prettify.js +0 -0
- package/docs/scripts/search.js +0 -0
- package/docs/styles/jsdoc.css +0 -0
- package/docs/styles/prettify.css +0 -0
- package/jest.config.js +0 -0
- package/jsdoc.json +0 -0
- package/link_mcs.sh +0 -0
- package/package.json +1 -1
- package/src/contentMetaData.js +0 -0
- package/src/filterBuilder.js +0 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +2 -0
- package/src/services/config.js +0 -0
- package/src/services/contentLikes.js +0 -0
- package/src/services/contentProgress.js +0 -0
- package/src/services/dataContext.js +0 -0
- package/src/services/lastUpdated.js +0 -0
- package/src/services/railcontent.js +6 -3
- package/src/services/sanity.js +35 -14
- package/src/services/userPermissions.js +0 -0
- package/test/contentLikes.test.js +0 -0
- package/test/contentProgress.test.js +0 -0
- package/test/initializeTests.js +0 -0
- package/test/lastUpdated.test.js +0 -0
- package/test/live/contentProgressLive.test.js +0 -0
- package/test/live/railcontentLive.test.js +0 -0
- package/test/localStorageMock.js +0 -0
- package/test/log.js +0 -0
- package/test/sanityQueryService.test.js +5 -0
- package/test/userPermissions.test.js +0 -0
- package/tools/generate-index.js +0 -0
|
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.0.238](https://github.com/railroadmedia/musora-content-services/compare/v1.0.237...v1.0.238) (2024-12-16)
|
|
6
|
+
|
|
7
|
+
### [1.0.237](https://github.com/railroadmedia/musora-content-services/compare/v1.0.236...v1.0.237) (2024-12-14)
|
|
8
|
+
|
|
5
9
|
### [1.0.236](https://github.com/railroadmedia/musora-content-services/compare/v1.0.235...v1.0.236) (2024-12-13)
|
|
6
10
|
|
|
7
11
|
### [1.0.235](https://github.com/railroadmedia/musora-content-services/compare/v1.0.234...v1.0.235) (2024-12-13)
|
package/README.md
CHANGED
|
File without changes
|
package/babel.config.js
CHANGED
|
File without changes
|
package/docs/config.js.html
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
|
package/docs/index.html
CHANGED
|
File without changes
|
package/docs/module-Config.html
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/docs/railcontent.js.html
CHANGED
|
File without changes
|
package/docs/sanity.js.html
CHANGED
|
File without changes
|
package/docs/scripts/collapse.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/docs/scripts/nav.js
CHANGED
|
File without changes
|
package/docs/scripts/polyfill.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/docs/scripts/search.js
CHANGED
|
File without changes
|
package/docs/styles/jsdoc.css
CHANGED
|
File without changes
|
package/docs/styles/prettify.css
CHANGED
|
File without changes
|
package/jest.config.js
CHANGED
|
File without changes
|
package/jsdoc.json
CHANGED
|
File without changes
|
package/link_mcs.sh
CHANGED
|
File without changes
|
package/package.json
CHANGED
package/src/contentMetaData.js
CHANGED
|
File without changes
|
package/src/filterBuilder.js
CHANGED
|
File without changes
|
package/src/index.d.ts
CHANGED
|
@@ -95,6 +95,7 @@ import {
|
|
|
95
95
|
fetchByReference,
|
|
96
96
|
fetchCatalogMetadata,
|
|
97
97
|
fetchChallengeOverview,
|
|
98
|
+
fetchChatAndLiveEnvent,
|
|
98
99
|
fetchChildren,
|
|
99
100
|
fetchCoachLessons,
|
|
100
101
|
fetchCommentModContentData,
|
|
@@ -172,6 +173,7 @@ declare module 'musora-content-services' {
|
|
|
172
173
|
fetchChallengeMetadata,
|
|
173
174
|
fetchChallengeOverview,
|
|
174
175
|
fetchChallengeUserActiveChallenges,
|
|
176
|
+
fetchChatAndLiveEnvent,
|
|
175
177
|
fetchChildren,
|
|
176
178
|
fetchCoachLessons,
|
|
177
179
|
fetchCommentModContentData,
|
package/src/index.js
CHANGED
|
@@ -95,6 +95,7 @@ import {
|
|
|
95
95
|
fetchByReference,
|
|
96
96
|
fetchCatalogMetadata,
|
|
97
97
|
fetchChallengeOverview,
|
|
98
|
+
fetchChatAndLiveEnvent,
|
|
98
99
|
fetchChildren,
|
|
99
100
|
fetchCoachLessons,
|
|
100
101
|
fetchCommentModContentData,
|
|
@@ -171,6 +172,7 @@ export {
|
|
|
171
172
|
fetchChallengeMetadata,
|
|
172
173
|
fetchChallengeOverview,
|
|
173
174
|
fetchChallengeUserActiveChallenges,
|
|
175
|
+
fetchChatAndLiveEnvent,
|
|
174
176
|
fetchChildren,
|
|
175
177
|
fetchCoachLessons,
|
|
176
178
|
fetchCommentModContentData,
|
package/src/services/config.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -617,14 +617,17 @@ export async function postChallengesHideCompletedBanner(contentId) {
|
|
|
617
617
|
* .then(playlists => console.log(playlists))
|
|
618
618
|
* .catch(error => console.error(error));
|
|
619
619
|
*/
|
|
620
|
-
export async function fetchUserPlaylists(brand, {page, limit, sort, searchTerm, content_id} = {}) {
|
|
620
|
+
export async function fetchUserPlaylists(brand, {page, limit, sort, searchTerm, content_id, categories} = {}) {
|
|
621
621
|
let url;
|
|
622
622
|
const limitString = limit ? `&limit=${limit}` : '';
|
|
623
623
|
const pageString = page ? `&page=${page}` : '';
|
|
624
624
|
const sortString = sort ? `&sort=${sort}` : '';
|
|
625
625
|
const searchFilter = searchTerm ? `&term=${searchTerm}` : '';
|
|
626
626
|
const content = content_id ? `&content_id=${content_id}` : '';
|
|
627
|
-
|
|
627
|
+
const categoryString = categories && categories.length
|
|
628
|
+
? categories.map(cat => `categories[]=${cat}`).join('&')
|
|
629
|
+
: '';
|
|
630
|
+
url = `/playlists/all?brand=${brand}${limitString}${pageString}${sortString}${searchFilter}${content}${categoryString ? `&${categoryString}` : ''}`;
|
|
628
631
|
return await fetchHandler(url);
|
|
629
632
|
}
|
|
630
633
|
|
|
@@ -1166,4 +1169,4 @@ function fetchAbsolute(url, params) {
|
|
|
1166
1169
|
}
|
|
1167
1170
|
}
|
|
1168
1171
|
return fetch(url, params);
|
|
1169
|
-
}
|
|
1172
|
+
}
|
package/src/services/sanity.js
CHANGED
|
@@ -28,7 +28,8 @@ import {
|
|
|
28
28
|
fetchCompletedChallenges,
|
|
29
29
|
fetchCurrentSongComplete,
|
|
30
30
|
fetchOwnedChallenges,
|
|
31
|
-
fetchNextContentDataForParent
|
|
31
|
+
fetchNextContentDataForParent,
|
|
32
|
+
fetchHandler,
|
|
32
33
|
} from './railcontent.js';
|
|
33
34
|
import {arrayToStringRepresentation, FilterBuilder} from "../filterBuilder";
|
|
34
35
|
import {fetchUserPermissions} from "./userPermissions";
|
|
@@ -522,12 +523,12 @@ export async function fetchAll(brand, type, {
|
|
|
522
523
|
// Construct the type filter
|
|
523
524
|
let typeFilter;
|
|
524
525
|
|
|
525
|
-
if(
|
|
526
|
+
if (type === 'archives') {
|
|
526
527
|
typeFilter = `&& status == "archived"`;
|
|
527
528
|
bypassStatusAndPublishedValidation = true;
|
|
528
529
|
} else {
|
|
529
530
|
typeFilter = type ? `&& _type == '${type}'` : "";
|
|
530
|
-
}
|
|
531
|
+
}
|
|
531
532
|
|
|
532
533
|
// Construct the search filter
|
|
533
534
|
const searchFilter = searchTerm
|
|
@@ -836,13 +837,13 @@ export async function fetchAllFilterOptions(
|
|
|
836
837
|
const constructCommonFilter = (excludeFilter) => {
|
|
837
838
|
const filterWithoutOption = excludeFilter ? filtersToGroq(filters, excludeFilter) : includedFieldsFilter;
|
|
838
839
|
const statusFilter = ' && status == "published"';
|
|
839
|
-
const includeStatusFilter = !isAdmin && !['instructor','artist','genre'].includes(contentType);
|
|
840
|
+
const includeStatusFilter = !isAdmin && !['instructor', 'artist', 'genre'].includes(contentType);
|
|
840
841
|
|
|
841
842
|
return coachId
|
|
842
843
|
? `brand == '${brand}' && status == "published" && references(*[_type=='instructor' && railcontent_id == ${coachId}]._id) ${filterWithoutOption || ''} ${term ? ` && (title match "${term}" || album match "${term}" || artist->name match "${term}" || genre[]->name match "${term}")` : ''}`
|
|
843
844
|
: `_type == '${contentType}' && brand == "${brand}"${includeStatusFilter ? statusFilter : ''}${style && excludeFilter !== "style" ? ` && '${style}' in genre[]->name` : ''}${artist && excludeFilter !== "artist" ? ` && artist->name == '${artist}'` : ''} ${progressFilter} ${filterWithoutOption || ''} ${term ? ` && (title match "${term}" || album match "${term}" || artist->name match "${term}" || genre[]->name match "${term}")` : ''}`;
|
|
844
845
|
};
|
|
845
|
-
|
|
846
|
+
|
|
846
847
|
const metaData = processMetadata(brand, contentType, true);
|
|
847
848
|
const allowableFilters = metaData?.allowableFilters || [];
|
|
848
849
|
const tabs = metaData?.tabs || [];
|
|
@@ -1303,17 +1304,20 @@ export async function fetchLiveEvent(brand) {
|
|
|
1303
1304
|
default:
|
|
1304
1305
|
break;
|
|
1305
1306
|
}
|
|
1306
|
-
let
|
|
1307
|
-
|
|
1307
|
+
let startDateTemp = new Date();
|
|
1308
|
+
let endDateTemp = new Date();
|
|
1309
|
+
startDateTemp= new Date (startDateTemp.setMinutes(startDateTemp.getMinutes() + 15));
|
|
1310
|
+
endDateTemp = new Date(endDateTemp.setMinutes(endDateTemp.getMinutes() - 15));
|
|
1308
1311
|
|
|
1309
1312
|
// See LiveStreamEventService.getCurrentOrNextLiveEvent for some nice complicated logic which I don't think is actually importart
|
|
1310
1313
|
// this has some +- on times
|
|
1311
1314
|
// But this query just finds the first scheduled event (sorted by start_time) that ends after now()
|
|
1312
|
-
const query = `*[status == 'scheduled' && defined(live_event_start_time) &&
|
|
1315
|
+
const query = `*[status == 'scheduled' && defined(live_event_start_time) && live_event_start_time <= '${getSanityDate(startDateTemp, false)}' && live_event_end_time >= '${getSanityDate(endDateTemp, false)}']{
|
|
1313
1316
|
'slug': slug.current,
|
|
1314
1317
|
'id': railcontent_id,
|
|
1315
1318
|
live_event_start_time,
|
|
1316
1319
|
live_event_end_time,
|
|
1320
|
+
live_event_youtube_id,
|
|
1317
1321
|
railcontent_id,
|
|
1318
1322
|
published_on,
|
|
1319
1323
|
'event_coach_url' : instructor[0]->web_url_path,
|
|
@@ -1326,7 +1330,7 @@ export async function fetchLiveEvent(brand) {
|
|
|
1326
1330
|
},
|
|
1327
1331
|
'videoId': coalesce(live_event_youtube_id, video.external_id),
|
|
1328
1332
|
} | order(live_event_start_time)[0...1]`;
|
|
1329
|
-
return await fetchSanity(query, false);
|
|
1333
|
+
return await fetchSanity(query, false, {processNeedAccess: false});
|
|
1330
1334
|
}
|
|
1331
1335
|
|
|
1332
1336
|
/**
|
|
@@ -1604,15 +1608,17 @@ export async function fetchGenreLessons(brand, name, contentType, {
|
|
|
1604
1608
|
}
|
|
1605
1609
|
|
|
1606
1610
|
export async function fetchTopLevelParentId(railcontentId) {
|
|
1611
|
+
const statusFilter = "&& status in ['scheduled', 'published', 'archived', 'unlisted']";
|
|
1612
|
+
|
|
1607
1613
|
const query = `*[railcontent_id == ${railcontentId}]{
|
|
1608
1614
|
railcontent_id,
|
|
1609
|
-
'parents': *[^._id in child[]._ref
|
|
1615
|
+
'parents': *[^._id in child[]._ref ${statusFilter}]{
|
|
1610
1616
|
railcontent_id,
|
|
1611
|
-
'parents': *[^._id in child[]._ref
|
|
1617
|
+
'parents': *[^._id in child[]._ref ${statusFilter}]{
|
|
1612
1618
|
railcontent_id,
|
|
1613
|
-
'parents': *[^._id in child[]._ref
|
|
1619
|
+
'parents': *[^._id in child[]._ref ${statusFilter}]{
|
|
1614
1620
|
railcontent_id,
|
|
1615
|
-
'parents': *[^._id in child[]._ref
|
|
1621
|
+
'parents': *[^._id in child[]._ref ${statusFilter}]{
|
|
1616
1622
|
railcontent_id,
|
|
1617
1623
|
}
|
|
1618
1624
|
}
|
|
@@ -1656,6 +1662,7 @@ export async function fetchHierarchy(railcontentId) {
|
|
|
1656
1662
|
let response = await fetchSanity(query, false, {processNeedAccess: false});
|
|
1657
1663
|
if (!response) return null;
|
|
1658
1664
|
let data = {
|
|
1665
|
+
topLevelId: topLevelId,
|
|
1659
1666
|
parents: {},
|
|
1660
1667
|
children: {}
|
|
1661
1668
|
};
|
|
@@ -1926,6 +1933,17 @@ export async function fetchMetadata(brand, type) {
|
|
|
1926
1933
|
return processedData ? processedData : {};
|
|
1927
1934
|
}
|
|
1928
1935
|
|
|
1936
|
+
export async function fetchChatAndLiveEnvent(brand, forcedId = null) {
|
|
1937
|
+
const liveEvent = (forcedId !== null) ? await fetchByRailContentIds([forcedId]): [await fetchLiveEvent(brand)];
|
|
1938
|
+
if (liveEvent.length === 0 || (liveEvent.length === 1 && liveEvent[0] === undefined)) {
|
|
1939
|
+
return null;
|
|
1940
|
+
}
|
|
1941
|
+
let url = `/content/live-chat?brand=${brand}`;
|
|
1942
|
+
const chatData = await fetchHandler(url);
|
|
1943
|
+
const mergedData = { ...chatData, ...liveEvent[0] };
|
|
1944
|
+
return mergedData;
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1929
1947
|
|
|
1930
1948
|
//Helper Functions
|
|
1931
1949
|
function arrayJoinWithQuotes(array, delimiter = ',') {
|
|
@@ -2041,6 +2059,7 @@ function getFilterOptions(option, commonFilter, contentType, brand) {
|
|
|
2041
2059
|
case "difficulty":
|
|
2042
2060
|
filterGroq = `
|
|
2043
2061
|
"difficulty": [
|
|
2062
|
+
{"type": "All", "count": count(*[${commonFilter} && difficulty_string == "All"])},
|
|
2044
2063
|
{"type": "Introductory", "count": count(*[${commonFilter} && difficulty_string == "Introductory"])},
|
|
2045
2064
|
{"type": "Beginner", "count": count(*[${commonFilter} && difficulty_string == "Beginner"])},
|
|
2046
2065
|
{"type": "Intermediate", "count": count(*[${commonFilter} && difficulty_string == "Intermediate" ])},
|
|
@@ -2049,7 +2068,9 @@ function getFilterOptions(option, commonFilter, contentType, brand) {
|
|
|
2049
2068
|
][count > 0],`;
|
|
2050
2069
|
break;
|
|
2051
2070
|
case "type":
|
|
2052
|
-
const typesString = types.map(t => {
|
|
2071
|
+
const typesString = types.map(t => {
|
|
2072
|
+
return `{"type": "${t}"}`
|
|
2073
|
+
}).join(', ');
|
|
2053
2074
|
filterGroq = `"type": [${typesString}]{type, 'count': count(*[_type == ^.type && ${commonFilter}])}[count > 0],`;
|
|
2054
2075
|
break;
|
|
2055
2076
|
case "genre":
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/test/initializeTests.js
CHANGED
|
File without changes
|
package/test/lastUpdated.test.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/test/localStorageMock.js
CHANGED
|
File without changes
|
package/test/log.js
CHANGED
|
File without changes
|
|
@@ -668,6 +668,11 @@ describe('Sanity Queries', function () {
|
|
|
668
668
|
expect(hierarchy.children[243085]).toStrictEqual([243170, 243171, 243172, 243174, 243176]);
|
|
669
669
|
});
|
|
670
670
|
|
|
671
|
+
test('fetchTopLeveldrafts', async () => {
|
|
672
|
+
let id = await fetchTopLevelParentId(413955);
|
|
673
|
+
expect(id).toBe(413955);
|
|
674
|
+
});
|
|
675
|
+
|
|
671
676
|
test('fetchCommentData', async()=>{
|
|
672
677
|
let data = await fetchCommentModContentData([241251,241252, 211153]);
|
|
673
678
|
expect(data[241251].title).toBe("Setting Up Your Space");
|
|
File without changes
|
package/tools/generate-index.js
CHANGED
|
File without changes
|