Skip to content

Commit 674c7e1

Browse files
committed
Revert "fix(client): Make action.workflowId optional on Schedule update"
This reverts commit 1993731.
1 parent 1993731 commit 674c7e1

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

packages/client/src/schedule-client.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ function assertRequiredScheduleOptions(
149149
if (!opts.action.taskQueue) {
150150
throw new TypeError(`Missing ${structureName}.action.taskQueue for 'startWorkflow' action`);
151151
}
152+
if (!opts.action.workflowId && action === 'UPDATE') {
153+
throw new TypeError(`Missing ${structureName}.action.workflowId for 'startWorkflow' action`);
154+
}
152155
if (!opts.action.workflowType) {
153156
throw new TypeError(`Missing ${structureName}.action.workflowType for 'startWorkflow' action`);
154157
}
@@ -456,11 +459,7 @@ export class ScheduleClient extends BaseClient {
456459
const currentHeader: Headers = current.raw.schedule?.action?.startWorkflow?.header?.fields ?? {};
457460
const updated = updateFn(current);
458461
assertRequiredScheduleOptions(updated, 'UPDATE');
459-
await this.client._updateSchedule(
460-
scheduleId,
461-
compileUpdatedScheduleOptions(scheduleId, updated),
462-
currentHeader
463-
);
462+
await this.client._updateSchedule(scheduleId, compileUpdatedScheduleOptions(updated), currentHeader);
464463
},
465464

466465
async delete(): Promise<void> {

packages/client/src/schedule-helpers.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,17 +221,13 @@ export function compileScheduleOptions(options: ScheduleOptions): CompiledSchedu
221221
};
222222
}
223223

224-
export function compileUpdatedScheduleOptions(
225-
scheduleId: string,
226-
options: ScheduleUpdateOptions
227-
): CompiledScheduleUpdateOptions {
224+
export function compileUpdatedScheduleOptions(options: ScheduleUpdateOptions): CompiledScheduleUpdateOptions {
228225
const workflowTypeOrFunc = options.action.workflowType;
229226
const workflowType = extractWorkflowType(workflowTypeOrFunc);
230227
return {
231228
...options,
232229
action: {
233230
...options.action,
234-
workflowId: options.action.workflowId ?? `${scheduleId}-workflow`,
235231
workflowType,
236232
args: (options.action.args ?? []) as unknown[],
237233
},

packages/client/src/schedule-types.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,13 @@ export type CompiledScheduleOptions = Replace<
135135
export type ScheduleUpdateOptions<A extends ScheduleOptionsAction = ScheduleOptionsAction> = Replace<
136136
Omit<ScheduleOptions, 'scheduleId' | 'memo' | 'searchAttributes'>,
137137
{
138-
action: A;
138+
action: Replace<
139+
A,
140+
{
141+
// No default value on update
142+
workflowId: string;
143+
}
144+
>;
139145
state: Omit<ScheduleOptions['state'], 'triggerImmediately' | 'backfill'>;
140146
}
141147
>;

packages/test/src/test-schedules.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ if (RUN_INTEGRATION_TESTS) {
396396
...x,
397397
action: {
398398
type: 'startWorkflow',
399+
workflowId: `${scheduleId}-workflow-2`,
399400
workflowType: dummyWorkflowWith2Args,
400401
args: [3, 4],
401402
taskQueue,

0 commit comments

Comments
 (0)