#[Incorrect Types] Apify JS Client

1 messages · Page 1 of 1 (latest)

night sage
#

I am using the API JS client version 2.8.0 to programmatically create a schedule with 1 task action. The code looks like the following

const schedule = await client.schedules().create({
  isEnabled: true,
  cronExpression,
  actions: [
    {
      type: ScheduleActions.RunActorTask,
      actorTaskId: task.id,
    },
  ],
});

However, I get a TS error saying that my action object is missing an id field due to the following interface definition:

interface BaseScheduleAction<Type extends ScheduleActions> {
    id: string;
    type: Type;
}

When I try to supply a value, the operation fails and no task is added but it works when I add a // @ts-ignore statement and omit id entirely. I suspect that the interface definition is incorrect and id should not be required and instead should be generated by Apify. My suspicions are further confirmed by the fact that the network request sent from the client does not include a value for id when adding a task to a schedule in the UI (see attached image)

night sage
inland stagBOT
#

@night sage just advanced to level 1! Thanks for your contributions! 🎉

night sage
#

My guess is that the value for id should be required when updating an action but not for creating an action -- as I am trying to do in this case