musora-content-services 2.5.1 → 2.6.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/.coderabbit.yaml +0 -0
- package/.editorconfig +0 -0
- package/.github/pull_request_template.md +0 -0
- package/.github/workflows/node.js.yml +0 -0
- package/.prettierignore +0 -0
- package/.prettierrc +0 -0
- package/CHANGELOG.md +14 -0
- package/README.md +0 -0
- package/babel.config.cjs +0 -0
- package/docs/Content-Organization.html +0 -0
- package/docs/ContentOrganization.html +2 -2
- package/docs/Gamification.html +2 -2
- package/docs/UserManagement.html +0 -0
- 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_playlists-types.js.html +2 -2
- package/docs/content-org_playlists.js.html +2 -2
- package/docs/content.js.html +2 -4
- 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/gamification_awards.js.html +2 -2
- package/docs/gamification_gamification.js.html +2 -2
- package/docs/gamification_types.js.html +2 -2
- package/docs/global.html +448 -2
- package/docs/global.html#User +0 -0
- package/docs/index.html +2 -2
- package/docs/module-Awards.html +2 -2
- package/docs/module-Config.html +2 -2
- package/docs/module-Content-Services-V2.html +8 -8
- package/docs/module-Interests.html +2 -2
- package/docs/module-Permissions.html +2 -2
- package/docs/module-Playlists.html +2 -2
- package/docs/module-Railcontent-Services.html +754 -44
- package/docs/module-Sanity-Services.html +2 -2
- package/docs/module-Session-Management.html +0 -0
- package/docs/module-Sessions.html +2 -2
- package/docs/module-User-Activity.html +521 -12
- package/docs/module-User-Management.html +0 -0
- package/docs/module-User-Permissions.html +0 -0
- package/docs/module-UserManagement.html +2 -2
- package/docs/module-UserProfile.html +266 -0
- package/docs/railcontent.js.html +41 -2
- package/docs/sanity.js.html +2 -2
- 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/types.js.html +0 -0
- package/docs/userActivity.js.html +350 -263
- package/docs/user_interests.js.html +2 -2
- package/docs/user_management.js.html +2 -2
- package/docs/user_permissions.js.html +2 -2
- package/docs/user_profile.js.html +105 -0
- package/docs/user_sessions.js.html +2 -2
- package/docs/user_types.js.html +22 -2
- package/docs/user_user-management-system.js.html +2 -2
- package/docs/user_user-management.js.html +0 -0
- package/jest.config.js +0 -0
- package/jsdoc.json +0 -0
- package/package.json +1 -1
- package/src/contentMetaData.js +14 -0
- package/src/filterBuilder.js +0 -0
- package/src/index.d.ts +15 -0
- package/src/index.js +15 -0
- package/src/infrastructure/http/HttpClient.ts +0 -0
- package/src/infrastructure/http/executors/FetchRequestExecutor.ts +0 -0
- package/src/infrastructure/http/index.ts +0 -0
- package/src/infrastructure/http/interfaces/HeaderProvider.ts +0 -0
- package/src/infrastructure/http/interfaces/HttpError.ts +0 -0
- package/src/infrastructure/http/interfaces/NetworkError.ts +0 -0
- package/src/infrastructure/http/interfaces/RequestExecutor.ts +0 -0
- package/src/infrastructure/http/interfaces/RequestOptions.ts +0 -0
- package/src/infrastructure/http/providers/DefaultHeaderProvider.ts +0 -0
- package/src/lib/httpHelper.js +0 -0
- package/src/lib/lastUpdated.js +0 -0
- package/src/services/api/types.js +0 -0
- package/src/services/config.js +0 -0
- package/src/services/content-org/content-org.js +0 -0
- package/src/services/content-org/playlists-types.js +0 -0
- package/src/services/content-org/playlists.js +0 -0
- package/src/services/content.js +0 -2
- package/src/services/contentAggregator.js +0 -0
- package/src/services/contentLikes.js +0 -0
- package/src/services/dataContext.js +0 -0
- package/src/services/dateUtils.js +0 -0
- package/src/services/forum.js +0 -0
- package/src/services/gamification/awards.js +0 -0
- package/src/services/gamification/gamification.js +0 -0
- package/src/services/gamification/types.js +0 -0
- package/src/services/imageSRCBuilder.js +0 -0
- package/src/services/imageSRCVerify.js +0 -0
- package/src/services/railcontent.js +39 -0
- package/src/services/recommendations.js +0 -0
- package/src/services/types.js +0 -0
- package/src/services/user/interests.js +0 -0
- package/src/services/user/management.js +0 -0
- package/src/services/user/permissions.js +0 -0
- package/src/services/user/profile.js +33 -0
- package/src/services/user/sessions.js +0 -0
- package/src/services/user/types.js +20 -0
- package/src/services/user/user-management-system.js +0 -0
- package/src/services/userActivity.js +348 -261
- package/test/HttpClient.test.js +0 -0
- package/test/content.test.js +8 -6
- package/test/contentLikes.test.js +0 -0
- package/test/contentProgress.test.js +0 -0
- package/test/dataContext.test.js +0 -0
- package/test/forum.test.js +0 -0
- package/test/imageSRCBuilder.test.js +0 -0
- package/test/imageSRCVerify.test.js +0 -0
- package/test/initializeTests.js +0 -0
- package/test/lib/lastUpdated.test.js +0 -0
- 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/mockData/mockData_fetchByRailContentIds_one_content.json +0 -0
- package/test/mockData/mockData_user_practices.json +0 -0
- package/test/sanityQueryService.test.js +6 -0
- package/test/streakMessage.test.js +0 -0
- package/test/user/permissions.test.js +0 -0
- package/test/userActivity.test.js +0 -0
- package/tools/generate-index.cjs +0 -0
- package/.yarnrc.yml +0 -1
- package/docs/module-Content-Services.html +0 -763
|
File without changes
|
|
File without changes
|
package/src/lib/httpHelper.js
CHANGED
|
File without changes
|
package/src/lib/lastUpdated.js
CHANGED
|
File without changes
|
|
File without changes
|
package/src/services/config.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/services/content.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
-
fetchAll,
|
|
7
6
|
fetchByRailContentIds,
|
|
8
7
|
fetchMetadata,
|
|
9
8
|
fetchRecent,
|
|
@@ -15,7 +14,6 @@ import {
|
|
|
15
14
|
fetchLeaving, fetchScheduledAndNewReleases
|
|
16
15
|
} from './sanity.js'
|
|
17
16
|
import {TabResponseType, Tabs, capitalizeFirstLetter} from '../contentMetaData.js'
|
|
18
|
-
import {getAllStartedOrCompleted} from "./contentProgress";
|
|
19
17
|
import {fetchHandler} from "./railcontent";
|
|
20
18
|
import {recommendations} from "./recommendations";
|
|
21
19
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/services/forum.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -848,6 +848,45 @@ export async function fetchLastInteractedChild(content_ids) {
|
|
|
848
848
|
return await fetchHandler(url, 'GET', null)
|
|
849
849
|
}
|
|
850
850
|
|
|
851
|
+
/**
|
|
852
|
+
* @typedef {Object} Activity
|
|
853
|
+
* @property {string} id - Unique identifier for the activity.
|
|
854
|
+
* @property {string} type - Type of activity (e.g., "lesson_completed").
|
|
855
|
+
* @property {string} timestamp - ISO 8601 string of when the activity occurred.
|
|
856
|
+
* @property {Object} meta - Additional metadata related to the activity.
|
|
857
|
+
*/
|
|
858
|
+
|
|
859
|
+
/**
|
|
860
|
+
* @typedef {Object} PaginatedActivities
|
|
861
|
+
* @property {number} currentPage
|
|
862
|
+
* @property {number} totalPages
|
|
863
|
+
* @property {Activity[]} data
|
|
864
|
+
*/
|
|
865
|
+
|
|
866
|
+
/**
|
|
867
|
+
* Fetches a paginated list of recent user activities.
|
|
868
|
+
* @param {Object} [params={}] - Optional parameters.
|
|
869
|
+
* @param {number} [params.page=1] - The page number for pagination.
|
|
870
|
+
* @param {number} [params.limit=10] - The number of results per page.
|
|
871
|
+
* @param {string|null} [params.tabName=null] - Optional filter for activity type/tab.
|
|
872
|
+
* @returns {Promise<PaginatedActivities>} - A promise that resolves to a paginated object of user activities.
|
|
873
|
+
*
|
|
874
|
+
* @example
|
|
875
|
+
* fetchRecentUserActivities({ page: 2, limit: 5 })
|
|
876
|
+
* .then(activities => console.log(activities))
|
|
877
|
+
* .catch(error => console.error(error));
|
|
878
|
+
*/
|
|
879
|
+
export async function fetchRecentUserActivities({
|
|
880
|
+
page = 1,
|
|
881
|
+
limit = 5,
|
|
882
|
+
tabName = null
|
|
883
|
+
} = {}) {
|
|
884
|
+
let pageAndLimit = `?page=${page}&limit=${limit}`
|
|
885
|
+
let tabParam = tabName ? `&tabName=${tabName}` : ''
|
|
886
|
+
const url = `/api/user-management-system/v1/activities/all${pageAndLimit}${tabParam}`
|
|
887
|
+
return await fetchHandler(url, 'GET', null)
|
|
888
|
+
}
|
|
889
|
+
|
|
851
890
|
|
|
852
891
|
function fetchAbsolute(url, params) {
|
|
853
892
|
if (globalConfig.sessionConfig.authToken) {
|
|
File without changes
|
package/src/services/types.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module UserProfile
|
|
3
|
+
*/
|
|
4
|
+
import { fetchJSONHandler } from '../../lib/httpHelper.js'
|
|
5
|
+
import { globalConfig } from '../config.js'
|
|
6
|
+
import { calculateLongestStreaks } from '../userActivity.js'
|
|
7
|
+
import './types.js'
|
|
8
|
+
|
|
9
|
+
const baseUrl = `/api/user-management-system`
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {number|null} userId - The user ID to reset permissions for.
|
|
13
|
+
* @returns {Promise<OtherStatsDTO>}
|
|
14
|
+
*/
|
|
15
|
+
export async function otherStats(userId = globalConfig.sessionConfig.userId) {
|
|
16
|
+
const [otherStats, longestStreaks] = await Promise.all([
|
|
17
|
+
fetchJSONHandler(`${baseUrl}/v1/users/${userId}/statistics`, 'get'),
|
|
18
|
+
calculateLongestStreaks(userId),
|
|
19
|
+
])
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
...otherStats,
|
|
23
|
+
longest_day_streak: {
|
|
24
|
+
type: 'day',
|
|
25
|
+
length: longestStreaks.longestDailyStreak,
|
|
26
|
+
},
|
|
27
|
+
longest_week_streak: {
|
|
28
|
+
type: 'week',
|
|
29
|
+
length: longestStreaks.longestWeeklyStreak,
|
|
30
|
+
},
|
|
31
|
+
total_practice_time: longestStreaks.totalPracticeSeconds,
|
|
32
|
+
}
|
|
33
|
+
}
|
|
File without changes
|
|
@@ -114,3 +114,23 @@
|
|
|
114
114
|
* @property {boolean} isAdmin
|
|
115
115
|
* @property {boolean} isABasicMember
|
|
116
116
|
*/
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @typedef {Object} StreakDTO
|
|
120
|
+
*
|
|
121
|
+
* @property {string} type - week or day
|
|
122
|
+
* @property {number} length
|
|
123
|
+
* @property {Date|null} start_date
|
|
124
|
+
* @property {Date|null} end_date
|
|
125
|
+
*/
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @typedef {Object} OtherStatsDTO
|
|
129
|
+
*
|
|
130
|
+
* @property {StreakDTO} longest_day_streak
|
|
131
|
+
* @property {StreakDTO} longest_week_streak
|
|
132
|
+
* @property {number} total_practice_time
|
|
133
|
+
* @property {number} comment_likes
|
|
134
|
+
* @property {number} forum_post_likes
|
|
135
|
+
* @property {number} experience_points
|
|
136
|
+
*/
|
|
File without changes
|