musora-content-services 2.83.0 → 2.85.0
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/.claude/settings.local.json +8 -0
- package/CHANGELOG.md +14 -0
- package/docs/ContentOrganization.html +2 -2
- package/docs/Forums.html +2 -2
- package/docs/Gamification.html +2 -2
- package/docs/TestUser.html +2 -2
- package/docs/UserManagementSystem.html +2 -2
- package/docs/api_types.js.html +2 -2
- package/docs/config.js.html +2 -5
- package/docs/content-org_content-org.js.html +2 -2
- package/docs/content-org_guided-courses.ts.html +2 -2
- package/docs/content-org_learning-paths.ts.html +24 -126
- package/docs/content-org_playlists-types.js.html +2 -2
- package/docs/content-org_playlists.js.html +2 -2
- package/docs/content.js.html +10 -88
- package/docs/forums_categories.ts.html +3 -22
- package/docs/forums_forums.ts.html +2 -2
- package/docs/forums_posts.ts.html +2 -2
- package/docs/forums_threads.ts.html +2 -2
- package/docs/gamification_awards.ts.html +12 -26
- package/docs/gamification_gamification.js.html +2 -2
- package/docs/global.html +2 -2
- package/docs/index.html +2 -2
- package/docs/liveTesting.ts.html +2 -2
- package/docs/module-Accounts.html +14 -14
- package/docs/module-Awards.html +6 -106
- package/docs/module-Config.html +4 -5
- package/docs/module-Content-Services-V2.html +9 -440
- package/docs/module-Forums.html +43 -607
- package/docs/module-GuidedCourses.html +2 -2
- package/docs/module-Interests.html +2 -2
- package/docs/module-LearningPaths.html +12 -640
- package/docs/module-Onboarding.html +2 -2
- package/docs/module-Payments.html +2 -2
- package/docs/module-Permissions.html +2 -2
- package/docs/module-Playlists.html +2 -2
- package/docs/module-ProgressRow.html +2 -2
- package/docs/module-Railcontent-Services.html +298 -31
- package/docs/module-Sanity-Services.html +1901 -530
- package/docs/module-Sessions.html +2 -2
- package/docs/module-UserActivity.html +5 -5
- 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/progress-row_method-card.js.html +3 -3
- package/docs/railcontent.js.html +20 -8
- package/docs/sanity.js.html +313 -199
- package/docs/userActivity.js.html +5 -17
- package/docs/user_account.ts.html +13 -14
- 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.ts.html +2 -2
- package/docs/user_notifications.js.html +2 -2
- package/docs/user_onboarding.ts.html +2 -2
- package/docs/user_payments.ts.html +2 -2
- package/docs/user_permissions.js.html +3 -3
- 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 +2 -2
- package/src/index.js +2 -2
- package/src/services/contentAggregator.js +34 -31
- package/src/services/contentProgress.js +250 -147
- package/src/services/railcontent.js +18 -6
- package/src/services/sanity.js +18 -2
- package/src/services/userActivity.js +3 -14
package/src/index.d.ts
CHANGED
|
@@ -96,7 +96,6 @@ import {
|
|
|
96
96
|
getAllStartedOrCompleted,
|
|
97
97
|
getLastInteractedOf,
|
|
98
98
|
getNavigateTo,
|
|
99
|
-
getNextLesson,
|
|
100
99
|
getProgressDateByIds,
|
|
101
100
|
getProgressPercentage,
|
|
102
101
|
getProgressPercentageByIds,
|
|
@@ -269,6 +268,7 @@ import {
|
|
|
269
268
|
fetchMethodPreviousNextLesson,
|
|
270
269
|
fetchMethodV2IntroVideo,
|
|
271
270
|
fetchMethodV2Structure,
|
|
271
|
+
fetchMethodV2StructureFromId,
|
|
272
272
|
fetchNewReleases,
|
|
273
273
|
fetchNextPreviousLesson,
|
|
274
274
|
fetchOtherSongVersions,
|
|
@@ -517,6 +517,7 @@ declare module 'musora-content-services' {
|
|
|
517
517
|
fetchMethodPreviousNextLesson,
|
|
518
518
|
fetchMethodV2IntroVideo,
|
|
519
519
|
fetchMethodV2Structure,
|
|
520
|
+
fetchMethodV2StructureFromId,
|
|
520
521
|
fetchNewReleases,
|
|
521
522
|
fetchNextContentDataForParent,
|
|
522
523
|
fetchNextPreviousLesson,
|
|
@@ -584,7 +585,6 @@ declare module 'musora-content-services' {
|
|
|
584
585
|
getNavigateTo,
|
|
585
586
|
getNavigateToForPlaylists,
|
|
586
587
|
getNewAndUpcoming,
|
|
587
|
-
getNextLesson,
|
|
588
588
|
getOnboardingRecommendedContent,
|
|
589
589
|
getOwnedContent,
|
|
590
590
|
getPracticeNotes,
|
package/src/index.js
CHANGED
|
@@ -96,7 +96,6 @@ import {
|
|
|
96
96
|
getAllStartedOrCompleted,
|
|
97
97
|
getLastInteractedOf,
|
|
98
98
|
getNavigateTo,
|
|
99
|
-
getNextLesson,
|
|
100
99
|
getProgressDateByIds,
|
|
101
100
|
getProgressPercentage,
|
|
102
101
|
getProgressPercentageByIds,
|
|
@@ -269,6 +268,7 @@ import {
|
|
|
269
268
|
fetchMethodPreviousNextLesson,
|
|
270
269
|
fetchMethodV2IntroVideo,
|
|
271
270
|
fetchMethodV2Structure,
|
|
271
|
+
fetchMethodV2StructureFromId,
|
|
272
272
|
fetchNewReleases,
|
|
273
273
|
fetchNextPreviousLesson,
|
|
274
274
|
fetchOtherSongVersions,
|
|
@@ -516,6 +516,7 @@ export {
|
|
|
516
516
|
fetchMethodPreviousNextLesson,
|
|
517
517
|
fetchMethodV2IntroVideo,
|
|
518
518
|
fetchMethodV2Structure,
|
|
519
|
+
fetchMethodV2StructureFromId,
|
|
519
520
|
fetchNewReleases,
|
|
520
521
|
fetchNextContentDataForParent,
|
|
521
522
|
fetchNextPreviousLesson,
|
|
@@ -583,7 +584,6 @@ export {
|
|
|
583
584
|
getNavigateTo,
|
|
584
585
|
getNavigateToForPlaylists,
|
|
585
586
|
getNewAndUpcoming,
|
|
586
|
-
getNextLesson,
|
|
587
587
|
getOnboardingRecommendedContent,
|
|
588
588
|
getOwnedContent,
|
|
589
589
|
getPracticeNotes,
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
getLastInteractedOf,
|
|
3
2
|
getNavigateTo,
|
|
4
|
-
getNextLesson,
|
|
5
3
|
getProgressDateByIds,
|
|
6
|
-
getProgressPercentageByIds,
|
|
7
4
|
getProgressStateByIds,
|
|
8
5
|
getResumeTimeSecondsByIds,
|
|
9
6
|
} from './contentProgress'
|
|
@@ -32,8 +29,8 @@ import { fetchLastInteractedChild, fetchLikeCount } from './railcontent'
|
|
|
32
29
|
* @param options.addProgressStatus - add progressStatus field
|
|
33
30
|
* @param options.addProgressTimestamp - add progressTimestamp field
|
|
34
31
|
* @param options.addResumeTimeSeconds - add resumeTimeSeconds field
|
|
35
|
-
* @param options.addLastInteractedChild - add lastInteractedChild field. This may be different from
|
|
36
|
-
* @param options.
|
|
32
|
+
* @param options.addLastInteractedChild - add lastInteractedChild field. This may be different from navigateTo.id
|
|
33
|
+
* @param options.collection {object|null} - define collection parameter: collection = { id: <collection_id>, type: <collection_type> } . This is needed for different collection types like learning paths.
|
|
37
34
|
*
|
|
38
35
|
* @returns {Promise<{ data: Object[] } | false>} - A promise that resolves to the fetched content data + added data or `false` if no data is found.
|
|
39
36
|
*
|
|
@@ -52,7 +49,7 @@ import { fetchLastInteractedChild, fetchLikeCount } from './railcontent'
|
|
|
52
49
|
* dataField_parentIsArray: true,
|
|
53
50
|
* addProgressStatus: true,
|
|
54
51
|
* addProgressPercentage: true,
|
|
55
|
-
*
|
|
52
|
+
* addNavigateTo: true
|
|
56
53
|
* })
|
|
57
54
|
*
|
|
58
55
|
*/
|
|
@@ -64,6 +61,7 @@ export async function addContextToContent(dataPromise, ...dataArgs) {
|
|
|
64
61
|
const options = typeof lastArg === 'object' && !Array.isArray(lastArg) ? lastArg : {}
|
|
65
62
|
|
|
66
63
|
const {
|
|
64
|
+
collection = null, // this is needed for different collection types like learning paths. has .id and .type
|
|
67
65
|
dataField = null,
|
|
68
66
|
dataField_includeParent = false,
|
|
69
67
|
addProgressPercentage = false,
|
|
@@ -73,7 +71,6 @@ export async function addContextToContent(dataPromise, ...dataArgs) {
|
|
|
73
71
|
addProgressTimestamp = false,
|
|
74
72
|
addResumeTimeSeconds = false,
|
|
75
73
|
addLastInteractedChild = false,
|
|
76
|
-
addNextLesson = false,
|
|
77
74
|
addNavigateTo = false,
|
|
78
75
|
} = options
|
|
79
76
|
|
|
@@ -93,17 +90,14 @@ export async function addContextToContent(dataPromise, ...dataArgs) {
|
|
|
93
90
|
isLikedData,
|
|
94
91
|
resumeTimeData,
|
|
95
92
|
lastInteractedChildData,
|
|
96
|
-
nextLessonData,
|
|
97
93
|
navigateToData,
|
|
98
|
-
] = await Promise.all([
|
|
94
|
+
] = await Promise.all([ //for now assume these all return `collection = {type, id}`. it will be so when watermelon here
|
|
99
95
|
addProgressPercentage || addProgressStatus || addProgressTimestamp
|
|
100
|
-
? getProgressDateByIds(ids)
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
addNextLesson ? getNextLesson(items) : Promise.resolve(null),
|
|
106
|
-
addNavigateTo ? getNavigateTo(items) : Promise.resolve(null),
|
|
96
|
+
? getProgressDateByIds(ids, collection) : Promise.resolve(null),
|
|
97
|
+
addIsLiked ? isContentLikedByIds(ids, collection) : Promise.resolve(null),
|
|
98
|
+
addResumeTimeSeconds ? getResumeTimeSecondsByIds(ids, collection) : Promise.resolve(null),
|
|
99
|
+
addLastInteractedChild ? fetchLastInteractedChild(ids, collection) : Promise.resolve(null),
|
|
100
|
+
addNavigateTo ? getNavigateTo(items, collection) : Promise.resolve(null),
|
|
107
101
|
])
|
|
108
102
|
|
|
109
103
|
const addContext = async (item) => ({
|
|
@@ -115,13 +109,6 @@ export async function addContextToContent(dataPromise, ...dataArgs) {
|
|
|
115
109
|
...(addLikeCount && ids.length === 1 ? { likeCount: await fetchLikeCount(item.id) } : {}),
|
|
116
110
|
...(addResumeTimeSeconds ? { resumeTime: resumeTimeData?.[item.id] } : {}),
|
|
117
111
|
...(addLastInteractedChild ? { lastInteractedChild: lastInteractedChildData?.[item.id] } : {}),
|
|
118
|
-
...(addNextLesson
|
|
119
|
-
? {
|
|
120
|
-
nextLesson: nextLessonData?.[item.id], //deprecated
|
|
121
|
-
next_lesson_id: nextLessonData?.[item.id],
|
|
122
|
-
next_lesson: item?.children?.find((child) => child.id === nextLessonData?.[item.id]),
|
|
123
|
-
}
|
|
124
|
-
: {}),
|
|
125
112
|
...(addNavigateTo ? { navigateTo: navigateToData?.[item.id] } : {}),
|
|
126
113
|
})
|
|
127
114
|
|
|
@@ -168,10 +155,20 @@ function extractItemsFromData(data, dataField, isParentArray, includeParent) {
|
|
|
168
155
|
if (dataField) {
|
|
169
156
|
if (isParentArray) {
|
|
170
157
|
for (const parent of data) {
|
|
171
|
-
|
|
158
|
+
const fieldValue = parent[dataField]
|
|
159
|
+
if (Array.isArray(fieldValue)) {
|
|
160
|
+
items = [...items, ...fieldValue]
|
|
161
|
+
} else if (fieldValue && typeof fieldValue === 'object') {
|
|
162
|
+
items = [...items, fieldValue]
|
|
163
|
+
}
|
|
172
164
|
}
|
|
173
165
|
} else {
|
|
174
|
-
|
|
166
|
+
const fieldValue = data[dataField]
|
|
167
|
+
if (Array.isArray(fieldValue)) {
|
|
168
|
+
items = fieldValue
|
|
169
|
+
} else if (fieldValue && typeof fieldValue === 'object') {
|
|
170
|
+
items = [fieldValue]
|
|
171
|
+
}
|
|
175
172
|
}
|
|
176
173
|
if (includeParent) {
|
|
177
174
|
if (isParentArray) {
|
|
@@ -194,14 +191,20 @@ async function processItems(data, addContext, dataField, isParentArray, includeP
|
|
|
194
191
|
if (dataField) {
|
|
195
192
|
if (isParentArray) {
|
|
196
193
|
for (let parent of data) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
194
|
+
const fieldValue = parent[dataField]
|
|
195
|
+
if (Array.isArray(fieldValue)) {
|
|
196
|
+
parent[dataField] = await Promise.all(fieldValue.map(addContext))
|
|
197
|
+
} else if (fieldValue && typeof fieldValue === 'object') {
|
|
198
|
+
parent[dataField] = await addContext(fieldValue)
|
|
199
|
+
}
|
|
200
200
|
}
|
|
201
201
|
} else {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
202
|
+
const fieldValue = data[dataField]
|
|
203
|
+
if (Array.isArray(fieldValue)) {
|
|
204
|
+
data[dataField] = await Promise.all(fieldValue.map(addContext))
|
|
205
|
+
} else if (fieldValue && typeof fieldValue === 'object') {
|
|
206
|
+
data[dataField] = await addContext(fieldValue)
|
|
207
|
+
}
|
|
205
208
|
}
|
|
206
209
|
if (includeParent) {
|
|
207
210
|
data = isParentArray ? await Promise.all(data.map(addContext)) : await addContext(data)
|