ilovepdf-nodejs icon indicating copy to clipboard operation
ilovepdf-nodejs copied to clipboard

Task construction for webhook payloads

Open heilmela opened this issue 6 months ago • 0 comments

Missing API for Webhook Task Construction

SDK Version: 0.3.1

When processing completed tasks from webhooks, there's no clean API to construct a Task object for operations like downloading files. Currently forced to bypass type system and access private properties:

const apiTask: ILovePDFApiTask = (this.ilovePDF as any).taskFactory.newTask(
  tool,
  (this.ilovePDF as any).auth,
  (this.ilovePDF as any).xhr,
  {
    id: task,
    server,
  }
);

Proposed Solutions:

  1. Expose private properties via getters (e.g., getAuth(), getServer()) - useful for custom requests when SDK lacks specific interfaces
  2. Add newTaskFromPayload(tool, id, server) method - requires server getter so tasks can be reconstructed by copying server/id from existing tasks
  3. Overload newTask to allow different task constructions (preferred) - fits webhook use case: webhook.task.server -> newTask(...).download()

Would be happy to submit a PR if external contributions are accepted ?

heilmela avatar Jul 06 '25 09:07 heilmela