@bpinternal/billing-ui 0.17.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 +72 -19
- package/dist/index.js +4975 -4652
- package/dist/index.umd.cjs +1 -1
- package/dist/style.css +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -53,7 +53,7 @@ export declare function addonPrice(addon: Addon, plan: Plan, interval: BillingIn
|
|
|
53
53
|
* Clickable summary of active add-ons (current quantities from the live
|
|
54
54
|
* subscription). Acts as a preview button that opens add-on management.
|
|
55
55
|
*/
|
|
56
|
-
export declare const AddonsSummaryCard: ({ onManage, className }: AddonsSummaryCardProps) => JSX.Element;
|
|
56
|
+
export declare const AddonsSummaryCard: ({ onManage, className }: AddonsSummaryCardProps) => JSX.Element | null;
|
|
57
57
|
|
|
58
58
|
export declare type AddonsSummaryCardProps = {
|
|
59
59
|
/** Opens the manage-add-ons dialog. */
|
|
@@ -65,7 +65,7 @@ export declare const AgentsIcon: ({ size, ...props }: IconProps) => JSX.Element;
|
|
|
65
65
|
|
|
66
66
|
export declare const ArrowRightIcon: ({ size, ...props }: IconProps) => JSX.Element;
|
|
67
67
|
|
|
68
|
-
export declare const AutoRechargeDialog: ({ open, onOpenChange, onSuccess, onUpgrade }: AutoRechargeDialogProps) => JSX.Element;
|
|
68
|
+
export declare const AutoRechargeDialog: ({ open, onOpenChange, onSuccess, onUpgrade }: AutoRechargeDialogProps) => JSX.Element | null;
|
|
69
69
|
|
|
70
70
|
export declare type AutoRechargeDialogProps = {
|
|
71
71
|
open: boolean;
|
|
@@ -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,12 +178,19 @@ 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
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
183
|
+
* `getWorkspaceMember` lives on the generic `@botpress/client`, not the
|
|
184
|
+
* billing client, but is REQUIRED here: `useIsAuthorized` depends on it to
|
|
185
|
+
* check the caller's workspace membership. Every host must pass a client
|
|
186
|
+
* object that also exposes it. Still type-only — no runtime dep.
|
|
187
|
+
*/
|
|
188
|
+
Pick<Client, 'getWorkspaceMember'> &
|
|
189
|
+
/**
|
|
190
|
+
* Per-bot usage breakdown is OPTIONAL: those methods also live on the
|
|
191
|
+
* generic `@botpress/client`, but only a host that wants the per-bot view
|
|
192
|
+
* needs to pass a client exposing them. Omit them and the UsageDashboard
|
|
193
|
+
* hides the per-bot section.
|
|
187
194
|
*/
|
|
188
195
|
Partial<Pick<Client, 'breakDownWorkspaceUsageByBot' | 'listBots'>>;
|
|
189
196
|
|
|
@@ -227,6 +234,7 @@ export declare const billingKeys: {
|
|
|
227
234
|
customer: (scope: string) => readonly ["bpb", string, "customer"];
|
|
228
235
|
invoices: (scope: string) => readonly ["bpb", string, "invoices"];
|
|
229
236
|
readonly: (scope: string) => readonly ["bpb", string, "billing-readonly"];
|
|
237
|
+
isAuthorized: (scope: string) => readonly ["bpb", string, "is-authorized"];
|
|
230
238
|
autoRecharge: (scope: string) => readonly ["bpb", string, "auto-recharge"];
|
|
231
239
|
usages: (scope: string, period: string) => readonly ["bpb", string, "usages", string];
|
|
232
240
|
bots: (scope: string) => readonly ["bpb", string, "bots"];
|
|
@@ -338,7 +346,7 @@ export declare const CheckIcon: ({ size, ...props }: IconProps) => JSX.Element;
|
|
|
338
346
|
* the subscribe button share the same Stripe context. The SetupIntent itself is only
|
|
339
347
|
* requested from CheckoutBody at Subscribe time, not eagerly on open.
|
|
340
348
|
*/
|
|
341
|
-
export declare const CheckoutDialog: ({ open, onOpenChange, planId, interval, onBack, onSuccess }: CheckoutDialogProps) => JSX.Element;
|
|
349
|
+
export declare const CheckoutDialog: ({ open, onOpenChange, planId, interval, onBack, onSuccess }: CheckoutDialogProps) => JSX.Element | null;
|
|
342
350
|
|
|
343
351
|
export declare type CheckoutDialogProps = {
|
|
344
352
|
open: boolean;
|
|
@@ -434,6 +442,8 @@ export declare function formatCurrency(amount: number, currency?: string, decima
|
|
|
434
442
|
|
|
435
443
|
export declare function formatDate(iso: string, locale?: string): string;
|
|
436
444
|
|
|
445
|
+
export declare function formatDateTime(iso: string, locale?: string): string;
|
|
446
|
+
|
|
437
447
|
export declare function formatQuantity(n: number, locale?: string): string;
|
|
438
448
|
|
|
439
449
|
export declare function formatUsage(value: number, unit: UsageUnit): string;
|
|
@@ -488,7 +498,7 @@ export declare type Invoice = Awaited<ReturnType<BillingClient['listInvoices']>>
|
|
|
488
498
|
* Read-only billing history. Lists invoices newest-first with status, amount,
|
|
489
499
|
* period, and a PDF download when Stripe provides one.
|
|
490
500
|
*/
|
|
491
|
-
export declare const InvoicesDialog: ({ open, onOpenChange }: InvoicesDialogProps) => JSX.Element;
|
|
501
|
+
export declare const InvoicesDialog: ({ open, onOpenChange }: InvoicesDialogProps) => JSX.Element | null;
|
|
492
502
|
|
|
493
503
|
export declare type InvoicesDialogProps = {
|
|
494
504
|
open: boolean;
|
|
@@ -516,7 +526,7 @@ export declare const LockIcon: ({ size, ...props }: IconProps) => JSX.Element;
|
|
|
516
526
|
* first), totals computed client-side, committed as absolute quantities via
|
|
517
527
|
* setAddons — 0 removes an add-on. No plan change involved.
|
|
518
528
|
*/
|
|
519
|
-
export declare const ManageAddonsDialog: ({ open, onOpenChange, onSuccess, onUpgrade }: ManageAddonsDialogProps) => JSX.Element;
|
|
529
|
+
export declare const ManageAddonsDialog: ({ open, onOpenChange, onSuccess, onUpgrade }: ManageAddonsDialogProps) => JSX.Element | null;
|
|
520
530
|
|
|
521
531
|
export declare type ManageAddonsDialogProps = {
|
|
522
532
|
open: boolean;
|
|
@@ -579,6 +589,8 @@ export declare type OutgrowFreeDialogProps = {
|
|
|
579
589
|
|
|
580
590
|
export declare const PaintIcon: ({ size, ...props }: IconProps) => JSX.Element;
|
|
581
591
|
|
|
592
|
+
export declare type PayInvoiceResult = Awaited<ReturnType<BillingClient['payInvoice']>>;
|
|
593
|
+
|
|
582
594
|
export declare type PaymentMethod = NonNullable<Awaited<ReturnType<BillingClient['getPaymentMethod']>>['paymentMethod']>;
|
|
583
595
|
|
|
584
596
|
export declare type PaymentMethodCard = NonNullable<PaymentMethod['card']>;
|
|
@@ -590,7 +602,7 @@ export declare type PaymentMethodCard = NonNullable<PaymentMethod['card']>;
|
|
|
590
602
|
* confirmCardSetup (no address required), then persisted; address is saved
|
|
591
603
|
* independently — matching Desk's separation.
|
|
592
604
|
*/
|
|
593
|
-
export declare const PaymentMethodDialog: ({ open, onOpenChange, onSuccess }: PaymentMethodDialogProps) => JSX.Element;
|
|
605
|
+
export declare const PaymentMethodDialog: ({ open, onOpenChange, onSuccess }: PaymentMethodDialogProps) => JSX.Element | null;
|
|
594
606
|
|
|
595
607
|
export declare type PaymentMethodDialogProps = {
|
|
596
608
|
open: boolean;
|
|
@@ -598,6 +610,32 @@ export declare type PaymentMethodDialogProps = {
|
|
|
598
610
|
onSuccess?: () => void;
|
|
599
611
|
};
|
|
600
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
|
+
|
|
601
639
|
export declare type Plan = Awaited<ReturnType<BillingClient['listPlans']>>[number];
|
|
602
640
|
|
|
603
641
|
/** Maps an English feature ID to its i18n label and tooltip description keys. */
|
|
@@ -725,7 +763,7 @@ export declare const PLAN_ORDER: PlanKind[];
|
|
|
725
763
|
* renews (paid, self-serve plans only), plus a manage CTA. On legacy billing
|
|
726
764
|
* it deep-links to the Dashboard.
|
|
727
765
|
*/
|
|
728
|
-
export declare const PlanBanner: ({ onManage, className }: PlanBannerProps) => JSX.Element;
|
|
766
|
+
export declare const PlanBanner: ({ onManage, className }: PlanBannerProps) => JSX.Element | null;
|
|
729
767
|
|
|
730
768
|
export declare type PlanBannerProps = {
|
|
731
769
|
/** Opens the plan picker / checkout. */
|
|
@@ -758,7 +796,7 @@ export declare function planKind(plan: Pick<Plan, 'name' | 'metadata'>): PlanKin
|
|
|
758
796
|
* Clickable summary of the current plan — name, interval, price, conversation
|
|
759
797
|
* allowance. Acts as a preview button that opens the plan-management flow.
|
|
760
798
|
*/
|
|
761
|
-
export declare const PlanSummaryCard: ({ onManage, className }: PlanSummaryCardProps) => JSX.Element;
|
|
799
|
+
export declare const PlanSummaryCard: ({ onManage, className }: PlanSummaryCardProps) => JSX.Element | null;
|
|
762
800
|
|
|
763
801
|
export declare type PlanSummaryCardProps = {
|
|
764
802
|
/** Opens the plan picker / checkout. */
|
|
@@ -905,7 +943,7 @@ export declare type TaxId = Customer['taxIds'][number];
|
|
|
905
943
|
|
|
906
944
|
export declare function toStripeLocale(locale: string): string;
|
|
907
945
|
|
|
908
|
-
export declare const UpgradePlanDialog: ({ open, onOpenChange, onSelectPlan, recommendedPlanId, defaultInterval, excludePlanIds, planFeatures, featureDescriptions, }: UpgradePlanDialogProps) => JSX.Element;
|
|
946
|
+
export declare const UpgradePlanDialog: ({ open, onOpenChange, onSelectPlan, recommendedPlanId, defaultInterval, excludePlanIds, planFeatures, featureDescriptions, }: UpgradePlanDialogProps) => JSX.Element | null;
|
|
909
947
|
|
|
910
948
|
export declare type UpgradePlanDialogProps = {
|
|
911
949
|
open: boolean;
|
|
@@ -1094,12 +1132,18 @@ export declare function useBillingReadonly(options?: QueryOptions): UseQueryResu
|
|
|
1094
1132
|
addonsReadonly: boolean;
|
|
1095
1133
|
}, Error>;
|
|
1096
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
|
+
|
|
1097
1138
|
export declare function useCreatePaymentMethodIntent(): UseMutationResult<{
|
|
1098
1139
|
clientSecret: string;
|
|
1099
1140
|
}, Error, void>;
|
|
1100
1141
|
|
|
1101
1142
|
export declare function useCustomer(options?: QueryOptions): UseQueryResult<Customer, Error>;
|
|
1102
1143
|
|
|
1144
|
+
/** Whether the subscription has a plan/add-on change awaiting payment confirmation. */
|
|
1145
|
+
export declare function useHasPendingUpgrade(options?: QueryOptions): boolean;
|
|
1146
|
+
|
|
1103
1147
|
export declare function useInvoices(options?: QueryOptions): UseQueryResult<{
|
|
1104
1148
|
invoices: Invoice[];
|
|
1105
1149
|
meta: {
|
|
@@ -1107,7 +1151,13 @@ export declare function useInvoices(options?: QueryOptions): UseQueryResult<{
|
|
|
1107
1151
|
};
|
|
1108
1152
|
}, Error>;
|
|
1109
1153
|
|
|
1110
|
-
|
|
1154
|
+
/** Whether the caller's role (via `getWorkspaceMember`) has `workspace.manageBilling`. */
|
|
1155
|
+
export declare function useIsAuthorized(options?: QueryOptions): UseQueryResult<boolean, Error>;
|
|
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
|
+
}>;
|
|
1111
1161
|
|
|
1112
1162
|
export declare function usePaymentMethod(options?: QueryOptions): UseQueryResult<{
|
|
1113
1163
|
paymentMethod: PaymentMethod | null;
|
|
@@ -1118,7 +1168,7 @@ export declare function usePlans(): UseQueryResult<Plan[], Error>;
|
|
|
1118
1168
|
export declare const UsersIcon: ({ size, ...props }: IconProps) => JSX.Element;
|
|
1119
1169
|
|
|
1120
1170
|
/** Absolute add-on quantities for the current subscription (0 removes an add-on). */
|
|
1121
|
-
export declare function useSetAddons(): UseMutationResult<
|
|
1171
|
+
export declare function useSetAddons(): UseMutationResult<Subscription, Error, {
|
|
1122
1172
|
addons: Record<string, number>;
|
|
1123
1173
|
couponCode?: string;
|
|
1124
1174
|
}>;
|
|
@@ -1131,8 +1181,8 @@ export declare function useSetPaymentMethod(): UseMutationResult<PaymentMethod,
|
|
|
1131
1181
|
paymentMethodId: string;
|
|
1132
1182
|
}>;
|
|
1133
1183
|
|
|
1134
|
-
/** Commits the plan
|
|
1135
|
-
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>;
|
|
1136
1186
|
|
|
1137
1187
|
export declare function useSubscription(options?: QueryOptions): UseQueryResult<Subscription, Error>;
|
|
1138
1188
|
|
|
@@ -1159,6 +1209,9 @@ export declare function useUsageByBot(type: string, options?: QueryOptions & {
|
|
|
1159
1209
|
period?: string;
|
|
1160
1210
|
}): UseQueryResult<BotUsageRow[], Error>;
|
|
1161
1211
|
|
|
1212
|
+
/** The caller's own workspace membership, as returned by `getWorkspaceMember`. */
|
|
1213
|
+
export declare type WorkspaceMember = Awaited<ReturnType<Client['getWorkspaceMember']>>;
|
|
1214
|
+
|
|
1162
1215
|
export declare type WorkspaceUsages = Awaited<ReturnType<BillingClient['getWorkspaceUsages']>>['quotas'];
|
|
1163
1216
|
|
|
1164
1217
|
export { }
|