Skip to content

Commit ce525fa

Browse files
authored
refactor(clerk-js): Replace internal error module with shared/errors (#6841)
1 parent 0ccfd25 commit ce525fa

File tree

23 files changed

+67
-57
lines changed

23 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+
---

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,7 @@ package-lock.json
2020
pnpm-lock.yaml
2121
playground
2222
packages/backend/tests/**/*.js
23+
packages/clerk-js/src/core/resources/internal.ts
24+
packages/clerk-js/src/core/resources/index.ts
2325
/**/CHANGELOG.md
2426
renovate.json5

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { EmailLinkErrorCodeStatus } from '@clerk/shared/error';
12
import type {
23
ActiveSessionResource,
34
PendingSessionResource,
@@ -13,7 +14,7 @@ import type { DevBrowser } from '../auth/devBrowser';
1314
import { Clerk } from '../clerk';
1415
import { eventBus, events } from '../events';
1516
import type { DisplayConfig, Organization } from '../resources/internal';
16-
import { BaseResource, Client, EmailLinkErrorCodeStatus, Environment, SignIn, SignUp } from '../resources/internal';
17+
import { BaseResource, Client, Environment, SignIn, SignUp } from '../resources/internal';
1718
import { mockJwt } from '../test/fixtures';
1819

1920
const mockClientFetch = jest.fn();

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.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import { ClerkAPIResponseError } from '@clerk/shared/error';
12
import { beforeEach, describe, expect, it, type Mock, vi } from 'vitest';
23

34
import { FraudProtection } from './fraudProtection';
45
import type { Clerk, Client } from './resources/internal';
5-
import { ClerkAPIResponseError } from './resources/internal';
66

77
describe('FraudProtectionService', () => {
88
let sut: FraudProtection;

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.

0 commit comments

Comments
 (0)