Files
alrahma_sunday_school_api/apps/api/dist/modules/vehicles/vehicle.schemas.js
T
2026-06-11 03:22:12 -04:00

94 lines
5.4 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.pricingRuleParamSchema = exports.blockIdParamSchema = exports.photoIdxSchema = exports.idParamSchema = exports.statusSchema = exports.publishSchema = exports.pricingRuleSchema = exports.pricingConfigSchema = exports.maintenanceLogSchema = exports.calendarBlockSchema = exports.calendarQuerySchema = exports.availabilityQuerySchema = exports.listQuerySchema = exports.vehicleSchema = void 0;
const zod_1 = require("zod");
exports.vehicleSchema = zod_1.z.object({
make: zod_1.z.string().min(1),
model: zod_1.z.string().min(1),
year: zod_1.z.number().int().min(1990).max(new Date().getFullYear() + 1),
color: zod_1.z.string().default(''),
licensePlate: zod_1.z.string().min(1),
vin: zod_1.z.string().optional(),
category: zod_1.z.enum(['ECONOMY', 'COMPACT', 'MIDSIZE', 'FULLSIZE', 'SUV', 'LUXURY', 'VAN', 'TRUCK']),
seats: zod_1.z.number().int().min(1).max(20).default(5),
transmission: zod_1.z.enum(['AUTOMATIC', 'MANUAL']).default('AUTOMATIC'),
fuelType: zod_1.z.enum(['GASOLINE', 'DIESEL', 'ELECTRIC', 'HYBRID']).default('GASOLINE'),
features: zod_1.z.array(zod_1.z.string()).default([]),
dailyRate: zod_1.z.number().int().min(0).optional(),
mileage: zod_1.z.number().int().optional(),
notes: zod_1.z.string().optional(),
isPublished: zod_1.z.boolean().default(true),
status: zod_1.z.enum(['AVAILABLE', 'RESERVED', 'READY', 'RENTED', 'RETURNED', 'NEEDS_CLEANING', 'MAINTENANCE', 'DAMAGE_REVIEW', 'OUT_OF_SERVICE']).optional(),
pickupLocations: zod_1.z.array(zod_1.z.string().trim().min(1)).default([]),
allowDifferentDropoff: zod_1.z.boolean().default(false),
dropoffLocations: zod_1.z.array(zod_1.z.string().trim().min(1)).default([]),
});
exports.listQuerySchema = zod_1.z.object({
status: zod_1.z.string().optional(),
category: zod_1.z.string().optional(),
published: zod_1.z.string().optional(),
page: zod_1.z.coerce.number().int().min(1).default(1),
pageSize: zod_1.z.coerce.number().int().min(1).max(100).default(20),
});
exports.availabilityQuerySchema = zod_1.z.object({
startDate: zod_1.z.string(),
endDate: zod_1.z.string(),
});
exports.calendarQuerySchema = zod_1.z.object({
year: zod_1.z.coerce.number().int(),
month: zod_1.z.coerce.number().int().min(1).max(12),
});
exports.calendarBlockSchema = zod_1.z.object({
startDate: zod_1.z.string().datetime({ offset: true }).or(zod_1.z.string().regex(/^\d{4}-\d{2}-\d{2}$/)),
endDate: zod_1.z.string().datetime({ offset: true }).or(zod_1.z.string().regex(/^\d{4}-\d{2}-\d{2}$/)),
reason: zod_1.z.string().optional(),
type: zod_1.z.enum(['MANUAL', 'MAINTENANCE']).default('MANUAL'),
});
exports.maintenanceLogSchema = zod_1.z.object({
type: zod_1.z.string().min(1),
description: zod_1.z.string().optional(),
cost: zod_1.z.number().int().optional(),
mileage: zod_1.z.number().int().optional(),
performedAt: zod_1.z.string().datetime(),
nextDueAt: zod_1.z.string().datetime().optional(),
nextDueMileage: zod_1.z.number().int().optional(),
});
const nullableRateSchema = zod_1.z.number().int().min(0).nullable().optional();
exports.pricingConfigSchema = zod_1.z.object({
pricingMode: zod_1.z.enum(['MANUAL', 'AUTOMATIC']),
baseDailyRate: zod_1.z.number().int().min(0),
weeklyRate: nullableRateSchema,
weekendRate: nullableRateSchema,
holidayRate: nullableRateSchema,
monthlyRate: nullableRateSchema,
longTermDailyRate: nullableRateSchema,
minimumDailyRate: nullableRateSchema,
maximumDailyRate: nullableRateSchema,
maxDailyPriceMovementPct: zod_1.z.number().int().min(0).max(100).default(10),
automaticPricingEnabled: zod_1.z.boolean().default(false),
approvalRequired: zod_1.z.boolean().default(false),
note: zod_1.z.string().trim().min(1).max(500).optional(),
});
exports.pricingRuleSchema = zod_1.z.object({
name: zod_1.z.string().trim().min(1).max(120),
ruleType: zod_1.z.enum(['DATE_RANGE', 'SEASONAL', 'HOLIDAY', 'WEEKEND', 'SPECIAL_EVENT', 'MANUAL_OVERRIDE']).default('DATE_RANGE'),
startDate: zod_1.z.string().datetime({ offset: true }).or(zod_1.z.string().regex(/^\d{4}-\d{2}-\d{2}$/)),
endDate: zod_1.z.string().datetime({ offset: true }).or(zod_1.z.string().regex(/^\d{4}-\d{2}-\d{2}$/)),
dailyRate: nullableRateSchema,
weeklyRate: nullableRateSchema,
weekendRate: nullableRateSchema,
monthlyRate: nullableRateSchema,
minDailyRate: nullableRateSchema,
maxDailyRate: nullableRateSchema,
automaticAdjustmentPct: zod_1.z.number().int().min(-100).max(200).nullable().optional(),
priceAdjustment: zod_1.z.number().int().nullable().optional(),
isActive: zod_1.z.boolean().default(true),
sortOrder: zod_1.z.number().int().min(0).max(1000).default(0),
});
exports.publishSchema = zod_1.z.object({ isPublished: zod_1.z.boolean() });
exports.statusSchema = zod_1.z.object({ status: zod_1.z.enum(['AVAILABLE', 'RESERVED', 'READY', 'RENTED', 'RETURNED', 'NEEDS_CLEANING', 'MAINTENANCE', 'DAMAGE_REVIEW', 'OUT_OF_SERVICE']) });
exports.idParamSchema = zod_1.z.object({ id: zod_1.z.string() });
exports.photoIdxSchema = zod_1.z.object({ id: zod_1.z.string(), idx: zod_1.z.string() });
exports.blockIdParamSchema = zod_1.z.object({ id: zod_1.z.string(), blockId: zod_1.z.string() });
exports.pricingRuleParamSchema = zod_1.z.object({ id: zod_1.z.string(), ruleId: zod_1.z.string() });
//# sourceMappingURL=vehicle.schemas.js.map