Skip to content

Commit b8fbadd

Browse files
chore(backend): Make SubscriptionItem's plan and planId nullable (#6839)
Co-authored-by: panteliselef <[email protected]>
1 parent ce525fa commit b8fbadd

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

.changeset/silly-rooms-sleep.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/backend': minor
3+
---
4+
5+
[Billing Beta] Update subscription item `plan` and `planId` properties to be `null`.

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ export class BillingSubscriptionItem {
4646
/**
4747
* The plan associated with this subscription item.
4848
*/
49-
readonly plan: BillingPlan,
49+
readonly plan: BillingPlan | null,
5050
/**
5151
* The plan ID.
5252
*/
53-
readonly planId: string,
53+
readonly planId: string | null,
5454
/**
5555
* Unix timestamp (milliseconds) of when the subscription item was created.
5656
*/
@@ -112,8 +112,8 @@ export class BillingSubscriptionItem {
112112
data.period_start,
113113
data.next_payment,
114114
formatAmountJSON(data.amount),
115-
BillingPlan.fromJSON(data.plan),
116-
data.plan_id,
115+
data.plan ? BillingPlan.fromJSON(data.plan) : null,
116+
data.plan_id ?? null,
117117
data.created_at,
118118
data.updated_at,
119119
data.period_end,

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -880,8 +880,8 @@ export interface BillingSubscriptionItemJSON extends ClerkResourceJSON {
880880
date: number;
881881
} | null;
882882
amount: BillingMoneyAmountJSON | null;
883-
plan: BillingPlanJSON;
884-
plan_id: string;
883+
plan?: BillingPlanJSON | null;
884+
plan_id?: string | null;
885885
}
886886

887887
/**
@@ -906,7 +906,7 @@ export interface BillingSubscriptionItemWebhookEventJSON extends ClerkResourceJS
906906
next_payment_amount: number;
907907
next_payment_date: number;
908908
amount: BillingMoneyAmountJSON;
909-
plan: {
909+
plan?: {
910910
id: string;
911911
instance_id: string;
912912
product_id: string;
@@ -922,8 +922,8 @@ export interface BillingSubscriptionItemWebhookEventJSON extends ClerkResourceJS
922922
currency: string;
923923
annual_monthly_amount: number;
924924
publicly_visible: boolean;
925-
};
926-
plan_id: string;
925+
} | null;
926+
plan_id?: string | null;
927927
}
928928

929929
/**

0 commit comments

Comments
 (0)