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
8 changes: 8 additions & 0 deletions .changeset/quick-pugs-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@clerk/clerk-js': patch
'@clerk/shared': patch
---

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.

`ConfigureSSO` was previously the only consumer but since it hasn't been released GA yet, these changes won't break existing production clients
91 changes: 0 additions & 91 deletions packages/clerk-js/src/core/resources/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import { getFullName } from '@clerk/shared/internal/clerk-js/user';
import type {
BackupCodeJSON,
BackupCodeResource,
ClerkPaginatedResponse,
CreateEmailAddressParams,
CreateExternalAccountParams,
CreateOrganizationEnterpriseConnectionParams,
CreatePhoneNumberParams,
CreateWeb3WalletParams,
DeletedObjectJSON,
Expand All @@ -14,15 +12,9 @@ import type {
EnterpriseAccountResource,
EnterpriseConnectionJSON,
EnterpriseConnectionResource,
EnterpriseConnectionTestRunInitJSON,
EnterpriseConnectionTestRunInitResource,
EnterpriseConnectionTestRunJSON,
EnterpriseConnectionTestRunResource,
EnterpriseConnectionTestRunsPaginatedJSON,
ExternalAccountJSON,
ExternalAccountResource,
GetEnterpriseConnectionsParams,
GetEnterpriseConnectionTestRunsParams,
GetOrganizationMemberships,
GetUserOrganizationInvitationsParams,
GetUserOrganizationSuggestionsParams,
Expand All @@ -34,7 +26,6 @@ import type {
SetProfileImageParams,
TOTPJSON,
TOTPResource,
UpdateOrganizationEnterpriseConnectionParams,
UpdateUserMetadataParams,
UpdateUserParams,
UpdateUserPasswordParams,
Expand All @@ -45,9 +36,7 @@ import type {
Web3WalletResource,
} from '@clerk/shared/types';

import { convertPageToOffsetSearchParams } from '../../utils/convertPageToOffsetSearchParams';
import { unixEpochToDate } from '../../utils/date';
import { toEnterpriseConnectionBody } from '../../utils/enterpriseConnection';
import { normalizeUnsafeMetadata } from '../../utils/resourceParams';
import { eventBus, events } from '../events';
import { addPaymentMethod, getPaymentMethods, initializePaymentMethod } from '../modules/billing';
Expand All @@ -58,7 +47,6 @@ import {
EmailAddress,
EnterpriseAccount,
EnterpriseConnection,
EnterpriseConnectionTestRun,
ExternalAccount,
Image,
OrganizationMembership,
Expand Down Expand Up @@ -336,85 +324,6 @@ export class User extends BaseResource implements UserResource {
return (json || []).map(connection => new EnterpriseConnection(connection));
};

createEnterpriseConnection = async (
params: CreateOrganizationEnterpriseConnectionParams,
): Promise<EnterpriseConnectionResource> => {
const json = (
await BaseResource._fetch<EnterpriseConnectionJSON>({
path: `${this.path()}/enterprise_connections`,
method: 'POST',
body: toEnterpriseConnectionBody(params) as any,
})
)?.response as unknown as EnterpriseConnectionJSON;

return new EnterpriseConnection(json);
};

updateEnterpriseConnection = async (
enterpriseConnectionId: string,
params: UpdateOrganizationEnterpriseConnectionParams,
): Promise<EnterpriseConnectionResource> => {
const json = (
await BaseResource._fetch<EnterpriseConnectionJSON>({
path: `${this.path()}/enterprise_connections/${enterpriseConnectionId}`,
method: 'PATCH',
body: toEnterpriseConnectionBody(params) as any,
})
)?.response as unknown as EnterpriseConnectionJSON;

return new EnterpriseConnection(json);
};

deleteEnterpriseConnection = async (enterpriseConnectionId: string): Promise<DeletedObjectResource> => {
const json = (
await BaseResource._fetch<DeletedObjectJSON>({
path: `${this.path()}/enterprise_connections/${enterpriseConnectionId}`,
method: 'DELETE',
})
)?.response as unknown as DeletedObjectJSON;

return new DeletedObject(json);
};

createEnterpriseConnectionTestRun = async (
enterpriseConnectionId: string,
): Promise<EnterpriseConnectionTestRunInitResource> => {
const json = (
await BaseResource._fetch({
path: `${this.path()}/enterprise_connections/${enterpriseConnectionId}/test_runs`,
method: 'POST',
})
)?.response as unknown as EnterpriseConnectionTestRunInitJSON;

return { url: json.url };
};

getEnterpriseConnectionTestRuns = async (
enterpriseConnectionId: string,
params?: GetEnterpriseConnectionTestRunsParams,
): Promise<ClerkPaginatedResponse<EnterpriseConnectionTestRunResource>> => {
const { status, ...rest } = params || {};
const search = convertPageToOffsetSearchParams(rest);
if (status?.length) {
for (const s of status) {
search.append('status', s);
}
}

const res = await BaseResource._fetch({
path: `${this.path()}/enterprise_connections/${enterpriseConnectionId}/test_runs`,
method: 'GET',
search,
});

const payload = res?.response as unknown as EnterpriseConnectionTestRunsPaginatedJSON | undefined;

return {
total_count: payload?.total_count ?? 0,
data: (payload?.data ?? []).map((row: EnterpriseConnectionTestRunJSON) => new EnterpriseConnectionTestRun(row)),
};
};

initializePaymentMethod: typeof initializePaymentMethod = params => {
return initializePaymentMethod(params);
};
Expand Down
Loading
Loading