@duvdu-v1/duvdu 1.1.128 → 1.1.130

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.
@@ -54,7 +54,6 @@ export interface IprojectCycle {
54
54
  };
55
55
  address: string;
56
56
  searchKeyWords: string[];
57
- insurance: number;
58
57
  showOnHome: boolean;
59
58
  projectScale: {
60
59
  unit: string;
@@ -18,7 +18,6 @@ exports.ProjectCycle = (0, mongoose_1.model)(duvdu_1.MODELS.portfolioPost, new m
18
18
  location: { lat: { type: Number, default: 0 }, lng: { type: Number, default: 0 } },
19
19
  address: { type: String, default: null },
20
20
  searchKeyWords: [String],
21
- insurance: { type: Number, default: 0 },
22
21
  showOnHome: { type: Boolean, default: true },
23
22
  projectScale: { unit: String, minimum: Number, maximum: Number, pricerPerUnit: Number },
24
23
  isDeleted: { type: Boolean, default: false },
@@ -6,8 +6,9 @@ interface Ititle {
6
6
  ar: string;
7
7
  en: string;
8
8
  }
9
- export declare function filterTagsForCategory(categoryId: string, subcategoryId: string, tags: string[], cycle: string): Promise<{
9
+ export declare function filterTagsForCategory(categoryId: string, subcategoryId: string, tagIds: string[], cycle: string, lang: string): Promise<{
10
10
  subCategoryTitle: Ititle;
11
11
  filteredTags: Itag[];
12
+ media: string | undefined;
12
13
  }>;
13
14
  export {};
@@ -13,24 +13,29 @@ exports.filterTagsForCategory = void 0;
13
13
  const bad_request_error_1 = require("../errors/bad-request-error");
14
14
  const notfound_error_1 = require("../errors/notfound-error");
15
15
  const category_model_1 = require("../models/category.model");
16
- function filterTagsForCategory(categoryId, subcategoryId, tags, cycle) {
16
+ const cycles_1 = require("../types/cycles");
17
+ function filterTagsForCategory(categoryId, subcategoryId, tagIds, cycle, lang) {
17
18
  var _a;
18
19
  return __awaiter(this, void 0, void 0, function* () {
19
20
  const category = yield category_model_1.Categories.findOne({ _id: categoryId });
20
21
  if (!category)
21
- throw new notfound_error_1.NotFound('Category not found');
22
+ throw new notfound_error_1.NotFound({ en: 'Category not found', ar: 'الفئة غير موجودة' }, lang);
22
23
  if (category.cycle !== cycle)
23
- throw new bad_request_error_1.BadRequestError('This category is not related to this cycle');
24
+ throw new bad_request_error_1.BadRequestError({ en: 'This category is not related to this cycle', ar: 'هذه الفئة ليست مرتبطة بهذه الدورة' }, lang);
25
+ if (cycle === cycles_1.CYCLES.portfolioPost) {
26
+ if (!category.media)
27
+ throw new bad_request_error_1.BadRequestError({ en: 'category must be incluide media', ar: 'يجب أن تتضمن الفئة الوسائط' }, lang);
28
+ }
24
29
  const subcategoryFound = (_a = category.subCategories) === null || _a === void 0 ? void 0 : _a.find((subCategory) => subCategory._id.toString() === subcategoryId);
25
30
  if (!subcategoryFound)
26
- throw new bad_request_error_1.BadRequestError('Invalid subcategory');
27
- function filterTags(tags, searchStrings) {
28
- return tags.filter(tag => searchStrings.includes(tag.ar) || searchStrings.includes(tag.en));
31
+ throw new bad_request_error_1.BadRequestError({ en: 'Invalid subcategory', ar: 'فئة فرعية غير صالحة' }, lang);
32
+ if (!subcategoryFound.tags || !Array.isArray(subcategoryFound.tags)) {
33
+ throw new bad_request_error_1.BadRequestError({ en: 'Subcategory does not contain valid tags', ar: 'الفئة الفرعية لا تحتوي على علامات صالحة' }, lang);
29
34
  }
30
- const filteredTags = filterTags(subcategoryFound.tags, tags);
31
- if (filteredTags.length != tags.length)
32
- throw new bad_request_error_1.BadRequestError('Invalid tags');
33
- return { subCategoryTitle: subcategoryFound.title, filteredTags };
35
+ const filteredTags = subcategoryFound.tags.filter((tag) => tagIds.includes(tag._id.toString()));
36
+ if (filteredTags.length !== tagIds.length)
37
+ throw new bad_request_error_1.BadRequestError({ en: 'Invalid tags', ar: 'العلامات غير صالحة' }, lang);
38
+ return { subCategoryTitle: subcategoryFound.title, filteredTags, media: category.media ? category.media : undefined };
34
39
  });
35
40
  }
36
41
  exports.filterTagsForCategory = filterTagsForCategory;
package/package.json CHANGED
@@ -1,57 +1,57 @@
1
- {
2
- "name": "@duvdu-v1/duvdu",
3
- "version": "1.1.128",
4
- "main": "./build/index.js",
5
- "types": "./build/index.d.ts",
6
- "files": [
7
- "build/**/*"
8
- ],
9
- "scripts": {
10
- "clean": "rimraf ./build",
11
- "build": "npm run clean && tsc",
12
- "fix:build": "mv ./build/common/src/* ./build && rm -rf ./build/auth ./build/common",
13
- "pub": "git add . && git commit -m \"updates\" && npm version patch && npm run build && npm publish",
14
- "lint": "eslint .",
15
- "lint:fix": "eslint --fix .",
16
- "format": "prettier --write ."
17
- },
18
- "keywords": [],
19
- "author": "motemed khaled",
20
- "license": "ISC",
21
- "dependencies": {
22
- "@duvdu-v1/duvdu": "^1.1.116",
23
- "@types/express": "^4.17.21",
24
- "@types/express-session": "^1.18.0",
25
- "@types/jsonwebtoken": "^9.0.5",
26
- "@types/multer": "^1.4.11",
27
- "@types/node": "^20.11.0",
28
- "@typescript-eslint/eslint-plugin": "^6.19.0",
29
- "@typescript-eslint/parser": "^6.19.0",
30
- "aws-sdk": "^2.1595.0",
31
- "connect-redis": "^7.1.1",
32
- "express": "^4.18.2",
33
- "express-async-errors": "^3.1.1",
34
- "express-session": "^1.18.0",
35
- "express-validator": "^7.0.1",
36
- "jsonwebtoken": "^9.0.2",
37
- "mongoose": "^8.0.4",
38
- "multer": "^1.4.5-lts.1",
39
- "node-nats-streaming": "^0.3.2",
40
- "redis": "^4.6.13",
41
- "rimraf": "^5.0.5",
42
- "typescript": "^5.3.3",
43
- "uuid": "^9.0.1",
44
- "winston": "^3.13.0",
45
- "winston-daily-rotate-file": "^5.0.0"
46
- },
47
- "devDependencies": {
48
- "@types/uuid": "^9.0.8",
49
- "del-cli": "^5.1.0",
50
- "eslint": "^8.56.0",
51
- "eslint-config-prettier": "^9.1.0",
52
- "eslint-plugin-import": "^2.29.1",
53
- "eslint-plugin-prettier": "^5.1.3",
54
- "prettier": "^3.2.4"
55
- },
56
- "description": ""
57
- }
1
+ {
2
+ "name": "@duvdu-v1/duvdu",
3
+ "version": "1.1.130",
4
+ "main": "./build/index.js",
5
+ "types": "./build/index.d.ts",
6
+ "files": [
7
+ "build/**/*"
8
+ ],
9
+ "scripts": {
10
+ "clean": "rimraf ./build",
11
+ "build": "npm run clean && tsc",
12
+ "fix:build": "mv ./build/common/src/* ./build && rm -rf ./build/auth ./build/common",
13
+ "pub": "git add . && git commit -m \"updates\" && npm version patch && npm run build && npm publish",
14
+ "lint": "eslint .",
15
+ "lint:fix": "eslint --fix .",
16
+ "format": "prettier --write ."
17
+ },
18
+ "keywords": [],
19
+ "author": "motemed khaled",
20
+ "license": "ISC",
21
+ "dependencies": {
22
+ "@duvdu-v1/duvdu": "^1.1.116",
23
+ "@types/express": "^4.17.21",
24
+ "@types/express-session": "^1.18.0",
25
+ "@types/jsonwebtoken": "^9.0.5",
26
+ "@types/multer": "^1.4.11",
27
+ "@types/node": "^20.11.0",
28
+ "@typescript-eslint/eslint-plugin": "^6.19.0",
29
+ "@typescript-eslint/parser": "^6.19.0",
30
+ "aws-sdk": "^2.1595.0",
31
+ "connect-redis": "^7.1.1",
32
+ "express": "^4.18.2",
33
+ "express-async-errors": "^3.1.1",
34
+ "express-session": "^1.18.0",
35
+ "express-validator": "^7.0.1",
36
+ "jsonwebtoken": "^9.0.2",
37
+ "mongoose": "^8.0.4",
38
+ "multer": "^1.4.5-lts.1",
39
+ "node-nats-streaming": "^0.3.2",
40
+ "redis": "^4.6.13",
41
+ "rimraf": "^5.0.5",
42
+ "typescript": "^5.3.3",
43
+ "uuid": "^9.0.1",
44
+ "winston": "^3.13.0",
45
+ "winston-daily-rotate-file": "^5.0.0"
46
+ },
47
+ "devDependencies": {
48
+ "@types/uuid": "^9.0.8",
49
+ "del-cli": "^5.1.0",
50
+ "eslint": "^8.56.0",
51
+ "eslint-config-prettier": "^9.1.0",
52
+ "eslint-plugin-import": "^2.29.1",
53
+ "eslint-plugin-prettier": "^5.1.3",
54
+ "prettier": "^3.2.4"
55
+ },
56
+ "description": ""
57
+ }