@alba-cars/common-modules 1.3.4 → 1.3.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.
- package/dist/core/network/fetch-api.js +15 -6
- package/dist/features/models/Vehicle.d.ts +2 -0
- package/dist/features/models/Vehicle.js +7 -0
- package/dist/features/sales-team/data/dto/SalesAgentDTO.js +2 -0
- package/dist/features/test-drive-request/data/dto/TestDriveRequestDTO.d.ts +3 -2
- package/dist/features/test-drive-request/data/dto/TestDriveRequestDTO.js +7 -4
- package/dist/features/vehicle/data/dto/VehicleDTO.d.ts +1 -1
- package/dist/features/vehicle/data/dto/VehicleFilterDTO.d.ts +5 -0
- package/dist/features/vehicle/data/dto/VehicleFilterDTO.js +26 -0
- package/dist/features/vehicle/data/enums/index.d.ts +7 -0
- package/dist/features/vehicle/data/enums/index.js +9 -1
- package/dist/features/vehicle/data/utilities.d.ts +1 -56
- package/dist/features/vehicle/data/utilities.js +1 -214
- package/dist/global/utilities.d.ts +1 -0
- package/dist/global/utilities.js +35 -2
- package/package.json +1 -1
|
@@ -33,25 +33,28 @@ const onTokenRefreshed = (token) => {
|
|
|
33
33
|
refreshSubscribers = [];
|
|
34
34
|
};
|
|
35
35
|
const refreshTokens = async () => {
|
|
36
|
+
var _a, _b, _c, _d;
|
|
36
37
|
try {
|
|
37
38
|
const tokens = (0, exports.getTokens)();
|
|
38
39
|
if (!(tokens === null || tokens === void 0 ? void 0 : tokens.refreshToken)) {
|
|
39
40
|
throw new Error("No refresh token available");
|
|
40
41
|
}
|
|
41
|
-
const response = await apiRequest("/auth/refresh", {
|
|
42
|
+
const response = await apiRequest("/auth/refresh-token", {
|
|
42
43
|
method: enums_1.HttpMethods.POST,
|
|
43
44
|
body: JSON.stringify({ refreshToken: tokens.refreshToken }),
|
|
44
45
|
skipAuth: true, // Skip auth to avoid infinite loop
|
|
45
46
|
});
|
|
47
|
+
if (!((_a = response.data) === null || _a === void 0 ? void 0 : _a.accessToken)) {
|
|
48
|
+
throw new Error("No access token available");
|
|
49
|
+
}
|
|
46
50
|
(0, exports.setTokens)({
|
|
47
|
-
accessToken: response.accessToken,
|
|
48
|
-
refreshToken: response.refreshToken,
|
|
51
|
+
accessToken: (_b = response.data) === null || _b === void 0 ? void 0 : _b.accessToken,
|
|
52
|
+
refreshToken: (_c = response.data) === null || _c === void 0 ? void 0 : _c.refreshToken,
|
|
49
53
|
});
|
|
50
|
-
return response.accessToken;
|
|
54
|
+
return (_d = response.data) === null || _d === void 0 ? void 0 : _d.accessToken;
|
|
51
55
|
}
|
|
52
56
|
catch (error) {
|
|
53
57
|
(0, exports.removeTokens)();
|
|
54
|
-
window.location.href = "/login";
|
|
55
58
|
throw error;
|
|
56
59
|
}
|
|
57
60
|
};
|
|
@@ -68,7 +71,7 @@ const buildUrl = (endpoint, query) => {
|
|
|
68
71
|
return url;
|
|
69
72
|
};
|
|
70
73
|
async function apiRequest(endpoint, options = {}) {
|
|
71
|
-
var _a, _b, _c;
|
|
74
|
+
var _a, _b, _c, _d;
|
|
72
75
|
const tokens = (0, exports.getTokens)();
|
|
73
76
|
const headers = {
|
|
74
77
|
Accept: "application/json",
|
|
@@ -151,6 +154,12 @@ async function apiRequest(endpoint, options = {}) {
|
|
|
151
154
|
}
|
|
152
155
|
throw error;
|
|
153
156
|
}
|
|
157
|
+
if ((_d = responseData === null || responseData === void 0 ? void 0 : responseData.data) === null || _d === void 0 ? void 0 : _d.token) {
|
|
158
|
+
(0, exports.setTokens)({
|
|
159
|
+
accessToken: responseData.data.token,
|
|
160
|
+
refreshToken: responseData.data.refreshToken,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
154
163
|
return responseData;
|
|
155
164
|
}
|
|
156
165
|
catch (error) {
|
|
@@ -41,6 +41,8 @@ export declare class Vehicle extends BaseModel {
|
|
|
41
41
|
finance?: VehicleFinance;
|
|
42
42
|
orders?: VehicleOrder[];
|
|
43
43
|
draft?: VehicleDraft;
|
|
44
|
+
static fromPlain(plain: Record<string, unknown>): Vehicle;
|
|
45
|
+
toPlain(): Record<string, unknown>;
|
|
44
46
|
}
|
|
45
47
|
export declare class VehicleDraft {
|
|
46
48
|
page: number;
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VehicleDraft = exports.Vehicle = void 0;
|
|
4
|
+
const class_transformer_1 = require("class-transformer");
|
|
4
5
|
const Base_1 = require("./Base");
|
|
5
6
|
class Vehicle extends Base_1.BaseModel {
|
|
7
|
+
static fromPlain(plain) {
|
|
8
|
+
return (0, class_transformer_1.plainToClass)(Vehicle, plain);
|
|
9
|
+
}
|
|
10
|
+
toPlain() {
|
|
11
|
+
return (0, class_transformer_1.instanceToPlain)(this);
|
|
12
|
+
}
|
|
6
13
|
}
|
|
7
14
|
exports.Vehicle = Vehicle;
|
|
8
15
|
class VehicleDraft {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TestDriveRequestFilter, TestDriveRequestSelectFields } from "../utilities";
|
|
2
|
-
import {
|
|
2
|
+
import { BaseUpdateDTO } from "../../../vehicle/data/dto/BaseDTO";
|
|
3
3
|
import { DynamicVehicleDTO } from "../../../vehicle/data/dto/VehicleDTO";
|
|
4
4
|
import { LeadThrough, TestDriveRequestStatus } from "../enums";
|
|
5
5
|
import { VehicleSelectFields } from "../../../vehicle/data/utilities";
|
|
@@ -17,7 +17,7 @@ export declare class TestDriveRequestGetDTO {
|
|
|
17
17
|
static fromPlain(plain: Record<string, unknown>): TestDriveRequestGetDTO;
|
|
18
18
|
toPlain(): Record<string, any>;
|
|
19
19
|
}
|
|
20
|
-
export declare class TestDriveRequestCreateDTO
|
|
20
|
+
export declare class TestDriveRequestCreateDTO {
|
|
21
21
|
vehicle: DynamicVehicleDTO;
|
|
22
22
|
testerName: string;
|
|
23
23
|
testerMobile: string;
|
|
@@ -27,6 +27,7 @@ export declare class TestDriveRequestCreateDTO extends BaseCreateDTO {
|
|
|
27
27
|
status?: TestDriveRequestStatus;
|
|
28
28
|
leadThrough?: LeadThrough;
|
|
29
29
|
comments?: string;
|
|
30
|
+
createdById?: string;
|
|
30
31
|
validate(): string[];
|
|
31
32
|
constructor(data?: Partial<TestDriveRequestCreateDTO>);
|
|
32
33
|
static fromPlain(plain: Record<string, unknown>): TestDriveRequestCreateDTO;
|
|
@@ -19,11 +19,10 @@ const enums_1 = require("../enums");
|
|
|
19
19
|
class TestDriveRequestGetDTOOptions {
|
|
20
20
|
}
|
|
21
21
|
exports.TestDriveRequestGetDTOOptions = TestDriveRequestGetDTOOptions;
|
|
22
|
-
;
|
|
23
22
|
class TestDriveRequestGetDTO {
|
|
24
23
|
validate() {
|
|
25
24
|
const errors = (0, class_validator_1.validateSync)(this);
|
|
26
|
-
return errors.map(error => { var _a; return Object.values((_a = error.constraints) !== null && _a !== void 0 ? _a : {}); }).flat();
|
|
25
|
+
return errors.map((error) => { var _a; return Object.values((_a = error.constraints) !== null && _a !== void 0 ? _a : {}); }).flat();
|
|
27
26
|
}
|
|
28
27
|
static fromPlain(plain) {
|
|
29
28
|
return (0, class_transformer_1.plainToClass)(TestDriveRequestGetDTO, plain);
|
|
@@ -33,13 +32,12 @@ class TestDriveRequestGetDTO {
|
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
34
|
exports.TestDriveRequestGetDTO = TestDriveRequestGetDTO;
|
|
36
|
-
class TestDriveRequestCreateDTO
|
|
35
|
+
class TestDriveRequestCreateDTO {
|
|
37
36
|
validate() {
|
|
38
37
|
const errors = (0, class_validator_1.validateSync)(this);
|
|
39
38
|
return errors.map((error) => { var _a; return Object.values((_a = error.constraints) !== null && _a !== void 0 ? _a : {}); }).flat();
|
|
40
39
|
}
|
|
41
40
|
constructor(data) {
|
|
42
|
-
super();
|
|
43
41
|
Object.assign(this, data);
|
|
44
42
|
if (!this.status)
|
|
45
43
|
this.status = enums_1.TestDriveRequestStatus.NOT_CONTACTED;
|
|
@@ -109,6 +107,11 @@ __decorate([
|
|
|
109
107
|
(0, class_validator_1.IsString)(),
|
|
110
108
|
__metadata("design:type", String)
|
|
111
109
|
], TestDriveRequestCreateDTO.prototype, "comments", void 0);
|
|
110
|
+
__decorate([
|
|
111
|
+
(0, class_validator_1.IsOptional)(),
|
|
112
|
+
(0, class_validator_1.IsString)(),
|
|
113
|
+
__metadata("design:type", String)
|
|
114
|
+
], TestDriveRequestCreateDTO.prototype, "createdById", void 0);
|
|
112
115
|
exports.TestDriveRequestCreateDTO = TestDriveRequestCreateDTO;
|
|
113
116
|
class TestDriveRequestUpdateDTO extends BaseDTO_1.BaseUpdateDTO {
|
|
114
117
|
validate() {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { VehicleFilter, VehicleOptions, VehicleUniqueFilter } from "../utilities";
|
|
2
1
|
import { BaseCreateDTO, BaseUpdateDTO } from "./BaseDTO";
|
|
3
2
|
import { DynamicMakeDTO } from "./VehicleMakeDTO";
|
|
4
3
|
import { DynamicModelDTO } from "./VehicleModelDTO";
|
|
5
4
|
import { DynamicVehicleBodyTypeDTO } from "./VehicleTypeDTO";
|
|
6
5
|
import { VehicleMediaCreateDTO, VehicleMediaUpdateDTO } from "./VehicleMedia";
|
|
6
|
+
import { VehicleFilter, VehicleOptions, VehicleUniqueFilter } from "./VehicleFilterDTO";
|
|
7
7
|
export declare class VehicleGetDTO {
|
|
8
8
|
filter?: VehicleFilter;
|
|
9
9
|
options?: VehicleOptions;
|
|
@@ -199,7 +199,12 @@ export declare class VehicleFilter extends BaseFilter {
|
|
|
199
199
|
emissions?: string | string[];
|
|
200
200
|
year?: NumberRange;
|
|
201
201
|
price?: NumberRange;
|
|
202
|
+
emi?: NumberRange;
|
|
202
203
|
status?: string | string[];
|
|
204
|
+
includeReserved?: boolean;
|
|
205
|
+
includeSelfReserved?: boolean;
|
|
206
|
+
includeSold?: boolean;
|
|
207
|
+
includeDraft?: boolean;
|
|
203
208
|
features?: string | string[];
|
|
204
209
|
search?: string;
|
|
205
210
|
validate(): string[];
|
|
@@ -641,11 +641,37 @@ __decorate([
|
|
|
641
641
|
(0, class_transformer_1.Type)(() => global_1.NumberRange),
|
|
642
642
|
__metadata("design:type", global_1.NumberRange)
|
|
643
643
|
], VehicleFilter.prototype, "price", void 0);
|
|
644
|
+
__decorate([
|
|
645
|
+
(0, class_validator_1.IsOptional)(),
|
|
646
|
+
(0, class_validator_1.ValidateNested)(),
|
|
647
|
+
(0, class_transformer_1.Type)(() => global_1.NumberRange),
|
|
648
|
+
__metadata("design:type", global_1.NumberRange)
|
|
649
|
+
], VehicleFilter.prototype, "emi", void 0);
|
|
644
650
|
__decorate([
|
|
645
651
|
(0, class_validator_1.IsOptional)(),
|
|
646
652
|
(0, class_validator_1.IsString)({ each: true }),
|
|
647
653
|
__metadata("design:type", Object)
|
|
648
654
|
], VehicleFilter.prototype, "status", void 0);
|
|
655
|
+
__decorate([
|
|
656
|
+
(0, class_validator_1.IsOptional)(),
|
|
657
|
+
(0, class_validator_1.IsBoolean)(),
|
|
658
|
+
__metadata("design:type", Boolean)
|
|
659
|
+
], VehicleFilter.prototype, "includeReserved", void 0);
|
|
660
|
+
__decorate([
|
|
661
|
+
(0, class_validator_1.IsOptional)(),
|
|
662
|
+
(0, class_validator_1.IsBoolean)(),
|
|
663
|
+
__metadata("design:type", Boolean)
|
|
664
|
+
], VehicleFilter.prototype, "includeSelfReserved", void 0);
|
|
665
|
+
__decorate([
|
|
666
|
+
(0, class_validator_1.IsOptional)(),
|
|
667
|
+
(0, class_validator_1.IsBoolean)(),
|
|
668
|
+
__metadata("design:type", Boolean)
|
|
669
|
+
], VehicleFilter.prototype, "includeSold", void 0);
|
|
670
|
+
__decorate([
|
|
671
|
+
(0, class_validator_1.IsOptional)(),
|
|
672
|
+
(0, class_validator_1.IsBoolean)(),
|
|
673
|
+
__metadata("design:type", Boolean)
|
|
674
|
+
], VehicleFilter.prototype, "includeDraft", void 0);
|
|
649
675
|
__decorate([
|
|
650
676
|
(0, class_validator_1.IsOptional)(),
|
|
651
677
|
(0, class_validator_1.IsString)({ each: true }),
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VehicleMediaType = void 0;
|
|
3
|
+
exports.VehicleStatusType = exports.VehicleMediaType = void 0;
|
|
4
4
|
var VehicleMediaType;
|
|
5
5
|
(function (VehicleMediaType) {
|
|
6
6
|
VehicleMediaType["IMAGE"] = "image";
|
|
7
7
|
VehicleMediaType["VIDEO"] = "video";
|
|
8
8
|
})(VehicleMediaType = exports.VehicleMediaType || (exports.VehicleMediaType = {}));
|
|
9
|
+
var VehicleStatusType;
|
|
10
|
+
(function (VehicleStatusType) {
|
|
11
|
+
VehicleStatusType["RESERVED"] = "Reserved";
|
|
12
|
+
VehicleStatusType["DRAFT"] = "Draft";
|
|
13
|
+
VehicleStatusType["PUBLISHED"] = "Published";
|
|
14
|
+
VehicleStatusType["SELF_RESERVED"] = "Self-Reserved";
|
|
15
|
+
VehicleStatusType["SOLD"] = "Sold";
|
|
16
|
+
})(VehicleStatusType = exports.VehicleStatusType || (exports.VehicleStatusType = {}));
|
|
@@ -5,7 +5,7 @@ import { VehicleMake } from "../../models/VehicleMake";
|
|
|
5
5
|
import { VehicleMetaData } from "../../models/VehicleMetaData";
|
|
6
6
|
import { VehicleModel } from "../../models/VehicleModel";
|
|
7
7
|
import { VehicleCategory } from "../../models/VehicleCategory";
|
|
8
|
-
import { BaseFilter,
|
|
8
|
+
import { BaseFilter, PaginationOptions } from "../../../global/utilities";
|
|
9
9
|
import { VehicleCategorySelectFields } from "./dto/VehicleFilterDTO";
|
|
10
10
|
export type VehicleMakeSelectFields = keyof VehicleMake;
|
|
11
11
|
export type VehicleModelSelectFields = keyof VehicleModel;
|
|
@@ -156,61 +156,6 @@ export declare class VehicleFeatureCategoryOptions extends PaginationOptions {
|
|
|
156
156
|
static fromPlain(plain: Record<string, unknown>): VehicleFeatureOptions;
|
|
157
157
|
static toPlain(entity: any): Record<string, unknown>;
|
|
158
158
|
}
|
|
159
|
-
export declare class VehicleFilter extends BaseFilter {
|
|
160
|
-
referenceNumber?: string | string[];
|
|
161
|
-
make?: string | string[];
|
|
162
|
-
model?: string | string[];
|
|
163
|
-
bodyType?: string | string[];
|
|
164
|
-
vin?: string | string[];
|
|
165
|
-
chassisNumber?: string | string[];
|
|
166
|
-
mileage?: NumberRange;
|
|
167
|
-
fuelType?: string | string[];
|
|
168
|
-
color?: string | string[];
|
|
169
|
-
engineCapacity?: string | string[];
|
|
170
|
-
numberOfCylinders?: NumberRange;
|
|
171
|
-
cylinderCapacity?: NumberRange;
|
|
172
|
-
doors?: NumberRange;
|
|
173
|
-
seats?: NumberRange;
|
|
174
|
-
keys?: NumberRange;
|
|
175
|
-
wheelsType?: string | string[];
|
|
176
|
-
airbags?: NumberRange;
|
|
177
|
-
transmission?: string | string[];
|
|
178
|
-
driveType?: string | string[];
|
|
179
|
-
emissions?: string | string[];
|
|
180
|
-
year?: NumberRange;
|
|
181
|
-
price?: NumberRange;
|
|
182
|
-
status?: string | string[];
|
|
183
|
-
features?: string | string[];
|
|
184
|
-
search?: string;
|
|
185
|
-
validate?: (shouldValidate?: boolean) => string[];
|
|
186
|
-
constructor(shouldIncludeValidate?: boolean);
|
|
187
|
-
static fromPlain(plain: Record<string, unknown>): VehicleFilter;
|
|
188
|
-
static toPlain(entity: any): Record<string, unknown>;
|
|
189
|
-
}
|
|
190
|
-
export declare class VehicleUniqueFilter {
|
|
191
|
-
id?: string;
|
|
192
|
-
referenceNumber?: string;
|
|
193
|
-
vin?: string;
|
|
194
|
-
chassisNumber?: string;
|
|
195
|
-
validate(): string[];
|
|
196
|
-
static fromPlain(plain: Record<string, unknown>): VehicleUniqueFilter;
|
|
197
|
-
static toPlain(entity: any): Record<string, unknown>;
|
|
198
|
-
}
|
|
199
|
-
export type VehicleSort = Partial<Record<keyof Pick<Vehicle, "referenceNumber" | "mileage" | "year" | "createdAt" | "updatedAt" | "engineCapacity" | "doors" | "seats" | "keys" | "transmission" | "driveType" | "price" | "status">, "asc" | "desc">>;
|
|
200
|
-
export declare class VehicleOptions extends PaginationOptions {
|
|
201
|
-
sort?: VehicleSort;
|
|
202
|
-
select?: (VehicleSelectFields | `make.${VehicleMakeSelectFields}` | `model.${VehicleModelSelectFields}` | `bodyType.${VehicleBodyTypeSelectFields}` | `features.${VehicleFeatureSelectFields}` | `metaData.${VehicleMetaDataSelectFields}`)[];
|
|
203
|
-
withMake?: boolean;
|
|
204
|
-
withModel?: boolean;
|
|
205
|
-
withBodyType?: boolean;
|
|
206
|
-
withFeatures?: boolean;
|
|
207
|
-
withMetaData?: boolean;
|
|
208
|
-
withFinance?: boolean;
|
|
209
|
-
validate?: (shouldValidate?: boolean) => string[];
|
|
210
|
-
constructor(shouldIncludeValidate?: boolean);
|
|
211
|
-
static fromPlain(plain: Record<string, unknown>): VehicleOptions;
|
|
212
|
-
static toPlain(entity: any): Record<string, unknown>;
|
|
213
|
-
}
|
|
214
159
|
export declare class VehicleCategoryFilter extends BaseFilter {
|
|
215
160
|
id?: string | string[];
|
|
216
161
|
slug?: string | string[];
|
|
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.VehicleCategoryOptions = exports.VehicleCategoryUniqueFilter = exports.VehicleCategoryFilter = exports.
|
|
12
|
+
exports.VehicleCategoryOptions = exports.VehicleCategoryUniqueFilter = exports.VehicleCategoryFilter = exports.VehicleFeatureCategoryOptions = exports.VehicleFeatureCategoryUniqueFilter = exports.VehicleFeatureCategoryFilter = exports.VehicleFeatureOptions = exports.VehicleFeatureUniqueFilter = exports.VehicleFeatureFilter = exports.VehicleBodyTypeOptions = exports.VehicleBodyTypeUniqueFilter = exports.VehicleBodyTypeFilter = exports.VehicleModelOptions = exports.VehicleModelUniqueFilter = exports.VehicleModelFilter = exports.VehicleMakeOptions = exports.VehicleMakeUniqueFilter = exports.VehicleMakeFilter = void 0;
|
|
13
13
|
const class_validator_1 = require("class-validator");
|
|
14
14
|
const class_transformer_1 = require("class-transformer");
|
|
15
15
|
const utilities_1 = require("../../../global/utilities");
|
|
@@ -434,219 +434,6 @@ class VehicleFeatureCategoryOptions extends utilities_1.PaginationOptions {
|
|
|
434
434
|
}
|
|
435
435
|
exports.VehicleFeatureCategoryOptions = VehicleFeatureCategoryOptions;
|
|
436
436
|
// -----------------------------------------------------CAR-------------------------------------------------------------------------
|
|
437
|
-
class VehicleFilter extends utilities_1.BaseFilter {
|
|
438
|
-
constructor(shouldIncludeValidate = true) {
|
|
439
|
-
super();
|
|
440
|
-
if (shouldIncludeValidate) {
|
|
441
|
-
this.validate = (shouldValidate = true) => {
|
|
442
|
-
if (!shouldValidate) {
|
|
443
|
-
return [];
|
|
444
|
-
}
|
|
445
|
-
const errors = (0, class_validator_1.validateSync)(this);
|
|
446
|
-
return errors
|
|
447
|
-
.map((error) => { var _a; return Object.values((_a = error.constraints) !== null && _a !== void 0 ? _a : {}); })
|
|
448
|
-
.flat();
|
|
449
|
-
};
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
static fromPlain(plain) {
|
|
453
|
-
return (0, class_transformer_1.plainToClass)(VehicleFilter, plain);
|
|
454
|
-
}
|
|
455
|
-
static toPlain(entity) {
|
|
456
|
-
return (0, class_transformer_1.instanceToPlain)(entity);
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
__decorate([
|
|
460
|
-
(0, class_validator_1.IsOptional)(),
|
|
461
|
-
(0, class_validator_1.IsString)({ each: true }),
|
|
462
|
-
__metadata("design:type", Object)
|
|
463
|
-
], VehicleFilter.prototype, "referenceNumber", void 0);
|
|
464
|
-
__decorate([
|
|
465
|
-
(0, class_validator_1.IsOptional)(),
|
|
466
|
-
(0, class_validator_1.IsString)({ each: true }),
|
|
467
|
-
__metadata("design:type", Object)
|
|
468
|
-
], VehicleFilter.prototype, "make", void 0);
|
|
469
|
-
__decorate([
|
|
470
|
-
(0, class_validator_1.IsOptional)(),
|
|
471
|
-
(0, class_validator_1.IsString)({ each: true }),
|
|
472
|
-
__metadata("design:type", Object)
|
|
473
|
-
], VehicleFilter.prototype, "model", void 0);
|
|
474
|
-
__decorate([
|
|
475
|
-
(0, class_validator_1.IsOptional)(),
|
|
476
|
-
(0, class_validator_1.IsString)({ each: true }),
|
|
477
|
-
__metadata("design:type", Object)
|
|
478
|
-
], VehicleFilter.prototype, "bodyType", void 0);
|
|
479
|
-
__decorate([
|
|
480
|
-
(0, class_validator_1.IsOptional)(),
|
|
481
|
-
(0, class_validator_1.IsString)({ each: true }),
|
|
482
|
-
__metadata("design:type", Object)
|
|
483
|
-
], VehicleFilter.prototype, "vin", void 0);
|
|
484
|
-
__decorate([
|
|
485
|
-
(0, class_validator_1.IsOptional)(),
|
|
486
|
-
(0, class_validator_1.IsString)({ each: true }),
|
|
487
|
-
__metadata("design:type", Object)
|
|
488
|
-
], VehicleFilter.prototype, "chassisNumber", void 0);
|
|
489
|
-
__decorate([
|
|
490
|
-
(0, class_validator_1.IsOptional)(),
|
|
491
|
-
(0, class_validator_1.ValidateNested)(),
|
|
492
|
-
(0, class_transformer_1.Type)(() => utilities_1.NumberRange),
|
|
493
|
-
__metadata("design:type", utilities_1.NumberRange)
|
|
494
|
-
], VehicleFilter.prototype, "mileage", void 0);
|
|
495
|
-
__decorate([
|
|
496
|
-
(0, class_validator_1.IsOptional)(),
|
|
497
|
-
(0, class_validator_1.IsString)({ each: true }),
|
|
498
|
-
__metadata("design:type", Object)
|
|
499
|
-
], VehicleFilter.prototype, "fuelType", void 0);
|
|
500
|
-
__decorate([
|
|
501
|
-
(0, class_validator_1.IsOptional)(),
|
|
502
|
-
(0, class_validator_1.IsString)({ each: true }),
|
|
503
|
-
__metadata("design:type", Object)
|
|
504
|
-
], VehicleFilter.prototype, "color", void 0);
|
|
505
|
-
__decorate([
|
|
506
|
-
(0, class_validator_1.IsOptional)(),
|
|
507
|
-
(0, class_validator_1.IsString)({ each: true }),
|
|
508
|
-
__metadata("design:type", Object)
|
|
509
|
-
], VehicleFilter.prototype, "engineCapacity", void 0);
|
|
510
|
-
__decorate([
|
|
511
|
-
(0, class_validator_1.IsOptional)(),
|
|
512
|
-
(0, class_validator_1.ValidateNested)(),
|
|
513
|
-
(0, class_transformer_1.Type)(() => utilities_1.NumberRange),
|
|
514
|
-
__metadata("design:type", utilities_1.NumberRange)
|
|
515
|
-
], VehicleFilter.prototype, "numberOfCylinders", void 0);
|
|
516
|
-
__decorate([
|
|
517
|
-
(0, class_validator_1.IsOptional)(),
|
|
518
|
-
(0, class_validator_1.ValidateNested)(),
|
|
519
|
-
(0, class_transformer_1.Type)(() => utilities_1.NumberRange),
|
|
520
|
-
__metadata("design:type", utilities_1.NumberRange)
|
|
521
|
-
], VehicleFilter.prototype, "cylinderCapacity", void 0);
|
|
522
|
-
__decorate([
|
|
523
|
-
(0, class_validator_1.IsOptional)(),
|
|
524
|
-
(0, class_validator_1.ValidateNested)(),
|
|
525
|
-
(0, class_transformer_1.Type)(() => utilities_1.NumberRange),
|
|
526
|
-
__metadata("design:type", utilities_1.NumberRange)
|
|
527
|
-
], VehicleFilter.prototype, "doors", void 0);
|
|
528
|
-
__decorate([
|
|
529
|
-
(0, class_validator_1.IsOptional)(),
|
|
530
|
-
(0, class_validator_1.ValidateNested)(),
|
|
531
|
-
(0, class_transformer_1.Type)(() => utilities_1.NumberRange),
|
|
532
|
-
__metadata("design:type", utilities_1.NumberRange)
|
|
533
|
-
], VehicleFilter.prototype, "seats", void 0);
|
|
534
|
-
__decorate([
|
|
535
|
-
(0, class_validator_1.IsOptional)(),
|
|
536
|
-
(0, class_validator_1.ValidateNested)(),
|
|
537
|
-
(0, class_transformer_1.Type)(() => utilities_1.NumberRange),
|
|
538
|
-
__metadata("design:type", utilities_1.NumberRange)
|
|
539
|
-
], VehicleFilter.prototype, "keys", void 0);
|
|
540
|
-
__decorate([
|
|
541
|
-
(0, class_validator_1.IsOptional)(),
|
|
542
|
-
(0, class_validator_1.IsString)({ each: true }),
|
|
543
|
-
__metadata("design:type", Object)
|
|
544
|
-
], VehicleFilter.prototype, "wheelsType", void 0);
|
|
545
|
-
__decorate([
|
|
546
|
-
(0, class_validator_1.IsOptional)(),
|
|
547
|
-
(0, class_validator_1.ValidateNested)(),
|
|
548
|
-
(0, class_transformer_1.Type)(() => utilities_1.NumberRange),
|
|
549
|
-
__metadata("design:type", utilities_1.NumberRange)
|
|
550
|
-
], VehicleFilter.prototype, "airbags", void 0);
|
|
551
|
-
__decorate([
|
|
552
|
-
(0, class_validator_1.IsOptional)(),
|
|
553
|
-
(0, class_validator_1.IsString)({ each: true }),
|
|
554
|
-
__metadata("design:type", Object)
|
|
555
|
-
], VehicleFilter.prototype, "transmission", void 0);
|
|
556
|
-
__decorate([
|
|
557
|
-
(0, class_validator_1.IsOptional)(),
|
|
558
|
-
(0, class_validator_1.IsString)({ each: true }),
|
|
559
|
-
__metadata("design:type", Object)
|
|
560
|
-
], VehicleFilter.prototype, "driveType", void 0);
|
|
561
|
-
__decorate([
|
|
562
|
-
(0, class_validator_1.IsOptional)(),
|
|
563
|
-
(0, class_validator_1.IsString)({ each: true }),
|
|
564
|
-
__metadata("design:type", Object)
|
|
565
|
-
], VehicleFilter.prototype, "emissions", void 0);
|
|
566
|
-
__decorate([
|
|
567
|
-
(0, class_validator_1.IsOptional)(),
|
|
568
|
-
(0, class_validator_1.ValidateNested)(),
|
|
569
|
-
(0, class_transformer_1.Type)(() => utilities_1.NumberRange),
|
|
570
|
-
__metadata("design:type", utilities_1.NumberRange)
|
|
571
|
-
], VehicleFilter.prototype, "year", void 0);
|
|
572
|
-
__decorate([
|
|
573
|
-
(0, class_validator_1.IsOptional)(),
|
|
574
|
-
(0, class_validator_1.ValidateNested)(),
|
|
575
|
-
(0, class_transformer_1.Type)(() => utilities_1.NumberRange),
|
|
576
|
-
__metadata("design:type", utilities_1.NumberRange)
|
|
577
|
-
], VehicleFilter.prototype, "price", void 0);
|
|
578
|
-
__decorate([
|
|
579
|
-
(0, class_validator_1.IsOptional)(),
|
|
580
|
-
(0, class_validator_1.IsString)({ each: true }),
|
|
581
|
-
__metadata("design:type", Object)
|
|
582
|
-
], VehicleFilter.prototype, "status", void 0);
|
|
583
|
-
__decorate([
|
|
584
|
-
(0, class_validator_1.IsOptional)(),
|
|
585
|
-
(0, class_validator_1.IsString)({ each: true }),
|
|
586
|
-
__metadata("design:type", Object)
|
|
587
|
-
], VehicleFilter.prototype, "features", void 0);
|
|
588
|
-
__decorate([
|
|
589
|
-
(0, class_validator_1.IsOptional)(),
|
|
590
|
-
(0, class_validator_1.IsString)(),
|
|
591
|
-
__metadata("design:type", String)
|
|
592
|
-
], VehicleFilter.prototype, "search", void 0);
|
|
593
|
-
exports.VehicleFilter = VehicleFilter;
|
|
594
|
-
class VehicleUniqueFilter {
|
|
595
|
-
validate() {
|
|
596
|
-
const errors = (0, class_validator_1.validateSync)(this);
|
|
597
|
-
return errors.map((error) => { var _a; return Object.values((_a = error.constraints) !== null && _a !== void 0 ? _a : {}); }).flat();
|
|
598
|
-
}
|
|
599
|
-
static fromPlain(plain) {
|
|
600
|
-
return (0, class_transformer_1.plainToClass)(VehicleUniqueFilter, plain);
|
|
601
|
-
}
|
|
602
|
-
static toPlain(entity) {
|
|
603
|
-
return (0, class_transformer_1.instanceToPlain)(entity);
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
__decorate([
|
|
607
|
-
(0, class_validator_1.IsOptional)(),
|
|
608
|
-
(0, class_validator_1.IsString)(),
|
|
609
|
-
__metadata("design:type", String)
|
|
610
|
-
], VehicleUniqueFilter.prototype, "id", void 0);
|
|
611
|
-
__decorate([
|
|
612
|
-
(0, class_validator_1.IsOptional)(),
|
|
613
|
-
(0, class_validator_1.IsString)(),
|
|
614
|
-
__metadata("design:type", String)
|
|
615
|
-
], VehicleUniqueFilter.prototype, "referenceNumber", void 0);
|
|
616
|
-
__decorate([
|
|
617
|
-
(0, class_validator_1.IsOptional)(),
|
|
618
|
-
(0, class_validator_1.IsString)(),
|
|
619
|
-
__metadata("design:type", String)
|
|
620
|
-
], VehicleUniqueFilter.prototype, "vin", void 0);
|
|
621
|
-
__decorate([
|
|
622
|
-
(0, class_validator_1.IsOptional)(),
|
|
623
|
-
(0, class_validator_1.IsString)(),
|
|
624
|
-
__metadata("design:type", String)
|
|
625
|
-
], VehicleUniqueFilter.prototype, "chassisNumber", void 0);
|
|
626
|
-
exports.VehicleUniqueFilter = VehicleUniqueFilter;
|
|
627
|
-
class VehicleOptions extends utilities_1.PaginationOptions {
|
|
628
|
-
constructor(shouldIncludeValidate = true) {
|
|
629
|
-
super();
|
|
630
|
-
if (shouldIncludeValidate) {
|
|
631
|
-
this.validate = (shouldValidate = true) => {
|
|
632
|
-
if (!shouldValidate) {
|
|
633
|
-
return [];
|
|
634
|
-
}
|
|
635
|
-
const errors = (0, class_validator_1.validateSync)(this);
|
|
636
|
-
return errors
|
|
637
|
-
.map((error) => { var _a; return Object.values((_a = error.constraints) !== null && _a !== void 0 ? _a : {}); })
|
|
638
|
-
.flat();
|
|
639
|
-
};
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
static fromPlain(plain) {
|
|
643
|
-
return (0, class_transformer_1.plainToClass)(VehicleOptions, plain);
|
|
644
|
-
}
|
|
645
|
-
static toPlain(entity) {
|
|
646
|
-
return (0, class_transformer_1.instanceToPlain)(entity);
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
exports.VehicleOptions = VehicleOptions;
|
|
650
437
|
class VehicleCategoryFilter extends utilities_1.BaseFilter {
|
|
651
438
|
validate() {
|
|
652
439
|
const errors = (0, class_validator_1.validateSync)(this);
|
|
@@ -50,3 +50,4 @@ export declare class TypedOptions<T extends Record<string, any>> extends Paginat
|
|
|
50
50
|
static fromPlain(plain: Record<string, unknown>): TypedOptions<Record<string, any>>;
|
|
51
51
|
static toPlain(entity: any): Record<string, unknown>;
|
|
52
52
|
}
|
|
53
|
+
export declare function formatImageUrl(src: string | null | undefined): string | null;
|
package/dist/global/utilities.js
CHANGED
|
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.TypedOptions = exports.TypedFilter = exports.BaseFilter = exports.NumberRange = exports.DateFilter = exports.PaginationOptions = exports.IsDateOrConvertible = exports.createFieldPath = void 0;
|
|
12
|
+
exports.formatImageUrl = exports.TypedOptions = exports.TypedFilter = exports.BaseFilter = exports.NumberRange = exports.DateFilter = exports.PaginationOptions = exports.IsDateOrConvertible = exports.createFieldPath = void 0;
|
|
13
13
|
const class_validator_1 = require("class-validator");
|
|
14
14
|
const class_transformer_1 = require("class-transformer");
|
|
15
15
|
const createFieldPath = (path) => path;
|
|
@@ -23,7 +23,9 @@ function IsDateOrConvertible(validationOptions) {
|
|
|
23
23
|
options: validationOptions,
|
|
24
24
|
validator: {
|
|
25
25
|
validate(value, _args) {
|
|
26
|
-
return value instanceof Date ||
|
|
26
|
+
return (value instanceof Date ||
|
|
27
|
+
typeof value === "string" ||
|
|
28
|
+
typeof value === "number");
|
|
27
29
|
},
|
|
28
30
|
defaultMessage(args) {
|
|
29
31
|
return `${args.property} must be a Date, string, or number`;
|
|
@@ -138,3 +140,34 @@ class TypedOptions extends PaginationOptions {
|
|
|
138
140
|
}
|
|
139
141
|
}
|
|
140
142
|
exports.TypedOptions = TypedOptions;
|
|
143
|
+
function isValidUrl(url) {
|
|
144
|
+
try {
|
|
145
|
+
new URL(url);
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
function formatImageUrl(src) {
|
|
153
|
+
if (!src) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
// Return as-is if it's already an absolute URL
|
|
157
|
+
if (isValidUrl(src)) {
|
|
158
|
+
return src;
|
|
159
|
+
}
|
|
160
|
+
// Return as-is if it's a data URL
|
|
161
|
+
if (src.startsWith("data:")) {
|
|
162
|
+
return src;
|
|
163
|
+
}
|
|
164
|
+
if (src.startsWith("/assets")) {
|
|
165
|
+
return src;
|
|
166
|
+
}
|
|
167
|
+
const domain = process.env.NEXT_PUBLIC_S3_URL;
|
|
168
|
+
// Ensure src has a leading slash
|
|
169
|
+
const normalizedSrc = src.startsWith("/") ? src : `/${src}`;
|
|
170
|
+
// Combine domain with normalized path
|
|
171
|
+
return `${domain}${normalizedSrc}`;
|
|
172
|
+
}
|
|
173
|
+
exports.formatImageUrl = formatImageUrl;
|
package/package.json
CHANGED