musora-content-services 1.2.5 → 1.3.2

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.
Files changed (40) hide show
  1. package/.prettierignore +5 -0
  2. package/.prettierrc +8 -0
  3. package/.yarnrc.yml +1 -0
  4. package/CHANGELOG.md +11 -0
  5. package/README.md +0 -0
  6. package/babel.config.cjs +1 -1
  7. package/docs/config.js.html +0 -0
  8. package/docs/index.html +0 -0
  9. package/docs/module-Config.html +0 -0
  10. package/docs/module-Railcontent-Services.html +0 -0
  11. package/docs/module-Sanity-Services.html +0 -0
  12. package/docs/railcontent.js.html +0 -0
  13. package/docs/sanity.js.html +0 -0
  14. package/jest.config.js +9 -10
  15. package/jsdoc.json +17 -12
  16. package/package.json +2 -1
  17. package/src/contentMetaData.js +1190 -1131
  18. package/src/contentTypeConfig.js +492 -387
  19. package/src/filterBuilder.js +163 -145
  20. package/src/index.d.ts +227 -237
  21. package/src/index.js +226 -236
  22. package/src/services/config.js +12 -12
  23. package/src/services/contentLikes.js +33 -32
  24. package/src/services/contentProgress.js +233 -200
  25. package/src/services/dataContext.js +99 -93
  26. package/src/services/lastUpdated.js +7 -7
  27. package/src/services/railcontent.js +368 -364
  28. package/src/services/sanity.js +983 -955
  29. package/src/services/userPermissions.js +12 -14
  30. package/test/contentLikes.test.js +89 -86
  31. package/test/contentProgress.test.js +229 -236
  32. package/test/initializeTests.js +54 -51
  33. package/test/lastUpdated.test.js +20 -18
  34. package/test/live/contentProgressLive.test.js +135 -137
  35. package/test/live/railcontentLive.test.js +12 -14
  36. package/test/localStorageMock.js +16 -16
  37. package/test/log.js +5 -5
  38. package/test/sanityQueryService.test.js +857 -821
  39. package/test/userPermissions.test.js +15 -15
  40. package/tools/generate-index.cjs +108 -111
package/src/index.js CHANGED
@@ -1,248 +1,238 @@
1
1
  /*** This file was generated automatically. To recreate, please run `npm run build-index`. ***/
2
2
 
3
- import {
4
- globalConfig,
5
- initializeService
6
- } from './services/config.js';
3
+ import { globalConfig, initializeService } from './services/config.js'
7
4
 
8
- import {
9
- isContentLiked,
10
- likeContent,
11
- unlikeContent
12
- } from './services/contentLikes.js';
5
+ import { isContentLiked, likeContent, unlikeContent } from './services/contentLikes.js'
13
6
 
14
7
  import {
15
- assignmentStatusCompleted,
16
- assignmentStatusReset,
17
- contentStatusCompleted,
18
- contentStatusReset,
19
- getAllCompleted,
20
- getAllStarted,
21
- getAllStartedOrCompleted,
22
- getProgressPercentage,
23
- getProgressPercentageByIds,
24
- getProgressState,
25
- getProgressStateByIds,
26
- getResumeTimeSeconds,
27
- recordWatchSession
28
- } from './services/contentProgress.js';
8
+ assignmentStatusCompleted,
9
+ assignmentStatusReset,
10
+ contentStatusCompleted,
11
+ contentStatusReset,
12
+ getAllCompleted,
13
+ getAllStarted,
14
+ getAllStartedOrCompleted,
15
+ getProgressPercentage,
16
+ getProgressPercentageByIds,
17
+ getProgressState,
18
+ getProgressStateByIds,
19
+ getResumeTimeSeconds,
20
+ recordWatchSession,
21
+ } from './services/contentProgress.js'
29
22
 
