Skip to content

Commit 4b94fc5

Browse files
committed
Remove deprecated test runs methods from the /me path
1 parent 69573c2 commit 4b94fc5

7 files changed

Lines changed: 1 addition & 303 deletions

File tree

.changeset/quick-pugs-tap.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
'@clerk/shared': patch
44
---
55

6-
Remove deprecated `createEnterpriseConnection`, `updateEnterpriseConnection`, and `deleteEnterpriseConnection` methods from the `User` resource in favor of `Organization` scoped ones
6+
Remove deprecated `createEnterpriseConnection`, `updateEnterpriseConnection`, `deleteEnterpriseConnection`, `createEnterpriseConnectionTestRun`, and `getEnterpriseConnectionTestRuns` methods from the `User` resource in favor of `Organization` scoped ones. Also removes the unused internal `__internal_useEnterpriseConnectionTestRuns` hook.
77

88
`ConfigureSSO` was previously the only consumer but since it hasn't been released GA yet, these changes won't break existing production clients

packages/clerk-js/src/core/resources/User.ts

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { getFullName } from '@clerk/shared/internal/clerk-js/user';
22
import type {
33
BackupCodeJSON,
44
BackupCodeResource,
5-
ClerkPaginatedResponse,
65
CreateEmailAddressParams,
76
CreateExternalAccountParams,
87
CreatePhoneNumberParams,
@@ -13,15 +12,9 @@ import type {
1312
EnterpriseAccountResource,
1413
EnterpriseConnectionJSON,
1514
EnterpriseConnectionResource,
16-
EnterpriseConnectionTestRunInitJSON,
17-
EnterpriseConnectionTestRunInitResource,
18-
EnterpriseConnectionTestRunJSON,
19-
EnterpriseConnectionTestRunResource,
20-
EnterpriseConnectionTestRunsPaginatedJSON,
2115
ExternalAccountJSON,
2216
ExternalAccountResource,
2317
GetEnterpriseConnectionsParams,
24-
GetEnterpriseConnectionTestRunsParams,
2518
GetOrganizationMemberships,
2619
GetUserOrganizationInvitationsParams,
2720
GetUserOrganizationSuggestionsParams,
@@ -43,7 +36,6 @@ import type {
4336
Web3WalletResource,
4437
} from '@clerk/shared/types';
4538

46-
import { convertPageToOffsetSearchParams } from '../../utils/convertPageToOffsetSearchParams';
4739
import { unixEpochToDate } from '../../utils/date';
4840
import { normalizeUnsafeMetadata } from '../../utils/resourceParams';
4941
import { eventBus, events } from '../events';
@@ -55,7 +47,6 @@ import {
5547
EmailAddress,
5648
EnterpriseAccount,
5749
EnterpriseConnection,
58-
EnterpriseConnectionTestRun,
5950
ExternalAccount,
6051
Image,
6152
OrganizationMembership,
@@ -333,45 +324,6 @@ export class User extends BaseResource implements UserResource {
333324
return (json || []).map(connection => new EnterpriseConnection(connection));
334325
};
335326

336-
createEnterpriseConnectionTestRun = async (
337-
enterpriseConnectionId: string,
338-
): Promise<EnterpriseConnectionTestRunInitResource> => {
339-
const json = (
340-
await BaseResource._fetch({
341-
path: `${this.path()}/enterprise_connections/${enterpriseConnectionId}/test_runs`,
342-
method: 'POST',
343-
})
344-
)?.response as unknown as EnterpriseConnectionTestRunInitJSON;
345-
346-
return { url: json.url };
347-
};
348-
349-
getEnterpriseConnectionTestRuns = async (
350-
enterpriseConnectionId: string,
351-
params?: GetEnterpriseConnectionTestRunsParams,
352-
): Promise<ClerkPaginatedResponse<EnterpriseConnectionTestRunResource>> => {
353-
const { status, ...rest } = params || {};
354-
const search = convertPageToOffsetSearchParams(rest);
355-
if (status?.length) {
356-
for (const s of status) {
357-
search.append('status', s);
358-
}
359-
}
360-
361-
const res = await BaseResource._fetch({
362-
path: `${this.path()}/enterprise_connections/${enterpriseConnectionId}/test_runs`,
363-
method: 'GET',
364-
search,
365-
});
366-
367-
const payload = res?.response as unknown as EnterpriseConnectionTestRunsPaginatedJSON | undefined;
368-
369-
return {
370-
total_count: payload?.total_count ?? 0,
371-
data: (payload?.data ?? []).map((row: EnterpriseConnectionTestRunJSON) => new EnterpriseConnectionTestRun(row)),
372-
};
373-
};
374-
375327
initializePaymentMethod: typeof initializePaymentMethod = params => {
376328
return initializePaymentMethod(params);
377329
};

packages/clerk-js/src/core/resources/__tests__/User.test.ts

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -139,72 +139,6 @@ describe('User', () => {
139139
expect(connections[0].allowOrganizationAccountLinking).toBe(true);
140140
});
141141

142-
it('creates an enterprise connection test run', async () => {
143-
// @ts-ignore
144-
BaseResource._fetch = vi.fn().mockReturnValue(Promise.resolve({ response: { url: 'https://example.com/test' } }));
145-
146-
const user = new User({
147-
email_addresses: [],
148-
phone_numbers: [],
149-
web3_wallets: [],
150-
external_accounts: [],
151-
} as unknown as UserJSON);
152-
153-
const init = await user.createEnterpriseConnectionTestRun('ec_123');
154-
155-
// @ts-ignore
156-
expect(BaseResource._fetch).toHaveBeenCalledWith({
157-
method: 'POST',
158-
path: '/me/enterprise_connections/ec_123/test_runs',
159-
});
160-
161-
expect(init.url).toBe('https://example.com/test');
162-
});
163-
164-
it('lists enterprise connection test runs', async () => {
165-
const paginated = {
166-
data: [
167-
{
168-
object: 'enterprise_connection_test_run' as const,
169-
id: 'run_1',
170-
status: 'success',
171-
connection_type: 'saml' as const,
172-
created_at: 1700000000000,
173-
},
174-
],
175-
total_count: 1,
176-
};
177-
178-
// @ts-ignore
179-
BaseResource._fetch = vi.fn().mockReturnValue(Promise.resolve({ response: paginated }));
180-
181-
const user = new User({
182-
email_addresses: [],
183-
phone_numbers: [],
184-
web3_wallets: [],
185-
external_accounts: [],
186-
} as unknown as UserJSON);
187-
188-
const result = await user.getEnterpriseConnectionTestRuns('ec_123', {
189-
initialPage: 1,
190-
pageSize: 10,
191-
status: ['pending', 'success'],
192-
});
193-
194-
// @ts-ignore
195-
const call = BaseResource._fetch.mock.calls[0][0];
196-
expect(call.method).toBe('GET');
197-
expect(call.path).toBe('/me/enterprise_connections/ec_123/test_runs');
198-
expect(call.search.get('limit')).toBe('10');
199-
expect(call.search.get('offset')).toBe('0');
200-
expect(call.search.getAll('status')).toEqual(['pending', 'success']);
201-
202-
expect(result.total_count).toBe(1);
203-
expect(result.data).toHaveLength(1);
204-
expect(result.data[0].id).toBe('run_1');
205-
expect(result.data[0].connectionType).toBe('saml');
206-
});
207-
208142
it('creates a web3 wallet', async () => {
209143
const targetWeb3Wallet = '0x0000000000000000000000000000000000000000';
210144
const web3WalletJSON = {

packages/shared/src/react/hooks/index.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ export type {
3838
UseUserEnterpriseConnectionsParams,
3939
UseUserEnterpriseConnectionsReturn,
4040
} from './useUserEnterpriseConnections';
41-
export { __internal_useEnterpriseConnectionTestRuns } from './useEnterpriseConnectionTestRuns';
42-
export type {
43-
UseEnterpriseConnectionTestRunsParams,
44-
UseEnterpriseConnectionTestRunsReturn,
45-
} from './useEnterpriseConnectionTestRuns';
4641
export { __internal_useOrganizationEnterpriseConnections } from './useOrganizationEnterpriseConnections';
4742
export type {
4843
UseOrganizationEnterpriseConnectionsParams,

packages/shared/src/react/hooks/useEnterpriseConnectionTestRuns.shared.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.

packages/shared/src/react/hooks/useEnterpriseConnectionTestRuns.tsx

Lines changed: 0 additions & 140 deletions
This file was deleted.

packages/shared/src/types/user.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ import type { DeletedObjectResource } from './deletedObject';
44
import type { EmailAddressResource } from './emailAddress';
55
import type { EnterpriseAccountResource } from './enterpriseAccount';
66
import type { EnterpriseConnectionResource } from './enterpriseConnection';
7-
import type {
8-
EnterpriseConnectionTestRunInitResource,
9-
EnterpriseConnectionTestRunResource,
10-
GetEnterpriseConnectionTestRunsParams,
11-
} from './enterpriseConnectionTestRun';
127
import type { ExternalAccountResource } from './externalAccount';
138
import type { ImageResource } from './image';
149
import type { UserJSON } from './json';
@@ -308,13 +303,6 @@ export interface UserResource extends ClerkResource, BillingPayerMethods {
308303
* @hidden
309304
*/
310305
getEnterpriseConnections: (params?: GetEnterpriseConnectionsParams) => Promise<EnterpriseConnectionResource[]>;
311-
createEnterpriseConnectionTestRun: (
312-
enterpriseConnectionId: string,
313-
) => Promise<EnterpriseConnectionTestRunInitResource>;
314-
getEnterpriseConnectionTestRuns: (
315-
enterpriseConnectionId: string,
316-
params?: GetEnterpriseConnectionTestRunsParams,
317-
) => Promise<ClerkPaginatedResponse<EnterpriseConnectionTestRunResource>>;
318306
/**
319307
* Generates a TOTP secret for a user that can be used to register the application on the user's authenticator app of choice. If this method is called again (while still unverified), it replaces the previously generated secret.
320308
* @returns A [`TOTPResource`](https://clerk.com/docs/reference/types/totp-resource) object.

0 commit comments

Comments
 (0)