Files
Zumri-Backend/app/validation/supportRecommendation.schemas.js
Sathira Sri Sathara f920ca8920
CI / test (push) Successful in 10m22s
CI / test (pull_request) Successful in 10m53s
feat: Implement Phase 10 support and recommendations features
- Added models for support messages, SLA policies, tickets, ticket events, and ticket links.
- Created routes for help, help admin, newsletter, recommendations, and support for both customer and admin.
- Developed services for help, marketing (newsletter), and recommendations.
- Introduced support service for ticket management, including creation, replies, transitions, and attachments.
- Added validation schemas for support recommendations and ticket management.
- Implemented a cron job for support reconciliation and recommendation cleanup.
- Created migration for new support and recommendation database tables.
- Added unit tests for validation and policy checks related to Phase 10 features.
2026-09-09 16:07:31 +05:30

2 lines
2.9 KiB
JavaScript

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(180),text=z.string().trim().min(1).max(10000),locale=z.enum(["en","si","ta"]);exports.ticketCreate=wrap(z.object({subject:z.string().trim().min(3).max(200),categoryId:id.optional(),message:text,relatedResource:z.object({type:z.enum(["ORDER","PAYMENT","REFUND","RETURN","SHIPMENT","LOYALTY_REDEMPTION","BUSINESS_SETTLEMENT"]),id}).optional(),attachmentIds:z.array(z.number().int().positive()).max(5).default([]),source:z.enum(["WEB","MOBILE"]).default("WEB")}));exports.message=wrap(z.object({message:text,attachmentIds:z.array(z.number().int().positive()).max(5).default([])}));exports.internalNote=wrap(z.object({message:text,attachmentIds:z.array(z.number().int().positive()).max(5).default([])}));exports.assign=wrap(z.object({agentId:id}));exports.priority=wrap(z.object({priority:z.enum(["LOW","NORMAL","HIGH","URGENT"])}));exports.link=wrap(z.object({type:z.enum(["ORDER","PAYMENT","REFUND","RETURN","SHIPMENT","LOYALTY_REDEMPTION","BUSINESS_SETTLEMENT"]),id}));exports.category=wrap(z.object({code:z.string().regex(/^[A-Z][A-Z0-9_]{1,59}$/),status:z.enum(["ACTIVE","INACTIVE"]).default("ACTIVE"),translations:z.record(locale,z.object({name:z.string().min(1).max(160),description:z.string().max(500).optional()})),sortOrder:z.number().int().default(0)}));exports.sla=wrap(z.object({name:z.string().trim().min(1).max(120),status:z.enum(["ACTIVE","INACTIVE"]),priority:z.enum(["LOW","NORMAL","HIGH","URGENT"]),firstResponseMinutes:z.number().int().positive().max(43200),resolutionMinutes:z.number().int().positive().max(129600)}).refine(x=>x.resolutionMinutes>=x.firstResponseMinutes));const translation=z.object({locale,title:z.string().min(1).max(220),summary:z.string().max(500).optional(),body:text,seoTitle:z.string().max(220).optional(),seoDescription:z.string().max(500).optional()});exports.helpCategory=wrap(z.object({slug:z.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),status:z.enum(["ACTIVE","INACTIVE"]).default("ACTIVE"),sortOrder:z.number().int().default(0),iconKey:z.string().max(80).optional(),translations:z.array(z.object({locale,name:z.string().min(1).max(160),description:z.string().max(500).optional()})).min(1)}));exports.helpArticle=wrap(z.object({slug:z.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),categoryId:id,articleType:z.enum(["ARTICLE","FAQ"]).default("ARTICLE"),sortOrder:z.number().int().default(0),isFeatured:z.boolean().default(false),translations:z.array(translation).min(1)}));exports.newsletter=wrap(z.object({email:z.string().trim().email().max(254),locale:locale.default("en"),source:z.enum(["HOME_FOOTER","CHECKOUT","ACCOUNT"]).default("HOME_FOOTER")}));exports.viewEvent=wrap(z.object({eventId:id,productId:id,variantId:id.optional(),source:z.enum(["WEB","MOBILE"]).default("WEB"),sessionKey:z.string().min(16).max(200).optional()}));