@buildbase/sdk 0.0.44 → 0.0.46
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/README.md +290 -48
- package/dist/css/styles.css +1 -1
- package/dist/index.d.ts +330 -16
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/react/index.d.ts +930 -18
- package/dist/react/index.js +5 -5
- package/dist/react/index.mjs +5 -5
- package/package.json +1 -1
package/dist/react/index.d.ts
CHANGED
|
@@ -79,12 +79,14 @@ declare const InvoiceStatuses: {
|
|
|
79
79
|
readonly Uncollectible: "uncollectible";
|
|
80
80
|
readonly Void: "void";
|
|
81
81
|
};
|
|
82
|
+
type InvoiceStatusType = (typeof InvoiceStatuses)[keyof typeof InvoiceStatuses];
|
|
82
83
|
/** Subscription item type constants */
|
|
83
84
|
declare const SubscriptionItemType: {
|
|
84
85
|
readonly Feature: "feature";
|
|
85
86
|
readonly Limit: "limit";
|
|
86
87
|
readonly Quota: "quota";
|
|
87
88
|
};
|
|
89
|
+
type SubscriptionItemTypeValue = (typeof SubscriptionItemType)[keyof typeof SubscriptionItemType];
|
|
88
90
|
/** Dunning state constants */
|
|
89
91
|
declare const DunningState: {
|
|
90
92
|
readonly None: "none";
|
|
@@ -93,11 +95,16 @@ declare const DunningState: {
|
|
|
93
95
|
readonly Final: "final";
|
|
94
96
|
readonly Suspended: "suspended";
|
|
95
97
|
};
|
|
98
|
+
type DunningStateType = (typeof DunningState)[keyof typeof DunningState];
|
|
96
99
|
interface ISubscription {
|
|
97
100
|
_id: string;
|
|
98
101
|
subscriptionStatus: SubscriptionStatusType;
|
|
102
|
+
/** Stripe Subscription ID (e.g. 'sub_...'). Present when linked to Stripe. */
|
|
103
|
+
subscriptionId?: string;
|
|
99
104
|
stripePriceId?: string;
|
|
100
105
|
stripeCurrentPeriodEnd?: string;
|
|
106
|
+
/** When the current monthly usage period ends (quotas reset on this date). */
|
|
107
|
+
usageCurrentPeriodEnd?: string;
|
|
101
108
|
cancelAtPeriodEnd: boolean;
|
|
102
109
|
billingInterval?: BillingInterval;
|
|
103
110
|
/** Trial start date (ISO string). Set when subscription is in trial. */
|
|
@@ -217,6 +224,21 @@ interface IPlanVersion {
|
|
|
217
224
|
durationDays: number;
|
|
218
225
|
requireCard: boolean;
|
|
219
226
|
};
|
|
227
|
+
/** Credit grant configuration. When enabled, credits are granted to workspaces on this plan. */
|
|
228
|
+
creditGrant?: {
|
|
229
|
+
enabled: boolean;
|
|
230
|
+
/** Linked credit package (populated with name, slug, creditAmount). */
|
|
231
|
+
creditPackage?: {
|
|
232
|
+
_id: string;
|
|
233
|
+
name: string;
|
|
234
|
+
slug: string;
|
|
235
|
+
creditAmount: number;
|
|
236
|
+
} | string;
|
|
237
|
+
/** How unused plan credits are handled on renewal: 'reset' = expire old, 'topup' = add to existing. */
|
|
238
|
+
mode: 'reset' | 'topup';
|
|
239
|
+
/** true = credits given fresh every month, false = one-time lifetime grant (default). */
|
|
240
|
+
renewOnPeriod?: boolean;
|
|
241
|
+
};
|
|
220
242
|
isCurrent?: boolean;
|
|
221
243
|
isLegacy?: boolean;
|
|
222
244
|
archived?: boolean;
|
|
@@ -485,6 +507,15 @@ interface IPublicPlanVersion {
|
|
|
485
507
|
durationDays: number;
|
|
486
508
|
requireCard: boolean;
|
|
487
509
|
};
|
|
510
|
+
/** Credit grant config. Only present when the plan grants credits. */
|
|
511
|
+
creditGrant?: {
|
|
512
|
+
enabled: boolean;
|
|
513
|
+
creditAmount: number | null;
|
|
514
|
+
packageName: string | null;
|
|
515
|
+
mode: 'reset' | 'topup';
|
|
516
|
+
/** true = credits given fresh every month, false = one-time lifetime grant. */
|
|
517
|
+
renewOnPeriod: boolean;
|
|
518
|
+
};
|
|
488
519
|
}
|
|
489
520
|
interface IPublicPlansResponse {
|
|
490
521
|
items: IPublicPlanItem[];
|
|
@@ -508,12 +539,10 @@ interface IInvoice {
|
|
|
508
539
|
subscription: string;
|
|
509
540
|
}
|
|
510
541
|
interface IInvoiceListResponse {
|
|
511
|
-
success: boolean;
|
|
512
542
|
invoices: IInvoice[];
|
|
513
543
|
has_more: boolean;
|
|
514
544
|
}
|
|
515
545
|
interface IInvoiceResponse {
|
|
516
|
-
success: boolean;
|
|
517
546
|
invoice: IInvoice;
|
|
518
547
|
}
|
|
519
548
|
/** Request body for POST .../workspaces/:id/subscription/usage */
|
|
@@ -580,6 +609,166 @@ interface IUsageLogsResponse {
|
|
|
580
609
|
hasNextPage: boolean;
|
|
581
610
|
hasPrevPage: boolean;
|
|
582
611
|
}
|
|
612
|
+
/** Credit bucket source (how credits entered the workspace) */
|
|
613
|
+
declare const CreditBucketSource: {
|
|
614
|
+
readonly PlanGrant: "plan_grant";
|
|
615
|
+
readonly CreditPackPurchase: "credit_pack_purchase";
|
|
616
|
+
readonly AdminGrant: "admin_grant";
|
|
617
|
+
readonly Refund: "refund";
|
|
618
|
+
};
|
|
619
|
+
type CreditBucketSourceType = (typeof CreditBucketSource)[keyof typeof CreditBucketSource];
|
|
620
|
+
/** Credit bucket status */
|
|
621
|
+
declare const CreditBucketStatus: {
|
|
622
|
+
readonly Pending: "pending";
|
|
623
|
+
readonly Active: "active";
|
|
624
|
+
readonly Expired: "expired";
|
|
625
|
+
readonly Consumed: "consumed";
|
|
626
|
+
};
|
|
627
|
+
type CreditBucketStatusType = (typeof CreditBucketStatus)[keyof typeof CreditBucketStatus];
|
|
628
|
+
/** Credit transaction type */
|
|
629
|
+
declare const CreditTransactionType: {
|
|
630
|
+
readonly PlanGrant: "plan_grant";
|
|
631
|
+
readonly PackPurchased: "pack_purchased";
|
|
632
|
+
readonly Consumed: "consumed";
|
|
633
|
+
readonly Expired: "expired";
|
|
634
|
+
readonly AdminGrant: "admin_grant";
|
|
635
|
+
readonly AdminRevoke: "admin_revoke";
|
|
636
|
+
readonly Refund: "refund";
|
|
637
|
+
};
|
|
638
|
+
type CreditTransactionTypeValue = (typeof CreditTransactionType)[keyof typeof CreditTransactionType];
|
|
639
|
+
/** Credit balance for a workspace */
|
|
640
|
+
interface ICreditBalance {
|
|
641
|
+
available: number;
|
|
642
|
+
totalGranted: number;
|
|
643
|
+
totalConsumed: number;
|
|
644
|
+
totalExpired: number;
|
|
645
|
+
totalRefunded: number;
|
|
646
|
+
}
|
|
647
|
+
/** Pricing variant for a credit package */
|
|
648
|
+
interface ICreditPackagePricingVariant {
|
|
649
|
+
currency: string;
|
|
650
|
+
/** Price in smallest currency unit (cents) */
|
|
651
|
+
amount: number;
|
|
652
|
+
stripePriceId?: string;
|
|
653
|
+
}
|
|
654
|
+
/** Admin-defined purchasable credit package */
|
|
655
|
+
interface ICreditPackage extends IDocument {
|
|
656
|
+
name: string;
|
|
657
|
+
slug: string;
|
|
658
|
+
description?: string;
|
|
659
|
+
creditAmount: number;
|
|
660
|
+
pricingVariants: ICreditPackagePricingVariant[];
|
|
661
|
+
validityDays?: number;
|
|
662
|
+
isActive: boolean;
|
|
663
|
+
sortOrder: number;
|
|
664
|
+
archived: boolean;
|
|
665
|
+
}
|
|
666
|
+
/** A single credit transaction (user-facing event history) */
|
|
667
|
+
interface ICreditTransaction extends IDocument {
|
|
668
|
+
workspace: string;
|
|
669
|
+
type: CreditTransactionTypeValue;
|
|
670
|
+
/** Positive for grants, negative for consume/expire/revoke */
|
|
671
|
+
amount: number;
|
|
672
|
+
balanceAfter: number;
|
|
673
|
+
description?: string;
|
|
674
|
+
bucket?: string;
|
|
675
|
+
creditPackage?: string;
|
|
676
|
+
actor?: string;
|
|
677
|
+
metadata?: Record<string, any>;
|
|
678
|
+
}
|
|
679
|
+
/** A credit bucket (per-grant allocation with expiry) */
|
|
680
|
+
interface ICreditBucket extends IDocument {
|
|
681
|
+
workspace: string;
|
|
682
|
+
source: CreditBucketSourceType;
|
|
683
|
+
status: CreditBucketStatusType;
|
|
684
|
+
creditAmount: number;
|
|
685
|
+
remaining: number;
|
|
686
|
+
expiresAt?: string;
|
|
687
|
+
activatedAt?: string;
|
|
688
|
+
creditPackage?: string | ICreditPackage;
|
|
689
|
+
grantedBy?: string;
|
|
690
|
+
metadata?: Record<string, any>;
|
|
691
|
+
}
|
|
692
|
+
/** Request body for POST .../credits/consume */
|
|
693
|
+
interface IConsumeCreditsRequest {
|
|
694
|
+
amount: number;
|
|
695
|
+
description?: string;
|
|
696
|
+
idempotencyKey?: string;
|
|
697
|
+
metadata?: Record<string, any>;
|
|
698
|
+
}
|
|
699
|
+
/** Response from POST .../credits/consume */
|
|
700
|
+
interface IConsumeCreditsResponse {
|
|
701
|
+
success: boolean;
|
|
702
|
+
consumed: number;
|
|
703
|
+
balanceAfter: number;
|
|
704
|
+
}
|
|
705
|
+
/** Request body for POST .../credits/purchase */
|
|
706
|
+
interface ICreditPurchaseRequest {
|
|
707
|
+
creditPackageId: string;
|
|
708
|
+
currency?: string;
|
|
709
|
+
successUrl: string;
|
|
710
|
+
cancelUrl: string;
|
|
711
|
+
}
|
|
712
|
+
/** Response from POST .../credits/purchase */
|
|
713
|
+
interface ICreditPurchaseResponse {
|
|
714
|
+
sessionId: string;
|
|
715
|
+
url: string;
|
|
716
|
+
}
|
|
717
|
+
/** Query params for GET .../credits/transactions */
|
|
718
|
+
interface ICreditTransactionsQuery {
|
|
719
|
+
type?: CreditTransactionTypeValue;
|
|
720
|
+
page?: number;
|
|
721
|
+
limit?: number;
|
|
722
|
+
}
|
|
723
|
+
/** Paginated response from GET .../credits/transactions */
|
|
724
|
+
interface ICreditTransactionsResponse {
|
|
725
|
+
docs: ICreditTransaction[];
|
|
726
|
+
totalDocs: number;
|
|
727
|
+
limit: number;
|
|
728
|
+
page: number;
|
|
729
|
+
totalPages: number;
|
|
730
|
+
hasNextPage: boolean;
|
|
731
|
+
hasPrevPage: boolean;
|
|
732
|
+
}
|
|
733
|
+
/** Query params for GET .../credits/buckets */
|
|
734
|
+
interface ICreditBucketsQuery {
|
|
735
|
+
status?: CreditBucketStatusType;
|
|
736
|
+
source?: CreditBucketSourceType;
|
|
737
|
+
page?: number;
|
|
738
|
+
limit?: number;
|
|
739
|
+
}
|
|
740
|
+
/** Paginated response from GET .../credits/buckets */
|
|
741
|
+
interface ICreditBucketsResponse {
|
|
742
|
+
docs: ICreditBucket[];
|
|
743
|
+
totalDocs: number;
|
|
744
|
+
limit: number;
|
|
745
|
+
page: number;
|
|
746
|
+
totalPages: number;
|
|
747
|
+
hasNextPage: boolean;
|
|
748
|
+
hasPrevPage: boolean;
|
|
749
|
+
}
|
|
750
|
+
/** Response from GET .../credits/expiring */
|
|
751
|
+
interface IExpiringCreditsResponse {
|
|
752
|
+
days: number;
|
|
753
|
+
expiringCredits: number;
|
|
754
|
+
buckets: ICreditBucket[];
|
|
755
|
+
}
|
|
756
|
+
/** Public credit package (from public endpoint, no auth) */
|
|
757
|
+
interface IPublicCreditPackage {
|
|
758
|
+
_id: string;
|
|
759
|
+
name: string;
|
|
760
|
+
slug: string;
|
|
761
|
+
description: string;
|
|
762
|
+
creditAmount: number;
|
|
763
|
+
pricingVariants: ICreditPackagePricingVariant[];
|
|
764
|
+
validityDays: number | null;
|
|
765
|
+
sortOrder: number;
|
|
766
|
+
}
|
|
767
|
+
/** Response from GET /:orgId/credit-packages (public, no auth) */
|
|
768
|
+
interface IPublicCreditPackagesResponse {
|
|
769
|
+
packages: IPublicCreditPackage[];
|
|
770
|
+
notes?: string;
|
|
771
|
+
}
|
|
583
772
|
|
|
584
773
|
interface IWorkspace {
|
|
585
774
|
_id: string;
|
|
@@ -877,6 +1066,8 @@ interface IBaseApiConfig {
|
|
|
877
1066
|
method: string;
|
|
878
1067
|
path: string;
|
|
879
1068
|
}) => void;
|
|
1069
|
+
/** Called when any request receives a 401 response (session expired mid-use). */
|
|
1070
|
+
onUnauthorized?: () => void;
|
|
880
1071
|
/** Custom fetch implementation. */
|
|
881
1072
|
fetch?: typeof globalThis.fetch;
|
|
882
1073
|
}
|
|
@@ -900,6 +1091,7 @@ declare abstract class BaseApi {
|
|
|
900
1091
|
private readonly _debug;
|
|
901
1092
|
private readonly _customHeaders;
|
|
902
1093
|
private readonly _onError?;
|
|
1094
|
+
private readonly _onUnauthorized?;
|
|
903
1095
|
private readonly _fetch;
|
|
904
1096
|
constructor(config: IBaseApiConfig);
|
|
905
1097
|
/** Throws if config is not ready for API calls. Called automatically by fetchJson/fetchResponse. */
|
|
@@ -928,6 +1120,16 @@ declare abstract class BaseApi {
|
|
|
928
1120
|
* Caller is responsible for checking response.ok and parsing body.
|
|
929
1121
|
*/
|
|
930
1122
|
protected fetchResponse(path: string, init?: RequestInit): Promise<Response>;
|
|
1123
|
+
/**
|
|
1124
|
+
* Throw an error from a failed response.
|
|
1125
|
+
* Tries to parse JSON error body; falls back to status-based message.
|
|
1126
|
+
*/
|
|
1127
|
+
protected throwResponseError(response: Response, defaultMsg: string): Promise<never>;
|
|
1128
|
+
/**
|
|
1129
|
+
* Parse JSON and unwrap `{ success, data }` envelope if present.
|
|
1130
|
+
* Throws if `success` is explicitly `false`.
|
|
1131
|
+
*/
|
|
1132
|
+
protected unwrapResponse<T>(response: Response, defaultMsg: string): Promise<T>;
|
|
931
1133
|
}
|
|
932
1134
|
|
|
933
1135
|
/**
|
|
@@ -956,7 +1158,8 @@ declare class AuthApi extends BaseApi {
|
|
|
956
1158
|
});
|
|
957
1159
|
/**
|
|
958
1160
|
* Initiate OAuth sign-in flow. Returns redirect URL to the auth provider.
|
|
959
|
-
* Uses /api/v1/auth/request
|
|
1161
|
+
* Uses /api/v1/auth/request — auth endpoints sit outside the /public basePath,
|
|
1162
|
+
* so we build the URL directly instead of using fetchResponse.
|
|
960
1163
|
*/
|
|
961
1164
|
requestAuth(params: AuthRequestParams): Promise<AuthRequestResponse>;
|
|
962
1165
|
/** Fetch user profile with the given session ID (used after OAuth redirect or from storage). */
|
|
@@ -1109,6 +1312,7 @@ interface NotificationEvent {
|
|
|
1109
1312
|
declare class WorkspaceApi extends BaseApi {
|
|
1110
1313
|
constructor(config: IOsConfig & {
|
|
1111
1314
|
sessionId?: string;
|
|
1315
|
+
onUnauthorized?: () => void;
|
|
1112
1316
|
});
|
|
1113
1317
|
getWorkspaces(): Promise<IWorkspace[]>;
|
|
1114
1318
|
createWorkspace(data: {
|
|
@@ -1184,6 +1388,14 @@ declare class WorkspaceApi extends BaseApi {
|
|
|
1184
1388
|
* @returns Plan group versions response with currentVersion and availableVersions
|
|
1185
1389
|
*/
|
|
1186
1390
|
getPublicPlans(slug: string): Promise<IPublicPlansResponse>;
|
|
1391
|
+
/**
|
|
1392
|
+
* Get credit packages (public, no auth required).
|
|
1393
|
+
* Returns active credit packages for the org with pricing info.
|
|
1394
|
+
* Use this for public credit store pages.
|
|
1395
|
+
*
|
|
1396
|
+
* @returns Credit packages with pricing variants
|
|
1397
|
+
*/
|
|
1398
|
+
getPublicCreditPackages(): Promise<IPublicCreditPackagesResponse>;
|
|
1187
1399
|
/**
|
|
1188
1400
|
* Get plan group version details by ID (public, no auth required).
|
|
1189
1401
|
* Returns the full plan group version with populated plan versions.
|
|
@@ -1343,6 +1555,56 @@ declare class WorkspaceApi extends BaseApi {
|
|
|
1343
1555
|
email?: boolean;
|
|
1344
1556
|
push?: boolean;
|
|
1345
1557
|
}>>;
|
|
1558
|
+
/**
|
|
1559
|
+
* Get credit balance for a workspace.
|
|
1560
|
+
* @param workspaceId - The workspace ID
|
|
1561
|
+
* @returns Credit balance with available, totalGranted, totalConsumed, totalExpired, totalRefunded
|
|
1562
|
+
*/
|
|
1563
|
+
getCreditBalance(workspaceId: string): Promise<ICreditBalance>;
|
|
1564
|
+
/**
|
|
1565
|
+
* Consume credits from a workspace balance.
|
|
1566
|
+
* Throws an error with `code: 'INSUFFICIENT_CREDITS'` and `available`/`requested` fields on 402.
|
|
1567
|
+
* @param workspaceId - The workspace ID
|
|
1568
|
+
* @param request - Consume request with amount, optional description, idempotencyKey, metadata
|
|
1569
|
+
* @returns Consume result with consumed amount and balanceAfter
|
|
1570
|
+
*/
|
|
1571
|
+
consumeCredits(workspaceId: string, request: IConsumeCreditsRequest): Promise<IConsumeCreditsResponse>;
|
|
1572
|
+
/**
|
|
1573
|
+
* Create a Stripe checkout session for purchasing a credit package.
|
|
1574
|
+
* Returns a checkout URL to redirect the user to.
|
|
1575
|
+
* @param workspaceId - The workspace ID
|
|
1576
|
+
* @param request - Purchase request with creditPackageId, successUrl, cancelUrl, optional currency
|
|
1577
|
+
* @returns Checkout session ID and URL
|
|
1578
|
+
*/
|
|
1579
|
+
purchaseCredits(workspaceId: string, request: ICreditPurchaseRequest): Promise<ICreditPurchaseResponse>;
|
|
1580
|
+
/**
|
|
1581
|
+
* List available credit packages for purchase.
|
|
1582
|
+
* Returns active, non-archived packages sorted by sortOrder then creditAmount.
|
|
1583
|
+
* @param workspaceId - The workspace ID
|
|
1584
|
+
* @returns Array of credit packages
|
|
1585
|
+
*/
|
|
1586
|
+
getCreditPackages(workspaceId: string): Promise<ICreditPackage[]>;
|
|
1587
|
+
/**
|
|
1588
|
+
* Get paginated credit transaction history.
|
|
1589
|
+
* @param workspaceId - The workspace ID
|
|
1590
|
+
* @param query - Optional filters: type, page, limit
|
|
1591
|
+
* @returns Paginated credit transactions
|
|
1592
|
+
*/
|
|
1593
|
+
getCreditTransactions(workspaceId: string, query?: ICreditTransactionsQuery): Promise<ICreditTransactionsResponse>;
|
|
1594
|
+
/**
|
|
1595
|
+
* Get paginated credit buckets.
|
|
1596
|
+
* @param workspaceId - The workspace ID
|
|
1597
|
+
* @param query - Optional filters: status, source, page, limit
|
|
1598
|
+
* @returns Paginated credit buckets
|
|
1599
|
+
*/
|
|
1600
|
+
getCreditBuckets(workspaceId: string, query?: ICreditBucketsQuery): Promise<ICreditBucketsResponse>;
|
|
1601
|
+
/**
|
|
1602
|
+
* Get credits expiring within N days.
|
|
1603
|
+
* @param workspaceId - The workspace ID
|
|
1604
|
+
* @param days - Look-ahead window in days (1-90, default 7)
|
|
1605
|
+
* @returns Expiring credits summary with bucket list
|
|
1606
|
+
*/
|
|
1607
|
+
getExpiringCredits(workspaceId: string, days?: number): Promise<IExpiringCreditsResponse>;
|
|
1346
1608
|
}
|
|
1347
1609
|
|
|
1348
1610
|
/**
|
|
@@ -1424,17 +1686,11 @@ declare class EventEmitter {
|
|
|
1424
1686
|
}
|
|
1425
1687
|
declare const eventEmitter: EventEmitter;
|
|
1426
1688
|
|
|
1427
|
-
|
|
1428
|
-
* Notify all subscribers to refetch quota usage (e.g. after recording usage).
|
|
1429
|
-
* Called internally by useRecordUsage on success.
|
|
1430
|
-
*/
|
|
1431
|
-
declare function invalidateQuotaUsage(): void;
|
|
1689
|
+
declare const invalidateCreditBalance: () => void;
|
|
1432
1690
|
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
*/
|
|
1437
|
-
declare function invalidateSubscription(): void;
|
|
1691
|
+
declare const invalidateQuotaUsage: () => void;
|
|
1692
|
+
|
|
1693
|
+
declare const invalidateSubscription: () => void;
|
|
1438
1694
|
|
|
1439
1695
|
/**
|
|
1440
1696
|
* BuildBase URL parameter utilities.
|
|
@@ -1468,6 +1724,37 @@ declare function invalidateSubscription(): void;
|
|
|
1468
1724
|
*/
|
|
1469
1725
|
/** The single URL param name used by the SDK */
|
|
1470
1726
|
declare const BB_PARAM = "bb";
|
|
1727
|
+
/** BB param action values */
|
|
1728
|
+
declare const BBAction: {
|
|
1729
|
+
readonly Checkout: "checkout";
|
|
1730
|
+
readonly Billing: "billing";
|
|
1731
|
+
readonly SelectPlan: "selectPlan";
|
|
1732
|
+
readonly CreditPurchase: "creditPurchase";
|
|
1733
|
+
readonly OpenCreditStore: "openCreditStore";
|
|
1734
|
+
readonly Invite: "invite";
|
|
1735
|
+
};
|
|
1736
|
+
type BBActionType = (typeof BBAction)[keyof typeof BBAction];
|
|
1737
|
+
/** BB param status values */
|
|
1738
|
+
declare const BBStatus: {
|
|
1739
|
+
readonly Success: "success";
|
|
1740
|
+
readonly Cancel: "cancel";
|
|
1741
|
+
readonly Error: "error";
|
|
1742
|
+
};
|
|
1743
|
+
type BBStatusType = (typeof BBStatus)[keyof typeof BBStatus];
|
|
1744
|
+
/** BB param screen values (mirrors SettingsScreen but avoids cross-layer import) */
|
|
1745
|
+
declare const BBScreen: {
|
|
1746
|
+
readonly Subscription: "subscription";
|
|
1747
|
+
readonly Credits: "credits";
|
|
1748
|
+
readonly Usage: "usage";
|
|
1749
|
+
readonly Users: "users";
|
|
1750
|
+
readonly Profile: "profile";
|
|
1751
|
+
readonly General: "general";
|
|
1752
|
+
readonly Features: "features";
|
|
1753
|
+
readonly Notifications: "notifications";
|
|
1754
|
+
readonly Permissions: "permissions";
|
|
1755
|
+
readonly Danger: "danger";
|
|
1756
|
+
};
|
|
1757
|
+
type BBScreenType = (typeof BBScreen)[keyof typeof BBScreen];
|
|
1471
1758
|
/**
|
|
1472
1759
|
* Build a URL with BuildBase params.
|
|
1473
1760
|
*
|
|
@@ -1495,6 +1782,14 @@ declare function createCheckoutRedirectUrls(workspaceId: string, baseUrl?: strin
|
|
|
1495
1782
|
successUrl: string;
|
|
1496
1783
|
cancelUrl: string;
|
|
1497
1784
|
};
|
|
1785
|
+
/**
|
|
1786
|
+
* Build success + cancel URL pair for credit purchase checkout redirects.
|
|
1787
|
+
* Both include the workspace ID and screen:credits.
|
|
1788
|
+
*/
|
|
1789
|
+
declare function createCreditPurchaseRedirectUrls(workspaceId: string, baseUrl?: string): {
|
|
1790
|
+
successUrl: string;
|
|
1791
|
+
cancelUrl: string;
|
|
1792
|
+
};
|
|
1498
1793
|
/**
|
|
1499
1794
|
* Read the `bb` param from the current URL.
|
|
1500
1795
|
* Returns null if no `bb` param is present.
|
|
@@ -1856,7 +2151,7 @@ declare function hasPermission(permission: string | string[], ctx: PermissionCon
|
|
|
1856
2151
|
*
|
|
1857
2152
|
* Or manually create `public/push-sw.js` with this content.
|
|
1858
2153
|
*/
|
|
1859
|
-
declare const PUSH_SERVICE_WORKER_SCRIPT = "\n// BuildBase Push Notification Service Worker\n// Place this file in your app's public directory (e.g. public/push-sw.js)\n\nself.addEventListener('push', function(event) {\n if (!event.data) return;\n\n try {\n
|
|
2154
|
+
declare const PUSH_SERVICE_WORKER_SCRIPT = "\n// BuildBase Push Notification Service Worker\n// Place this file in your app's public directory (e.g. public/push-sw.js)\n\nself.addEventListener('push', function(event) {\n if (!event.data) return;\n\n try {\n const payload = event.data.json();\n const title = payload.title || 'Notification';\n const options = {\n body: payload.body || '',\n icon: payload.icon || undefined,\n badge: payload.icon || undefined,\n data: { url: payload.url, ...(payload.data || {}) },\n tag: 'buildbase-push-' + Date.now(),\n };\n\n event.waitUntil(\n self.registration.showNotification(title, options)\n );\n } catch (e) {\n console.error('[PushSW] Failed to show notification:', e);\n }\n});\n\nself.addEventListener('notificationclick', function(event) {\n event.notification.close();\n\n const url = event.notification.data && event.notification.data.url;\n if (url) {\n event.waitUntil(\n clients.matchAll({ type: 'window', includeUncontrolled: true }).then(function(clientList) {\n for (let i = 0; i < clientList.length; i++) {\n const client = clientList[i];\n if (client.url === url && 'focus' in client) {\n return client.focus();\n }\n }\n if (clients.openWindow) {\n return clients.openWindow(url);\n }\n })\n );\n }\n});\n";
|
|
1860
2155
|
|
|
1861
2156
|
interface BetaFormData {
|
|
1862
2157
|
name?: string;
|
|
@@ -1879,6 +2174,7 @@ interface SDKMessages {
|
|
|
1879
2174
|
users: string;
|
|
1880
2175
|
subscription: string;
|
|
1881
2176
|
usage: string;
|
|
2177
|
+
credits: string;
|
|
1882
2178
|
features: string;
|
|
1883
2179
|
notifications: string;
|
|
1884
2180
|
permissions: string;
|
|
@@ -1892,6 +2188,7 @@ interface SDKMessages {
|
|
|
1892
2188
|
users: string;
|
|
1893
2189
|
subscription: string;
|
|
1894
2190
|
usage: string;
|
|
2191
|
+
credits: string;
|
|
1895
2192
|
features: string;
|
|
1896
2193
|
notifications: string;
|
|
1897
2194
|
permissions: string;
|
|
@@ -1912,6 +2209,9 @@ interface SDKMessages {
|
|
|
1912
2209
|
error: string;
|
|
1913
2210
|
refreshAction: string;
|
|
1914
2211
|
retryAction: string;
|
|
2212
|
+
noPermissionTitle: string;
|
|
2213
|
+
noPermissionDescription: string;
|
|
2214
|
+
billingManageOnly: string;
|
|
1915
2215
|
};
|
|
1916
2216
|
};
|
|
1917
2217
|
subscription: {
|
|
@@ -1992,6 +2292,17 @@ interface SDKMessages {
|
|
|
1992
2292
|
features: string;
|
|
1993
2293
|
limits: string;
|
|
1994
2294
|
quotas: string;
|
|
2295
|
+
credits: string;
|
|
2296
|
+
creditsPerMonth: string;
|
|
2297
|
+
creditsOneTime: string;
|
|
2298
|
+
creditRenewal: string;
|
|
2299
|
+
creditModeReset: string;
|
|
2300
|
+
creditModeTopup: string;
|
|
2301
|
+
creditModeLifetime: string;
|
|
2302
|
+
/** @deprecated */
|
|
2303
|
+
creditsPerPeriod: string;
|
|
2304
|
+
/** @deprecated */
|
|
2305
|
+
creditRollover: string;
|
|
1995
2306
|
};
|
|
1996
2307
|
checkout: {
|
|
1997
2308
|
upgrade: string;
|
|
@@ -2357,6 +2668,50 @@ interface SDKMessages {
|
|
|
2357
2668
|
saving: string;
|
|
2358
2669
|
saveSuccess: string;
|
|
2359
2670
|
};
|
|
2671
|
+
credits: {
|
|
2672
|
+
title: string;
|
|
2673
|
+
description: string;
|
|
2674
|
+
balance: string;
|
|
2675
|
+
available: string;
|
|
2676
|
+
totalGranted: string;
|
|
2677
|
+
totalConsumed: string;
|
|
2678
|
+
totalExpired: string;
|
|
2679
|
+
noCredits: string;
|
|
2680
|
+
noCreditsHint: string;
|
|
2681
|
+
buyCredits: string;
|
|
2682
|
+
buyAmount: string;
|
|
2683
|
+
purchasing: string;
|
|
2684
|
+
packages: string;
|
|
2685
|
+
noPackages: string;
|
|
2686
|
+
creditsAmount: string;
|
|
2687
|
+
validityDays: string;
|
|
2688
|
+
validityUnlimited: string;
|
|
2689
|
+
transactions: string;
|
|
2690
|
+
noTransactions: string;
|
|
2691
|
+
loadMore: string;
|
|
2692
|
+
viewAll: string;
|
|
2693
|
+
expiringSoon: string;
|
|
2694
|
+
expiringInDays: string;
|
|
2695
|
+
noExpiring: string;
|
|
2696
|
+
type: {
|
|
2697
|
+
plan_grant: string;
|
|
2698
|
+
pack_purchased: string;
|
|
2699
|
+
consumed: string;
|
|
2700
|
+
expired: string;
|
|
2701
|
+
admin_grant: string;
|
|
2702
|
+
admin_revoke: string;
|
|
2703
|
+
refund: string;
|
|
2704
|
+
};
|
|
2705
|
+
dialogTitle: string;
|
|
2706
|
+
dialogDescription: string;
|
|
2707
|
+
dialogDescriptionWorkspace: string;
|
|
2708
|
+
perCredit: string;
|
|
2709
|
+
purchaseSuccess: string;
|
|
2710
|
+
purchaseCanceled: string;
|
|
2711
|
+
purchaseFailed: string;
|
|
2712
|
+
errorLoading: string;
|
|
2713
|
+
insufficientCredits: string;
|
|
2714
|
+
};
|
|
2360
2715
|
errors: {
|
|
2361
2716
|
networkError: string;
|
|
2362
2717
|
unauthorized: string;
|
|
@@ -2378,6 +2733,12 @@ interface SDKMessages {
|
|
|
2378
2733
|
fetchQuotaUsage: string;
|
|
2379
2734
|
fetchAllQuotaUsage: string;
|
|
2380
2735
|
fetchUsageLogs: string;
|
|
2736
|
+
fetchCreditBalance: string;
|
|
2737
|
+
consumeCredits: string;
|
|
2738
|
+
purchaseCredits: string;
|
|
2739
|
+
fetchCreditPackages: string;
|
|
2740
|
+
fetchCreditTransactions: string;
|
|
2741
|
+
fetchExpiringCredits: string;
|
|
2381
2742
|
};
|
|
2382
2743
|
}
|
|
2383
2744
|
/** Supported locale codes */
|
|
@@ -2566,6 +2927,7 @@ declare const SettingsScreen: {
|
|
|
2566
2927
|
readonly Users: "users";
|
|
2567
2928
|
readonly Subscription: "subscription";
|
|
2568
2929
|
readonly Usage: "usage";
|
|
2930
|
+
readonly Credits: "credits";
|
|
2569
2931
|
readonly Features: "features";
|
|
2570
2932
|
readonly Notifications: "notifications";
|
|
2571
2933
|
readonly Permissions: "permissions";
|
|
@@ -2579,6 +2941,8 @@ declare function useSaaSAuth(): {
|
|
|
2579
2941
|
signIn: (returnUrl?: string) => Promise<void>;
|
|
2580
2942
|
signOut: () => Promise<void>;
|
|
2581
2943
|
openWorkspaceSettings: (section?: WorkspaceSettingsSection) => void;
|
|
2944
|
+
openCreditStore: () => void;
|
|
2945
|
+
openPlanPicker: () => void;
|
|
2582
2946
|
isAuthenticated: boolean;
|
|
2583
2947
|
isLoading: boolean;
|
|
2584
2948
|
isRedirecting: boolean;
|
|
@@ -3172,6 +3536,292 @@ declare const WhenQuotaThreshold: {
|
|
|
3172
3536
|
displayName: string;
|
|
3173
3537
|
};
|
|
3174
3538
|
|
|
3539
|
+
interface CreditActionsDetails {
|
|
3540
|
+
/** Current credit balance. Null while loading. */
|
|
3541
|
+
balance: ICreditBalance | null;
|
|
3542
|
+
/** Whether balance is loading. */
|
|
3543
|
+
loading: boolean;
|
|
3544
|
+
/** Available credit packages for purchase. */
|
|
3545
|
+
packages: ICreditPackage[];
|
|
3546
|
+
/** Whether packages are loading. */
|
|
3547
|
+
packagesLoading: boolean;
|
|
3548
|
+
/**
|
|
3549
|
+
* Consume credits from the workspace balance.
|
|
3550
|
+
* Throws with `code: 'INSUFFICIENT_CREDITS'` if balance is too low.
|
|
3551
|
+
*
|
|
3552
|
+
* @example
|
|
3553
|
+
* ```ts
|
|
3554
|
+
* try {
|
|
3555
|
+
* const result = await consume({ amount: 10, description: 'AI generation' });
|
|
3556
|
+
* console.log(`Balance: ${result.balanceAfter}`);
|
|
3557
|
+
* } catch (err) {
|
|
3558
|
+
* if (err.code === 'INSUFFICIENT_CREDITS') showUpgradePrompt();
|
|
3559
|
+
* }
|
|
3560
|
+
* ```
|
|
3561
|
+
*/
|
|
3562
|
+
consume: (request: IConsumeCreditsRequest) => Promise<IConsumeCreditsResponse>;
|
|
3563
|
+
/** Whether a consume operation is in progress. */
|
|
3564
|
+
consuming: boolean;
|
|
3565
|
+
/**
|
|
3566
|
+
* Purchase a credit package. Redirects to Stripe Checkout.
|
|
3567
|
+
* On success, user returns to the app with the credits screen open.
|
|
3568
|
+
*
|
|
3569
|
+
* @example
|
|
3570
|
+
* ```ts
|
|
3571
|
+
* await purchase(packages[0]); // Redirects to Stripe
|
|
3572
|
+
* ```
|
|
3573
|
+
*/
|
|
3574
|
+
purchase: (pkg: ICreditPackage) => Promise<void>;
|
|
3575
|
+
/** Whether a purchase redirect is in progress. */
|
|
3576
|
+
purchasing: boolean;
|
|
3577
|
+
/** Refetch the balance. */
|
|
3578
|
+
refetch: () => Promise<void>;
|
|
3579
|
+
/** Error from the last consume or purchase operation. */
|
|
3580
|
+
error: string | null;
|
|
3581
|
+
}
|
|
3582
|
+
interface CreditActionsProviderProps {
|
|
3583
|
+
/** Render prop receiving credit actions — build your own UI. */
|
|
3584
|
+
children: (details: CreditActionsDetails) => React.ReactNode;
|
|
3585
|
+
}
|
|
3586
|
+
/**
|
|
3587
|
+
* Provides credit balance, packages, and action functions (consume, purchase) via render prop.
|
|
3588
|
+
* Must be inside SaaSOSProvider. Handles Stripe redirect URLs automatically.
|
|
3589
|
+
*
|
|
3590
|
+
* @example
|
|
3591
|
+
* ```tsx
|
|
3592
|
+
* <CreditActionsProvider>
|
|
3593
|
+
* {({ balance, packages, consume, purchase, consuming, purchasing }) => (
|
|
3594
|
+
* <div>
|
|
3595
|
+
* <p>{balance?.available ?? 0} credits</p>
|
|
3596
|
+
*
|
|
3597
|
+
* <button onClick={() => consume({ amount: 5 })} disabled={consuming}>
|
|
3598
|
+
* Use 5 Credits
|
|
3599
|
+
* </button>
|
|
3600
|
+
*
|
|
3601
|
+
* {packages.map(pkg => (
|
|
3602
|
+
* <button key={pkg._id} onClick={() => purchase(pkg)} disabled={purchasing}>
|
|
3603
|
+
* Buy {pkg.creditAmount} for ${pkg.pricingVariants[0]?.amount / 100}
|
|
3604
|
+
* </button>
|
|
3605
|
+
* ))}
|
|
3606
|
+
* </div>
|
|
3607
|
+
* )}
|
|
3608
|
+
* </CreditActionsProvider>
|
|
3609
|
+
* ```
|
|
3610
|
+
*/
|
|
3611
|
+
declare const CreditActionsProvider: {
|
|
3612
|
+
({ children }: CreditActionsProviderProps): react.ReactNode;
|
|
3613
|
+
displayName: string;
|
|
3614
|
+
};
|
|
3615
|
+
|
|
3616
|
+
interface CreditBalanceDetails {
|
|
3617
|
+
/** Credit balance data. Null while loading or if no workspace. */
|
|
3618
|
+
balance: ICreditBalance | null;
|
|
3619
|
+
/** Whether data is being fetched. */
|
|
3620
|
+
loading: boolean;
|
|
3621
|
+
/** Error message if fetch failed. */
|
|
3622
|
+
error: string | null;
|
|
3623
|
+
/** Manually refresh the balance. */
|
|
3624
|
+
refetch: () => Promise<void>;
|
|
3625
|
+
}
|
|
3626
|
+
interface CreditBalanceProps {
|
|
3627
|
+
/** Render prop receiving balance details — build your own UI. */
|
|
3628
|
+
children: (details: CreditBalanceDetails) => React.ReactNode;
|
|
3629
|
+
}
|
|
3630
|
+
/**
|
|
3631
|
+
* Provides credit balance data for the current workspace via render prop.
|
|
3632
|
+
* Must be inside SaaSOSProvider. Balance auto-updates after consume/purchase.
|
|
3633
|
+
*
|
|
3634
|
+
* @example
|
|
3635
|
+
* ```tsx
|
|
3636
|
+
* <CreditBalance>
|
|
3637
|
+
* {({ balance, loading }) => {
|
|
3638
|
+
* if (loading) return <Skeleton />;
|
|
3639
|
+
* return <span>{balance?.available ?? 0} credits</span>;
|
|
3640
|
+
* }}
|
|
3641
|
+
* </CreditBalance>
|
|
3642
|
+
* ```
|
|
3643
|
+
*
|
|
3644
|
+
* @example
|
|
3645
|
+
* ```tsx
|
|
3646
|
+
* // Navbar credit indicator
|
|
3647
|
+
* <CreditBalance>
|
|
3648
|
+
* {({ balance, loading, refetch }) => (
|
|
3649
|
+
* <button onClick={refetch} disabled={loading}>
|
|
3650
|
+
* <CoinIcon />
|
|
3651
|
+
* {loading ? '...' : balance?.available ?? 0}
|
|
3652
|
+
* </button>
|
|
3653
|
+
* )}
|
|
3654
|
+
* </CreditBalance>
|
|
3655
|
+
* ```
|
|
3656
|
+
*/
|
|
3657
|
+
declare const CreditBalance: {
|
|
3658
|
+
({ children }: CreditBalanceProps): react.ReactNode;
|
|
3659
|
+
displayName: string;
|
|
3660
|
+
};
|
|
3661
|
+
|
|
3662
|
+
interface CreditStorePageDetails {
|
|
3663
|
+
/** Whether package data is being fetched */
|
|
3664
|
+
loading: boolean;
|
|
3665
|
+
/** Error message if fetch failed */
|
|
3666
|
+
error: string | null;
|
|
3667
|
+
/** Available credit packages with pricing */
|
|
3668
|
+
packages: IPublicCreditPackage[];
|
|
3669
|
+
/** Optional note from API (e.g. "Pricing is in cents.") */
|
|
3670
|
+
notes?: string;
|
|
3671
|
+
/** Refetch package data */
|
|
3672
|
+
refetch: () => Promise<void>;
|
|
3673
|
+
/**
|
|
3674
|
+
* Select a package to purchase. Handles everything automatically:
|
|
3675
|
+
* - If authenticated → opens the workspace settings Credits tab
|
|
3676
|
+
* - If not authenticated → saves a redirect URL and triggers sign-in
|
|
3677
|
+
*
|
|
3678
|
+
* @example
|
|
3679
|
+
* ```tsx
|
|
3680
|
+
* <button onClick={() => selectPackage(pkg._id)}>
|
|
3681
|
+
* Buy {pkg.creditAmount} Credits
|
|
3682
|
+
* </button>
|
|
3683
|
+
* ```
|
|
3684
|
+
*/
|
|
3685
|
+
selectPackage: (packageId: string) => void;
|
|
3686
|
+
}
|
|
3687
|
+
interface CreditStorePageProps {
|
|
3688
|
+
/** Render prop receiving package details — build your own credit store UI */
|
|
3689
|
+
children: (details: CreditStorePageDetails) => ReactNode;
|
|
3690
|
+
/** Custom loading UI. Defaults to skeleton. */
|
|
3691
|
+
loadingFallback?: ReactNode;
|
|
3692
|
+
/** Custom error UI. Receives error message. */
|
|
3693
|
+
errorFallback?: (error: string) => ReactNode;
|
|
3694
|
+
/**
|
|
3695
|
+
* Base URL for post-login redirects (e.g. `"https://app.com/dashboard"`).
|
|
3696
|
+
* When set, `selectPackage()` can redirect unauthenticated users through login
|
|
3697
|
+
* and back to the dashboard with the credits screen open.
|
|
3698
|
+
*/
|
|
3699
|
+
redirectBaseUrl?: string;
|
|
3700
|
+
}
|
|
3701
|
+
/**
|
|
3702
|
+
* Fetches and provides credit package details for public credit store pages (no login required).
|
|
3703
|
+
* Returns packages with pricing — the consumer constructs the layout.
|
|
3704
|
+
* Similar to `<PricingPage>` but for credit packages.
|
|
3705
|
+
*
|
|
3706
|
+
* @example
|
|
3707
|
+
* ```tsx
|
|
3708
|
+
* <CreditStorePage redirectBaseUrl="https://app.com/dashboard">
|
|
3709
|
+
* {({ loading, error, packages, selectPackage }) => {
|
|
3710
|
+
* if (loading) return <Loading />;
|
|
3711
|
+
* if (error) return <Error message={error} />;
|
|
3712
|
+
*
|
|
3713
|
+
* return (
|
|
3714
|
+
* <div className="grid grid-cols-3 gap-4">
|
|
3715
|
+
* {packages.map(pkg => (
|
|
3716
|
+
* <div key={pkg._id}>
|
|
3717
|
+
* <h3>{pkg.name}</h3>
|
|
3718
|
+
* <p>{pkg.creditAmount} credits</p>
|
|
3719
|
+
* <p>${(pkg.pricingVariants[0]?.amount / 100).toFixed(2)}</p>
|
|
3720
|
+
* <button onClick={() => selectPackage(pkg._id)}>Buy</button>
|
|
3721
|
+
* </div>
|
|
3722
|
+
* ))}
|
|
3723
|
+
* </div>
|
|
3724
|
+
* );
|
|
3725
|
+
* }}
|
|
3726
|
+
* </CreditStorePage>
|
|
3727
|
+
* ```
|
|
3728
|
+
*/
|
|
3729
|
+
declare function CreditStorePage({ children, loadingFallback, errorFallback, redirectBaseUrl, }: CreditStorePageProps): react_jsx_runtime.JSX.Element;
|
|
3730
|
+
|
|
3731
|
+
interface IWhenCreditsProps {
|
|
3732
|
+
/** Content to render when the condition is met. */
|
|
3733
|
+
children: React.ReactNode;
|
|
3734
|
+
/** Optional component/element to show while credit balance is loading (e.g. <Skeleton />). */
|
|
3735
|
+
loadingComponent?: React.ReactNode;
|
|
3736
|
+
/** Optional component/element to show when condition is not met (e.g. <BuyCreditsPrompt />). */
|
|
3737
|
+
fallbackComponent?: React.ReactNode;
|
|
3738
|
+
}
|
|
3739
|
+
interface IWhenCreditsAvailableProps extends IWhenCreditsProps {
|
|
3740
|
+
/** Minimum credits required to render children. Default: 1 */
|
|
3741
|
+
min?: number;
|
|
3742
|
+
}
|
|
3743
|
+
interface IWhenCreditsLowProps extends IWhenCreditsProps {
|
|
3744
|
+
/** Credits threshold. Children render when available <= threshold. */
|
|
3745
|
+
threshold: number;
|
|
3746
|
+
}
|
|
3747
|
+
/**
|
|
3748
|
+
* Renders children only when the workspace has at least `min` credits available.
|
|
3749
|
+
* Must be used within CreditBalanceContextProvider (included in SaaSOSProvider by default).
|
|
3750
|
+
*
|
|
3751
|
+
* @example
|
|
3752
|
+
* ```tsx
|
|
3753
|
+
* <WhenCreditsAvailable min={10}>
|
|
3754
|
+
* <GenerateButton />
|
|
3755
|
+
* </WhenCreditsAvailable>
|
|
3756
|
+
* ```
|
|
3757
|
+
*
|
|
3758
|
+
* @example
|
|
3759
|
+
* ```tsx
|
|
3760
|
+
* <WhenCreditsAvailable
|
|
3761
|
+
* min={5}
|
|
3762
|
+
* loadingComponent={<Skeleton />}
|
|
3763
|
+
* fallbackComponent={<p>Not enough credits. <BuyCreditsLink /></p>}
|
|
3764
|
+
* >
|
|
3765
|
+
* <AIFeature />
|
|
3766
|
+
* </WhenCreditsAvailable>
|
|
3767
|
+
* ```
|
|
3768
|
+
*/
|
|
3769
|
+
declare const WhenCreditsAvailable: {
|
|
3770
|
+
(props: IWhenCreditsAvailableProps): react.ReactNode;
|
|
3771
|
+
displayName: string;
|
|
3772
|
+
};
|
|
3773
|
+
/**
|
|
3774
|
+
* Renders children only when the workspace has zero credits available.
|
|
3775
|
+
* Must be used within CreditBalanceContextProvider (included in SaaSOSProvider by default).
|
|
3776
|
+
*
|
|
3777
|
+
* @example
|
|
3778
|
+
* ```tsx
|
|
3779
|
+
* <WhenCreditsExhausted>
|
|
3780
|
+
* <BuyCreditsPrompt message="You're out of credits!" />
|
|
3781
|
+
* </WhenCreditsExhausted>
|
|
3782
|
+
* ```
|
|
3783
|
+
*
|
|
3784
|
+
* @example
|
|
3785
|
+
* ```tsx
|
|
3786
|
+
* <WhenCreditsExhausted
|
|
3787
|
+
* loadingComponent={<Spinner />}
|
|
3788
|
+
* fallbackComponent={null}
|
|
3789
|
+
* >
|
|
3790
|
+
* <NoCreditsOverlay />
|
|
3791
|
+
* </WhenCreditsExhausted>
|
|
3792
|
+
* ```
|
|
3793
|
+
*/
|
|
3794
|
+
declare const WhenCreditsExhausted: {
|
|
3795
|
+
(props: IWhenCreditsProps): react.ReactNode;
|
|
3796
|
+
displayName: string;
|
|
3797
|
+
};
|
|
3798
|
+
/**
|
|
3799
|
+
* Renders children when credits are at or below a threshold.
|
|
3800
|
+
* Must be used within CreditBalanceContextProvider (included in SaaSOSProvider by default).
|
|
3801
|
+
*
|
|
3802
|
+
* @example
|
|
3803
|
+
* ```tsx
|
|
3804
|
+
* <WhenCreditsLow threshold={50}>
|
|
3805
|
+
* <p>Running low on credits! Consider buying more.</p>
|
|
3806
|
+
* </WhenCreditsLow>
|
|
3807
|
+
* ```
|
|
3808
|
+
*
|
|
3809
|
+
* @example
|
|
3810
|
+
* ```tsx
|
|
3811
|
+
* <WhenCreditsLow
|
|
3812
|
+
* threshold={10}
|
|
3813
|
+
* loadingComponent={<Skeleton />}
|
|
3814
|
+
* fallbackComponent={null}
|
|
3815
|
+
* >
|
|
3816
|
+
* <LowCreditsBanner />
|
|
3817
|
+
* </WhenCreditsLow>
|
|
3818
|
+
* ```
|
|
3819
|
+
*/
|
|
3820
|
+
declare const WhenCreditsLow: {
|
|
3821
|
+
(props: IWhenCreditsLowProps): react.ReactNode;
|
|
3822
|
+
displayName: string;
|
|
3823
|
+
};
|
|
3824
|
+
|
|
3175
3825
|
/**
|
|
3176
3826
|
* Value provided by SubscriptionContext and returned by useSubscriptionContext.
|
|
3177
3827
|
*/
|
|
@@ -3242,6 +3892,35 @@ declare const QuotaUsageContextProvider: react__default.FC<{
|
|
|
3242
3892
|
*/
|
|
3243
3893
|
declare function useQuotaUsageContext(): QuotaUsageContextValue;
|
|
3244
3894
|
|
|
3895
|
+
interface CreditBalanceContextValue {
|
|
3896
|
+
/** Credit balance for the current workspace. Null if not loaded or no workspace. */
|
|
3897
|
+
balance: ICreditBalance | null;
|
|
3898
|
+
/** Whether the balance is being fetched. */
|
|
3899
|
+
loading: boolean;
|
|
3900
|
+
/** Error message if the fetch failed. */
|
|
3901
|
+
error: string | null;
|
|
3902
|
+
/** Manually refetch the credit balance. */
|
|
3903
|
+
refetch: () => Promise<void>;
|
|
3904
|
+
}
|
|
3905
|
+
|
|
3906
|
+
/**
|
|
3907
|
+
* Provides credit balance data for the current workspace to credit gate components.
|
|
3908
|
+
* Fetches when workspace changes; refetches when credit balance is invalidated
|
|
3909
|
+
* (e.g. after consume or purchase).
|
|
3910
|
+
* Included in SaaSOSProvider by default.
|
|
3911
|
+
*/
|
|
3912
|
+
declare const CreditBalanceContextProvider: react__default.FC<{
|
|
3913
|
+
children: ReactNode;
|
|
3914
|
+
}>;
|
|
3915
|
+
/**
|
|
3916
|
+
* Returns credit balance data for the current workspace.
|
|
3917
|
+
* Must be used within CreditBalanceContextProvider (included in SaaSOSProvider by default).
|
|
3918
|
+
*
|
|
3919
|
+
* @returns CreditBalanceContextValue - { balance, loading, error, refetch }
|
|
3920
|
+
* @throws Error if used outside CreditBalanceContextProvider
|
|
3921
|
+
*/
|
|
3922
|
+
declare function useCreditBalanceContext(): CreditBalanceContextValue;
|
|
3923
|
+
|
|
3245
3924
|
/**
|
|
3246
3925
|
* Hook to access OS (organization) state (serverUrl, version, orgId, auth, settings).
|
|
3247
3926
|
* Prefer useSaaSSettings() when you only need settings.
|
|
@@ -3800,7 +4479,7 @@ declare const useSubscriptionManagement: (workspaceId: string | null | undefined
|
|
|
3800
4479
|
* return (
|
|
3801
4480
|
* <div>
|
|
3802
4481
|
* {invoices.map(invoice => (
|
|
3803
|
-
* <InvoiceCard key={invoice.
|
|
4482
|
+
* <InvoiceCard key={invoice.id} invoice={invoice} />
|
|
3804
4483
|
* ))}
|
|
3805
4484
|
* {hasMore && <button onClick={() => refetch()}>Load More</button>}
|
|
3806
4485
|
* </div>
|
|
@@ -3828,7 +4507,7 @@ declare const useSubscriptionManagement: (workspaceId: string | null | undefined
|
|
|
3828
4507
|
*
|
|
3829
4508
|
* return (
|
|
3830
4509
|
* <div>
|
|
3831
|
-
* {invoices.map(invoice => <InvoiceCard key={invoice.
|
|
4510
|
+
* {invoices.map(invoice => <InvoiceCard key={invoice.id} invoice={invoice} />)}
|
|
3832
4511
|
* {hasMore && <button onClick={loadMore}>Load More</button>}
|
|
3833
4512
|
* </div>
|
|
3834
4513
|
* );
|
|
@@ -4157,6 +4836,239 @@ declare const useUsageLogs: (workspaceId: string | null | undefined, quotaSlug?:
|
|
|
4157
4836
|
refetch: () => Promise<void>;
|
|
4158
4837
|
};
|
|
4159
4838
|
|
|
4839
|
+
/**
|
|
4840
|
+
* Hook to get the credit balance for a workspace.
|
|
4841
|
+
* Automatically fetches when workspaceId changes.
|
|
4842
|
+
*
|
|
4843
|
+
* @param workspaceId - The workspace ID. Can be null/undefined to disable fetching.
|
|
4844
|
+
* @returns { balance, loading, error, refetch }
|
|
4845
|
+
*
|
|
4846
|
+
* @example
|
|
4847
|
+
* ```tsx
|
|
4848
|
+
* function CreditDisplay() {
|
|
4849
|
+
* const { currentWorkspace } = useSaaSWorkspaces();
|
|
4850
|
+
* const { balance, loading } = useCreditBalance(currentWorkspace?._id);
|
|
4851
|
+
*
|
|
4852
|
+
* if (loading) return <Loading />;
|
|
4853
|
+
* if (!balance) return null;
|
|
4854
|
+
*
|
|
4855
|
+
* return <p>{balance.available} credits available</p>;
|
|
4856
|
+
* }
|
|
4857
|
+
* ```
|
|
4858
|
+
*/
|
|
4859
|
+
declare const useCreditBalance: (workspaceId: string | null | undefined) => {
|
|
4860
|
+
balance: ICreditBalance | null;
|
|
4861
|
+
loading: boolean;
|
|
4862
|
+
error: string | null;
|
|
4863
|
+
refetch: () => Promise<void>;
|
|
4864
|
+
};
|
|
4865
|
+
/**
|
|
4866
|
+
* Hook to consume credits from a workspace balance.
|
|
4867
|
+
* Returns a mutation function. Throws with `code: 'INSUFFICIENT_CREDITS'` on 402.
|
|
4868
|
+
*
|
|
4869
|
+
* @param workspaceId - The workspace ID. Can be null/undefined.
|
|
4870
|
+
* @returns { consumeCredits, loading, error }
|
|
4871
|
+
*
|
|
4872
|
+
* @example
|
|
4873
|
+
* ```tsx
|
|
4874
|
+
* function GenerateButton() {
|
|
4875
|
+
* const { currentWorkspace } = useSaaSWorkspaces();
|
|
4876
|
+
* const { consumeCredits, loading } = useConsumeCredits(currentWorkspace?._id);
|
|
4877
|
+
*
|
|
4878
|
+
* const handleGenerate = async () => {
|
|
4879
|
+
* try {
|
|
4880
|
+
* const result = await consumeCredits({
|
|
4881
|
+
* amount: 10,
|
|
4882
|
+
* description: 'AI image generation',
|
|
4883
|
+
* idempotencyKey: `gen-${crypto.randomUUID()}`,
|
|
4884
|
+
* });
|
|
4885
|
+
* console.log(`Balance after: ${result.balanceAfter}`);
|
|
4886
|
+
* } catch (err: any) {
|
|
4887
|
+
* if (err.code === 'INSUFFICIENT_CREDITS') {
|
|
4888
|
+
* alert(`Not enough credits. Available: ${err.available}`);
|
|
4889
|
+
* }
|
|
4890
|
+
* }
|
|
4891
|
+
* };
|
|
4892
|
+
*
|
|
4893
|
+
* return <button onClick={handleGenerate} disabled={loading}>Generate</button>;
|
|
4894
|
+
* }
|
|
4895
|
+
* ```
|
|
4896
|
+
*/
|
|
4897
|
+
declare const useConsumeCredits: (workspaceId: string | null | undefined) => {
|
|
4898
|
+
consumeCredits: (request: IConsumeCreditsRequest) => Promise<IConsumeCreditsResponse>;
|
|
4899
|
+
loading: boolean;
|
|
4900
|
+
error: string | null;
|
|
4901
|
+
};
|
|
4902
|
+
/**
|
|
4903
|
+
* Hook to create a Stripe checkout session for purchasing a credit package.
|
|
4904
|
+
* Returns a mutation function that resolves with { sessionId, url }.
|
|
4905
|
+
*
|
|
4906
|
+
* @param workspaceId - The workspace ID. Can be null/undefined.
|
|
4907
|
+
* @returns { purchaseCredits, loading, error }
|
|
4908
|
+
*
|
|
4909
|
+
* @example
|
|
4910
|
+
* ```tsx
|
|
4911
|
+
* function BuyCreditsButton({ packageId }) {
|
|
4912
|
+
* const { currentWorkspace } = useSaaSWorkspaces();
|
|
4913
|
+
* const { purchaseCredits, loading } = usePurchaseCredits(currentWorkspace?._id);
|
|
4914
|
+
*
|
|
4915
|
+
* const handleBuy = async () => {
|
|
4916
|
+
* const result = await purchaseCredits({
|
|
4917
|
+
* creditPackageId: packageId,
|
|
4918
|
+
* successUrl: `${window.location.origin}/credits/success`,
|
|
4919
|
+
* cancelUrl: `${window.location.origin}/credits`,
|
|
4920
|
+
* });
|
|
4921
|
+
* window.location.href = result.url;
|
|
4922
|
+
* };
|
|
4923
|
+
*
|
|
4924
|
+
* return <button onClick={handleBuy} disabled={loading}>Buy Credits</button>;
|
|
4925
|
+
* }
|
|
4926
|
+
* ```
|
|
4927
|
+
*/
|
|
4928
|
+
declare const usePurchaseCredits: (workspaceId: string | null | undefined) => {
|
|
4929
|
+
purchaseCredits: (request: ICreditPurchaseRequest) => Promise<ICreditPurchaseResponse>;
|
|
4930
|
+
loading: boolean;
|
|
4931
|
+
error: string | null;
|
|
4932
|
+
};
|
|
4933
|
+
/**
|
|
4934
|
+
* Hook to list available credit packages for purchase.
|
|
4935
|
+
* Automatically fetches when workspaceId changes.
|
|
4936
|
+
*
|
|
4937
|
+
* @param workspaceId - The workspace ID. Can be null/undefined to disable fetching.
|
|
4938
|
+
* @returns { packages, loading, error, refetch }
|
|
4939
|
+
*
|
|
4940
|
+
* @example
|
|
4941
|
+
* ```tsx
|
|
4942
|
+
* function CreditStore() {
|
|
4943
|
+
* const { currentWorkspace } = useSaaSWorkspaces();
|
|
4944
|
+
* const { packages, loading } = useCreditPackages(currentWorkspace?._id);
|
|
4945
|
+
*
|
|
4946
|
+
* if (loading) return <Loading />;
|
|
4947
|
+
*
|
|
4948
|
+
* return (
|
|
4949
|
+
* <div>
|
|
4950
|
+
* {packages.map(pkg => (
|
|
4951
|
+
* <div key={pkg._id}>
|
|
4952
|
+
* <h3>{pkg.name}</h3>
|
|
4953
|
+
* <p>{pkg.creditAmount} credits</p>
|
|
4954
|
+
* </div>
|
|
4955
|
+
* ))}
|
|
4956
|
+
* </div>
|
|
4957
|
+
* );
|
|
4958
|
+
* }
|
|
4959
|
+
* ```
|
|
4960
|
+
*/
|
|
4961
|
+
declare const useCreditPackages: (workspaceId: string | null | undefined) => {
|
|
4962
|
+
packages: ICreditPackage[];
|
|
4963
|
+
loading: boolean;
|
|
4964
|
+
error: string | null;
|
|
4965
|
+
refetch: () => Promise<void>;
|
|
4966
|
+
};
|
|
4967
|
+
/**
|
|
4968
|
+
* Hook to get paginated credit transaction history.
|
|
4969
|
+
* Automatically fetches when workspaceId or query params change.
|
|
4970
|
+
*
|
|
4971
|
+
* @param workspaceId - The workspace ID. Can be null/undefined to disable fetching.
|
|
4972
|
+
* @param query - Optional filters: type, page, limit
|
|
4973
|
+
* @returns { transactions, totalDocs, totalPages, page, hasNextPage, hasPrevPage, loading, error, refetch }
|
|
4974
|
+
*
|
|
4975
|
+
* @example
|
|
4976
|
+
* ```tsx
|
|
4977
|
+
* function TransactionHistory() {
|
|
4978
|
+
* const { currentWorkspace } = useSaaSWorkspaces();
|
|
4979
|
+
* const { transactions, totalPages, page, loading } = useCreditTransactions(
|
|
4980
|
+
* currentWorkspace?._id,
|
|
4981
|
+
* { limit: 20 }
|
|
4982
|
+
* );
|
|
4983
|
+
*
|
|
4984
|
+
* if (loading) return <Loading />;
|
|
4985
|
+
*
|
|
4986
|
+
* return (
|
|
4987
|
+
* <div>
|
|
4988
|
+
* {transactions.map(tx => (
|
|
4989
|
+
* <div key={tx._id}>
|
|
4990
|
+
* {tx.type}: {tx.amount} (balance: {tx.balanceAfter})
|
|
4991
|
+
* </div>
|
|
4992
|
+
* ))}
|
|
4993
|
+
* <p>Page {page} of {totalPages}</p>
|
|
4994
|
+
* </div>
|
|
4995
|
+
* );
|
|
4996
|
+
* }
|
|
4997
|
+
* ```
|
|
4998
|
+
*/
|
|
4999
|
+
declare const useCreditTransactions: (workspaceId: string | null | undefined, query?: ICreditTransactionsQuery) => {
|
|
5000
|
+
transactions: ICreditTransaction[];
|
|
5001
|
+
totalDocs: number;
|
|
5002
|
+
totalPages: number;
|
|
5003
|
+
page: number;
|
|
5004
|
+
hasNextPage: boolean;
|
|
5005
|
+
hasPrevPage: boolean;
|
|
5006
|
+
loading: boolean;
|
|
5007
|
+
error: string | null;
|
|
5008
|
+
refetch: () => Promise<void>;
|
|
5009
|
+
};
|
|
5010
|
+
/**
|
|
5011
|
+
* Hook to get credits expiring within N days.
|
|
5012
|
+
* Automatically fetches when workspaceId or days changes.
|
|
5013
|
+
*
|
|
5014
|
+
* @param workspaceId - The workspace ID. Can be null/undefined to disable fetching.
|
|
5015
|
+
* @param days - Look-ahead window in days (1-90, default 7)
|
|
5016
|
+
* @returns { expiringCredits, buckets, days, loading, error, refetch }
|
|
5017
|
+
*
|
|
5018
|
+
* @example
|
|
5019
|
+
* ```tsx
|
|
5020
|
+
* function ExpiringCreditsWarning() {
|
|
5021
|
+
* const { currentWorkspace } = useSaaSWorkspaces();
|
|
5022
|
+
* const { expiringCredits, loading } = useExpiringCredits(currentWorkspace?._id, 7);
|
|
5023
|
+
*
|
|
5024
|
+
* if (loading || expiringCredits === 0) return null;
|
|
5025
|
+
*
|
|
5026
|
+
* return <p>Warning: {expiringCredits} credits expire within 7 days</p>;
|
|
5027
|
+
* }
|
|
5028
|
+
* ```
|
|
5029
|
+
*/
|
|
5030
|
+
declare const useExpiringCredits: (workspaceId: string | null | undefined, days?: number) => {
|
|
5031
|
+
expiringCredits: number;
|
|
5032
|
+
buckets: ICreditBucket[];
|
|
5033
|
+
days: number;
|
|
5034
|
+
loading: boolean;
|
|
5035
|
+
error: string | null;
|
|
5036
|
+
refetch: () => Promise<void>;
|
|
5037
|
+
};
|
|
5038
|
+
/**
|
|
5039
|
+
* Hook to fetch credit packages publicly (no auth required).
|
|
5040
|
+
* Uses orgId from SaaSOSProvider — must be inside the provider.
|
|
5041
|
+
*
|
|
5042
|
+
* @returns { packages, notes, loading, error, refetch }
|
|
5043
|
+
*
|
|
5044
|
+
* @example
|
|
5045
|
+
* ```tsx
|
|
5046
|
+
* function CreditStore() {
|
|
5047
|
+
* const { packages, loading } = usePublicCreditPackages();
|
|
5048
|
+
*
|
|
5049
|
+
* if (loading) return <Loading />;
|
|
5050
|
+
*
|
|
5051
|
+
* return (
|
|
5052
|
+
* <div>
|
|
5053
|
+
* {packages.map(pkg => (
|
|
5054
|
+
* <div key={pkg._id}>
|
|
5055
|
+
* <h3>{pkg.name}</h3>
|
|
5056
|
+
* <p>{pkg.creditAmount} credits</p>
|
|
5057
|
+
* </div>
|
|
5058
|
+
* ))}
|
|
5059
|
+
* </div>
|
|
5060
|
+
* );
|
|
5061
|
+
* }
|
|
5062
|
+
* ```
|
|
5063
|
+
*/
|
|
5064
|
+
declare const usePublicCreditPackages: () => {
|
|
5065
|
+
packages: IPublicCreditPackage[];
|
|
5066
|
+
notes: string | undefined;
|
|
5067
|
+
loading: boolean;
|
|
5068
|
+
error: string | null;
|
|
5069
|
+
refetch: () => Promise<void>;
|
|
5070
|
+
};
|
|
5071
|
+
|
|
4160
5072
|
interface TrialStatus {
|
|
4161
5073
|
/** Whether the current subscription is in trial. */
|
|
4162
5074
|
isTrialing: boolean;
|
|
@@ -4368,5 +5280,5 @@ declare const PushNotificationProvider: react__default.FC<PushNotificationProvid
|
|
|
4368
5280
|
*/
|
|
4369
5281
|
declare function usePushNotifications(): PushNotificationContextValue;
|
|
4370
5282
|
|
|
4371
|
-
export { ApiVersion, AuthApi, AuthStatus, BB_PARAM, BaseApi, BetaForm, BillingIntervals, CURRENCY_DISPLAY, CURRENCY_FLAG, DEFAULT_ROLE_PERMISSIONS, DunningState, EventEmitter, InvoiceStatuses, PLAN_CURRENCY_CODES, PLAN_CURRENCY_OPTIONS, PUSH_SERVICE_WORKER_SCRIPT, Permission, PricingPage, PushApi, PushNotificationProvider, QuotaUsageContextProvider, SDKEvent, SETTINGS_SCREENS, SUPPORTED_LOCALES, SaaSOSProvider, SettingsApi, SettingsScreen, SubscriptionContextProvider, SubscriptionItemType, SubscriptionStatus, UserApi, WhenAuthenticated, WhenNoSubscription, WhenNotTrialing, WhenPermission, WhenQuotaAvailable, WhenQuotaExhausted, WhenQuotaOverage, WhenQuotaThreshold, WhenRoles, WhenSubscription, WhenSubscriptionToPlans, WhenTrialEnding, WhenTrialing, WhenUnauthenticated, WhenUserFeatureDisabled, WhenUserFeatureEnabled, WhenWorkspaceFeatureDisabled, WhenWorkspaceFeatureEnabled, WhenWorkspaceRoles, WorkspaceApi, WorkspaceSwitcher, calculateBillableSeats, calculateSeatOverageCents, calculateTotalSubscriptionCents, cleanBBParams, clearAuthIntent, consumeAuthIntent, createBBUrl, createCheckoutRedirectUrls, eventEmitter, formatCents, formatOverageRate, formatOverageRateWithLabel, formatQuotaIncludedOverage, formatQuotaWithPrice, getAvailableCurrenciesFromPlans, getBasePriceCents, getBillingIntervalAndCurrencyFromPriceId, getCurrencyFlag, getCurrencySymbol, getDisplayCurrency, getPerSeatPriceCents, getPricingVariant, getQuotaDisplayValue, getQuotaDisplayWithVariant, getQuotaOverageCents, getQuotaUnitLabelFromName, getSeatPricing, getStripePriceIdForInterval, hasPermission, invalidateQuotaUsage, invalidateSubscription, readBBParams, resolveMaxUsers, resolvePermissions, safeRedirect, saveAuthIntent, useAllQuotaUsage, useBillingPortal, useCancelSubscription, useCreateCheckoutSession, useInvoice, useInvoices, usePermissions, usePlanGroup, usePlanGroupVersions, usePublicPlanGroupVersion, usePublicPlans, usePushNotifications, useQuotaUsageContext, useQuotaUsageStatus, useRecordUsage, useResumeSubscription, useSaaSAuth, useSaaSOs, useSaaSSettings, useSaaSWorkspaces, useSeatStatus, useSubscription, useSubscriptionContext, useSubscriptionManagement, useTranslation, useTrialStatus, useUpdateSubscription, useUsageLogs, useUserAttributes, useUserFeatures, validateInvite, validateRedirectUrl };
|
|
4372
|
-
export type { BetaFormData, BetaFormResponse, BillingInterval, CheckoutResult, EventData, EventType, FormatQuotaWithPriceOptions, GetCheckoutStripeParams, IAllQuotaUsageResponse, IBaseApiConfig, IBasePricing, IBetaConfig, ICheckoutSessionRequest, ICheckoutSessionResponse, ICheckoutStripeOptions, IEventCallbacks, IInvoice, IInvoiceListResponse, IInvoiceResponse, IOsConfig, IOsState, IPlan, IPlanGroup, IPlanGroupInfo, IPlanGroupLatestVersion, IPlanGroupResponse, IPlanGroupVersion, IPlanGroupVersionWithPlans, IPlanGroupVersionsResponse, IPlanVersion, IPlanVersionSummary, IPlanVersionWithPlan, IPricingVariant, IPublicPlanItem, IPublicPlanItemCategory, IPublicPlanVersion, IPublicPlansResponse, IQuotaByInterval, IQuotaIntervalValue, IQuotaOveragePriceIdsByInterval, IQuotaOveragesByInterval, IQuotaUsageStatus, IQuotaUsageStatusResponse, IRecordUsageRequest, IRecordUsageResponse, IStripePricesByInterval, ISubscription, ISubscriptionItem, ISubscriptionResponse, ISubscriptionUpdateRequest, ISubscriptionUpdateResponse, IUsageLogEntry, IUsageLogsQuery, IUsageLogsResponse, InviteBlockReason, InviteValidation, InvoiceStatus, MaxUsersConfig, NotificationData, NotificationEvent, NotificationResult, OnWorkspaceChangeParams, PermissionContext, PermissionKey, PlanVersionWithPricingVariants, PricingPageDetails, PricingPageProps, QuotaDisplayValue, QuotaDisplayWithOverage, QuotaUsageContextValue, RolePermissionMap, SDKLocale, SDKMessages, SaaSOSProviderProps, SeatStatus, SubscriptionContextValue, SubscriptionStatusType, TrialStatus, UserCreatedEventData, UserUpdatedEventData, WorkspaceChangedEventData, WorkspaceCreatedEventData, WorkspaceDeletedEventData, WorkspaceSettingsSection, WorkspaceUpdatedEventData, WorkspaceUserAddedEventData, WorkspaceUserRemovedEventData, WorkspaceUserRoleChangedEventData };
|
|
5283
|
+
export { ApiVersion, AuthApi, AuthStatus, BBAction, BBScreen, BBStatus, BB_PARAM, BaseApi, BetaForm, BillingIntervals, CURRENCY_DISPLAY, CURRENCY_FLAG, CreditActionsProvider, CreditBalance, CreditBalanceContextProvider, CreditBucketSource, CreditBucketStatus, CreditStorePage, CreditTransactionType, DEFAULT_ROLE_PERMISSIONS, DunningState, EventEmitter, InvoiceStatuses, PLAN_CURRENCY_CODES, PLAN_CURRENCY_OPTIONS, PUSH_SERVICE_WORKER_SCRIPT, Permission, PricingPage, PushApi, PushNotificationProvider, QuotaUsageContextProvider, SDKEvent, SETTINGS_SCREENS, SUPPORTED_LOCALES, SaaSOSProvider, SettingsApi, SettingsScreen, SubscriptionContextProvider, SubscriptionItemType, SubscriptionStatus, UserApi, WhenAuthenticated, WhenCreditsAvailable, WhenCreditsExhausted, WhenCreditsLow, WhenNoSubscription, WhenNotTrialing, WhenPermission, WhenQuotaAvailable, WhenQuotaExhausted, WhenQuotaOverage, WhenQuotaThreshold, WhenRoles, WhenSubscription, WhenSubscriptionToPlans, WhenTrialEnding, WhenTrialing, WhenUnauthenticated, WhenUserFeatureDisabled, WhenUserFeatureEnabled, WhenWorkspaceFeatureDisabled, WhenWorkspaceFeatureEnabled, WhenWorkspaceRoles, WorkspaceApi, WorkspaceSwitcher, calculateBillableSeats, calculateSeatOverageCents, calculateTotalSubscriptionCents, cleanBBParams, clearAuthIntent, consumeAuthIntent, createBBUrl, createCheckoutRedirectUrls, createCreditPurchaseRedirectUrls, eventEmitter, formatCents, formatOverageRate, formatOverageRateWithLabel, formatQuotaIncludedOverage, formatQuotaWithPrice, getAvailableCurrenciesFromPlans, getBasePriceCents, getBillingIntervalAndCurrencyFromPriceId, getCurrencyFlag, getCurrencySymbol, getDisplayCurrency, getPerSeatPriceCents, getPricingVariant, getQuotaDisplayValue, getQuotaDisplayWithVariant, getQuotaOverageCents, getQuotaUnitLabelFromName, getSeatPricing, getStripePriceIdForInterval, hasPermission, invalidateCreditBalance, invalidateQuotaUsage, invalidateSubscription, readBBParams, resolveMaxUsers, resolvePermissions, safeRedirect, saveAuthIntent, useAllQuotaUsage, useBillingPortal, useCancelSubscription, useConsumeCredits, useCreateCheckoutSession, useCreditBalance, useCreditBalanceContext, useCreditPackages, useCreditTransactions, useExpiringCredits, useInvoice, useInvoices, usePermissions, usePlanGroup, usePlanGroupVersions, usePublicCreditPackages, usePublicPlanGroupVersion, usePublicPlans, usePurchaseCredits, usePushNotifications, useQuotaUsageContext, useQuotaUsageStatus, useRecordUsage, useResumeSubscription, useSaaSAuth, useSaaSOs, useSaaSSettings, useSaaSWorkspaces, useSeatStatus, useSubscription, useSubscriptionContext, useSubscriptionManagement, useTranslation, useTrialStatus, useUpdateSubscription, useUsageLogs, useUserAttributes, useUserFeatures, validateInvite, validateRedirectUrl };
|
|
5284
|
+
export type { BBActionType, BBScreenType, BBStatusType, BetaFormData, BetaFormResponse, BillingInterval, CheckoutResult, CreditActionsDetails, CreditBalanceContextValue, CreditBalanceDetails, CreditBucketSourceType, CreditBucketStatusType, CreditStorePageDetails, CreditTransactionTypeValue, DunningStateType, EventData, EventType, FormatQuotaWithPriceOptions, GetCheckoutStripeParams, IAllQuotaUsageResponse, IBaseApiConfig, IBasePricing, IBetaConfig, ICheckoutSessionRequest, ICheckoutSessionResponse, ICheckoutStripeOptions, IConsumeCreditsRequest, IConsumeCreditsResponse, ICreditBalance, ICreditBucket, ICreditBucketsQuery, ICreditBucketsResponse, ICreditPackage, ICreditPackagePricingVariant, ICreditPurchaseRequest, ICreditPurchaseResponse, ICreditTransaction, ICreditTransactionsQuery, ICreditTransactionsResponse, IEventCallbacks, IExpiringCreditsResponse, IInvoice, IInvoiceListResponse, IInvoiceResponse, IOsConfig, IOsState, IPlan, IPlanGroup, IPlanGroupInfo, IPlanGroupLatestVersion, IPlanGroupResponse, IPlanGroupVersion, IPlanGroupVersionWithPlans, IPlanGroupVersionsResponse, IPlanVersion, IPlanVersionSummary, IPlanVersionWithPlan, IPricingVariant, IPublicCreditPackage, IPublicCreditPackagesResponse, IPublicPlanItem, IPublicPlanItemCategory, IPublicPlanVersion, IPublicPlansResponse, IQuotaByInterval, IQuotaIntervalValue, IQuotaOveragePriceIdsByInterval, IQuotaOveragesByInterval, IQuotaUsageStatus, IQuotaUsageStatusResponse, IRecordUsageRequest, IRecordUsageResponse, IStripePricesByInterval, ISubscription, ISubscriptionItem, ISubscriptionResponse, ISubscriptionUpdateRequest, ISubscriptionUpdateResponse, IUsageLogEntry, IUsageLogsQuery, IUsageLogsResponse, InviteBlockReason, InviteValidation, InvoiceStatus, InvoiceStatusType, MaxUsersConfig, NotificationData, NotificationEvent, NotificationResult, OnWorkspaceChangeParams, PermissionContext, PermissionKey, PlanVersionWithPricingVariants, PricingPageDetails, PricingPageProps, QuotaDisplayValue, QuotaDisplayWithOverage, QuotaUsageContextValue, RolePermissionMap, SDKLocale, SDKMessages, SaaSOSProviderProps, SeatStatus, SubscriptionContextValue, SubscriptionItemTypeValue, SubscriptionStatusType, TrialStatus, UserCreatedEventData, UserUpdatedEventData, WorkspaceChangedEventData, WorkspaceCreatedEventData, WorkspaceDeletedEventData, WorkspaceSettingsSection, WorkspaceUpdatedEventData, WorkspaceUserAddedEventData, WorkspaceUserRemovedEventData, WorkspaceUserRoleChangedEventData };
|