@alba-cars/common-modules 1.2.3 → 1.2.5

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.
Files changed (56) hide show
  1. package/dist/core/models/pagination/paginated_data.d.ts +18 -3
  2. package/dist/core/models/pagination/paginated_data.js +19 -0
  3. package/dist/core/network/endpoint-config.js +11 -11
  4. package/dist/core/network/fetch-api.d.ts +1 -1
  5. package/dist/core/network/fetch-api.js +4 -2
  6. package/dist/core/utils/global-utils.d.ts +73 -7
  7. package/dist/core/utils/global-utils.js +112 -9
  8. package/dist/core/utils/query_flatten.d.ts +1 -0
  9. package/dist/core/utils/query_flatten.js +15 -0
  10. package/dist/features/sales-team/api/GetAgent.d.ts +1 -1
  11. package/dist/features/vehicle/api/body_types/CreateBodyType.d.ts +2 -0
  12. package/dist/features/vehicle/api/body_types/CreateBodyType.js +22 -0
  13. package/dist/features/vehicle/api/body_types/DeleteBodyType.d.ts +2 -0
  14. package/dist/features/vehicle/api/body_types/DeleteBodyType.js +17 -0
  15. package/dist/features/vehicle/api/body_types/GetAllBodyTypes.d.ts +3 -0
  16. package/dist/features/vehicle/api/body_types/GetAllBodyTypes.js +26 -0
  17. package/dist/features/vehicle/api/body_types/UpdateBodyType.d.ts +2 -0
  18. package/dist/features/vehicle/api/body_types/UpdateBodyType.js +22 -0
  19. package/dist/features/vehicle/api/body_types/index.d.ts +4 -0
  20. package/dist/features/vehicle/api/body_types/index.js +20 -0
  21. package/dist/features/vehicle/api/index.d.ts +3 -0
  22. package/dist/features/vehicle/api/index.js +19 -0
  23. package/dist/features/vehicle/api/make/CreateMake.d.ts +2 -0
  24. package/dist/features/vehicle/api/make/CreateMake.js +21 -0
  25. package/dist/features/vehicle/api/make/DeleteMake.d.ts +2 -0
  26. package/dist/features/vehicle/api/make/DeleteMake.js +16 -0
  27. package/dist/features/vehicle/api/make/GetAllMakes.d.ts +3 -0
  28. package/dist/features/vehicle/api/make/GetAllMakes.js +25 -0
  29. package/dist/features/vehicle/api/make/GetOneMake.d.ts +2 -0
  30. package/dist/features/vehicle/api/make/GetOneMake.js +16 -0
  31. package/dist/features/vehicle/api/make/UpdateMake.d.ts +1 -1
  32. package/dist/features/vehicle/api/make/UpdateMake.js +9 -4
  33. package/dist/features/vehicle/api/make/index.d.ts +5 -0
  34. package/dist/features/vehicle/api/make/index.js +21 -0
  35. package/dist/features/vehicle/api/models/CreateModel.d.ts +2 -0
  36. package/dist/features/vehicle/api/models/CreateModel.js +21 -0
  37. package/dist/features/vehicle/api/models/DeleteModel.d.ts +2 -0
  38. package/dist/features/vehicle/api/models/DeleteModel.js +16 -0
  39. package/dist/features/vehicle/api/models/GetAllModels.d.ts +3 -0
  40. package/dist/features/vehicle/api/models/GetAllModels.js +36 -0
  41. package/dist/features/vehicle/api/models/UpdateModel.d.ts +2 -0
  42. package/dist/features/vehicle/api/models/UpdateModel.js +21 -0
  43. package/dist/features/vehicle/api/models/index.d.ts +4 -0
  44. package/dist/features/vehicle/api/models/index.js +20 -0
  45. package/dist/features/vehicle/data/dto/VehicleDTO.d.ts +2 -1
  46. package/dist/features/vehicle/data/dto/VehicleDTO.js +10 -3
  47. package/dist/features/vehicle/data/dto/VehicleMakeDTO.d.ts +2 -0
  48. package/dist/features/vehicle/data/dto/VehicleModelDTO.d.ts +1 -3
  49. package/dist/features/vehicle/data/dto/VehicleModelDTO.js +0 -7
  50. package/dist/features/vehicle/data/utilities.d.ts +4 -2
  51. package/dist/features/vehicle/data/utilities.js +22 -6
  52. package/dist/features/vehicle/index.d.ts +1 -0
  53. package/dist/features/vehicle/index.js +1 -0
  54. package/dist/models.d.ts +1 -2
  55. package/dist/models.js +15 -0
  56. package/package.json +3 -2
