musora-content-services 1.3.8 → 1.3.9

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/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.3.9](https://github.com/railroadmedia/musora-content-services/compare/v1.3.8...v1.3.9) (2025-02-22)
6
+
5
7
  ### [1.3.8](https://github.com/railroadmedia/musora-content-services/compare/v1.3.7...v1.3.8) (2025-02-21)
6
8
 
7
9
  ### [1.3.7](https://github.com/railroadmedia/musora-content-services/compare/v1.3.6...v1.3.7) (2025-02-20)
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.9",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
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
  };
@@ -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
@@ -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
  })