openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
21 lines (20 loc) • 1.29 kB
JavaScript
import { l as isRecord } from "./record-coerce-CVPuDqcc.mjs";
//#region src/cron/service/list-page-validation.ts
function isSafeNonNegativeInteger(e) {
return typeof e === "number" && Number.isSafeInteger(e) && e >= 0;
}
function readCanonicalCronListPage(e, t) {
if (!isRecord(e) || !Array.isArray(e.jobs)) throw new Error("cron.list returned an invalid inventory page");
const n = e;
const r = e.jobs;
const i = typeof n.limit === "number" ? n.limit : 0;
if (typeof n.snapshotRevision !== "string" || n.snapshotRevision.length === 0 || !isSafeNonNegativeInteger(n.total) || !isSafeNonNegativeInteger(n.offset) || !Number.isSafeInteger(i) || i < 1 || i > t || r.length > i || typeof n.hasMore !== "boolean" || n.nextOffset !== null && !isSafeNonNegativeInteger(n.nextOffset)) throw new Error("cron.list returned an invalid inventory page");
return n;
}
function resolveCronListPageNextOffset(e, t) {
const n = t + e.jobs.length;
if (e.offset !== t || !Number.isSafeInteger(n) || n > e.total || (e.hasMore ? e.nextOffset !== n || n <= t || n >= e.total : e.nextOffset !== null || n !== e.total)) throw new Error("cron.list returned an invalid inventory page");
return e.hasMore ? n : null;
}
//#endregion
export { resolveCronListPageNextOffset as n, readCanonicalCronListPage as t };