@alba-cars/common-modules 1.3.3 → 1.3.4
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 +121 -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 +6 -0
- package/dist/features/{vehicle/data/models → models}/Vehicle.js +4 -1
- 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 +67 -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/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 +2 -2
- 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/index.d.ts +1 -1
- package/dist/features/vehicle/data/index.js +1 -1
- package/dist/features/vehicle/data/utilities.d.ts +7 -7
- 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 → 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
|
@@ -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);
|
|
@@ -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;
|
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;
|
|
@@ -1,26 +0,0 @@
|
|
|
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;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateVehicleMake = void 0;
|
|
4
|
-
const core_1 = require("../../../../core");
|
|
5
|
-
const updateVehicleMake = async (makeID, params) => {
|
|
6
|
-
var _a, _b;
|
|
7
|
-
try {
|
|
8
|
-
const res = await (0, core_1.apiRequest)(core_1.API_ENDPOINTS.vehicleMake.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.log('Failed to update make with id:', makeID, 'Error:', error);
|
|
19
|
-
return await Promise.reject(error);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
exports.updateVehicleMake = updateVehicleMake;
|
|
@@ -1,22 +0,0 @@
|
|
|
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;
|
|
@@ -1,17 +0,0 @@
|
|
|
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;
|
|
@@ -1,37 +0,0 @@
|
|
|
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;
|
|
@@ -1,22 +0,0 @@
|
|
|
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;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export declare class UserGetDTO {
|
|
2
|
-
id: number;
|
|
3
|
-
name: string;
|
|
4
|
-
static fromEntity(entity: any): UserGetDTO;
|
|
5
|
-
toPlain(): Record<string, unknown>;
|
|
6
|
-
}
|
|
7
|
-
export declare class UserCreateDTO {
|
|
8
|
-
name: string;
|
|
9
|
-
validate(): string[];
|
|
10
|
-
static fromPlain(plain: Record<string, unknown>): UserCreateDTO;
|
|
11
|
-
}
|
|
12
|
-
export declare class UserUpdateDTO {
|
|
13
|
-
name?: string;
|
|
14
|
-
validate(): string[];
|
|
15
|
-
static fromPlain(plain: Record<string, unknown>): UserUpdateDTO;
|
|
16
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// UserDTO.ts
|
|
3
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
4
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
7
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8
|
-
};
|
|
9
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
10
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.UserUpdateDTO = exports.UserCreateDTO = exports.UserGetDTO = void 0;
|
|
14
|
-
const class_validator_1 = require("class-validator");
|
|
15
|
-
const class_transformer_1 = require("class-transformer");
|
|
16
|
-
class UserGetDTO {
|
|
17
|
-
static fromEntity(entity) {
|
|
18
|
-
return (0, class_transformer_1.plainToClass)(UserGetDTO, entity);
|
|
19
|
-
}
|
|
20
|
-
toPlain() {
|
|
21
|
-
return (0, class_transformer_1.classToPlain)(this);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.UserGetDTO = UserGetDTO;
|
|
25
|
-
class UserCreateDTO {
|
|
26
|
-
validate() {
|
|
27
|
-
const errors = (0, class_validator_1.validateSync)(this);
|
|
28
|
-
return errors.map(error => { var _a; return Object.values((_a = error.constraints) !== null && _a !== void 0 ? _a : {}); }).flat();
|
|
29
|
-
}
|
|
30
|
-
static fromPlain(plain) {
|
|
31
|
-
return (0, class_transformer_1.plainToClass)(UserCreateDTO, plain);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
__decorate([
|
|
35
|
-
(0, class_validator_1.IsString)(),
|
|
36
|
-
__metadata("design:type", String)
|
|
37
|
-
], UserCreateDTO.prototype, "name", void 0);
|
|
38
|
-
exports.UserCreateDTO = UserCreateDTO;
|
|
39
|
-
class UserUpdateDTO {
|
|
40
|
-
validate() {
|
|
41
|
-
const errors = (0, class_validator_1.validateSync)(this);
|
|
42
|
-
return errors.map(error => { var _a; return Object.values((_a = error.constraints) !== null && _a !== void 0 ? _a : {}); }).flat();
|
|
43
|
-
}
|
|
44
|
-
static fromPlain(plain) {
|
|
45
|
-
return (0, class_transformer_1.plainToClass)(UserUpdateDTO, plain);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
__decorate([
|
|
49
|
-
(0, class_validator_1.IsOptional)(),
|
|
50
|
-
(0, class_validator_1.IsString)(),
|
|
51
|
-
__metadata("design:type", String)
|
|
52
|
-
], UserUpdateDTO.prototype, "name", void 0);
|
|
53
|
-
exports.UserUpdateDTO = UserUpdateDTO;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare class User {
|
|
2
|
-
id: string;
|
|
3
|
-
refId: number;
|
|
4
|
-
createdBy: User;
|
|
5
|
-
updatedBy: User;
|
|
6
|
-
deletedBy: User;
|
|
7
|
-
isDeleted: boolean;
|
|
8
|
-
isActive: boolean;
|
|
9
|
-
createdAt: Date;
|
|
10
|
-
updatedAt: Date;
|
|
11
|
-
name: string;
|
|
12
|
-
email: string;
|
|
13
|
-
phone: string;
|
|
14
|
-
userId: string;
|
|
15
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|