musora-content-services 1.0.153 → 1.0.155
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/.github/workflows/node.js.yml +0 -0
- package/CHANGELOG.md +4 -0
- package/babel.config.js +0 -0
- 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/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/jest.config.js +0 -0
- package/jsdoc.json +0 -0
- package/link_mcs.sh +0 -0
- package/package.json +1 -1
- package/src/index.d.ts +4 -4
- package/src/index.js +4 -4
- package/src/services/contentProgress.js +21 -23
- package/src/services/dataContext.js +2 -2
- package/src/services/railcontent.js +0 -5
- package/test/contentProgress.test.js +23 -1
|
File without changes
|
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.0.155](https://github.com/railroadmedia/musora-content-services/compare/v1.0.154...v1.0.155) (2024-11-05)
|
|
6
|
+
|
|
7
|
+
### [1.0.154](https://github.com/railroadmedia/musora-content-services/compare/v1.0.153...v1.0.154) (2024-11-05)
|
|
8
|
+
|
|
5
9
|
### [1.0.153](https://github.com/railroadmedia/musora-content-services/compare/v1.0.152...v1.0.153) (2024-11-05)
|
|
6
10
|
|
|
7
11
|
### [1.0.152](https://github.com/railroadmedia/musora-content-services/compare/v1.0.142...v1.0.152) (2024-11-05)
|
package/babel.config.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/docs/scripts/collapse.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/docs/scripts/nav.js
CHANGED
|
File without changes
|
package/docs/scripts/polyfill.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/docs/scripts/search.js
CHANGED
|
File without changes
|
package/docs/styles/jsdoc.css
CHANGED
|
File without changes
|
package/docs/styles/prettify.css
CHANGED
|
File without changes
|
package/jest.config.js
CHANGED
|
File without changes
|
package/jsdoc.json
CHANGED
|
File without changes
|
package/link_mcs.sh
CHANGED
|
File without changes
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -14,9 +14,10 @@ import {
|
|
|
14
14
|
import {
|
|
15
15
|
contentStatusCompleted,
|
|
16
16
|
contentStatusReset,
|
|
17
|
-
contentStatusStarted,
|
|
18
17
|
getProgressPercentage,
|
|
18
|
+
getProgressPercentageByIds,
|
|
19
19
|
getProgressState,
|
|
20
|
+
getProgressStateByIds,
|
|
20
21
|
getResumeTimeSeconds,
|
|
21
22
|
recordWatchSession
|
|
22
23
|
} from './services/contentProgress.js';
|
|
@@ -57,7 +58,6 @@ import {
|
|
|
57
58
|
postContentCompleted,
|
|
58
59
|
postContentLiked,
|
|
59
60
|
postContentReset,
|
|
60
|
-
postContentStarted,
|
|
61
61
|
postContentUnliked,
|
|
62
62
|
postRecordWatchSession,
|
|
63
63
|
updatePlaylist,
|
|
@@ -118,7 +118,6 @@ declare module 'musora-content-services' {
|
|
|
118
118
|
export {
|
|
119
119
|
contentStatusCompleted,
|
|
120
120
|
contentStatusReset,
|
|
121
|
-
contentStatusStarted,
|
|
122
121
|
createPlaylist,
|
|
123
122
|
deletePlaylist,
|
|
124
123
|
deletePlaylistItem,
|
|
@@ -190,7 +189,9 @@ declare module 'musora-content-services' {
|
|
|
190
189
|
fetchUserPlaylists,
|
|
191
190
|
fetchWorkouts,
|
|
192
191
|
getProgressPercentage,
|
|
192
|
+
getProgressPercentageByIds,
|
|
193
193
|
getProgressState,
|
|
194
|
+
getProgressStateByIds,
|
|
194
195
|
getResumeTimeSeconds,
|
|
195
196
|
getSortOrder,
|
|
196
197
|
globalConfig,
|
|
@@ -208,7 +209,6 @@ declare module 'musora-content-services' {
|
|
|
208
209
|
postContentCompleted,
|
|
209
210
|
postContentLiked,
|
|
210
211
|
postContentReset,
|
|
211
|
-
postContentStarted,
|
|
212
212
|
postContentUnliked,
|
|
213
213
|
postRecordWatchSession,
|
|
214
214
|
recordWatchSession,
|
package/src/index.js
CHANGED
|
@@ -14,9 +14,10 @@ import {
|
|
|
14
14
|
import {
|
|
15
15
|
contentStatusCompleted,
|
|
16
16
|
contentStatusReset,
|
|
17
|
-
contentStatusStarted,
|
|
18
17
|
getProgressPercentage,
|
|
18
|
+
getProgressPercentageByIds,
|
|
19
19
|
getProgressState,
|
|
20
|
+
getProgressStateByIds,
|
|
20
21
|
getResumeTimeSeconds,
|
|
21
22
|
recordWatchSession
|
|
22
23
|
} from './services/contentProgress.js';
|
|
@@ -57,7 +58,6 @@ import {
|
|
|
57
58
|
postContentCompleted,
|
|
58
59
|
postContentLiked,
|
|
59
60
|
postContentReset,
|
|
60
|
-
postContentStarted,
|
|
61
61
|
postContentUnliked,
|
|
62
62
|
postRecordWatchSession,
|
|
63
63
|
updatePlaylist,
|
|
@@ -117,7 +117,6 @@ import {
|
|
|
117
117
|
export {
|
|
118
118
|
contentStatusCompleted,
|
|
119
119
|
contentStatusReset,
|
|
120
|
-
contentStatusStarted,
|
|
121
120
|
createPlaylist,
|
|
122
121
|
deletePlaylist,
|
|
123
122
|
deletePlaylistItem,
|
|
@@ -189,7 +188,9 @@ export {
|
|
|
189
188
|
fetchUserPlaylists,
|
|
190
189
|
fetchWorkouts,
|
|
191
190
|
getProgressPercentage,
|
|
191
|
+
getProgressPercentageByIds,
|
|
192
192
|
getProgressState,
|
|
193
|
+
getProgressStateByIds,
|
|
193
194
|
getResumeTimeSeconds,
|
|
194
195
|
getSortOrder,
|
|
195
196
|
globalConfig,
|
|
@@ -207,7 +208,6 @@ export {
|
|
|
207
208
|
postContentCompleted,
|
|
208
209
|
postContentLiked,
|
|
209
210
|
postContentReset,
|
|
210
|
-
postContentStarted,
|
|
211
211
|
postContentUnliked,
|
|
212
212
|
postRecordWatchSession,
|
|
213
213
|
recordWatchSession,
|
|
@@ -13,42 +13,40 @@ const STATE_COMPLETED = 'completed';
|
|
|
13
13
|
const DATA_KEY_STATUS = 's';
|
|
14
14
|
const DATA_KEY_PROGRESS = 'p';
|
|
15
15
|
const DATA_KEY_RESUME_TIME = 't';
|
|
16
|
-
export let dataContext = new DataContext(ContentProgressVersionKey, fetchContentProgress
|
|
16
|
+
export let dataContext = new DataContext(ContentProgressVersionKey, fetchContentProgress);
|
|
17
17
|
|
|
18
18
|
export async function getProgressPercentage(contentId) {
|
|
19
19
|
let data = await dataContext.getData();
|
|
20
20
|
return data[contentId]?.[DATA_KEY_PROGRESS] ?? 0;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export async function
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
export async function getProgressPercentageByIds(contentIds) {
|
|
24
|
+
const data = await dataContext.getData();
|
|
25
|
+
let progress = {};
|
|
26
|
+
|
|
27
|
+
contentIds?.forEach(id => progress[id] = data[id]?.[DATA_KEY_PROGRESS] ?? 0);
|
|
28
|
+
|
|
29
|
+
return progress;
|
|
26
30
|
}
|
|
27
31
|
|
|
28
|
-
export async function
|
|
32
|
+
export async function getProgressState(contentId) {
|
|
29
33
|
let data = await dataContext.getData();
|
|
30
|
-
return data[contentId]?.[
|
|
34
|
+
return data[contentId]?.[DATA_KEY_STATUS] ?? "";
|
|
31
35
|
}
|
|
32
36
|
|
|
33
|
-
export async function
|
|
34
|
-
await dataContext.
|
|
35
|
-
|
|
36
|
-
let data = localContext.data[contentId] ?? [];
|
|
37
|
-
let progress = data?.[DATA_KEY_PROGRESS] ?? 0;
|
|
38
|
-
let status = data?.[DATA_KEY_STATUS] ?? 0;
|
|
37
|
+
export async function getProgressStateByIds(contentIds) {
|
|
38
|
+
const data = await dataContext.getData();
|
|
39
|
+
let progress = {};
|
|
39
40
|
|
|
40
|
-
|
|
41
|
-
status = STATE_STARTED;
|
|
42
|
-
}
|
|
41
|
+
contentIds?.forEach(id => progress[id] = data[id]?.[DATA_KEY_STATUS] ?? "");
|
|
43
42
|
|
|
44
|
-
|
|
45
|
-
localContext.data[contentId] = data;
|
|
46
|
-
},
|
|
47
|
-
async function () {
|
|
48
|
-
return postContentStarted(contentId);
|
|
49
|
-
});
|
|
43
|
+
return progress;
|
|
50
44
|
}
|
|
51
45
|
|
|
46
|
+
export async function getResumeTimeSeconds(contentId) {
|
|
47
|
+
let data = await dataContext.getData();
|
|
48
|
+
return data[contentId]?.[DATA_KEY_RESUME_TIME] ?? 0;
|
|
49
|
+
}
|
|
52
50
|
|
|
53
51
|
export async function contentStatusCompleted(contentId) {
|
|
54
52
|
await dataContext.update(
|
|
@@ -68,8 +66,8 @@ function completeStatusInLocalContext(contentId, localContext, hierarchy) {
|
|
|
68
66
|
localContext.data[contentId] = data;
|
|
69
67
|
|
|
70
68
|
let children = hierarchy.children[contentId] ?? [];
|
|
71
|
-
for(let i = 0; i < children.length; i++) {
|
|
72
|
-
let childId
|
|
69
|
+
for (let i = 0; i < children.length; i++) {
|
|
70
|
+
let childId = children[i];
|
|
73
71
|
completeStatusInLocalContext(childId, localContext, hierarchy);
|
|
74
72
|
}
|
|
75
73
|
}
|
|
@@ -19,8 +19,8 @@ export class DataContext {
|
|
|
19
19
|
constructor(dataVersionKey, fetchDataFunction) {
|
|
20
20
|
this.dataVersionKey = dataVersionKey;
|
|
21
21
|
this.fetchDataFunction = fetchDataFunction;
|
|
22
|
-
this.localStorageKey = `dataContext_${this.dataVersionKey}`;
|
|
23
|
-
this.localStorageLastUpdatedKey = `dataContext_${this.dataVersionKey}_lastUpdated`;
|
|
22
|
+
this.localStorageKey = `dataContext_${this.dataVersionKey.toString()}`;
|
|
23
|
+
this.localStorageLastUpdatedKey = `dataContext_${this.dataVersionKey.toString()}_lastUpdated`;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
async getData() {
|
|
@@ -823,11 +823,6 @@ export async function fetchPlaylistItem(payload) {
|
|
|
823
823
|
return await fetchHandler(url);
|
|
824
824
|
}
|
|
825
825
|
|
|
826
|
-
export async function postContentStarted(contentId) {
|
|
827
|
-
let url = `/content/${contentId}/started`;
|
|
828
|
-
return postDataHandler(url);
|
|
829
|
-
}
|
|
830
|
-
|
|
831
826
|
export async function postContentCompleted(contentId) {
|
|
832
827
|
let url = `/content/${contentId}/completed`;
|
|
833
828
|
return postDataHandler(url);
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
getProgressPercentage,
|
|
3
|
+
dataContext,
|
|
4
|
+
recordWatchSession,
|
|
5
|
+
getProgressPercentageByIds, getProgressState, getProgressStateByIds
|
|
6
|
+
} from "../src/services/contentProgress";
|
|
2
7
|
import {initializeTestService} from "./sanityQueryService.test";
|
|
3
8
|
|
|
4
9
|
const railContentModule = require('../src/services/railcontent.js')
|
|
@@ -20,11 +25,28 @@ describe('contentProgressDataContext', function () {
|
|
|
20
25
|
expect(result).toBe(6);
|
|
21
26
|
});
|
|
22
27
|
|
|
28
|
+
test('getProgressPercentageByIds', async () => {
|
|
29
|
+
let result = await getProgressPercentageByIds([234191, 111111]);
|
|
30
|
+
expect(result[234191]).toBe(6);
|
|
31
|
+
expect(result[111111]).toBe(0);
|
|
32
|
+
});
|
|
33
|
+
|
|
23
34
|
test('getProgressPercentage_notExists', async () => {
|
|
24
35
|
let result = await getProgressPercentage(111111);
|
|
25
36
|
expect(result).toBe(0);
|
|
26
37
|
});
|
|
27
38
|
|
|
39
|
+
test('getProgressState', async () => {
|
|
40
|
+
let result = await getProgressState(234191);
|
|
41
|
+
expect(result).toBe("started");
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test('getProgressStateByIds', async () => {
|
|
45
|
+
let result = await getProgressStateByIds([234191, 120402]);
|
|
46
|
+
expect(result[234191]).toBe("started");
|
|
47
|
+
expect(result[120402]).toBe("");
|
|
48
|
+
});
|
|
49
|
+
|
|
28
50
|
test('progressBubbling', async () => {
|
|
29
51
|
let mock2 = jest.spyOn(railContentModule, 'postRecordWatchSession');
|
|
30
52
|
let serverVersion = 2;
|