Repository navigation
Highlights
verifyWebhook()works with real PDFMonkey webhooks. It used to reject every delivery after a valid signature, because it expected a{ type, data, timestamp }envelope the API never sends. It now returns the body PDFMonkey actually delivers. (#21)- Search and filter by several statuses in
documentCards.list(). (#19) waitForGeneration()respects its timeout, even when a poll is slow or being retried. (#18)
Upgrading
Webhooks
verifyWebhook() now returns a WebhookPayload:
{ document }fordocuments.generation.successanddocuments.generation.failure, wheredocumentis aDocumentCard{ period_start, period_end, available_documents, threshold }forquota.warning
The event type isn't part of the body, so narrow on its shape and check the status:
const payload = await verifyWebhook(rawBody, headers, secret);
if ('document' in payload) {
if (payload.document.status === 'success') {
console.log(payload.document.download_url);
} else {
console.log(payload.document.failure_cause);
}
} else {
console.log(`${payload.available_documents} documents left`);
}These types were removed because they never matched what the API sends: WebhookEvent, WebhookEventType, DocumentDoneEvent, DocumentDoneEventData, DocumentErrorEvent, DocumentErrorEventData and UnknownWebhookEvent.
meta arrives as a JSON-encoded string, so JSON.parse() it before reading its keys.
DocumentStatus
'error' is no longer a DocumentStatus value: the API only returns 'draft', 'pending', 'generating', 'success' and 'failure'. Code that compares a status to 'error' will no longer compile. Remove those branches, since they could never match.
What's new
documentCards.list()acceptssearch: an exact document ID, or part of the filename (case-sensitive).documentCards.list()accepts several statuses:status: ['pending', 'generating']. An empty array applies no status filter.- Query values can be arrays and are sent as
key[]=a&key[]=b. - The accepted
foldersandsortvalues ondocumentTemplates.list()are now documented.
const page = await client.documentCards.list({
search: 'invoice',
status: ['pending', 'generating'],
});Fixes
verifyWebhook()returns the real webhook payloads instead of rejecting them. (#21)workspaceCards.update()sendsPUTinstead ofPATCH, matching the API and the other update endpoints. (#19)documents.waitForGeneration()treatstimeoutas a total time limit. When it runs out, in-flight polls and their retries are aborted, instead of returning a late success or reporting the timeout only after a slow response came back. (#18)
Full changelog: v1.3.0...v1.4.0