diff --git a/.changeset/curvy-suns-roll.md b/.changeset/curvy-suns-roll.md new file mode 100644 index 00000000000..010103b444e --- /dev/null +++ b/.changeset/curvy-suns-roll.md @@ -0,0 +1,7 @@ +--- +'@clerk/backend': patch +--- + +The `emails` endpoint helper and the corresponding `createEmail` method have been removed from the `@clerk/backend` SDK and `apiClint.emails.createEmail` will no longer be available. + +We will not be providing an alternative method for creating and sending emails directly from our JavaScript SDKs with this release. If you are currently using `createEmail` and you wish to update to the latest SDK version, please reach out to our support team (https://clerk.com/support) so we can assist you. diff --git a/packages/backend/src/api/__tests__/factory.test.ts b/packages/backend/src/api/__tests__/factory.test.ts index 075e0eb3985..227cea88909 100644 --- a/packages/backend/src/api/__tests__/factory.test.ts +++ b/packages/backend/src/api/__tests__/factory.test.ts @@ -1,8 +1,6 @@ import type QUnit from 'qunit'; import sinon from 'sinon'; -// @ts-ignore -import emailJson from '../../fixtures/email.json'; // @ts-ignore import userJson from '../../fixtures/user.json'; import runtime from '../../runtime'; @@ -88,39 +86,6 @@ export default (QUnit: QUnit) => { ); }); - test('executes a successful backend API request for a resource that contains data (key related to pagination)', async assert => { - fakeFetch = sinon.stub(runtime, 'fetch'); - fakeFetch.onCall(0).returns(jsonOk(emailJson)); - - const body = { - fromEmailName: 'foobar123', - emailAddressId: 'test@test.dev', - body: 'this is a test', - subject: 'this is a test', - }; - const requestBody = - '{"from_email_name":"foobar123","email_address_id":"test@test.dev","body":"this is a test","subject":"this is a test"}'; - const response = await apiClient.emails.createEmail(body); - assertResponse(assert, response); - const { data: payload, totalCount } = response; - - assert.equal(JSON.stringify(payload.data), '{}'); - assert.equal(payload.id, 'ema_2PHa2N3bS7D6NPPQ5mpHEg0waZQ'); - assert.equal(totalCount, undefined); - - assert.ok( - fakeFetch.calledOnceWith('https://api.clerk.test/v1/emails', { - method: 'POST', - body: requestBody, - headers: { - Authorization: 'Bearer deadbeef', - 'Content-Type': 'application/json', - 'User-Agent': '@clerk/backend@0.0.0-test', - }, - }), - ); - }); - test('executes a successful backend API request for a paginated response', async assert => { fakeFetch = sinon.stub(runtime, 'fetch'); fakeFetch.onCall(0).returns(jsonPaginatedOk([userJson], 3)); diff --git a/packages/backend/src/api/endpoints/EmailApi.ts b/packages/backend/src/api/endpoints/EmailApi.ts deleted file mode 100644 index 77e88c06fc9..00000000000 --- a/packages/backend/src/api/endpoints/EmailApi.ts +++ /dev/null @@ -1,21 +0,0 @@ -import type { Email } from '../resources/Email'; -import { AbstractAPI } from './AbstractApi'; - -type EmailParams = { - fromEmailName: string; - emailAddressId: string; - subject: string; - body: string; -}; - -const basePath = '/emails'; - -export class EmailAPI extends AbstractAPI { - public async createEmail(params: EmailParams) { - return this.request({ - method: 'POST', - path: basePath, - bodyParams: params, - }); - } -} diff --git a/packages/backend/src/api/endpoints/index.ts b/packages/backend/src/api/endpoints/index.ts index 9d823d9de1a..dd61b88f2b3 100644 --- a/packages/backend/src/api/endpoints/index.ts +++ b/packages/backend/src/api/endpoints/index.ts @@ -3,7 +3,6 @@ export * from './AllowlistIdentifierApi'; export * from './ClientApi'; export * from './DomainApi'; export * from './EmailAddressApi'; -export * from './EmailApi'; export * from './InvitationApi'; export * from './OrganizationApi'; export * from './PhoneNumberApi'; diff --git a/packages/backend/src/api/factory.ts b/packages/backend/src/api/factory.ts index 6a9e63b4c6c..e9f69b6e5e2 100644 --- a/packages/backend/src/api/factory.ts +++ b/packages/backend/src/api/factory.ts @@ -3,7 +3,6 @@ import { ClientAPI, DomainAPI, EmailAddressAPI, - EmailAPI, InvitationAPI, OrganizationAPI, PhoneNumberAPI, @@ -25,7 +24,6 @@ export function createBackendApiClient(options: CreateBackendApiOptions) { allowlistIdentifiers: new AllowlistIdentifierAPI(request), clients: new ClientAPI(request), emailAddresses: new EmailAddressAPI(request), - emails: new EmailAPI(request), invitations: new InvitationAPI(request), organizations: new OrganizationAPI(request), phoneNumbers: new PhoneNumberAPI(request), diff --git a/packages/backend/src/fixtures/email.json b/packages/backend/src/fixtures/email.json deleted file mode 100644 index 98b1b64ed11..00000000000 --- a/packages/backend/src/fixtures/email.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "id": "ema_2PHa2N3bS7D6NPPQ5mpHEg0waZQ", - "object": "email", - "slug": null, - "from_email_name": "foobar123", - "to_email_address": "test@test.dev", - "email_address_id": "idn_2LVNCHPlLJpGE8Ep2wPtsxg7qRt", - "user_id": "user_2LVNDmSPQYOhXFeELW9IpLQcvDs", - "subject": "this is a test", - "body": "this is a test", - "body_plain": null, - "status": "queued", - "data": {}, - "delivered_by_clerk": true -}