@alba-cars/common-modules 1.7.8 → 1.8.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.
@@ -54,6 +54,7 @@ type APIEndpointType = {
54
54
  googleReview: BaseEndpoint;
55
55
  tickets: BaseEndpoint;
56
56
  user: BaseEndpoint;
57
+ faq: BaseEndpoint;
57
58
  };
58
59
  export declare const API_ENDPOINTS: APIEndpointType;
59
60
  export declare const UTIL_ENDPOINTS: {
@@ -203,6 +203,13 @@ exports.API_ENDPOINTS = {
203
203
  deleteOne: (id) => `/tickets/${id}`,
204
204
  updateOne: (id) => `/tickets/${id}`,
205
205
  },
206
+ faq: {
207
+ getAll: `/faqs`,
208
+ create: `/faqs`,
209
+ getOne: (id) => `/faqs/${id}`,
210
+ deleteOne: (id) => `/faqs/${id}`,
211
+ updateOne: (id) => `/faqs/${id}`,
212
+ }
206
213
  };
207
214
  exports.UTIL_ENDPOINTS = {
208
215
  media: {
@@ -51,6 +51,7 @@ export declare class UserFilterDTO {
51
51
  email?: string | string[];
52
52
  name?: string | string[];
53
53
  phone?: string | string[];
54
+ isPhoneNumberVerified?: boolean;
54
55
  roles?: Role[];
55
56
  isActive?: boolean;
56
57
  fromDate?: Date;
@@ -165,6 +165,11 @@ __decorate([
165
165
  (0, class_validator_1.IsString)({ each: true }),
166
166
  __metadata("design:type", Object)
167
167
  ], UserFilterDTO.prototype, "phone", void 0);
168
+ __decorate([
169
+ (0, class_validator_1.IsOptional)(),
170
+ (0, class_validator_1.IsBoolean)(),
171
+ __metadata("design:type", Boolean)
172
+ ], UserFilterDTO.prototype, "isPhoneNumberVerified", void 0);
168
173
  __decorate([
169
174
  (0, class_validator_1.IsOptional)(),
170
175
  (0, class_validator_1.IsArray)(),
@@ -0,0 +1,101 @@
1
+ import { FaqCategory } from "../enums";
2
+ export declare class MultilingualContentFetch {
3
+ en: string;
4
+ ar: string;
5
+ ru: string;
6
+ zh: string;
7
+ toPlain(): {
8
+ en: string;
9
+ ar: string;
10
+ ru: string;
11
+ zh: string;
12
+ };
13
+ static fromPlain(plain: any): MultilingualContentFetch;
14
+ }
15
+ export declare class FaqFilterDTO {
16
+ search?: string;
17
+ searchLanguage?: 'en' | 'ar' | 'ru' | 'zh';
18
+ searchInAnswers?: boolean;
19
+ category?: FaqCategory;
20
+ isActive?: boolean;
21
+ constructor(init?: Partial<FaqFilterDTO>);
22
+ validate(shouldValidate?: boolean): string[];
23
+ static fromPlain(plain: any): FaqFilterDTO;
24
+ static toPlain(instance: FaqFilterDTO): Record<string, unknown>;
25
+ }
26
+ export declare class FaqOptionsDTO {
27
+ page: number;
28
+ limit: number;
29
+ sort?: {
30
+ field: string;
31
+ direction: 'asc' | 'desc';
32
+ };
33
+ constructor(init?: Partial<FaqOptionsDTO>);
34
+ validate(shouldValidate?: boolean): string[];
35
+ static toPlain(instance: FaqOptionsDTO): Record<string, any>;
36
+ static fromPlain(plain: any): FaqOptionsDTO;
37
+ }
38
+ export declare class FaqFetchDTO {
39
+ filter?: FaqFilterDTO;
40
+ options?: FaqOptionsDTO;
41
+ static fromPlain(plain: any): FaqFetchDTO;
42
+ constructor(init?: Partial<FaqFetchDTO>);
43
+ static toPlain(instance: FaqFetchDTO): Record<string, unknown>;
44
+ }
45
+ export declare class FaqResponseDTO {
46
+ id: string;
47
+ question: MultilingualContentFetch;
48
+ answer: MultilingualContentFetch;
49
+ category: string;
50
+ isActive: boolean;
51
+ order: number;
52
+ createdAt: string;
53
+ updatedAt: string;
54
+ toPlain(): {
55
+ id: string;
56
+ question: {
57
+ en: string;
58
+ ar: string;
59
+ ru: string;
60
+ zh: string;
61
+ };
62
+ answer: {
63
+ en: string;
64
+ ar: string;
65
+ ru: string;
66
+ zh: string;
67
+ };
68
+ category: string;
69
+ isActive: boolean;
70
+ order: number;
71
+ createdAt: string;
72
+ updatedAt: string;
73
+ };
74
+ static fromPlain(plain: Record<string, any>): FaqResponseDTO;
75
+ validate(): string[];
76
+ }
77
+ export interface FaqApiResponse {
78
+ success: boolean;
79
+ message?: string;
80
+ error?: {
81
+ message: string;
82
+ code?: string;
83
+ details?: Record<string, any>;
84
+ };
85
+ data?: FaqResponseDTO;
86
+ }
87
+ export interface FaqListApiResponse {
88
+ success: boolean;
89
+ message?: string;
90
+ error?: {
91
+ message: string;
92
+ code?: string;
93
+ details?: Record<string, any>;
94
+ };
95
+ data?: {
96
+ items: FaqResponseDTO[];
97
+ total: number;
98
+ page: number;
99
+ limit: number;
100
+ };
101
+ }
@@ -0,0 +1,348 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.FaqResponseDTO = exports.FaqFetchDTO = exports.FaqOptionsDTO = exports.FaqFilterDTO = exports.MultilingualContentFetch = void 0;
13
+ const class_transformer_1 = require("class-transformer");
14
+ const class_validator_1 = require("class-validator");
15
+ const enums_1 = require("../enums");
16
+ class MultilingualContentFetch {
17
+ toPlain() {
18
+ return {
19
+ en: this.en,
20
+ ar: this.ar,
21
+ ru: this.ru,
22
+ zh: this.zh
23
+ };
24
+ }
25
+ static fromPlain(plain) {
26
+ const content = new MultilingualContentFetch();
27
+ content.en = plain.en;
28
+ content.ar = plain.ar;
29
+ content.ru = plain.ru;
30
+ content.zh = plain.zh;
31
+ return content;
32
+ }
33
+ }
34
+ __decorate([
35
+ (0, class_validator_1.IsNotEmpty)(),
36
+ (0, class_validator_1.IsString)(),
37
+ __metadata("design:type", String)
38
+ ], MultilingualContentFetch.prototype, "en", void 0);
39
+ __decorate([
40
+ (0, class_validator_1.IsNotEmpty)(),
41
+ (0, class_validator_1.IsString)(),
42
+ __metadata("design:type", String)
43
+ ], MultilingualContentFetch.prototype, "ar", void 0);
44
+ __decorate([
45
+ (0, class_validator_1.IsNotEmpty)(),
46
+ (0, class_validator_1.IsString)(),
47
+ __metadata("design:type", String)
48
+ ], MultilingualContentFetch.prototype, "ru", void 0);
49
+ __decorate([
50
+ (0, class_validator_1.IsNotEmpty)(),
51
+ (0, class_validator_1.IsString)(),
52
+ __metadata("design:type", String)
53
+ ], MultilingualContentFetch.prototype, "zh", void 0);
54
+ exports.MultilingualContentFetch = MultilingualContentFetch;
55
+ class FaqFilterDTO {
56
+ constructor(init) {
57
+ Object.assign(this, init);
58
+ }
59
+ validate(shouldValidate = true) {
60
+ const errors = [];
61
+ if (shouldValidate) {
62
+ if (this.category && !Object.values(enums_1.FaqCategory).includes(this.category)) {
63
+ errors.push(`Invalid category: ${this.category}. Valid categories are: ${Object.values(enums_1.FaqCategory).join(', ')}`);
64
+ }
65
+ if (this.searchLanguage && !['en', 'ar', 'ru', 'zh'].includes(this.searchLanguage)) {
66
+ errors.push(`Invalid search language: ${this.searchLanguage}. Valid languages are: en, ar, ru, zh`);
67
+ }
68
+ }
69
+ return errors;
70
+ }
71
+ static fromPlain(plain) {
72
+ const dto = new FaqFilterDTO();
73
+ if (plain) {
74
+ dto.search = plain.search;
75
+ dto.searchLanguage = plain.searchLanguage;
76
+ dto.searchInAnswers = plain.searchInAnswers;
77
+ // Handle category
78
+ if (plain.category) {
79
+ const categoryValue = plain.category.value || plain.category;
80
+ if (Object.values(enums_1.FaqCategory).includes(categoryValue)) {
81
+ dto.category = categoryValue;
82
+ }
83
+ }
84
+ // Handle boolean conversions
85
+ if (typeof plain.isActive === 'string') {
86
+ dto.isActive = plain.isActive.toLowerCase() === 'true';
87
+ }
88
+ else {
89
+ dto.isActive = plain.isActive;
90
+ }
91
+ if (typeof plain.searchInAnswers === 'string') {
92
+ dto.searchInAnswers = plain.searchInAnswers.toLowerCase() === 'true';
93
+ }
94
+ else {
95
+ dto.searchInAnswers = plain.searchInAnswers;
96
+ }
97
+ }
98
+ return dto;
99
+ }
100
+ static toPlain(instance) {
101
+ return (0, class_transformer_1.instanceToPlain)(instance);
102
+ }
103
+ }
104
+ __decorate([
105
+ (0, class_validator_1.IsOptional)(),
106
+ (0, class_validator_1.IsString)(),
107
+ __metadata("design:type", String)
108
+ ], FaqFilterDTO.prototype, "search", void 0);
109
+ __decorate([
110
+ (0, class_validator_1.IsOptional)(),
111
+ (0, class_validator_1.IsString)(),
112
+ __metadata("design:type", String)
113
+ ], FaqFilterDTO.prototype, "searchLanguage", void 0);
114
+ __decorate([
115
+ (0, class_validator_1.IsOptional)(),
116
+ (0, class_validator_1.IsBoolean)(),
117
+ __metadata("design:type", Boolean)
118
+ ], FaqFilterDTO.prototype, "searchInAnswers", void 0);
119
+ __decorate([
120
+ (0, class_validator_1.IsOptional)(),
121
+ (0, class_validator_1.IsEnum)(enums_1.FaqCategory, { message: 'Invalid category provided' }),
122
+ __metadata("design:type", String)
123
+ ], FaqFilterDTO.prototype, "category", void 0);
124
+ __decorate([
125
+ (0, class_validator_1.IsOptional)(),
126
+ (0, class_validator_1.IsBoolean)(),
127
+ __metadata("design:type", Boolean)
128
+ ], FaqFilterDTO.prototype, "isActive", void 0);
129
+ exports.FaqFilterDTO = FaqFilterDTO;
130
+ class SortDTO {
131
+ }
132
+ __decorate([
133
+ (0, class_validator_1.IsString)(),
134
+ __metadata("design:type", String)
135
+ ], SortDTO.prototype, "field", void 0);
136
+ __decorate([
137
+ (0, class_validator_1.IsString)(),
138
+ __metadata("design:type", String)
139
+ ], SortDTO.prototype, "direction", void 0);
140
+ class FaqOptionsDTO {
141
+ constructor(init) {
142
+ this.page = 1;
143
+ this.limit = 10;
144
+ Object.assign(this, init);
145
+ }
146
+ validate(shouldValidate = true) {
147
+ const errors = [];
148
+ if (shouldValidate) {
149
+ // Validate page
150
+ if (this.page < 1) {
151
+ errors.push('Page must be greater than 0');
152
+ }
153
+ // Validate limit
154
+ if (this.limit < 1) {
155
+ errors.push('Limit must be greater than 0');
156
+ }
157
+ if (this.limit > 100) {
158
+ errors.push('Limit cannot exceed 100');
159
+ }
160
+ // Validate sort if present
161
+ if (this.sort) {
162
+ if (!this.sort.field) {
163
+ errors.push('Sort field is required when sort is provided');
164
+ }
165
+ if (this.sort.direction && !['asc', 'desc'].includes(this.sort.direction.toLowerCase())) {
166
+ errors.push('Sort direction must be either "asc" or "desc"');
167
+ }
168
+ }
169
+ }
170
+ return errors;
171
+ }
172
+ static toPlain(instance) {
173
+ return (0, class_transformer_1.instanceToPlain)(instance);
174
+ }
175
+ static fromPlain(plain) {
176
+ var _a;
177
+ const dto = new FaqOptionsDTO();
178
+ if (plain) {
179
+ // Convert and validate page
180
+ dto.page = plain.page ? Number(plain.page) : 1;
181
+ // Convert and validate limit
182
+ dto.limit = plain.limit ? Number(plain.limit) : 10;
183
+ // Handle sort if present
184
+ if (plain.sort) {
185
+ dto.sort = {
186
+ field: plain.sort.field,
187
+ direction: (_a = plain.sort.direction) === null || _a === void 0 ? void 0 : _a.toLowerCase()
188
+ };
189
+ }
190
+ }
191
+ return dto;
192
+ }
193
+ }
194
+ __decorate([
195
+ (0, class_validator_1.IsNumber)(),
196
+ (0, class_validator_1.Min)(1),
197
+ __metadata("design:type", Number)
198
+ ], FaqOptionsDTO.prototype, "page", void 0);
199
+ __decorate([
200
+ (0, class_transformer_1.Type)(() => SortDTO),
201
+ (0, class_validator_1.IsNumber)(),
202
+ (0, class_validator_1.Min)(1),
203
+ (0, class_validator_1.Max)(100) // Optional: add max limit to prevent excessive requests
204
+ ,
205
+ __metadata("design:type", Number)
206
+ ], FaqOptionsDTO.prototype, "limit", void 0);
207
+ __decorate([
208
+ (0, class_validator_1.IsOptional)(),
209
+ (0, class_validator_1.ValidateNested)(),
210
+ (0, class_transformer_1.Type)(() => SortDTO),
211
+ __metadata("design:type", Object)
212
+ ], FaqOptionsDTO.prototype, "sort", void 0);
213
+ exports.FaqOptionsDTO = FaqOptionsDTO;
214
+ class FaqFetchDTO {
215
+ static fromPlain(plain) {
216
+ return (0, class_transformer_1.plainToClass)(FaqFetchDTO, {
217
+ filter: plain.filter,
218
+ options: plain.options
219
+ });
220
+ }
221
+ constructor(init) {
222
+ Object.assign(this, init);
223
+ }
224
+ static toPlain(instance) {
225
+ return (0, class_transformer_1.instanceToPlain)(instance);
226
+ }
227
+ }
228
+ __decorate([
229
+ (0, class_transformer_1.Type)(() => FaqFilterDTO),
230
+ (0, class_validator_1.ValidateNested)(),
231
+ (0, class_validator_1.IsOptional)(),
232
+ __metadata("design:type", FaqFilterDTO)
233
+ ], FaqFetchDTO.prototype, "filter", void 0);
234
+ __decorate([
235
+ (0, class_transformer_1.Type)(() => FaqOptionsDTO),
236
+ (0, class_validator_1.ValidateNested)(),
237
+ (0, class_validator_1.IsOptional)(),
238
+ __metadata("design:type", FaqOptionsDTO)
239
+ ], FaqFetchDTO.prototype, "options", void 0);
240
+ exports.FaqFetchDTO = FaqFetchDTO;
241
+ class FaqResponseDTO {
242
+ toPlain() {
243
+ return {
244
+ id: this.id,
245
+ question: this.question.toPlain(),
246
+ answer: this.answer.toPlain(),
247
+ category: this.category,
248
+ isActive: this.isActive,
249
+ order: this.order,
250
+ createdAt: this.createdAt,
251
+ updatedAt: this.updatedAt
252
+ };
253
+ }
254
+ static fromPlain(plain) {
255
+ if (!plain) {
256
+ throw new Error('Cannot create FaqResponseDTO from null or undefined');
257
+ }
258
+ const dto = new FaqResponseDTO();
259
+ try {
260
+ dto.id = plain.id;
261
+ dto.question = MultilingualContentFetch.fromPlain(plain.question);
262
+ dto.answer = MultilingualContentFetch.fromPlain(plain.answer);
263
+ dto.category = plain.category;
264
+ dto.isActive = Boolean(plain.isActive);
265
+ dto.order = Number(plain.order);
266
+ dto.createdAt = plain.createdAt;
267
+ dto.updatedAt = plain.updatedAt;
268
+ return dto;
269
+ }
270
+ catch (error) {
271
+ if (error instanceof Error) {
272
+ throw new Error(`Failed to create FaqResponseDTO: ${error.message}`);
273
+ }
274
+ else {
275
+ throw new Error('Failed to create FaqResponseDTO: Unknown error');
276
+ }
277
+ }
278
+ }
279
+ // Optional: Add a validate method if needed
280
+ validate() {
281
+ const errors = [];
282
+ if (!this.id)
283
+ errors.push('ID is required');
284
+ if (!this.question)
285
+ errors.push('Question is required');
286
+ if (!this.answer)
287
+ errors.push('Answer is required');
288
+ if (!this.category)
289
+ errors.push('Category is required');
290
+ if (this.isActive === undefined)
291
+ errors.push('isActive is required');
292
+ if (this.order === undefined)
293
+ errors.push('Order is required');
294
+ if (!this.createdAt)
295
+ errors.push('CreatedAt is required');
296
+ if (!this.updatedAt)
297
+ errors.push('UpdatedAt is required');
298
+ // Add any additional validation logic here
299
+ return errors;
300
+ }
301
+ }
302
+ __decorate([
303
+ (0, class_validator_1.IsString)(),
304
+ (0, class_validator_1.IsNotEmpty)(),
305
+ __metadata("design:type", String)
306
+ ], FaqResponseDTO.prototype, "id", void 0);
307
+ __decorate([
308
+ (0, class_validator_1.ValidateNested)(),
309
+ (0, class_transformer_1.Type)(() => MultilingualContentFetch),
310
+ (0, class_validator_1.IsNotEmpty)(),
311
+ __metadata("design:type", MultilingualContentFetch)
312
+ ], FaqResponseDTO.prototype, "question", void 0);
313
+ __decorate([
314
+ (0, class_validator_1.ValidateNested)(),
315
+ (0, class_transformer_1.Type)(() => MultilingualContentFetch),
316
+ (0, class_validator_1.IsNotEmpty)(),
317
+ __metadata("design:type", MultilingualContentFetch)
318
+ ], FaqResponseDTO.prototype, "answer", void 0);
319
+ __decorate([
320
+ (0, class_validator_1.IsString)(),
321
+ (0, class_validator_1.IsNotEmpty)(),
322
+ (0, class_validator_1.IsEnum)(enums_1.FaqCategory) // Add enum validation if you have FaqCategory enum
323
+ ,
324
+ __metadata("design:type", String)
325
+ ], FaqResponseDTO.prototype, "category", void 0);
326
+ __decorate([
327
+ (0, class_validator_1.IsBoolean)(),
328
+ (0, class_validator_1.IsNotEmpty)(),
329
+ __metadata("design:type", Boolean)
330
+ ], FaqResponseDTO.prototype, "isActive", void 0);
331
+ __decorate([
332
+ (0, class_validator_1.IsNumber)(),
333
+ (0, class_validator_1.IsNotEmpty)(),
334
+ (0, class_validator_1.Min)(0) // Add minimum value validation
335
+ ,
336
+ __metadata("design:type", Number)
337
+ ], FaqResponseDTO.prototype, "order", void 0);
338
+ __decorate([
339
+ (0, class_validator_1.IsString)(),
340
+ (0, class_validator_1.IsNotEmpty)(),
341
+ __metadata("design:type", String)
342
+ ], FaqResponseDTO.prototype, "createdAt", void 0);
343
+ __decorate([
344
+ (0, class_validator_1.IsString)(),
345
+ (0, class_validator_1.IsNotEmpty)(),
346
+ __metadata("design:type", String)
347
+ ], FaqResponseDTO.prototype, "updatedAt", void 0);
348
+ exports.FaqResponseDTO = FaqResponseDTO;
@@ -1,2 +1,3 @@
1
1
  export * from "./CreateFaqDTO";
2
2
  export * from "./UpdateFaqDTO";
3
+ export * from "./FaqFetchDTO";
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./CreateFaqDTO"), exports);
18
18
  __exportStar(require("./UpdateFaqDTO"), exports);
19
+ __exportStar(require("./FaqFetchDTO"), exports);
@@ -36,7 +36,6 @@ export declare class FinanceEligibilityRequestCreateDTO {
36
36
  employeeCount: EmployeeCount;
37
37
  isCompanyOlderThanOneYear: boolean;
38
38
  hasLandline: YesNo;
39
- eligibility: EligibilityStatus;
40
39
  documents?: string[];
41
40
  static fromPlain(plain: Record<string, unknown>): FinanceEligibilityRequestCreateDTO;
42
41
  toPlain(): Record<string, unknown>;
@@ -117,10 +117,6 @@ __decorate([
117
117
  (0, class_validator_1.IsEnum)(YesNo),
118
118
  __metadata("design:type", String)
119
119
  ], FinanceEligibilityRequestCreateDTO.prototype, "hasLandline", void 0);
120
- __decorate([
121
- (0, class_validator_1.IsEnum)(EligibilityStatus),
122
- __metadata("design:type", Number)
123
- ], FinanceEligibilityRequestCreateDTO.prototype, "eligibility", void 0);
124
120
  __decorate([
125
121
  (0, class_validator_1.IsOptional)(),
126
122
  (0, class_validator_1.IsString)({ each: true }),
@@ -14,6 +14,7 @@ export interface User {
14
14
  lastLogin?: Date;
15
15
  createdAt: Date;
16
16
  updatedAt: Date;
17
+ isPhoneNumberVerified: boolean;
17
18
  vehicleFavorites?: UserFavoriteVehicle[];
18
19
  favoriteVehicles?: Vehicle[];
19
20
  deposits?: Deposit[];
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.7.8",
6
+ "version": "1.8.0",
7
7
  "description": "A package containing DTOs, validation classes and common modules and interfaces for Alba Cars",
8
8
  "main": "dist/index.js",
9
9
  "types": "dist/index.d.ts",
@@ -33,6 +33,7 @@
33
33
  "url": "git+https://github.com/alba-cars/AlbaCarsCommonModules.git"
34
34
  },
35
35
  "dependencies": {
36
+ "@alba-cars/common-modules": "^1.7.4",
36
37
  "axios": "^1.7.9",
37
38
  "class-transformer": "^0.5.1",
38
39
  "class-validator": "^0.14.1",