@bpinternal/billing-ui 0.13.0 → 0.14.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 CHANGED
@@ -63,6 +63,38 @@ export declare type AddonsSummaryCardProps = {
63
63
 
64
64
  export declare const ArrowRightIcon: ({ size, ...props }: IconProps) => JSX.Element;
65
65
 
66
+ export declare const AutoRechargeDialog: ({ open, onOpenChange, onSuccess, onUpgrade }: AutoRechargeDialogProps) => JSX.Element;
67
+
68
+ export declare type AutoRechargeDialogProps = {
69
+ open: boolean;
70
+ onOpenChange: (open: boolean) => void;
71
+ onSuccess?: () => void;
72
+ onUpgrade?: () => void;
73
+ };
74
+
75
+ export declare type AutoRechargeSetting = AutoRechargeSettings[string];
76
+
77
+ /**
78
+ * Auto-recharge settings, keyed by feature (e.g. 'ai_spend' for the AI-spend
79
+ * credit wallet). `threshold`/`chunkSize`/`maxAmount` are nano-dollars
80
+ * (1e9 nano = $1) and must be multiples of $5 (5_000_000_000).
81
+ */
82
+ export declare type AutoRechargeSettings = Awaited<ReturnType<BillingClient['getAutoRechargeSettings']>>['settings'];
83
+
84
+ /**
85
+ * Clickable summary of auto-recharge for the AI-spend credit wallet (on/off,
86
+ * and the recharge amount + monthly limit when on). Acts as a preview button
87
+ * that opens `AutoRechargeDialog` — the settings themselves are edited there,
88
+ * not inline.
89
+ */
90
+ export declare const AutoRechargeSummaryCard: ({ onManage, className }: AutoRechargeSummaryCardProps) => JSX.Element | null;
91
+
92
+ export declare type AutoRechargeSummaryCardProps = {
93
+ /** Opens the auto-recharge management dialog. */
94
+ onManage: () => void;
95
+ className?: string;
96
+ };
97
+
66
98
  export declare const Badge: ({ variant, children, className }: BadgeProps) => JSX.Element;
67
99
 
68
100
  export declare type BadgeProps = {
@@ -89,6 +121,7 @@ export declare const BILLING_EVENTS: {
89
121
  readonly BILLING_ADDRESS_UPDATED: "billing_address_updated";
90
122
  readonly INVOICE_DOWNLOADED: "billing_invoice_downloaded";
91
123
  readonly UPGRADE_CTA_CLICKED: "billing_upgrade_cta_clicked";
124
+ readonly AUTO_RECHARGE_UPDATED: "billing_auto_recharge_updated";
92
125
  };
93
126
 
94
127
  export declare const BillingActionCard: ({ Icon, title, description, onClick, className }: BillingActionCardProps) => JSX.Element;
@@ -104,11 +137,11 @@ export declare type BillingActionCardProps = {
104
137
  };
105
138
 
106
139
  export declare type BillingAddress = {
107
- lineOne: string;
140
+ lineOne?: string;
108
141
  lineTwo?: string;
109
- city: string;
142
+ city?: string;
110
143
  state?: string;
111
- postalCode: string;
144
+ postalCode?: string;
112
145
  country: string;
113
146
  };
114
147
 
@@ -126,7 +159,7 @@ export declare type BillingAnalyticsClient = {
126
159
  };
127
160
 
128
161
  export declare type BillingChangeEvent = {
129
- type: 'subscription' | 'addons' | 'payment-method' | 'billing-address';
162
+ type: 'subscription' | 'addons' | 'payment-method' | 'billing-address' | 'auto-recharge';
130
163
  };
131
164
 
132
165
  /**
@@ -138,7 +171,7 @@ export declare type BillingChangeEvent = {
138
171
  * this interface over your own backend proxy (e.g. tRPC) — the shapes are the
139
172
  * official wire shapes, the transport is yours.
140
173
  */
141
- export declare type BillingClient = Pick<billing.Client, 'listPlans' | 'listAddons' | 'getSubscription' | 'previewSubscriptionUpdate' | 'setPlan' | 'setAddons' | 'getPaymentMethod' | 'createPaymentMethodIntent' | 'setPaymentMethod' | 'getCustomer' | 'setCustomer' | 'listInvoices' | 'getBillingReadonly' | 'getWorkspaceUsages'> &
174
+ export declare type BillingClient = Pick<billing.Client, 'listPlans' | 'listAddons' | 'getSubscription' | 'previewSubscriptionUpdate' | 'setPlan' | 'setAddons' | 'getPaymentMethod' | 'createPaymentMethodIntent' | 'setPaymentMethod' | 'getCustomer' | 'setCustomer' | 'listInvoices' | 'getBillingReadonly' | 'getWorkspaceUsages' | 'getAutoRechargeSettings' | 'setAutoRechargeSettings'> &
142
175
  /**
143
176
  * Per-bot usage breakdown is OPTIONAL: those methods live on the generic
144
177
  * `@botpress/client` (not the billing client), so a host that wants the per-bot
@@ -187,6 +220,7 @@ export declare const billingKeys: {
187
220
  customer: (scope: string) => readonly ["bpb", string, "customer"];
188
221
  invoices: (scope: string) => readonly ["bpb", string, "invoices"];
189
222
  readonly: (scope: string) => readonly ["bpb", string, "billing-readonly"];
223
+ autoRecharge: (scope: string) => readonly ["bpb", string, "auto-recharge"];
190
224
  usages: (scope: string, period: string) => readonly ["bpb", string, "usages", string];
191
225
  bots: (scope: string) => readonly ["bpb", string, "bots"];
192
226
  usageByBot: (scope: string, type: string, period: string) => readonly ["bpb", string, "usage-by-bot", string, string];
@@ -432,10 +466,11 @@ export declare type InfoTooltipProps = {
432
466
  };
433
467
 
434
468
  /** Floating-label input matching Stripe Elements' field look (grey fill, label inside). */
435
- export declare const Input: ({ label, className, id, ...props }: InputProps) => JSX.Element;
469
+ export declare const Input: ({ label, invalid, className, id, ...props }: InputProps) => JSX.Element;
436
470
 
437
471
  export declare type InputProps = InputHTMLAttributes<HTMLInputElement> & {
438
472
  label?: string;
473
+ invalid?: boolean;
439
474
  };
440
475
 
441
476
  export declare type Invoice = Awaited<ReturnType<BillingClient['listInvoices']>>['invoices'][number];
@@ -784,6 +819,10 @@ export declare type SelectProps = SelectHTMLAttributes<HTMLSelectElement> & {
784
819
  label?: string;
785
820
  };
786
821
 
822
+ export declare type SetAutoRechargeSettingsInput = {
823
+ settings: Record<string, AutoRechargeSetting>;
824
+ };
825
+
787
826
  declare type SetCustomerInput = {
788
827
  name?: string;
789
828
  address?: BillingAddress;
@@ -840,6 +879,16 @@ export declare type SubscriptionUpdate = {
840
879
 
841
880
  export { SupportedLocale }
842
881
 
882
+ export declare const Switch: ({ checked, onChange, disabled, className, ...aria }: SwitchProps) => JSX.Element;
883
+
884
+ export declare type SwitchProps = {
885
+ checked: boolean;
886
+ onChange: (checked: boolean) => void;
887
+ disabled?: boolean;
888
+ 'aria-label': string;
889
+ className?: string;
890
+ };
891
+
843
892
  export declare type TaxId = Customer['taxIds'][number];
844
893
 
845
894
  export declare function toStripeLocale(locale: string): string;
@@ -1022,6 +1071,9 @@ export declare type UsageUnit = 'count' | 'bytes' | 'nano-usd';
1022
1071
 
1023
1072
  export declare function useAddons(): UseQueryResult<Addon[], Error>;
1024
1073
 
1074
+ /** Auto-recharge settings, keyed by feature (e.g. 'ai_spend'). */
1075
+ export declare function useAutoRechargeSettings(options?: QueryOptions): UseQueryResult<AutoRechargeSettings, Error>;
1076
+
1025
1077
  export declare function useBilling(): BillingContextValue;
1026
1078
 
1027
1079
  /** Managed/enterprise locks — when planReadonly, plan changes go through sales. */
@@ -1057,6 +1109,8 @@ export declare function useSetAddons(): UseMutationResult<void, Error, {
1057
1109
  couponCode?: string;
1058
1110
  }>;
1059
1111
 
1112
+ export declare function useSetAutoRechargeSettings(): UseMutationResult<AutoRechargeSettings, Error, SetAutoRechargeSettingsInput>;
1113
+
1060
1114
  export declare function useSetCustomer(): UseMutationResult<Customer, Error, SetCustomerInput>;
1061
1115
 
1062
1116
  export declare function useSetPaymentMethod(): UseMutationResult<PaymentMethod, Error, {