yumauri / gotenberg-js-client

A simple JS/TS client for interacting with a Gotenberg API
MIT License
110 stars 9 forks source link

`to` type signature does not support UrlRequest #25

Closed peteralbert closed 3 years ago

peteralbert commented 3 years ago

For the code:

pipe(
  gotenberg('http://localhost:3000'),
  convert,
  url,
  to(landscape),
  please
)(address)

TypeScript complains:

Type 'RequestType.Url' is not assignable to type 'RequestType.Html'

in the url line. The actually execution works fine.

Could it be that the function overloading in to.ts lacks this additional signature?

(...opts: ConversionOptions[]): (request: UrlRequest) => UrlRequest

Let me know if I should create a PR!

Thanks

yumauri commented 3 years ago

Hm... I think I made it intentionally, to disable ability to set margins, because of warning on Gotenberg page

Attention: when converting a website to PDF, you should remove all margins. If not, some of the content of the page might be hidden.

But I guess I missed orientation and paper size... Does it work when you interact with Gotenberg directly? (I cannot check right now)

peteralbert commented 3 years ago

So the orientation works (when simply casting to to any). I haven’t tried size or margins yet - will try this tonight.

peteralbert commented 3 years ago

Just verified - all three elements (orientation, size, margins) work without any issue!

yumauri commented 3 years ago

Cool, thank you! Sorry for delay, was away from laptop for a few days. Then I'll fix typings and will publish new version in a week :) Hopefully tomorrow

yumauri commented 3 years ago

Published version 0.6.3 with fixed typings for url function. @peteralbert check please

peteralbert commented 3 years ago

Thank you - this solves the issue!