Files
ss-tools/frontend/src/lib/api/translate/schedules.js
busya 48c0756d6d fix(translate): fix job creation tab navigation and preview validation
- frontend: add  to reload job data on param change after goto
- frontend: set existingJob from createJob response for immediate tabs
- frontend: suppress error toasts for schedule 404 (normal state)
- frontend: conditional ScheduleConfig mount to avoid 'new' job loading
- backend: skip preview check for jobs with direct Superset datasource
- backend: add orthogonal test for datasource+no-preview success case
2026-05-18 10:56:21 +03:00

62 lines
2.0 KiB
JavaScript

// #region TranslateSchedulesApi [C:2] [TYPE Module] [SEMANTICS translate, schedules, api, cron]
// @BRIEF API client for translation job scheduling — CRUD, enable/disable, next executions.
// @RELATION DEPENDS_ON -> [ApiModule]
import { api } from '$lib/api.js';
function normalizeTranslateError(error, defaultMessage = 'Translation API error') {
const message =
(error && typeof error.message === 'string' && error.message) ||
(typeof error === 'string' && error) ||
defaultMessage;
return { message, code: 'TRANSLATE_API_ERROR', retryable: true };
}
export async function fetchSchedule(jobId) {
try {
return await api.fetchApi(`/translate/jobs/${jobId}/schedule`, { suppressToast: true });
} catch (error) {
throw normalizeTranslateError(error, 'Failed to fetch schedule');
}
}
export async function setSchedule(jobId, payload) {
try {
return await api.requestApi(`/translate/jobs/${jobId}/schedule`, 'PUT', payload);
} catch (error) {
throw normalizeTranslateError(error, 'Failed to set schedule');
}
}
export async function deleteSchedule(jobId) {
try {
return await api.deleteApi(`/translate/jobs/${jobId}/schedule`);
} catch (error) {
throw normalizeTranslateError(error, 'Failed to delete schedule');
}
}
export async function enableSchedule(jobId) {
try {
return await api.postApi(`/translate/jobs/${jobId}/schedule/enable`, {});
} catch (error) {
throw normalizeTranslateError(error, 'Failed to enable schedule');
}
}
export async function disableSchedule(jobId) {
try {
return await api.postApi(`/translate/jobs/${jobId}/schedule/disable`, {});
} catch (error) {
throw normalizeTranslateError(error, 'Failed to disable schedule');
}
}
export async function fetchNextExecutions(jobId, n = 3) {
try {
return await api.fetchApi(`/translate/jobs/${jobId}/schedule/next-executions?n=${n}`, { suppressToast: true });
} catch (error) {
throw normalizeTranslateError(error, 'Failed to fetch next executions');
}
}
// #endregion TranslateSchedulesApi