@duvdu-v1/duvdu 1.1.178 → 1.1.179

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.
@@ -6,8 +6,8 @@ interface Ititle {
6
6
  ar: string;
7
7
  en: string;
8
8
  }
9
- export declare function filterTagsForCategory(categoryId: string, subcategoryId: string, tagIds: string[], cycle: string, lang: string): Promise<{
10
- subCategoryTitle: Ititle;
9
+ export declare function filterTagsForCategory(categoryId: string, subcategoryId: string | undefined, tagIds: string[] | undefined, cycle: string, lang: string): Promise<{
10
+ subCategoryTitle: Ititle | undefined;
11
11
  filteredTags: Itag[];
12
12
  media: string | undefined;
13
13
  }>;
@@ -26,6 +26,12 @@ function filterTagsForCategory(categoryId, subcategoryId, tagIds, cycle, lang) {
26
26
  if (!category.media)
27
27
  throw new bad_request_error_1.BadRequestError({ en: 'category must be incluide media', ar: 'يجب أن تتضمن الفئة الوسائط' }, lang);
28
28
  }
29
+ if (!subcategoryId)
30
+ return {
31
+ subCategoryTitle: undefined,
32
+ filteredTags: [],
33
+ media: category.media ? category.media : undefined,
34
+ };
29
35
  const subcategoryFound = (_a = category.subCategories) === null || _a === void 0 ? void 0 : _a.find((subCategory) => subCategory._id.toString() === subcategoryId);
30
36
  if (!subcategoryFound)
31
37
  throw new bad_request_error_1.BadRequestError({ en: 'Invalid subcategory', ar: 'فئة فرعية غير صالحة' }, lang);
@@ -35,12 +41,15 @@ function filterTagsForCategory(categoryId, subcategoryId, tagIds, cycle, lang) {
35
41
  ar: 'الفئة الفرعية لا تحتوي على علامات صالحة',
36
42
  }, lang);
37
43
  }
38
- const filteredTags = subcategoryFound.tags.filter((tag) => tagIds.includes(tag._id.toString()));
39
- if (filteredTags.length !== tagIds.length)
40
- throw new bad_request_error_1.BadRequestError({ en: 'Invalid tags', ar: 'العلامات غير صالحة' }, lang);
44
+ let filteredTags;
45
+ if (tagIds) {
46
+ filteredTags = subcategoryFound.tags.filter((tag) => tagIds.includes(tag._id.toString()));
47
+ if (filteredTags.length !== tagIds.length)
48
+ throw new bad_request_error_1.BadRequestError({ en: 'Invalid tags', ar: 'العلامات غير صالحة' }, lang);
49
+ }
41
50
  return {
42
51
  subCategoryTitle: subcategoryFound.title,
43
- filteredTags,
52
+ filteredTags: filteredTags || [],
44
53
  media: category.media ? category.media : undefined,
45
54
  };
46
55
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duvdu-v1/duvdu",
3
- "version": "1.1.178",
3
+ "version": "1.1.179",
4
4
  "main": "./build/index.js",
5
5
  "types": "./build/index.d.ts",
6
6
  "files": [