11import type {
2- __experimental_CommerceBillingNamespace ,
3- __experimental_CommerceCheckoutJSON ,
4- __experimental_CommerceInvoiceJSON ,
5- __experimental_CommerceInvoiceResource ,
6- __experimental_CommercePlanResource ,
7- __experimental_CommerceProductJSON ,
8- __experimental_CommerceSubscriptionJSON ,
9- __experimental_CommerceSubscriptionResource ,
10- __experimental_CreateCheckoutParams ,
11- __experimental_GetInvoicesParams ,
12- __experimental_GetPlansParams ,
13- __experimental_GetSubscriptionsParams ,
142 ClerkPaginatedResponse ,
3+ CommerceBillingNamespace ,
4+ CommerceCheckoutJSON ,
5+ CommerceInvoiceJSON ,
6+ CommerceInvoiceResource ,
7+ CommercePlanResource ,
8+ CommerceProductJSON ,
9+ CommerceSubscriptionJSON ,
10+ CommerceSubscriptionResource ,
11+ CreateCheckoutParams ,
12+ GetInvoicesParams ,
13+ GetPlansParams ,
14+ GetSubscriptionsParams ,
1515} from '@clerk/types' ;
1616
1717import { convertPageToOffsetSearchParams } from '../../../utils/convertPageToOffsetSearchParams' ;
1818import {
19- __experimental_CommerceCheckout ,
20- __experimental_CommerceInvoice ,
21- __experimental_CommercePlan ,
22- __experimental_CommerceSubscription ,
2319 BaseResource ,
20+ CommerceCheckout ,
21+ CommerceInvoice ,
22+ CommercePlan ,
23+ CommerceSubscription ,
2424} from '../../resources/internal' ;
2525
26- export class __experimental_CommerceBilling implements __experimental_CommerceBillingNamespace {
27- getPlans = async ( params ?: __experimental_GetPlansParams ) : Promise < __experimental_CommercePlanResource [ ] > => {
26+ export class CommerceBilling implements CommerceBillingNamespace {
27+ getPlans = async ( params ?: GetPlansParams ) : Promise < CommercePlanResource [ ] > => {
2828 const { data : products } = ( await BaseResource . _fetch ( {
2929 path : `/commerce/products` ,
3030 method : 'GET' ,
3131 search : { payerType : params ?. subscriberType || '' } ,
32- } ) ) as unknown as ClerkPaginatedResponse < __experimental_CommerceProductJSON > ;
32+ } ) ) as unknown as ClerkPaginatedResponse < CommerceProductJSON > ;
3333
3434 const defaultProduct = products . find ( product => product . is_default ) ;
35- return defaultProduct ?. plans . map ( plan => new __experimental_CommercePlan ( plan ) ) || [ ] ;
35+ return defaultProduct ?. plans . map ( plan => new CommercePlan ( plan ) ) || [ ] ;
3636 } ;
3737
3838 getSubscriptions = async (
39- params : __experimental_GetSubscriptionsParams ,
40- ) : Promise < ClerkPaginatedResponse < __experimental_CommerceSubscriptionResource > > => {
39+ params : GetSubscriptionsParams ,
40+ ) : Promise < ClerkPaginatedResponse < CommerceSubscriptionResource > > => {
4141 const { orgId, ...rest } = params ;
4242
4343 return await BaseResource . _fetch ( {
@@ -46,45 +46,42 @@ export class __experimental_CommerceBilling implements __experimental_CommerceBi
4646 search : convertPageToOffsetSearchParams ( rest ) ,
4747 } ) . then ( res => {
4848 const { data : subscriptions , total_count } =
49- res ?. response as unknown as ClerkPaginatedResponse < __experimental_CommerceSubscriptionJSON > ;
49+ res ?. response as unknown as ClerkPaginatedResponse < CommerceSubscriptionJSON > ;
5050
5151 return {
5252 total_count,
53- data : subscriptions . map ( subscription => new __experimental_CommerceSubscription ( subscription ) ) ,
53+ data : subscriptions . map ( subscription => new CommerceSubscription ( subscription ) ) ,
5454 } ;
5555 } ) ;
5656 } ;
5757
58- getInvoices = async (
59- params : __experimental_GetInvoicesParams ,
60- ) : Promise < ClerkPaginatedResponse < __experimental_CommerceInvoiceResource > > => {
58+ getInvoices = async ( params : GetInvoicesParams ) : Promise < ClerkPaginatedResponse < CommerceInvoiceResource > > => {
6159 const { orgId, ...rest } = params ;
6260
6361 return await BaseResource . _fetch ( {
6462 path : orgId ? `/organizations/${ orgId } /commerce/invoices` : `/me/commerce/invoices` ,
6563 method : 'GET' ,
6664 search : convertPageToOffsetSearchParams ( rest ) ,
6765 } ) . then ( res => {
68- const { data : invoices , total_count } =
69- res ?. response as unknown as ClerkPaginatedResponse < __experimental_CommerceInvoiceJSON > ;
66+ const { data : invoices , total_count } = res ?. response as unknown as ClerkPaginatedResponse < CommerceInvoiceJSON > ;
7067
7168 return {
7269 total_count,
73- data : invoices . map ( invoice => new __experimental_CommerceInvoice ( invoice ) ) ,
70+ data : invoices . map ( invoice => new CommerceInvoice ( invoice ) ) ,
7471 } ;
7572 } ) ;
7673 } ;
7774
78- startCheckout = async ( params : __experimental_CreateCheckoutParams ) => {
75+ startCheckout = async ( params : CreateCheckoutParams ) => {
7976 const { orgId, ...rest } = params ;
8077 const json = (
81- await BaseResource . _fetch < __experimental_CommerceCheckoutJSON > ( {
78+ await BaseResource . _fetch < CommerceCheckoutJSON > ( {
8279 path : orgId ? `/organizations/${ orgId } /commerce/checkouts` : `/me/commerce/checkouts` ,
8380 method : 'POST' ,
8481 body : rest as any ,
8582 } )
86- ) ?. response as unknown as __experimental_CommerceCheckoutJSON ;
83+ ) ?. response as unknown as CommerceCheckoutJSON ;
8784
88- return new __experimental_CommerceCheckout ( json , orgId ) ;
85+ return new CommerceCheckout ( json , orgId ) ;
8986 } ;
9087}
0 commit comments