Skip to content

Commit 2f84c47

Browse files
committed
refactor: share task flow create params
1 parent d385b96 commit 2f84c47

1 file changed

Lines changed: 12 additions & 21 deletions

File tree

‎src/tasks/task-flow-registry.ts‎

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,9 @@ type FlowRecordPatch = Omit<
5858
endedAt?: number | null;
5959
};
6060

61-
export type CreateFlowRecordParams = {
62-
syncMode?: TaskFlowSyncMode;
61+
type FlowRecordCreateFields = {
6362
ownerKey: string;
6463
requesterOrigin?: TaskFlowRecord["requesterOrigin"];
65-
controllerId?: string | null;
66-
revision?: number;
6764
status?: TaskFlowStatus;
6865
notifyPolicy?: TaskNotifyPolicy;
6966
goal: string;
@@ -78,6 +75,12 @@ export type CreateFlowRecordParams = {
7875
endedAt?: number | null;
7976
};
8077

78+
export type CreateFlowRecordParams = FlowRecordCreateFields & {
79+
syncMode?: TaskFlowSyncMode;
80+
controllerId?: string | null;
81+
revision?: number;
82+
};
83+
8184
export type TaskFlowUpdateResult =
8285
| {
8386
applied: true;
@@ -349,23 +352,11 @@ export function createFlowRecord(params: CreateFlowRecordParams): TaskFlowRecord
349352
return writeFlowRecord(record);
350353
}
351354

352-
export function createManagedTaskFlow(params: {
353-
ownerKey: string;
354-
controllerId: string;
355-
requesterOrigin?: TaskFlowRecord["requesterOrigin"];
356-
status?: TaskFlowStatus;
357-
notifyPolicy?: TaskNotifyPolicy;
358-
goal: string;
359-
currentStep?: string | null;
360-
blockedTaskId?: string | null;
361-
blockedSummary?: string | null;
362-
stateJson?: JsonValue | null;
363-
waitJson?: JsonValue | null;
364-
cancelRequestedAt?: number | null;
365-
createdAt?: number;
366-
updatedAt?: number;
367-
endedAt?: number | null;
368-
}): TaskFlowRecord {
355+
export function createManagedTaskFlow(
356+
params: FlowRecordCreateFields & {
357+
controllerId: string;
358+
},
359+
): TaskFlowRecord {
369360
return createFlowRecord({
370361
...params,
371362
syncMode: "managed",

0 commit comments

Comments
 (0)