musora-content-services 1.0.133 → 1.0.134

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.0.134](https://github.com/railroadmedia/musora-content-services/compare/v1.0.133...v1.0.134) (2024-10-11)
6
+
5
7
  ### [1.0.133](https://github.com/railroadmedia/musora-content-services/compare/v1.0.132...v1.0.133) (2024-10-10)
6
8
 
7
9
  ### [1.0.132](https://github.com/railroadmedia/musora-content-services/compare/v1.0.131...v1.0.132) (2024-10-10)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "1.0.133",
3
+ "version": "1.0.134",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1214,10 +1214,17 @@ export async function fetchByReference(brand, {
1214
1214
  * @param {string} brand - The brand for which to fetch lessons.
1215
1215
  * @param {string} name - The name of the artist
1216
1216
  * @param {string} contentType - The type of the lessons we need to get from the artist. If not defined, groq will get lessons from all content types
1217
+ * @param {Object} params - Parameters for sorting, searching, pagination and filtering.
1218
+ * @param {string} [params.sort="-published_on"] - The field to sort the lessons by.
1219
+ * @param {string} [params.searchTerm=""] - The search term to filter the lessons.
1220
+ * @param {number} [params.page=1] - The page number for pagination.
1221
+ * @param {number} [params.limit=10] - The number of items per page.
1222
+ * @param {Array<string>} [params.includedFields=[]] - Additional filters to apply to the query in the format of a key,value array. eg. ['difficulty,Intermediate', 'genre,rock'].
1223
+ * @param {Array<number>} [params.progressIds] - The ids of the lessons that are in progress or completed
1217
1224
  * @returns {Promise<Object|null>} - The lessons for the artist and some details about the artist (name and thumbnail).
1218
1225
  *
1219
1226
  * @example
1220
- * fetchArtistLessons('10 Years', 'song')
1227
+ * fetchArtistLessons('drumeo', '10 Years', 'song', {'-published_on', '', 1, 10, ["difficulty,Intermediate"], [232168, 232824, 303375, 232194, 393125]})
1221
1228
  * .then(lessons => console.log(lessons))
1222
1229
  * .catch(error => console.error(error));
1223
1230
  */
@@ -1227,7 +1234,9 @@ export async function fetchArtistLessons(brand, name, contentType, {
1227
1234
  page = 1,
1228
1235
  limit = 10,
1229
1236
  includedFields = [],
1237
+ progressIds = undefined,
1230
1238
  } = {}) {
1239
+
1231
1240
  const fieldsString = DEFAULT_FIELDS.join(',');
1232
1241
  const start = (page - 1) * limit;
1233
1242
  const end = start + limit;
@@ -1238,12 +1247,15 @@ export async function fetchArtistLessons(brand, name, contentType, {
1238
1247
  ? filtersToGroq(includedFields)
1239
1248
  : "";
1240
1249
 
1250
+ // limits the results to supplied progressIds for started & completed filters
1251
+ const progressFilter = progressIds !== undefined ? `&& railcontent_id in [${progressIds.join(',')}]` : "";
1252
+
1241
1253
  const query = `{
1242
1254
  "entity":
1243
1255
  *[_type == 'artist' && name == '${name}']
1244
1256
  {'type': _type, name, 'thumbnail_url':thumbnail_url.asset->url,
1245
1257
  'lessons_count': count(*[${addType} brand == '${brand}' && references(^._id)]),
1246
- 'lessons': *[${addType} brand == '${brand}' && references(^._id) ${searchFilter} ${includedFieldsFilter}]{${fieldsString}}
1258
+ 'lessons': *[${addType} brand == '${brand}' && references(^._id) ${searchFilter} ${includedFieldsFilter} ${progressFilter}]{${fieldsString}}
1247
1259
  [${start}...${end}]}
1248
1260
  |order(${sortOrder})
1249
1261
  }`;
@@ -1254,11 +1266,17 @@ export async function fetchArtistLessons(brand, name, contentType, {
1254
1266
  * Fetch the genre's lessons.
1255
1267
  * @param {string} brand - The brand for which to fetch lessons.
1256
1268
  * @param {string} name - The name of the genre
1257
- * @param {string} contentType - The type of the lessons we need to get from the genre. If not defined, groq will get lessons from all content types
1258
- * @returns {Promise<Object|null>} - The lessons for the genre and some details about the genre (name and thumbnail).
1269
+ * @param {Object} params - Parameters for sorting, searching, pagination and filtering.
1270
+ * @param {string} [params.sort="-published_on"] - The field to sort the lessons by.
1271
+ * @param {string} [params.searchTerm=""] - The search term to filter the lessons.
1272
+ * @param {number} [params.page=1] - The page number for pagination.
1273
+ * @param {number} [params.limit=10] - The number of items per page.
1274
+ * @param {Array<string>} [params.includedFields=[]] - Additional filters to apply to the query in the format of a key,value array. eg. ['difficulty,Intermediate', 'genre,rock'].
1275
+ * @param {Array<number>} [params.progressIds] - The ids of the lessons that are in progress or completed
1276
+ * @returns {Promise<Object|null>} - The lessons for the artist and some details about the artist (name and thumbnail).
1259
1277
  *
1260
1278
  * @example
1261
- * fetchGenreLessons('Blues', 'song')
1279
+ * fetchGenreLessons('drumeo', 'Blues', 'song', {'-published_on', '', 1, 10, ["difficulty,Intermediate"], [232168, 232824, 303375, 232194, 393125]})
1262
1280
  * .then(lessons => console.log(lessons))
1263
1281
  * .catch(error => console.error(error));
1264
1282
  */
@@ -1268,6 +1286,7 @@ export async function fetchGenreLessons(brand, name, contentType, {
1268
1286
  page = 1,
1269
1287
  limit = 10,
1270
1288
  includedFields = [],
1289
+ progressIds = undefined,
1271
1290
  } = {}) {
1272
1291
  const fieldsString = DEFAULT_FIELDS.join(',');
1273
1292
  const start = (page - 1) * limit;
@@ -1278,13 +1297,15 @@ export async function fetchGenreLessons(brand, name, contentType, {
1278
1297
  const includedFieldsFilter = includedFields.length > 0
1279
1298
  ? filtersToGroq(includedFields)
1280
1299
  : "";
1300
+ // limits the results to supplied progressIds for started & completed filters
1301
+ const progressFilter = progressIds !== undefined ? `&& railcontent_id in [${progressIds.join(',')}]` : "";
1281
1302
 
1282
1303
  const query = `{
1283
1304
  "entity":
1284
1305
  *[_type == 'genre' && name == '${name}']
1285
1306
  {'type': _type, name, 'thumbnail_url':thumbnail_url.asset->url,
1286
1307
  'lessons_count': count(*[${addType} brand == '${brand}' && references(^._id)]),
1287
- 'lessons': *[${addType} brand == '${brand}' && references(^._id) ${searchFilter} ${includedFieldsFilter}]{${fieldsString}}
1308
+ 'lessons': *[${addType} brand == '${brand}' && references(^._id) ${searchFilter} ${includedFieldsFilter} ${progressFilter}]{${fieldsString}}
1288
1309
  [${start}...${end}]}
1289
1310
  |order(${sortOrder})
1290
1311
  }`;
File without changes