- Create tRPC router with checkNumber, classifySMS, classifyCall endpoints - Add protected procedures for rule CRUD, feedback submission, and stats - Implement service layer with phone number normalization and audit logging - Add ML engine with BERT stub, feature extraction, and rule engine - Implement reputation API module with circuit breaker and caching - Write comprehensive tests (34 tests) for all layers - Wire spamshield router into app root router
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { object, string, minLength, optional, number, boolean as vBoolean, picklist } from "valibot";
|
|
|
|
export const CheckNumberSchema = object({
|
|
phoneNumber: string([minLength(1)]),
|
|
});
|
|
|
|
export const ClassifySMSSchema = object({
|
|
text: string([minLength(1)]),
|
|
});
|
|
|
|
export const ClassifyCallSchema = object({
|
|
callerNumber: string([minLength(1)]),
|
|
duration: optional(number()),
|
|
timeOfDay: optional(number()),
|
|
});
|
|
|
|
export const CreateRuleSchema = object({
|
|
ruleType: picklist(["phoneNumber", "areaCode", "prefix", "pattern", "reputation"]),
|
|
pattern: string([minLength(1)]),
|
|
action: picklist(["block", "flag", "allow", "challenge"]),
|
|
priority: optional(number(), 0),
|
|
});
|
|
|
|
export const DeleteRuleSchema = object({
|
|
ruleId: string([minLength(1)]),
|
|
});
|
|
|
|
export const FeedbackSchema = object({
|
|
phoneNumber: string([minLength(1)]),
|
|
isSpam: vBoolean(),
|
|
feedbackType: picklist(["initial_detection", "user_confirmation", "user_rejection", "auto_learned"]),
|
|
});
|
|
|
|
export const StatsFilterSchema = object({
|
|
period: optional(picklist(["day", "week", "month", "year"]), "month"),
|
|
});
|