brevo-node icon indicating copy to clipboard operation
brevo-node copied to clipboard

Is there a release date for Typescript support?

Open cdslxc opened this issue 2 years ago • 41 comments

My current project used Typescript, I wasn't able to migrate from SIB to Brevo.

CleanShot 2023-06-15 at 16 13 51@2x

cdslxc avatar Jun 15 '23 09:06 cdslxc

Hi @cody-ta We are still trying to find a way to provide TS support for the same. It is taking us some time to figure that out since our SDKs are auto-generated using swagger-codegen@2. Thanks.

shubhamUpadhyayInBlue avatar Jun 20 '23 10:06 shubhamUpadhyayInBlue

Yeah, I think most of NodeJS developers will look for this issue. @shubhamUpadhyayInBlue have you tried https://github.com/acacode/swagger-typescript-api?

NarHakobyan avatar Jun 21 '23 15:06 NarHakobyan

Also looking for typescript support as I'm moving my website from js to typescript at the moment.

reynolga avatar Jun 24 '23 11:06 reynolga

Hello I have raised the request and will update you as soon as I have any updates. Thanks.

shubhamUpadhyayInBlue avatar Jun 26 '23 07:06 shubhamUpadhyayInBlue

Until solved:

swagger-typescript-api -p https://api.brevo.com/v3/swagger_definition.yml -o ./lib/email/brevo

matthiasbruns avatar Jun 27 '23 12:06 matthiasbruns

Until solved:

swagger-typescript-api -p https://api.brevo.com/v3/swagger_definition.yml -o ./lib/email/brevo

Better then lib 😄

NarHakobyan avatar Jul 02 '23 19:07 NarHakobyan

@matthiasbruns How do you set the API key?

AlexZeitler avatar Jul 04 '23 08:07 AlexZeitler

@matthiasbruns How do you set the API key?

new Brevo({
          baseApiParams: {
            headers: {
              'api-key': yourKeyhere,
            },
          },
        })

NarHakobyan avatar Jul 04 '23 13:07 NarHakobyan

@NarHakobyan Thanks!

AlexZeitler avatar Jul 05 '23 05:07 AlexZeitler

The latest swagger file is here: https://api.brevo.com/v3/swagger_definition_v3.yml

So, @matthiasbruns @NarHakobyan you can try using this latest swagger file instead.

shubhamUpadhyayInBlue avatar Jul 05 '23 06:07 shubhamUpadhyayInBlue

Hi @shubhamUpadhyayInBlue, thanks for the new definition but there is an issue in the swagger file at line 17986. Please remove the double quote.

   try to get swagger by URL "https://api.brevo.com/v3/swagger_definition_v3.yml"
☄️    start generating your typescript api
SyntaxError: ';' expected. (6656:97)
  6654 |    * @example "request"
  6655 |    */
> 6656 |     event: "invalid_parameter" | "missing_parameter" | "hardBounce" | "softBounce" | "delivered"" | "spam" | "request" | "opened" | "click" | "invalid" | "deferred" | "blocked" | "unsubscribed" | "error" | "uniqueOpened" | "loadedByProxy" | "allEvents",
       |                                                                                                 ^
  6657 |   /**
  6658 |    * Webhook URL to receive CSV file link
  6659 |    * @example "https://brevo.com"

garysb avatar Jul 05 '23 07:07 garysb

Hi @garysb I have fixed the swagger file. Please try and let me know if you face any issue.

shubhamUpadhyayInBlue avatar Jul 06 '23 12:07 shubhamUpadhyayInBlue

Take me sometimes to get it working (because din't know how swagger-typescript-api was working) but now everything is working and tested!

https://gist.github.com/marentdev/28d49bfee47704ac39fcd55cb4ac8b0e (Brevo Lib)

marentdev avatar Jul 14 '23 13:07 marentdev

Hi @shubhamUpadhyayInBlue Do you have defined an estimated time for an official documentation of the library under TS?

Developer:

If you do not know how to use the swagger-typescript-api library you can guide yourself with the following steps:

/** npx swagger-typescript-api -p https://api.brevo.com/v3/swagger_definition.yml -o [PATH-OUTPUT] -n [TS-FILENAME (Sample: Brevo.ts)]
**/

