refactor: trim cron helper exports

This commit is contained in:
Peter Steinberger
2026-05-02 03:00:16 +01:00
parent 7d827a8022
commit 7e84513334
5 changed files with 7 additions and 21 deletions

View File

@@ -6,7 +6,7 @@ const trimStringPreprocess = (value: unknown) => (typeof value === "string" ? va
const trimLowercaseStringPreprocess = (value: unknown) =>
normalizeOptionalLowercaseString(value) ?? value;
export const DeliveryModeFieldSchema = z
const DeliveryModeFieldSchema = z
.preprocess(trimLowercaseStringPreprocess, z.enum(["deliver", "announce", "none", "webhook"]))
.transform((value) => (value === "deliver" ? "announce" : value));
@@ -30,7 +30,7 @@ export const TimeoutSecondsFieldSchema = z
.finite()
.transform((value) => Math.max(0, value));
export type ParsedDeliveryInput = {
type ParsedDeliveryInput = {
mode?: "announce" | "none" | "webhook";
channel?: string;
to?: string;

View File

@@ -1,7 +1,7 @@
import { resolveSendableOutboundReplyParts } from "openclaw/plugin-sdk/reply-payload";
import { stripHeartbeatToken } from "../auto-reply/heartbeat.js";
export type HeartbeatDeliveryPayload = {
type HeartbeatDeliveryPayload = {
text?: string;
mediaUrl?: string;
mediaUrls?: string[];

View File

@@ -61,9 +61,7 @@ function resolveSchedulePayload(
return schedulePayloadFromRecord(job);
}
export function cronScheduleIdentity(
job: Pick<CronJob, "schedule"> & { enabled?: boolean },
): string {
function cronScheduleIdentity(job: Pick<CronJob, "schedule"> & { enabled?: boolean }): string {
const schedule = resolveSchedulePayload(job as unknown as Record<string, unknown>);
if (!schedule) {
throw new Error("Unsupported cron schedule kind");

View File

@@ -13,9 +13,7 @@ import type {
} from "./service/state.js";
import type { CronJob } from "./types.js";
export type { CronListPageOptions, CronListPageResult } from "./service/list-page-types.js";
export type CronWakeResult = { ok: true } | { ok: false };
type CronWakeResult = { ok: true } | { ok: false };
export type CronServiceRunResult = CronRunResult | { ok: true; ran: false; reason: "invalid-spec" };

View File

@@ -1,20 +1,10 @@
import type {
CronListPageOptions,
CronServiceContract,
CronServiceRunResult,
} from "./service-contract.js";
import type { CronServiceContract, CronServiceRunResult } from "./service-contract.js";
import type { CronListPageOptions } from "./service/list-page-types.js";
import * as ops from "./service/ops.js";
import { type CronServiceDeps, createCronServiceState } from "./service/state.js";
import type { CronJob, CronJobCreate, CronJobPatch } from "./types.js";
export type { CronEvent, CronServiceDeps } from "./service/state.js";
export type {
CronListPageOptions,
CronListPageResult,
CronServiceContract,
CronServiceRunResult,
CronWakeResult,
} from "./service-contract.js";
export class CronService implements CronServiceContract {
private readonly state;