musora-content-services 1.3.21 → 2.0.5
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/.editorconfig +16 -0
- package/.github/workflows/node.js.yml +0 -0
- package/.prettierignore +0 -0
- package/.prettierrc +0 -0
- package/CHANGELOG.md +4 -4
- package/README.md +0 -0
- package/babel.config.cjs +0 -0
- package/docs/Content-Organization.html +245 -0
- package/docs/Playlists.html +192 -0
- package/docs/config.js.html +14 -5
- package/docs/content-org_playlists-types.js.html +109 -0
- package/docs/content-org_playlists.js.html +194 -0
- package/docs/content-org_types.js.html +112 -0
- package/docs/content.js.html +443 -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/global.html +3878 -0
- package/docs/index.html +2 -2
- package/docs/module-Config.html +60 -7
- package/docs/module-Content-Organization-Playlists.html +194 -0
- package/docs/module-Content-Organization.html +976 -0
- package/docs/module-Content-Services-V2.html +2433 -0
- package/docs/module-Playlists.html +969 -0
- package/docs/module-Railcontent-Services.html +3052 -1991
- package/docs/module-Sanity-Services.html +57 -43
- package/docs/module-Session-Management.html +575 -0
- package/docs/module-User-Permissions.html +406 -0
- package/docs/module-playlists.html +1878 -0
- package/docs/module-playlists_.html +108 -0
- package/docs/railcontent.js.html +149 -112
- package/docs/sanity.js.html +297 -109
- 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/docs/user_permissions.js.html +110 -0
- package/docs/user_sessions.js.html +139 -0
- package/docs/user_types.js.html +188 -0
- package/jest.config.js +0 -0
- package/jsdoc.json +3 -0
- package/package.json +1 -1
- package/publish.sh +2 -2
- package/src/contentMetaData.js +307 -1088
- package/src/contentTypeConfig.js +108 -4
- package/src/filterBuilder.js +6 -6
- package/src/index.d.ts +67 -9
- package/src/index.js +67 -9
- package/src/{services → lib}/lastUpdated.js +17 -1
- package/src/services/content-org/playlists-types.js +37 -0
- package/src/services/content-org/playlists.js +122 -0
- package/src/services/content.js +371 -0
- package/src/services/contentLikes.js +0 -0
- package/src/services/contentProgress.js +0 -0
- package/src/services/forum.js +57 -0
- package/src/services/railcontent.js +122 -122
- package/src/services/recommendations.js +19 -0
- package/src/services/sanity.js +278 -104
- package/src/services/{userPermissions.js → user/permissions.js} +16 -2
- package/src/services/user/sessions.js +67 -0
- package/src/services/user/types.js +116 -0
- package/src/services/userActivity.js +32 -0
- package/test/content.test.js +116 -0
- package/test/contentProgress.test.js +83 -5
- package/test/forum.test.js +18 -0
- package/test/initializeTests.js +6 -1
- package/test/{lastUpdated.test.js → lib/lastUpdated.test.js} +2 -5
- 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 +66 -18
- package/test/{userPermissions.test.js → user/permissions.test.js} +3 -3
- package/tools/generate-index.cjs +16 -3
package/src/contentTypeConfig.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
//import {AWSUrl, CloudFrontURl} from "./services/config";
|
|
2
|
+
import {Tabs} from "./contentMetaData.js";
|
|
3
|
+
|
|
2
4
|
export const AWSUrl = 'https://s3.us-east-1.amazonaws.com/musora-web-platform'
|
|
3
5
|
export const CloudFrontURl = 'https://d3fzm1tzeyr5n3.cloudfront.net'
|
|
4
6
|
export const DEFAULT_FIELDS = [
|
|
@@ -25,6 +27,7 @@ export const DEFAULT_FIELDS = [
|
|
|
25
27
|
"'permission_id': permission[]->railcontent_id",
|
|
26
28
|
'xp',
|
|
27
29
|
'child_count',
|
|
30
|
+
'"lesson_count": coalesce(count(child[]->.child[]->), child_count)',
|
|
28
31
|
]
|
|
29
32
|
export const DEFAULT_CHILD_FIELDS = [
|
|
30
33
|
`"id": railcontent_id`,
|
|
@@ -50,7 +53,7 @@ export const assignmentsField = `"assignments":assignment[]{
|
|
|
50
53
|
"id": railcontent_id,
|
|
51
54
|
"soundslice_slug": assignment_soundslice,
|
|
52
55
|
"title": assignment_title,
|
|
53
|
-
"sheet_music_image_url":
|
|
56
|
+
"sheet_music_image_url":
|
|
54
57
|
coalesce(assignment_sheet_music_image_new[]{
|
|
55
58
|
_type == 'Image' => {
|
|
56
59
|
'url': asset->url
|
|
@@ -126,6 +129,62 @@ export const childContentTypeConfig = {
|
|
|
126
129
|
]
|
|
127
130
|
}
|
|
128
131
|
|
|
132
|
+
export const singleLessonTypes = ['quick-tips', 'rudiment', 'coach-lessons'];
|
|
133
|
+
export const practiceAlongsLessonTypes = ['workout', 'boot-camp','challenges'];
|
|
134
|
+
export const performancesLessonTypes = ['performance','solo','drum-fest-international-2022'];
|
|
135
|
+
export const documentariesLessonTypes = ['tama','sonor','history-of-electronic-drums','paiste-cymbals'];
|
|
136
|
+
export const liveArchivesLessonTypes = ['podcast', 'coach-stream', 'live-streams'];
|
|
137
|
+
export const studentArchivesLessonTypes = ['student-review', 'question-and-answer', 'student-focus','student-collaborations'];
|
|
138
|
+
export const tutorialsLessonTypes = ['song-tutorial'];
|
|
139
|
+
export const transcriptionsLessonTypes = ['song'];
|
|
140
|
+
export const playAlongLessonTypes = ['play-along'];
|
|
141
|
+
|
|
142
|
+
export const individualLessonsTypes = [
|
|
143
|
+
...singleLessonTypes,
|
|
144
|
+
...practiceAlongsLessonTypes,
|
|
145
|
+
...performancesLessonTypes,
|
|
146
|
+
...documentariesLessonTypes,
|
|
147
|
+
...liveArchivesLessonTypes,
|
|
148
|
+
...studentArchivesLessonTypes
|
|
149
|
+
];
|
|
150
|
+
|
|
151
|
+
export const coursesLessonTypes = ['course', 'pack','spotlight'];
|
|
152
|
+
export const showsLessonTypes = ['diy-drum-experiments','exploring-beats','in-rhythm', 'rhythmic-adventures-of-captain-carson','rhythms-from-another-planet','study-the-greats'];
|
|
153
|
+
export const collectionLessonTypes = [
|
|
154
|
+
...coursesLessonTypes,
|
|
155
|
+
...showsLessonTypes
|
|
156
|
+
];
|
|
157
|
+
|
|
158
|
+
export const lessonTypesMapping = {
|
|
159
|
+
'single lessons': singleLessonTypes,
|
|
160
|
+
'practice alongs': practiceAlongsLessonTypes,
|
|
161
|
+
'live archives': liveArchivesLessonTypes,
|
|
162
|
+
'performances': performancesLessonTypes,
|
|
163
|
+
'student archives': studentArchivesLessonTypes,
|
|
164
|
+
'documentaries': documentariesLessonTypes,
|
|
165
|
+
'courses': coursesLessonTypes,
|
|
166
|
+
'shows': showsLessonTypes,
|
|
167
|
+
'collections': collectionLessonTypes,
|
|
168
|
+
'individuals': individualLessonsTypes,
|
|
169
|
+
'tutorials': tutorialsLessonTypes,
|
|
170
|
+
'transcriptions': transcriptionsLessonTypes,
|
|
171
|
+
'tabs': transcriptionsLessonTypes,
|
|
172
|
+
'sheet music': transcriptionsLessonTypes,
|
|
173
|
+
'play alongs': playAlongLessonTypes,
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
export const filterTypes = {
|
|
178
|
+
lessons: [...individualLessonsTypes, ...collectionLessonTypes],
|
|
179
|
+
songs: [...tutorialsLessonTypes, ...transcriptionsLessonTypes, ...playAlongLessonTypes]
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export const recentTypes = {
|
|
183
|
+
lessons: [...individualLessonsTypes],
|
|
184
|
+
songs: [...tutorialsLessonTypes, ...transcriptionsLessonTypes, ...playAlongLessonTypes],
|
|
185
|
+
home: [...individualLessonsTypes, ...tutorialsLessonTypes, ...transcriptionsLessonTypes, ...playAlongLessonTypes]
|
|
186
|
+
}
|
|
187
|
+
|
|
129
188
|
export let contentTypeConfig = {
|
|
130
189
|
song: {
|
|
131
190
|
fields: ['album', 'soundslice', 'instrumentless', `"resources": ${resourcesField}`],
|
|
@@ -230,7 +289,7 @@ export let contentTypeConfig = {
|
|
|
230
289
|
"instructors": instructor[]->name,
|
|
231
290
|
length_in_seconds,
|
|
232
291
|
"resources": ${resourcesField},
|
|
233
|
-
difficulty,
|
|
292
|
+
difficulty,
|
|
234
293
|
difficulty_string,
|
|
235
294
|
artist->,
|
|
236
295
|
"thumbnail_url":thumbnail.asset->url,
|
|
@@ -595,7 +654,7 @@ export function getChildFieldsForContentType(contentType, asQueryString = true)
|
|
|
595
654
|
* 'genre,rock']
|
|
596
655
|
* @returns {string} - A string that can be used in a groq query
|
|
597
656
|
*/
|
|
598
|
-
export function filtersToGroq(filters, selectedFilters = []) {
|
|
657
|
+
export function filtersToGroq(filters, selectedFilters = [], pageName = '') {
|
|
599
658
|
if (!filters) {
|
|
600
659
|
filters = []
|
|
601
660
|
}
|
|
@@ -639,6 +698,13 @@ export function filtersToGroq(filters, selectedFilters = []) {
|
|
|
639
698
|
!selectedFilters.includes(key)
|
|
640
699
|
) {
|
|
641
700
|
return `"${value}" in ${key}[]->name`
|
|
701
|
+
} else if (
|
|
702
|
+
['style'].includes(
|
|
703
|
+
key
|
|
704
|
+
) &&
|
|
705
|
+
!selectedFilters.includes(key)
|
|
706
|
+
) {
|
|
707
|
+
return `"${value}" in genre[]->name`
|
|
642
708
|
} else if (key === 'gear' && !selectedFilters.includes('gear')) {
|
|
643
709
|
return `gear match "${value}"`
|
|
644
710
|
} else if (key === 'instrumentless' && !selectedFilters.includes(key)) {
|
|
@@ -654,8 +720,44 @@ export function filtersToGroq(filters, selectedFilters = []) {
|
|
|
654
720
|
return `(difficulty_string == "Novice" || difficulty_string == "Introductory" )`
|
|
655
721
|
}
|
|
656
722
|
return `difficulty_string == "${value}"`
|
|
657
|
-
} else if (key === '
|
|
723
|
+
} else if (key === 'tab' && !selectedFilters.includes(key)) {
|
|
724
|
+
if(value.toLowerCase() === Tabs.Individuals.name.toLowerCase()){
|
|
725
|
+
const conditions = individualLessonsTypes.map(lessonType => `_type == '${lessonType}'`).join(' || ');
|
|
726
|
+
return ` (${conditions})`;
|
|
727
|
+
} else if(value.toLowerCase() === Tabs.Collections.name.toLowerCase()){
|
|
728
|
+
const conditions = collectionLessonTypes.map(lessonType => `_type == '${lessonType}'`).join(' || ');
|
|
729
|
+
return ` (${conditions})`;
|
|
730
|
+
} else if(value.toLowerCase() === Tabs.Tutorials.name.toLowerCase()){
|
|
731
|
+
const conditions = tutorialsLessonTypes.map(lessonType => `_type == '${lessonType}'`).join(' || ');
|
|
732
|
+
return ` (${conditions})`;
|
|
733
|
+
} else if(value.toLowerCase() === Tabs.Transcriptions.name.toLowerCase()){
|
|
734
|
+
const conditions = transcriptionsLessonTypes.map(lessonType => `_type == '${lessonType}'`).join(' || ');
|
|
735
|
+
return ` (${conditions})`;
|
|
736
|
+
} else if(value.toLowerCase() === Tabs.PlayAlongs.name.toLowerCase()){
|
|
737
|
+
const conditions = playAlongLessonTypes.map(lessonType => `_type == '${lessonType}'`).join(' || ');
|
|
738
|
+
return ` (${conditions})`;
|
|
739
|
+
} else if(value.toLowerCase() === Tabs.ExploreAll.name.toLowerCase()){
|
|
740
|
+
var allLessons = filterTypes[pageName] || [];
|
|
741
|
+
const conditions = allLessons.map(lessonType => `_type == '${lessonType}'`).join(' || ');
|
|
742
|
+
if (conditions === "") return '';
|
|
743
|
+
return ` (${conditions})`;
|
|
744
|
+
}else if(value.toLowerCase() === Tabs.RecentAll.name.toLowerCase()){
|
|
745
|
+
var allLessons = recentTypes[pageName] || [];
|
|
746
|
+
const conditions = allLessons.map(lessonType => `_type == '${lessonType}'`).join(' || ');
|
|
747
|
+
if (conditions === "") return '';
|
|
748
|
+
return ` (${conditions})`;
|
|
749
|
+
}
|
|
658
750
|
return `_type == "${value}"`
|
|
751
|
+
} else if (key === 'type' && !selectedFilters.includes(key)) {
|
|
752
|
+
const typeKey = value.toLowerCase();
|
|
753
|
+
const lessonTypes = lessonTypesMapping[typeKey];
|
|
754
|
+
if (lessonTypes) {
|
|
755
|
+
const conditions = lessonTypes.map(
|
|
756
|
+
(lessonType) => `_type == '${lessonType}'`
|
|
757
|
+
).join(' || ');
|
|
758
|
+
return ` (${conditions})`;
|
|
759
|
+
}
|
|
760
|
+
return `_type == "${value}"`;
|
|
659
761
|
} else if (key === 'length_in_seconds') {
|
|
660
762
|
if (value.includes('-')) {
|
|
661
763
|
const [min, max] = value.split('-').map(Number)
|
|
@@ -666,6 +768,8 @@ export function filtersToGroq(filters, selectedFilters = []) {
|
|
|
666
768
|
} else {
|
|
667
769
|
return `${key} == ${value}`
|
|
668
770
|
}
|
|
771
|
+
} else if (key === 'pageName') {
|
|
772
|
+
return ` `
|
|
669
773
|
} else if (!selectedFilters.includes(key)) {
|
|
670
774
|
return ` ${key} == ${/^\d+$/.test(value) ? value : `"$${value}"`}`
|
|
671
775
|
}
|
package/src/filterBuilder.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { fetchUserPermissions } from './services/
|
|
1
|
+
import { fetchUserPermissions } from './services/user/permissions.js'
|
|
2
2
|
import { plusMembershipPermissions } from './contentTypeConfig.js'
|
|
3
3
|
|
|
4
4
|
export class FilterBuilder {
|
|
@@ -56,13 +56,13 @@ export class FilterBuilder {
|
|
|
56
56
|
return filter
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
_getRoundedTime(){
|
|
59
|
+
_getRoundedTime() {
|
|
60
60
|
// We need to set the published on filter date to be a round time so that it doesn't bypass the query cache
|
|
61
61
|
// with every request by changing the filter date every second. I've set it to one minute past the current hour
|
|
62
62
|
// because publishing usually publishes content on the hour exactly which means it should still skip the cache
|
|
63
63
|
// when the new content is available.
|
|
64
|
-
const now = new Date()
|
|
65
|
-
return new Date(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), 1)
|
|
64
|
+
const now = new Date()
|
|
65
|
+
return new Date(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), 1)
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
_applyContentStatuses() {
|
|
@@ -98,7 +98,7 @@ export class FilterBuilder {
|
|
|
98
98
|
) {
|
|
99
99
|
// we must pull in future content here, otherwise we'll restrict on content this is published in the past and remove any scheduled content
|
|
100
100
|
this.pullFutureContent = true
|
|
101
|
-
const now = this._getRoundedTime().toISOString()
|
|
101
|
+
const now = this._getRoundedTime().toISOString()
|
|
102
102
|
let statuses = [...this.availableContentStatuses]
|
|
103
103
|
statuses.splice(statuses.indexOf(this.STATUS_SCHEDULED), 1)
|
|
104
104
|
this._andWhere(
|
|
@@ -130,7 +130,7 @@ export class FilterBuilder {
|
|
|
130
130
|
|
|
131
131
|
_applyPublishingDateRestrictions() {
|
|
132
132
|
if (this.bypassPublishedDateRestriction) return this
|
|
133
|
-
const now = this._getRoundedTime().toISOString()
|
|
133
|
+
const now = this._getRoundedTime().toISOString()
|
|
134
134
|
|
|
135
135
|
if (this.getFutureContentOnly) {
|
|
136
136
|
this._andWhere(`${this.prefix}published_on >= '${now}'`)
|
package/src/index.d.ts
CHANGED
|
@@ -5,6 +5,22 @@ import {
|
|
|
5
5
|
initializeService
|
|
6
6
|
} from './services/config.js';
|
|
7
7
|
|
|
8
|
+
import {
|
|
9
|
+
addItemToPlaylist,
|
|
10
|
+
createPlaylist,
|
|
11
|
+
fetchUserPlaylists
|
|
12
|
+
} from './services/content-org/playlists.js';
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
getContentRows,
|
|
16
|
+
getLessonContentRows,
|
|
17
|
+
getNewAndUpcoming,
|
|
18
|
+
getRecent,
|
|
19
|
+
getRecommendedForYou,
|
|
20
|
+
getScheduleContentRows,
|
|
21
|
+
getTabResults
|
|
22
|
+
} from './services/content.js';
|
|
23
|
+
|
|
8
24
|
import {
|
|
9
25
|
isContentLiked,
|
|
10
26
|
likeContent,
|
|
@@ -32,18 +48,20 @@ import {
|
|
|
32
48
|
} from './services/dataContext.js';
|
|
33
49
|
|
|
34
50
|
import {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} from './services/lastUpdated.js';
|
|
51
|
+
getActiveDiscussions
|
|
52
|
+
} from './services/forum.js';
|
|
38
53
|
|
|
39
54
|
import {
|
|
40
|
-
|
|
55
|
+
assignModeratorToComment,
|
|
56
|
+
closeComment,
|
|
41
57
|
countAssignmentsAndLessons,
|
|
42
|
-
|
|
58
|
+
createComment,
|
|
59
|
+
deleteComment,
|
|
43
60
|
deletePlaylist,
|
|
44
61
|
deletePlaylistItem,
|
|
45
62
|
deletePlaylistLike,
|
|
46
63
|
duplicatePlaylist,
|
|
64
|
+
editComment,
|
|
47
65
|
fetchAllCompletedStates,
|
|
48
66
|
fetchCarouselCardData,
|
|
49
67
|
fetchChallengeIndexMetadata,
|
|
@@ -72,8 +90,9 @@ import {
|
|
|
72
90
|
fetchUserChallengeProgress,
|
|
73
91
|
fetchUserLikes,
|
|
74
92
|
fetchUserPermissionsData,
|
|
75
|
-
|
|
93
|
+
likeComment,
|
|
76
94
|
likePlaylist,
|
|
95
|
+
openComment,
|
|
77
96
|
pinPlaylist,
|
|
78
97
|
playback,
|
|
79
98
|
postChallengesCommunityNotification,
|
|
@@ -90,8 +109,11 @@ import {
|
|
|
90
109
|
postContentReset,
|
|
91
110
|
postContentUnliked,
|
|
92
111
|
postRecordWatchSession,
|
|
112
|
+
replyToComment,
|
|
93
113
|
reportPlaylist,
|
|
94
114
|
setStudentViewForUser,
|
|
115
|
+
unassignModeratorToComment,
|
|
116
|
+
unlikeComment,
|
|
95
117
|
unpinPlaylist,
|
|
96
118
|
updatePlaylist,
|
|
97
119
|
updatePlaylistItem
|
|
@@ -100,6 +122,7 @@ import {
|
|
|
100
122
|
import {
|
|
101
123
|
rankCategories,
|
|
102
124
|
rankItems,
|
|
125
|
+
recommendations,
|
|
103
126
|
similarItems
|
|
104
127
|
} from './services/recommendations.js';
|
|
105
128
|
|
|
@@ -133,14 +156,17 @@ import {
|
|
|
133
156
|
fetchPackData,
|
|
134
157
|
fetchParentForDownload,
|
|
135
158
|
fetchPlayAlongsCount,
|
|
159
|
+
fetchRecent,
|
|
136
160
|
fetchRelatedLessons,
|
|
137
161
|
fetchRelatedSongs,
|
|
138
162
|
fetchReturning,
|
|
139
163
|
fetchSanity,
|
|
164
|
+
fetchScheduledAndNewReleases,
|
|
140
165
|
fetchScheduledReleases,
|
|
141
166
|
fetchShowsData,
|
|
142
167
|
fetchSongArtistCount,
|
|
143
168
|
fetchSongById,
|
|
169
|
+
fetchTabData,
|
|
144
170
|
fetchTopLevelParentId,
|
|
145
171
|
fetchUpcomingEvents,
|
|
146
172
|
getSortOrder,
|
|
@@ -150,21 +176,35 @@ import {
|
|
|
150
176
|
import {
|
|
151
177
|
fetchUserPermissions,
|
|
152
178
|
reset
|
|
153
|
-
} from './services/
|
|
179
|
+
} from './services/user/permissions.js';
|
|
180
|
+
|
|
181
|
+
import {
|
|
182
|
+
login,
|
|
183
|
+
logout
|
|
184
|
+
} from './services/user/sessions.js';
|
|
185
|
+
|
|
186
|
+
import {
|
|
187
|
+
getUserActivityStats
|
|
188
|
+
} from './services/userActivity.js';
|
|
154
189
|
|
|
155
190
|
declare module 'musora-content-services' {
|
|
156
191
|
export {
|
|
157
192
|
addItemToPlaylist,
|
|
193
|
+
assignModeratorToComment,
|
|
158
194
|
assignmentStatusCompleted,
|
|
159
195
|
assignmentStatusReset,
|
|
196
|
+
closeComment,
|
|
160
197
|
contentStatusCompleted,
|
|
161
198
|
contentStatusReset,
|
|
162
199
|
countAssignmentsAndLessons,
|
|
200
|
+
createComment,
|
|
163
201
|
createPlaylist,
|
|
202
|
+
deleteComment,
|
|
164
203
|
deletePlaylist,
|
|
165
204
|
deletePlaylistItem,
|
|
166
205
|
deletePlaylistLike,
|
|
167
206
|
duplicatePlaylist,
|
|
207
|
+
editComment,
|
|
168
208
|
fetchAll,
|
|
169
209
|
fetchAllCompletedStates,
|
|
170
210
|
fetchAllFilterOptions,
|
|
@@ -215,15 +255,18 @@ declare module 'musora-content-services' {
|
|
|
215
255
|
fetchPlaylist,
|
|
216
256
|
fetchPlaylistItem,
|
|
217
257
|
fetchPlaylistItems,
|
|
258
|
+
fetchRecent,
|
|
218
259
|
fetchRelatedLessons,
|
|
219
260
|
fetchRelatedSongs,
|
|
220
261
|
fetchReturning,
|
|
221
262
|
fetchSanity,
|
|
263
|
+
fetchScheduledAndNewReleases,
|
|
222
264
|
fetchScheduledReleases,
|
|
223
265
|
fetchShowsData,
|
|
224
266
|
fetchSongArtistCount,
|
|
225
267
|
fetchSongById,
|
|
226
268
|
fetchSongsInProgress,
|
|
269
|
+
fetchTabData,
|
|
227
270
|
fetchTopComment,
|
|
228
271
|
fetchTopLevelParentId,
|
|
229
272
|
fetchUpcomingEvents,
|
|
@@ -234,21 +277,34 @@ declare module 'musora-content-services' {
|
|
|
234
277
|
fetchUserPermissions,
|
|
235
278
|
fetchUserPermissionsData,
|
|
236
279
|
fetchUserPlaylists,
|
|
280
|
+
getActiveDiscussions,
|
|
237
281
|
getAllCompleted,
|
|
238
282
|
getAllStarted,
|
|
239
283
|
getAllStartedOrCompleted,
|
|
284
|
+
getContentRows,
|
|
285
|
+
getLessonContentRows,
|
|
286
|
+
getNewAndUpcoming,
|
|
240
287
|
getProgressPercentage,
|
|
241
288
|
getProgressPercentageByIds,
|
|
242
289
|
getProgressState,
|
|
243
290
|
getProgressStateByIds,
|
|
291
|
+
getRecent,
|
|
292
|
+
getRecommendedForYou,
|
|
244
293
|
getResumeTimeSeconds,
|
|
294
|
+
getScheduleContentRows,
|
|
245
295
|
getSortOrder,
|
|
296
|
+
getTabResults,
|
|
297
|
+
getUserActivityStats,
|
|
246
298
|
globalConfig,
|
|
247
299
|
initializeService,
|
|
248
300
|
isContentLiked,
|
|
249
301
|
jumpToContinueContent,
|
|
302
|
+
likeComment,
|
|
250
303
|
likeContent,
|
|
251
304
|
likePlaylist,
|
|
305
|
+
login,
|
|
306
|
+
logout,
|
|
307
|
+
openComment,
|
|
252
308
|
pinPlaylist,
|
|
253
309
|
playback,
|
|
254
310
|
postChallengesCommunityNotification,
|
|
@@ -267,17 +323,19 @@ declare module 'musora-content-services' {
|
|
|
267
323
|
postRecordWatchSession,
|
|
268
324
|
rankCategories,
|
|
269
325
|
rankItems,
|
|
326
|
+
recommendations,
|
|
270
327
|
recordWatchSession,
|
|
328
|
+
replyToComment,
|
|
271
329
|
reportPlaylist,
|
|
272
330
|
reset,
|
|
273
|
-
setLastUpdatedTime,
|
|
274
331
|
setStudentViewForUser,
|
|
275
332
|
similarItems,
|
|
333
|
+
unassignModeratorToComment,
|
|
334
|
+
unlikeComment,
|
|
276
335
|
unlikeContent,
|
|
277
336
|
unpinPlaylist,
|
|
278
337
|
updatePlaylist,
|
|
279
338
|
updatePlaylistItem,
|
|
280
339
|
verifyLocalDataContext,
|
|
281
|
-
wasLastUpdateOlderThanXSeconds,
|
|
282
340
|
}
|
|
283
341
|
}
|
package/src/index.js
CHANGED
|
@@ -5,6 +5,22 @@ import {
|
|
|
5
5
|
initializeService
|
|
6
6
|
} from './services/config.js';
|
|
7
7
|
|
|
8
|
+
import {
|
|
9
|
+
addItemToPlaylist,
|
|
10
|
+
createPlaylist,
|
|
11
|
+
fetchUserPlaylists
|
|
12
|
+
} from './services/content-org/playlists.js';
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
getContentRows,
|
|
16
|
+
getLessonContentRows,
|
|
17
|
+
getNewAndUpcoming,
|
|
18
|
+
getRecent,
|
|
19
|
+
getRecommendedForYou,
|
|
20
|
+
getScheduleContentRows,
|
|
21
|
+
getTabResults
|
|
22
|
+
} from './services/content.js';
|
|
23
|
+
|
|
8
24
|
import {
|
|
9
25
|
isContentLiked,
|
|
10
26
|
likeContent,
|
|
@@ -32,18 +48,20 @@ import {
|
|
|
32
48
|
} from './services/dataContext.js';
|
|
33
49
|
|
|
34
50
|
import {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} from './services/lastUpdated.js';
|
|
51
|
+
getActiveDiscussions
|
|
52
|
+
} from './services/forum.js';
|
|
38
53
|
|
|
39
54
|
import {
|
|
40
|
-
|
|
55
|
+
assignModeratorToComment,
|
|
56
|
+
closeComment,
|
|
41
57
|
countAssignmentsAndLessons,
|
|
42
|
-
|
|
58
|
+
createComment,
|
|
59
|
+
deleteComment,
|
|
43
60
|
deletePlaylist,
|
|
44
61
|
deletePlaylistItem,
|
|
45
62
|
deletePlaylistLike,
|
|
46
63
|
duplicatePlaylist,
|
|
64
|
+
editComment,
|
|
47
65
|
fetchAllCompletedStates,
|
|
48
66
|
fetchCarouselCardData,
|
|
49
67
|
fetchChallengeIndexMetadata,
|
|
@@ -72,8 +90,9 @@ import {
|
|
|
72
90
|
fetchUserChallengeProgress,
|
|
73
91
|
fetchUserLikes,
|
|
74
92
|
fetchUserPermissionsData,
|
|
75
|
-
|
|
93
|
+
likeComment,
|
|
76
94
|
likePlaylist,
|
|
95
|
+
openComment,
|
|
77
96
|
pinPlaylist,
|
|
78
97
|
playback,
|
|
79
98
|
postChallengesCommunityNotification,
|
|
@@ -90,8 +109,11 @@ import {
|
|
|
90
109
|
postContentReset,
|
|
91
110
|
postContentUnliked,
|
|
92
111
|
postRecordWatchSession,
|
|
112
|
+
replyToComment,
|
|
93
113
|
reportPlaylist,
|
|
94
114
|
setStudentViewForUser,
|
|
115
|
+
unassignModeratorToComment,
|
|
116
|
+
unlikeComment,
|
|
95
117
|
unpinPlaylist,
|
|
96
118
|
updatePlaylist,
|
|
97
119
|
updatePlaylistItem
|
|
@@ -100,6 +122,7 @@ import {
|
|
|
100
122
|
import {
|
|
101
123
|
rankCategories,
|
|
102
124
|
rankItems,
|
|
125
|
+
recommendations,
|
|
103
126
|
similarItems
|
|
104
127
|
} from './services/recommendations.js';
|
|
105
128
|
|
|
@@ -133,14 +156,17 @@ import {
|
|
|
133
156
|
fetchPackData,
|
|
134
157
|
fetchParentForDownload,
|
|
135
158
|
fetchPlayAlongsCount,
|
|
159
|
+
fetchRecent,
|
|
136
160
|
fetchRelatedLessons,
|
|
137
161
|
fetchRelatedSongs,
|
|
138
162
|
fetchReturning,
|
|
139
163
|
fetchSanity,
|
|
164
|
+
fetchScheduledAndNewReleases,
|
|
140
165
|
fetchScheduledReleases,
|
|
141
166
|
fetchShowsData,
|
|
142
167
|
fetchSongArtistCount,
|
|
143
168
|
fetchSongById,
|
|
169
|
+
fetchTabData,
|
|
144
170
|
fetchTopLevelParentId,
|
|
145
171
|
fetchUpcomingEvents,
|
|
146
172
|
getSortOrder,
|
|
@@ -150,20 +176,34 @@ import {
|
|
|
150
176
|
import {
|
|
151
177
|
fetchUserPermissions,
|
|
152
178
|
reset
|
|
153
|
-
} from './services/
|
|
179
|
+
} from './services/user/permissions.js';
|
|
180
|
+
|
|
181
|
+
import {
|
|
182
|
+
login,
|
|
183
|
+
logout
|
|
184
|
+
} from './services/user/sessions.js';
|
|
185
|
+
|
|
186
|
+
import {
|
|
187
|
+
getUserActivityStats
|
|
188
|
+
} from './services/userActivity.js';
|
|
154
189
|
|
|
155
190
|
export {
|
|
156
191
|
addItemToPlaylist,
|
|
192
|
+
assignModeratorToComment,
|
|
157
193
|
assignmentStatusCompleted,
|
|
158
194
|
assignmentStatusReset,
|
|
195
|
+
closeComment,
|
|
159
196
|
contentStatusCompleted,
|
|
160
197
|
contentStatusReset,
|
|
161
198
|
countAssignmentsAndLessons,
|
|
199
|
+
createComment,
|
|
162
200
|
createPlaylist,
|
|
201
|
+
deleteComment,
|
|
163
202
|
deletePlaylist,
|
|
164
203
|
deletePlaylistItem,
|
|
165
204
|
deletePlaylistLike,
|
|
166
205
|
duplicatePlaylist,
|
|
206
|
+
editComment,
|
|
167
207
|
fetchAll,
|
|
168
208
|
fetchAllCompletedStates,
|
|
169
209
|
fetchAllFilterOptions,
|
|
@@ -214,15 +254,18 @@ export {
|
|
|
214
254
|
fetchPlaylist,
|
|
215
255
|
fetchPlaylistItem,
|
|
216
256
|
fetchPlaylistItems,
|
|
257
|
+
fetchRecent,
|
|
217
258
|
fetchRelatedLessons,
|
|
218
259
|
fetchRelatedSongs,
|
|
219
260
|
fetchReturning,
|
|
220
261
|
fetchSanity,
|
|
262
|
+
fetchScheduledAndNewReleases,
|
|
221
263
|
fetchScheduledReleases,
|
|
222
264
|
fetchShowsData,
|
|
223
265
|
fetchSongArtistCount,
|
|
224
266
|
fetchSongById,
|
|
225
267
|
fetchSongsInProgress,
|
|
268
|
+
fetchTabData,
|
|
226
269
|
fetchTopComment,
|
|
227
270
|
fetchTopLevelParentId,
|
|
228
271
|
fetchUpcomingEvents,
|
|
@@ -233,21 +276,34 @@ export {
|
|
|
233
276
|
fetchUserPermissions,
|
|
234
277
|
fetchUserPermissionsData,
|
|
235
278
|
fetchUserPlaylists,
|
|
279
|
+
getActiveDiscussions,
|
|
236
280
|
getAllCompleted,
|
|
237
281
|
getAllStarted,
|
|
238
282
|
getAllStartedOrCompleted,
|
|
283
|
+
getContentRows,
|
|
284
|
+
getLessonContentRows,
|
|
285
|
+
getNewAndUpcoming,
|
|
239
286
|
getProgressPercentage,
|
|
240
287
|
getProgressPercentageByIds,
|
|
241
288
|
getProgressState,
|
|
242
289
|
getProgressStateByIds,
|
|
290
|
+
getRecent,
|
|
291
|
+
getRecommendedForYou,
|
|
243
292
|
getResumeTimeSeconds,
|
|
293
|
+
getScheduleContentRows,
|
|
244
294
|
getSortOrder,
|
|
295
|
+
getTabResults,
|
|
296
|
+
getUserActivityStats,
|
|
245
297
|
globalConfig,
|
|
246
298
|
initializeService,
|
|
247
299
|
isContentLiked,
|
|
248
300
|
jumpToContinueContent,
|
|
301
|
+
likeComment,
|
|
249
302
|
likeContent,
|
|
250
303
|
likePlaylist,
|
|
304
|
+
login,
|
|
305
|
+
logout,
|
|
306
|
+
openComment,
|
|
251
307
|
pinPlaylist,
|
|
252
308
|
playback,
|
|
253
309
|
postChallengesCommunityNotification,
|
|
@@ -266,16 +322,18 @@ export {
|
|
|
266
322
|
postRecordWatchSession,
|
|
267
323
|
rankCategories,
|
|
268
324
|
rankItems,
|
|
325
|
+
recommendations,
|
|
269
326
|
recordWatchSession,
|
|
327
|
+
replyToComment,
|
|
270
328
|
reportPlaylist,
|
|
271
329
|
reset,
|
|
272
|
-
setLastUpdatedTime,
|
|
273
330
|
setStudentViewForUser,
|
|
274
331
|
similarItems,
|
|
332
|
+
unassignModeratorToComment,
|
|
333
|
+
unlikeComment,
|
|
275
334
|
unlikeContent,
|
|
276
335
|
unpinPlaylist,
|
|
277
336
|
updatePlaylist,
|
|
278
337
|
updatePlaylistItem,
|
|
279
338
|
verifyLocalDataContext,
|
|
280
|
-
wasLastUpdateOlderThanXSeconds,
|
|
281
339
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { globalConfig } from '
|
|
1
|
+
import { globalConfig } from '../services/config'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Exported functions that are excluded from index generation.
|
|
@@ -6,6 +6,15 @@ import { globalConfig } from './config.js'
|
|
|
6
6
|
* @type {string[]}
|
|
7
7
|
*/
|
|
8
8
|
const excludeFromGeneratedIndex = ['wasLastUpdateOlderThanXSeconds', 'setLastUpdatedTime']
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Checks if the last update was older than X seconds.
|
|
12
|
+
*
|
|
13
|
+
* @param {number} seconds - The number of seconds to compare.
|
|
14
|
+
* @param {string} key - The key to check the last updated time.
|
|
15
|
+
*
|
|
16
|
+
* @returns {boolean} - True if the last update was older than X seconds, false otherwise.
|
|
17
|
+
*/
|
|
9
18
|
export function wasLastUpdateOlderThanXSeconds(seconds, key) {
|
|
10
19
|
let lastUpdated = globalConfig.localStorage.getItem(key)
|
|
11
20
|
if (!lastUpdated) return false
|
|
@@ -13,6 +22,13 @@ export function wasLastUpdateOlderThanXSeconds(seconds, key) {
|
|
|
13
22
|
return new Date().getTime() - lastUpdated > verifyServerTime
|
|
14
23
|
}
|
|
15
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Sets the last updated time.
|
|
27
|
+
*
|
|
28
|
+
* @param {string} key - The key to set the last updated time.
|
|
29
|
+
*
|
|
30
|
+
* @returns {void}
|
|
31
|
+
*/
|
|
16
32
|
export function setLastUpdatedTime(key) {
|
|
17
33
|
globalConfig.localStorage.setItem(key, new Date().getTime()?.toString())
|
|
18
34
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import '../user/types'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef CreatePlaylistDTO
|
|
5
|
+
* @property {string} name - The name of the new playlist. (required, max 255 characters)
|
|
6
|
+
* @property {string} description - A description of the playlist. (optional, max 1000 characters)
|
|
7
|
+
* @property {string} category - The category of the playlist.
|
|
8
|
+
* @property {string} thumbnail_url - The URL of the playlist thumbnail. (optional, must be a valid URL)
|
|
9
|
+
* @property {boolean} private - Whether the playlist is private. (optional, defaults to true)
|
|
10
|
+
* @property {string} brand - Brand identifier for the playlist.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @typedef Playlist
|
|
15
|
+
* @property {number} id
|
|
16
|
+
* @property {string} brand
|
|
17
|
+
* @property {string} name
|
|
18
|
+
* @property {string} description
|
|
19
|
+
* @property {string|null} thumbnail_url
|
|
20
|
+
* @property {string} duration_formated
|
|
21
|
+
* @property {Array<string>} first_4_items_thumbnail_url
|
|
22
|
+
* @property {string|null} url
|
|
23
|
+
* @property {string|null} playback_url
|
|
24
|
+
* @property {number} total_items
|
|
25
|
+
* @property {User} user
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @typedef AddItemToPlaylistDTO
|
|
30
|
+
* @property {number} content_id - The ID of the content to add to the playlist(s).
|
|
31
|
+
* @property {Array<number>} playlist_id - An array of playlist IDs where the content should be added.
|
|
32
|
+
* @property {boolean} import_full_soundslice_assignment - Flag to include full Soundslice assignments.
|
|
33
|
+
* @property {boolean} import_instrumentless_soundslice_assignment - Flag to include instrumentless Soundslice assignments.
|
|
34
|
+
* @property {boolean} import_high_routine - Flag to include high routine content.
|
|
35
|
+
* @property {boolean} import_low_routine - Flag to include low routine content.
|
|
36
|
+
* @property {boolean} import_all_assignments - Flag to include all Soundslice assignments if true.
|
|
37
|
+
*/
|