musora-content-services 1.2.1 → 1.2.3
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/.yarnrc.yml +1 -0
- package/CHANGELOG.md +4 -0
- package/package.json +2 -2
- package/src/filterBuilder.js +0 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +2 -0
- package/src/services/railcontent.js +16 -0
- package/test/contentProgress.test.js +1 -1
- package/test/sanityQueryService.test.js +0 -0
- package/tools/{generate-index.js → generate-index.cjs} +9 -3
package/.yarnrc.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
nodeLinker: node-modules
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.2.3](https://github.com/railroadmedia/musora-content-services/compare/v1.2.1...v1.2.3) (2025-01-17)
|
|
6
|
+
|
|
7
|
+
### [1.2.2](https://github.com/railroadmedia/musora-content-services/compare/v1.2.1...v1.2.2) (2025-01-16)
|
|
8
|
+
|
|
5
9
|
### [1.2.1](https://github.com/railroadmedia/musora-content-services/compare/v1.2.0...v1.2.1) (2025-01-16)
|
|
6
10
|
|
|
7
11
|
## [1.2.0](https://github.com/railroadmedia/musora-content-services/compare/v1.0.233...v1.2.0) (2025-01-14)
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "musora-content-services",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "A package for Musoras content services ",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build-index": "node tools/generate-index.
|
|
8
|
+
"build-index": "node tools/generate-index.cjs",
|
|
9
9
|
"release": "standard-version",
|
|
10
10
|
"doc": "jsdoc -c jsdoc.json --verbose",
|
|
11
11
|
"test": "jest --setupFiles dotenv/config"
|
package/src/filterBuilder.js
CHANGED
|
File without changes
|
package/src/index.d.ts
CHANGED
|
@@ -79,6 +79,7 @@ import {
|
|
|
79
79
|
postContentUnliked,
|
|
80
80
|
postRecordWatchSession,
|
|
81
81
|
reportPlaylist,
|
|
82
|
+
setStudentViewForUser,
|
|
82
83
|
unpinPlaylist,
|
|
83
84
|
updatePlaylist,
|
|
84
85
|
updatePlaylistItem
|
|
@@ -268,6 +269,7 @@ declare module 'musora-content-services' {
|
|
|
268
269
|
recordWatchSession,
|
|
269
270
|
reportPlaylist,
|
|
270
271
|
reset,
|
|
272
|
+
setStudentViewForUser,
|
|
271
273
|
unlikeContent,
|
|
272
274
|
unpinPlaylist,
|
|
273
275
|
updatePlaylist,
|
package/src/index.js
CHANGED
|
@@ -79,6 +79,7 @@ import {
|
|
|
79
79
|
postContentUnliked,
|
|
80
80
|
postRecordWatchSession,
|
|
81
81
|
reportPlaylist,
|
|
82
|
+
setStudentViewForUser,
|
|
82
83
|
unpinPlaylist,
|
|
83
84
|
updatePlaylist,
|
|
84
85
|
updatePlaylistItem
|
|
@@ -267,6 +268,7 @@ export {
|
|
|
267
268
|
recordWatchSession,
|
|
268
269
|
reportPlaylist,
|
|
269
270
|
reset,
|
|
271
|
+
setStudentViewForUser,
|
|
270
272
|
unlikeContent,
|
|
271
273
|
unpinPlaylist,
|
|
272
274
|
updatePlaylist,
|
|
@@ -289,6 +289,9 @@ async function postDataHandler(url, data) {
|
|
|
289
289
|
return fetchHandler(url, 'post', null, data);
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
+
async function patchDataHandler(url, data) {
|
|
293
|
+
return fetchHandler(url, 'patch', null, data);}
|
|
294
|
+
|
|
292
295
|
export async function fetchHandler(url, method = "get", dataVersion = null, body = null) {
|
|
293
296
|
let headers = {
|
|
294
297
|
'Content-Type': 'application/json',
|
|
@@ -1178,6 +1181,19 @@ export async function playback(playlistId) {
|
|
|
1178
1181
|
return await fetchHandler(url, "GET");
|
|
1179
1182
|
}
|
|
1180
1183
|
|
|
1184
|
+
/**
|
|
1185
|
+
* Set a user's StudentView Flag
|
|
1186
|
+
*
|
|
1187
|
+
* @param {int|string} userId - id of the user (must be currently authenticated)
|
|
1188
|
+
* @param {bool} enable - truthsy value to enable student view
|
|
1189
|
+
* @returns {Promise<any|null>}
|
|
1190
|
+
*/
|
|
1191
|
+
export async function setStudentViewForUser(userId, enable) {
|
|
1192
|
+
let url = `/user-management-system/user/update/${userId}`;
|
|
1193
|
+
let data = {'use_student_view' : enable ? 1 : 0};
|
|
1194
|
+
return await patchDataHandler(url, data);
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1181
1197
|
function fetchAbsolute(url, params) {
|
|
1182
1198
|
if (globalConfig.railcontentConfig.authToken) {
|
|
1183
1199
|
params.headers['Authorization'] = `Bearer ${globalConfig.railcontentConfig.authToken}`;
|
|
@@ -129,7 +129,7 @@ describe('contentProgressDataContext', function () {
|
|
|
129
129
|
let progress241247 = await getProgressPercentage(241247);
|
|
130
130
|
expect(progress241247).toBe(1);
|
|
131
131
|
|
|
132
|
-
});
|
|
132
|
+
}, 50000);
|
|
133
133
|
|
|
134
134
|
// test('completedProgressNotOverwritten', async () => {
|
|
135
135
|
// const contentId = 241262;
|
|
File without changes
|
|
@@ -17,10 +17,16 @@ const fileExports = {};
|
|
|
17
17
|
function extractExportedFunctions(filePath) {
|
|
18
18
|
const fileContent = fs.readFileSync(filePath, 'utf-8');
|
|
19
19
|
|
|
20
|
-
const
|
|
20
|
+
const exportFunctionRegex = /export\s+(async\s+)?function\s+(\w+)/g;
|
|
21
|
+
const exportVariableRegex = /export\s+(let|const|var)\s+(globalConfig)\s+/g;
|
|
21
22
|
const moduleExportsRegex = /module\.exports\s*=\s*{\s*([\s\S]+?)\s*};/g;
|
|
22
23
|
|
|
23
|
-
let matches = [...fileContent.matchAll(
|
|
24
|
+
let matches = [...fileContent.matchAll(exportFunctionRegex)].map(match => match[2]);
|
|
25
|
+
|
|
26
|
+
// Match `globalConfig` variable
|
|
27
|
+
const variableMatches = [...fileContent.matchAll(exportVariableRegex)].map(match => match[2]);
|
|
28
|
+
matches = matches.concat(variableMatches);
|
|
29
|
+
|
|
24
30
|
|
|
25
31
|
const moduleExportsMatch = moduleExportsRegex.exec(fileContent);
|
|
26
32
|
if (moduleExportsMatch) {
|
|
@@ -102,4 +108,4 @@ dtsContent += '}\n';
|
|
|
102
108
|
const outputDtsPath = path.join(__dirname, '../src/index.d.ts');
|
|
103
109
|
fs.writeFileSync(outputDtsPath, dtsContent);
|
|
104
110
|
|
|
105
|
-
console.log('index.d.ts generated successfully!');
|
|
111
|
+
console.log('index.d.ts generated successfully!');
|