30
23
  import {
31
- addItemToPlaylist,
32
- countAssignmentsAndLessons,
33
- createPlaylist,
34
- deletePlaylist,
35
- deletePlaylistItem,
36
- deletePlaylistLike,
37
- duplicatePlaylist,
38
- fetchAllCompletedStates,
39
- fetchCarouselCardData,
40
- fetchChallengeIndexMetadata,
41
- fetchChallengeLessonData,
42
- fetchChallengeMetadata,
43
- fetchChallengeUserActiveChallenges,
44
- fetchCompletedChallenges,
45
- fetchCompletedContent,
46
- fetchCompletedState,
47
- fetchContentInProgress,
48
- fetchContentPageUserData,
49
- fetchContentProgress,
50
- fetchHandler,
51
- fetchNextContentDataForParent,
52
- fetchOwnedChallenges,
53
- fetchPinnedPlaylists,
54
- fetchPlaylist,
55
- fetchPlaylistItem,
56
- fetchPlaylistItems,
57
- fetchSongsInProgress,
58
- fetchUserAward,
59
- fetchUserBadges,
60
- fetchUserChallengeProgress,
61
- fetchUserLikes,
62
- fetchUserPermissionsData,
63
- fetchUserPlaylists,
64
- likePlaylist,
65
- pinPlaylist,
66
- playback,
67
- postChallengesCommunityNotification,
68
- postChallengesCompleteLesson,
69
- postChallengesEnroll,
70
- postChallengesEnrollmentNotification,
71
- postChallengesHideCompletedBanner,
72
- postChallengesLeave,
73
- postChallengesSetStartDate,
74
- postChallengesSoloNotification,
75
- postChallengesUnlock,
76
- postContentCompleted,
77
- postContentLiked,
78
- postContentReset,
79
- postContentUnliked,
80
- postRecordWatchSession,
81
- reportPlaylist,
82
- setStudentViewForUser,
83
- unpinPlaylist,
84
- updatePlaylist,
85
- updatePlaylistItem
86
- } from './services/railcontent.js';
24
+ addItemToPlaylist,
25
+ countAssignmentsAndLessons,
26
+ createPlaylist,
27
+ deletePlaylist,
28
+ deletePlaylistItem,
29
+ deletePlaylistLike,
30
+ duplicatePlaylist,
31
+ fetchAllCompletedStates,
32
+ fetchCarouselCardData,
33
+ fetchChallengeIndexMetadata,
34
+ fetchChallengeLessonData,
35
+ fetchChallengeMetadata,
36
+ fetchChallengeUserActiveChallenges,
37
+ fetchCompletedChallenges,
38
+ fetchCompletedContent,
39
+ fetchCompletedState,
40
+ fetchContentInProgress,
41
+ fetchContentPageUserData,
42
+ fetchContentProgress,
43
+ fetchHandler,
44
+ fetchNextContentDataForParent,
45
+ fetchOwnedChallenges,
46
+ fetchPinnedPlaylists,
47
+ fetchPlaylist,
48
+ fetchPlaylistItem,
49
+ fetchPlaylistItems,
50
+ fetchSongsInProgress,
51
+ fetchUserAward,
52
+ fetchUserBadges,
53
+ fetchUserChallengeProgress,
54
+ fetchUserLikes,
55
+ fetchUserPermissionsData,
56
+ fetchUserPlaylists,
57
+ likePlaylist,
58
+ pinPlaylist,
59
+ playback,
60
+ postChallengesCommunityNotification,
61
+ postChallengesCompleteLesson,
62
+ postChallengesEnroll,
63
+ postChallengesEnrollmentNotification,
64
+ postChallengesHideCompletedBanner,
65
+ postChallengesLeave,
66
+ postChallengesSetStartDate,
67
+ postChallengesSoloNotification,
68
+ postChallengesUnlock,
69
+ postContentCompleted,
70
+ postContentLiked,
71
+ postContentReset,
72
+ postContentUnliked,
73
+ postRecordWatchSession,
74
+ reportPlaylist,
75
+ setStudentViewForUser,
76
+ unpinPlaylist,
77
+ updatePlaylist,
78
+ updatePlaylistItem,
79
+ } from './services/railcontent.js'
87
80
 
