feat(notificaciones): ejecutar todos for servicios jobs
Add POST /notifications/run-all: runs the four notification jobs (outstanding, payment confirmation, account status, trust confirmation) sequentially with one shared set of flags from "Flags del envío". Sequential rather than parallel — the jobs share the SES transport and account status can self-throttle via useEmailLimit. A job that throws is captured and the sweep continues, so one bad query cannot swallow the other three envíos; the aggregate response carries per-job results plus summed sent/skipped/failed and an errors count. Audited as a single notification.run-all.run entry so one staff click is one audit row. UI adds the button to the flags card, with a confirm when debug is off, and a per-job summary in "Última respuesta".
This commit is contained in:
@@ -1125,6 +1125,38 @@ export function runTrustConfirmation(
|
||||
});
|
||||
}
|
||||
|
||||
export type NotificationJobKind = "outstanding" | "payment" | "account" | "trust";
|
||||
|
||||
export interface NotificationRunAllJobResult {
|
||||
kind: NotificationJobKind;
|
||||
ok: boolean;
|
||||
result?: NotificationJobResponse;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
/** Aggregate response of the "Ejecutar todos" sweep. */
|
||||
export interface NotificationRunAllResponse {
|
||||
request: "success";
|
||||
notificationType: "runAllNotifications";
|
||||
statusCode: 200;
|
||||
debug: boolean;
|
||||
sent: number;
|
||||
skipped: number;
|
||||
failed: number;
|
||||
errors: number;
|
||||
jobs: NotificationRunAllJobResult[];
|
||||
type: "RUN_ALL";
|
||||
}
|
||||
|
||||
export function runAllNotifications(
|
||||
flags: NotificationFlags = {},
|
||||
): Promise<NotificationRunAllResponse> {
|
||||
return apiFetch<NotificationRunAllResponse>("/notifications/run-all", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(flags),
|
||||
});
|
||||
}
|
||||
|
||||
export interface NotificationLogQuery {
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
|
||||
Reference in New Issue
Block a user