musora-content-services 1.3.10 → 1.3.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "1.3.10",
3
+ "version": "1.3.14",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -453,9 +453,14 @@ export let contentTypeConfig = {
453
453
  'behind-the-scenes': contentWithSortField,
454
454
  'exploring-beats': contentWithSortField,
455
455
  sonor: contentWithSortField,
456
+ returning: {
457
+ fields: [
458
+ `quarter_published`,
459
+ ]
460
+ }
456
461
  }
457
462
 
458
- export const songAccessMembership = 94
463
+ export const plusMembershipPermissions = 92
459
464
 
460
465
  export function getNewReleasesTypes(brand) {
461
466
  const baseNewTypes = [
@@ -1,5 +1,5 @@
1
1
  import { fetchUserPermissions } from './services/userPermissions.js'
2
- import { songAccessMembership } from './contentTypeConfig.js'
2
+ import { plusMembershipPermissions } from './contentTypeConfig.js'
3
3
 
4
4
  export class FilterBuilder {
5
5
  STATUS_SCHEDULED = 'scheduled'
@@ -116,7 +116,7 @@ export class FilterBuilder {
116
116
  if (this.bypassPermissions || this.userData.isAdmin) return this
117
117
  let requiredPermissions = this._getUserPermissions()
118
118
  if (this.userData.isABasicMember && this.allowsPullSongsContent) {
119
- requiredPermissions = [...requiredPermissions, songAccessMembership]
119
+ requiredPermissions = [...requiredPermissions, plusMembershipPermissions]
120
120
  }
121
121
  this._andWhere(
122
122
  `(!defined(permission) || references(*[_type == 'permission' && railcontent_id in ${arrayToRawRepresentation(requiredPermissions)}]._id))`
File without changes
@@ -1198,6 +1198,43 @@ export async function setStudentViewForUser(userId, enable) {
1198
1198
  return await patchDataHandler(url, data)
1199
1199
  }
1200
1200
 
1201
+
1202
+ /**
1203
+ * Fetch the top comment for a given content
1204
+ *
1205
+ * @param {int} railcontentId - The railcontent id to fetch.
1206
+ * @returns {Promise<Object|null>} - A promise that resolves to an comment object
1207
+ */
1208
+ export async function fetchTopComment(railcontentId) {
1209
+ const url = `/api/content/v1/comments/${railcontentId}/top`
1210
+ return await fetchHandler(url)
1211
+ }
1212
+
1213
+
1214
+ /**
1215
+ *
1216
+ * @param railcontentId
1217
+ * @param page
1218
+ * @param limit
1219
+ * @returns {Promise<*|null>}
1220
+ */
1221
+ export async function fetchComments(railcontentId, page = 1, limit = 20) {
1222
+ const url = `/api/content/v1/comments/${railcontentId}/all?page=${page}&limit=${limit}`
1223
+ return await fetchHandler(url)
1224
+ }
1225
+
1226
+ /**
1227
+ *
1228
+ * @param commentId
1229
+ * @param page
1230
+ * @param limit
1231
+ * @returns {Promise<*|null>}
1232
+ */
1233
+ export async function fetchCommentRelies(commentId, page = 1, limit = 20) {
1234
+ const url = `/api/content/v1/comments/${commentId}/replies?page=${page}&limit=${limit}`
1235
+ return await fetchHandler(url)
1236
+ }
1237
+
1201
1238
  function fetchAbsolute(url, params) {
1202
1239
  if (globalConfig.railcontentConfig.authToken) {
1203
1240
  params.headers['Authorization'] = `Bearer ${globalConfig.railcontentConfig.authToken}`
@@ -99,7 +99,7 @@ export async function fetchReturning(
99
99
  const filterString = `brand == '${brand}' && quarter_published == '${nextQuarter}'`;
100
100
  const startEndOrder = getQueryFromPage(pageNumber, contentPerPage);
101
101
  const sortOrder = {sortOrder: "published_on desc, id desc", start: startEndOrder['start'], end: startEndOrder['end']};
102
- const query = await buildQuery(filterString, {pullFutureContent: true, availableContentStatuses: ["draft"]}, getFieldsForContentType(), sortOrder);
102
+ const query = await buildQuery(filterString, {pullFutureContent: true, availableContentStatuses: ["draft"]}, getFieldsForContentType('returning'), sortOrder);
103
103
 
104
104
  return fetchSanity(query, true);
105
105
  }
@@ -255,6 +255,7 @@ export async function fetchRelatedSongs(brand, songId) {
255
255
  "published_on": published_on,
256
256
  status,
257
257
  "image": thumbnail.asset->url,
258
+ "permission_id": permission[]->railcontent_id,
258
259
  "fields": [
259
260
  {
260
261
  "key": "title",
@@ -280,6 +281,7 @@ export async function fetchRelatedSongs(brand, songId) {
280
281
  "id": railcontent_id,
281
282
  "url": web_url_path,
282
283
  "published_on": published_on,
284
+ "permission_id": permission[]->railcontent_id,
283
285
  status,
284
286
  "fields": [
285
287
  {
@@ -486,6 +488,9 @@ export async function fetchByRailContentId(id, contentType) {
486
488
  * .catch(error => console.error(error));
487
489
  */
488
490
  export async function fetchByRailContentIds(ids, contentType = undefined) {
491
+ if (!ids) {
492
+ return [];
493
+ }
489
494
  const idsString = ids.join(',')
490
495
 
491
496
  const query = `*[railcontent_id in [${idsString}]]{
package/.yarnrc.yml DELETED
@@ -1 +0,0 @@
1
- nodeLinker: node-modules