88
81
  import {
89
- fetchAll,
90
- fetchAllFilterOptions,
91
- fetchAllPacks,
92
- fetchArtistLessons,
93
- fetchArtists,
94
- fetchByRailContentId,
95
- fetchByRailContentIds,
96
- fetchByReference,
97
- fetchChatAndLiveEnvent,
98
- fetchCoachLessons,
99
- fetchCommentModContentData,
100
- fetchFoundation,
101
- fetchGenreLessons,
102
- fetchHierarchy,
103
- fetchLessonContent,
104
- fetchLiveEvent,
105
- fetchMetadata,
106
- fetchMethod,
107
- fetchMethodChildren,
108
- fetchMethodChildrenIds,
109
- fetchMethodPreviousNextLesson,
110
- fetchNewReleases,
111
- fetchNextPreviousLesson,
112
- fetchPackAll,
113
- fetchPackData,
114
- fetchParentForDownload,
115
- fetchPlayAlongsCount,
116
- fetchRelatedLessons,
117
- fetchRelatedSongs,
118
- fetchSanity,
119
- fetchScheduledReleases,
120
- fetchShowsData,
121
- fetchSongArtistCount,
122
- fetchSongById,
123
- fetchTopLevelParentId,
124
- fetchUpcomingEvents,
125
- getSortOrder,
126
- jumpToContinueContent
127
- } from './services/sanity.js';
82
+ fetchAll,
83
+ fetchAllFilterOptions,
84
+ fetchAllPacks,
85
+ fetchArtistLessons,
86
+ fetchArtists,
87
+ fetchByRailContentId,
88
+ fetchByRailContentIds,
89
+ fetchByReference,
90
+ fetchChatAndLiveEnvent,
91
+ fetchCoachLessons,
92
+ fetchCommentModContentData,
93
+ fetchFoundation,
94
+ fetchGenreLessons,
95
+ fetchHierarchy,
96
+ fetchLessonContent,
97
+ fetchLiveEvent,
98
+ fetchMetadata,
99
+ fetchMethod,
100
+ fetchMethodChildren,
101
+ fetchMethodChildrenIds,
102
+ fetchMethodPreviousNextLesson,
103
+ fetchNewReleases,
104
+ fetchNextPreviousLesson,
105
+ fetchPackAll,
106
+ fetchPackData,
107
+ fetchParentForDownload,
108
+ fetchPlayAlongsCount,
109
+ fetchRelatedLessons,
110
+ fetchRelatedSongs,
111
+ fetchSanity,
112
+ fetchScheduledReleases,
113
+ fetchShowsData,
114
+ fetchSongArtistCount,
115
+ fetchSongById,
116
+ fetchTopLevelParentId,
117
+ fetchUpcomingEvents,
118
+ getSortOrder,
119
+ jumpToContinueContent,
120
+ } from './services/sanity.js'
128
121
 
129
- import {
130
- fetchUserPermissions,
131
- reset
132
- } from './services/userPermissions.js';
122
+ import { fetchUserPermissions, reset } from './services/userPermissions.js'
133
123
 
