Skip to content

Releases: pdfmonkey/pdfmonkey-node

v1.4.0

Choose a tag to compare

@github-actions github-actions released this 05 Oct 22:26
37d9063

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 } for documents.generation.success and documents.generation.failure, where document is a DocumentCard
  • { period_start, period_end, available_documents, threshold } for quota.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() accepts search: 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 folders and sort values on documentTemplates.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() sends PUT instead of PATCH, matching the API and the other update endpoints. (#19)
  • documents.waitForGeneration() treats timeout as 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

v1.3.0

Choose a tag to compare

@github-actions github-actions released this 05 Oct 13:00
33f028b

Minor Changes

  • 44349df: Adding client.workspaceCards to call the workspace_cards endpoint: list()/listAll() return workspace summaries including the admin's current_plan, and update() renames a workspace.

v1.2.0

Choose a tag to compare

@github-actions github-actions released this 05 Oct 12:24
861114f

Minor Changes

  • 2c03f6d: Fixing endpoints that never worked against the live API: workspaces.list()/listAll()/get() now read the apps/app payload keys, documentTemplates.create() and templateFolders.create() take a required workspace_id, and restHooks.create() sends the event/platform fields the API expects (events are now documents.generation.success / documents.generation.failure). Adding a live-API integration suite runnable with pnpm test:integration.

v1.1.0

Choose a tag to compare

@github-actions github-actions released this 02 Oct 14:04
0bd4140

Minor Changes

  • df48ead: Adding a required workspace_id to snippets.list() and templateFolders.list() (the API returns nothing without it), and a listAll() method on workspaces, document templates, snippets and template folders that fetches every item in a single page=all request.

v1.0.0

Choose a tag to compare

@necmes necmes released this 17 Aug 11:04

Initial public release of the PDFMonkey Node.js SDK. See CHANGELOG.md. Published to npm: https://www.npmjs.com/package/pdfmonkey