ilovepdf-nodejs
ilovepdf-nodejs copied to clipboard
Task construction for webhook payloads
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:
- Expose private properties via getters (e.g.,
getAuth(),getServer()) - useful for custom requests when SDK lacks specific interfaces - Add
newTaskFromPayload(tool, id, server)method - requires server getter so tasks can be reconstructed by copying server/id from existing tasks - Overload
newTaskto 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 ?