@@ -248,6 +248,20 @@ export async function ensureLoaded(
248248 mutated = true ;
249249 }
250250
251+ const rawId = typeof raw . id === "string" ? raw . id . trim ( ) : "" ;
252+ const legacyJobId = typeof raw . jobId === "string" ? raw . jobId . trim ( ) : "" ;
253+ if ( ! rawId && legacyJobId ) {
254+ raw . id = legacyJobId ;
255+ mutated = true ;
256+ } else if ( rawId && raw . id !== rawId ) {
257+ raw . id = rawId ;
258+ mutated = true ;
259+ }
260+ if ( "jobId" in raw ) {
261+ delete raw . jobId ;
262+ mutated = true ;
263+ }
264+
251265 const nameRaw = raw . name ;
252266 if ( typeof nameRaw !== "string" || nameRaw . trim ( ) . length === 0 ) {
253267 raw . name = inferLegacyName ( {
@@ -279,6 +293,22 @@ export async function ensureLoaded(
279293 mutated = true ;
280294 }
281295
296+ const wakeModeRaw = typeof raw . wakeMode === "string" ? raw . wakeMode . trim ( ) . toLowerCase ( ) : "" ;
297+ if ( wakeModeRaw === "next-heartbeat" ) {
298+ if ( raw . wakeMode !== "next-heartbeat" ) {
299+ raw . wakeMode = "next-heartbeat" ;
300+ mutated = true ;
301+ }
302+ } else if ( wakeModeRaw === "now" ) {
303+ if ( raw . wakeMode !== "now" ) {
304+ raw . wakeMode = "now" ;
305+ mutated = true ;
306+ }
307+ } else {
308+ raw . wakeMode = "now" ;
309+ mutated = true ;
310+ }
311+
282312 const payload = raw . payload ;
283313 if (
284314 ( ! payload || typeof payload !== "object" || Array . isArray ( payload ) ) &&
@@ -383,13 +413,24 @@ export async function ensureLoaded(
383413 }
384414
385415 const exprRaw = typeof sched . expr === "string" ? sched . expr . trim ( ) : "" ;
386- if ( typeof sched . expr === "string" && sched . expr !== exprRaw ) {
387- sched . expr = exprRaw ;
416+ const legacyCronRaw = typeof sched . cron === "string" ? sched . cron . trim ( ) : "" ;
417+ let normalizedExpr = exprRaw ;
418+ if ( ! normalizedExpr && legacyCronRaw ) {
419+ normalizedExpr = legacyCronRaw ;
420+ sched . expr = normalizedExpr ;
421+ mutated = true ;
422+ }
423+ if ( typeof sched . expr === "string" && sched . expr !== normalizedExpr ) {
424+ sched . expr = normalizedExpr ;
425+ mutated = true ;
426+ }
427+ if ( "cron" in sched ) {
428+ delete sched . cron ;
388429 mutated = true ;
389430 }
390- if ( ( kind === "cron" || sched . kind === "cron" ) && exprRaw ) {
431+ if ( ( kind === "cron" || sched . kind === "cron" ) && normalizedExpr ) {
391432 const explicitStaggerMs = normalizeCronStaggerMs ( sched . staggerMs ) ;
392- const defaultStaggerMs = resolveDefaultCronStaggerMs ( exprRaw ) ;
433+ const defaultStaggerMs = resolveDefaultCronStaggerMs ( normalizedExpr ) ;
393434 const targetStaggerMs = explicitStaggerMs ?? defaultStaggerMs ;
394435 if ( targetStaggerMs === undefined ) {
395436 if ( "staggerMs" in sched ) {
0 commit comments