Bug fixes (from bugs/ directory): - Fix cross-module DB queries in 9 modules (homework, grades, parent, diagnostic, elective, proctoring, notifications, scheduling, classes) by routing through data-access functions - Fix shared/lib <-> auth circular dependency via new session.ts module - Fix divide-by-zero guard in grades data-access - Fix audit export data truncation (paginated fetch for full datasets) - Fix missing transactions in homework grading and elective lottery - Fix missing revalidatePath in course-plans actions - Fix frontend permission checks using requirePermission instead of requireAuth - Fix dashboard role routing using session.user.roles - Fix student auth pattern (migrate getDemoStudentUser to users module) - Fix ActionState return type handling in components Code quality fixes: - Remove 60+ as type assertions (replace with type guards) - Remove non-null assertions (use optional chaining or explicit checks) - Convert dynamic imports to static imports (grades, diagnostic) - Add React.cache() wrapping for read functions - Parallelize independent queries with Promise.all - Add explicit return types to 30+ arrow functions - Replace any with unknown + type guards - Fix import type for type-only imports - Add Zod validation schemas for classes and diagnostic modules - Extract duplicate code (normalizeRoleName, normalizeBcryptHash, logger IP extraction) - Add console.error to silent catch blocks - Fix permission naming consistency (exam:proctor_read -> exam:proctor:read) Architecture doc sync: - Update 004_architecture_impact_map.md and 005_architecture_data.json - Update management-modules-audit.md for P0-7 cross-module fix Moved deleted proctoring event route to deletes/ folder.
62 lines
2.0 KiB
TypeScript
62 lines
2.0 KiB
TypeScript
/**
|
|
* 通知渠道集成模块
|
|
*
|
|
* 对外导出:
|
|
* - sendNotification / sendBatchNotifications: 分发器入口
|
|
* - createNotification / getNotifications / markNotificationAsRead / markAllNotificationsAsRead / getUnreadNotificationCount: 站内通知 CRUD
|
|
* - getNotificationPreferences / upsertNotificationPreferences: 通知偏好 CRUD
|
|
* - 类型定义: NotificationPayload, ChannelSendResult, NotificationChannel, NotificationType, Notification, NotificationPreferences 等
|
|
* - 渠道发送器工厂: createSmsSender, createWechatSender, createEmailSender, createInAppSender
|
|
*
|
|
* 典型用法:
|
|
* ```ts
|
|
* import { sendNotification } from "@/modules/notifications"
|
|
* await sendNotification({
|
|
* userId: "user-xxx",
|
|
* title: "作业提醒",
|
|
* content: "您有一份新作业待提交",
|
|
* type: "info",
|
|
* actionUrl: "/homework/123",
|
|
* })
|
|
* ```
|
|
*/
|
|
|
|
export { sendNotification, sendBatchNotifications } from "./dispatcher"
|
|
export {
|
|
createNotification,
|
|
getNotifications,
|
|
markNotificationAsRead,
|
|
markAllNotificationsAsRead,
|
|
getUnreadNotificationCount,
|
|
getUserContactInfo,
|
|
logNotificationSend,
|
|
logNotificationSendBatch,
|
|
} from "./data-access"
|
|
export {
|
|
getNotificationPreferences,
|
|
upsertNotificationPreferences,
|
|
} from "./preferences"
|
|
export type {
|
|
NotificationChannel,
|
|
NotificationPayload,
|
|
ChannelSendResult,
|
|
NotificationChannelConfig,
|
|
SmsChannelConfig,
|
|
WechatChannelConfig,
|
|
EmailChannelConfig,
|
|
NotificationType,
|
|
Notification,
|
|
PaginatedResult,
|
|
GetNotificationsParams,
|
|
CreateNotificationInput,
|
|
NotificationPreferences,
|
|
UpdateNotificationPreferencesInput,
|
|
} from "./types"
|
|
export type { NotificationChannelSender, ChannelRecipient } from "./channels/types"
|
|
|
|
// 渠道发送器工厂(供高级用法直接调用单个渠道)
|
|
export { createSmsSender } from "./channels/sms-channel"
|
|
export { createWechatSender, isWechatEnabled } from "./channels/wechat-channel"
|
|
export { createEmailSender, isEmailEnabled } from "./channels/email-channel"
|
|
export { createInAppSender } from "./channels/in-app-channel"
|