musora-content-services 2.35.0 → 2.36.3
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 +18 -0
- package/docs/ContentOrganization.html +2 -2
- package/docs/Gamification.html +2 -2
- package/docs/UserManagementSystem.html +2 -2
- package/docs/api_types.js.html +2 -2
- package/docs/config.js.html +2 -2
- package/docs/content-org_content-org.js.html +2 -2
- package/docs/content-org_guided-courses.ts.html +2 -2
- package/docs/content-org_playlists-types.js.html +2 -2
- package/docs/content-org_playlists.js.html +2 -2
- package/docs/content.js.html +2 -2
- package/docs/gamification_awards.ts.html +2 -2
- package/docs/gamification_gamification.js.html +2 -2
- package/docs/global.html +2 -2
- package/docs/index.html +2 -2
- package/docs/module-Accounts.html +2 -2
- package/docs/module-Awards.html +2 -2
- package/docs/module-Config.html +2 -2
- package/docs/module-Content-Services-V2.html +2 -2
- package/docs/module-GuidedCourses.html +2 -2
- package/docs/module-Interests.html +2 -2
- package/docs/module-Payments.html +220 -0
- package/docs/module-Permissions.html +2 -2
- package/docs/module-Playlists.html +2 -2
- package/docs/module-Railcontent-Services.html +2 -2
- package/docs/module-Sanity-Services.html +4 -4
- package/docs/module-Sessions.html +2 -2
- package/docs/module-UserActivity.html +2 -2
- package/docs/module-UserChat.html +2 -2
- package/docs/module-UserManagement.html +2 -2
- package/docs/module-UserMemberships.html +2 -2
- package/docs/module-UserNotifications.html +2 -2
- package/docs/module-UserProfile.html +2 -2
- package/docs/railcontent.js.html +2 -2
- package/docs/sanity.js.html +4 -7
- package/docs/userActivity.js.html +3 -3
- package/docs/user_account.ts.html +2 -2
- package/docs/user_chat.js.html +2 -2
- package/docs/user_interests.js.html +2 -2
- package/docs/user_management.js.html +2 -2
- package/docs/user_memberships.js.html +2 -2
- package/docs/user_notifications.js.html +2 -2
- package/docs/user_payments.ts.html +88 -0
- package/docs/user_permissions.js.html +2 -2
- package/docs/user_profile.js.html +2 -2
- package/docs/user_sessions.js.html +2 -2
- package/docs/user_types.js.html +2 -2
- package/docs/user_user-management-system.js.html +2 -2
- package/package.json +1 -1
- package/src/index.d.ts +9 -2
- package/src/index.js +9 -2
- package/src/services/content-org/guided-courses.ts +0 -5
- package/src/services/contentAggregator.js +0 -1
- package/src/services/contentProgress.js +30 -0
- package/src/services/imageSRCVerify.js +0 -0
- package/src/services/railcontent.js +10 -0
- package/src/services/sanity.js +0 -3
- package/src/services/user/payments.ts +25 -0
- package/src/services/userActivity.js +19 -36
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
import { DataContext, UserActivityVersionKey } from './dataContext.js'
|
|
14
14
|
import { fetchByRailContentId, fetchByRailContentIds, fetchShows } from './sanity'
|
|
15
15
|
import { fetchPlaylist, fetchUserPlaylists } from './content-org/playlists'
|
|
16
|
-
import {guidedCourses
|
|
16
|
+
import {guidedCourses} from './content-org/guided-courses'
|
|
17
17
|
import {
|
|
18
18
|
getMonday,
|
|
19
19
|
getWeekNumber,
|
|
@@ -950,7 +950,6 @@ async function extractPinnedItemsAndSortAllItems(
|
|
|
950
950
|
userPinnedItem,
|
|
951
951
|
contentsMap,
|
|
952
952
|
eligiblePlaylistItems,
|
|
953
|
-
pinnedGuidedCourse,
|
|
954
953
|
limit
|
|
955
954
|
) {
|
|
956
955
|
let pinnedItem = await popPinnedItemFromContentsOrPlaylistMap(
|
|
@@ -959,22 +958,8 @@ async function extractPinnedItemsAndSortAllItems(
|
|
|
959
958
|
eligiblePlaylistItems
|
|
960
959
|
)
|
|
961
960
|
|
|
962
|
-
const guidedCourseID = pinnedGuidedCourse?.content_id
|
|
963
961
|
let combined = []
|
|
964
|
-
|
|
965
|
-
const guidedCourseContent =
|
|
966
|
-
contentsMap.get(guidedCourseID) ??
|
|
967
|
-
(await addContextToContent(fetchByRailContentId, guidedCourseID, 'guided-course', {
|
|
968
|
-
addNextLesson: true,
|
|
969
|
-
addNavigateTo: true,
|
|
970
|
-
addProgressStatus: true,
|
|
971
|
-
addProgressPercentage: true,
|
|
972
|
-
addProgressTimestamp: true,
|
|
973
|
-
}))
|
|
974
|
-
contentsMap = popContentAndRemoveChildrenFromContentsMap(guidedCourseContent, contentsMap)
|
|
975
|
-
guidedCourseContent.pinned = true
|
|
976
|
-
combined.push(guidedCourseContent)
|
|
977
|
-
}
|
|
962
|
+
|
|
978
963
|
if (pinnedItem) {
|
|
979
964
|
pinnedItem.pinned = true
|
|
980
965
|
combined.push(pinnedItem)
|
|
@@ -1052,20 +1037,15 @@ function generateContentsMap(contents, playlistsContents) {
|
|
|
1052
1037
|
export async function getProgressRows({ brand = null, limit = 8 } = {}) {
|
|
1053
1038
|
// TODO slice progress to a reasonable number, say 100
|
|
1054
1039
|
|
|
1055
|
-
const [recentPlaylists, progressContents,
|
|
1040
|
+
const [recentPlaylists, progressContents, userPinnedItem, enrolledGuidedCourses] =
|
|
1056
1041
|
await Promise.all([
|
|
1057
1042
|
fetchUserPlaylists(brand, { sort: '-last_progress', limit: limit }),
|
|
1058
1043
|
getAllStartedOrCompleted({ onlyIds: false, brand: brand }),
|
|
1059
|
-
pinnedGuidedCourses(brand),
|
|
1060
1044
|
getUserPinnedItem(brand),
|
|
1061
1045
|
guidedCourses()
|
|
1062
1046
|
])
|
|
1063
1047
|
|
|
1064
1048
|
const enrolledGuidedCoursesIds = enrolledGuidedCourses.map(course => String(course.content_id));
|
|
1065
|
-
|
|
1066
|
-
const mergedGuidedCourses = 1 //get all cuigded courses, incl no progress.
|
|
1067
|
-
let pinnedGuidedCourse = allPinnedGuidedCourse?.[0] ?? null
|
|
1068
|
-
|
|
1069
1049
|
const playlists = recentPlaylists?.data || []
|
|
1070
1050
|
const eligiblePlaylistItems = await getEligiblePlaylistItems(playlists)
|
|
1071
1051
|
const playlistEngagedOnContents = eligiblePlaylistItems.map(
|
|
@@ -1079,8 +1059,6 @@ export async function getProgressRows({ brand = null, limit = 8 } = {}) {
|
|
|
1079
1059
|
if (userPinnedItem?.progressType === 'content') {
|
|
1080
1060
|
nonPlaylistContentIds.push(userPinnedItem.id)
|
|
1081
1061
|
}
|
|
1082
|
-
console.log("nonPlaylistContentIds",nonPlaylistContentIds)
|
|
1083
|
-
|
|
1084
1062
|
|
|
1085
1063
|
const [playlistsContents, contents] = await Promise.all([
|
|
1086
1064
|
playlistEngagedOnContents ? addContextToContent(fetchByRailContentIds, playlistEngagedOnContents, 'progress-tracker', {
|
|
@@ -1103,7 +1081,6 @@ console.log("nonPlaylistContentIds",nonPlaylistContentIds)
|
|
|
1103
1081
|
userPinnedItem,
|
|
1104
1082
|
contentsMap,
|
|
1105
1083
|
eligiblePlaylistItems,
|
|
1106
|
-
pinnedGuidedCourse,
|
|
1107
1084
|
limit
|
|
1108
1085
|
)
|
|
1109
1086
|
const results = await Promise.all(
|
|
@@ -1361,8 +1338,10 @@ export function findIncompleteLesson(progressOnItems, currentContentId, contentT
|
|
|
1361
1338
|
|
|
1362
1339
|
async function popPinnedItemFromContentsOrPlaylistMap(pinned, contentsMap, playlistItems) {
|
|
1363
1340
|
if (!pinned) return null
|
|
1364
|
-
const { id,
|
|
1341
|
+
const { id, pinnedAt } = pinned
|
|
1365
1342
|
let item = null
|
|
1343
|
+
const progressType = pinned.progressType ?? pinned.type;
|
|
1344
|
+
|
|
1366
1345
|
if (progressType === 'content') {
|
|
1367
1346
|
const pinnedId = parseInt(id)
|
|
1368
1347
|
if (contentsMap.has(pinnedId)) {
|
|
@@ -1399,15 +1378,19 @@ async function popPinnedItemFromContentsOrPlaylistMap(pinned, contentsMap, playl
|
|
|
1399
1378
|
}
|
|
1400
1379
|
|
|
1401
1380
|
function popContentAndRemoveChildrenFromContentsMap(content, contentsMap) {
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
contentsMap.delete(child)
|
|
1381
|
+
if (!content.children || content.children.length === 0){
|
|
1382
|
+
console.warn(`content ${content.id} has no children`, content);
|
|
1383
|
+
} else {
|
|
1384
|
+
const children = content.children.map((child) => child.id)
|
|
1385
|
+
if (contentsMap.has(content.id)) {
|
|
1386
|
+
contentsMap.delete(content.id)
|
|
1409
1387
|
}
|
|
1410
|
-
|
|
1388
|
+
children.forEach((child) => {
|
|
1389
|
+
if (contentsMap.has(child)) {
|
|
1390
|
+
contentsMap.delete(child)
|
|
1391
|
+
}
|
|
1392
|
+
})
|
|
1393
|
+
}
|
|
1411
1394
|
return contentsMap
|
|
1412
1395
|
}
|
|
1413
1396
|
|
|
@@ -1427,7 +1410,7 @@ function popContentAndRemoveChildrenFromContentsMap(content, contentsMap) {
|
|
|
1427
1410
|
export async function pinProgressRow(brand, id, progressType) {
|
|
1428
1411
|
const url = `/api/user-management-system/v1/progress/pin?brand=${brand}&id=${id}&progressType=${progressType}`
|
|
1429
1412
|
const response = await fetchHandler(url, 'PUT', null)
|
|
1430
|
-
if (response && !response.error
|
|
1413
|
+
if (response && !response.error) {
|
|
1431
1414
|
await updateUserPinnedProgressRow(brand, {
|
|
1432
1415
|
id,
|
|
1433
1416
|
progressType,
|