musora-content-services 2.3.11 → 2.3.13
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/workflows/node.js.yml +0 -0
- package/.prettierignore +0 -0
- package/.prettierrc +0 -0
- package/CHANGELOG.md +4 -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 -3
- 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 -2
- 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 +2 -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 +2 -2
- package/docs/module-Permissions.html +2 -2
- package/docs/module-Playlists.html +2 -2
- package/docs/module-Railcontent-Services.html +222 -57
- package/docs/module-Sanity-Services.html +19 -19
- package/docs/module-Session-Management.html +0 -0
- package/docs/module-Sessions.html +2 -2
- package/docs/module-User-Activity.html +2849 -0
- 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/railcontent.js.html +47 -20
- package/docs/sanity.js.html +3 -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 +742 -0
- package/docs/user_management.js.html +2 -2
- package/docs/user_permissions.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/docs/user_user-management.js.html +0 -0
- package/jest.config.js +0 -0
- package/jsdoc.json +1 -0
- package/link_mcs.sh +0 -0
- package/package.json +1 -1
- package/src/contentMetaData.js +0 -0
- package/src/filterBuilder.js +0 -0
- package/src/index.d.ts +8 -0
- package/src/index.js +8 -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 -0
- package/src/services/contentProgress.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 +15 -0
- package/src/services/recommendations.js +9 -7
- package/src/services/sanity.js +4 -2
- package/src/services/types.js +0 -0
- package/src/services/user/management.js +0 -0
- package/src/services/user/permissions.js +0 -0
- package/src/services/user/sessions.js +0 -0
- package/src/services/user/types.js +0 -0
- package/src/services/user/user-management-system.js +0 -0
- package/src/services/userActivity.js +103 -6
- package/test/content.test.js +0 -0
- 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 +0 -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
package/jsdoc.json
CHANGED
package/link_mcs.sh
CHANGED
|
File without changes
|
package/package.json
CHANGED
package/src/contentMetaData.js
CHANGED
|
File without changes
|
package/src/filterBuilder.js
CHANGED
|
File without changes
|
package/src/index.d.ts
CHANGED
|
@@ -115,6 +115,7 @@ import {
|
|
|
115
115
|
fetchUserLikes,
|
|
116
116
|
fetchUserPermissionsData,
|
|
117
117
|
fetchUserPracticeMeta,
|
|
118
|
+
fetchUserPracticeNotes,
|
|
118
119
|
fetchUserPractices,
|
|
119
120
|
likeComment,
|
|
120
121
|
likePlaylist,
|
|
@@ -218,7 +219,9 @@ import {
|
|
|
218
219
|
} from './services/user/sessions.js';
|
|
219
220
|
|
|
220
221
|
import {
|
|
222
|
+
createPracticeNotes,
|
|
221
223
|
deletePracticeSession,
|
|
224
|
+
getPracticeNotes,
|
|
222
225
|
getPracticeSessions,
|
|
223
226
|
getRecentActivity,
|
|
224
227
|
getUserMonthlyStats,
|
|
@@ -228,6 +231,7 @@ import {
|
|
|
228
231
|
removeUserPractice,
|
|
229
232
|
restorePracticeSession,
|
|
230
233
|
restoreUserPractice,
|
|
234
|
+
updatePracticeNotes,
|
|
231
235
|
updateUserPractice
|
|
232
236
|
} from './services/userActivity.js';
|
|
233
237
|
|
|
@@ -248,6 +252,7 @@ declare module 'musora-content-services' {
|
|
|
248
252
|
countAssignmentsAndLessons,
|
|
249
253
|
createComment,
|
|
250
254
|
createPlaylist,
|
|
255
|
+
createPracticeNotes,
|
|
251
256
|
deleteComment,
|
|
252
257
|
deletePlaylist,
|
|
253
258
|
deletePlaylistItem,
|
|
@@ -334,6 +339,7 @@ declare module 'musora-content-services' {
|
|
|
334
339
|
fetchUserPermissionsData,
|
|
335
340
|
fetchUserPlaylists,
|
|
336
341
|
fetchUserPracticeMeta,
|
|
342
|
+
fetchUserPracticeNotes,
|
|
337
343
|
fetchUserPractices,
|
|
338
344
|
getActiveDiscussions,
|
|
339
345
|
getAllCompleted,
|
|
@@ -343,6 +349,7 @@ declare module 'musora-content-services' {
|
|
|
343
349
|
getLessonContentRows,
|
|
344
350
|
getMonday,
|
|
345
351
|
getNewAndUpcoming,
|
|
352
|
+
getPracticeNotes,
|
|
346
353
|
getPracticeSessions,
|
|
347
354
|
getProgressPercentage,
|
|
348
355
|
getProgressPercentageByIds,
|
|
@@ -407,6 +414,7 @@ declare module 'musora-content-services' {
|
|
|
407
414
|
unpinPlaylist,
|
|
408
415
|
updatePlaylist,
|
|
409
416
|
updatePlaylistItem,
|
|
417
|
+
updatePracticeNotes,
|
|
410
418
|
updateUserPractice,
|
|
411
419
|
verifyImageSRC,
|
|
412
420
|
verifyLocalDataContext,
|
package/src/index.js
CHANGED
|
@@ -115,6 +115,7 @@ import {
|
|
|
115
115
|
fetchUserLikes,
|
|
116
116
|
fetchUserPermissionsData,
|
|
117
117
|
fetchUserPracticeMeta,
|
|
118
|
+
fetchUserPracticeNotes,
|
|
118
119
|
fetchUserPractices,
|
|
119
120
|
likeComment,
|
|
120
121
|
likePlaylist,
|
|
@@ -218,7 +219,9 @@ import {
|
|
|
218
219
|
} from './services/user/sessions.js';
|
|
219
220
|
|
|
220
221
|
import {
|
|
222
|
+
createPracticeNotes,
|
|
221
223
|
deletePracticeSession,
|
|
224
|
+
getPracticeNotes,
|
|
222
225
|
getPracticeSessions,
|
|
223
226
|
getRecentActivity,
|
|
224
227
|
getUserMonthlyStats,
|
|
@@ -228,6 +231,7 @@ import {
|
|
|
228
231
|
removeUserPractice,
|
|
229
232
|
restorePracticeSession,
|
|
230
233
|
restoreUserPractice,
|
|
234
|
+
updatePracticeNotes,
|
|
231
235
|
updateUserPractice
|
|
232
236
|
} from './services/userActivity.js';
|
|
233
237
|
|
|
@@ -247,6 +251,7 @@ export {
|
|
|
247
251
|
countAssignmentsAndLessons,
|
|
248
252
|
createComment,
|
|
249
253
|
createPlaylist,
|
|
254
|
+
createPracticeNotes,
|
|
250
255
|
deleteComment,
|
|
251
256
|
deletePlaylist,
|
|
252
257
|
deletePlaylistItem,
|
|
@@ -333,6 +338,7 @@ export {
|
|
|
333
338
|
fetchUserPermissionsData,
|
|
334
339
|
fetchUserPlaylists,
|
|
335
340
|
fetchUserPracticeMeta,
|
|
341
|
+
fetchUserPracticeNotes,
|
|
336
342
|
fetchUserPractices,
|
|
337
343
|
getActiveDiscussions,
|
|
338
344
|
getAllCompleted,
|
|
@@ -342,6 +348,7 @@ export {
|
|
|
342
348
|
getLessonContentRows,
|
|
343
349
|
getMonday,
|
|
344
350
|
getNewAndUpcoming,
|
|
351
|
+
getPracticeNotes,
|
|
345
352
|
getPracticeSessions,
|
|
346
353
|
getProgressPercentage,
|
|
347
354
|
getProgressPercentageByIds,
|
|
@@ -406,6 +413,7 @@ export {
|
|
|
406
413
|
unpinPlaylist,
|
|
407
414
|
updatePlaylist,
|
|
408
415
|
updatePlaylistItem,
|
|
416
|
+
updatePracticeNotes,
|
|
409
417
|
updateUserPractice,
|
|
410
418
|
verifyImageSRC,
|
|
411
419
|
verifyLocalDataContext,
|
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
|
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
|
|
@@ -1233,6 +1233,21 @@ export async function fetchUserPracticeMeta(practiceIds) {
|
|
|
1233
1233
|
return await fetchHandler(url, 'GET', null)
|
|
1234
1234
|
}
|
|
1235
1235
|
|
|
1236
|
+
/**
|
|
1237
|
+
* Fetches user practice notes for a specific date.
|
|
1238
|
+
* @param {string} date - The date for which to fetch practice notes (format: YYYY-MM-DD).
|
|
1239
|
+
* @returns {Promise<Object|null>} - A promise that resolves to an object containing the practice notes if found, otherwise null.
|
|
1240
|
+
*
|
|
1241
|
+
* @example
|
|
1242
|
+
* fetchUserPracticeNotes('2025-04-10')
|
|
1243
|
+
* .then(notes => console.log(notes))
|
|
1244
|
+
* .catch(error => console.error(error));
|
|
1245
|
+
*/
|
|
1246
|
+
export async function fetchUserPracticeNotes(date) {
|
|
1247
|
+
const url = `/api/user/practices/v1/notes?date=${date}`
|
|
1248
|
+
return await fetchHandler(url, 'GET', null)
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1236
1251
|
function fetchAbsolute(url, params) {
|
|
1237
1252
|
if (globalConfig.sessionConfig.authToken) {
|
|
1238
1253
|
params.headers['Authorization'] = `Bearer ${globalConfig.sessionConfig.authToken}`
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* @module Railcontent-Services
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import {globalConfig} from './config.js'
|
|
6
|
+
import {fetchJSONHandler} from '../lib/httpHelper.js'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Exported functions that are excluded from index generation.
|
|
@@ -32,12 +32,13 @@ export async function fetchSimilarItems(content_id, brand, count = 10) {
|
|
|
32
32
|
let data = {
|
|
33
33
|
brand: brand,
|
|
34
34
|
content_ids: content_id,
|
|
35
|
-
num_similar: count,
|
|
35
|
+
num_similar: count + 1, // because the content itself is sometimes returned
|
|
36
36
|
}
|
|
37
37
|
const url = `/similar_items/`
|
|
38
38
|
try {
|
|
39
39
|
const response = await fetchHandler(url, 'POST', data)
|
|
40
|
-
|
|
40
|
+
// we requested count + 1 then filtered out the extra potential value, so we need slice to the correct size if necessary
|
|
41
|
+
return response['similar_items'].filter((item) => item !== content_id).slice(0, count)
|
|
41
42
|
} catch (error) {
|
|
42
43
|
console.error('Fetch error:', error)
|
|
43
44
|
return null
|
|
@@ -113,11 +114,12 @@ export async function rankItems(brand, content_ids) {
|
|
|
113
114
|
}
|
|
114
115
|
}
|
|
115
116
|
|
|
116
|
-
export async function recommendations(brand, {
|
|
117
|
+
export async function recommendations(brand, {section = ''} = {}) {
|
|
117
118
|
section = section.toUpperCase().replace('-', '_')
|
|
118
119
|
const sectionString = section ? `§ion=${section}` : '';
|
|
119
120
|
const url = `/api/content/v1/recommendations?brand=${brand}${sectionString}`
|
|
120
121
|
try {
|
|
122
|
+
// This goes through the MPB, not the recommendations api, so we use fetchJSONHandler instead of the local handler
|
|
121
123
|
return fetchJSONHandler(
|
|
122
124
|
url,
|
|
123
125
|
globalConfig.sessionConfig.token,
|
|
@@ -133,8 +135,8 @@ export async function recommendations(brand, { section = ''} = {}) {
|
|
|
133
135
|
async function fetchHandler(url, method = 'get', body = null) {
|
|
134
136
|
return fetchJSONHandler(
|
|
135
137
|
url,
|
|
136
|
-
globalConfig.
|
|
137
|
-
globalConfig.baseUrl,
|
|
138
|
+
globalConfig.recommendationsConfig.token,
|
|
139
|
+
globalConfig.recommendationsConfig.baseUrl,
|
|
138
140
|
method,
|
|
139
141
|
null,
|
|
140
142
|
body
|
package/src/services/sanity.js
CHANGED
|
@@ -406,7 +406,8 @@ export async function fetchUpcomingEvents(brand, { page = 1, limit = 10 } = {})
|
|
|
406
406
|
published_on,
|
|
407
407
|
"type": _type,
|
|
408
408
|
web_url_path,
|
|
409
|
-
"permission_id": permission[]->railcontent_id
|
|
409
|
+
"permission_id": permission[]->railcontent_id,
|
|
410
|
+
"isLive": live_event_start_time <= '${now}' && live_event_end_time >= '${now}'`
|
|
410
411
|
const query = buildRawQuery(
|
|
411
412
|
`_type in ${typesString} && brand == '${brand}' && published_on > '${now}' && status == 'scheduled'`,
|
|
412
413
|
fields,
|
|
@@ -2348,7 +2349,8 @@ export async function fetchScheduledAndNewReleases(
|
|
|
2348
2349
|
published_on,
|
|
2349
2350
|
"type": _type,
|
|
2350
2351
|
show_in_new_feed,
|
|
2351
|
-
"permission_id": permission[]->railcontent_id
|
|
2352
|
+
"permission_id": permission[]->railcontent_id,
|
|
2353
|
+
"isLive": live_event_start_time <= '${now}' && live_event_end_time >= '${now}',
|
|
2352
2354
|
}`
|
|
2353
2355
|
|
|
2354
2356
|
return fetchSanity(query, true)
|
package/src/services/types.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module User-Activity
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {fetchUserPractices, logUserPractice, fetchUserPracticeMeta, fetchHandler} from './railcontent'
|
|
5
|
+
import {fetchUserPractices, logUserPractice, fetchUserPracticeMeta, fetchUserPracticeNotes, fetchHandler} from './railcontent'
|
|
6
6
|
import { DataContext, UserActivityVersionKey } from './dataContext.js'
|
|
7
7
|
import {fetchByRailContentIds} from "./sanity";
|
|
8
8
|
import {lessonTypesMapping} from "../contentTypeConfig";
|
|
@@ -340,6 +340,22 @@ export async function restoreUserPractice(id) {
|
|
|
340
340
|
return response;
|
|
341
341
|
}
|
|
342
342
|
|
|
343
|
+
/**
|
|
344
|
+
* Deletes all practice sessions for a specific day.
|
|
345
|
+
*
|
|
346
|
+
* This function retrieves all user practice session IDs for a given day and sends a DELETE request
|
|
347
|
+
* to remove them from the server. It also updates the local context to reflect the deletion.
|
|
348
|
+
*
|
|
349
|
+
* @async
|
|
350
|
+
* @param {string} day - The day (in `YYYY-MM-DD` format) for which practice sessions should be deleted.
|
|
351
|
+
* @returns {Promise<string[]>} - A promise that resolves once the practice session is removed.
|
|
352
|
+
*
|
|
353
|
+
* * @example
|
|
354
|
+
* // Delete practice sessions for April 10, 2025
|
|
355
|
+
* deletePracticeSession("2025-04-10")
|
|
356
|
+
* .then(deletedIds => console.log("Deleted sessions:", response))
|
|
357
|
+
* .catch(error => console.error("Delete failed:", error));
|
|
358
|
+
*/
|
|
343
359
|
export async function deletePracticeSession(day) {
|
|
344
360
|
const userPracticesIds = await getUserPracticeIds(day);
|
|
345
361
|
if (!userPracticesIds.length) return [];
|
|
@@ -348,9 +364,7 @@ export async function deletePracticeSession(day) {
|
|
|
348
364
|
await userActivityContext.update(
|
|
349
365
|
async function (localContext) {
|
|
350
366
|
if (localContext.data?.[DATA_KEY_PRACTICES]?.[day]) {
|
|
351
|
-
|
|
352
|
-
practice => !userPracticesIds.includes(practice.id)
|
|
353
|
-
);
|
|
367
|
+
delete localContext.data[DATA_KEY_PRACTICES][day];
|
|
354
368
|
}
|
|
355
369
|
},
|
|
356
370
|
async function () {
|
|
@@ -359,6 +373,22 @@ export async function deletePracticeSession(day) {
|
|
|
359
373
|
);
|
|
360
374
|
}
|
|
361
375
|
|
|
376
|
+
/**
|
|
377
|
+
* Restores deleted practice sessions for a specific date.
|
|
378
|
+
*
|
|
379
|
+
* Sends a PUT request to restore any previously deleted practices for a given date.
|
|
380
|
+
* If restored practices are returned, they are added back into the local context.
|
|
381
|
+
*
|
|
382
|
+
* @async
|
|
383
|
+
* @param {string} date - The date (in `YYYY-MM-DD` format) for which deleted practice sessions should be restored.
|
|
384
|
+
* @returns {Promise<Object>} - The response object from the API, containing practices for selected date.
|
|
385
|
+
*
|
|
386
|
+
* @example
|
|
387
|
+
* // Restore practice sessions deleted on April 10, 2025
|
|
388
|
+
* restorePracticeSession("2025-04-10")
|
|
389
|
+
* .then(response => console.log("Practice session restored:", response))
|
|
390
|
+
* .catch(error => console.error("Restore failed:", error));
|
|
391
|
+
*/
|
|
362
392
|
export async function restorePracticeSession(date) {
|
|
363
393
|
const url = `/api/user/practices/v1/practices/restore?date=${date}`;
|
|
364
394
|
const response = await fetchHandler(url, 'PUT', null);
|
|
@@ -395,7 +425,7 @@ export async function restorePracticeSession(date) {
|
|
|
395
425
|
*/
|
|
396
426
|
export async function getPracticeSessions(day) {
|
|
397
427
|
const userPracticesIds = await getUserPracticeIds(day);
|
|
398
|
-
if (!userPracticesIds.length) return { data: { practices: [], practiceDuration: 0
|
|
428
|
+
if (!userPracticesIds.length) return { data: { practices: [], practiceDuration: 0} };
|
|
399
429
|
|
|
400
430
|
const meta = await fetchUserPracticeMeta(userPracticesIds);
|
|
401
431
|
if (!meta.data.length) return { data: { practices: [], practiceDuration: 0 } };
|
|
@@ -432,14 +462,81 @@ export async function getPracticeSessions(day) {
|
|
|
432
462
|
created_at: convertToTimeZone(utcDate, userTimeZone)
|
|
433
463
|
};
|
|
434
464
|
});
|
|
435
|
-
return { data: { practices: formattedMeta, practiceDuration
|
|
465
|
+
return { data: { practices: formattedMeta, practiceDuration} };
|
|
436
466
|
}
|
|
437
467
|
|
|
468
|
+
/**
|
|
469
|
+
* Retrieves user practice notes for a specific day.
|
|
470
|
+
*
|
|
471
|
+
* @async
|
|
472
|
+
* @param {string} day - The day (in `YYYY-MM-DD` format) to fetch practice notes for.
|
|
473
|
+
* @returns {Promise<{ data: Object[] }>} - A promise that resolves to an object containing the practice notes.
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
* // Get notes for April 10, 2025
|
|
477
|
+
* getPracticeNotes("2025-04-10")
|
|
478
|
+
* .then(({ data }) => console.log("Practice notes:", data))
|
|
479
|
+
* .catch(error => console.error("Failed to get notes:", error));
|
|
480
|
+
*/
|
|
481
|
+
export async function getPracticeNotes(day) {
|
|
482
|
+
const notes = await fetchUserPracticeNotes(day);
|
|
483
|
+
return { data: notes };
|
|
484
|
+
}
|
|
438
485
|
|
|
486
|
+
/**
|
|
487
|
+
* Retrieves the user's recent activity.
|
|
488
|
+
*
|
|
489
|
+
* Returns an object containing recent practice activity.
|
|
490
|
+
*
|
|
491
|
+
* @async
|
|
492
|
+
* @returns {Promise<{ data: Object[] }>} - A promise that resolves to an object containing recent activity items.
|
|
493
|
+
*
|
|
494
|
+
* @example
|
|
495
|
+
* // Fetch recent practice activity
|
|
496
|
+
* getRecentActivity()
|
|
497
|
+
* .then(({ data }) => console.log("Recent activity:", data))
|
|
498
|
+
* .catch(error => console.error("Failed to get recent activity:", error));
|
|
499
|
+
*/
|
|
439
500
|
export async function getRecentActivity() {
|
|
440
501
|
return { data: recentActivity };
|
|
441
502
|
}
|
|
442
503
|
|
|
504
|
+
/**
|
|
505
|
+
* Creates practice notes for a specific date.
|
|
506
|
+
*
|
|
507
|
+
* @param {Object} payload - The data required to create practice notes.
|
|
508
|
+
* @param {string} payload.date - The date for which to create notes (format: YYYY-MM-DD).
|
|
509
|
+
* @param {string} payload.notes - The notes content to be saved.
|
|
510
|
+
* @returns {Promise<Object>} - A promise that resolves to the API response after creating the notes.
|
|
511
|
+
*
|
|
512
|
+
* @example
|
|
513
|
+
* createPracticeNotes({ date: '2025-04-10', notes: 'Worked on scales and arpeggios' })
|
|
514
|
+
* .then(response => console.log(response))
|
|
515
|
+
* .catch(error => console.error(error));
|
|
516
|
+
*/
|
|
517
|
+
export async function createPracticeNotes(payload) {
|
|
518
|
+
const url = `/api/user/practices/v1/notes`
|
|
519
|
+
return await fetchHandler(url, 'POST', null, payload)
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* Updates existing practice notes for a specific date.
|
|
524
|
+
*
|
|
525
|
+
* @param {Object} payload - The data required to update practice notes.
|
|
526
|
+
* @param {string} payload.date - The date for which to update notes (format: YYYY-MM-DD).
|
|
527
|
+
* @param {string} payload.notes - The updated notes content.
|
|
528
|
+
* @returns {Promise<Object>} - A promise that resolves to the API response after updating the notes.
|
|
529
|
+
*
|
|
530
|
+
* @example
|
|
531
|
+
* updatePracticeNotes({ date: '2025-04-10', notes: 'Updated: Focused on technique and timing' })
|
|
532
|
+
* .then(response => console.log(response))
|
|
533
|
+
* .catch(error => console.error(error));
|
|
534
|
+
*/
|
|
535
|
+
export async function updatePracticeNotes(payload) {
|
|
536
|
+
const url = `/api/user/practices/v1/notes`
|
|
537
|
+
return await fetchHandler(url, 'PUT', null, payload)
|
|
538
|
+
}
|
|
539
|
+
|
|
443
540
|
function getStreaksAndMessage(practices) {
|
|
444
541
|
let { currentDailyStreak, currentWeeklyStreak, streakMessage } = calculateStreaks(practices, true);
|
|
445
542
|
|
package/test/content.test.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/test/dataContext.test.js
CHANGED
|
File without changes
|
package/test/forum.test.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/test/initializeTests.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/test/localStorageMock.js
CHANGED
|
File without changes
|
package/test/log.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/tools/generate-index.cjs
CHANGED
|
File without changes
|
package/.yarnrc.yml
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
nodeLinker: node-modules
|