134
124
  export {
135
- addItemToPlaylist,
136
- assignmentStatusCompleted,
137
- assignmentStatusReset,
138
- contentStatusCompleted,
139
- contentStatusReset,
140
- countAssignmentsAndLessons,
141
- createPlaylist,
142
- deletePlaylist,
143
- deletePlaylistItem,
144
- deletePlaylistLike,
145
- duplicatePlaylist,
146
- fetchAll,
147
- fetchAllCompletedStates,
148
- fetchAllFilterOptions,
149
- fetchAllPacks,
150
- fetchArtistLessons,
151
- fetchArtists,
152
- fetchByRailContentId,
153
- fetchByRailContentIds,
154
- fetchByReference,
155
- fetchCarouselCardData,
156
- fetchChallengeIndexMetadata,
157
- fetchChallengeLessonData,
158
- fetchChallengeMetadata,
159
- fetchChallengeUserActiveChallenges,
160
- fetchChatAndLiveEnvent,
161
- fetchCoachLessons,
162
- fetchCommentModContentData,
163
- fetchCompletedChallenges,
164
- fetchCompletedContent,
165
- fetchCompletedState,
166
- fetchContentInProgress,
167
- fetchContentPageUserData,
168
- fetchContentProgress,
169
- fetchFoundation,
170
- fetchGenreLessons,
171
- fetchHandler,
172
- fetchHierarchy,
173
- fetchLessonContent,
174
- fetchLiveEvent,
175
- fetchMetadata,
176
- fetchMethod,
177
- fetchMethodChildren,
178
- fetchMethodChildrenIds,
179
- fetchMethodPreviousNextLesson,
180
- fetchNewReleases,
181
- fetchNextContentDataForParent,
182
- fetchNextPreviousLesson,
183
- fetchOwnedChallenges,
184
- fetchPackAll,
185
- fetchPackData,
186
- fetchParentForDownload,
187
- fetchPinnedPlaylists,
188
- fetchPlayAlongsCount,
189
- fetchPlaylist,
190
- fetchPlaylistItem,
191
- fetchPlaylistItems,
192
- fetchRelatedLessons,
193
- fetchRelatedSongs,
194
- fetchSanity,
195
- fetchScheduledReleases,
196
- fetchShowsData,
197
- fetchSongArtistCount,
198
- fetchSongById,
199
- fetchSongsInProgress,
200
- fetchTopLevelParentId,
201
- fetchUpcomingEvents,
202
- fetchUserAward,
203
- fetchUserBadges,
204
- fetchUserChallengeProgress,
205
- fetchUserLikes,
206
- fetchUserPermissions,
207
- fetchUserPermissionsData,
208
- fetchUserPlaylists,
209
- getAllCompleted,
210
- getAllStarted,
211
- getAllStartedOrCompleted,
212
- getProgressPercentage,
213
- getProgressPercentageByIds,
214
- getProgressState,
215
- getProgressStateByIds,
216
- getResumeTimeSeconds,
217
- getSortOrder,
218
- globalConfig,
219
- initializeService,
220
- isContentLiked,
221
- jumpToContinueContent,
222
- likeContent,
223
- likePlaylist,
224
- pinPlaylist,
225
- playback,
226
- postChallengesCommunityNotification,
227
- postChallengesCompleteLesson,
228
- postChallengesEnroll,
229
- postChallengesEnrollmentNotification,
230
- postChallengesHideCompletedBanner,
231
- postChallengesLeave,
232
- postChallengesSetStartDate,
233
- postChallengesSoloNotification,
234
- postChallengesUnlock,
235
- postContentCompleted,
236
- postContentLiked,
237
- postContentReset,
238
- postContentUnliked,
239
- postRecordWatchSession,
240
- recordWatchSession,
241
- reportPlaylist,
242
- reset,
243
- setStudentViewForUser,
244
- unlikeContent,
245
- unpinPlaylist,
246
- updatePlaylist,
247
- updatePlaylistItem,
248
- };
125
+ addItemToPlaylist,
126
+ assignmentStatusCompleted,
127
+ assignmentStatusReset,
128
+ contentStatusCompleted,
129
+ contentStatusReset,
130
+ countAssignmentsAndLessons,
131
+ createPlaylist,
132
+ deletePlaylist,
133
+ deletePlaylistItem,
134
+ deletePlaylistLike,
135
+ duplicatePlaylist,
136
+ fetchAll,
137
+ fetchAllCompletedStates,
138
+ fetchAllFilterOptions,
139
+ fetchAllPacks,
140
+ fetchArtistLessons,
141
+ fetchArtists,
142
+ fetchByRailContentId,
143
+ fetchByRailContentIds,
144
+ fetchByReference,
145
+ fetchCarouselCardData,
146
+ fetchChallengeIndexMetadata,
147
+ fetchChallengeLessonData,
148
+ fetchChallengeMetadata,
149
+ fetchChallengeUserActiveChallenges,
150
+ fetchChatAndLiveEnvent,
151
+ fetchCoachLessons,
152
+ fetchCommentModContentData,
153
+ fetchCompletedChallenges,
154
+ fetchCompletedContent,
155
+ fetchCompletedState,
156
+ fetchContentInProgress,
157
+ fetchContentPageUserData,
158
+ fetchContentProgress,
159
+ fetchFoundation,
160
+ fetchGenreLessons,
161
+ fetchHandler,
162
+ fetchHierarchy,
163
+ fetchLessonContent,
164
+ fetchLiveEvent,
165
+ fetchMetadata,
166
+ fetchMethod,
167
+ fetchMethodChildren,
168
+ fetchMethodChildrenIds,
169
+ fetchMethodPreviousNextLesson,
170
+ fetchNewReleases,
171
+ fetchNextContentDataForParent,
172
+ fetchNextPreviousLesson,
173
+ fetchOwnedChallenges,
174
+ fetchPackAll,
175
+ fetchPackData,
176
+ fetchParentForDownload,
177
+ fetchPinnedPlaylists,
178
+ fetchPlayAlongsCount,
179
+ fetchPlaylist,
180
+ fetchPlaylistItem,
181
+ fetchPlaylistItems,
182
+ fetchRelatedLessons,
183
+ fetchRelatedSongs,
184
+ fetchSanity,
185
+ fetchScheduledReleases,
186
+ fetchShowsData,
187
+ fetchSongArtistCount,
188
+ fetchSongById,
189
+ fetchSongsInProgress,
190
+ fetchTopLevelParentId,
191
+ fetchUpcomingEvents,
192
+ fetchUserAward,
193
+ fetchUserBadges,
194
+ fetchUserChallengeProgress,
195
+ fetchUserLikes,
196
+ fetchUserPermissions,
197
+ fetchUserPermissionsData,
198
+ fetchUserPlaylists,
199
+ getAllCompleted,
200
+ getAllStarted,
201
+ getAllStartedOrCompleted,
202
+ getProgressPercentage,
203
+ getProgressPercentageByIds,
204
+ getProgressState,
205
+ getProgressStateByIds,
206
+ getResumeTimeSeconds,
207
+ getSortOrder,
208
+ globalConfig,
209
+ initializeService,
210
+ isContentLiked,
211
+ jumpToContinueContent,
212
+ likeContent,
213
+ likePlaylist,
214
+ pinPlaylist,
215
+ playback,
216
+ postChallengesCommunityNotification,
217
+ postChallengesCompleteLesson,
218
+ postChallengesEnroll,
219
+ postChallengesEnrollmentNotification,
220
+ postChallengesHideCompletedBanner,
221
+ postChallengesLeave,
222
+ postChallengesSetStartDate,
223
+ postChallengesSoloNotification,
224
+ postChallengesUnlock,
225
+ postContentCompleted,
226
+ postContentLiked,
227
+ postContentReset,
228
+ postContentUnliked,
229
+ postRecordWatchSession,
230
+ recordWatchSession,
231
+ reportPlaylist,
232
+ reset,
233
+ setStudentViewForUser,
234
+ unlikeContent,
235
+ unpinPlaylist,
236
+ updatePlaylist,
237
+ updatePlaylistItem,
238
+ }
@@ -3,19 +3,19 @@
3
3
  */
