From 2f84c47b8bc2cccf9915d03c4a5eef11e7327908 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 19 Apr 2026 05:16:38 +0100 Subject: [PATCH] refactor: share task flow create params --- src/tasks/task-flow-registry.ts | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/src/tasks/task-flow-registry.ts b/src/tasks/task-flow-registry.ts index c39980c38d9..98286813d5c 100644 --- a/src/tasks/task-flow-registry.ts +++ b/src/tasks/task-flow-registry.ts @@ -58,12 +58,9 @@ type FlowRecordPatch = Omit< endedAt?: number | null; }; -export type CreateFlowRecordParams = { - syncMode?: TaskFlowSyncMode; +type FlowRecordCreateFields = { ownerKey: string; requesterOrigin?: TaskFlowRecord["requesterOrigin"]; - controllerId?: string | null; - revision?: number; status?: TaskFlowStatus; notifyPolicy?: TaskNotifyPolicy; goal: string; @@ -78,6 +75,12 @@ export type CreateFlowRecordParams = { endedAt?: number | null; }; +export type CreateFlowRecordParams = FlowRecordCreateFields & { + syncMode?: TaskFlowSyncMode; + controllerId?: string | null; + revision?: number; +}; + export type TaskFlowUpdateResult = | { applied: true; @@ -349,23 +352,11 @@ export function createFlowRecord(params: CreateFlowRecordParams): TaskFlowRecord return writeFlowRecord(record); } -export function createManagedTaskFlow(params: { - ownerKey: string; - controllerId: string; - requesterOrigin?: TaskFlowRecord["requesterOrigin"]; - status?: TaskFlowStatus; - notifyPolicy?: TaskNotifyPolicy; - goal: string; - currentStep?: string | null; - blockedTaskId?: string | null; - blockedSummary?: string | null; - stateJson?: JsonValue | null; - waitJson?: JsonValue | null; - cancelRequestedAt?: number | null; - createdAt?: number; - updatedAt?: number; - endedAt?: number | null; -}): TaskFlowRecord { +export function createManagedTaskFlow( + params: FlowRecordCreateFields & { + controllerId: string; + }, +): TaskFlowRecord { return createFlowRecord({ ...params, syncMode: "managed",