// SAMPLE
// console
npx swagger-typescript-api -p https://api.brevo.com/v3/swagger_definition.yml -o /src/utils/email -n Brevo.ts
...

// ts-file.ts
import { Brevo } from './utils/email/Brevo';

...

const brevo = new Brevo({ baseApiParams: { headers: { 'api-key': 'YOUR-KEY' } })

higuitadiaz avatar Aug 11 '23 13:08 higuitadiaz

Hi @shubhamUpadhyayInBlue Do you have defined an estimated time for an official documentation of the library under TS?

Developer:

If you do not know how to use the swagger-typescript-api library you can guide yourself with the following steps:

/** npx swagger-typescript-api -p https://api.brevo.com/v3/swagger_definition.yml -o [PATH-OUTPUT] -n [TS-FILENAME (Sample: Brevo.ts)]
**/

// SAMPLE
// console
npx swagger-typescript-api -p https://api.brevo.com/v3/swagger_definition.yml -o /src/utils/email -n Brevo.ts
...

// ts-file.ts
import { Brevo } from './utils/email/Brevo';

...

const brevo = new Brevo({ baseApiParams: { headers: { 'api-key': 'YOUR-KEY' } })

Hi @higuitadiaz, Thanks for the explanation. Just a few comments, the swagger definition in your guide is outdated. The link to the current swagger definition is https://api.brevo.com/v3/swagger_definition_v3.yml (notice the second v3 at the end). Also swagger-typescript-api does not name the client "Brevo" by default. The name for the client is "Api", so you should either change the name to Brevo in the Brevo.ts file or use it like this:

// ts-file.ts
import { Api } from './utils/email/Brevo';

...

const brevo = new Api({ baseApiParams: { headers: { 'api-key': 'YOUR-KEY' } })

kracas avatar Aug 17 '23 10:08 kracas

Really need ts support before we can migrate to brevo

SMKH-PRO avatar Aug 18 '23 08:08 SMKH-PRO

I also need ts support before I can move to brevo... @shubhamUpadhyayInBlue have you thought about moving to the openapi generator? In openapi generator, which should be compatible to your swagger definition file, you should be able to generate typescript code for several libs like fetch or axios. https://openapi-generator.tech/docs/generators

shorthander avatar Aug 23 '23 10:08 shorthander

Any update here @shubhamUpadhyayInBlue ?

We do not want to continue building with deprecated lib, but the lack of Typescript support here is blocking us. It has been several months since you've raised this issue, so I would hope some progress has been made. Could you provide us with an estimate?

cwierzbicki00 avatar Sep 07 '23 18:09 cwierzbicki00

Hi @cwierzbicki00 It is under discussion and we will be able to give feedback soon. I will make sure your message reaches the concerned team. Thanks.

shubhamUpadhyayInBlue avatar Sep 08 '23 05:09 shubhamUpadhyayInBlue

Hi @shubhamUpadhyayInBlue Do you have defined an estimated time for an official documentation of the library under TS? Developer: If you do not know how to use the swagger-typescript-api library you can guide yourself with the following steps:

/** npx swagger-typescript-api -p https://api.brevo.com/v3/swagger_definition.yml -o [PATH-OUTPUT] -n [TS-FILENAME (Sample: Brevo.ts)]
**/

// SAMPLE
// console
npx swagger-typescript-api -p https://api.brevo.com/v3/swagger_definition.yml -o /src/utils/email -n Brevo.ts
...

// ts-file.ts
import { Brevo } from './utils/email/Brevo';

...

const brevo = new Brevo({ baseApiParams: { headers: { 'api-key': 'YOUR-KEY' } })

Hi @higuitadiaz, Thanks for the explanation. Just a few comments, the swagger definition in your guide is outdated. The link to the current swagger definition is https://api.brevo.com/v3/swagger_definition_v3.yml (notice the second v3 at the end). Also swagger-typescript-api does not name the client "Brevo" by default. The name for the client is "Api", so you should either change the name to Brevo in the Brevo.ts file or use it like this:

// ts-file.ts
import { Api } from './utils/email/Brevo';

...

const brevo = new Api({ baseApiParams: { headers: { 'api-key': 'YOUR-KEY' } })

Thanks for the Ts help. Can anyone help with the the steps to send a simple transactional email with a template and a param? I cant seem to follow the instructions with this ts file.


EDIT:

I figured it out. For anyone who gets confused too:

import { Api } from './utils/email/Brevo' // import from whichever location you generated the ts file to

const brevo = new Api({ baseApiParams: { headers: { 'api-key': 'YOUR-KEY' } })

let emailData: SendSmtpEmail = {
  templateId: parseInt(templateId),
  sender: { name: siteConfig.name, email: env.SMTP_FROM },
  to: [{ email: identifier }],
  headers: { "X-Entity-Ref-ID": new Date().getTime() + "" },
  params: {
    action_url: url,
    product_name: siteConfig.name,
  },
};

const result = await await brevo.smtp.sendTransacEmail(emailData);

if (result.status != 201) {
  throw new Error(result.error.message);
}

Thanks

iampapagray avatar Sep 21 '23 01:09 iampapagray

Is there any update about the typescript release ?

theofrgs avatar Oct 06 '23 10:10 theofrgs

$ npm remove @sendinblue/client
$ npm install @getbrevo/brevo
$ npm i --save-dev @types/getbrevo__brevo
npm ERR! code E404

=> Googling, finding this github issue, then 5 minutes later:

$ npm remove @getbrevo/brevo
$ npm install @sendinblue/client

:)

(I do hope they support TS soon though as the security audit of sendinblue/client is bad)

FredTreg avatar Oct 18 '23 15:10 FredTreg

Sending transactional emails via axios/fetch is more comfortable

vladislavbogomolov avatar Oct 19 '23 13:10 vladislavbogomolov

Until solved:

swagger-typescript-api -p https://api.brevo.com/v3/swagger_definition.yml -o ./lib/email/brevo

how do I make use of this

dkrest1 avatar Oct 23 '23 12:10 dkrest1

Is there any update about the typescript release ?

I am not sure because I have not seen one

dkrest1 avatar Oct 23 '23 12:10 dkrest1

Is there any news about TypeScript?

tiavina-mika avatar Nov 06 '23 16:11 tiavina-mika

Up !

akouyate avatar Nov 13 '23 09:11 akouyate

Is there something new on this? Send In blue is gone now for a while and still missleading docs on the page, still no TS support.

mwolf1989 avatar Nov 13 '23 10:11 mwolf1989

Hi, my client bought a license for Brevo without telling me, now i'm stuck with this and can't deliver the app, client is waiting, do you guys could at least bother to respond to us ? I understood you guys don't care but we are client, and you can bet I won't recommend this to any of my clients in the futur

FrancoisSoler avatar Nov 16 '23 17:11 FrancoisSoler

@shubhamUpadhyayInBlue

Hi @cwierzbicki00 It is under discussion and we will be able to give feedback soon. I will make sure your message reaches the concerned team. Thanks.

This seems to be a larger and larger issue for everyone. Especially knowing that the types can be generated, this is frustrating. "swagger-typescript-api -p https://api.brevo.com/v3/swagger_definition.yml -o ./lib/email/brevo" is not a valid long-term solution for a production level product like this. I am hoping for an update soon.

Please at least advise how we should proceed - we need Typescript support. I don't want to build with insecure and deprecated sendinblue. What are we to do to use Brevo?

Thanks

cwierzbicki00 avatar Nov 16 '23 20:11 cwierzbicki00