- Replaced multiple global exception filters with a unified exception filter to streamline error handling across the application. - Removed deprecated AuthErrorFilter and GlobalExceptionFilter to reduce redundancy. - Enhanced SupportController to include new endpoints for listing, retrieving, and creating support cases, improving the support case management functionality. - Integrated SalesforceCaseService for better interaction with Salesforce data in support case operations. - Updated support case schemas to align with new requirements and ensure data consistency.
106 lines
3.3 KiB
TypeScript
106 lines
3.3 KiB
TypeScript
import { z } from "zod";
|
|
import {
|
|
SUPPORT_CASE_STATUS,
|
|
SUPPORT_CASE_PRIORITY,
|
|
SUPPORT_CASE_CATEGORY,
|
|
} from "./contract";
|
|
|
|
/**
|
|
* Portal status values (mapped from Salesforce Japanese API names)
|
|
*/
|
|
const supportCaseStatusValues = [
|
|
SUPPORT_CASE_STATUS.NEW,
|
|
SUPPORT_CASE_STATUS.IN_PROGRESS,
|
|
SUPPORT_CASE_STATUS.AWAITING_APPROVAL,
|
|
SUPPORT_CASE_STATUS.VPN_PENDING,
|
|
SUPPORT_CASE_STATUS.PENDING,
|
|
SUPPORT_CASE_STATUS.RESOLVED,
|
|
SUPPORT_CASE_STATUS.CLOSED,
|
|
] as const;
|
|
|
|
/**
|
|
* Portal priority values (mapped from Salesforce Japanese API names)
|
|
*/
|
|
const supportCasePriorityValues = [
|
|
SUPPORT_CASE_PRIORITY.LOW,
|
|
SUPPORT_CASE_PRIORITY.MEDIUM,
|
|
SUPPORT_CASE_PRIORITY.HIGH,
|
|
] as const;
|
|
|
|
const supportCaseCategoryValues = [
|
|
SUPPORT_CASE_CATEGORY.TECHNICAL,
|
|
SUPPORT_CASE_CATEGORY.BILLING,
|
|
SUPPORT_CASE_CATEGORY.GENERAL,
|
|
SUPPORT_CASE_CATEGORY.FEATURE_REQUEST,
|
|
] as const;
|
|
|
|
export const supportCaseStatusSchema = z.enum(supportCaseStatusValues);
|
|
export const supportCasePrioritySchema = z.enum(supportCasePriorityValues);
|
|
export const supportCaseCategorySchema = z.enum(supportCaseCategoryValues);
|
|
|
|
/**
|
|
* Support case schema - compatible with Salesforce Case object
|
|
* ID is a string (Salesforce ID format: 15 or 18 char alphanumeric)
|
|
*/
|
|
export const supportCaseSchema = z.object({
|
|
id: z.string().min(15).max(18),
|
|
caseNumber: z.string(),
|
|
subject: z.string().min(1),
|
|
status: z.string(), // Allow any status from Salesforce
|
|
priority: z.string(), // Allow any priority from Salesforce
|
|
category: z.string().nullable(), // Maps to Salesforce Type field
|
|
createdAt: z.string(),
|
|
updatedAt: z.string(),
|
|
closedAt: z.string().nullable(),
|
|
description: z.string(),
|
|
});
|
|
|
|
export const supportCaseSummarySchema = z.object({
|
|
total: z.number().int().nonnegative(),
|
|
open: z.number().int().nonnegative(),
|
|
highPriority: z.number().int().nonnegative(),
|
|
resolved: z.number().int().nonnegative(),
|
|
});
|
|
|
|
export const supportCaseListSchema = z.object({
|
|
cases: z.array(supportCaseSchema),
|
|
summary: supportCaseSummarySchema,
|
|
});
|
|
|
|
export const supportCaseFilterSchema = z
|
|
.object({
|
|
status: z.string().optional(),
|
|
priority: z.string().optional(),
|
|
category: z.string().optional(),
|
|
search: z.string().trim().min(1).optional(),
|
|
})
|
|
.default({});
|
|
|
|
/**
|
|
* Request schema for creating a new support case
|
|
*/
|
|
export const createCaseRequestSchema = z.object({
|
|
subject: z.string().min(1).max(255),
|
|
description: z.string().min(1).max(32000),
|
|
category: supportCaseCategorySchema.optional(),
|
|
priority: supportCasePrioritySchema.optional(),
|
|
});
|
|
|
|
/**
|
|
* Response schema for case creation
|
|
*/
|
|
export const createCaseResponseSchema = z.object({
|
|
id: z.string(),
|
|
caseNumber: z.string(),
|
|
});
|
|
|
|
export type SupportCaseStatus = z.infer<typeof supportCaseStatusSchema>;
|
|
export type SupportCasePriority = z.infer<typeof supportCasePrioritySchema>;
|
|
export type SupportCaseCategory = z.infer<typeof supportCaseCategorySchema>;
|
|
export type SupportCase = z.infer<typeof supportCaseSchema>;
|
|
export type SupportCaseSummary = z.infer<typeof supportCaseSummarySchema>;
|
|
export type SupportCaseList = z.infer<typeof supportCaseListSchema>;
|
|
export type SupportCaseFilter = z.infer<typeof supportCaseFilterSchema>;
|
|
export type CreateCaseRequest = z.infer<typeof createCaseRequestSchema>;
|
|
export type CreateCaseResponse = z.infer<typeof createCaseResponseSchema>;
|