musora-content-services 1.3.8 → 1.3.10

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.
Files changed (40) hide show
  1. package/.prettierignore +0 -0
  2. package/.prettierrc +0 -0
  3. package/.yarnrc.yml +1 -0
  4. package/CHANGELOG.md +4 -0
  5. package/babel.config.cjs +0 -0
  6. package/docs/config.js.html +0 -0
  7. package/docs/global.html +809 -0
  8. package/docs/index.html +0 -0
  9. package/docs/module-Config.html +0 -0
  10. package/docs/module-Content-Services.html +763 -0
  11. package/docs/module-Railcontent-Services.html +0 -0
  12. package/docs/module-Sanity-Services.html +0 -0
  13. package/docs/railcontent.js.html +0 -0
  14. package/docs/sanity.js.html +0 -0
  15. package/jest.config.js +0 -0
  16. package/jsdoc.json +0 -0
  17. package/package.json +1 -1
  18. package/src/contentMetaData.js +0 -0
  19. package/src/index.d.ts +5 -0
  20. package/src/index.js +5 -0
  21. package/src/services/config.js +0 -0
  22. package/src/services/contentLikes.js +0 -0
  23. package/src/services/contentProgress.js +0 -0
  24. package/src/services/dataContext.js +17 -17
  25. package/src/services/lastUpdated.js +0 -0
  26. package/src/services/railcontent.js +0 -0
  27. package/src/services/sanity.js +13 -2
  28. package/src/services/userPermissions.js +0 -0
  29. package/test/contentLikes.test.js +0 -0
  30. package/test/contentProgress.test.js +0 -0
  31. package/test/dataContext.test.js +3 -3
  32. package/test/initializeTests.js +0 -0
  33. package/test/lastUpdated.test.js +0 -0
  34. package/test/live/contentProgressLive.test.js +0 -0
  35. package/test/live/railcontentLive.test.js +0 -0
  36. package/test/localStorageMock.js +0 -0
  37. package/test/log.js +0 -0
  38. package/test/sanityQueryService.test.js +0 -0
  39. package/test/userPermissions.test.js +0 -0
  40. package/tools/generate-index.cjs +0 -0
File without changes
File without changes
File without changes
File without changes
package/jest.config.js CHANGED
File without changes
package/jsdoc.json CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "1.3.8",
3
+ "version": "1.3.10",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
File without changes
package/src/index.d.ts CHANGED
@@ -27,6 +27,10 @@ import {
27
27
  recordWatchSession
28
28
  } from './services/contentProgress.js';
29
29
 
30
+ import {
31
+ verifyLocalDataContext
32
+ } from './services/dataContext.js';
33
+
30
34
  import {
31
35
  setLastUpdatedTime,
32
36
  wasLastUpdateOlderThanXSeconds
@@ -258,6 +262,7 @@ declare module 'musora-content-services' {
258
262
  unpinPlaylist,
259
263
  updatePlaylist,
260
264
  updatePlaylistItem,
265
+ verifyLocalDataContext,
261
266
  wasLastUpdateOlderThanXSeconds,
262
267
  }
263
268
  }
package/src/index.js CHANGED
@@ -27,6 +27,10 @@ import {
27
27
  recordWatchSession
28
28
  } from './services/contentProgress.js';
29
29
 
