refactor: share task flow create params

This commit is contained in:
Peter Steinberger
2026-04-19 05:16:38 +01:00
parent d385b96451
commit 2f84c47b8b

View File

@@ -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",