// NOTE: Real cronhost API integration pending official REST docs. // These stubs simulate scheduling/canceling and should be replaced with actual fetch calls. export interface ScheduleParams { apiKey: string; runAt: number; // epoch seconds method: 'POST' | 'GET'; url: string; body?: any; headers?: Record; } export interface ScheduleResult { jobId: string; scheduledRunAtUtc: number; } export async function scheduleOneTimeJob(params: ScheduleParams): Promise { const { apiKey, runAt, method, url } = params; if (!apiKey) throw new Error('Missing cronhost API key'); if (!url) throw new Error('Missing target URL'); if (!runAt || runAt < Math.floor(Date.now() / 1000)) throw new Error('runAt must be in the future'); console.warn('[cronhost] scheduleOneTimeJob is a stub. Replace with real API call.'); // Example real call outline: // await fetch('https://api.cronho.st/schedules', { method: 'POST', headers: { Authorization: `Bearer ${apiKey}`, 'Content-Type': 'application/json' }, body: JSON.stringify({...}) }) return { jobId: `stub_${Math.random().toString(36).slice(2)}`, scheduledRunAtUtc: runAt, }; } export async function cancelJob(apiKey: string, jobId: string): Promise { if (!apiKey || !jobId) return; console.warn('[cronhost] cancelJob is a stub. Replace with real API call.', { jobId }); // Example: await fetch(`https://api.cronho.st/jobs/${jobId}`, { method: 'DELETE', headers: { Authorization: `Bearer ${apiKey}` } }) }