Adds GET /admin/sla-runs (filterable by status), GET /admin/escalation- events (capped, most-recent-first), and GET /admin/products (with integration status joined in, never the full ProductIntegration row). None of these existed as a single query before - only per-ticket or per-integration-id lookups did. Discovered while planning supporthub-web's 001-agent-admin-ui User Stories 6-7 (SLA/escalation monitoring, product catalog), the same way 011-agent-ticket-queue was discovered for User Story 1. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
import { z } from 'zod';
|
|
|
|
export const createEscalationPolicySchema = z
|
|
.object({
|
|
name: z.string().min(1),
|
|
productId: z.string().optional(),
|
|
})
|
|
.strict();
|
|
|
|
/** research.md "EscalationRule.triggerType is stored, not evaluated": all 10 of doc05 §6's
|
|
* values are valid config — only resolution_breach/first_response_breach are ever evaluated by
|
|
* this feature's own breach sweep. */
|
|
export const ESCALATION_TRIGGER_TYPES = [
|
|
'first_response_breach',
|
|
'resolution_breach',
|
|
'inactivity',
|
|
'priority_increase',
|
|
'customer_escalation',
|
|
'repeated_reopen',
|
|
'manual',
|
|
'product_defect',
|
|
'dependency_timeout',
|
|
'critical_incident',
|
|
] as const;
|
|
|
|
export const createEscalationRuleSchema = z
|
|
.object({
|
|
triggerType: z.enum(ESCALATION_TRIGGER_TYPES),
|
|
condition: z.record(z.string(), z.unknown()),
|
|
targetNodeId: z.string().min(1),
|
|
notify: z.record(z.string(), z.unknown()),
|
|
active: z.boolean().optional(),
|
|
})
|
|
.strict();
|
|
|
|
export const updateEscalationRuleSchema = createEscalationRuleSchema.partial();
|
|
|
|
export const manualEscalationSchema = z
|
|
.object({
|
|
targetNodeId: z.string().min(1),
|
|
reason: z.string().min(1),
|
|
})
|
|
.strict();
|
|
|
|
/** 012-admin-list-views: caps the "recent escalation events" monitoring list — see that
|
|
* feature's own research.md. */
|
|
export const listRecentEventsQuerySchema = z.object({
|
|
limit: z.coerce.number().int().positive().max(200).default(50),
|
|
});
|
|
|
|
export type CreateEscalationPolicyBody = z.infer<typeof createEscalationPolicySchema>;
|
|
export type CreateEscalationRuleBody = z.infer<typeof createEscalationRuleSchema>;
|
|
export type UpdateEscalationRuleBody = z.infer<typeof updateEscalationRuleSchema>;
|
|
export type ManualEscalationBody = z.infer<typeof manualEscalationSchema>;
|