@alba-cars/common-modules 1.3.3 → 1.3.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.
- package/dist/core/network/endpoint-config.d.ts +5 -0
- package/dist/core/network/endpoint-config.js +11 -0
- package/dist/core/network/fetch-api.d.ts +8 -0
- package/dist/core/network/fetch-api.js +130 -30
- package/dist/features/auth/data/dto/AuthDTO.d.ts +8 -7
- package/dist/features/auth/data/dto/AuthDTO.js +21 -0
- package/dist/features/auth/data/dto/RoleDTO.d.ts +37 -0
- package/dist/features/auth/data/dto/RoleDTO.js +119 -0
- package/dist/features/auth/data/dto/UserDTO.d.ts +40 -0
- package/dist/features/auth/data/dto/UserDTO.js +120 -0
- package/dist/features/auth/data/index.d.ts +2 -0
- package/dist/features/auth/data/index.js +2 -0
- package/dist/features/models/Roles.d.ts +7 -0
- package/dist/features/models/Roles.js +2 -0
- package/dist/features/models/User.d.ts +14 -0
- package/dist/features/{vehicle/data/models → models}/User.js +0 -4
- package/dist/features/{vehicle/data/models → models}/Vehicle.d.ts +8 -0
- package/dist/features/models/Vehicle.js +17 -0
- package/dist/features/{vehicle/data/models → models}/VehicleMedia.d.ts +1 -1
- package/dist/features/{vehicle/data/models → models}/index.js +1 -3
- package/dist/features/sales-team/data/dto/LanguageDTO.d.ts +20 -0
- package/dist/features/sales-team/data/dto/LanguageDTO.js +89 -0
- package/dist/features/sales-team/data/dto/SalesAgentDTO.d.ts +17 -22
- package/dist/features/sales-team/data/dto/SalesAgentDTO.js +69 -45
- package/dist/features/sales-team/data/index.d.ts +1 -0
- package/dist/features/sales-team/data/index.js +1 -0
- package/dist/features/showroom-visit/data/dto/ShowroomVisit.d.ts +19 -0
- package/dist/features/showroom-visit/data/dto/ShowroomVisit.js +46 -1
- 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/test-drive-request/data/models/TestDriveRequest.d.ts +2 -2
- package/dist/features/test-drive-request/data/models/TestDriveRequest.js +1 -1
- package/dist/features/vehicle/data/dto/VehicleFilterDTO.d.ts +6 -2
- package/dist/features/vehicle/data/dto/VehicleFilterDTO.js +21 -0
- package/dist/features/vehicle/data/dto/VehicleMakeDTO.d.ts +5 -5
- package/dist/features/vehicle/data/dto/VehicleMakeDTO.js +7 -7
- package/dist/features/vehicle/data/dto/VehicleModelDTO.d.ts +2 -2
- package/dist/features/vehicle/data/dto/VehicleModelDTO.js +2 -2
- package/dist/features/vehicle/data/dto/index.d.ts +0 -1
- package/dist/features/vehicle/data/dto/index.js +0 -1
- 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/index.d.ts +1 -1
- package/dist/features/vehicle/data/index.js +1 -1
- package/dist/features/vehicle/data/utilities.d.ts +11 -7
- package/dist/features/vehicle/data/utilities.js +20 -0
- package/dist/global/utilities.d.ts +1 -0
- package/dist/global/utilities.js +35 -2
- package/package.json +1 -1
- package/dist/core/error-handling/errorHandler.d.ts +0 -5
- package/dist/core/error-handling/errorHandler.js +0 -69
- package/dist/core/network/react-query.d.ts +0 -6
- package/dist/core/network/react-query.js +0 -15
- package/dist/features/sales-team/api/AddAgent.d.ts +0 -2
- package/dist/features/sales-team/api/AddAgent.js +0 -20
- package/dist/features/sales-team/api/EditAgent.d.ts +0 -2
- package/dist/features/sales-team/api/EditAgent.js +0 -21
- package/dist/features/sales-team/api/GetAgent.d.ts +0 -3
- package/dist/features/sales-team/api/GetAgent.js +0 -19
- package/dist/features/sales-team/api/RemoveAgent.d.ts +0 -1
- package/dist/features/sales-team/api/RemoveAgent.js +0 -15
- package/dist/features/sales-team/api/index.d.ts +0 -4
- package/dist/features/sales-team/api/index.js +0 -20
- package/dist/features/vehicle/api/make/CreateMake.d.ts +0 -2
- package/dist/features/vehicle/api/make/CreateMake.js +0 -22
- package/dist/features/vehicle/api/make/DeleteMake.d.ts +0 -2
- package/dist/features/vehicle/api/make/DeleteMake.js +0 -17
- package/dist/features/vehicle/api/make/GetAllMakes.d.ts +0 -3
- package/dist/features/vehicle/api/make/GetAllMakes.js +0 -26
- package/dist/features/vehicle/api/make/UpdateMake.d.ts +0 -2
- package/dist/features/vehicle/api/make/UpdateMake.js +0 -22
- package/dist/features/vehicle/api/models/CreateModel.d.ts +0 -2
- package/dist/features/vehicle/api/models/CreateModel.js +0 -22
- package/dist/features/vehicle/api/models/DeleteModel.d.ts +0 -2
- package/dist/features/vehicle/api/models/DeleteModel.js +0 -17
- package/dist/features/vehicle/api/models/GetAllModels.d.ts +0 -3
- package/dist/features/vehicle/api/models/GetAllModels.js +0 -37
- package/dist/features/vehicle/api/models/UpdateModel.d.ts +0 -2
- package/dist/features/vehicle/api/models/UpdateModel.js +0 -22
- package/dist/features/vehicle/data/dto/UserDTO.d.ts +0 -16
- package/dist/features/vehicle/data/dto/UserDTO.js +0 -53
- package/dist/features/vehicle/data/models/User.d.ts +0 -15
- package/dist/features/vehicle/data/models/Vehicle.js +0 -7
- /package/dist/features/{vehicle/data/models → models}/Base.d.ts +0 -0
- /package/dist/features/{vehicle/data/models → models}/Base.js +0 -0
- /package/dist/features/{vehicle/data/models → models}/Payment.d.ts +0 -0
- /package/dist/features/{vehicle/data/models → models}/Payment.js +0 -0
- /package/dist/features/{vehicle/data/models → models}/VehicleBodyType.d.ts +0 -0
- /package/dist/features/{vehicle/data/models → models}/VehicleBodyType.js +0 -0
- /package/dist/features/{vehicle/data/models → models}/VehicleCategory.d.ts +0 -0
- /package/dist/features/{vehicle/data/models → models}/VehicleCategory.js +0 -0
- /package/dist/features/{vehicle/data/models → models}/VehicleFeature.d.ts +0 -0
- /package/dist/features/{vehicle/data/models → models}/VehicleFeature.js +0 -0
- /package/dist/features/{vehicle/data/models → models}/VehicleFeatureCategory.d.ts +0 -0
- /package/dist/features/{vehicle/data/models → models}/VehicleFeatureCategory.js +0 -0
- /package/dist/features/{vehicle/data/models → models}/VehicleFinance.d.ts +0 -0
- /package/dist/features/{vehicle/data/models → models}/VehicleFinance.js +0 -0
- /package/dist/features/{vehicle/data/models → models}/VehicleMake.d.ts +0 -0
- /package/dist/features/{vehicle/data/models → models}/VehicleMake.js +0 -0
- /package/dist/features/{vehicle/data/models → models}/VehicleMedia.js +0 -0
- /package/dist/features/{vehicle/data/models → models}/VehicleMetaData.d.ts +0 -0
- /package/dist/features/{vehicle/data/models → models}/VehicleMetaData.js +0 -0
- /package/dist/features/{vehicle/data/models → models}/VehicleModel.d.ts +0 -0
- /package/dist/features/{vehicle/data/models → models}/VehicleModel.js +0 -0
- /package/dist/features/{vehicle/data/models → models}/VehicleOrder.d.ts +0 -0
- /package/dist/features/{vehicle/data/models → models}/VehicleOrder.js +0 -0
- /package/dist/features/{vehicle/data/models → models}/_index.d.ts +0 -0
- /package/dist/features/{vehicle/data/models → models}/_index.js +0 -0
- /package/dist/features/{vehicle/data/models → models}/index.d.ts +0 -0
|
@@ -641,11 +641,32 @@ __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, "includeSold", void 0);
|
|
665
|
+
__decorate([
|
|
666
|
+
(0, class_validator_1.IsOptional)(),
|
|
667
|
+
(0, class_validator_1.IsBoolean)(),
|
|
668
|
+
__metadata("design:type", Boolean)
|
|
669
|
+
], VehicleFilter.prototype, "includeDraft", void 0);
|
|
649
670
|
__decorate([
|
|
650
671
|
(0, class_validator_1.IsOptional)(),
|
|
651
672
|
(0, class_validator_1.IsString)({ each: true }),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { VehicleMakeFilter, VehicleMakeOptions, VehicleMakeUniqueFilter } from
|
|
2
|
-
import { BaseCreateDTO, BaseUpdateDTO } from
|
|
3
|
-
import { VehicleMake } from
|
|
1
|
+
import { VehicleMakeFilter, VehicleMakeOptions, VehicleMakeUniqueFilter } from "../utilities";
|
|
2
|
+
import { BaseCreateDTO, BaseUpdateDTO } from "./BaseDTO";
|
|
3
|
+
import { VehicleMake } from "../../../models";
|
|
4
4
|
export declare class VehicleMakeGetDTO {
|
|
5
5
|
filter?: VehicleMakeFilter;
|
|
6
6
|
options?: VehicleMakeOptions;
|
|
@@ -8,10 +8,10 @@ export declare class VehicleMakeGetDTO {
|
|
|
8
8
|
static fromPlain(plain: Record<string, unknown>): VehicleMakeGetDTO;
|
|
9
9
|
static toPlain(entity: any): Record<string, unknown>;
|
|
10
10
|
}
|
|
11
|
-
export type VehicleMakeApiResponse = Omit<VehicleMake,
|
|
11
|
+
export type VehicleMakeApiResponse = Omit<VehicleMake, "createdBy" | "updatedBy" | "deletedBy" | "_id">;
|
|
12
12
|
export declare class VehicleMakeGetUniqueDTO {
|
|
13
13
|
filter?: VehicleMakeUniqueFilter;
|
|
14
|
-
options?: Omit<VehicleMakeOptions,
|
|
14
|
+
options?: Omit<VehicleMakeOptions, "page" | "limit" | "sort">;
|
|
15
15
|
validate(): string[];
|
|
16
16
|
static fromPlain(plain: Record<string, unknown>): VehicleMakeGetUniqueDTO;
|
|
17
17
|
static toPlain(entity: any): Record<string, unknown>;
|
|
@@ -17,7 +17,7 @@ const BaseDTO_1 = require("./BaseDTO");
|
|
|
17
17
|
class VehicleMakeGetDTO {
|
|
18
18
|
validate() {
|
|
19
19
|
const errors = (0, class_validator_1.validateSync)(this);
|
|
20
|
-
return errors.map(error => { var _a; return Object.values((_a = error.constraints) !== null && _a !== void 0 ? _a : {}); }).flat();
|
|
20
|
+
return errors.map((error) => { var _a; return Object.values((_a = error.constraints) !== null && _a !== void 0 ? _a : {}); }).flat();
|
|
21
21
|
}
|
|
22
22
|
static fromPlain(plain) {
|
|
23
23
|
return (0, class_transformer_1.plainToClass)(VehicleMakeGetDTO, plain);
|
|
@@ -31,7 +31,7 @@ exports.VehicleMakeGetDTO = VehicleMakeGetDTO;
|
|
|
31
31
|
class VehicleMakeGetUniqueDTO {
|
|
32
32
|
validate() {
|
|
33
33
|
const errors = (0, class_validator_1.validateSync)(this);
|
|
34
|
-
return errors.map(error => { var _a; return Object.values((_a = error.constraints) !== null && _a !== void 0 ? _a : {}); }).flat();
|
|
34
|
+
return errors.map((error) => { var _a; return Object.values((_a = error.constraints) !== null && _a !== void 0 ? _a : {}); }).flat();
|
|
35
35
|
}
|
|
36
36
|
static fromPlain(plain) {
|
|
37
37
|
return (0, class_transformer_1.plainToClass)(VehicleMakeGetUniqueDTO, plain);
|
|
@@ -47,7 +47,7 @@ class VehicleMakeCreateDTO extends BaseDTO_1.BaseCreateDTO {
|
|
|
47
47
|
// - We cannot create a attach vehicles and models to a make during creation because the make should be created first and then the vehicles and models should be created and attached to the make.
|
|
48
48
|
validate() {
|
|
49
49
|
const errors = (0, class_validator_1.validateSync)(this);
|
|
50
|
-
return errors.map(error => { var _a; return Object.values((_a = error.constraints) !== null && _a !== void 0 ? _a : {}); }).flat();
|
|
50
|
+
return errors.map((error) => { var _a; return Object.values((_a = error.constraints) !== null && _a !== void 0 ? _a : {}); }).flat();
|
|
51
51
|
}
|
|
52
52
|
static fromPlain(plain) {
|
|
53
53
|
return (0, class_transformer_1.plainToClass)(VehicleMakeCreateDTO, plain);
|
|
@@ -61,7 +61,7 @@ __decorate([
|
|
|
61
61
|
(0, class_validator_1.IsNotEmpty)(),
|
|
62
62
|
(0, class_validator_1.IsDefined)(),
|
|
63
63
|
(0, class_validator_1.Matches)(/^[a-zA-Z0-9\s\-\_]*$/, {
|
|
64
|
-
message:
|
|
64
|
+
message: "Name can only contain letters, numbers, spaces, hyphens, and underscores.",
|
|
65
65
|
}),
|
|
66
66
|
__metadata("design:type", String)
|
|
67
67
|
], VehicleMakeCreateDTO.prototype, "name", void 0);
|
|
@@ -94,7 +94,7 @@ exports.VehicleMakeCreateDTO = VehicleMakeCreateDTO;
|
|
|
94
94
|
class VehicleMakeUpdateDTO extends BaseDTO_1.BaseUpdateDTO {
|
|
95
95
|
validate() {
|
|
96
96
|
const errors = (0, class_validator_1.validateSync)(this);
|
|
97
|
-
return errors.map(error => { var _a; return Object.values((_a = error.constraints) !== null && _a !== void 0 ? _a : {}); }).flat();
|
|
97
|
+
return errors.map((error) => { var _a; return Object.values((_a = error.constraints) !== null && _a !== void 0 ? _a : {}); }).flat();
|
|
98
98
|
}
|
|
99
99
|
static fromPlain(plain) {
|
|
100
100
|
return (0, class_transformer_1.plainToClass)(VehicleMakeUpdateDTO, plain);
|
|
@@ -107,7 +107,7 @@ __decorate([
|
|
|
107
107
|
(0, class_validator_1.IsString)(),
|
|
108
108
|
(0, class_validator_1.IsOptional)(),
|
|
109
109
|
(0, class_validator_1.Matches)(/^[a-zA-Z0-9\s\-\_]*$/, {
|
|
110
|
-
message:
|
|
110
|
+
message: "Name can only contain letters, numbers, spaces, hyphens, and underscores.",
|
|
111
111
|
}),
|
|
112
112
|
__metadata("design:type", String)
|
|
113
113
|
], VehicleMakeUpdateDTO.prototype, "name", void 0);
|
|
@@ -145,7 +145,7 @@ exports.VehicleMakeUpdateDTO = VehicleMakeUpdateDTO;
|
|
|
145
145
|
class DynamicMakeDTO {
|
|
146
146
|
validate() {
|
|
147
147
|
if (!this.existingId && !this.new) {
|
|
148
|
-
throw new Error(
|
|
148
|
+
throw new Error("Either existingId or new details must be provided.");
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
static fromPlain(plain) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseCreateDTO, BaseUpdateDTO } from "./BaseDTO";
|
|
2
|
-
import { Vehicle } from "
|
|
3
|
-
import { VehicleMake } from "
|
|
2
|
+
import { Vehicle } from "../../../models/Vehicle";
|
|
3
|
+
import { VehicleMake } from "../../../models/VehicleMake";
|
|
4
4
|
import { VehicleModelFilter, VehicleModelOptions, VehicleModelUniqueFilter } from "../utilities";
|
|
5
5
|
export declare class VehicleModelGetDTO {
|
|
6
6
|
filter?: VehicleModelFilter;
|
|
@@ -14,8 +14,8 @@ 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 Vehicle_1 = require("
|
|
18
|
-
const VehicleMake_1 = require("
|
|
17
|
+
const Vehicle_1 = require("../../../models/Vehicle");
|
|
18
|
+
const VehicleMake_1 = require("../../../models/VehicleMake");
|
|
19
19
|
class VehicleModelGetDTO {
|
|
20
20
|
validate() {
|
|
21
21
|
const errors = (0, class_validator_1.validateSync)(this);
|
|
@@ -16,7 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./BaseDTO"), exports);
|
|
18
18
|
__exportStar(require("./PaymentDTO"), exports);
|
|
19
|
-
__exportStar(require("./UserDTO"), exports);
|
|
20
19
|
__exportStar(require("./VehicleDTO"), exports);
|
|
21
20
|
__exportStar(require("./VehicleFeatureCategoriesDTO"), exports);
|
|
22
21
|
__exportStar(require("./VehicleFeatureDTO"), exports);
|
|
@@ -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 = {}));
|
|
@@ -16,5 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./dto"), exports);
|
|
18
18
|
__exportStar(require("./enums/index"), exports);
|
|
19
|
-
__exportStar(require("
|
|
19
|
+
__exportStar(require("../../models/_index"), exports);
|
|
20
20
|
// export * from "./utilities";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Vehicle } from "
|
|
2
|
-
import { VehicleBodyType } from "
|
|
3
|
-
import { VehicleFeature } from "
|
|
4
|
-
import { VehicleMake } from "
|
|
5
|
-
import { VehicleMetaData } from "
|
|
6
|
-
import { VehicleModel } from "
|
|
7
|
-
import { VehicleCategory } from "
|
|
1
|
+
import { Vehicle } from "../../models/Vehicle";
|
|
2
|
+
import { VehicleBodyType } from "../../models/VehicleBodyType";
|
|
3
|
+
import { VehicleFeature } from "../../models/VehicleFeature";
|
|
4
|
+
import { VehicleMake } from "../../models/VehicleMake";
|
|
5
|
+
import { VehicleMetaData } from "../../models/VehicleMetaData";
|
|
6
|
+
import { VehicleModel } from "../../models/VehicleModel";
|
|
7
|
+
import { VehicleCategory } from "../../models/VehicleCategory";
|
|
8
8
|
import { BaseFilter, NumberRange, PaginationOptions } from "../../../global/utilities";
|
|
9
9
|
import { VehicleCategorySelectFields } from "./dto/VehicleFilterDTO";
|
|
10
10
|
export type VehicleMakeSelectFields = keyof VehicleMake;
|
|
@@ -179,6 +179,10 @@ export declare class VehicleFilter extends BaseFilter {
|
|
|
179
179
|
emissions?: string | string[];
|
|
180
180
|
year?: NumberRange;
|
|
181
181
|
price?: NumberRange;
|
|
182
|
+
includeReserved?: boolean;
|
|
183
|
+
includeSelfReserved?: boolean;
|
|
184
|
+
includeSold?: boolean;
|
|
185
|
+
includeDraft?: boolean;
|
|
182
186
|
status?: string | string[];
|
|
183
187
|
features?: string | string[];
|
|
184
188
|
search?: string;
|
|
@@ -575,6 +575,26 @@ __decorate([
|
|
|
575
575
|
(0, class_transformer_1.Type)(() => utilities_1.NumberRange),
|
|
576
576
|
__metadata("design:type", utilities_1.NumberRange)
|
|
577
577
|
], VehicleFilter.prototype, "price", void 0);
|
|
578
|
+
__decorate([
|
|
579
|
+
(0, class_validator_1.IsOptional)(),
|
|
580
|
+
(0, class_validator_1.IsBoolean)(),
|
|
581
|
+
__metadata("design:type", Boolean)
|
|
582
|
+
], VehicleFilter.prototype, "includeReserved", void 0);
|
|
583
|
+
__decorate([
|
|
584
|
+
(0, class_validator_1.IsOptional)(),
|
|
585
|
+
(0, class_validator_1.IsBoolean)(),
|
|
586
|
+
__metadata("design:type", Boolean)
|
|
587
|
+
], VehicleFilter.prototype, "includeSelfReserved", void 0);
|
|
588
|
+
__decorate([
|
|
589
|
+
(0, class_validator_1.IsOptional)(),
|
|
590
|
+
(0, class_validator_1.IsBoolean)(),
|
|
591
|
+
__metadata("design:type", Boolean)
|
|
592
|
+
], VehicleFilter.prototype, "includeSold", void 0);
|
|
593
|
+
__decorate([
|
|
594
|
+
(0, class_validator_1.IsOptional)(),
|
|
595
|
+
(0, class_validator_1.IsBoolean)(),
|
|
596
|
+
__metadata("design:type", Boolean)
|
|
597
|
+
], VehicleFilter.prototype, "includeDraft", void 0);
|
|
578
598
|
__decorate([
|
|
579
599
|
(0, class_validator_1.IsOptional)(),
|
|
580
600
|
(0, class_validator_1.IsString)({ each: true }),
|
|
@@ -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
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { Request, Response, NextFunction } from "express";
|
|
2
|
-
type AsyncFunction = (req: Request, res: Response, next: NextFunction) => Promise<any>;
|
|
3
|
-
export declare function asyncHandler(fn: AsyncFunction): (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
4
|
-
export declare function globalErrorHandlerMiddleware(err: Error, req: Request, res: Response, next: NextFunction): void;
|
|
5
|
-
export {};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// errorHandler.ts
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.globalErrorHandlerMiddleware = exports.asyncHandler = void 0;
|
|
5
|
-
const AppError_1 = require("./AppError");
|
|
6
|
-
function asyncHandler(fn) {
|
|
7
|
-
return async (req, res, next) => {
|
|
8
|
-
try {
|
|
9
|
-
await fn(req, res, next);
|
|
10
|
-
}
|
|
11
|
-
catch (error) {
|
|
12
|
-
// Log the original error with stack trace
|
|
13
|
-
console.error("[Error Handler]", {
|
|
14
|
-
timestamp: new Date().toISOString(),
|
|
15
|
-
path: req.path,
|
|
16
|
-
method: req.method,
|
|
17
|
-
error: {
|
|
18
|
-
name: error instanceof Error ? error.name : "Unknown Error",
|
|
19
|
-
message: error instanceof Error ? error.message : String(error),
|
|
20
|
-
stack: error instanceof Error ? error.stack : undefined,
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
// Transform to AppError if needed
|
|
24
|
-
const appError = error instanceof AppError_1.AppError
|
|
25
|
-
? error
|
|
26
|
-
: AppError_1.AppError.internal("Internal Server Error", error instanceof Error ? error.message : undefined);
|
|
27
|
-
// Log the transformed error response
|
|
28
|
-
console.info("[Error Response]", {
|
|
29
|
-
statusCode: appError.statusCode,
|
|
30
|
-
type: appError.type,
|
|
31
|
-
message: appError.message,
|
|
32
|
-
details: appError.details,
|
|
33
|
-
});
|
|
34
|
-
// Send error response
|
|
35
|
-
res.status(appError.statusCode).json({
|
|
36
|
-
error: {
|
|
37
|
-
type: appError.type,
|
|
38
|
-
message: appError.message,
|
|
39
|
-
details: appError.details,
|
|
40
|
-
...(process.env.NODE_ENV === "development" && {
|
|
41
|
-
stack: appError.stack,
|
|
42
|
-
}),
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
exports.asyncHandler = asyncHandler;
|
|
49
|
-
function globalErrorHandlerMiddleware(err, req, res, next) {
|
|
50
|
-
if (res.headersSent) {
|
|
51
|
-
return next(err);
|
|
52
|
-
}
|
|
53
|
-
let error = err;
|
|
54
|
-
console.log(error);
|
|
55
|
-
if (!(error instanceof AppError_1.AppError)) {
|
|
56
|
-
error = AppError_1.AppError.internal("Internal Server Error");
|
|
57
|
-
}
|
|
58
|
-
const appError = error;
|
|
59
|
-
console.log(appError.statusCode);
|
|
60
|
-
console.log(appError.details);
|
|
61
|
-
res.status(appError.statusCode).json({
|
|
62
|
-
error: {
|
|
63
|
-
type: appError.type,
|
|
64
|
-
message: appError.message,
|
|
65
|
-
details: appError.details,
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
exports.globalErrorHandlerMiddleware = globalErrorHandlerMiddleware;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { UseMutationOptions } from "@tanstack/react-query";
|
|
2
|
-
export declare const queryConfig: DefaultOptions;
|
|
3
|
-
export declare const queryClient: any;
|
|
4
|
-
export type ApiFnReturnType<FnType extends (..._args: any) => Promise<any>> = Awaited<ReturnType<FnType>>;
|
|
5
|
-
export type QueryConfig<T extends (..._args: any[]) => any> = Omit<ReturnType<T>, "queryKey" | "queryFn">;
|
|
6
|
-
export type MutationConfig<MutationFnType extends (..._args: any) => Promise<any>> = UseMutationOptions<ApiFnReturnType<MutationFnType>, Error, Parameters<MutationFnType>[0]>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.queryClient = exports.queryConfig = void 0;
|
|
4
|
-
const react_query_1 = require("@tanstack/react-query");
|
|
5
|
-
const global_constants_1 = require("../utils/global-constants");
|
|
6
|
-
exports.queryConfig = {
|
|
7
|
-
queries: {
|
|
8
|
-
refetchOnWindowFocus: false,
|
|
9
|
-
retry: false,
|
|
10
|
-
staleTime: global_constants_1.ONE_MINUTE_MILLIS,
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
exports.queryClient = new react_query_1.QueryClient({
|
|
14
|
-
defaultOptions: exports.queryConfig,
|
|
15
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use server";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.addAgent = void 0;
|
|
5
|
-
const core_1 = require("../../../core");
|
|
6
|
-
async function addAgent(agentDTO) {
|
|
7
|
-
try {
|
|
8
|
-
const formattedAgentDTO = {
|
|
9
|
-
...agentDTO,
|
|
10
|
-
dob: agentDTO.dob ? new Date(agentDTO.dob).toISOString() : null,
|
|
11
|
-
};
|
|
12
|
-
const res = await (0, core_1.apiRequest)(core_1.API_ENDPOINTS.agents.create.toString(), { method: "POST", body: JSON.stringify(formattedAgentDTO) });
|
|
13
|
-
return res;
|
|
14
|
-
}
|
|
15
|
-
catch (error) {
|
|
16
|
-
console.error('Failed to add agent:', error);
|
|
17
|
-
return Promise.reject(error);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.addAgent = addAgent;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use server";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.editAgent = void 0;
|
|
5
|
-
const core_1 = require("../../../core");
|
|
6
|
-
async function editAgent(id, agentDTO) {
|
|
7
|
-
try {
|
|
8
|
-
const formattedAgentDTO = {
|
|
9
|
-
...agentDTO,
|
|
10
|
-
dob: agentDTO.dob ? new Date(agentDTO.dob).toISOString() : null, // Ensure this is a valid ISO date string
|
|
11
|
-
};
|
|
12
|
-
const res = await (0, core_1.apiRequest)(`${core_1.API_ENDPOINTS.agents.updateOne(id)}`, // Pass the ID in the endpoint
|
|
13
|
-
{ method: "PUT", body: JSON.stringify(formattedAgentDTO) });
|
|
14
|
-
return res;
|
|
15
|
-
}
|
|
16
|
-
catch (error) {
|
|
17
|
-
console.error('Failed to edit agent:', error);
|
|
18
|
-
return Promise.reject(error);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.editAgent = editAgent;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchAgents = void 0;
|
|
4
|
-
const core_1 = require("../../../core");
|
|
5
|
-
const fetchAgents = async (page, searchQuery) => {
|
|
6
|
-
try {
|
|
7
|
-
const queryParams = { page: `${page}`, limit: "10" };
|
|
8
|
-
if ((searchQuery !== null && searchQuery !== void 0 ? searchQuery : "").trim().length > 1) {
|
|
9
|
-
queryParams.searchQuery = searchQuery;
|
|
10
|
-
}
|
|
11
|
-
const res = await (0, core_1.apiRequest)(core_1.API_ENDPOINTS.agents.getAll.toString(), { query: queryParams });
|
|
12
|
-
return res;
|
|
13
|
-
}
|
|
14
|
-
catch (error) {
|
|
15
|
-
console.error('Failed to fetch agents:', error);
|
|
16
|
-
return Promise.reject(error);
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
exports.fetchAgents = fetchAgents;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const removeAgent: (agentId: string) => Promise<boolean>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeAgent = void 0;
|
|
4
|
-
const core_1 = require("../../../core");
|
|
5
|
-
const removeAgent = async (agentId) => {
|
|
6
|
-
try {
|
|
7
|
-
const result = await (0, core_1.apiRequest)(core_1.API_ENDPOINTS.agents.deleteOne(agentId), { method: "DELETE" });
|
|
8
|
-
console.log("Agent delete result is ", result);
|
|
9
|
-
return true;
|
|
10
|
-
}
|
|
11
|
-
catch (error) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
exports.removeAgent = removeAgent;
|
|
@@ -1,20 +0,0 @@
|
|
|
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("./AddAgent"), exports);
|
|
18
|
-
__exportStar(require("./EditAgent"), exports);
|
|
19
|
-
__exportStar(require("./GetAgent"), exports);
|
|
20
|
-
__exportStar(require("./RemoveAgent"), exports);
|
|
@@ -1,22 +0,0 @@
|
|
|
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;
|
|
@@ -1,17 +0,0 @@
|
|
|
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;
|