musora-content-services 2.3.4 → 2.3.6
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 +22 -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 +245 -0
- package/docs/Gamification.html +2 -2
- package/docs/UserManagement.html +269 -0
- package/docs/UserManagementSystem.html +293 -0
- package/docs/api_types.js.html +2 -2
- package/docs/config.js.html +16 -22
- package/docs/content-org_content-org.js.html +76 -0
- package/docs/content-org_playlists-types.js.html +2 -2
- package/docs/content-org_playlists.js.html +4 -6
- package/docs/content.js.html +6 -3
- 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 +293 -0
- package/docs/index.html +2 -2
- package/docs/module-Awards.html +2 -2
- package/docs/module-Config.html +83 -616
- package/docs/module-Content-Services-V2.html +3 -3
- package/docs/module-Permissions.html +406 -0
- package/docs/module-Playlists.html +6 -6
- package/docs/module-Railcontent-Services.html +57 -57
- package/docs/module-Sanity-Services.html +34 -34
- package/docs/module-Session-Management.html +0 -0
- package/docs/module-Sessions.html +575 -0
- package/docs/module-User-Management.html +490 -0
- package/docs/module-User-Permissions.html +0 -0
- package/docs/module-UserManagement.html +490 -0
- package/docs/railcontent.js.html +82 -74
- package/docs/sanity.js.html +12 -9
- 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 +122 -0
- package/docs/user_management.js.html +105 -0
- package/docs/user_permissions.js.html +3 -3
- package/docs/user_sessions.js.html +6 -6
- package/docs/user_types.js.html +2 -2
- package/docs/user_user-management-system.js.html +78 -0
- package/docs/user_user-management.js.html +78 -0
- package/jest.config.js +0 -0
- package/jsdoc.json +0 -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 +0 -0
- package/src/index.js +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 +13 -20
- package/src/services/content-org/content-org.js +4 -0
- package/src/services/content-org/playlists-types.js +0 -0
- package/src/services/content-org/playlists.js +2 -4
- package/src/services/content.js +0 -0
- package/src/services/contentLikes.js +0 -0
- package/src/services/contentProgress.js +0 -0
- package/src/services/dataContext.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 +41 -43
- package/src/services/recommendations.js +19 -19
- package/src/services/sanity.js +1 -0
- package/src/services/types.js +50 -0
- package/src/services/user/management.js +1 -3
- package/src/services/user/permissions.js +1 -1
- package/src/services/user/sessions.js +4 -4
- package/src/services/user/types.js +0 -0
- package/src/services/user/user-management-system.js +6 -0
- 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 +6 -4
- 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/sanityQueryService.test.js +11 -1
- 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/Playlists.html +0 -192
- package/docs/content-org_types.js.html +0 -112
- package/docs/module-Content-Organization-Playlists.html +0 -194
- package/docs/module-Content-Organization.html +0 -976
- package/docs/module-Content-Services.html +0 -763
- package/docs/module-playlists.html +0 -1878
- package/docs/module-playlists_.html +0 -108
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Railcontent-Services
|
|
3
3
|
*/
|
|
4
|
-
import { contentStatusCompleted } from './contentProgress.js'
|
|
5
|
-
|
|
6
4
|
import { globalConfig } from './config.js'
|
|
7
5
|
import { fetchJSONHandler } from '../lib/httpHelper.js'
|
|
8
6
|
|
|
@@ -35,12 +33,12 @@ let challengeIndexMetaDataPromise = null
|
|
|
35
33
|
* .catch(error => console.error(error));
|
|
36
34
|
*/
|
|
37
35
|
export async function fetchCompletedState(content_id) {
|
|
38
|
-
const url = `/content/user_progress/${globalConfig.
|
|
36
|
+
const url = `/content/user_progress/${globalConfig.sessionConfig.userId}?content_ids[]=${content_id}`
|
|
39
37
|
|
|
40
38
|
const headers = {
|
|
41
39
|
'Content-Type': 'application/json',
|
|
42
40
|
Accept: 'application/json',
|
|
43
|
-
'X-CSRF-TOKEN': globalConfig.
|
|
41
|
+
'X-CSRF-TOKEN': globalConfig.sessionConfig.token,
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
try {
|
|
@@ -69,12 +67,12 @@ export async function fetchCompletedState(content_id) {
|
|
|
69
67
|
* .catch(error => console.error(error));
|
|
70
68
|
*/
|
|
71
69
|
export async function fetchAllCompletedStates(contentIds) {
|
|
72
|
-
const url = `/content/user_progress/${globalConfig.
|
|
70
|
+
const url = `/content/user_progress/${globalConfig.sessionConfig.userId}?${contentIds.map((id) => `content_ids[]=${id}`).join('&')}`
|
|
73
71
|
|
|
74
72
|
const headers = {
|
|
75
73
|
'Content-Type': 'application/json',
|
|
76
74
|
Accept: 'application/json',
|
|
77
|
-
'X-CSRF-TOKEN': globalConfig.
|
|
75
|
+
'X-CSRF-TOKEN': globalConfig.sessionConfig.token,
|
|
78
76
|
}
|
|
79
77
|
|
|
80
78
|
try {
|
|
@@ -102,12 +100,12 @@ export async function fetchAllCompletedStates(contentIds) {
|
|
|
102
100
|
* .catch(error => console.error(error));
|
|
103
101
|
*/
|
|
104
102
|
export async function fetchSongsInProgress(brand) {
|
|
105
|
-
const url = `/content/in_progress/${globalConfig.
|
|
103
|
+
const url = `/content/in_progress/${globalConfig.sessionConfig.userId}?content_type=song&brand=${brand}`
|
|
106
104
|
|
|
107
105
|
const headers = {
|
|
108
106
|
'Content-Type': 'application/json',
|
|
109
107
|
Accept: 'application/json',
|
|
110
|
-
'X-CSRF-TOKEN': globalConfig.
|
|
108
|
+
'X-CSRF-TOKEN': globalConfig.sessionConfig.token,
|
|
111
109
|
}
|
|
112
110
|
|
|
113
111
|
try {
|
|
@@ -144,14 +142,14 @@ export async function fetchContentInProgress(type = 'all', brand, { page, limit
|
|
|
144
142
|
const pageString = page ? `&page=${page}` : ''
|
|
145
143
|
|
|
146
144
|
if (type === 'all') {
|
|
147
|
-
url = `/content/in_progress/${globalConfig.
|
|
145
|
+
url = `/content/in_progress/${globalConfig.sessionConfig.userId}?brand=${brand}${limitString}${pageString}`
|
|
148
146
|
} else {
|
|
149
|
-
url = `/content/in_progress/${globalConfig.
|
|
147
|
+
url = `/content/in_progress/${globalConfig.sessionConfig.userId}?content_type=${type}&brand=${brand}${limitString}${pageString}`
|
|
150
148
|
}
|
|
151
149
|
const headers = {
|
|
152
150
|
'Content-Type': 'application/json',
|
|
153
151
|
Accept: 'application/json',
|
|
154
|
-
'X-CSRF-TOKEN': globalConfig.
|
|
152
|
+
'X-CSRF-TOKEN': globalConfig.sessionConfig.token,
|
|
155
153
|
}
|
|
156
154
|
try {
|
|
157
155
|
const response = await fetchAbsolute(url, { headers })
|
|
@@ -187,14 +185,14 @@ export async function fetchCompletedContent(type = 'all', brand, { page, limit }
|
|
|
187
185
|
const pageString = page ? `&page=${page}` : ''
|
|
188
186
|
|
|
189
187
|
if (type === 'all') {
|
|
190
|
-
url = `/content/completed/${globalConfig.
|
|
188
|
+
url = `/content/completed/${globalConfig.sessionConfig.userId}?brand=${brand}${limitString}${pageString}`
|
|
191
189
|
} else {
|
|
192
|
-
url = `/content/completed/${globalConfig.
|
|
190
|
+
url = `/content/completed/${globalConfig.sessionConfig.userId}?content_type=${type}&brand=${brand}${limitString}${pageString}`
|
|
193
191
|
}
|
|
194
192
|
const headers = {
|
|
195
193
|
'Content-Type': 'application/json',
|
|
196
194
|
Accept: 'application/json',
|
|
197
|
-
'X-CSRF-TOKEN': globalConfig.
|
|
195
|
+
'X-CSRF-TOKEN': globalConfig.sessionConfig.token,
|
|
198
196
|
}
|
|
199
197
|
try {
|
|
200
198
|
const response = await fetchAbsolute(url, { headers })
|
|
@@ -222,11 +220,11 @@ export async function fetchCompletedContent(type = 'all', brand, { page, limit }
|
|
|
222
220
|
* .catch(error => console.error(error));
|
|
223
221
|
*/
|
|
224
222
|
export async function fetchContentPageUserData(contentId) {
|
|
225
|
-
let url = `/api/content/v1/${contentId}/user_data/${globalConfig.
|
|
223
|
+
let url = `/api/content/v1/${contentId}/user_data/${globalConfig.sessionConfig.userId}`
|
|
226
224
|
const headers = {
|
|
227
225
|
'Content-Type': 'application/json',
|
|
228
226
|
Accept: 'application/json',
|
|
229
|
-
'X-CSRF-TOKEN': globalConfig.
|
|
227
|
+
'X-CSRF-TOKEN': globalConfig.sessionConfig.token,
|
|
230
228
|
}
|
|
231
229
|
|
|
232
230
|
try {
|
|
@@ -251,10 +249,10 @@ export async function fetchContentPageUserData(contentId) {
|
|
|
251
249
|
* @returns {Promise<Object|null>} - Returns and Object with the id and type of the next piece of content if found, otherwise null.
|
|
252
250
|
*/
|
|
253
251
|
export async function fetchNextContentDataForParent(contentId) {
|
|
254
|
-
let url = `/content/${contentId}/next/${globalConfig.
|
|
252
|
+
let url = `/content/${contentId}/next/${globalConfig.sessionConfig.userId}`
|
|
255
253
|
const headers = {
|
|
256
254
|
'Content-Type': 'application/json',
|
|
257
|
-
'X-CSRF-TOKEN': globalConfig.
|
|
255
|
+
'X-CSRF-TOKEN': globalConfig.sessionConfig.token,
|
|
258
256
|
}
|
|
259
257
|
|
|
260
258
|
try {
|
|
@@ -1178,30 +1176,30 @@ export async function editComment(commentId, comment) {
|
|
|
1178
1176
|
|
|
1179
1177
|
export async function fetchUserPractices(currentVersion) {
|
|
1180
1178
|
const url = `/api/user/practices/v1/practices`
|
|
1181
|
-
const response =
|
|
1182
|
-
const { data, version } = response
|
|
1183
|
-
const userPractices = data
|
|
1179
|
+
const response = await fetchDataHandler(url, currentVersion)
|
|
1180
|
+
const { data, version } = response
|
|
1181
|
+
const userPractices = data
|
|
1184
1182
|
|
|
1185
1183
|
let formattedPractices = userPractices.reduce((acc, practice) => {
|
|
1186
1184
|
// Initialize the array if the day does not exist
|
|
1187
1185
|
if (!acc[practice.day]) {
|
|
1188
|
-
acc[practice.day] = []
|
|
1186
|
+
acc[practice.day] = []
|
|
1189
1187
|
}
|
|
1190
1188
|
|
|
1191
1189
|
// Push the practice entry into the array
|
|
1192
|
-
acc[practice.day].push({ id:practice.id, duration_seconds: practice.duration_seconds })
|
|
1190
|
+
acc[practice.day].push({ id: practice.id, duration_seconds: practice.duration_seconds })
|
|
1193
1191
|
|
|
1194
|
-
return acc
|
|
1195
|
-
}, {})
|
|
1192
|
+
return acc
|
|
1193
|
+
}, {})
|
|
1196
1194
|
|
|
1197
1195
|
let json = {
|
|
1198
1196
|
data: {
|
|
1199
|
-
practices: formattedPractices
|
|
1197
|
+
practices: formattedPractices,
|
|
1200
1198
|
},
|
|
1201
|
-
version: version
|
|
1202
|
-
}
|
|
1199
|
+
version: version,
|
|
1200
|
+
}
|
|
1203
1201
|
|
|
1204
|
-
return json
|
|
1202
|
+
return json
|
|
1205
1203
|
}
|
|
1206
1204
|
|
|
1207
1205
|
export async function logUserPractice(practiceDetails) {
|
|
@@ -1209,29 +1207,28 @@ export async function logUserPractice(practiceDetails) {
|
|
|
1209
1207
|
return await fetchHandler(url, 'POST', null, practiceDetails)
|
|
1210
1208
|
}
|
|
1211
1209
|
export async function fetchUserPracticeMeta(practiceIds) {
|
|
1212
|
-
if(practiceIds.length == 0)
|
|
1213
|
-
|
|
1214
|
-
return [];
|
|
1210
|
+
if (practiceIds.length == 0) {
|
|
1211
|
+
return []
|
|
1215
1212
|
}
|
|
1216
|
-
let idsString = ''
|
|
1213
|
+
let idsString = ''
|
|
1217
1214
|
if (practiceIds && practiceIds.length > 0) {
|
|
1218
|
-
idsString = '?'
|
|
1215
|
+
idsString = '?'
|
|
1219
1216
|
practiceIds.forEach((id, index) => {
|
|
1220
|
-
idsString += `practice_ids[]=${id}${index < practiceIds.length - 1 ? '&' : ''}
|
|
1221
|
-
})
|
|
1217
|
+
idsString += `practice_ids[]=${id}${index < practiceIds.length - 1 ? '&' : ''}`
|
|
1218
|
+
})
|
|
1222
1219
|
}
|
|
1223
1220
|
const url = `/api/user/practices/v1/practices${idsString}`
|
|
1224
1221
|
return await fetchHandler(url, 'GET', null)
|
|
1225
1222
|
}
|
|
1226
1223
|
|
|
1227
1224
|
function fetchAbsolute(url, params) {
|
|
1228
|
-
if (globalConfig.
|
|
1229
|
-
params.headers['Authorization'] = `Bearer ${globalConfig.
|
|
1225
|
+
if (globalConfig.sessionConfig.authToken) {
|
|
1226
|
+
params.headers['Authorization'] = `Bearer ${globalConfig.sessionConfig.authToken}`
|
|
1230
1227
|
}
|
|
1231
1228
|
|
|
1232
|
-
if (globalConfig.
|
|
1229
|
+
if (globalConfig.baseUrl) {
|
|
1233
1230
|
if (url.startsWith('/')) {
|
|
1234
|
-
return fetch(globalConfig.
|
|
1231
|
+
return fetch(globalConfig.baseUrl + url, params)
|
|
1235
1232
|
}
|
|
1236
1233
|
}
|
|
1237
1234
|
return fetch(url, params)
|
|
@@ -1239,9 +1236,10 @@ function fetchAbsolute(url, params) {
|
|
|
1239
1236
|
export async function fetchHandler(url, method = 'get', dataVersion = null, body = null) {
|
|
1240
1237
|
return fetchJSONHandler(
|
|
1241
1238
|
url,
|
|
1242
|
-
globalConfig.
|
|
1243
|
-
globalConfig.
|
|
1239
|
+
globalConfig.sessionConfig.token,
|
|
1240
|
+
globalConfig.baseUrl,
|
|
1244
1241
|
method,
|
|
1245
1242
|
dataVersion,
|
|
1246
|
-
body
|
|
1243
|
+
body
|
|
1244
|
+
)
|
|
1247
1245
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { globalConfig } from './config.js'
|
|
6
|
-
import { fetchJSONHandler} from '../lib/httpHelper.js'
|
|
6
|
+
import { fetchJSONHandler } from '../lib/httpHelper.js'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Exported functions that are excluded from index generation.
|
|
@@ -30,9 +30,9 @@ export async function fetchSimilarItems(content_id, brand, count = 10) {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
let data = {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
brand: brand,
|
|
34
|
+
content_ids: content_id,
|
|
35
|
+
num_similar: count,
|
|
36
36
|
}
|
|
37
37
|
const url = `/similar_items/`
|
|
38
38
|
try {
|
|
@@ -64,15 +64,18 @@ export async function rankCategories(brand, categories) {
|
|
|
64
64
|
return []
|
|
65
65
|
}
|
|
66
66
|
let data = {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
brand: brand,
|
|
68
|
+
user_id: globalConfig.sessionConfig.userId,
|
|
69
|
+
playlists: categories,
|
|
70
70
|
}
|
|
71
71
|
const url = `/rank_each_list/`
|
|
72
72
|
try {
|
|
73
73
|
const response = await fetchHandler(url, 'POST', data)
|
|
74
74
|
let rankedCategories = {}
|
|
75
|
-
response['ranked_playlists'].forEach(
|
|
75
|
+
response['ranked_playlists'].forEach(
|
|
76
|
+
(category) =>
|
|
77
|
+
(rankedCategories[category['playlist_id']] = categories[category['playlist_id']])
|
|
78
|
+
)
|
|
76
79
|
return rankedCategories
|
|
77
80
|
} catch (error) {
|
|
78
81
|
console.error('Fetch error:', error)
|
|
@@ -96,9 +99,9 @@ export async function rankItems(brand, content_ids) {
|
|
|
96
99
|
return []
|
|
97
100
|
}
|
|
98
101
|
let data = {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
+
brand: brand,
|
|
103
|
+
user_id: globalConfig.sessionConfig.userId,
|
|
104
|
+
content_ids: content_ids,
|
|
102
105
|
}
|
|
103
106
|
const url = `/rank_items/`
|
|
104
107
|
try {
|
|
@@ -110,14 +113,11 @@ export async function rankItems(brand, content_ids) {
|
|
|
110
113
|
}
|
|
111
114
|
}
|
|
112
115
|
|
|
113
|
-
export async function recommendations(brand, {
|
|
114
|
-
page = 1,
|
|
115
|
-
limit = 10,
|
|
116
|
-
} = {}) {
|
|
116
|
+
export async function recommendations(brand, { page = 1, limit = 10 } = {}) {
|
|
117
117
|
let data = {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
brand: brand,
|
|
119
|
+
user_id: globalConfig.sessionConfig.userId,
|
|
120
|
+
num_recommendations: limit,
|
|
121
121
|
}
|
|
122
122
|
const url = `/recommendations/`
|
|
123
123
|
try {
|
|
@@ -137,5 +137,5 @@ async function fetchHandler(url, method = 'get', body = null) {
|
|
|
137
137
|
method,
|
|
138
138
|
null,
|
|
139
139
|
body
|
|
140
|
-
|
|
140
|
+
)
|
|
141
141
|
}
|
package/src/services/sanity.js
CHANGED
|
@@ -1273,6 +1273,7 @@ export async function fetchLessonContent(railContentId) {
|
|
|
1273
1273
|
chapter_timecode,
|
|
1274
1274
|
"chapter_thumbnail_url": chapter_thumbnail_url.asset->url
|
|
1275
1275
|
},
|
|
1276
|
+
artist->,
|
|
1276
1277
|
"instructors":instructor[]->name,
|
|
1277
1278
|
"instructor": instructor[]->{
|
|
1278
1279
|
"id":railcontent_id,
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {object} SanityConfig - Configuration for Sanity API.
|
|
3
|
+
*
|
|
4
|
+
* @property {string} token - The API token for authenticating with Sanity.
|
|
5
|
+
* @property {string} projectId - The project ID in Sanity.
|
|
6
|
+
* @property {string} dataset - The dataset name in Sanity.
|
|
7
|
+
* @property {string} version - The API version to use.
|
|
8
|
+
* @property {boolean} [debug=false] - Optional flag to enable debug mode.
|
|
9
|
+
* @property {boolean} [useCachedAPI=true] - Optional flag to enable or disable the use of the cached API.
|
|
10
|
+
* @property {boolean} [useDummyRailContentMethods=false] - Optional flag to use test harness for railcontent methods. Should only be used by jest tests.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated use `config.session` and `config.baseUrl` instead. Will be removed in future versions.
|
|
15
|
+
*
|
|
16
|
+
* @typedef {object} RailcontentConfig - Configuration for user services.
|
|
17
|
+
*
|
|
18
|
+
* @property {string} token - The token for authenticating user-specific requests.
|
|
19
|
+
* @property {string} userId - The user ID for fetching user-specific data.
|
|
20
|
+
* @property {string} authToken - The bearer authorization token.
|
|
21
|
+
* @property {string} baseUrl - The url for the environment.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @typedef {object} SessionConfig - Configuration for user session.
|
|
26
|
+
*
|
|
27
|
+
* @property {string} token - The token for authenticating user-specific requests.
|
|
28
|
+
* @property {string} userId - The user ID for fetching user-specific data.
|
|
29
|
+
* @property {string} authToken - The bearer authorization token.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @typedef {object} RecommendationsConfig - Configuration for recommendation services.
|
|
34
|
+
*
|
|
35
|
+
* @property {string} token - The token for authenticating recommendation requests.
|
|
36
|
+
* @property {string} baseUrl - The url for the recommendation server.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @typedef {object} Config
|
|
41
|
+
*
|
|
42
|
+
* @property {SanityConfig} sanityConfig
|
|
43
|
+
* @property {RailcontentConfig} railcontentConfig - DEPRECATED use sessionConfig and baseUrl instead.
|
|
44
|
+
* @property {SessionConfig} sessionConfig
|
|
45
|
+
* @property {RecommendationsConfig} recommendationsConfig
|
|
46
|
+
* @property {string} baseUrl - The url for the environment.
|
|
47
|
+
* @property {Object} localStorage - Cache to use for localStorage
|
|
48
|
+
* @property {boolean} isMA - Variable that tells if the library is used by MA or FEW
|
|
49
|
+
* @property {string} localTimezoneString - The local timezone string in format: America/Vancouver
|
|
50
|
+
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @module
|
|
2
|
+
* @module Sessions
|
|
3
3
|
*/
|
|
4
4
|
import { globalConfig } from '../config.js'
|
|
5
5
|
import './types.js'
|
|
@@ -11,8 +11,6 @@ import './types.js'
|
|
|
11
11
|
*/
|
|
12
12
|
const excludeFromGeneratedIndex = []
|
|
13
13
|
|
|
14
|
-
const baseUrl = `${globalConfig.railcontentConfig.baseUrl}/api/user-management-system`
|
|
15
|
-
|
|
16
14
|
/**
|
|
17
15
|
* Authenticates the User.
|
|
18
16
|
*
|
|
@@ -30,6 +28,7 @@ const baseUrl = `${globalConfig.railcontentConfig.baseUrl}/api/user-management-s
|
|
|
30
28
|
* .catch(error => console.error(error));
|
|
31
29
|
*/
|
|
32
30
|
export async function login(email, password, deviceName, deviceToken, platform) {
|
|
31
|
+
const baseUrl = `${globalConfig.baseUrl}/api/user-management-system`
|
|
33
32
|
return fetch(`${baseUrl}/v1/sessions`, {
|
|
34
33
|
method: 'POST',
|
|
35
34
|
headers: {
|
|
@@ -57,10 +56,11 @@ export async function login(email, password, deviceName, deviceToken, platform)
|
|
|
57
56
|
* .catch(error => console.error(error));
|
|
58
57
|
*/
|
|
59
58
|
export async function logout() {
|
|
59
|
+
const baseUrl = `${globalConfig.baseUrl}/api/user-management-system`
|
|
60
60
|
await fetch(`${baseUrl}/v1/sessions`, {
|
|
61
61
|
method: 'DELETE',
|
|
62
62
|
headers: {
|
|
63
|
-
Authorization: `Bearer ${globalConfig.
|
|
63
|
+
Authorization: `Bearer ${globalConfig.sessionConfig.authToken}`,
|
|
64
64
|
'Content-Type': 'application/json',
|
|
65
65
|
},
|
|
66
66
|
})
|
|
File without changes
|
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
|
@@ -14,6 +14,7 @@ export async function initializeTestService(useLive = false, isAdmin = false) {
|
|
|
14
14
|
token = data['token']
|
|
15
15
|
userId = data['userId']
|
|
16
16
|
}
|
|
17
|
+
|
|
17
18
|
const config = {
|
|
18
19
|
sanityConfig: {
|
|
19
20
|
token: process.env.SANITY_API_TOKEN,
|
|
@@ -24,17 +25,18 @@ export async function initializeTestService(useLive = false, isAdmin = false) {
|
|
|
24
25
|
debug: process.env.DEBUG === 'true' || false,
|
|
25
26
|
useDummyRailContentMethods: true,
|
|
26
27
|
},
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
sessionConfig: {
|
|
29
|
+
token: token,
|
|
29
30
|
userId: userId,
|
|
30
31
|
authToken: token,
|
|
31
32
|
},
|
|
33
|
+
baseUrl: process.env.RAILCONTENT_BASE_URL,
|
|
32
34
|
localStorage: new LocalStorageMock(),
|
|
33
35
|
isMA: true,
|
|
34
36
|
recommendationsConfig: {
|
|
35
37
|
token: process.env.HUGGINGFACE_TOKEN,
|
|
36
|
-
baseUrl: process.env.HUGGINGFACE_URL
|
|
37
|
-
}
|
|
38
|
+
baseUrl: process.env.HUGGINGFACE_URL,
|
|
39
|
+
},
|
|
38
40
|
}
|
|
39
41
|
initializeService(config)
|
|
40
42
|
|
|
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
|
|
@@ -148,9 +148,19 @@ describe('Sanity Queries', function() {
|
|
|
148
148
|
})
|
|
149
149
|
|
|
150
150
|
test('fetchLessonContent', async () => {
|
|
151
|
-
const id =
|
|
151
|
+
const id = 392820
|
|
152
|
+
const response = await fetchLessonContent(id)
|
|
153
|
+
expect(response.id).toBe(id)
|
|
154
|
+
expect(response.video.type).toBeDefined()
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
test('fetchLessonContent-PlayAlong-containts-array-of-videos', async () => {
|
|
158
|
+
const id = 9184
|
|
152
159
|
const response = await fetchLessonContent(id)
|
|
153
160
|
expect(response.id).toBe(id)
|
|
161
|
+
expect(response.video.length).toBeGreaterThanOrEqual(1)
|
|
162
|
+
const firstElement = response.video.find(() => true)
|
|
163
|
+
expect(firstElement.version_name).toBeDefined()
|
|
154
164
|
})
|
|
155
165
|
|
|
156
166
|
test('fetchAllSongsInProgress', async () => {
|
|
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
|