Skip to content

Commit d6c7bbb

Browse files
chore(clerk-js,types): Replace commerce with billing in resources (#6757)
Co-authored-by: Alexis Aguilar <[email protected]>
1 parent 8d1514a commit d6c7bbb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+596
-594
lines changed

.changeset/yummy-snails-work.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@clerk/clerk-js': minor
3+
'@clerk/types': minor
4+
'@clerk/backend': patch
5+
'@clerk/shared': patch
6+
'@clerk/clerk-react': patch
7+
---
8+
9+
[Billing Beta] Rename types, interfaces and classes that contain `commerce` to use `billing` instead.

.typedoc/__tests__/__snapshots__/file-structure.test.ts.snap

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,41 @@ exports[`Typedoc output > should have a deliberate file structure 1`] = `
66
"types/act-jwt-claim.mdx",
77
"types/active-session-resource.mdx",
88
"types/add-payment-source-params.mdx",
9+
"types/billing-checkout-json.mdx",
10+
"types/billing-checkout-resource.mdx",
11+
"types/billing-checkout-totals-json.mdx",
12+
"types/billing-checkout-totals.mdx",
13+
"types/billing-initialized-payment-source-json.mdx",
14+
"types/billing-initialized-payment-source-resource.mdx",
15+
"types/billing-money-amount-json.mdx",
16+
"types/billing-money-amount.mdx",
17+
"types/billing-namespace.mdx",
18+
"types/billing-payer-json.mdx",
19+
"types/billing-payer-resource-type.mdx",
20+
"types/billing-payer-resource.mdx",
21+
"types/billing-payment-charge-type.mdx",
22+
"types/billing-payment-json.mdx",
23+
"types/billing-payment-resource.mdx",
24+
"types/billing-payment-source-json.mdx",
25+
"types/billing-payment-source-methods.mdx",
26+
"types/billing-payment-source-resource.mdx",
27+
"types/billing-payment-source-status.mdx",
28+
"types/billing-payment-status.mdx",
29+
"types/billing-plan-json.mdx",
30+
"types/billing-plan-resource.mdx",
31+
"types/billing-statement-group-json.mdx",
32+
"types/billing-statement-group.mdx",
33+
"types/billing-statement-json.mdx",
34+
"types/billing-statement-resource.mdx",
35+
"types/billing-statement-status.mdx",
36+
"types/billing-statement-totals-json.mdx",
37+
"types/billing-statement-totals.mdx",
38+
"types/billing-subscription-item-json.mdx",
39+
"types/billing-subscription-item-resource.mdx",
40+
"types/billing-subscription-json.mdx",
41+
"types/billing-subscription-plan-period.mdx",
42+
"types/billing-subscription-resource.mdx",
43+
"types/billing-subscription-status.mdx",
944
"types/cancel-subscription-params.mdx",
1045
"types/check-authorization-fn.mdx",
1146
"types/check-authorization-from-session-claims.mdx",
@@ -21,43 +56,6 @@ exports[`Typedoc output > should have a deliberate file structure 1`] = `
2156
"types/clerk-resource.mdx",
2257
"types/clerk-status.mdx",
2358
"types/clerk.mdx",
24-
"types/commerce-billing-namespace.mdx",
25-
"types/commerce-checkout-json.mdx",
26-
"types/commerce-checkout-resource.mdx",
27-
"types/commerce-checkout-totals-json.mdx",
28-
"types/commerce-checkout-totals.mdx",
29-
"types/commerce-feature-json.mdx",
30-
"types/commerce-feature-resource.mdx",
31-
"types/commerce-initialized-payment-source-json.mdx",
32-
"types/commerce-initialized-payment-source-resource.mdx",
33-
"types/commerce-money-amount-json.mdx",
34-
"types/commerce-money-amount.mdx",
35-
"types/commerce-payer-json.mdx",
36-
"types/commerce-payer-resource-type.mdx",
37-
"types/commerce-payer-resource.mdx",
38-
"types/commerce-payment-charge-type.mdx",
39-
"types/commerce-payment-json.mdx",
40-
"types/commerce-payment-resource.mdx",
41-
"types/commerce-payment-source-json.mdx",
42-
"types/commerce-payment-source-methods.mdx",
43-
"types/commerce-payment-source-resource.mdx",
44-
"types/commerce-payment-source-status.mdx",
45-
"types/commerce-payment-status.mdx",
46-
"types/commerce-plan-json.mdx",
47-
"types/commerce-plan-resource.mdx",
48-
"types/commerce-statement-group-json.mdx",
49-
"types/commerce-statement-group.mdx",
50-
"types/commerce-statement-json.mdx",
51-
"types/commerce-statement-resource.mdx",
52-
"types/commerce-statement-status.mdx",
53-
"types/commerce-statement-totals-json.mdx",
54-
"types/commerce-statement-totals.mdx",
55-
"types/commerce-subscription-item-json.mdx",
56-
"types/commerce-subscription-item-resource.mdx",
57-
"types/commerce-subscription-json.mdx",
58-
"types/commerce-subscription-plan-period.mdx",
59-
"types/commerce-subscription-resource.mdx",
60-
"types/commerce-subscription-status.mdx",
6159
"types/confirm-checkout-params.mdx",
6260
"types/create-checkout-params.mdx",
6361
"types/create-organization-params.mdx",
@@ -67,6 +65,8 @@ exports[`Typedoc output > should have a deliberate file structure 1`] = `
6765
"types/experimental_checkout-button-props.mdx",
6866
"types/experimental_plan-details-button-props.mdx",
6967
"types/experimental_subscription-details-button-props.mdx",
68+
"types/feature-json.mdx",
69+
"types/feature-resource.mdx",
7070
"types/field-error.mdx",
7171
"types/field-errors.mdx",
7272
"types/for-payer-type.mdx",

packages/backend/src/api/resources/CommercePlan.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { CommerceMoneyAmount } from '@clerk/types';
1+
import type { BillingMoneyAmount } from '@clerk/types';
22

33
import { Feature } from './Feature';
44
import type { CommercePlanJSON } from './JSON';
@@ -49,15 +49,15 @@ export class CommercePlan {
4949
/**
5050
* The monthly fee of the plan.
5151
*/
52-
readonly fee: CommerceMoneyAmount,
52+
readonly fee: BillingMoneyAmount,
5353
/**
5454
* The annual fee of the plan.
5555
*/
56-
readonly annualFee: CommerceMoneyAmount,
56+
readonly annualFee: BillingMoneyAmount,
5757
/**
5858
* The annual fee of the plan on a monthly basis.
5959
*/
60-
readonly annualMonthlyFee: CommerceMoneyAmount,
60+
readonly annualMonthlyFee: BillingMoneyAmount,
6161
/**
6262
* The type of payer for the plan.
6363
*/

packages/backend/src/api/resources/CommerceSubscription.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type CommerceMoneyAmount } from '@clerk/types';
1+
import { type BillingMoneyAmount } from '@clerk/types';
22

33
import { CommerceSubscriptionItem } from './CommerceSubscriptionItem';
44
import type { CommerceSubscriptionJSON } from './JSON';
@@ -45,7 +45,7 @@ export class CommerceSubscription {
4545
/**
4646
* Information about the next scheduled payment.
4747
*/
48-
readonly nextPayment: { date: number; amount: CommerceMoneyAmount } | null,
48+
readonly nextPayment: { date: number; amount: BillingMoneyAmount } | null,
4949
/**
5050
* Whether the payer is eligible for a free trial.
5151
*/

packages/backend/src/api/resources/CommerceSubscriptionItem.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { CommerceMoneyAmount, CommerceMoneyAmountJSON } from '@clerk/types';
1+
import type { BillingMoneyAmount, BillingMoneyAmountJSON } from '@clerk/types';
22

33
import { CommercePlan } from './CommercePlan';
44
import type { CommerceSubscriptionItemJSON } from './JSON';
@@ -42,7 +42,7 @@ export class CommerceSubscriptionItem {
4242
/**
4343
* The current amount for the subscription item.
4444
*/
45-
readonly amount: CommerceMoneyAmount | null | undefined,
45+
readonly amount: BillingMoneyAmount | null | undefined,
4646
/**
4747
* The plan associated with this subscription item.
4848
*/
@@ -86,13 +86,13 @@ export class CommerceSubscriptionItem {
8686
/**
8787
* The lifetime amount paid for this subscription item.
8888
*/
89-
readonly lifetimePaid?: CommerceMoneyAmount | null,
89+
readonly lifetimePaid?: BillingMoneyAmount | null,
9090
) {}
9191

9292
static fromJSON(data: CommerceSubscriptionItemJSON): CommerceSubscriptionItem {
9393
function formatAmountJSON(
94-
amount: CommerceMoneyAmountJSON | null | undefined,
95-
): CommerceMoneyAmount | null | undefined {
94+
amount: BillingMoneyAmountJSON | null | undefined,
95+
): BillingMoneyAmount | null | undefined {
9696
if (!amount) {
9797
return amount;
9898
}

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ import type {
3030
AuthenticateWithGoogleOneTapParams,
3131
AuthenticateWithMetamaskParams,
3232
AuthenticateWithOKXWalletParams,
33+
BillingNamespace,
3334
Clerk as ClerkInterface,
3435
ClerkAPIError,
3536
ClerkAuthenticateWithWeb3Params,
3637
ClerkOptions,
3738
ClientJSONSnapshot,
3839
ClientResource,
39-
CommerceBillingNamespace,
4040
CreateOrganizationParams,
4141
CreateOrganizationProps,
4242
CredentialReturn,
@@ -148,7 +148,7 @@ import { createFapiClient } from './fapiClient';
148148
import { createClientFromJwt } from './jwt-client';
149149
import { APIKeys } from './modules/apiKeys';
150150
import { createCheckoutInstance } from './modules/checkout/instance';
151-
import { CommerceBilling } from './modules/commerce';
151+
import { Billing } from './modules/commerce';
152152
import {
153153
BaseResource,
154154
Client,
@@ -206,7 +206,7 @@ export class Clerk implements ClerkInterface {
206206
version: __PKG_VERSION__,
207207
};
208208

209-
private static _billing: CommerceBillingNamespace;
209+
private static _billing: BillingNamespace;
210210
private static _apiKeys: APIKeysNamespace;
211211
private _checkout: ClerkInterface['__experimental_checkout'] | undefined;
212212

@@ -337,9 +337,9 @@ export class Clerk implements ClerkInterface {
337337
return this.#options.standardBrowser || false;
338338
}
339339

340-
get billing(): CommerceBillingNamespace {
340+
get billing(): BillingNamespace {
341341
if (!Clerk._billing) {
342-
Clerk._billing = new CommerceBilling();
342+
Clerk._billing = new Billing();
343343
}
344344
return Clerk._billing;
345345
}
@@ -625,7 +625,7 @@ export class Clerk implements ClerkInterface {
625625
this.assertComponentsReady(this.#componentControls);
626626
if (disabledAllBillingFeatures(this, this.environment)) {
627627
if (this.#instanceType === 'development') {
628-
throw new ClerkRuntimeError(warnings.cannotRenderAnyCommerceComponent('Checkout'), {
628+
throw new ClerkRuntimeError(warnings.cannotRenderAnyBillingComponent('Checkout'), {
629629
code: CANNOT_RENDER_BILLING_DISABLED_ERROR_CODE,
630630
});
631631
}
@@ -654,7 +654,7 @@ export class Clerk implements ClerkInterface {
654654
this.assertComponentsReady(this.#componentControls);
655655
if (disabledAllBillingFeatures(this, this.environment)) {
656656
if (this.#instanceType === 'development') {
657-
throw new ClerkRuntimeError(warnings.cannotRenderAnyCommerceComponent('PlanDetails'), {
657+
throw new ClerkRuntimeError(warnings.cannotRenderAnyBillingComponent('PlanDetails'), {
658658
code: CANNOT_RENDER_BILLING_DISABLED_ERROR_CODE,
659659
});
660660
}
@@ -1113,7 +1113,7 @@ export class Clerk implements ClerkInterface {
11131113
this.assertComponentsReady(this.#componentControls);
11141114
if (disabledAllBillingFeatures(this, this.environment)) {
11151115
if (this.#instanceType === 'development') {
1116-
throw new ClerkRuntimeError(warnings.cannotRenderAnyCommerceComponent('PricingTable'), {
1116+
throw new ClerkRuntimeError(warnings.cannotRenderAnyBillingComponent('PricingTable'), {
11171117
code: CANNOT_RENDER_BILLING_DISABLED_ERROR_CODE,
11181118
});
11191119
}

0 commit comments

Comments
 (0)