4
4
 
5
5
  export let globalConfig = {
6
- sanityConfig: {},
7
- railcontentConfig: {},
8
- localStorage: null,
9
- isMA: false,
10
- localTimezoneString: null, // In format: America/Vancouver
11
- };
6
+ sanityConfig: {},
7
+ railcontentConfig: {},
8
+ localStorage: null,
9
+ isMA: false,
10
+ localTimezoneString: null, // In format: America/Vancouver
11
+ }
12
12
 
13
13
  /**
14
14
  * Exported functions that are excluded from index generation.
15
15
  *
16
16
  * @type {string[]}
17
17
  */
18
- const excludeFromGeneratedIndex = [];
18
+ const excludeFromGeneratedIndex = []
19
19
 
20
20
  /**
21
21
  * Initializes the service with the given configuration.
@@ -61,9 +61,9 @@ const excludeFromGeneratedIndex = [];
61
61
  * });
62
62
  */
63
63
  export function initializeService(config) {
64
- globalConfig.sanityConfig = config.sanityConfig;
65
- globalConfig.railcontentConfig = config.railcontentConfig;
66
- globalConfig.localStorage = config.localStorage;
67
- globalConfig.isMA = config.isMA || false;
68
- globalConfig.localTimezoneString = config.localTimezoneString || null;
64
+ globalConfig.sanityConfig = config.sanityConfig
65
+ globalConfig.railcontentConfig = config.railcontentConfig
66
+ globalConfig.localStorage = config.localStorage
67
+ globalConfig.isMA = config.isMA || false
68
+ globalConfig.localTimezoneString = config.localTimezoneString || null
69
69
  }
