Skip to content

Commit a932bcc

Browse files
committed
refactor(clerk-js): Replace internal error module with shared/errors
1 parent 98fe792 commit a932bcc

File tree

14 files changed

+67
-57
lines changed

14 files changed

+67
-57
lines changed

.changeset/mighty-frogs-brake.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import { inBrowser as inClientSide, isValidBrowserOnline } from '@clerk/shared/browser';
22
import { clerkEvents, createClerkEventBus } from '@clerk/shared/clerkEventBus';
33
import { deprecated } from '@clerk/shared/deprecated';
4-
import { ClerkRuntimeError, EmailLinkErrorCodeStatus, is4xxError, isClerkAPIResponseError } from '@clerk/shared/error';
4+
import {
5+
ClerkRuntimeError,
6+
EmailLinkError,
7+
EmailLinkErrorCodeStatus,
8+
is4xxError,
9+
isClerkAPIResponseError,
10+
isClerkRuntimeError,
11+
} from '@clerk/shared/error';
512
import { parsePublishableKey } from '@clerk/shared/keys';
613
import { LocalStorageBroadcastChannel } from '@clerk/shared/localStorageBroadcastChannel';
714
import { logger } from '@clerk/shared/logger';
@@ -149,15 +156,7 @@ import { createClientFromJwt } from './jwt-client';
149156
import { APIKeys } from './modules/apiKeys';
150157
import { Billing } from './modules/billing';
151158
import { createCheckoutInstance } from './modules/checkout/instance';
152-
import {
153-
BaseResource,
154-
Client,
155-
EmailLinkError,
156-
Environment,
157-
isClerkRuntimeError,
158-
Organization,
159-
Waitlist,
160-
} from './resources/internal';
159+
import { BaseResource, Client, Environment, Organization, Waitlist } from './resources/internal';
161160
import { getTaskEndpoint, navigateIfTaskExists, warnMissingPendingTaskHandlers } from './sessionTasks';
162161
import { State } from './state';
163162
import { warnings } from './warnings';

packages/clerk-js/src/core/fraudProtection.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import { ClerkRuntimeError, isClerkAPIResponseError } from '@clerk/shared/error';
2+
13
import { CaptchaChallenge } from '../utils/captcha/CaptchaChallenge';
24
import type { Clerk } from './resources/internal';
3-
import { ClerkRuntimeError, Client, isClerkAPIResponseError } from './resources/internal';
5+
import { Client } from './resources/internal';
46

