From 03701e1601fe0216addad4dd38b8d0b07aba32f4 Mon Sep 17 00:00:00 2001 From: Dima Grossman Date: Sun, 14 Jan 2024 14:16:37 +0200 Subject: [PATCH] fix: resend sdk version --- pnpm-lock.yaml | 75 +++---------------- providers/resend/package.json | 2 +- .../resend/src/lib/resend.provider.spec.ts | 7 +- providers/resend/src/lib/resend.provider.ts | 6 +- 4 files changed, 20 insertions(+), 70 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fe597dd94a8..bdc240d441d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5625,8 +5625,8 @@ importers: specifier: ^0.22.0 version: link:../../packages/stateless resend: - specifier: ^0.17.2 - version: 0.17.2 + specifier: ^2.1.0 + version: 2.1.0 devDependencies: '@istanbuljs/nyc-config-typescript': specifier: ^1.0.1 @@ -20184,11 +20184,11 @@ packages: react-dom: 17.0.2(react@17.0.2) dev: false - /@react-email/render@0.0.7: - resolution: {integrity: sha512-hMMhxk6TpOcDC5qnKzXPVJoVGEwfm+U5bGOPH+MyTTlx0F02RLQygcATBKsbP7aI/mvkmBAZoFbgPIHop7ovug==} - engines: {node: '>=16.0.0'} + /@react-email/render@0.0.9: + resolution: {integrity: sha512-nrim7wiACnaXsGtL7GF6jp3Qmml8J6vAjAH88jkC8lIbfNZaCyuPQHANjyYIXlvQeAbsWADQJFZgOHUqFqjh/A==} + engines: {node: '>=18.0.0'} dependencies: - html-to-text: 9.0.3 + html-to-text: 9.0.5 pretty: 2.0.0 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) @@ -20584,13 +20584,6 @@ packages: - supports-color dev: false - /@selderee/plugin-htmlparser2@0.10.0: - resolution: {integrity: sha512-gW69MEamZ4wk1OsOq1nG1jcyhXIQcnrsX5JwixVw/9xaiav8TCyjESAruu1Rz9yyInhgBXxkNwMeygKnN2uxNA==} - dependencies: - domhandler: 5.0.3 - selderee: 0.10.0 - dev: false - /@selderee/plugin-htmlparser2@0.11.0: resolution: {integrity: sha512-P33hHGdldxGabLFjPPpaTxVolMrzrcegejx+0GxjrIb9Zv48D8yAIA/QTDR2dFl7Uz7urX8aX6+5bCZslr+gWQ==} dependencies: @@ -28501,16 +28494,6 @@ packages: - debug dev: true - /axios@1.4.0: - resolution: {integrity: sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==} - dependencies: - follow-redirects: 1.15.2 - form-data: 4.0.0 - proxy-from-env: 1.1.0 - transitivePeerDependencies: - - debug - dev: false - /axios@1.6.0: resolution: {integrity: sha512-EZ1DYihju9pwVB+jg67ogm+Tmqc6JmhamRN6I4Zt8DfZu5lbcQGw3ozH9lFejSJgs/ibaef3A9PMXPLeefFGJg==} dependencies: @@ -33297,7 +33280,7 @@ packages: eslint: 8.51.0 eslint-import-resolver-node: 0.3.7 eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.58.0)(eslint-import-resolver-node@0.3.7)(eslint-import-resolver-webpack@0.13.7)(eslint@8.51.0) - has: 1.0.4 + has: 1.0.3 is-core-module: 2.13.0 is-glob: 4.0.3 minimatch: 3.1.2 @@ -36164,17 +36147,6 @@ packages: engines: {node: '>=8'} dev: true - /html-to-text@9.0.3: - resolution: {integrity: sha512-hxDF1kVCF2uw4VUJ3vr2doc91pXf2D5ngKcNviSitNkhP9OMOaJkDrFIFL6RMvko7NisWTEiqGpQ9LAxcVok1w==} - engines: {node: '>=14'} - dependencies: - '@selderee/plugin-htmlparser2': 0.10.0 - deepmerge: 4.3.1 - dom-serializer: 2.0.0 - htmlparser2: 8.0.2 - selderee: 0.10.0 - dev: false - /html-to-text@9.0.5: resolution: {integrity: sha512-qY60FjREgVZL03vJU6IfMV4GDjGBIoOyvuFdpBDIX9yTlDw0TjxVBQp+P8NvpdIXNJvfWBTNul7fsAQJq2FNpg==} engines: {node: '>=14'} @@ -43424,13 +43396,6 @@ packages: dependencies: entities: 4.5.0 - /parseley@0.11.0: - resolution: {integrity: sha512-VfcwXlBWgTF+unPcr7yu3HSSA6QUdDaDnrHcytVfj5Z8azAyKBDrYnSIfeSxlrEayndNcLmrXzg+Vxbo6DWRXQ==} - dependencies: - leac: 0.6.0 - peberminta: 0.8.0 - dev: false - /parseley@0.12.1: resolution: {integrity: sha512-e6qHKe3a9HWr0oMRVDTRhKce+bRO8VGQR3NyVwcjwrbhMmFCX9KszEV35+rn4AdilFAq9VPxP/Fe1wC9Qjd2lw==} dependencies: @@ -43655,10 +43620,6 @@ packages: resolution: {integrity: sha512-KG8UEiEVkR3wGEb4m5yZkVCzigAD+cVEJck2CzYZO37ZGJfctvVptVO192MwrtPhzONn6go8ylnOdMhKqi4nfg==} dev: false - /peberminta@0.8.0: - resolution: {integrity: sha512-YYEs+eauIjDH5nUEGi18EohWE0nV2QbGTqmxQcqgZ/0g+laPCQmuIqq7EBLVi9uim9zMgfJv0QBZEnQ3uHw/Tw==} - dev: false - /peberminta@0.9.0: resolution: {integrity: sha512-XIxfHpEuSJbITd1H3EeQwpcZbTLHc+VVr8ANI9t5sit565tsI4/xK3KWTUFE2e6QiangUkh3B0jihzmGnNrRsQ==} dev: false @@ -47221,14 +47182,11 @@ packages: dev: false optional: true - /resend@0.17.2: - resolution: {integrity: sha512-lakm76u4MiIDeMF1s2tCmjtksOhwZOs4WcAXkA7aUTvl+63/h+0h6Q6WnkB8RGtj6GakUhQuUkiZshfXgtIrGw==} + /resend@2.1.0: + resolution: {integrity: sha512-s6LlaEReTUvlbo6w3Eg1M1TMuwK9OKJ1GVgyptIV8smLPHhFZVqnwBTFPZHID9rcsih72t3iuyrtkQ3IIGwnow==} + engines: {node: '>=18'} dependencies: - '@react-email/render': 0.0.7 - axios: 1.4.0 - type-fest: 3.13.0 - transitivePeerDependencies: - - debug + '@react-email/render': 0.0.9 dev: false /reserved@0.1.2: @@ -47834,12 +47792,6 @@ packages: resolution: {integrity: sha512-6aU+Rwsezw7VR8/nyvKTx8QpWH9FrcYiXXlqC4z5d5XQBDRqtbfsRjnwGyqbi3gddNtWHuEk9OANUotL26qKUw==} dev: false - /selderee@0.10.0: - resolution: {integrity: sha512-DEL/RW/f4qLw/NrVg97xKaEBC8IpzIG2fvxnzCp3Z4yk4jQ3MXom+Imav9wApjxX2dfS3eW7x0DXafJr85i39A==} - dependencies: - parseley: 0.11.0 - dev: false - /selderee@0.11.0: resolution: {integrity: sha512-5TF+l7p4+OsnP8BCCvSyZiSPc4x4//p5uPwK8TCnVPJYRmU2aYKMpOXvw8zM5a5JvuuCGN1jmsMwuU2W02ukfA==} dependencies: @@ -50691,11 +50643,6 @@ packages: resolution: {integrity: sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==} engines: {node: '>=12.20'} - /type-fest@3.13.0: - resolution: {integrity: sha512-Gur3yQGM9qiLNs0KPP7LPgeRbio2QTt4xXouobMCarR0/wyW3F+F/+OWwshg3NG0Adon7uQfSZBpB46NfhoF1A==} - engines: {node: '>=14.16'} - dev: false - /type-is@1.6.18: resolution: {integrity: sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==} engines: {node: '>= 0.6'} diff --git a/providers/resend/package.json b/providers/resend/package.json index 9bc5511fda0..a87967e61ea 100644 --- a/providers/resend/package.json +++ b/providers/resend/package.json @@ -33,7 +33,7 @@ }, "dependencies": { "@novu/stateless": "^0.22.0", - "resend": "^0.17.2" + "resend": "^2.1.0" }, "devDependencies": { "@istanbuljs/nyc-config-typescript": "^1.0.1", diff --git a/providers/resend/src/lib/resend.provider.spec.ts b/providers/resend/src/lib/resend.provider.spec.ts index 27b05cb95f8..31cde396fd3 100644 --- a/providers/resend/src/lib/resend.provider.spec.ts +++ b/providers/resend/src/lib/resend.provider.spec.ts @@ -1,10 +1,13 @@ -import { ResendEmailProvider } from './resend.provider'; import { Resend } from 'resend'; + +import { ResendEmailProvider } from './resend.provider'; const mockConfig = { apiKey: 'this-api-key-from-resend', from: 'test@test.com', }; +(global as any).Headers = () => {}; + const mockNovuMessage = { from: 'test@test.com', to: ['test@test.com'], @@ -48,7 +51,7 @@ test('should trigger resend email with From Name', async () => { const provider = new ResendEmailProvider(mockConfigWithSenderName); const spy = jest - .spyOn(Resend.prototype, 'sendEmail') + .spyOn((provider as any).resendClient.emails, 'send') .mockImplementation(async () => { // eslint-disable-next-line @typescript-eslint/no-explicit-any return {} as any; diff --git a/providers/resend/src/lib/resend.provider.ts b/providers/resend/src/lib/resend.provider.ts index 5f3cf57c11f..ec924a64c30 100644 --- a/providers/resend/src/lib/resend.provider.ts +++ b/providers/resend/src/lib/resend.provider.ts @@ -29,7 +29,7 @@ export class ResendEmailProvider implements IEmailProvider { const senderName = options.senderName || this.config?.senderName; const fromAddress = options.from || this.config.from; - const response: any = await this.resendClient.sendEmail({ + const response = await this.resendClient.emails.send({ from: senderName ? `${senderName} <${fromAddress}>` : fromAddress, to: options.to, subject: options.subject, @@ -44,7 +44,7 @@ export class ResendEmailProvider implements IEmailProvider { }); return { - id: response.id, + id: response.data?.id, date: new Date().toISOString(), }; } @@ -53,7 +53,7 @@ export class ResendEmailProvider implements IEmailProvider { options: IEmailOptions ): Promise { try { - await this.resendClient.sendEmail({ + await this.resendClient.emails.send({ from: options.from || this.config.from, to: options.to, subject: options.subject,