feat: Implement Phase 8 Delivery and Rider Management
CI / test (push) Successful in 10m26s

- Introduced new Delivery and Rider API documentation.
- Added new models for RiderProfile, Shipment, ShipmentItem, ShipmentAssignment, ShipmentEvent, and ShipmentProof.
- Developed controllers for admin and rider logistics, including shipment management and rider actions.
- Created services for handling shipment creation, assignment, and state transitions.
- Implemented validation schemas for shipment and rider operations.
- Added new routes for admin and rider logistics, including tracking endpoints.
- Established a state machine for shipment status transitions.
- Created migration scripts for new database tables and relationships.
- Added unit tests for shipment state transitions and validation security.
This commit is contained in:
Sathira Sri Sathara
2026-09-09 12:55:32 +05:30
parent cd2c1c6d08
commit 222483d194
24 changed files with 168 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
const{z}=require("zod"),wrap=body=>z.object({body:body.strict(),params:z.object({}).passthrough(),query:z.object({}).passthrough()}),id=z.string().min(1).max(160);exports.shipment=wrap(z.object({orderId:id,items:z.array(z.object({orderItemId:id,quantity:z.number().int().positive()}).strict()).min(1),notes:z.string().max(500).optional()}));exports.returnPickup=wrap(z.object({returnRequestId:id}));exports.assign=wrap(z.object({riderId:id}));exports.reason=wrap(z.object({reasonCode:z.enum(["CUSTOMER_UNAVAILABLE","ADDRESS_NOT_FOUND","CUSTOMER_REFUSED","ACCESS_RESTRICTED","VEHICLE_ISSUE","OTHER"]),note:z.string().max(500).optional()}));exports.note=wrap(z.object({note:z.string().max(500).optional()}));exports.reschedule=wrap(z.object({scheduledDate:z.coerce.date(),timeWindowStart:z.string().max(20).optional(),timeWindowEnd:z.string().max(20).optional(),reason:z.string().min(1).max(500)}));exports.proof=wrap(z.object({type:z.enum(["SIGNATURE","PHOTO","RECIPIENT_CONFIRMATION","RETURN_PICKUP_PHOTO"]),recipientName:z.string().max(150).optional(),photoUploadId:z.number().int().positive().optional(),signatureUploadId:z.number().int().positive().optional(),notes:z.string().max(500).optional()}));exports.rider=wrap(z.object({userId:id,employeeCode:z.string().min(1).max(60),phoneOverride:z.string().max(30).optional(),vehicleType:z.string().max(60).optional(),vehicleRegistration:z.string().max(60).optional(),status:z.enum(["ACTIVE","INACTIVE","SUSPENDED"]).default("ACTIVE"),availabilityStatus:z.enum(["AVAILABLE","BUSY","OFFLINE"]).default("OFFLINE"),maxActiveAssignments:z.number().int().positive().max(20).default(1)}));exports.location=wrap(z.object({latitude:z.number().min(-90).max(90),longitude:z.number().min(-180).max(180)}));