57
export class FraudProtection {
68
private static instance: FraudProtection;

packages/clerk-js/src/core/modules/apiKeys/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ClerkRuntimeError } from '@clerk/shared/error';
12
import type {
23
ApiKeyJSON,
34
APIKeyResource,
@@ -9,7 +10,7 @@ import type {
910

1011
import type { FapiRequestInit } from '@/core/fapiClient';
1112

12-
import { APIKey, BaseResource, ClerkRuntimeError } from '../../resources/internal';
13+
import { APIKey, BaseResource } from '../../resources/internal';
1314

1415
export class APIKeys implements APIKeysNamespace {
1516
/**

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { isValidBrowserOnline } from '@clerk/shared/browser';
2+
import { ClerkAPIResponseError, ClerkRuntimeError } from '@clerk/shared/error';
23
import { isProductionFromPublishableKey } from '@clerk/shared/keys';
34
import type { ClerkAPIErrorJSON, ClerkResourceJSON, ClerkResourceReloadParams, DeletedObjectJSON } from '@clerk/types';
45

56
import { clerkMissingFapiClientInResources } from '../errors';
67
import type { FapiClient, FapiRequestInit, FapiResponse, FapiResponseJSON, HTTPMethod } from '../fapiClient';
78
import { FraudProtection } from '../fraudProtection';
89
import type { Clerk } from './internal';
9-
import { ClerkAPIResponseError, ClerkRuntimeError, Client } from './internal';
10+
import { Client } from './internal';
1011

1112
export type BaseFetchOptions = ClerkResourceReloadParams & {
1213
forceUpdateClient?: boolean;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { isClerkAPIResponseError } from '@clerk/shared/error';
12
import { retry } from '@clerk/shared/retry';
23
import type {
34
BillingCheckoutJSON,
@@ -12,7 +13,7 @@ import { unixEpochToDate } from '@/utils/date';
1213

1314
import { billingTotalsFromJSON } from '../../utils';
1415
import { BillingPayer } from './BillingPayer';
15-
import { BaseResource, BillingPaymentSource, BillingPlan, isClerkAPIResponseError } from './internal';
16+
import { BaseResource, BillingPaymentSource, BillingPlan } from './internal';
1617

1718
export class BillingCheckout extends BaseResource implements BillingCheckoutResource {
1819
id!: string;

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

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isCaptchaError, isClerkAPIResponseError } from '@clerk/shared/error';
1+
import { ClerkRuntimeError, isCaptchaError, isClerkAPIResponseError } from '@clerk/shared/error';
22
import { Poller } from '@clerk/shared/poller';
33
import type {
44
AttemptEmailAddressVerificationParams,
@@ -63,7 +63,7 @@ import {
6363
clerkVerifyWeb3WalletCalledBeforeCreate,
6464
} from '../errors';
6565
import { eventBus } from '../events';
66-
import { BaseResource, ClerkRuntimeError, SignUpVerifications } from './internal';
66+
import { BaseResource, SignUpVerifications } from './internal';
6767

6868
declare global {
6969
interface Window {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ export * from './DeletedObject';
44
export * from './DisplayConfig';
55
export * from './EmailAddress';
66
export * from './Environment';
7-
export * from './Error';
87
export * from './ExternalAccount';
98
export * from './IdentificationLink';
109
export * from './Image';
@@ -17,5 +16,5 @@ export * from './SignUp';
1716
export * from './Token';
1817
export * from './User';
1918
export * from './Verification';
20-
export * from './Web3Wallet';
2119
export * from './Waitlist';
20+
export * from './Web3Wallet';
Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,44 @@
11
export type { Clerk } from '../clerk';
2-
export * from './Base';
3-
export * from './UserSettings';
4-
export * from './CommerceSettings';
2+
export * from './APIKey';
53
export * from './AuthConfig';
6-
export * from './Client';
4+
export * from './Base';
75
export * from './BillingCheckout';
8-
export * from './Feature';
9-
export * from './BillingStatement';
106
export * from './BillingPayment';
117
export * from './BillingPaymentSource';
128
export * from './BillingPlan';
9+
export * from './BillingStatement';
1310
export * from './BillingSubscription';
11+
export * from './Client';
12+
export * from './CommerceSettings';
1413
export * from './DeletedObject';
1514
export * from './DisplayConfig';
1615
export * from './EmailAddress';
16+
export * from './EnterpriseAccount';
1717
export * from './Environment';
18-
export * from './Error';
1918
export * from './ExternalAccount';
20-
export * from './EnterpriseAccount';
19+
export * from './Feature';
2120
export * from './IdentificationLink';
2221
export * from './Image';
23-
export * from './PhoneNumber';
2422
export * from './Organization';
2523
export * from './OrganizationDomain';
2624
export * from './OrganizationInvitation';
2725
export * from './OrganizationMembership';
2826
export * from './OrganizationMembershipRequest';
2927
export * from './OrganizationSuggestion';
30-
export * from './SamlAccount';
31-
export * from './Session';
3228
export * from './Passkey';
29+
export * from './PhoneNumber';
3330
export * from './PublicUserData';
31+
export * from './SamlAccount';
32+
export * from './Session';
3433
export * from './SessionWithActivities';
3534
export * from './SignIn';
36-
export * from './UserData';
3735
export * from './SignUp';
3836
export * from './Token';
3937
export * from './TOTP';
4038
export * from './User';
39+
export * from './UserData';
4140
export * from './UserOrganizationInvitation';
41+
export * from './UserSettings';
4242
export * from './Verification';
43-
export * from './Web3Wallet';
4443
export * from './Waitlist';
45-
export * from './APIKey';
44+
export * from './Web3Wallet';

0 commit comments

Comments
 (0)