@@ -1,6 +1,21 @@
1
- export interface PaginatedData<T> {
2
- result: T[];
1
+ import { AppError } from "../../error-handling";
2
+ export declare class DataReturnType<Data = unknown> {
3
+ constructor(success: boolean, message?: string, data?: Data, error?: AppError);
4
+ success: boolean;
5
+ message?: string;
6
+ data?: Data;
7
+ error?: AppError;
8
+ }
9
+ export interface PaginatedData<Data = unknown> {
10
+ result: Data;
11
+ limit: number;
3
12
  total: number;
4
13
  page: number;
5
- limit: number;
14
+ }
15
+ export declare class ReturnTypeWithPagination<Data = unknown> {
16
+ success: boolean;
17
+ message?: string | undefined;
18
+ data?: PaginatedData<Data> | undefined;
19
+ error?: AppError | undefined;
20
+ constructor(success: boolean, message?: string | undefined, data?: PaginatedData<Data> | undefined, error?: AppError | undefined);
6
21
  }
@@ -1,2 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReturnTypeWithPagination = exports.DataReturnType = void 0;
4
+ class DataReturnType {
5
+ constructor(success, message, data, error) {
6
+ this.success = success;
7
+ this.message = message;
8
+ this.data = data;
9
+ this.error = error;
10
+ }
11
+ }
12
+ exports.DataReturnType = DataReturnType;
13
+ class ReturnTypeWithPagination {
14
+ constructor(success, message, data, error) {
15
+ this.success = success;
16
+ this.message = message;
17
+ this.data = data;
18
+ this.error = error;
19
+ }
20
+ }
21
+ exports.ReturnTypeWithPagination = ReturnTypeWithPagination;
@@ -26,16 +26,16 @@ exports.API_ENDPOINTS = {
26
26
  vehicleMake: {
27
27
  getAll: `/vehicle/makes`,
28
28
  create: `/vehicle/makes`,
29
- getOne: (id) => `/vehiclemake/${id}`,
30
- deleteOne: (id) => `/vehiclemake/${id}`,
31
- updateOne: (id) => `/vehiclemake/${id}`,
29
+ getOne: (id) => `/vehicle/makes/${id}`,
30
+ deleteOne: (id) => `/vehicle/makes/${id}`,
31
+ updateOne: (id) => `/vehicle/makes/${id}`,
32
32
  },
33
33
  vehicleModel: {
34
34
  getAll: `/vehicle/models`,
35
35
  create: `/vehicle/models`,
36
- getOne: (id) => `/vehiclemodel/${id}`,
37
- deleteOne: (id) => `/vehiclemodel/${id}`,
38
- updateOne: (id) => `/vehiclemodel/${id}`,
36
+ getOne: (id) => `/vehicle/models/${id}`,
37
+ deleteOne: (id) => `/vehicle/models/${id}`,
38
+ updateOne: (id) => `/vehicle/models/${id}`,
39
39
  },
40
40
  TestDrive: {
41
41
  getAll: `/test-drive-requests`,
@@ -52,11 +52,11 @@ exports.API_ENDPOINTS = {
52
52
  updateOne: (id) => `/vehicleorder/${id}`,
53
53
  },
54
54
  vehicleType: {
55
- getAll: `/body-types`,
56
- create: `/body-types`,
57
- getOne: (id) => `/body-types/${id}`,
58
- deleteOne: (id) => `/body-types/${id}`,
59
- updateOne: (id) => `/body-types/${id}`,
55
+ getAll: `/vehicle/body-types`,
56
+ create: `/vehicle/body-types`,
57
+ getOne: (id) => `/vehicle/body-types/${id}`,
58
+ deleteOne: (id) => `/vehicle/body-types/${id}`,
59
+ updateOne: (id) => `/vehicle/body-types/${id}`,
60
60
  },
61
61
  carOptions: {
62
62
  getAll: `/caroptions`,
@@ -1,6 +1,6 @@
1
1
  interface ApiRequestOptions extends RequestInit {
2
2
  headers?: Record<string, string>;
3
- query?: Record<string, string>;
3
+ query?: Record<string, any>;
4
4
  }
5
5
  export declare function apiRequest<T>(endpoint: string, options?: ApiRequestOptions): Promise<T>;
6
6
  export {};
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.apiRequest = void 0;
7
- const querystring_1 = __importDefault(require("querystring"));
7
+ const qs_1 = __importDefault(require("qs"));
8
8
  const utils_1 = require("../utils");
9
9
  const enums_1 = require("../enums");
10
10
  const BASE_URL = process.env.NEXT_PUBLIC_API_URL;
@@ -27,7 +27,9 @@ async function apiRequest(endpoint, options = {}) {
27
27
  options.method && options.method !== enums_1.HttpMethods.GET && console.log(`${BASE_URL}${endpoint}`);
28
28
  let url = `${BASE_URL}${endpoint}`;
29
29
  if (options.query && Object.keys(options.query).length > 0) {
30
- url += `?${querystring_1.default.stringify(options.query)}`;
30
+ console.log("Raw params ", options.query);
31
+ console.log("Stringified params = ", qs_1.default.stringify(options.query));
32
+ url += `?${qs_1.default.stringify(options.query, { allowDots: true, arrayFormat: 'brackets', allowEmptyArrays: false, skipNulls: true })}`;
31
33
  }
32
34
  const response = await fetch(url, config);
33
35
  // Parse the response once and store it
@@ -1,10 +1,4 @@
1
- /**
2
- * Converts a value to an array.
3
- *
4
- * @param value - The value to convert.
5
- * @returns An array containing the value, or the value itself if it is already an array.
6
- */
7
- export declare const makeArray: <T>(value: T) => T[];
1
+ import { Booleanish } from "../../global";
8
2
  /**
9
3
  * Deeply compares two objects for equality.
10
4
  *
@@ -39,4 +33,76 @@ type ComparatorFunction = (_a: any, _b: any) => number;
39
33
  export declare const sortBy: (array: any[], key: string | ComparatorFunction) => any[];
40
34
  export declare function generateRandomBase64(length: number): string;
41
35
  export declare const formatValue: (n: number | string) => string;
36
+ interface TimeInput {
37
+ minutes?: number;
38
+ hours?: number;
39
+ seconds?: number;
40
+ }
41
+ /**
42
+ * Converts a time input to milliseconds
43
+ */
44
+ export declare const timeAsMilliseconds: ({ minutes, hours, seconds }: TimeInput) => number;
45
+ /**
46
+ * Converts a time input to seconds
47
+ */
48
+ export declare const timeAsSeconds: ({ minutes, hours, seconds }: TimeInput) => number;
49
+ /**
50
+ * Removes a key from an object or an array of objects (deeply)
51
+ */
52
+ export declare function removeKeyFromObject(obj: any, keyToRemove: string): unknown;
53
+ /**
54
+ * Formats a number as a currency string (AED)
55
+ */
56
+ export declare const currencyFormatter: ({ isDecimal, decimalPlaces }: {
57
+ isDecimal: boolean;
58
+ decimalPlaces: number;
59
+ }) => Intl.NumberFormat;
60
+ /**
61
+ * Safely parses a string or number into a number
62
+ */
63
+ export declare const safeParseNumber: (value: string | number) => number;
64
+ /**
65
+ * Formats a number with commas
66
+ */
67
+ export declare const formatNumberWithCommas: (value: string) => string;
68
+ /**
69
+ * Converts a single value or an array of values into an array
70
+ */
71
+ export declare const makeArray: <T>(value: T | T[]) => T[];
72
+ /**
73
+ * Check if a value is empty (nullable or empty string)
74
+ */
75
+ export declare const isEmpty: (value: any) => boolean;
76
+ /**
77
+ * Check if an object is an empty object
78
+ */
79
+ export declare const isEmptyObject: (value: Record<string, any>) => boolean;
80
+ /**
81
+ * Check if a value is an empty array
82
+ */
83
+ export declare const isEmptyArray: (value: any) => boolean;
84
+ /**
85
+ * Checks if a value is not empty (null, undefined, or empty string), not an empty object, and not an empty array
86
+ */
87
+ export declare const hasValue: (value: any) => boolean;
88
+ /**
89
+ * Returns a pluralized string based on the value
90
+ * @example getPlural(1, 'item') => '1 item'
91
+ * @example getPlural(4, 'item') => '4 items'
92
+ * @example getPlural(2, 'person', 'people') => '2 people'
93
+ * @example getPlural(0, 'item') => '0 items'
94
+ */
95
+ export declare const getPlural: (value: number, singular: string, plural?: string | null) => string;
96
+ /**
97
+ * Escapes special characters in a search term to prevent them from being interpreted as regex operators
98
+ */
99
+ export declare const sanitizeRegexString: (input: string) => string;
100
+ /**
101
+ * Converts a value to a plain object by serializing to and from JSON
102
+ */
103
+ export declare const toPlainObject: (value: unknown) => Record<string, any>;
104
+ /**
105
+ * Converts a Booleanish value (boolean | 'true' | '1' | 'false' | '0') to a boolean
106
+ */
107
+ export declare const booleanize: (value: Booleanish) => boolean;
42
108
  export {};
@@ -1,14 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formatValue = exports.generateRandomBase64 = exports.sortBy = exports.isFunction = exports.isPlainObject = exports.deepEqual = exports.makeArray = void 0;
4
- /**
5
- * Converts a value to an array.
6
- *
7
- * @param value - The value to convert.
8
- * @returns An array containing the value, or the value itself if it is already an array.
9
- */
10
- const makeArray = (value) => (Array.isArray(value) ? value : [value]);
11
- exports.makeArray = makeArray;
3
+ exports.booleanize = exports.toPlainObject = exports.sanitizeRegexString = exports.getPlural = exports.hasValue = exports.isEmptyArray = exports.isEmptyObject = exports.isEmpty = exports.makeArray = exports.formatNumberWithCommas = exports.safeParseNumber = exports.currencyFormatter = exports.removeKeyFromObject = exports.timeAsSeconds = exports.timeAsMilliseconds = exports.formatValue = exports.generateRandomBase64 = exports.sortBy = exports.isFunction = exports.isPlainObject = exports.deepEqual = void 0;
12
4
  /**
13
5
  * Deeply compares two objects for equality.
14
6
  *
@@ -85,3 +77,114 @@ const formatValue = (n) => {
85
77
  .replace(/\B(?=(\d{3})+(?!\d))/g, ",");
86
78
  };
87
79
  exports.formatValue = formatValue;
80
+ /**
81
+ * Converts a time input to milliseconds
82
+ */
83
+ const timeAsMilliseconds = ({ minutes = 0, hours = 0, seconds = 0 }) => {
84
+ return minutes * 60 * 1000 + hours * 60 * 60 * 1000 + seconds * 1000;
85
+ };
86
+ exports.timeAsMilliseconds = timeAsMilliseconds;
87
+ /**
88
+ * Converts a time input to seconds
89
+ */
90
+ const timeAsSeconds = ({ minutes = 0, hours = 0, seconds = 0 }) => {
91
+ return minutes * 60 + hours * 60 * 60 + seconds;
92
+ };
93
+ exports.timeAsSeconds = timeAsSeconds;
94
+ /**
95
+ * Removes a key from an object or an array of objects (deeply)
96
+ */
97
+ function removeKeyFromObject(obj, keyToRemove) {
98
+ if (Array.isArray(obj)) {
99
+ return obj.map((item) => removeKeyFromObject(item, keyToRemove));
100
+ }
101
+ else if (typeof obj === "object" && obj !== null) {
102
+ return Object.keys(obj).reduce((acc, key) => {
103
+ if (key !== keyToRemove) {
104
+ acc[key] = removeKeyFromObject(obj[key], keyToRemove);
105
+ }
106
+ return acc;
107
+ }, {});
108
+ }
109
+ return obj;
110
+ }
111
+ exports.removeKeyFromObject = removeKeyFromObject;
112
+ /**
113
+ * Formats a number as a currency string (AED)
114
+ */
115
+ const currencyFormatter = ({ isDecimal, decimalPlaces = 2 }) => new Intl.NumberFormat('en-US', {
116
+ style: "currency",
117
+ currency: "AED",
118
+ maximumFractionDigits: isDecimal ? decimalPlaces : 0,
119
+ });
120
+ exports.currencyFormatter = currencyFormatter;
121
+ /**
122
+ * Safely parses a string or number into a number
123
+ */
124
+ const safeParseNumber = (value) => {
125
+ if (typeof value === 'number')
126
+ return value;
127
+ if (typeof value !== 'string')
128
+ return 0;
129
+ return Number(value.trim().replace(/,/g, '')) || 0;
130
+ };
131
+ exports.safeParseNumber = safeParseNumber;
132
+ /**
133
+ * Formats a number with commas
134
+ */
135
+ const formatNumberWithCommas = (value) => {
136
+ const number = value.replace(/[^\d]/g, '');
137
+ return number.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
138
+ };
139
+ exports.formatNumberWithCommas = formatNumberWithCommas;
140
+ /**
141
+ * Converts a single value or an array of values into an array
142
+ */
143
+ const makeArray = (value) => {
144
+ return Array.isArray(value) ? value : [value];
145
+ };
146
+ exports.makeArray = makeArray;
147
+ /**
148
+ * Check if a value is empty (nullable or empty string)
149
+ */
150
+ const isEmpty = (value) => (value === null || value === undefined || value === '');
151
+ exports.isEmpty = isEmpty;
152
+ /**
153
+ * Check if an object is an empty object
154
+ */
155
+ const isEmptyObject = (value) => Object.keys(value).length === 0 && value.constructor === Object;
156
+ exports.isEmptyObject = isEmptyObject;
157
+ /**
158
+ * Check if a value is an empty array
159
+ */
160
+ const isEmptyArray = (value) => Array.isArray(value) && value.length === 0;
161
+ exports.isEmptyArray = isEmptyArray;
162
+ /**
163
+ * Checks if a value is not empty (null, undefined, or empty string), not an empty object, and not an empty array
164
+ */
165
+ const hasValue = (value) => !(0, exports.isEmpty)(value) && !(0, exports.isEmptyObject)(value) && !(0, exports.isEmptyArray)(value);
166
+ exports.hasValue = hasValue;
167
+ /**
168
+ * Returns a pluralized string based on the value
169
+ * @example getPlural(1, 'item') => '1 item'
170
+ * @example getPlural(4, 'item') => '4 items'
171
+ * @example getPlural(2, 'person', 'people') => '2 people'
172
+ * @example getPlural(0, 'item') => '0 items'
173
+ */
174
+ const getPlural = (value, singular, plural = null) => value === 1 ? `${value} ${singular}` : plural ? `${value} ${plural}` : `${value} ${singular}s`;
175
+ exports.getPlural = getPlural;
176
+ /**
177
+ * Escapes special characters in a search term to prevent them from being interpreted as regex operators
178
+ */
179
+ const sanitizeRegexString = (input) => input.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
180
+ exports.sanitizeRegexString = sanitizeRegexString;
181
+ /**
182
+ * Converts a value to a plain object by serializing to and from JSON
183
+ */
184
+ const toPlainObject = (value) => JSON.parse(JSON.stringify(value));
185
+ exports.toPlainObject = toPlainObject;
186
+ /**
187
+ * Converts a Booleanish value (boolean | 'true' | '1' | 'false' | '0') to a boolean
188
+ */
189
+ const booleanize = (value) => ([true, 'true', '1'].includes(value) ? true : false);
190
+ exports.booleanize = booleanize;
@@ -0,0 +1 @@
1
+ declare function flattenQuery(query: Record<string, any>): Record<string, any>;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ function flattenQuery(query) {
3
+ const flattened = {};
4
+ for (const key in query) {
5
+ if (typeof query[key] === "object" && query[key] !== null) {
6
+ for (const subKey in query[key]) {
7
+ flattened[subKey] = query[key][subKey];
8
+ }
9
+ }
10
+ else {
11
+ flattened[key] = query[key];
12
+ }
13
+ }
14
+ return flattened;
15
+ }
@@ -1,3 +1,3 @@
1
1
  import { SalesAgentGetDTO } from "../data/dto/SalesAgentDTO";
2
2
  import { PaginatedData } from "../../../core";
3
- export declare const fetchAgents: (page: number, searchQuery?: string) => Promise<PaginatedData<SalesAgentGetDTO>>;
3
+ export declare const fetchAgents: (page: number, searchQuery?: string) => Promise<PaginatedData<SalesAgentGetDTO[]>>;
@@ -0,0 +1,2 @@
1
+ import { VehicleBodyType, VehicleBodyTypeCreateDTO } from "../../data";
2
+ export declare const createVehicleBodyType: (vehicleBodyTypeDTO: VehicleBodyTypeCreateDTO) => Promise<VehicleBodyType>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createVehicleBodyType = void 0;
4
+ const core_1 = require("../../../../core");
5
+ const createVehicleBodyType = async (vehicleBodyTypeDTO) => {
6
+ var _a, _b;
7
+ try {
8
+ const response = await (0, core_1.apiRequest)(core_1.API_ENDPOINTS.vehicleType.create.toString(), {
9
+ method: core_1.HttpMethods.POST,
10
+ body: JSON.stringify(vehicleBodyTypeDTO)
11
+ });
12
+ if (!response.success) {
13
+ throw Error((_a = response.message) !== null && _a !== void 0 ? _a : (_b = response.error) === null || _b === void 0 ? void 0 : _b.message);
14
+ }
15
+ return response.data;
16
+ }
17
+ catch (error) {
18
+ console.error('Failed to create vehicle make:', error);
19
+ return Promise.reject(error);
20
+ }
21
+ };
22
+ exports.createVehicleBodyType = createVehicleBodyType;
@@ -0,0 +1,2 @@
1
+ import { VehicleBodyType } from "../../data";
2
+ export declare const deleteVehicleBodyType: (bodyTypeId: string) => Promise<VehicleBodyType>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteVehicleBodyType = void 0;
4
+ const core_1 = require("../../../../core");
5
+ const deleteVehicleBodyType = async (bodyTypeId) => {
6
+ try {
7
+ const response = await (0, core_1.apiRequest)(core_1.API_ENDPOINTS.vehicleType.deleteOne(bodyTypeId).toString(), {
8
+ method: core_1.HttpMethods.DELETE,
9
+ });
10
+ return response;
11
+ }
12
+ catch (error) {
13
+ console.error('Failed to delete vehicle body type:', error);
14
+ return Promise.reject(error);
15
+ }
16
+ };
17
+ exports.deleteVehicleBodyType = deleteVehicleBodyType;
@@ -0,0 +1,3 @@
1
+ import { PaginatedData } from "../../../../core";
2
+ import { VehicleBodyType } from "../../data";
3
+ export declare const getAllVehicleBodyTypes: (page: number | null, searchQuery: string | null) => Promise<PaginatedData<VehicleBodyType[]>>;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAllVehicleBodyTypes = void 0;
4
+ const core_1 = require("../../../../core");
5
+ const getAllVehicleBodyTypes = async (page, searchQuery) => {
6
+ var _a, _b, _c;
7
+ try {
8
+ const queryParams = { page: `${page}`, limit: "10" };
9
+ if ((searchQuery !== null && searchQuery !== void 0 ? searchQuery : "").trim().length > 1) {
10
+ queryParams.search = searchQuery;
11
+ }
12
+ const response = await (0, core_1.apiRequest)(core_1.API_ENDPOINTS.vehicleType.getAll.toString(), {
13
+ method: core_1.HttpMethods.GET,
14
+ query: queryParams
15
+ });
16
+ if (!response.success) {
17
+ throw Error((_a = response.message) !== null && _a !== void 0 ? _a : (_b = response.error) === null || _b === void 0 ? void 0 : _b.message);
18
+ }
19
+ return (_c = response.data) !== null && _c !== void 0 ? _c : [];
20
+ }
21
+ catch (error) {
22
+ console.error('Failed to fetch vehicle types:', error);
23
+ return Promise.reject(error);
24
+ }
25
+ };
26
+ exports.getAllVehicleBodyTypes = getAllVehicleBodyTypes;
@@ -0,0 +1,2 @@
1
+ import { VehicleBodyType, VehicleBodyTypeUpdateDTO } from "../../data";
2
+ export declare const updateVehicleBodyType: (bodyTypeId: string | number, params: VehicleBodyTypeUpdateDTO) => Promise<VehicleBodyType>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateVehicleBodyType = void 0;
4
+ const core_1 = require("../../../../core");
5
+ const updateVehicleBodyType = async (bodyTypeId, params) => {
6
+ var _a, _b;
7
+ try {
8
+ const res = await (0, core_1.apiRequest)(core_1.API_ENDPOINTS.vehicleType.updateOne(bodyTypeId), {
9
+ method: core_1.HttpMethods.PUT,
10
+ body: JSON.stringify(params),
11
+ });
12
+ if (!res.success) {
13
+ throw Error((_a = res.message) !== null && _a !== void 0 ? _a : (_b = res.error) === null || _b === void 0 ? void 0 : _b.message);
14
+ }
15
+ return res.data;
16
+ }
17
+ catch (error) {
18
+ console.log('Failed to update make with id:', bodyTypeId, 'Error:', error);
19
+ return await Promise.reject(error);
20
+ }
21
+ };
22
+ exports.updateVehicleBodyType = updateVehicleBodyType;
@@ -0,0 +1,4 @@
1
+ export * from "./CreateBodyType";
2
+ export * from "./DeleteBodyType";
3
+ export * from "./GetAllBodyTypes";
4
+ export * from "./UpdateBodyType";
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./CreateBodyType"), exports);
18
+ __exportStar(require("./DeleteBodyType"), exports);
19
+ __exportStar(require("./GetAllBodyTypes"), exports);
20
+ __exportStar(require("./UpdateBodyType"), exports);
@@ -0,0 +1,3 @@
1
+ export * from "./make";
2
+ export * from "./models";
3
+ export * from "./body_types";
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./make"), exports);
18
+ __exportStar(require("./models"), exports);
19
+ __exportStar(require("./body_types"), exports);
@@ -0,0 +1,2 @@
1
+ import { VehicleMakeApiResponse, VehicleMakeCreateDTO } from "../../data";
2
+ export declare const createVehicleMake: (vehicleMakeDTO: VehicleMakeCreateDTO) => Promise<VehicleMakeApiResponse>;
@@ -1 +1,22 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createVehicleMake = void 0;
4
+ const core_1 = require("../../../../core");
5
+ const createVehicleMake = async (vehicleMakeDTO) => {
6
+ var _a, _b;
7
+ try {
8
+ const response = await (0, core_1.apiRequest)(core_1.API_ENDPOINTS.vehicleMake.create.toString(), {
9
+ method: core_1.HttpMethods.POST,
10
+ body: JSON.stringify(vehicleMakeDTO)
11
+ });
12
+ if (!response.success) {
13
+ throw Error((_a = response.message) !== null && _a !== void 0 ? _a : (_b = response.error) === null || _b === void 0 ? void 0 : _b.message);
14
+ }
15
+ return response.data;
16
+ }
17
+ catch (error) {
18
+ console.error('Failed to create vehicle make:', error);
19
+ return Promise.reject(error);
20
+ }
21
+ };
22
+ exports.createVehicleMake = createVehicleMake;
@@ -0,0 +1,2 @@
1
+ import { VehicleMakeGetDTO } from "../../data";
2
+ export declare const deleteVehicleMake: (vehicleId: string) => Promise<VehicleMakeGetDTO>;
@@ -1 +1,17 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteVehicleMake = void 0;
4
+ const core_1 = require("../../../../core");
5
+ const deleteVehicleMake = async (vehicleId) => {
6
+ try {
7
+ const response = await (0, core_1.apiRequest)(core_1.API_ENDPOINTS.vehicleMake.deleteOne(vehicleId).toString(), {
8
+ method: core_1.HttpMethods.DELETE,
9
+ });
10
+ return response;
11
+ }
12
+ catch (error) {
13
+ console.error('Failed to delete vehicle make:', error);
14
+ return Promise.reject(error);
15
+ }
16
+ };
17
+ exports.deleteVehicleMake = deleteVehicleMake;
@@ -0,0 +1,3 @@
1
+ import { PaginatedData } from "../../../../core";
2
+ import { VehicleMake } from "../../data";
3
+ export declare const getAllVehicleMakes: (page: number | null, searchQuery: string | null) => Promise<PaginatedData<VehicleMake[]>>;
@@ -1 +1,26 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAllVehicleMakes = void 0;
4
+ const core_1 = require("../../../../core");
5
+ const getAllVehicleMakes = async (page, searchQuery) => {
6
+ var _a, _b, _c;
7
+ try {
8
+ const queryParams = { page: `${page}`, limit: "10" };
9
+ if ((searchQuery !== null && searchQuery !== void 0 ? searchQuery : "").trim().length > 1) {
10
+ queryParams.search = searchQuery;
11
+ }
12
+ const response = await (0, core_1.apiRequest)(core_1.API_ENDPOINTS.vehicleMake.getAll.toString(), {
13
+ method: core_1.HttpMethods.GET,
14
+ query: queryParams
15
+ });
16
+ if (!response.success) {
17
+ throw Error((_a = response.message) !== null && _a !== void 0 ? _a : (_b = response.error) === null || _b === void 0 ? void 0 : _b.message);
18
+ }
19
+ return (_c = response.data) !== null && _c !== void 0 ? _c : [];
20
+ }
21
+ catch (error) {
22
+ console.error('Failed to fetch vehicle make:', error);
23
+ return Promise.reject(error);
24
+ }
25
+ };
26
+ exports.getAllVehicleMakes = getAllVehicleMakes;
@@ -0,0 +1,2 @@
1
+ import { VehicleMakeGetDTO } from "../../data";
2
+ export default function getOneMake(makeID: string | number): Promise<VehicleMakeGetDTO>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("../../../../core");
4
+ async function getOneMake(makeID) {
5
+ try {
6
+ const res = await (0, core_1.apiRequest)(core_1.API_ENDPOINTS.vehicleMake.getOne(makeID), {
7
+ method: core_1.HttpMethods.GET,
8
+ });
9
+ return res;
10
+ }
11
+ catch (error) {
12
+ console.log('Failed to update make with id:', makeID, 'Error:', error);
13
+ return await Promise.reject(error);
14
+ }
15
+ }
16
+ exports.default = getOneMake;
@@ -1,2 +1,2 @@
1
1
  import { VehicleMakeGetDTO, VehicleMakeUpdateDTO } from "../../data";
2
- export default function updateMake(makeID: string | number, params: VehicleMakeUpdateDTO): Promise<VehicleMakeGetDTO>;
2
+ export declare const updateVehicleMake: (makeID: string | number, params: VehicleMakeUpdateDTO) => Promise<VehicleMakeGetDTO>;
@@ -1,17 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateVehicleMake = void 0;
3
4
  const core_1 = require("../../../../core");
4
- async function updateMake(makeID, params) {
5
+ const updateVehicleMake = async (makeID, params) => {
6
+ var _a, _b;
5
7
  try {
6
8
  const res = await (0, core_1.apiRequest)(core_1.API_ENDPOINTS.vehicleMake.updateOne(makeID), {
7
9
  method: core_1.HttpMethods.PUT,
8
10
  body: JSON.stringify(params),
9
11
  });
10
- return res;
12
+ if (!res.success) {
13
+ throw Error((_a = res.message) !== null && _a !== void 0 ? _a : (_b = res.error) === null || _b === void 0 ? void 0 : _b.message);
14
+ }
15
+ return res.data;
11
16
  }
12
17
  catch (error) {
13
18
  console.log('Failed to update make with id:', makeID, 'Error:', error);
14
19
  return await Promise.reject(error);
15
20
  }
16
- }
17
- exports.default = updateMake;
21
+ };
22
+ exports.updateVehicleMake = updateVehicleMake;
@@ -0,0 +1,5 @@
1
+ export * from "./CreateMake";
2
+ export * from "./DeleteMake";
3
+ export * from "./GetAllMakes";
4
+ export * from "./GetOneMake";
5
+ export * from "./UpdateMake";
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./CreateMake"), exports);
18
+ __exportStar(require("./DeleteMake"), exports);
19
+ __exportStar(require("./GetAllMakes"), exports);
20
+ __exportStar(require("./GetOneMake"), exports);
21
+ __exportStar(require("./UpdateMake"), exports);
@@ -0,0 +1,2 @@
1
+ import { VehicleModel, VehicleModelCreateDTO } from "../../data";
2
+ export declare const createVehicleModel: (vehicleModelDTO: VehicleModelCreateDTO) => Promise<VehicleModel>;
@@ -1 +1,22 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createVehicleModel = void 0;
4
+ const core_1 = require("../../../../core");
5
+ const createVehicleModel = async (vehicleModelDTO) => {
6
+ var _a, _b;
7
+ try {
8
+ const response = await (0, core_1.apiRequest)(core_1.API_ENDPOINTS.vehicleModel.create.toString(), {
9
+ method: core_1.HttpMethods.POST,
10
+ body: JSON.stringify(vehicleModelDTO)
11
+ });
12
+ if (!response.success) {
13
+ throw Error((_a = response.message) !== null && _a !== void 0 ? _a : (_b = response.error) === null || _b === void 0 ? void 0 : _b.message);
14
+ }
15
+ return response.data;
16
+ }
17
+ catch (error) {
18
+ console.error('Failed to create vehicle model:', error);
19
+ return Promise.reject(error);
20
+ }
21
+ };
22
+ exports.createVehicleModel = createVehicleModel;
@@ -0,0 +1,2 @@
1
+ import { VehicleModel } from "../../data";
2
+ export declare const deleteVehicleModel: (modelId: string) => Promise<VehicleModel>;
@@ -1 +1,17 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteVehicleModel = void 0;
4
+ const core_1 = require("../../../../core");
5
+ const deleteVehicleModel = async (modelId) => {
6
+ try {
7
+ const response = await (0, core_1.apiRequest)(core_1.API_ENDPOINTS.vehicleModel.deleteOne(modelId).toString(), {
8
+ method: core_1.HttpMethods.DELETE,
9
+ });
10
+ return response;
11
+ }
12
+ catch (error) {
13
+ console.error('Failed to delete vehicle model:', error);
14
+ return Promise.reject(error);
15
+ }
16
+ };
17
+ exports.deleteVehicleModel = deleteVehicleModel;
@@ -0,0 +1,3 @@
1
+ import { PaginatedData } from "../../../../core";
2
+ import { VehicleModel } from "../../data";
3
+ export declare const getAllVehicleModels: (page: number | null, searchQuery: string | null) => Promise<PaginatedData<VehicleModel[]>>;
@@ -1 +1,37 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getAllVehicleModels = void 0;
7
+ const qs_1 = __importDefault(require("qs"));
8
+ const core_1 = require("../../../../core");
9
+ const data_1 = require("../../data");
10
+ const getAllVehicleModels = async (page, searchQuery) => {
11
+ var _a, _b, _c;
12
+ try {
13
+ let getDTO = new data_1.VehicleModelGetDTO();
14
+ let options = new data_1.VehicleModelOptions();
15
+ if ((searchQuery !== null && searchQuery !== void 0 ? searchQuery : "").trim().length > 1) {
16
+ let filter = new data_1.VehicleModelFilter();
17
+ filter.search = searchQuery;
18
+ getDTO.filter = filter;
19
+ }
20
+ options.withMake = true;
21
+ options.page = (page !== null && page !== void 0 ? page : 0) + 1;
22
+ getDTO.options = options;
23
+ const endpoint = `${core_1.API_ENDPOINTS.vehicleModel.getAll.toString()}?${qs_1.default.stringify(getDTO.toPlain(), { arrayFormat: 'brackets', allowEmptyArrays: false, skipNulls: true })}`;
24
+ const response = await (0, core_1.apiRequest)(endpoint, {
25
+ method: core_1.HttpMethods.GET,
26
+ });
27
+ if (!response.success) {
28
+ throw Error((_a = response.message) !== null && _a !== void 0 ? _a : (_b = response.error) === null || _b === void 0 ? void 0 : _b.message);
29
+ }
30
+ return (_c = response.data) !== null && _c !== void 0 ? _c : [];
31
+ }
32
+ catch (error) {
33
+ console.error('Failed to fetch vehicle models:', error);
34
+ return Promise.reject(error);
35
+ }
36
+ };
37
+ exports.getAllVehicleModels = getAllVehicleModels;
@@ -0,0 +1,2 @@
1
+ import { VehicleModel, VehicleModelUpdateDTO } from "../../data";
2
+ export declare const updateVehicleModel: (makeID: string | number, params: VehicleModelUpdateDTO) => Promise<VehicleModel>;
@@ -1 +1,22 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateVehicleModel = void 0;
4
+ const core_1 = require("../../../../core");
5
+ const updateVehicleModel = async (makeID, params) => {
6
+ var _a, _b;
7
+ try {
8
+ const res = await (0, core_1.apiRequest)(core_1.API_ENDPOINTS.vehicleModel.updateOne(makeID), {
9
+ method: core_1.HttpMethods.PUT,
10
+ body: JSON.stringify(params),
11
+ });
12
+ if (!res.success) {
13
+ throw Error((_a = res.message) !== null && _a !== void 0 ? _a : (_b = res.error) === null || _b === void 0 ? void 0 : _b.message);
14
+ }
15
+ return res.data;
16
+ }
17
+ catch (error) {
18
+ console.error('Failed to update model with id:', makeID, 'Error:', error);
19
+ return await Promise.reject(error);
20
+ }
21
+ };
22
+ exports.updateVehicleModel = updateVehicleModel;
@@ -0,0 +1,4 @@
1
+ export * from "./CreateModel";
2
+ export * from "./GetAllModels";
3
+ export * from "./DeleteModel";
4
+ export * from "./UpdateModel";
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./CreateModel"), exports);
18
+ __exportStar(require("./GetAllModels"), exports);
19
+ __exportStar(require("./DeleteModel"), exports);
20
+ __exportStar(require("./UpdateModel"), exports);
@@ -7,7 +7,8 @@ import { VehicleMediaCreateDTO, VehicleMediaUpdateDTO } from './VehicleMedia';
7
7
  export declare class VehicleGetDTO {
8
8
  filter?: VehicleFilter;
9
9
  options?: VehicleOptions;
10
- validate(): string[];
10
+ validate?: (shouldValidate?: boolean) => string[];
11
+ constructor(shouldIncludeValidate?: boolean);
11
12
  static fromPlain(plain: Record<string, unknown>): VehicleGetDTO;
12
13
  static toPlain(entity: any): Record<string, unknown>;
13
14
  }
@@ -19,9 +19,16 @@ const VehicleModelDTO_1 = require("./VehicleModelDTO");
19
19
  const VehicleTypeDTO_1 = require("./VehicleTypeDTO");
20
20
  const VehicleMedia_1 = require("./VehicleMedia");
21
21
  class VehicleGetDTO {
22
- validate() {
23
- const errors = (0, class_validator_1.validateSync)(this);
24
- return errors.map((error) => { var _a; return Object.values((_a = error.constraints) !== null && _a !== void 0 ? _a : {}); }).flat();
22
+ constructor(shouldIncludeValidate = true) {
23
+ if (shouldIncludeValidate) {
24
+ this.validate = (shouldValidate = true) => {
25
+ if (!shouldValidate) {
26
+ return [];
27
+ }
28
+ const errors = (0, class_validator_1.validateSync)(this);
29
+ return errors.map((error) => { var _a; return Object.values((_a = error.constraints) !== null && _a !== void 0 ? _a : {}); }).flat();
30
+ };
31
+ }
25
32
  }
26
33
  static fromPlain(plain) {
27
34
  return (0, class_transformer_1.plainToClass)(VehicleGetDTO, plain);
@@ -1,5 +1,6 @@
1
1
  import { VehicleMakeFilter, VehicleMakeOptions, VehicleMakeUniqueFilter } from '../utilities';
2
2
  import { BaseCreateDTO, BaseUpdateDTO } from './BaseDTO';
3
+ import { VehicleMake } from '../models';
3
4
  export declare class VehicleMakeGetDTO {
4
5
  filter?: VehicleMakeFilter;
5
6
  options?: VehicleMakeOptions;
@@ -7,6 +8,7 @@ export declare class VehicleMakeGetDTO {
7
8
  static fromPlain(plain: Record<string, unknown>): VehicleMakeGetDTO;
8
9
  static toPlain(entity: any): Record<string, unknown>;
9
10
  }
11
+ export type VehicleMakeApiResponse = Omit<VehicleMake, 'createdBy' | 'updatedBy' | 'deletedBy' | '_id'>;
10
12
  export declare class VehicleMakeGetUniqueDTO {
11
13
  filter?: VehicleMakeUniqueFilter;
12
14
  options?: Omit<VehicleMakeOptions, 'page' | 'limit' | 'sort'>;
@@ -1,6 +1,5 @@
1
1
  import { VehicleModelFilter, VehicleModelOptions, VehicleModelUniqueFilter } from '../utilities';
2
2
  import { BaseCreateDTO, BaseUpdateDTO } from './BaseDTO';
3
- import { VehicleBodyType } from '../models/VehicleBodyType';
4
3
  import { Vehicle } from '../models/Vehicle';
5
4
  import { VehicleMake } from '../models/VehicleMake';
6
5
  export declare class VehicleModelGetDTO {
@@ -8,7 +7,7 @@ export declare class VehicleModelGetDTO {
8
7
  options?: VehicleModelOptions;
9
8
  validate(): string[];
10
9
  static fromPlain(plain: Record<string, unknown>): VehicleModelGetDTO;
11
- toPlain(): Record<string, unknown>;
10
+ toPlain(): Record<string, any>;
12
11
  }
13
12
  export declare class VehicleModelGetUniqueDTO {
14
13
  filter?: VehicleModelUniqueFilter;
@@ -26,7 +25,6 @@ export declare class VehicleModelCreateDTO extends BaseCreateDTO {
26
25
  metaKeywords?: string;
27
26
  make: VehicleMake;
28
27
  vehicles?: Vehicle[];
29
- bodyType: VehicleBodyType;
30
28
  validate(): string[];
31
29
  static fromPlain(plain: Record<string, unknown>): VehicleModelCreateDTO;
32
30
  static toPlain(entity: any): Record<string, unknown>;
@@ -14,7 +14,6 @@ exports.DynamicModelDTO = exports.VehicleModelUpdateDTO = exports.VehicleModelCr
14
14
  const class_validator_1 = require("class-validator");
15
15
  const class_transformer_1 = require("class-transformer");
16
16
  const BaseDTO_1 = require("./BaseDTO");
17
- const VehicleBodyType_1 = require("../models/VehicleBodyType");
18
17
  const Vehicle_1 = require("../models/Vehicle");
19
18
  const VehicleMake_1 = require("../models/VehicleMake");
20
19
  class VehicleModelGetDTO {
@@ -104,12 +103,6 @@ __decorate([
104
103
  ,
105
104
  __metadata("design:type", Array)
106
105
  ], VehicleModelCreateDTO.prototype, "vehicles", void 0);
107
- __decorate([
108
- (0, class_validator_1.ValidateNested)(),
109
- (0, class_transformer_1.Type)(() => VehicleBodyType_1.VehicleBodyType) // This transforms each object in the array to the OtherDetailsDTO class
110
- ,
111
- __metadata("design:type", VehicleBodyType_1.VehicleBodyType)
112
- ], VehicleModelCreateDTO.prototype, "bodyType", void 0);
113
106
  exports.VehicleModelCreateDTO = VehicleModelCreateDTO;
114
107
  class VehicleModelUpdateDTO extends BaseDTO_1.BaseUpdateDTO {
115
108
  validate() {
@@ -181,7 +181,8 @@ export declare class VehicleFilter extends BaseFilter {
181
181
  status?: string | string[];
182
182
  features?: string | string[];
183
183
  search?: string;
184
- validate(): string[];
184
+ validate?: (shouldValidate?: boolean) => string[];
185
+ constructor(shouldIncludeValidate?: boolean);
185
186
  static fromPlain(plain: Record<string, unknown>): VehicleFilter;
186
187
  static toPlain(entity: any): Record<string, unknown>;
187
188
  }
@@ -203,7 +204,8 @@ export declare class VehicleOptions extends PaginationOptions {
203
204
  withBodyType?: boolean;
204
205
  withFeatures?: boolean;
205
206
  withMetaData?: boolean;
206
- validate(): string[];
207
+ validate?: (shouldValidate?: boolean) => string[];
208
+ constructor(shouldIncludeValidate?: boolean);
207
209
  static fromPlain(plain: Record<string, unknown>): VehicleOptions;
208
210
  static toPlain(entity: any): Record<string, unknown>;
209
211
  }
@@ -512,9 +512,17 @@ class VehicleFeatureCategoryOptions extends utilities_1.PaginationOptions {
512
512
  exports.VehicleFeatureCategoryOptions = VehicleFeatureCategoryOptions;
513
513
  // -----------------------------------------------------CAR-------------------------------------------------------------------------
514
514
  class VehicleFilter extends utilities_1.BaseFilter {
515
- validate() {
516
- const errors = (0, class_validator_1.validateSync)(this);
517
- return errors.map(error => { var _a; return Object.values((_a = error.constraints) !== null && _a !== void 0 ? _a : {}); }).flat();
515
+ constructor(shouldIncludeValidate = true) {
516
+ super();
517
+ if (shouldIncludeValidate) {
518
+ this.validate = (shouldValidate = true) => {
519
+ if (!shouldValidate) {
520
+ return [];
521
+ }
522
+ const errors = (0, class_validator_1.validateSync)(this);
523
+ return errors.map((error) => { var _a; return Object.values((_a = error.constraints) !== null && _a !== void 0 ? _a : {}); }).flat();
524
+ };
525
+ }
518
526
  }
519
527
  static fromPlain(plain) {
520
528
  return (0, class_transformer_1.plainToClass)(VehicleFilter, plain);
@@ -692,9 +700,17 @@ __decorate([
692
700
  ], VehicleUniqueFilter.prototype, "chassisNumber", void 0);
693
701
  exports.VehicleUniqueFilter = VehicleUniqueFilter;
694
702
  class VehicleOptions extends utilities_1.PaginationOptions {
695
- validate() {
696
- const errors = (0, class_validator_1.validateSync)(this);
697
- return errors.map(error => { var _a; return Object.values((_a = error.constraints) !== null && _a !== void 0 ? _a : {}); }).flat();
703
+ constructor(shouldIncludeValidate = true) {
704
+ super();
705
+ if (shouldIncludeValidate) {
706
+ this.validate = (shouldValidate = true) => {
707
+ if (!shouldValidate) {
708
+ return [];
709
+ }
710
+ const errors = (0, class_validator_1.validateSync)(this);
711
+ return errors.map((error) => { var _a; return Object.values((_a = error.constraints) !== null && _a !== void 0 ? _a : {}); }).flat();
712
+ };
713
+ }
698
714
  }
699
715
  static fromPlain(plain) {
700
716
  return (0, class_transformer_1.plainToClass)(VehicleOptions, plain);
@@ -1 +1,2 @@
1
1
  export * from "./data";
2
+ export * from "./api";
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./data"), exports);
18
+ __exportStar(require("./api"), exports);
package/dist/models.d.ts CHANGED
@@ -1,2 +1 @@
1
- import { PaginatedData } from "./core/models/pagination/paginated_data";
2
- export { PaginatedData };
1
+ export * from "./core/models/pagination/paginated_data";
package/dist/models.js CHANGED
@@ -1,2 +1,17 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./core/models/pagination/paginated_data"), exports);
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.2.3",
6
+ "version": "1.2.5",
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",
@@ -37,7 +37,8 @@
37
37
  "class-transformer": "^0.5.1",
38
38
  "class-validator": "^0.14.1",
39
39
  "dist": "^0.1.2",
40
- "express": "^4.21.1"
40
+ "express": "^4.21.1",
41
+ "qs": "^6.13.1"
41
42
  },
42
43
  "devDependencies": {
43
44
  "@types/express": "^4.17.13",