@bpinternal/billing-ui 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +46 -5
- package/dist/index.js +4295 -3983
- package/dist/index.umd.cjs +1 -1
- package/dist/style.css +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -166,7 +166,7 @@ export declare type BillingAnalyticsClient = {
|
|
|
166
166
|
};
|
|
167
167
|
|
|
168
168
|
export declare type BillingChangeEvent = {
|
|
169
|
-
type: 'subscription' | 'addons' | 'payment-method' | 'billing-address' | 'auto-recharge';
|
|
169
|
+
type: 'subscription' | 'addons' | 'payment-method' | 'billing-address' | 'auto-recharge' | 'pending-upgrade';
|
|
170
170
|
};
|
|
171
171
|
|
|
172
172
|
/**
|
|
@@ -178,7 +178,7 @@ export declare type BillingChangeEvent = {
|
|
|
178
178
|
* this interface over your own backend proxy (e.g. tRPC) — the shapes are the
|
|
179
179
|
* official wire shapes, the transport is yours.
|
|
180
180
|
*/
|
|
181
|
-
export declare type BillingClient = Pick<billing.Client, 'listPlans' | 'listAddons' | 'getSubscription' | 'previewSubscriptionUpdate' | 'setPlan' | 'setAddons' | 'getPaymentMethod' | 'createPaymentMethodIntent' | 'setPaymentMethod' | 'getCustomer' | 'setCustomer' | 'listInvoices' | 'getBillingReadonly' | 'getWorkspaceUsages' | 'getAutoRechargeSettings' | 'setAutoRechargeSettings'> &
|
|
181
|
+
export declare type BillingClient = Pick<billing.Client, 'listPlans' | 'listAddons' | 'getSubscription' | 'previewSubscriptionUpdate' | 'setPlan' | 'setAddons' | 'getPaymentMethod' | 'createPaymentMethodIntent' | 'setPaymentMethod' | 'getCustomer' | 'setCustomer' | 'listInvoices' | 'getBillingReadonly' | 'getWorkspaceUsages' | 'getAutoRechargeSettings' | 'setAutoRechargeSettings' | 'payInvoice' | 'cancelPendingSubscriptionUpgrade'> &
|
|
182
182
|
/**
|
|
183
183
|
* `getWorkspaceMember` lives on the generic `@botpress/client`, not the
|
|
184
184
|
* billing client, but is REQUIRED here: `useIsAuthorized` depends on it to
|
|
@@ -442,6 +442,8 @@ export declare function formatCurrency(amount: number, currency?: string, decima
|
|
|
442
442
|
|
|
443
443
|
export declare function formatDate(iso: string, locale?: string): string;
|
|
444
444
|
|
|
445
|
+
export declare function formatDateTime(iso: string, locale?: string): string;
|
|
446
|
+
|
|
445
447
|
export declare function formatQuantity(n: number, locale?: string): string;
|
|
446
448
|
|
|
447
449
|
export declare function formatUsage(value: number, unit: UsageUnit): string;
|
|
@@ -587,6 +589,8 @@ export declare type OutgrowFreeDialogProps = {
|
|
|
587
589
|
|
|
588
590
|
export declare const PaintIcon: ({ size, ...props }: IconProps) => JSX.Element;
|
|
589
591
|
|
|
592
|
+
export declare type PayInvoiceResult = Awaited<ReturnType<BillingClient['payInvoice']>>;
|
|
593
|
+
|
|
590
594
|
export declare type PaymentMethod = NonNullable<Awaited<ReturnType<BillingClient['getPaymentMethod']>>['paymentMethod']>;
|
|
591
595
|
|
|
592
596
|
export declare type PaymentMethodCard = NonNullable<PaymentMethod['card']>;
|
|
@@ -606,6 +610,32 @@ export declare type PaymentMethodDialogProps = {
|
|
|
606
610
|
onSuccess?: () => void;
|
|
607
611
|
};
|
|
608
612
|
|
|
613
|
+
/** A plan/addon change awaiting payment confirmation. */
|
|
614
|
+
export declare type PendingUpgrade = NonNullable<Subscription['pendingUpgrade']>;
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* Full-width alert shown when the subscription has a plan/add-on change awaiting
|
|
618
|
+
* payment confirmation (`subscription.pendingUpgrade`). Clicking it opens
|
|
619
|
+
* `PendingUpgradeDialog` (or `onManage`, when the host wants to own that flow).
|
|
620
|
+
* Renders nothing without a pending upgrade — safe to mount unconditionally.
|
|
621
|
+
*/
|
|
622
|
+
export declare const PendingUpgradeBanner: ({ onManage, className }: PendingUpgradeBannerProps) => JSX.Element | null;
|
|
623
|
+
|
|
624
|
+
export declare type PendingUpgradeBannerProps = {
|
|
625
|
+
/** Opens a host-owned pending-upgrade view instead of the library's own dialog. */
|
|
626
|
+
onManage?: () => void;
|
|
627
|
+
className?: string;
|
|
628
|
+
};
|
|
629
|
+
|
|
630
|
+
/** Standalone dialog around `PendingUpgradeContent` — opened from `PendingUpgradeBanner`. */
|
|
631
|
+
export declare const PendingUpgradeDialog: ({ open, onOpenChange, onSuccess }: PendingUpgradeDialogProps) => JSX.Element | null;
|
|
632
|
+
|
|
633
|
+
export declare type PendingUpgradeDialogProps = {
|
|
634
|
+
open: boolean;
|
|
635
|
+
onOpenChange: (open: boolean) => void;
|
|
636
|
+
onSuccess?: () => void;
|
|
637
|
+
};
|
|
638
|
+
|
|
609
639
|
export declare type Plan = Awaited<ReturnType<BillingClient['listPlans']>>[number];
|
|
610
640
|
|
|
611
641
|
/** Maps an English feature ID to its i18n label and tooltip description keys. */
|
|
@@ -1102,12 +1132,18 @@ export declare function useBillingReadonly(options?: QueryOptions): UseQueryResu
|
|
|
1102
1132
|
addonsReadonly: boolean;
|
|
1103
1133
|
}, Error>;
|
|
1104
1134
|
|
|
1135
|
+
/** Cancels a pending upgrade (the plan/add-on change and its unpaid invoice), reverting to the current subscription. */
|
|
1136
|
+
export declare function useCancelPendingSubscriptionUpgrade(): UseMutationResult<void, Error, void>;
|
|
1137
|
+
|
|
1105
1138
|
export declare function useCreatePaymentMethodIntent(): UseMutationResult<{
|
|
1106
1139
|
clientSecret: string;
|
|
1107
1140
|
}, Error, void>;
|
|
1108
1141
|
|
|
1109
1142
|
export declare function useCustomer(options?: QueryOptions): UseQueryResult<Customer, Error>;
|
|
1110
1143
|
|
|
1144
|
+
/** Whether the subscription has a plan/add-on change awaiting payment confirmation. */
|
|
1145
|
+
export declare function useHasPendingUpgrade(options?: QueryOptions): boolean;
|
|
1146
|
+
|
|
1111
1147
|
export declare function useInvoices(options?: QueryOptions): UseQueryResult<{
|
|
1112
1148
|
invoices: Invoice[];
|
|
1113
1149
|
meta: {
|
|
@@ -1118,6 +1154,11 @@ export declare function useInvoices(options?: QueryOptions): UseQueryResult<{
|
|
|
1118
1154
|
/** Whether the caller's role (via `getWorkspaceMember`) has `workspace.manageBilling`. */
|
|
1119
1155
|
export declare function useIsAuthorized(options?: QueryOptions): UseQueryResult<boolean, Error>;
|
|
1120
1156
|
|
|
1157
|
+
/** Pays the invoice tied to a pending upgrade, confirming the plan/add-on change. */
|
|
1158
|
+
export declare function usePayInvoice(): UseMutationResult<PayInvoiceResult, Error, {
|
|
1159
|
+
invoiceId: string;
|
|
1160
|
+
}>;
|
|
1161
|
+
|
|
1121
1162
|
export declare function usePaymentMethod(options?: QueryOptions): UseQueryResult<{
|
|
1122
1163
|
paymentMethod: PaymentMethod | null;
|
|
1123
1164
|
}, Error>;
|
|
@@ -1127,7 +1168,7 @@ export declare function usePlans(): UseQueryResult<Plan[], Error>;
|
|
|
1127
1168
|
export declare const UsersIcon: ({ size, ...props }: IconProps) => JSX.Element;
|
|
1128
1169
|
|
|
1129
1170
|
/** Absolute add-on quantities for the current subscription (0 removes an add-on). */
|
|
1130
|
-
export declare function useSetAddons(): UseMutationResult<
|
|
1171
|
+
export declare function useSetAddons(): UseMutationResult<Subscription, Error, {
|
|
1131
1172
|
addons: Record<string, number>;
|
|
1132
1173
|
couponCode?: string;
|
|
1133
1174
|
}>;
|
|
@@ -1140,8 +1181,8 @@ export declare function useSetPaymentMethod(): UseMutationResult<PaymentMethod,
|
|
|
1140
1181
|
paymentMethodId: string;
|
|
1141
1182
|
}>;
|
|
1142
1183
|
|
|
1143
|
-
/** Commits the plan
|
|
1144
|
-
export declare function useSetSubscription(): UseMutationResult<
|
|
1184
|
+
/** Commits the plan and add-ons. A failed charge returns `pendingUpgrade` instead of throwing. */
|
|
1185
|
+
export declare function useSetSubscription(): UseMutationResult<Subscription, Error, SetSubscriptionInput>;
|
|
1145
1186
|
|
|
1146
1187
|
export declare function useSubscription(options?: QueryOptions): UseQueryResult<Subscription, Error>;
|
|
1147
1188
|
|