mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-15 02:20:38 +09:00
fix: address greptile routine review
This commit is contained in:
parent
99eb317600
commit
9093cfbe4f
6 changed files with 157 additions and 19 deletions
30
ui/src/lib/routine-trigger-patch.ts
Normal file
30
ui/src/lib/routine-trigger-patch.ts
Normal file
|
|
@ -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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue