musora-content-services 2.1.1 → 2.2.1
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 +9 -0
- package/docs/Content-Organization.html +2 -2
- package/docs/Gamification.html +245 -0
- package/docs/api_types.js.html +97 -0
- package/docs/config.js.html +2 -2
- package/docs/content-org_playlists-types.js.html +3 -5
- package/docs/content-org_playlists.js.html +8 -9
- package/docs/content.js.html +2 -2
- package/docs/gamification_awards.js.html +664 -0
- package/docs/gamification_gamification.js.html +76 -0
- package/docs/gamification_types.js.html +98 -0
- package/docs/global.html +1441 -153
- package/docs/index.html +2 -2
- package/docs/module-Awards.html +354 -0
- package/docs/module-Config.html +2 -2
- package/docs/module-Content-Services-V2.html +2 -2
- package/docs/module-Playlists.html +6 -6
- package/docs/module-Railcontent-Services.html +33 -194
- package/docs/module-Sanity-Services.html +885 -90
- package/docs/module-Session-Management.html +2 -2
- package/docs/module-User-Permissions.html +2 -2
- package/docs/railcontent.js.html +13 -25
- package/docs/sanity.js.html +76 -5
- package/docs/user_permissions.js.html +3 -3
- package/docs/user_sessions.js.html +4 -4
- package/docs/user_types.js.html +2 -2
- package/jsdoc.json +4 -2
- package/package.json +1 -1
- package/src/contentTypeConfig.js +1 -0
- package/src/index.d.ts +40 -3
- package/src/index.js +40 -2
- package/src/services/api/types.js +25 -0
- package/src/services/dataContext.js +15 -2
- package/src/services/gamification/awards.js +592 -0
- package/src/services/gamification/gamification.js +4 -0
- package/src/services/gamification/types.js +26 -0
- package/src/services/railcontent.js +60 -0
- package/src/services/sanity.js +22 -21
- package/src/services/userActivity.js +377 -23
- package/test/contentLikes.test.js +2 -0
- package/test/mockData/mockData_fetchByRailContentIds_one_content.json +35 -0
- package/test/userActivity.test.js +118 -0
package/src/index.js
CHANGED
|
@@ -51,6 +51,10 @@ import {
|
|
|
51
51
|
getActiveDiscussions
|
|
52
52
|
} from './services/forum.js';
|
|
53
53
|
|
|
54
|
+
import {
|
|
55
|
+
fetchAwardsForUser
|
|
56
|
+
} from './services/gamification/awards.js';
|
|
57
|
+
|
|
54
58
|
import {
|
|
55
59
|
assignModeratorToComment,
|
|
56
60
|
closeComment,
|
|
@@ -90,8 +94,11 @@ import {
|
|
|
90
94
|
fetchUserChallengeProgress,
|
|
91
95
|
fetchUserLikes,
|
|
92
96
|
fetchUserPermissionsData,
|
|
97
|
+
fetchUserPracticeMeta,
|
|
98
|
+
fetchUserPractices,
|
|
93
99
|
likeComment,
|
|
94
100
|
likePlaylist,
|
|
101
|
+
logUserPractice,
|
|
95
102
|
openComment,
|
|
96
103
|
pinPlaylist,
|
|
97
104
|
playback,
|
|
@@ -175,6 +182,11 @@ import {
|
|
|
175
182
|
jumpToContinueContent
|
|
176
183
|
} from './services/sanity.js';
|
|
177
184
|
|
|
185
|
+
import {
|
|
186
|
+
blockUser,
|
|
187
|
+
unblockUser
|
|
188
|
+
} from './services/user/management.js';
|
|
189
|
+
|
|
178
190
|
import {
|
|
179
191
|
fetchUserPermissions,
|
|
180
192
|
reset
|
|
@@ -186,7 +198,17 @@ import {
|
|
|
186
198
|
} from './services/user/sessions.js';
|
|
187
199
|
|
|
188
200
|
import {
|
|
189
|
-
|
|
201
|
+
deletePracticeSession,
|
|
202
|
+
getPracticeSessions,
|
|
203
|
+
getRecentActivity,
|
|
204
|
+
getUserMonthlyStats,
|
|
205
|
+
getUserPractices,
|
|
206
|
+
getUserWeeklyStats,
|
|
207
|
+
recordUserPractice,
|
|
208
|
+
removeUserPractice,
|
|
209
|
+
restorePracticeSession,
|
|
210
|
+
restoreUserPractice,
|
|
211
|
+
updateUserPractice
|
|
190
212
|
} from './services/userActivity.js';
|
|
191
213
|
|
|
192
214
|
export {
|
|
@@ -194,6 +216,7 @@ export {
|
|
|
194
216
|
assignModeratorToComment,
|
|
195
217
|
assignmentStatusCompleted,
|
|
196
218
|
assignmentStatusReset,
|
|
219
|
+
blockUser,
|
|
197
220
|
closeComment,
|
|
198
221
|
contentStatusCompleted,
|
|
199
222
|
contentStatusReset,
|
|
@@ -204,6 +227,7 @@ export {
|
|
|
204
227
|
deletePlaylist,
|
|
205
228
|
deletePlaylistItem,
|
|
206
229
|
deletePlaylistLike,
|
|
230
|
+
deletePracticeSession,
|
|
207
231
|
duplicatePlaylist,
|
|
208
232
|
editComment,
|
|
209
233
|
fetchAll,
|
|
@@ -212,6 +236,7 @@ export {
|
|
|
212
236
|
fetchAllPacks,
|
|
213
237
|
fetchArtistLessons,
|
|
214
238
|
fetchArtists,
|
|
239
|
+
fetchAwardsForUser,
|
|
215
240
|
fetchByRailContentId,
|
|
216
241
|
fetchByRailContentIds,
|
|
217
242
|
fetchByReference,
|
|
@@ -282,6 +307,8 @@ export {
|
|
|
282
307
|
fetchUserPermissions,
|
|
283
308
|
fetchUserPermissionsData,
|
|
284
309
|
fetchUserPlaylists,
|
|
310
|
+
fetchUserPracticeMeta,
|
|
311
|
+
fetchUserPractices,
|
|
285
312
|
getActiveDiscussions,
|
|
286
313
|
getAllCompleted,
|
|
287
314
|
getAllStarted,
|
|
@@ -289,17 +316,21 @@ export {
|
|
|
289
316
|
getContentRows,
|
|
290
317
|
getLessonContentRows,
|
|
291
318
|
getNewAndUpcoming,
|
|
319
|
+
getPracticeSessions,
|
|
292
320
|
getProgressPercentage,
|
|
293
321
|
getProgressPercentageByIds,
|
|
294
322
|
getProgressState,
|
|
295
323
|
getProgressStateByIds,
|
|
296
324
|
getRecent,
|
|
325
|
+
getRecentActivity,
|
|
297
326
|
getRecommendedForYou,
|
|
298
327
|
getResumeTimeSeconds,
|
|
299
328
|
getScheduleContentRows,
|
|
300
329
|
getSortOrder,
|
|
301
330
|
getTabResults,
|
|
302
|
-
|
|
331
|
+
getUserMonthlyStats,
|
|
332
|
+
getUserPractices,
|
|
333
|
+
getUserWeeklyStats,
|
|
303
334
|
globalConfig,
|
|
304
335
|
initializeService,
|
|
305
336
|
isContentLiked,
|
|
@@ -307,6 +338,7 @@ export {
|
|
|
307
338
|
likeComment,
|
|
308
339
|
likeContent,
|
|
309
340
|
likePlaylist,
|
|
341
|
+
logUserPractice,
|
|
310
342
|
login,
|
|
311
343
|
logout,
|
|
312
344
|
openComment,
|
|
@@ -328,16 +360,22 @@ export {
|
|
|
328
360
|
rankCategories,
|
|
329
361
|
rankItems,
|
|
330
362
|
recommendations,
|
|
363
|
+
recordUserPractice,
|
|
331
364
|
recordWatchSession,
|
|
365
|
+
removeUserPractice,
|
|
332
366
|
replyToComment,
|
|
333
367
|
reportPlaylist,
|
|
334
368
|
reset,
|
|
369
|
+
restorePracticeSession,
|
|
370
|
+
restoreUserPractice,
|
|
335
371
|
setStudentViewForUser,
|
|
336
372
|
unassignModeratorToComment,
|
|
373
|
+
unblockUser,
|
|
337
374
|
unlikeComment,
|
|
338
375
|
unlikeContent,
|
|
339
376
|
unpinPlaylist,
|
|
340
377
|
updatePlaylist,
|
|
341
378
|
updatePlaylistItem,
|
|
379
|
+
updateUserPractice,
|
|
342
380
|
verifyLocalDataContext,
|
|
343
381
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} PaginatedMeta
|
|
3
|
+
* @property {number} current_page - Total number of items
|
|
4
|
+
* @property {number} from - First index of returned data
|
|
5
|
+
* @property {number} to - Last index of returned data
|
|
6
|
+
* @property {number} per_page - Total number of items per page
|
|
7
|
+
* @property {number} last_page - Last page accessed
|
|
8
|
+
* @property {number} total - Total number of items
|
|
9
|
+
* @property {string} path - Url of the current page
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {Object} PaginatedLinks
|
|
14
|
+
* @property {string} first - URL of the first page
|
|
15
|
+
* @property {string} last - URL of the last page
|
|
16
|
+
* @property {string} next - URL of the next page
|
|
17
|
+
* @property {string} prev - URL of the previous page
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @typedef {Object<T>} PaginatedResponse
|
|
22
|
+
* @property {PaginatedMeta} meta - Meta information
|
|
23
|
+
* @property {PaginatedLinks} links - Links information
|
|
24
|
+
* @property {Array<T>} data - Data
|
|
25
|
+
*/
|
|
@@ -10,6 +10,7 @@ const excludeFromGeneratedIndex = []
|
|
|
10
10
|
//These constants need to match MWP UserDataVersionKeyEnum enum
|
|
11
11
|
export const ContentLikesVersionKey = 0
|
|
12
12
|
export const ContentProgressVersionKey = 1
|
|
13
|
+
export const UserActivityVersionKey = 2
|
|
13
14
|
|
|
14
15
|
let cache = null
|
|
15
16
|
|
|
@@ -101,8 +102,10 @@ export class DataContext {
|
|
|
101
102
|
|
|
102
103
|
clearCache() {
|
|
103
104
|
this.clearContext()
|
|
104
|
-
cache
|
|
105
|
-
|
|
105
|
+
if (cache) {
|
|
106
|
+
cache.removeItem(this.localStorageKey)
|
|
107
|
+
cache.removeItem(this.localStorageLastUpdatedKey)
|
|
108
|
+
}
|
|
106
109
|
}
|
|
107
110
|
|
|
108
111
|
clearContext() {
|
|
@@ -134,4 +137,14 @@ export class DataContext {
|
|
|
134
137
|
version() {
|
|
135
138
|
return this.context?.version ?? -1
|
|
136
139
|
}
|
|
140
|
+
async updateLocal(localUpdateFunction) {
|
|
141
|
+
await this.ensureLocalContextLoaded()
|
|
142
|
+
if (this.context) {
|
|
143
|
+
const res = await localUpdateFunction(this.context)
|
|
144
|
+
if (this.context) this.context.version++
|
|
145
|
+
let data = JSON.stringify(this.context)
|
|
146
|
+
cache.setItem(this.localStorageKey, data)
|
|
147
|
+
this.setLastUpdatedTime()
|
|
148
|
+
}
|
|
149
|
+
}
|
|
137
150
|
}
|