@alba-cars/common-modules 1.2.5 → 1.2.6

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.
@@ -1,17 +1,28 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.getAllVehicleBodyTypes = void 0;
7
+ const qs_1 = __importDefault(require("qs"));
4
8
  const core_1 = require("../../../../core");
9
+ const data_1 = require("../../data");
5
10
  const getAllVehicleBodyTypes = async (page, searchQuery) => {
6
11
  var _a, _b, _c;
7
12
  try {
8
- const queryParams = { page: `${page}`, limit: "10" };
13
+ let getDTO = new data_1.VehicleBodyTypeGetDTO();
14
+ let options = new data_1.VehicleBodyTypeOptions();
9
15
  if ((searchQuery !== null && searchQuery !== void 0 ? searchQuery : "").trim().length > 1) {
10
- queryParams.search = searchQuery;
16
+ let filter = new data_1.VehicleBodyTypeFilter();
17
+ filter.search = searchQuery;
18
+ getDTO.filter = filter;
11
19
  }
12
- const response = await (0, core_1.apiRequest)(core_1.API_ENDPOINTS.vehicleType.getAll.toString(), {
20
+ // options.withVehicles = true;
21
+ options.page = (page !== null && page !== void 0 ? page : 0) + 1;
22
+ getDTO.options = options;
23
+ const endpoint = `${core_1.API_ENDPOINTS.vehicleType.getAll.toString()}?${qs_1.default.stringify(getDTO.toPlain(), { arrayFormat: 'brackets', allowEmptyArrays: false, skipNulls: true })}`;
24
+ const response = await (0, core_1.apiRequest)(endpoint, {
13
25
  method: core_1.HttpMethods.GET,
14
- query: queryParams
15
26
  });
16
27
  if (!response.success) {
17
28
  throw Error((_a = response.message) !== null && _a !== void 0 ? _a : (_b = response.error) === null || _b === void 0 ? void 0 : _b.message);
@@ -5,7 +5,7 @@ export declare class VehicleBodyTypeGetDTO {
5
5
  options?: VehicleBodyTypeOptions;
6
6
  validate(): string[];
7
7
  static fromPlain(plain: Record<string, unknown>): VehicleBodyTypeGetDTO;
8
- static toPlain(entity: any): Record<string, unknown>;
8
+ toPlain(): Record<string, any>;
9
9
  }
10
10
  export declare class VehicleBodyTypeGetUniqueDTO {
11
11
  filter?: VehicleBodyTypeUniqueFilter;
@@ -22,8 +22,8 @@ class VehicleBodyTypeGetDTO {
22
22
  static fromPlain(plain) {
23
23
  return (0, class_transformer_1.plainToClass)(VehicleBodyTypeGetDTO, plain);
24
24
  }
25
- static toPlain(entity) {
26
- return (0, class_transformer_1.instanceToPlain)(entity);
25
+ toPlain() {
26
+ return (0, class_transformer_1.instanceToPlain)(this);
27
27
  }
28
28
  }
29
29
  exports.VehicleBodyTypeGetDTO = VehicleBodyTypeGetDTO;
@@ -33,7 +33,7 @@ export declare class VehicleMakeUniqueFilter extends BaseFilter {
33
33
  static fromPlain(plain: Record<string, unknown>): VehicleMakeFilter;
34
34
  static toPlain(entity: any): Record<string, unknown>;
35
35
  }
36
- export type VehicleMakeSort = Record<keyof Pick<VehicleMake, 'name' | 'isActive' | 'createdAt' | 'updatedAt'>, 'asc' | 'desc'>;
36
+ export type VehicleMakeSort = Partial<Record<keyof Pick<VehicleMake, 'name' | 'isActive' | 'createdAt' | 'updatedAt'>, 'asc' | 'desc'>>;
37
37
  export declare class VehicleMakeOptions extends PaginationOptions {
38
38
  sort?: VehicleMakeSort;
39
39
  withModels?: boolean;
@@ -63,7 +63,7 @@ export declare class VehicleModelUniqueFilter extends BaseFilter {
63
63
  static fromPlain(plain: Record<string, unknown>): VehicleModelUniqueFilter;
64
64
  static toPlain(entity: any): Record<string, unknown>;
65
65
  }
66
- export type VehicleModelSort = Record<keyof Pick<VehicleModel, 'name' | 'isActive' | 'createdAt' | 'updatedAt'>, 'asc' | 'desc'>;
66
+ export type VehicleModelSort = Partial<Record<keyof Pick<VehicleModel, 'name' | 'isActive' | 'createdAt' | 'updatedAt'>, 'asc' | 'desc'>>;
67
67
  export declare class VehicleModelOptions extends PaginationOptions {
68
68
  sort?: VehicleModelSort;
69
69
  withVehicles?: boolean;
@@ -92,7 +92,7 @@ export declare class VehicleBodyTypeUniqueFilter {
92
92
  static fromPlain(plain: Record<string, unknown>): VehicleModelFilter;
93
93
  static toPlain(entity: any): Record<string, unknown>;
94
94
  }
95
- export type VehicleBodyTypeSort = Record<keyof Pick<VehicleBodyType, 'name' | 'isActive' | 'createdAt' | 'updatedAt'>, 'asc' | 'desc'>;
95
+ export type VehicleBodyTypeSort = Partial<Record<keyof Pick<VehicleBodyType, 'name' | 'isActive' | 'createdAt' | 'updatedAt'>, 'asc' | 'desc'>>;
96
96
  export declare class VehicleBodyTypeOptions extends PaginationOptions {
97
97
  sort?: VehicleBodyTypeSort;
98
98
  withVehicles?: boolean;
@@ -119,7 +119,7 @@ export declare class VehicleFeatureUniqueFilter {
119
119
  static fromPlain(plain: Record<string, unknown>): VehicleModelFilter;
120
120
  static toPlain(entity: any): Record<string, unknown>;
121
121
  }
122
- export type VehicleFeatureSort = Record<keyof Pick<VehicleFeature, 'name' | 'isActive' | 'createdAt' | 'updatedAt'>, 'asc' | 'desc'>;
122
+ export type VehicleFeatureSort = Partial<Record<keyof Pick<VehicleFeature, 'name' | 'isActive' | 'createdAt' | 'updatedAt'>, 'asc' | 'desc'>>;
123
123
  export declare class VehicleFeatureOptions extends PaginationOptions {
124
124
  sort?: VehicleFeatureSort;
125
125
  withCategories?: boolean;
@@ -146,7 +146,7 @@ export declare class VehicleFeatureCategoryUniqueFilter {
146
146
  static fromPlain(plain: Record<string, unknown>): VehicleModelFilter;
147
147
  static toPlain(entity: any): Record<string, unknown>;
148
148
  }
149
- export type VehicleFeatureCategorySort = Record<keyof Pick<VehicleCategory, 'name' | 'isActive' | 'createdAt' | 'updatedAt'>, 'asc' | 'desc'>;
149
+ export type VehicleFeatureCategorySort = Partial<Record<keyof Pick<VehicleCategory, 'name' | 'isActive' | 'createdAt' | 'updatedAt'>, 'asc' | 'desc'>>;
150
150
  export declare class VehicleFeatureCategoryOptions extends PaginationOptions {
151
151
  sort?: VehicleFeatureCategorySort;
152
152
  withFeatures?: boolean;
@@ -195,7 +195,7 @@ export declare class VehicleUniqueFilter {
195
195
  static fromPlain(plain: Record<string, unknown>): VehicleUniqueFilter;
196
196
  static toPlain(entity: any): Record<string, unknown>;
197
197
  }
198
- export type VehicleSort = Record<keyof Pick<Vehicle, 'referenceNumber' | 'mileage' | 'year' | 'createdAt' | 'updatedAt' | 'engineCapacity' | 'doors' | 'seats' | 'keys' | 'transmission' | 'driveType' | 'price' | 'status'>, 'asc' | 'desc'>;
198
+ export type VehicleSort = Partial<Record<keyof Pick<Vehicle, 'referenceNumber' | 'mileage' | 'year' | 'createdAt' | 'updatedAt' | 'engineCapacity' | 'doors' | 'seats' | 'keys' | 'transmission' | 'driveType' | 'price' | 'status'>, 'asc' | 'desc'>>;
199
199
  export declare class VehicleOptions extends PaginationOptions {
200
200
  sort?: VehicleSort;
201
201
  select?: (VehicleSelectFields | `make.${VehicleMakeSelectFields}` | `model.${VehicleModelSelectFields}` | `bodyType.${VehicleBodyTypeSelectFields}` | `features.${VehicleFeatureSelectFields}` | `metaData.${VehicleMetaDataSelectFields}`)[];
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.2.5",
6
+ "version": "1.2.6",
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",