@buildbase/sdk 0.0.30 → 0.0.32
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 +134 -0
- package/dist/css/styles.css +1 -1
- package/dist/css/styles.d.ts +6 -0
- package/dist/data/index.d.ts +39 -0
- package/dist/data/index.js +1 -0
- package/dist/data/index.mjs +1 -0
- package/dist/index.d.ts +280 -58
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/react/index.d.ts +796 -71
- package/dist/react/index.js +1 -35
- package/dist/react/index.mjs +1 -35
- package/package.json +99 -15
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
1
|
interface IDocument {
|
|
4
2
|
_id: string;
|
|
5
3
|
/** Optional; some APIs only return _id. Prefer _id for identity. */
|
|
@@ -52,9 +50,48 @@ interface IAsset extends IDocument {
|
|
|
52
50
|
creator: string | IUser;
|
|
53
51
|
}
|
|
54
52
|
type BillingInterval = 'monthly' | 'yearly' | 'quarterly';
|
|
53
|
+
/** Billing interval constants */
|
|
54
|
+
declare const BillingIntervals: {
|
|
55
|
+
readonly Monthly: "monthly";
|
|
56
|
+
readonly Yearly: "yearly";
|
|
57
|
+
readonly Quarterly: "quarterly";
|
|
58
|
+
};
|
|
59
|
+
/** Subscription status constants */
|
|
60
|
+
declare const SubscriptionStatus: {
|
|
61
|
+
readonly Active: "active";
|
|
62
|
+
readonly Trialing: "trialing";
|
|
63
|
+
readonly Canceled: "canceled";
|
|
64
|
+
readonly PastDue: "past_due";
|
|
65
|
+
readonly Paused: "paused";
|
|
66
|
+
readonly Incomplete: "incomplete";
|
|
67
|
+
readonly Unpaid: "unpaid";
|
|
68
|
+
};
|
|
69
|
+
type SubscriptionStatusType = (typeof SubscriptionStatus)[keyof typeof SubscriptionStatus];
|
|
70
|
+
/** Invoice status constants */
|
|
71
|
+
declare const InvoiceStatuses: {
|
|
72
|
+
readonly Draft: "draft";
|
|
73
|
+
readonly Open: "open";
|
|
74
|
+
readonly Paid: "paid";
|
|
75
|
+
readonly Uncollectible: "uncollectible";
|
|
76
|
+
readonly Void: "void";
|
|
77
|
+
};
|
|
78
|
+
/** Subscription item type constants */
|
|
79
|
+
declare const SubscriptionItemType: {
|
|
80
|
+
readonly Feature: "feature";
|
|
81
|
+
readonly Limit: "limit";
|
|
82
|
+
readonly Quota: "quota";
|
|
83
|
+
};
|
|
84
|
+
/** Dunning state constants */
|
|
85
|
+
declare const DunningState: {
|
|
86
|
+
readonly None: "none";
|
|
87
|
+
readonly Notified: "notified";
|
|
88
|
+
readonly Warning: "warning";
|
|
89
|
+
readonly Final: "final";
|
|
90
|
+
readonly Suspended: "suspended";
|
|
91
|
+
};
|
|
55
92
|
interface ISubscription {
|
|
56
93
|
_id: string;
|
|
57
|
-
subscriptionStatus:
|
|
94
|
+
subscriptionStatus: SubscriptionStatusType;
|
|
58
95
|
stripePriceId?: string;
|
|
59
96
|
stripeCurrentPeriodEnd?: string;
|
|
60
97
|
cancelAtPeriodEnd: boolean;
|
|
@@ -542,10 +579,19 @@ interface IWorkspaceUser {
|
|
|
542
579
|
role: string;
|
|
543
580
|
}
|
|
544
581
|
|
|
545
|
-
/**
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
582
|
+
/** Event type constants */
|
|
583
|
+
declare const SDKEvent: {
|
|
584
|
+
readonly UserCreated: "user:created";
|
|
585
|
+
readonly UserUpdated: "user:updated";
|
|
586
|
+
readonly WorkspaceChanged: "workspace:changed";
|
|
587
|
+
readonly WorkspaceUpdated: "workspace:updated";
|
|
588
|
+
readonly WorkspaceUserAdded: "workspace:user-added";
|
|
589
|
+
readonly WorkspaceUserRemoved: "workspace:user-removed";
|
|
590
|
+
readonly WorkspaceUserRoleChanged: "workspace:user-role-changed";
|
|
591
|
+
readonly WorkspaceCreated: "workspace:created";
|
|
592
|
+
readonly WorkspaceDeleted: "workspace:deleted";
|
|
593
|
+
};
|
|
594
|
+
type EventType = (typeof SDKEvent)[keyof typeof SDKEvent];
|
|
549
595
|
/**
|
|
550
596
|
* Event data types for each event
|
|
551
597
|
*/
|
|
@@ -646,6 +692,26 @@ interface IAuthCallbacks {
|
|
|
646
692
|
* ```
|
|
647
693
|
*/
|
|
648
694
|
getSession: () => Promise<string | null>;
|
|
695
|
+
/**
|
|
696
|
+
* Called when a session is missing, expired, or invalid.
|
|
697
|
+
* Use this to redirect to login, show a re-auth modal, or refresh the token.
|
|
698
|
+
*
|
|
699
|
+
* Triggers:
|
|
700
|
+
* - `getSession()` returns null on page refresh (cookie missing/expired)
|
|
701
|
+
* - `getProfile()` fails with 401 (session revoked server-side)
|
|
702
|
+
* - API call returns 401 during usage (session expired mid-session)
|
|
703
|
+
*
|
|
704
|
+
* @param reason - Why the session expired
|
|
705
|
+
*
|
|
706
|
+
* @example
|
|
707
|
+
* ```ts
|
|
708
|
+
* onSessionExpired: (reason) => {
|
|
709
|
+
* console.log('Session expired:', reason);
|
|
710
|
+
* router.push('/login');
|
|
711
|
+
* }
|
|
712
|
+
* ```
|
|
713
|
+
*/
|
|
714
|
+
onSessionExpired?: (reason: 'missing' | 'expired' | 'invalid') => void;
|
|
649
715
|
/**
|
|
650
716
|
* Event handler for User and Workspace events
|
|
651
717
|
* @param eventType - The type of event that occurred
|
|
@@ -665,12 +731,25 @@ interface OnWorkspaceChangeParams {
|
|
|
665
731
|
role: string | null;
|
|
666
732
|
}
|
|
667
733
|
|
|
734
|
+
type WorkspaceMode = 'personal' | 'platform';
|
|
668
735
|
interface ISettings {
|
|
669
736
|
workspace: {
|
|
670
737
|
roles: string[];
|
|
671
738
|
defaultRole: string;
|
|
672
739
|
maxWorkspaces: number;
|
|
673
740
|
maxWorkspaceUsers: number;
|
|
741
|
+
/** Workspace mode: 'personal' (solo) or 'platform' (multi-user, default) */
|
|
742
|
+
mode: WorkspaceMode;
|
|
743
|
+
/** Whether users can create workspaces. false = disabled, 'owner-only' = restricted */
|
|
744
|
+
canCreateWorkspace: boolean | 'owner-only';
|
|
745
|
+
/** Whether members can invite others. false = disabled, 'admin-only' = restricted */
|
|
746
|
+
canInviteMembers: boolean | 'admin-only';
|
|
747
|
+
/** Show workspace switcher in the UI */
|
|
748
|
+
showSwitcher: boolean;
|
|
749
|
+
/** Max workspaces a user can own. 0 = unlimited */
|
|
750
|
+
maxWorkspacesPerUser: number;
|
|
751
|
+
/** Auto-create workspace on first login */
|
|
752
|
+
autoCreateFirst: boolean;
|
|
674
753
|
};
|
|
675
754
|
[key: string]: any;
|
|
676
755
|
}
|
|
@@ -1052,6 +1131,41 @@ declare class WorkspaceApi extends BaseApi {
|
|
|
1052
1131
|
* @returns Usage result with consumed/included/available/overage
|
|
1053
1132
|
*/
|
|
1054
1133
|
recordUsage(workspaceId: string, request: IRecordUsageRequest): Promise<IRecordUsageResponse>;
|
|
1134
|
+
/**
|
|
1135
|
+
* Record multiple quota usage entries in a single request.
|
|
1136
|
+
* Designed for backend-to-backend high-volume scenarios (bulk exports, batch jobs).
|
|
1137
|
+
* Max 100 items per request.
|
|
1138
|
+
*
|
|
1139
|
+
* @example
|
|
1140
|
+
* ```ts
|
|
1141
|
+
* await api.recordUsageBatch(workspaceId, {
|
|
1142
|
+
* items: [
|
|
1143
|
+
* { quotaSlug: 'images', quantity: 500, source: 'batch-export' },
|
|
1144
|
+
* { quotaSlug: 'videos', quantity: 10, source: 'batch-export' },
|
|
1145
|
+
* ]
|
|
1146
|
+
* });
|
|
1147
|
+
* ```
|
|
1148
|
+
*/
|
|
1149
|
+
recordUsageBatch(workspaceId: string, request: {
|
|
1150
|
+
items: Array<{
|
|
1151
|
+
quotaSlug: string;
|
|
1152
|
+
quantity: number;
|
|
1153
|
+
metadata?: Record<string, any>;
|
|
1154
|
+
source?: string;
|
|
1155
|
+
idempotencyKey?: string;
|
|
1156
|
+
}>;
|
|
1157
|
+
}): Promise<{
|
|
1158
|
+
success: boolean;
|
|
1159
|
+
total: number;
|
|
1160
|
+
succeeded: number;
|
|
1161
|
+
failed: number;
|
|
1162
|
+
results: Array<{
|
|
1163
|
+
success: boolean;
|
|
1164
|
+
quotaSlug: string;
|
|
1165
|
+
quantity: number;
|
|
1166
|
+
error?: string;
|
|
1167
|
+
}>;
|
|
1168
|
+
}>;
|
|
1055
1169
|
/**
|
|
1056
1170
|
* Get usage status for a single quota
|
|
1057
1171
|
* @param workspaceId - The workspace ID
|
|
@@ -1165,6 +1279,93 @@ declare function invalidateSubscription(): void;
|
|
|
1165
1279
|
*/
|
|
1166
1280
|
declare function invalidateQuotaUsage(): void;
|
|
1167
1281
|
|
|
1282
|
+
/**
|
|
1283
|
+
* BuildBase URL parameter utilities.
|
|
1284
|
+
*
|
|
1285
|
+
* Single URL param `bb` carries comma-separated key:value pairs.
|
|
1286
|
+
* No collision with user's own URL params.
|
|
1287
|
+
*
|
|
1288
|
+
* Format: ?bb=key:value,key:value,key:value
|
|
1289
|
+
*
|
|
1290
|
+
* Reserved keys:
|
|
1291
|
+
* screen → settings section to open (subscription, users, etc.)
|
|
1292
|
+
* ws → workspace ID to switch to
|
|
1293
|
+
* action → what triggered it (checkout, billing, invite, etc.)
|
|
1294
|
+
* status → result status (success, cancel, error)
|
|
1295
|
+
*
|
|
1296
|
+
* @example
|
|
1297
|
+
* ```ts
|
|
1298
|
+
* import { createBBUrl, readBBParams, cleanBBParams } from '@buildbase/sdk'
|
|
1299
|
+
*
|
|
1300
|
+
* // After Stripe checkout
|
|
1301
|
+
* const url = createBBUrl({ action: 'checkout', status: 'success', ws: workspaceId, screen: 'subscription' })
|
|
1302
|
+
* // → https://app.com/dashboard?bb=action:checkout,status:success,ws:65abc,screen:subscription
|
|
1303
|
+
*
|
|
1304
|
+
* // Read on page load
|
|
1305
|
+
* const params = readBBParams()
|
|
1306
|
+
* // → { action: 'checkout', status: 'success', ws: '65abc', screen: 'subscription' }
|
|
1307
|
+
*
|
|
1308
|
+
* // Clean up
|
|
1309
|
+
* cleanBBParams()
|
|
1310
|
+
* ```
|
|
1311
|
+
*/
|
|
1312
|
+
/** The single URL param name used by the SDK */
|
|
1313
|
+
declare const BB_PARAM = "bb";
|
|
1314
|
+
/**
|
|
1315
|
+
* Build a URL with BuildBase params.
|
|
1316
|
+
*
|
|
1317
|
+
* @param params - Key-value pairs to encode (screen, ws, action, status, or any custom key)
|
|
1318
|
+
* @param baseUrl - Base URL (defaults to current page)
|
|
1319
|
+
*
|
|
1320
|
+
* @example
|
|
1321
|
+
* ```ts
|
|
1322
|
+
* // Stripe checkout redirect
|
|
1323
|
+
* createBBUrl({ action: 'checkout', status: 'success', ws: workspaceId, screen: 'subscription' })
|
|
1324
|
+
*
|
|
1325
|
+
* // Direct link to settings
|
|
1326
|
+
* createBBUrl({ screen: 'users' })
|
|
1327
|
+
*
|
|
1328
|
+
* // Custom data
|
|
1329
|
+
* createBBUrl({ action: 'invite', ws: workspaceId, email: 'user@example.com' })
|
|
1330
|
+
* ```
|
|
1331
|
+
*/
|
|
1332
|
+
declare function createBBUrl(params: Record<string, string>, baseUrl?: string): string;
|
|
1333
|
+
/**
|
|
1334
|
+
* Build success + cancel URL pair for Stripe checkout redirects.
|
|
1335
|
+
* Both include the workspace ID and screen:subscription.
|
|
1336
|
+
*/
|
|
1337
|
+
declare function createCheckoutRedirectUrls(workspaceId: string, baseUrl?: string): {
|
|
1338
|
+
successUrl: string;
|
|
1339
|
+
cancelUrl: string;
|
|
1340
|
+
};
|
|
1341
|
+
/**
|
|
1342
|
+
* Read the `bb` param from the current URL.
|
|
1343
|
+
* Returns null if no `bb` param is present.
|
|
1344
|
+
* Returns a plain object of key-value pairs.
|
|
1345
|
+
*
|
|
1346
|
+
* Common keys: screen, ws, action, status
|
|
1347
|
+
*/
|
|
1348
|
+
declare function readBBParams(): Record<string, string> | null;
|
|
1349
|
+
/**
|
|
1350
|
+
* Remove the `bb` param from the current URL without triggering navigation.
|
|
1351
|
+
*/
|
|
1352
|
+
declare function cleanBBParams(): void;
|
|
1353
|
+
|
|
1354
|
+
/**
|
|
1355
|
+
* Security utilities for the SDK.
|
|
1356
|
+
*/
|
|
1357
|
+
/**
|
|
1358
|
+
* Validate that a URL is safe to redirect to.
|
|
1359
|
+
* Prevents open redirect attacks by ensuring the URL uses https (or http on localhost).
|
|
1360
|
+
* Returns the URL if safe, or null if not.
|
|
1361
|
+
*/
|
|
1362
|
+
declare function validateRedirectUrl(url: string | null | undefined): string | null;
|
|
1363
|
+
/**
|
|
1364
|
+
* Safely redirect to a URL after validating it.
|
|
1365
|
+
* Falls back to fallbackUrl if the target URL is invalid.
|
|
1366
|
+
*/
|
|
1367
|
+
declare function safeRedirect(url: string | null | undefined, fallbackUrl?: string): void;
|
|
1368
|
+
|
|
1168
1369
|
/**
|
|
1169
1370
|
* Centralized formatting for subscription/quota display: cents, overage rates, included + overage text.
|
|
1170
1371
|
* Currency must be provided by the caller (e.g. workspace.billingCurrency, plan.currency, or selected currency).
|
|
@@ -1186,29 +1387,41 @@ declare const PLAN_CURRENCY_OPTIONS: {
|
|
|
1186
1387
|
}[];
|
|
1187
1388
|
/** Format cents as money string (e.g. 1999, "usd" -> "$19.99"). Caller must pass currency (e.g. from plan or workspace). */
|
|
1188
1389
|
declare function formatCents(cents: number, currency: string): string;
|
|
1390
|
+
/** Translatable labels for overage/quota formatting */
|
|
1391
|
+
interface OverageLabels {
|
|
1392
|
+
/** Singular unit fallback (default: "unit") */
|
|
1393
|
+
unit: string;
|
|
1394
|
+
/** Plural units fallback (default: "units") */
|
|
1395
|
+
units: string;
|
|
1396
|
+
/** "Included" label */
|
|
1397
|
+
included: string;
|
|
1398
|
+
/** "after that" separator */
|
|
1399
|
+
afterThat: string;
|
|
1400
|
+
/** "After included:" prefix when no included count */
|
|
1401
|
+
afterIncluded: string;
|
|
1402
|
+
}
|
|
1189
1403
|
/**
|
|
1190
1404
|
* Format overage rate for display. When unitSize > 1: "$1.00/1,000 units"; else "$1.00/unit".
|
|
1191
|
-
*
|
|
1405
|
+
* Pass `labels` for i18n support.
|
|
1192
1406
|
*/
|
|
1193
|
-
declare function formatOverageRate(overageCents: number | undefined, unitSize: number | undefined, currency: string): string | null;
|
|
1407
|
+
declare function formatOverageRate(overageCents: number | undefined, unitSize: number | undefined, currency: string, labels?: Partial<OverageLabels>): string | null;
|
|
1194
1408
|
/**
|
|
1195
1409
|
* Format overage rate with optional unit label for comparison/preview UIs.
|
|
1196
|
-
* e.g. formatOverageRateWithLabel(50, 1000, "video") -> "$0.50/1,000 videos"
|
|
1197
|
-
*
|
|
1198
|
-
* When unitLabel is omitted, falls back to formatOverageRate behavior.
|
|
1410
|
+
* e.g. formatOverageRateWithLabel(50, 1000, "video", "usd") -> "$0.50/1,000 videos"
|
|
1411
|
+
* Pass `labels` for i18n support. Pass `pluralUnitLabel` to avoid English "s" pluralization.
|
|
1199
1412
|
*/
|
|
1200
|
-
declare function formatOverageRateWithLabel(overageCents: number | undefined, unitSize: number | undefined, unitLabel: string | undefined, currency: string): string | null;
|
|
1413
|
+
declare function formatOverageRateWithLabel(overageCents: number | undefined, unitSize: number | undefined, unitLabel: string | undefined, currency: string, pluralUnitLabel?: string, labels?: Partial<OverageLabels>): string | null;
|
|
1201
1414
|
/**
|
|
1202
1415
|
* Get singular unit label from item name or slug (e.g. "Videos" -> "video", "reels" -> "reel").
|
|
1203
1416
|
* Used for quota display in comparison and preview.
|
|
1417
|
+
* Pass `fallback` for i18n unit fallback (default: "unit").
|
|
1204
1418
|
*/
|
|
1205
|
-
declare function getQuotaUnitLabelFromName(nameOrSlug: string): string;
|
|
1419
|
+
declare function getQuotaUnitLabelFromName(nameOrSlug: string, fallback?: string): string;
|
|
1206
1420
|
/**
|
|
1207
1421
|
* Format quota "included + overage" for display.
|
|
1208
|
-
*
|
|
1209
|
-
* Otherwise: "Included: 5, after that $0.30/image".
|
|
1422
|
+
* Pass `labels` and `pluralUnitLabel` for i18n support.
|
|
1210
1423
|
*/
|
|
1211
|
-
declare function formatQuotaIncludedOverage(included: number | undefined, overageCents: number | undefined, unitLabel: string, currency: string, unitSize?: number): string;
|
|
1424
|
+
declare function formatQuotaIncludedOverage(included: number | undefined, overageCents: number | undefined, unitLabel: string, currency: string, unitSize?: number, pluralUnitLabel?: string, labels?: Partial<OverageLabels>): string;
|
|
1212
1425
|
|
|
1213
1426
|
type QuotaDisplayValue = {
|
|
1214
1427
|
included: number;
|
|
@@ -1227,10 +1440,29 @@ interface FormatQuotaWithPriceOptions {
|
|
|
1227
1440
|
currencySymbol?: string;
|
|
1228
1441
|
/** Stripe currency code (e.g. 'usd', 'inr'). Used to resolve symbol when currencySymbol is not set. */
|
|
1229
1442
|
currency?: string;
|
|
1443
|
+
/**
|
|
1444
|
+
* i18n labels for quota display. When provided, used instead of hardcoded English.
|
|
1445
|
+
* Callers in React components should pass translated strings from `t()`.
|
|
1446
|
+
*/
|
|
1447
|
+
labels?: QuotaLabels;
|
|
1448
|
+
}
|
|
1449
|
+
/** Translatable labels for quota formatting */
|
|
1450
|
+
interface QuotaLabels {
|
|
1451
|
+
/** e.g. "included" — appended after count */
|
|
1452
|
+
included: string;
|
|
1453
|
+
/** e.g. "then" — separator between included and price */
|
|
1454
|
+
then: string;
|
|
1230
1455
|
}
|
|
1231
1456
|
/**
|
|
1232
|
-
* Format a quota display value as "X included, then $Y.YY / unit"
|
|
1233
|
-
*
|
|
1457
|
+
* Format a quota display value as "X included, then $Y.YY / unit".
|
|
1458
|
+
* Pass `labels` for i18n support.
|
|
1459
|
+
*
|
|
1460
|
+
* @example
|
|
1461
|
+
* formatQuotaWithPrice(value, 'videos', { currency: 'inr' })
|
|
1462
|
+
* // → "1 included, then ₹1.00 / 1,000 videos"
|
|
1463
|
+
*
|
|
1464
|
+
* formatQuotaWithPrice(value, 'वीडियो', { currency: 'inr', labels: { included: 'शामिल', then: 'फिर' } })
|
|
1465
|
+
* // → "1 शामिल, फिर ₹1.00 / 1,000 वीडियो"
|
|
1234
1466
|
*/
|
|
1235
1467
|
declare function formatQuotaWithPrice(value: QuotaDisplayValue, unitName: string, options?: FormatQuotaWithPriceOptions): string;
|
|
1236
1468
|
|
|
@@ -1331,8 +1563,10 @@ interface InviteValidation {
|
|
|
1331
1563
|
canInvite: boolean;
|
|
1332
1564
|
/** Reason the invite is blocked, or null if allowed. */
|
|
1333
1565
|
blockReason: InviteBlockReason;
|
|
1334
|
-
/**
|
|
1335
|
-
|
|
1566
|
+
/** i18n key for the block message. Resolve with t(blockMessageKey, blockMessageValues). */
|
|
1567
|
+
blockMessageKey: string | null;
|
|
1568
|
+
/** Values for ICU interpolation in the block message. */
|
|
1569
|
+
blockMessageValues: Record<string, string | number> | null;
|
|
1336
1570
|
}
|
|
1337
1571
|
/**
|
|
1338
1572
|
* Validate whether a new member can be invited given current seat/user limits.
|
|
@@ -1360,41 +1594,6 @@ declare function validateInvite(opts: {
|
|
|
1360
1594
|
*/
|
|
1361
1595
|
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 var payload = event.data.json();\n var title = payload.title || 'Notification';\n var 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 var 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 (var i = 0; i < clientList.length; i++) {\n var 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";
|
|
1362
1596
|
|
|
1363
|
-
declare const countries: {
|
|
1364
|
-
value: string;
|
|
1365
|
-
flag: string;
|
|
1366
|
-
text: string;
|
|
1367
|
-
currencyCode: string;
|
|
1368
|
-
currencyIcon: string;
|
|
1369
|
-
}[];
|
|
1370
|
-
|
|
1371
|
-
declare const uniqueCurrencies: {
|
|
1372
|
-
value: string;
|
|
1373
|
-
text: string;
|
|
1374
|
-
icon: any;
|
|
1375
|
-
}[];
|
|
1376
|
-
|
|
1377
|
-
declare const languages: {
|
|
1378
|
-
value: string;
|
|
1379
|
-
label: string;
|
|
1380
|
-
flag: string;
|
|
1381
|
-
}[];
|
|
1382
|
-
|
|
1383
|
-
declare const timezones: {
|
|
1384
|
-
value: string;
|
|
1385
|
-
abbr: string;
|
|
1386
|
-
offset: number;
|
|
1387
|
-
isdst: boolean;
|
|
1388
|
-
text: string;
|
|
1389
|
-
utc: string[];
|
|
1390
|
-
}[];
|
|
1391
|
-
|
|
1392
|
-
declare const formSchema: z.ZodObject<{
|
|
1393
|
-
name: z.ZodString;
|
|
1394
|
-
email: z.ZodString;
|
|
1395
|
-
}, z.core.$strip>;
|
|
1396
|
-
type formValuesType = z.infer<typeof formSchema>;
|
|
1397
|
-
|
|
1398
1597
|
interface BetaFormData {
|
|
1399
1598
|
name?: string;
|
|
1400
1599
|
email: string;
|
|
@@ -1585,8 +1784,31 @@ interface InvoiceActions {
|
|
|
1585
1784
|
list(workspaceId: string, limit?: number, startingAfter?: string): Promise<IInvoiceListResponse>;
|
|
1586
1785
|
get(workspaceId: string, invoiceId: string): Promise<IInvoiceResponse>;
|
|
1587
1786
|
}
|
|
1787
|
+
interface UsageBatchRequest {
|
|
1788
|
+
items: Array<{
|
|
1789
|
+
quotaSlug: string;
|
|
1790
|
+
quantity: number;
|
|
1791
|
+
metadata?: Record<string, any>;
|
|
1792
|
+
source?: string;
|
|
1793
|
+
idempotencyKey?: string;
|
|
1794
|
+
}>;
|
|
1795
|
+
}
|
|
1796
|
+
interface UsageBatchResponse {
|
|
1797
|
+
success: boolean;
|
|
1798
|
+
total: number;
|
|
1799
|
+
succeeded: number;
|
|
1800
|
+
failed: number;
|
|
1801
|
+
results: Array<{
|
|
1802
|
+
success: boolean;
|
|
1803
|
+
quotaSlug: string;
|
|
1804
|
+
quantity: number;
|
|
1805
|
+
error?: string;
|
|
1806
|
+
}>;
|
|
1807
|
+
}
|
|
1588
1808
|
interface UsageActions {
|
|
1589
1809
|
record(workspaceId: string, request: IRecordUsageRequest): Promise<IRecordUsageResponse>;
|
|
1810
|
+
/** Record multiple usage entries in one request. Max 100 items. For bulk/batch operations. */
|
|
1811
|
+
recordBatch(workspaceId: string, request: UsageBatchRequest): Promise<UsageBatchResponse>;
|
|
1590
1812
|
getQuota(workspaceId: string, quotaSlug: string): Promise<IQuotaUsageStatusResponse>;
|
|
1591
1813
|
getAll(workspaceId: string): Promise<IAllQuotaUsageResponse>;
|
|
1592
1814
|
getLogs(workspaceId: string, query?: IUsageLogsQuery): Promise<IUsageLogsResponse>;
|
|
@@ -1656,5 +1878,5 @@ interface BuildBaseResult extends ScopedActions {
|
|
|
1656
1878
|
}
|
|
1657
1879
|
declare function BuildBase(config: BuildBaseConfig): BuildBaseResult;
|
|
1658
1880
|
|
|
1659
|
-
export { ApiVersion, AuthApi, AuthStatus, BaseApi, BetaForm, BuildBase, CURRENCY_DISPLAY, CURRENCY_FLAG, EventEmitter, PLAN_CURRENCY_CODES, PLAN_CURRENCY_OPTIONS, PUSH_SERVICE_WORKER_SCRIPT, PushApi, SettingsApi,
|
|
1660
|
-
export type { BetaFormData, BetaFormResponse,
|
|
1881
|
+
export { ApiVersion, AuthApi, AuthStatus, BB_PARAM, BaseApi, BetaForm, BillingIntervals, BuildBase, CURRENCY_DISPLAY, CURRENCY_FLAG, DunningState, EventEmitter, InvoiceStatuses, PLAN_CURRENCY_CODES, PLAN_CURRENCY_OPTIONS, PUSH_SERVICE_WORKER_SCRIPT, PushApi, SDKEvent, SettingsApi, SubscriptionItemType, SubscriptionStatus, UserApi, WorkspaceApi, calculateBillableSeats, calculateSeatOverageCents, calculateTotalSubscriptionCents, cleanBBParams, createBBUrl, createCheckoutRedirectUrls, BuildBase as default, eventEmitter, formatCents, formatOverageRate, formatOverageRateWithLabel, formatQuotaIncludedOverage, formatQuotaWithPrice, getAvailableCurrenciesFromPlans, getBasePriceCents, getBillingIntervalAndCurrencyFromPriceId, getCurrencyFlag, getCurrencySymbol, getDisplayCurrency, getPerSeatPriceCents, getPricingVariant, getQuotaDisplayValue, getQuotaDisplayWithVariant, getQuotaOverageCents, getQuotaUnitLabelFromName, getSeatPricing, getStripePriceIdForInterval, invalidateQuotaUsage, invalidateSubscription, readBBParams, resolveMaxUsers, safeRedirect, validateInvite, validateRedirectUrl };
|
|
1882
|
+
export type { BetaFormData, BetaFormResponse, BillingInterval, BuildBaseConfig, BuildBaseResult, BuildBaseSession, CheckoutResult, EventData, EventType, FeatureActions, FormatQuotaWithPriceOptions, IAllQuotaUsageResponse, IBaseApiConfig, IBasePricing, IBetaConfig, ICheckoutSessionRequest, ICheckoutSessionResponse, 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, InvoiceActions, InvoiceStatus, MaxUsersConfig, OnWorkspaceChangeParams, PlanActions, PlanVersionWithPricingVariants, QuotaDisplayValue, QuotaDisplayWithOverage, ScopedActions, SettingsActions, SubscriptionActions, SubscriptionStatusType, UsageActions, UserActions, UserCreatedEventData, UserUpdatedEventData, WorkspaceActions, WorkspaceChangedEventData, WorkspaceCreatedEventData, WorkspaceDeletedEventData, WorkspaceUpdatedEventData, WorkspaceUserAddedEventData, WorkspaceUserRemovedEventData, WorkspaceUserRoleChangedEventData };
|