@bpinternal/billing-ui 0.17.0 → 0.18.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
@@ -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;
@@ -180,10 +180,17 @@ export declare type BillingChangeEvent = {
180
180
  */
181
181
  export declare type BillingClient = Pick<billing.Client, 'listPlans' | 'listAddons' | 'getSubscription' | 'previewSubscriptionUpdate' | 'setPlan' | 'setAddons' | 'getPaymentMethod' | 'createPaymentMethodIntent' | 'setPaymentMethod' | 'getCustomer' | 'setCustomer' | 'listInvoices' | 'getBillingReadonly' | 'getWorkspaceUsages' | 'getAutoRechargeSettings' | 'setAutoRechargeSettings'> &
182
182
  /**
183
- * Per-bot usage breakdown is OPTIONAL: those methods live on the generic
184
- * `@botpress/client` (not the billing client), so a host that wants the per-bot
185
- * view passes a client object that also exposes them. Omit them and the
186
- * UsageDashboard hides the per-bot section. Still type-only — no runtime dep.
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;
@@ -488,7 +496,7 @@ export declare type Invoice = Awaited<ReturnType<BillingClient['listInvoices']>>
488
496
  * Read-only billing history. Lists invoices newest-first with status, amount,
489
497
  * period, and a PDF download when Stripe provides one.
490
498
  */
491
- export declare const InvoicesDialog: ({ open, onOpenChange }: InvoicesDialogProps) => JSX.Element;
499
+ export declare const InvoicesDialog: ({ open, onOpenChange }: InvoicesDialogProps) => JSX.Element | null;
492
500
 
493
501
  export declare type InvoicesDialogProps = {
494
502
  open: boolean;
@@ -516,7 +524,7 @@ export declare const LockIcon: ({ size, ...props }: IconProps) => JSX.Element;
516
524
  * first), totals computed client-side, committed as absolute quantities via
517
525
  * setAddons — 0 removes an add-on. No plan change involved.
518
526
  */
519
- export declare const ManageAddonsDialog: ({ open, onOpenChange, onSuccess, onUpgrade }: ManageAddonsDialogProps) => JSX.Element;
527
+ export declare const ManageAddonsDialog: ({ open, onOpenChange, onSuccess, onUpgrade }: ManageAddonsDialogProps) => JSX.Element | null;
520
528
 
521
529
  export declare type ManageAddonsDialogProps = {
522
530
  open: boolean;
@@ -590,7 +598,7 @@ export declare type PaymentMethodCard = NonNullable<PaymentMethod['card']>;
590
598
  * confirmCardSetup (no address required), then persisted; address is saved
591
599
  * independently — matching Desk's separation.
592
600
  */
593
- export declare const PaymentMethodDialog: ({ open, onOpenChange, onSuccess }: PaymentMethodDialogProps) => JSX.Element;
601
+ export declare const PaymentMethodDialog: ({ open, onOpenChange, onSuccess }: PaymentMethodDialogProps) => JSX.Element | null;
594
602
 
595
603
  export declare type PaymentMethodDialogProps = {
596
604
  open: boolean;
@@ -725,7 +733,7 @@ export declare const PLAN_ORDER: PlanKind[];
725
733
  * renews (paid, self-serve plans only), plus a manage CTA. On legacy billing
726
734
  * it deep-links to the Dashboard.
727
735
  */
728
- export declare const PlanBanner: ({ onManage, className }: PlanBannerProps) => JSX.Element;
736
+ export declare const PlanBanner: ({ onManage, className }: PlanBannerProps) => JSX.Element | null;
729
737
 
730
738
  export declare type PlanBannerProps = {
731
739
  /** Opens the plan picker / checkout. */
@@ -758,7 +766,7 @@ export declare function planKind(plan: Pick<Plan, 'name' | 'metadata'>): PlanKin
758
766
  * Clickable summary of the current plan — name, interval, price, conversation
759
767
  * allowance. Acts as a preview button that opens the plan-management flow.
760
768
  */
761
- export declare const PlanSummaryCard: ({ onManage, className }: PlanSummaryCardProps) => JSX.Element;
769
+ export declare const PlanSummaryCard: ({ onManage, className }: PlanSummaryCardProps) => JSX.Element | null;
762
770
 
763
771
  export declare type PlanSummaryCardProps = {
764
772
  /** Opens the plan picker / checkout. */
@@ -905,7 +913,7 @@ export declare type TaxId = Customer['taxIds'][number];
905
913
 
906
914
  export declare function toStripeLocale(locale: string): string;
907
915
 
908
- export declare const UpgradePlanDialog: ({ open, onOpenChange, onSelectPlan, recommendedPlanId, defaultInterval, excludePlanIds, planFeatures, featureDescriptions, }: UpgradePlanDialogProps) => JSX.Element;
916
+ export declare const UpgradePlanDialog: ({ open, onOpenChange, onSelectPlan, recommendedPlanId, defaultInterval, excludePlanIds, planFeatures, featureDescriptions, }: UpgradePlanDialogProps) => JSX.Element | null;
909
917
 
910
918
  export declare type UpgradePlanDialogProps = {
911
919
  open: boolean;
@@ -1107,7 +1115,8 @@ export declare function useInvoices(options?: QueryOptions): UseQueryResult<{
1107
1115
  };
1108
1116
  }, Error>;
1109
1117
 
1110
- export declare function useIsAuthorized(): boolean | Error | undefined;
1118
+ /** Whether the caller's role (via `getWorkspaceMember`) has `workspace.manageBilling`. */
1119
+ export declare function useIsAuthorized(options?: QueryOptions): UseQueryResult<boolean, Error>;
1111
1120
 
1112
1121
  export declare function usePaymentMethod(options?: QueryOptions): UseQueryResult<{
1113
1122
  paymentMethod: PaymentMethod | null;
@@ -1159,6 +1168,9 @@ export declare function useUsageByBot(type: string, options?: QueryOptions & {
1159
1168
  period?: string;
1160
1169
  }): UseQueryResult<BotUsageRow[], Error>;
1161
1170
 
1171
+ /** The caller's own workspace membership, as returned by `getWorkspaceMember`. */
1172
+ export declare type WorkspaceMember = Awaited<ReturnType<Client['getWorkspaceMember']>>;
1173
+
1162
1174
  export declare type WorkspaceUsages = Awaited<ReturnType<BillingClient['getWorkspaceUsages']>>['quotas'];
1163
1175
 
1164
1176
  export { }