30
+ import {
31
+ verifyLocalDataContext
32
+ } from './services/dataContext.js';
33
+
30
34
  import {
31
35
  setLastUpdatedTime,
32
36
  wasLastUpdateOlderThanXSeconds
@@ -257,5 +261,6 @@ export {
257
261
  unpinPlaylist,
258
262
  updatePlaylist,
259
263
  updatePlaylistItem,
264
+ verifyLocalDataContext,
260
265
  wasLastUpdateOlderThanXSeconds,
261
266
  };
File without changes
File without changes
File without changes
@@ -13,27 +13,27 @@ export const ContentProgressVersionKey = 1
13
13
 
14
14
  let cache = null
15
15
 
16
+ /**
17
+ * Verify current cached data is on the correct version
18
+ *
19
+ * @param {int} dataVersionKey - Data version key from the back end
20
+ * @param {int} currentVersion - Current version of the data on the back end
21
+ * */
22
+ export async function verifyLocalDataContext(dataVersionKey, currentVersion) {
23
+ const tempContext = new DataContext(dataVersionKey, null)
24
+ await tempContext.ensureLocalContextLoaded()
25
+
26
+ if (currentVersion !== tempContext.version()) {
27
+ tempContext.clearCache()
28
+ } else {
29
+ tempContext.setLastUpdatedTime()
30
+ }
31
+ }
32
+
16
33
  export class DataContext {
17
34
  context = null
18
35
  dataPromise = null
19
36
 
20
- /**
21
- * Verify current cached data is on the correct version
22
- *
23
- * @param {int} dataVersionKey - Data version key from the back end
24
- * @param {int} currentVersion - Current version of the data on the back end
25
- * */
26
- static async verifyLocalData(dataVersionKey, currentVersion) {
27
- const tempContext = new DataContext(dataVersionKey, null)
28
- await tempContext.ensureLocalContextLoaded()
29
-
30
- if (currentVersion !== tempContext.version()) {
31
- tempContext.clearCache()
32
- } else {
33
- tempContext.setLastUpdatedTime()
34
- }
35
- }
36
-
37
37
  constructor(dataVersionKey, fetchDataFunction) {
38
38
  this.dataVersionKey = dataVersionKey
39
39
  this.fetchDataFunction = fetchDataFunction
File without changes
File without changes
@@ -1253,11 +1253,22 @@ export async function fetchLessonContent(railContentId) {
1253
1253
  "type": *[railcontent_id == ^.id][0]._type,
1254
1254
  },
1255
1255
  sort,
1256
- xp`
1256
+ xp,
1257
+ stbs,ds2stbs, bdsStbs`
1257
1258
  const query = await buildQuery(`railcontent_id == ${railContentId}`, filterParams, fields, {
1258
1259
  isSingle: true,
1259
1260
  })
1260
- return fetchSanity(query, false)
1261
+ const chapterProcess = (result) => {
1262
+ const chapters = result.chapters ?? [];
1263
+ if(chapters.length == 0) return result
1264
+ result.chapters = chapters.map((chapter, index) => ({
1265
+ ...chapter,
1266
+ chapter_thumbnail_url: `https://musora-web-platform.s3.amazonaws.com/chapters/${result.brand}/Chapter${index + 1}.jpg`
1267
+ }));
1268
+ return result
1269
+ }
1270
+
1271
+ return fetchSanity(query, false, {customPostProcess:chapterProcess})
1261
1272
  }
1262
1273
 
1263
1274
  /**
File without changes
File without changes
File without changes
@@ -1,5 +1,5 @@
1
1
  import { initializeTestService } from './initializeTests'
2
- import { DataContext } from '../src/services/dataContext.js'
2
+ import { DataContext, verifyLocalDataContext } from '../src/services/dataContext.js'
3
3
 
4
4
  describe('dataContext', function () {
5
5
  let mock = null
@@ -26,12 +26,12 @@ describe('dataContext', function () {
26
26
  expect(dataContext.version()).toBe(1)
27
27
 
28
28
  //verifyLocalData with old source version and verify context still uses old version
29
- await DataContext.verifyLocalData(1, 1)
29
+ await verifyLocalDataContext(1, 1)
30
30
  await dataContext.getData()
31
31
  expect(dataContext.version()).toBe(1)
32
32
 
33
33
  //verifyLocalData with new source version and verify context loads new version
34
- await DataContext.verifyLocalData(1, 2)
34
+ await verifyLocalDataContext(1, 2)
35
35
  await dataContext.getData()
36
36
  expect(dataContext.version()).toBe(2)
37
37
  })
File without changes
File without changes
File without changes
File without changes
File without changes
package/test/log.js CHANGED
File without changes
File without changes
File without changes
File without changes