musora-content-services 1.0.32 → 1.0.33

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.
@@ -0,0 +1 @@
1
+ module.exports = {presets: ['@babel/preset-env']}
package/jest.config.js CHANGED
@@ -101,7 +101,7 @@ const config = {
101
101
  // notifyMode: "failure-change",
102
102
 
103
103
  // A preset that is used as a base for Jest's configuration
104
- // preset: undefined,
104
+ preset: 'ts-jest',
105
105
 
106
106
  // Run tests from one or more projects
107
107
  // projects: undefined,
@@ -174,8 +174,11 @@ const config = {
174
174
  // testRunner: "jest-circus/runner",
175
175
 
176
176
  // A map from regular expressions to paths to transformers
177
- // transform: undefined,
178
177
 
178
+ transform: {
179
+ '^.+\\.(ts|tsx)?$': 'ts-jest',
180
+ '^.+\\.(js|jsx)$': 'babel-jest',
181
+ }
179
182
  // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
180
183
  // transformIgnorePatterns: [
181
184
  // "/node_modules/",
@@ -193,6 +196,8 @@ const config = {
193
196
 
194
197
  // Whether to use watchman for file crawling
195
198
  // watchman: true,
199
+
196
200
  };
197
201
 
198
202
  module.exports = config;
203
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "1.0.32",
3
+ "version": "1.0.33",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -25,6 +25,9 @@
25
25
  "standard-version": "^9.5.0"
26
26
  },
27
27
  "dependencies": {
28
- "docdash": "^2.0.2"
28
+ "@babel/preset-env": "^7.25.3",
29
+ "babel-jest": "^29.7.0",
30
+ "docdash": "^2.0.2",
31
+ "ts-jest": "^29.2.4"
29
32
  }
30
33
  }
package/publish.sh CHANGED
File without changes
@@ -3,7 +3,7 @@ let contentTypeConfig = {
3
3
  'fields': [
4
4
  '"artist_name": artist->name',
5
5
  'soundslice',
6
- 'instrumentless'
6
+ 'instrumentless',
7
7
  ],
8
8
  'relationships': {
9
9
  'artist': {
package/src/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import {
2
- initializeService,
3
2
  fetchSongById,
4
3
  fetchArtists,
5
4
  fetchSongArtistCount,
@@ -9,6 +8,7 @@ import {
9
8
  fetchSongCount,
10
9
  fetchWorkouts,
11
10
  fetchNewReleases,
11
+ fetchLiveEvent,
12
12
  fetchUpcomingEvents,
13
13
  fetchByRailContentId,
14
14
  fetchByRailContentIds,
@@ -21,7 +21,9 @@ import {
21
21
  fetchPackAll,
22
22
  fetchPackChildren,
23
23
  fetchLessonContent
24
- } from './index.js';
24
+ } from './services/sanity.js';
25
+
26
+ import { initializeService } from './services/config.js';
25
27
 
26
28
  declare module 'musora-content-services' {
27
29
  export {
@@ -1,11 +1,10 @@
1
1
  /**
2
2
  * @module Sanity-Services
3
3
  */
4
+ import {contentTypeConfig} from "../contentTypeConfig";
5
+ import {globalConfig} from "./config";
4
6
 
5
- const { contentTypeConfig } = require('../contentTypeConfig.js');
6
- const { globalConfig } = require('./config');
7
-
8
- import { fetchAllCompletedStates, fetchCurrentSongComplete } from './railcontent.js';
7
+ import { fetchAllCompletedStates, fetchCurrentSongComplete } from './railcontent.js';
9
8
 
10
9
  /**
11
10
  * Fetch a song by its document ID from Sanity.
@@ -20,6 +19,10 @@ import { fetchAllCompletedStates, fetchCurrentSongComplete } from './railcontent
20
19
  */
21
20
  export async function fetchSongById(documentId) {
22
21
  const fields = [
22
+ '"id": railcontent_id',
23
+ 'railcontent_id',
24
+ '"type": _type',
25
+ 'description',
23
26
  'title',
24
27
  '"thumbnail_url": thumbnail.asset->url',
25
28
  '"style": genre[0]->name',
@@ -28,8 +31,9 @@ export async function fetchSongById(documentId) {
28
31
  'instrumentless',
29
32
  'soundslice',
30
33
  '"resources": resource[]{resource_url, resource_name}',
34
+ '"url": web_url_path',
31
35
  ];
32
-
36
+
33
37
  const query = `
34
38
  *[_type == "song" && railcontent_id == ${documentId}]{
35
39
  ${fields.join(', ')}
@@ -144,11 +148,11 @@ export async function fetchRelatedSongs(brand, songId) {
144
148
  }[0...10])
145
149
  ])[0...10]
146
150
  }`;
147
-
151
+
148
152
  // Fetch the related songs data
149
153
  return fetchSanity(query, false);
150
154
  }
151
-
155
+
152
156
  /**
153
157
  * Fetch all songs for a specific brand with pagination and search options.
154
158
  * @param {string} brand - The brand for which to fetch songs.
@@ -289,7 +293,7 @@ export async function fetchNewReleases(brand) {
289
293
 
290
294
 
291
295
  /**
292
- * Fetch upcoming events for a specific brand that are within 48 hours before their `published_on` date
296
+ * Fetch upcoming events for a specific brand that are within 48 hours before their `published_on` date
293
297
  * and are currently ongoing based on their `length_in_seconds`.
294
298
  *
295
299
  * This function retrieves events that have a `published_on` date within the last 48 hours or are currently
@@ -303,7 +307,7 @@ export async function fetchNewReleases(brand) {
303
307
  * fetchLiveEvent('drumeo')
304
308
  * .then(events => console.log(events))
305
309
  * .catch(error => console.error(error));
306
- *
310
+ *
307
311
  */
308
312
  export async function fetchLiveEvent(brand) {
309
313
  const baseLiveTypes = ["student-review", "student-reviews", "student-focus", "coach-stream", "live", "question-and-answer", "student-review", "boot-camps", "recording", "pack-bundle-lesson"];
@@ -511,7 +515,10 @@ export async function fetchAll(brand, type, {
511
515
  break;
512
516
  }
513
517
 
514
- let defaultFields = ['railcontent_id',
518
+ let defaultFields = [
519
+ '"id": railcontent_id',
520
+ 'railcontent_id',
521
+ '"type": _type',
515
522
  'title',
516
523
  '"image": thumbnail.asset->url',
517
524
  'difficulty',
@@ -1,5 +1,6 @@
1
+ import {initializeService} from '../src/services/config.js';
2
+
1
3
  const {
2
- initializeService,
3
4
  fetchSongById,
4
5
  fetchArtists,
5
6
  fetchSongArtistCount,
@@ -21,18 +22,18 @@ const {
21
22
  fetchPackAll,
22
23
  fetchPackChildren,
23
24
  fetchLessonContent
24
- } = require('../src/index.js');
25
+ } = require('../src/services/sanity.js');
25
26
 
26
27
  describe('Sanity Queries', function () {
27
28
  beforeEach(() => {
28
- const config = {
29
+ const config = { 'sanityConfig':{
29
30
  token: process.env.SANITY_API_TOKEN,
30
31
  projectId: process.env.SANITY_PROJECT_ID,
31
32
  dataset: process.env.SANITY_DATASET,
32
33
  useCachedAPI: process.env.SANITY_USE_CACHED_API || true,
33
34
  version: '2021-06-07',
34
35
  debug: process.env.DEBUG || false
35
- };
36
+ }};
36
37
  initializeService(config);
37
38
  });
38
39