@@ -1,48 +1,49 @@
1
- import {fetchUserLikes, postContentLiked, postContentUnliked} from "./railcontent.js";
2
- import {DataContext, ContentLikesVersionKey} from "./dataContext.js";
1
+ import { fetchUserLikes, postContentLiked, postContentUnliked } from './railcontent.js'
2
+ import { DataContext, ContentLikesVersionKey } from './dataContext.js'
3
3
 
4
4
  /**
5
5
  * Exported functions that are excluded from index generation.
6
6
  *
7
7
  * @type {string[]}
8
8
  */
9
- const excludeFromGeneratedIndex = [];
9
+ const excludeFromGeneratedIndex = []
10
10
 
11
- export let dataContext = new DataContext(ContentLikesVersionKey, fetchUserLikes);
11
+ export let dataContext = new DataContext(ContentLikesVersionKey, fetchUserLikes)
12
12
 
13
13
  export async function isContentLiked(contentId) {
14
- contentId = parseInt(contentId);
15
- let data = await dataContext.getData();
16
- return data.includes(contentId);
14
+ contentId = parseInt(contentId)
15
+ let data = await dataContext.getData()
16
+ return data.includes(contentId)
17
17
  }
18
18
 
19
19
  export async function likeContent(contentId) {
20
- contentId = parseInt(contentId);
21
- await dataContext.update(
22
- function (localContext) {
23
- if (!localContext.data.includes(contentId)) {
24
- localContext.data.push(contentId);
25
- }
26
- },
27
- async function () {
28
- return postContentLiked(contentId);
29
- }
30
- );
20
+ contentId = parseInt(contentId)
21
+ await dataContext.update(
22
+ function (localContext) {
23
+ if (!localContext.data.includes(contentId)) {
24
+ localContext.data.push(contentId)
25
+ }
26
+ },
27
+ async function () {
28
+ return postContentLiked(contentId)
29
+ }
30
+ )
31
31
  }
32
32
 
33
33
  export async function unlikeContent(contentId) {
34
- contentId = parseInt(contentId);
35
- await dataContext.update(
36
- function (localContext) {
37
- if (localContext.data.includes(contentId)) {
38
- const index = localContext.data.indexOf(contentId);
39
- if (index > -1) { // only splice array when item is found
40
- localContext.data.splice(index, 1); // 2nd parameter means remove one item only
41
- }
42
- }
43
- },
44
- async function () {
45
- return postContentUnliked(contentId);
34
+ contentId = parseInt(contentId)
35
+ await dataContext.update(
36
+ function (localContext) {
37
+ if (localContext.data.includes(contentId)) {
38
+ const index = localContext.data.indexOf(contentId)
39
+ if (index > -1) {
40
+ // only splice array when item is found
41
+ localContext.data.splice(index, 1) // 2nd parameter means remove one item only
46
42
  }
47
- );
48
- }
43
+ }
44
+ },
45
+ async function () {
46
+ return postContentUnliked(contentId)
47
+ }
48
+ )
49
+ }