forked from farhoodlabs/paperclip
fix: address greptile routine review
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import type { RoutineTrigger } from "@paperclipai/shared";
|
||||
|
||||
export type RoutineTriggerEditorDraft = {
|
||||
label: string;
|
||||
cronExpression: string;
|
||||
signingMode: string;
|
||||
replayWindowSec: string;
|
||||
};
|
||||
|
||||
export function buildRoutineTriggerPatch(
|
||||
trigger: RoutineTrigger,
|
||||
draft: RoutineTriggerEditorDraft,
|
||||
fallbackTimezone: string,
|
||||
) {
|
||||
const patch: Record<string, unknown> = {
|
||||
label: draft.label.trim() || null,
|
||||
};
|
||||
|
||||
if (trigger.kind === "schedule") {
|
||||
patch.cronExpression = draft.cronExpression.trim();
|
||||
patch.timezone = trigger.timezone ?? fallbackTimezone;
|
||||
}
|
||||
|
||||
if (trigger.kind === "webhook") {
|
||||
patch.signingMode = draft.signingMode;
|
||||
patch.replayWindowSec = Number(draft.replayWindowSec || "300");
|
||||
}
|
||||
|
||||
return patch;
|
||||
}
|
||||
Reference in New Issue
Block a user