Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/curvy-suns-roll.md
Original file line number Diff line number Diff line change
@@ -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.
35 changes: 0 additions & 35 deletions packages/backend/src/api/__tests__/factory.test.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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 => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Instead of removing this test, replace the apiClient.emails.createEmail(body); with another API call. This test is not related to the EmailAPI, it was just used as an example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible this test is no longer needed? 🤔 After looking around only SMSMessage and Emails contain the property readonly data?: Record<string, any> | null that is being checked here.

To be completely honest I am not 100% sure what is being tested here 😓 And whats the differences between this test and the first one that executes a successful backend API request for a single resource and parses the response

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct. This case is no longer applicable. let's drop it.

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));
Expand Down
21 changes: 0 additions & 21 deletions packages/backend/src/api/endpoints/EmailApi.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/backend/src/api/endpoints/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 0 additions & 2 deletions packages/backend/src/api/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
ClientAPI,
DomainAPI,
EmailAddressAPI,
EmailAPI,
InvitationAPI,
OrganizationAPI,
PhoneNumberAPI,
Expand All @@ -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),
Expand Down
15 changes: 0 additions & 15 deletions packages/backend/src/fixtures/email.json

This file was deleted.