musora-content-services 1.0.153 → 1.0.154
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 +2 -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 -0
- package/src/index.js +4 -0
- package/src/services/contentProgress.js +22 -4
- package/src/services/dataContext.js +2 -2
- package/test/contentProgress.test.js +23 -1
|
File without changes
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
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.154](https://github.com/railroadmedia/musora-content-services/compare/v1.0.153...v1.0.154) (2024-11-05)
|
|
6
|
+
|
|
5
7
|
### [1.0.153](https://github.com/railroadmedia/musora-content-services/compare/v1.0.152...v1.0.153) (2024-11-05)
|
|
6
8
|
|
|
7
9
|
### [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
|
@@ -16,7 +16,9 @@ import {
|
|
|
16
16
|
contentStatusReset,
|
|
17
17
|
contentStatusStarted,
|
|
18
18
|
getProgressPercentage,
|
|
19
|
+
getProgressPercentageByIds,
|
|
19
20
|
getProgressState,
|
|
21
|
+
getProgressStateByIds,
|
|
20
22
|
getResumeTimeSeconds,
|
|
21
23
|
recordWatchSession
|
|
22
24
|
} from './services/contentProgress.js';
|
|
@@ -190,7 +192,9 @@ declare module 'musora-content-services' {
|
|
|
190
192
|
fetchUserPlaylists,
|
|
191
193
|
fetchWorkouts,
|
|
192
194
|
getProgressPercentage,
|
|
195
|
+
getProgressPercentageByIds,
|
|
193
196
|
getProgressState,
|
|
197
|
+
getProgressStateByIds,
|
|
194
198
|
getResumeTimeSeconds,
|
|
195
199
|
getSortOrder,
|
|
196
200
|
globalConfig,
|
package/src/index.js
CHANGED
|
@@ -16,7 +16,9 @@ import {
|
|
|
16
16
|
contentStatusReset,
|
|
17
17
|
contentStatusStarted,
|
|
18
18
|
getProgressPercentage,
|
|
19
|
+
getProgressPercentageByIds,
|
|
19
20
|
getProgressState,
|
|
21
|
+
getProgressStateByIds,
|
|
20
22
|
getResumeTimeSeconds,
|
|
21
23
|
recordWatchSession
|
|
22
24
|
} from './services/contentProgress.js';
|
|
@@ -189,7 +191,9 @@ export {
|
|
|
189
191
|
fetchUserPlaylists,
|
|
190
192
|
fetchWorkouts,
|
|
191
193
|
getProgressPercentage,
|
|
194
|
+
getProgressPercentageByIds,
|
|
192
195
|
getProgressState,
|
|
196
|
+
getProgressStateByIds,
|
|
193
197
|
getResumeTimeSeconds,
|
|
194
198
|
getSortOrder,
|
|
195
199
|
globalConfig,
|
|
@@ -13,16 +13,34 @@ 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 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;
|
|
30
|
+
}
|
|
31
|
+
|
|
23
32
|
export async function getProgressState(contentId) {
|
|
24
33
|
let data = await dataContext.getData();
|
|
25
|
-
return data[contentId]?.[DATA_KEY_STATUS] ??
|
|
34
|
+
return data[contentId]?.[DATA_KEY_STATUS] ?? "";
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export async function getProgressStateByIds(contentIds) {
|
|
38
|
+
const data = await dataContext.getData();
|
|
39
|
+
let progress = {};
|
|
40
|
+
|
|
41
|
+
contentIds?.forEach(id => progress[id] = data[id]?.[DATA_KEY_STATUS] ?? "");
|
|
42
|
+
|
|
43
|
+
return progress;
|
|
26
44
|
}
|
|
27
45
|
|
|
28
46
|
export async function getResumeTimeSeconds(contentId) {
|
|
@@ -68,8 +86,8 @@ function completeStatusInLocalContext(contentId, localContext, hierarchy) {
|
|
|
68
86
|
localContext.data[contentId] = data;
|
|
69
87
|
|
|
70
88
|
let children = hierarchy.children[contentId] ?? [];
|
|
71
|
-
for(let i = 0; i < children.length; i++) {
|
|
72
|
-
let childId
|
|
89
|
+
for (let i = 0; i < children.length; i++) {
|
|
90
|
+
let childId = children[i];
|
|
73
91
|
completeStatusInLocalContext(childId, localContext, hierarchy);
|
|
74
92
|
}
|
|
75
93
|
}
|
|
@@ -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() {
|
|
@@ -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;
|