musora-content-services 2.61.1 → 2.62.0

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,8 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(rg:*)"
5
+ ],
6
+ "deny": []
7
+ }
8
+ }
package/CHANGELOG.md CHANGED
@@ -2,6 +2,19 @@
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
+ ## [2.62.0](https://github.com/railroadmedia/musora-content-services/compare/v2.61.1...v2.62.0) (2025-10-30)
6
+
7
+
8
+ ### Features
9
+
10
+ * **MU2E1-137:** number of active accounts ([#515](https://github.com/railroadmedia/musora-content-services/issues/515)) ([fd8b57e](https://github.com/railroadmedia/musora-content-services/commit/fd8b57ee401596471cdc4e940b1282c800483bf5))
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * sanity function refactors ([#520](https://github.com/railroadmedia/musora-content-services/issues/520)) ([2667c25](https://github.com/railroadmedia/musora-content-services/commit/2667c25dd876bec81c49a524823efac66f846fbf))
16
+ * sort in fetch all ([#521](https://github.com/railroadmedia/musora-content-services/issues/521)) ([f353410](https://github.com/railroadmedia/musora-content-services/commit/f353410c210a1185337ae737e6f0c047bd95c751))
17
+
5
18
  ### [2.61.1](https://github.com/railroadmedia/musora-content-services/compare/v2.61.0...v2.61.1) (2025-10-29)
6
19
 
7
20
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "2.61.1",
3
+ "version": "2.62.0",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -583,13 +583,14 @@ export let contentTypeConfig = {
583
583
  "method-v2": [
584
584
  `"id":_id`,
585
585
  `"type":_type`,
586
+ "title",
586
587
  "brand",
587
588
  `"intro_video": intro_video->{ ${getIntroVideoFields().join(", ")} }`,
588
589
  `child[]->{
589
590
  "resource": ${resourcesField},
590
591
  total_skills,
591
- "difficulty":difficulty,
592
- "published_on":published_on,
592
+ difficulty,
593
+ published_on,
593
594
  "type":_type,
594
595
  brand,
595
596
  title,
@@ -601,16 +602,17 @@ export let contentTypeConfig = {
601
602
  hlsManifestUrl,
602
603
  video_playback_endpoints
603
604
  },
604
- lp_lessons[]->{
605
+ child[]->{
605
606
  ${DEFAULT_FIELDS.join(',')}
606
607
  }
607
608
  }`,
608
609
  ],
609
- "method-v2-intro-video": getIntroVideoFields(),
610
+ "method-intro": getIntroVideoFields(),
610
611
  }
611
612
 
612
613
  export function getIntroVideoFields() {
613
614
  return [
615
+ "title",
614
616
  "brand",
615
617
  `"description": ${descriptionField}`,
616
618
  `"thumbnail": thumbnail.asset->url`,
@@ -764,7 +766,7 @@ export function getChildFieldsForContentType(contentType, asQueryString = true)
764
766
  if (!contentType) {
765
767
  return asQueryString ? DEFAULT_CHILD_FIELDS.toString() + ',' : DEFAULT_CHILD_FIELDS
766
768
  }
767
-
769
+
768
770
  if (contentTypeConfig[contentType]?.childFields || contentTypeConfig[contentType]?.includeChildFields) {
769
771
  const childFields = contentType
770
772
  ? DEFAULT_CHILD_FIELDS.concat(contentTypeConfig?.[contentType]?.childFields ?? [])
package/src/index.d.ts CHANGED
@@ -213,7 +213,6 @@ import {
213
213
  fetchCommentModContentData,
214
214
  fetchContentRows,
215
215
  fetchFoundation,
216
- fetchFullMethodV2StructureFor,
217
216
  fetchGenreLessons,
218
217
  fetchHierarchy,
219
218
  fetchLeaving,
@@ -226,6 +225,7 @@ import {
226
225
  fetchMethodChildrenIds,
227
226
  fetchMethodPreviousNextLesson,
228
227
  fetchMethodV2IntroVideo,
228
+ fetchMethodV2Structure,
229
229
  fetchNewReleases,
230
230
  fetchNextPreviousLesson,
231
231
  fetchOtherSongVersions,
@@ -255,6 +255,7 @@ import {
255
255
  import {
256
256
  confirmEmailChange,
257
257
  deleteAccount,
258
+ numberOfActiveUsers,
258
259
  requestEmailChange,
259
260
  resetPassword,
260
261
  sendAccountSetupEmail,
@@ -437,7 +438,6 @@ declare module 'musora-content-services' {
437
438
  fetchFollowedThreads,
438
439
  fetchForumCategories,
439
440
  fetchFoundation,
440
- fetchFullMethodV2StructureFor,
441
441
  fetchGenreLessons,
442
442
  fetchHandler,
443
443
  fetchHierarchy,
@@ -457,6 +457,7 @@ declare module 'musora-content-services' {
457
457
  fetchMethodChildrenIds,
458
458
  fetchMethodPreviousNextLesson,
459
459
  fetchMethodV2IntroVideo,
460
+ fetchMethodV2Structure,
460
461
  fetchNewReleases,
461
462
  fetchNextContentDataForParent,
462
463
  fetchNextPreviousLesson,
@@ -566,6 +567,7 @@ declare module 'musora-content-services' {
566
567
  markContentAsNotInterested,
567
568
  markNotificationAsRead,
568
569
  markNotificationAsUnread,
570
+ numberOfActiveUsers,
569
571
  openComment,
570
572
  otherStats,
571
573
  pauseLiveEventPolling,
package/src/index.js CHANGED
@@ -213,7 +213,6 @@ import {
213
213
  fetchCommentModContentData,
214
214
  fetchContentRows,
215
215
  fetchFoundation,
216
- fetchFullMethodV2StructureFor,
217
216
  fetchGenreLessons,
218
217
  fetchHierarchy,
219
218
  fetchLeaving,
@@ -226,6 +225,7 @@ import {
226
225
  fetchMethodChildrenIds,
227
226
  fetchMethodPreviousNextLesson,
228
227
  fetchMethodV2IntroVideo,
228
+ fetchMethodV2Structure,
229
229
  fetchNewReleases,
230
230
  fetchNextPreviousLesson,
231
231
  fetchOtherSongVersions,
@@ -255,6 +255,7 @@ import {
255
255
  import {
256
256
  confirmEmailChange,
257
257
  deleteAccount,
258
+ numberOfActiveUsers,
258
259
  requestEmailChange,
259
260
  resetPassword,
260
261
  sendAccountSetupEmail,
@@ -436,7 +437,6 @@ export {
436
437
  fetchFollowedThreads,
437
438
  fetchForumCategories,
438
439
  fetchFoundation,
439
- fetchFullMethodV2StructureFor,
440
440
  fetchGenreLessons,
441
441
  fetchHandler,
442
442
  fetchHierarchy,
@@ -456,6 +456,7 @@ export {
456
456
  fetchMethodChildrenIds,
457
457
  fetchMethodPreviousNextLesson,
458
458
  fetchMethodV2IntroVideo,
459
+ fetchMethodV2Structure,
459
460
  fetchNewReleases,
460
461
  fetchNextContentDataForParent,
461
462
  fetchNextPreviousLesson,
@@ -565,6 +566,7 @@ export {
565
566
  markContentAsNotInterested,
566
567
  markNotificationAsRead,
567
568
  markNotificationAsUnread,
569
+ numberOfActiveUsers,
568
570
  openComment,
569
571
  otherStats,
570
572
  pauseLiveEventPolling,
@@ -748,17 +748,17 @@ async function getProgressFilter(progress, progressIds) {
748
748
  }
749
749
 
750
750
  export function getSortOrder(sort = '-published_on', brand, groupBy) {
751
- // Determine the sort order
751
+ const sanitizedSort = sort?.trim() || '-published_on'
752
+ const isDesc = sanitizedSort.startsWith('-')
753
+ const sortField = isDesc ? sanitizedSort.substring(1) : sanitizedSort
754
+
752
755
  let sortOrder = ''
753
- let isDesc = sort.startsWith('-')
754
- sort = isDesc ? sort.substring(1) : sort
755
- switch (sort) {
756
+
757
+ switch (sortField) {
756
758
  case 'slug':
757
759
  sortOrder = groupBy ? 'name' : '!defined(title), lower(title)'
758
760
  break
759
- case 'name':
760
- sortOrder = sort
761
- break
761
+
762
762
  case 'popularity':
763
763
  if (groupBy == 'artist' || groupBy == 'genre') {
764
764
  sortOrder = isDesc ? `coalesce(popularity.${brand}, -1)` : 'popularity'
@@ -766,15 +766,17 @@ export function getSortOrder(sort = '-published_on', brand, groupBy) {
766
766
  sortOrder = isDesc ? 'coalesce(popularity, -1)' : 'popularity'
767
767
  }
768
768
  break
769
+
769
770
  case 'recommended':
770
771
  sortOrder = 'published_on'
771
772
  isDesc = true
772
773
  break
773
- case 'published_on':
774
+
774
775
  default:
775
- sortOrder = 'published_on'
776
+ sortOrder = sortField
776
777
  break
777
778
  }
779
+
778
780
  sortOrder += isDesc ? ' desc' : ' asc'
779
781
  return sortOrder
780
782
  }
@@ -2280,20 +2282,23 @@ export async function fetchShows(brand, type, sort = 'sort') {
2280
2282
 
2281
2283
 
2282
2284
  export async function fetchMethodV2IntroVideo(brand) {
2283
- const _type = "method-intro";
2284
- const filter = `_type == '${_type}' && brand == '${brand}'`;
2285
+ const type = "method-intro";
2286
+ const filter = `_type == '${type}' && brand == '${brand}'`;
2285
2287
  const fields = getIntroVideoFields();
2286
2288
 
2287
2289
  const query = `*[${filter}] { ${fields.join(", ")} }`;
2288
2290
  return fetchSanity(query, false);
2289
2291
  }
2290
2292
 
2291
- export async function fetchFullMethodV2StructureFor(brand) {
2293
+ export async function fetchMethodV2Structure(brand) {
2292
2294
  const _type = "method-v2";
2293
- const filter = `_type == '${_type}' && brand == '${brand}'`;
2294
-
2295
- const fields = contentTypeConfig[_type];
2296
- const query = `*[${filter}] { ${fields.join(",")} }`;
2295
+ const query = `*[_type == '${_type}' && brand == '${brand}'][0...1]{
2296
+ 'sanity_id': _id,
2297
+ 'children': child[]->{
2298
+ 'id': railcontent_id,
2299
+ 'children': child[]->railcontent_id
2300
+ }
2301
+ }`;
2297
2302
 
2298
- return await fetchSanity(query, true);
2303
+ return await fetchSanity(query, false);
2299
2304
  }
@@ -151,3 +151,15 @@ export async function deleteAccount(userId: number): Promise<void> {
151
151
  return httpClient.delete(apiUrl)
152
152
  }
153
153
 
154
+ /**
155
+ * Calls a public API endpoint to get the number of active users.
156
+ *
157
+ * @returns {Promise<number>} - A promise that resolves to the number of active users.
158
+ * @throws {HttpError} - Throws HttpError if the request fails.
159
+ */
160
+ export async function numberOfActiveUsers(): Promise<number> {
161
+ const apiUrl = `/api/user-management-system/v1/accounts/active-users/count`
162
+ const httpClient = new HttpClient(globalConfig.baseUrl)
163
+ const response = await httpClient.get<{ active_users: number }>(apiUrl)
164
+ return response.active_users
165
+ }