refactor: cron payload migration cleanup (#621)

* refactor: centralize cron payload migration

* test: stabilize block streaming mocks

* test: adjust chunker fence-close case
This commit is contained in:
Peter Steinberger
2026-01-09 22:56:55 +00:00
committed by GitHub
parent e3c340fd38
commit 98d0318d4e
7 changed files with 173 additions and 62 deletions

View File

@@ -1,6 +1,7 @@
import crypto from "node:crypto";
import { truncateUtf16Safe } from "../utils.js";
import { migrateLegacyCronPayload } from "./payload-migration.js";
import { computeNextRunAtMs } from "./schedule.js";
import { loadCronStore, saveCronStore } from "./store.js";
import type {
@@ -320,22 +321,7 @@ export class CronService {
const payload = raw.payload;
if (payload && typeof payload === "object" && !Array.isArray(payload)) {
const legacyChannel =
typeof (payload as Record<string, unknown>).channel === "string"
? String((payload as Record<string, unknown>).channel).trim()
: "";
const provider =
typeof (payload as Record<string, unknown>).provider === "string"
? String((payload as Record<string, unknown>).provider).trim()
: "";
// Back-compat: older cron payloads used `channel` for delivery provider.
if (!provider && legacyChannel) {
(payload as Record<string, unknown>).provider =
legacyChannel.toLowerCase();
mutated = true;
}
if ("channel" in (payload as Record<string, unknown>)) {
delete (payload as Record<string, unknown>).channel;
if (migrateLegacyCronPayload(payload as Record<string, unknown>)) {
mutated = true;
}
}