@streamoid/settings 0.25.1 → 0.26.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.mts +51 -1
- package/dist/index.d.ts +51 -1
- package/dist/index.js +110 -6
- package/dist/index.mjs +110 -6
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1306,6 +1306,20 @@ interface SettingsApiAdapter {
|
|
|
1306
1306
|
/** Save it and return the new view. Turning it on rejects with code
|
|
1307
1307
|
* `NO_ACTIVE_SUBSCRIPTION`, `NO_PAYMENT_METHOD` or `UNSUPPORTED_CURRENCY`. */
|
|
1308
1308
|
setAutoTopUp?: (input: AutoTopUpSettings) => Promise<AutoTopUpView>;
|
|
1309
|
+
/** Start adding or replacing the card auto top-up charges (it also becomes
|
|
1310
|
+
* the subscription's card). Resolves with a Stripe Checkout URL the card
|
|
1311
|
+
* navigates to; `successUrl` and `cancelUrl` are the current page with
|
|
1312
|
+
* `card_setup` params, so pass them through unchanged. Admins only, like
|
|
1313
|
+
* `fetchAutoTopUp`. When omitted, there is no "Add card" / "Update card". */
|
|
1314
|
+
startAutoTopUpCardSetup?: (input: {
|
|
1315
|
+
successUrl: string;
|
|
1316
|
+
cancelUrl: string;
|
|
1317
|
+
}) => Promise<{
|
|
1318
|
+
url: string;
|
|
1319
|
+
}>;
|
|
1320
|
+
/** Make the card a completed setup session saved the default, and return
|
|
1321
|
+
* the new view. The card calls it when the page loads back from Stripe. */
|
|
1322
|
+
confirmAutoTopUpCardSetup?: (sessionId: string) => Promise<AutoTopUpView>;
|
|
1309
1323
|
/**
|
|
1310
1324
|
* Who this workspace shares its credits with, or whose it spends. When
|
|
1311
1325
|
* omitted, Billing hides the "Shared credits" entry.
|
|
@@ -2862,6 +2876,37 @@ declare function autoTopUpCycleText(view: Pick<AutoTopUpView, "spentThisCycleCre
|
|
|
2862
2876
|
* leaves the setting on.
|
|
2863
2877
|
*/
|
|
2864
2878
|
declare function autoTopUpCapNotice(view: Pick<AutoTopUpView, "enabled" | "lastAttempt" | "cycle" | "spentThisCycleCredits" | "packCredits" | "cycleCapCredits">, now?: Date): string | null;
|
|
2879
|
+
/**
|
|
2880
|
+
* Which card button the card shows: "add" with no card on file, "update"
|
|
2881
|
+
* beside the one shown, `null` without a paid plan (no Stripe customer to
|
|
2882
|
+
* save a card to).
|
|
2883
|
+
*/
|
|
2884
|
+
declare function autoTopUpCardAction(view: Pick<AutoTopUpView, "paidPlan" | "paymentMethod">): "add" | "update" | null;
|
|
2885
|
+
declare const CARD_SETUP_PARAM = "card_setup";
|
|
2886
|
+
declare const CARD_SETUP_SESSION_PARAM = "session_id";
|
|
2887
|
+
/**
|
|
2888
|
+
* Where Stripe returns to from adding a card: the page at `href`. The
|
|
2889
|
+
* session placeholder is appended as text, since URLSearchParams would
|
|
2890
|
+
* percent-encode its braces and Stripe would no longer replace it.
|
|
2891
|
+
*/
|
|
2892
|
+
declare function cardSetupReturnUrls(href: string): {
|
|
2893
|
+
successUrl: string;
|
|
2894
|
+
cancelUrl: string;
|
|
2895
|
+
};
|
|
2896
|
+
type CardSetupReturn = {
|
|
2897
|
+
status: "success";
|
|
2898
|
+
sessionId: string;
|
|
2899
|
+
cleanHref: string;
|
|
2900
|
+
} | {
|
|
2901
|
+
status: "cancelled";
|
|
2902
|
+
cleanHref: string;
|
|
2903
|
+
};
|
|
2904
|
+
/**
|
|
2905
|
+
* What a page loaded at `href` came back from, or `null` when it did not
|
|
2906
|
+
* come back from adding a card. `cleanHref` is the page without the params,
|
|
2907
|
+
* to replace the address with so a reload doesn't confirm again.
|
|
2908
|
+
*/
|
|
2909
|
+
declare function readCardSetupReturn(href: string): CardSetupReturn | null;
|
|
2865
2910
|
|
|
2866
2911
|
/**
|
|
2867
2912
|
* Auto top-up: when credits fall below a threshold, billing buys the chosen
|
|
@@ -2869,6 +2914,11 @@ declare function autoTopUpCapNotice(view: Pick<AutoTopUpView, "enabled" | "lastA
|
|
|
2869
2914
|
* it only for workspace or org admins. Renders nothing when the host has no
|
|
2870
2915
|
* `api.fetchAutoTopUp`. `onTopUpSettled` runs when a top-up the card watched
|
|
2871
2916
|
* finishes, so the host can reload the balance.
|
|
2917
|
+
*
|
|
2918
|
+
* With `api.startAutoTopUpCardSetup` it offers "Add card" / "Update card",
|
|
2919
|
+
* which goes to Stripe Checkout and back to this page; on the way back it
|
|
2920
|
+
* confirms the session through `api.confirmAutoTopUpCardSetup` and shows
|
|
2921
|
+
* the new card.
|
|
2872
2922
|
*/
|
|
2873
2923
|
declare function AutoTopUpCard({ onTopUpSettled }?: {
|
|
2874
2924
|
onTopUpSettled?: () => void;
|
|
@@ -3304,4 +3354,4 @@ interface AppSettingsRowProps {
|
|
|
3304
3354
|
}
|
|
3305
3355
|
declare function AppSettingsRow({ title, description, summary, href, onClick, disabled, disabledReason, ariaLabel, trailing }: AppSettingsRowProps): react.JSX.Element;
|
|
3306
3356
|
|
|
3307
|
-
export { APP_KEYS, AUTO_TOPUP_DEFAULTS, type AddCreditPoolMemberInput, AdministrationOverview, type AdministrationOverviewProps, type AdministrativeNavigationOptions, type ApiToken, type AppKey, AppSettingsHeader, type AppSettingsHeaderProps, AppSettingsPage, type AppSettingsPageProps, AppSettingsRow, type AppSettingsRowProps, AppSettingsSection, type AppSettingsSectionProps, AutoTopUpCard, type AutoTopUpSettings, type AutoTopUpValidation, type AutoTopUpView, type AvailableCreditsResponse, BILLING_TABLE_FRAME_STYLE, BILLING_TABLE_MIN_HEIGHT, BILLING_TABLE_PAGER_STYLE, BillingContent, type BillingEntitlement, type BillingEventPayload, type BillingProduct, type BillingSubscription, BuyCreditsModal, type BuyCreditsPayload, type BuyCreditsResponse, ConfirmDeleteModal, ConfirmLeaveModal, type ConnectedApp, ConnectedAppsContent, type CreatedToken, type CreditCycleUnit, type CreditLimitUnit, type CreditLimitValidation, type CreditPoolCandidate, type CreditPoolFormerMember, type CreditPoolMember, CreditPoolMemberModal, type CreditPoolMemberModalProps, type CreditPoolMemberStatus, type CreditPoolMode, type CreditPoolResponse, type CreditPoolSelfShare, type CreditsMeter, type CurrentPlanState, type CustomCreditInfo, type CustomCreditResponse, DEFAULT_PERMISSIONS, DEFAULT_USER_LANGUAGE, EMPTY_USAGE_LOGS_PAGE, ExportDateModal, type FetchUsageLogs, type FetchUsageLogsInRangeOptions, INITIAL_USAGE_LOGS_STATE, INVOICE_DOWNLOAD_FAILED_MESSAGE, INVOICE_NOT_AVAILABLE_MESSAGE, InviteUpdateModal, type InvoiceDownloadKind, type InvoicePdfResponse, type LoginMethodsMember, type LoginMethodsSettings, type LoginMethodsSwitchState, MOCK_REFERRED_USERS, type MemberCreditLimit, MemberCreditLimitModal, type MemberCreditLimitRow, type MemberCreditLimitSource, type MemberCreditLimitsResponse, MemberListFrame, type MemberListFrameProps, type MemberListTab, MemberListToolbar, type MemberListToolbarProps, type MemberPermissionsPayload, OrganizationContent, type OrganizationData, type OrganizationDetails, OrganizationIntegrationsContent, type OrganizationInvite, type OrganizationJoinRequest, type OrganizationJoinableWorkspace, OrganizationLoginMethodsContent, type OrganizationMember, OrganizationMemberModal, type OrganizationMemberModalProps, type OrganizationMemberRole, OrganizationModal, OrganizationPicker, type OrganizationPickerItem, type OrganizationPickerProps, type OrganizationPickerType, type OrganizationView, type OrganizationWorkspaceItem, POOL_ERROR_CODES, POOL_EXPIRY_MAX_MONTHS, POOL_NOTE_MAX_LENGTH, PerUserLimitsView, type PoolEndsAtResult, type PoolErrorCode, type PoolExpiryChoice, type PoolValueValidation, type Price, type PriceMetadata, type ProductsResponse, ProfileAvatar, ProfileTab, REMOVE_REASON_MAX_LENGTH, ReferralHistoryView, type ReferralHistoryViewProps, ReferralTab, type ReferredUser, RemovePoolMemberModal, type RemovePoolMemberModalProps, RemoveSelfShareModal, type RemoveSelfShareModalProps, SCOPE_LABELS, ScopeHeader, type ScopeHeaderProps, type ServiceItem, type SetCreditPoolSelfShareInput, type SettingsAdapters, SettingsAdaptersProvider, type SettingsApiAdapter, type SettingsAuthAdapter, type SettingsAuthUser, SettingsContent, type SettingsContentProps, type SettingsImageUploadAdapter, type SettingsIntegrationsAdapter, type SettingsLoginMethodsAdapter, type SettingsNavigationAdapter, type SettingsOrganizationAdapter, type SettingsOrganizationCreateOptions, type SettingsOrganizationCurrent, type SettingsOrganizationJoinableItem, type SettingsOrganizationListItem, type SettingsOrganizationType, type SettingsOrganizationWorkspaceJoin, type SettingsScope, type SettingsTab, type SettingsToastAdapter, SettingsTooltip, type SettingsTooltipPlacement, type SettingsTooltipProps, type SettingsWorkspaceAdapter, type SettingsWorkspaceCurrent, type SettingsWorkspaceListItem, SharedCreditsView, type SharedPoolBalance, SiconKey, type SponsorShareBalance, type StoreItem, type SubscriptionPlan, type SubscriptionResponse, TAB_DESCRIPTIONS, TAB_LABELS, TAB_SCOPE, TAB_TO_URL, type TeamMember, TeamsContent, type TokenExpiry, TokensContent, URL_TO_TAB, USAGE_LOGS_EXPORT_BATCH_SIZE, USAGE_LOGS_EXPORT_EXTRA_REQUESTS, USAGE_LOGS_EXPORT_MAX_ROWS, USAGE_LOGS_PAGE_SIZE, USER_LANGUAGES, type UpdateCreditPoolMemberInput, type UpdateSubscriptionPayload, type UpdateSubscriptionResponse, type UsageHistoryItem, type UsageHistoryPagination, type UsageHistoryResponse, type UsageLogsAction, type UsageLogsExportResult, type UsageLogsPage, UsageLogsPager, type UsageLogsQuery, type UsageLogsState, UsageLogsTable, type UsedByNamesLoader, type UserLanguage, type UserPermissions, WORKSPACE_CREDIT_LIMIT_REACHED, WORKSPACE_CREDIT_LIMIT_REACHED_MESSAGE, WORKSPACE_LIST_PAGE_SIZE, type WorkspaceCreditLimit, WorkspaceCreditLimitCard, type WorkspaceCreditLimitSummary, type WorkspaceData, WorkspaceGeneralTab, type WorkspaceGeneralTabProps, type WorkspaceInvite, type WorkspaceListOrganization, WorkspaceListTab, type WorkspaceMember, WorkspaceModal, type WorkspaceOrganization, type WorkspaceOrganizationRequest, WorkspacePicker, type WorkspacePickerGroup, type WorkspacePickerItem, type WorkspacePickerProps, WorkspaceTab, type WorkspaceUsageResponse, aboveTotalReason, autoTopUpBlockedReason, autoTopUpCapNotice, autoTopUpCycleText, autoTopUpDisabledMessage, belowUsageReason, canManageOnlyWorkspaceCreditLimit, canShowSharedCredits, capMoney, checkPoolPercentTotal, cleanAutoTopUpInput, cleanCreditLimitInput, cleanPoolValueInput, countLabel, createUsedByNamesLoader, creditCycleUnit, creditsMeter, deriveWorkspaceInvitePermission, describeAllowance, describeDefaultLimit, describeMemberLimit, describeWorkspaceCreditLimit, entitlementFromBody, entitlementFromFailure, expiryChoiceFor, fetchUsageLogsInRange, findBillingError, findPoolError, formatAutoTopUpMoney, formatCreditLimit, formatCredits, formatPackOption, formatPoolEndsAt, formatPoolSplit, groupWorkspaceList, hasPaidFeatures, inviteUpdate, invoiceDownloadKind, isLimitAboveTotal, isLimitBelowUsage, isPaidPlan, isSponsoredEntitlement, isWorkspaceCreditLimitReached, joinMembersWithLimits, lastUsedLabel, limitAboveTotalTotal, limitBelowUsageUsed, limitSourceLabel, loadCurrentPlan, loadWorkspaceOrganization, loginMethodsSwitchState, maximumCreditLimit, memberRoleUpdate, minPoolEndDate, minimumCreditLimit, ownCreditsFirstText, parseBillingEntitlement, parseInviteEmails, pausedOwnCreditsText, poolAllocatedPercent, poolAllocationText, poolEndsAtFrom, poolErrorMessage, poolRenewsAtCycleEnd, poolSharesCredits, poolUnallocatedPercent, poolWorkspaceName, productsForCountry, readSettingsCaller, referralCodeOf, referralCountLabel, referralLink, referralSignupDate, rememberSettingsCaller, resolveSettingsTabFromPath, roundCredits, settingsReturnTarget, sharedPoolBannerText, sharedPoolEndsText, sliceUsageLogsPage, sortReferredUsers, sponsorShareBannerText, sponsorShareDetailText, sponsorShareSpentText, sponsoredCreditsText, ssoLabel, toCsv, toLocalDateInput, usageLogsCsvRows, usageLogsDateRange, usageLogsExportFileName, usageLogsPage, usageLogsReducer, usageLogsReloadPage, usageLogsShowWorkspace, usageLogsSpentByOthers, useBillingEntitlement, useSettingsAdapters, useWorkspaceInvitePermission, useWorkspaceOrganization, usedByNamesFrom, usedByWorkspaceKey, userLanguageLabel, validateAutoTopUpInput, validateCreditLimitInput, validateDefaultCreditLimitInput, validatePoolText, validatePoolValue };
|
|
3357
|
+
export { APP_KEYS, AUTO_TOPUP_DEFAULTS, type AddCreditPoolMemberInput, AdministrationOverview, type AdministrationOverviewProps, type AdministrativeNavigationOptions, type ApiToken, type AppKey, AppSettingsHeader, type AppSettingsHeaderProps, AppSettingsPage, type AppSettingsPageProps, AppSettingsRow, type AppSettingsRowProps, AppSettingsSection, type AppSettingsSectionProps, AutoTopUpCard, type AutoTopUpSettings, type AutoTopUpValidation, type AutoTopUpView, type AvailableCreditsResponse, BILLING_TABLE_FRAME_STYLE, BILLING_TABLE_MIN_HEIGHT, BILLING_TABLE_PAGER_STYLE, BillingContent, type BillingEntitlement, type BillingEventPayload, type BillingProduct, type BillingSubscription, BuyCreditsModal, type BuyCreditsPayload, type BuyCreditsResponse, CARD_SETUP_PARAM, CARD_SETUP_SESSION_PARAM, type CardSetupReturn, ConfirmDeleteModal, ConfirmLeaveModal, type ConnectedApp, ConnectedAppsContent, type CreatedToken, type CreditCycleUnit, type CreditLimitUnit, type CreditLimitValidation, type CreditPoolCandidate, type CreditPoolFormerMember, type CreditPoolMember, CreditPoolMemberModal, type CreditPoolMemberModalProps, type CreditPoolMemberStatus, type CreditPoolMode, type CreditPoolResponse, type CreditPoolSelfShare, type CreditsMeter, type CurrentPlanState, type CustomCreditInfo, type CustomCreditResponse, DEFAULT_PERMISSIONS, DEFAULT_USER_LANGUAGE, EMPTY_USAGE_LOGS_PAGE, ExportDateModal, type FetchUsageLogs, type FetchUsageLogsInRangeOptions, INITIAL_USAGE_LOGS_STATE, INVOICE_DOWNLOAD_FAILED_MESSAGE, INVOICE_NOT_AVAILABLE_MESSAGE, InviteUpdateModal, type InvoiceDownloadKind, type InvoicePdfResponse, type LoginMethodsMember, type LoginMethodsSettings, type LoginMethodsSwitchState, MOCK_REFERRED_USERS, type MemberCreditLimit, MemberCreditLimitModal, type MemberCreditLimitRow, type MemberCreditLimitSource, type MemberCreditLimitsResponse, MemberListFrame, type MemberListFrameProps, type MemberListTab, MemberListToolbar, type MemberListToolbarProps, type MemberPermissionsPayload, OrganizationContent, type OrganizationData, type OrganizationDetails, OrganizationIntegrationsContent, type OrganizationInvite, type OrganizationJoinRequest, type OrganizationJoinableWorkspace, OrganizationLoginMethodsContent, type OrganizationMember, OrganizationMemberModal, type OrganizationMemberModalProps, type OrganizationMemberRole, OrganizationModal, OrganizationPicker, type OrganizationPickerItem, type OrganizationPickerProps, type OrganizationPickerType, type OrganizationView, type OrganizationWorkspaceItem, POOL_ERROR_CODES, POOL_EXPIRY_MAX_MONTHS, POOL_NOTE_MAX_LENGTH, PerUserLimitsView, type PoolEndsAtResult, type PoolErrorCode, type PoolExpiryChoice, type PoolValueValidation, type Price, type PriceMetadata, type ProductsResponse, ProfileAvatar, ProfileTab, REMOVE_REASON_MAX_LENGTH, ReferralHistoryView, type ReferralHistoryViewProps, ReferralTab, type ReferredUser, RemovePoolMemberModal, type RemovePoolMemberModalProps, RemoveSelfShareModal, type RemoveSelfShareModalProps, SCOPE_LABELS, ScopeHeader, type ScopeHeaderProps, type ServiceItem, type SetCreditPoolSelfShareInput, type SettingsAdapters, SettingsAdaptersProvider, type SettingsApiAdapter, type SettingsAuthAdapter, type SettingsAuthUser, SettingsContent, type SettingsContentProps, type SettingsImageUploadAdapter, type SettingsIntegrationsAdapter, type SettingsLoginMethodsAdapter, type SettingsNavigationAdapter, type SettingsOrganizationAdapter, type SettingsOrganizationCreateOptions, type SettingsOrganizationCurrent, type SettingsOrganizationJoinableItem, type SettingsOrganizationListItem, type SettingsOrganizationType, type SettingsOrganizationWorkspaceJoin, type SettingsScope, type SettingsTab, type SettingsToastAdapter, SettingsTooltip, type SettingsTooltipPlacement, type SettingsTooltipProps, type SettingsWorkspaceAdapter, type SettingsWorkspaceCurrent, type SettingsWorkspaceListItem, SharedCreditsView, type SharedPoolBalance, SiconKey, type SponsorShareBalance, type StoreItem, type SubscriptionPlan, type SubscriptionResponse, TAB_DESCRIPTIONS, TAB_LABELS, TAB_SCOPE, TAB_TO_URL, type TeamMember, TeamsContent, type TokenExpiry, TokensContent, URL_TO_TAB, USAGE_LOGS_EXPORT_BATCH_SIZE, USAGE_LOGS_EXPORT_EXTRA_REQUESTS, USAGE_LOGS_EXPORT_MAX_ROWS, USAGE_LOGS_PAGE_SIZE, USER_LANGUAGES, type UpdateCreditPoolMemberInput, type UpdateSubscriptionPayload, type UpdateSubscriptionResponse, type UsageHistoryItem, type UsageHistoryPagination, type UsageHistoryResponse, type UsageLogsAction, type UsageLogsExportResult, type UsageLogsPage, UsageLogsPager, type UsageLogsQuery, type UsageLogsState, UsageLogsTable, type UsedByNamesLoader, type UserLanguage, type UserPermissions, WORKSPACE_CREDIT_LIMIT_REACHED, WORKSPACE_CREDIT_LIMIT_REACHED_MESSAGE, WORKSPACE_LIST_PAGE_SIZE, type WorkspaceCreditLimit, WorkspaceCreditLimitCard, type WorkspaceCreditLimitSummary, type WorkspaceData, WorkspaceGeneralTab, type WorkspaceGeneralTabProps, type WorkspaceInvite, type WorkspaceListOrganization, WorkspaceListTab, type WorkspaceMember, WorkspaceModal, type WorkspaceOrganization, type WorkspaceOrganizationRequest, WorkspacePicker, type WorkspacePickerGroup, type WorkspacePickerItem, type WorkspacePickerProps, WorkspaceTab, type WorkspaceUsageResponse, aboveTotalReason, autoTopUpBlockedReason, autoTopUpCapNotice, autoTopUpCardAction, autoTopUpCycleText, autoTopUpDisabledMessage, belowUsageReason, canManageOnlyWorkspaceCreditLimit, canShowSharedCredits, capMoney, cardSetupReturnUrls, checkPoolPercentTotal, cleanAutoTopUpInput, cleanCreditLimitInput, cleanPoolValueInput, countLabel, createUsedByNamesLoader, creditCycleUnit, creditsMeter, deriveWorkspaceInvitePermission, describeAllowance, describeDefaultLimit, describeMemberLimit, describeWorkspaceCreditLimit, entitlementFromBody, entitlementFromFailure, expiryChoiceFor, fetchUsageLogsInRange, findBillingError, findPoolError, formatAutoTopUpMoney, formatCreditLimit, formatCredits, formatPackOption, formatPoolEndsAt, formatPoolSplit, groupWorkspaceList, hasPaidFeatures, inviteUpdate, invoiceDownloadKind, isLimitAboveTotal, isLimitBelowUsage, isPaidPlan, isSponsoredEntitlement, isWorkspaceCreditLimitReached, joinMembersWithLimits, lastUsedLabel, limitAboveTotalTotal, limitBelowUsageUsed, limitSourceLabel, loadCurrentPlan, loadWorkspaceOrganization, loginMethodsSwitchState, maximumCreditLimit, memberRoleUpdate, minPoolEndDate, minimumCreditLimit, ownCreditsFirstText, parseBillingEntitlement, parseInviteEmails, pausedOwnCreditsText, poolAllocatedPercent, poolAllocationText, poolEndsAtFrom, poolErrorMessage, poolRenewsAtCycleEnd, poolSharesCredits, poolUnallocatedPercent, poolWorkspaceName, productsForCountry, readCardSetupReturn, readSettingsCaller, referralCodeOf, referralCountLabel, referralLink, referralSignupDate, rememberSettingsCaller, resolveSettingsTabFromPath, roundCredits, settingsReturnTarget, sharedPoolBannerText, sharedPoolEndsText, sliceUsageLogsPage, sortReferredUsers, sponsorShareBannerText, sponsorShareDetailText, sponsorShareSpentText, sponsoredCreditsText, ssoLabel, toCsv, toLocalDateInput, usageLogsCsvRows, usageLogsDateRange, usageLogsExportFileName, usageLogsPage, usageLogsReducer, usageLogsReloadPage, usageLogsShowWorkspace, usageLogsSpentByOthers, useBillingEntitlement, useSettingsAdapters, useWorkspaceInvitePermission, useWorkspaceOrganization, usedByNamesFrom, usedByWorkspaceKey, userLanguageLabel, validateAutoTopUpInput, validateCreditLimitInput, validateDefaultCreditLimitInput, validatePoolText, validatePoolValue };
|
package/dist/index.d.ts
CHANGED
|
@@ -1306,6 +1306,20 @@ interface SettingsApiAdapter {
|
|
|
1306
1306
|
/** Save it and return the new view. Turning it on rejects with code
|
|
1307
1307
|
* `NO_ACTIVE_SUBSCRIPTION`, `NO_PAYMENT_METHOD` or `UNSUPPORTED_CURRENCY`. */
|
|
1308
1308
|
setAutoTopUp?: (input: AutoTopUpSettings) => Promise<AutoTopUpView>;
|
|
1309
|
+
/** Start adding or replacing the card auto top-up charges (it also becomes
|
|
1310
|
+
* the subscription's card). Resolves with a Stripe Checkout URL the card
|
|
1311
|
+
* navigates to; `successUrl` and `cancelUrl` are the current page with
|
|
1312
|
+
* `card_setup` params, so pass them through unchanged. Admins only, like
|
|
1313
|
+
* `fetchAutoTopUp`. When omitted, there is no "Add card" / "Update card". */
|
|
1314
|
+
startAutoTopUpCardSetup?: (input: {
|
|
1315
|
+
successUrl: string;
|
|
1316
|
+
cancelUrl: string;
|
|
1317
|
+
}) => Promise<{
|
|
1318
|
+
url: string;
|
|
1319
|
+
}>;
|
|
1320
|
+
/** Make the card a completed setup session saved the default, and return
|
|
1321
|
+
* the new view. The card calls it when the page loads back from Stripe. */
|
|
1322
|
+
confirmAutoTopUpCardSetup?: (sessionId: string) => Promise<AutoTopUpView>;
|
|
1309
1323
|
/**
|
|
1310
1324
|
* Who this workspace shares its credits with, or whose it spends. When
|
|
1311
1325
|
* omitted, Billing hides the "Shared credits" entry.
|
|
@@ -2862,6 +2876,37 @@ declare function autoTopUpCycleText(view: Pick<AutoTopUpView, "spentThisCycleCre
|
|
|
2862
2876
|
* leaves the setting on.
|
|
2863
2877
|
*/
|
|
2864
2878
|
declare function autoTopUpCapNotice(view: Pick<AutoTopUpView, "enabled" | "lastAttempt" | "cycle" | "spentThisCycleCredits" | "packCredits" | "cycleCapCredits">, now?: Date): string | null;
|
|
2879
|
+
/**
|
|
2880
|
+
* Which card button the card shows: "add" with no card on file, "update"
|
|
2881
|
+
* beside the one shown, `null` without a paid plan (no Stripe customer to
|
|
2882
|
+
* save a card to).
|
|
2883
|
+
*/
|
|
2884
|
+
declare function autoTopUpCardAction(view: Pick<AutoTopUpView, "paidPlan" | "paymentMethod">): "add" | "update" | null;
|
|
2885
|
+
declare const CARD_SETUP_PARAM = "card_setup";
|
|
2886
|
+
declare const CARD_SETUP_SESSION_PARAM = "session_id";
|
|
2887
|
+
/**
|
|
2888
|
+
* Where Stripe returns to from adding a card: the page at `href`. The
|
|
2889
|
+
* session placeholder is appended as text, since URLSearchParams would
|
|
2890
|
+
* percent-encode its braces and Stripe would no longer replace it.
|
|
2891
|
+
*/
|
|
2892
|
+
declare function cardSetupReturnUrls(href: string): {
|
|
2893
|
+
successUrl: string;
|
|
2894
|
+
cancelUrl: string;
|
|
2895
|
+
};
|
|
2896
|
+
type CardSetupReturn = {
|
|
2897
|
+
status: "success";
|
|
2898
|
+
sessionId: string;
|
|
2899
|
+
cleanHref: string;
|
|
2900
|
+
} | {
|
|
2901
|
+
status: "cancelled";
|
|
2902
|
+
cleanHref: string;
|
|
2903
|
+
};
|
|
2904
|
+
/**
|
|
2905
|
+
* What a page loaded at `href` came back from, or `null` when it did not
|
|
2906
|
+
* come back from adding a card. `cleanHref` is the page without the params,
|
|
2907
|
+
* to replace the address with so a reload doesn't confirm again.
|
|
2908
|
+
*/
|
|
2909
|
+
declare function readCardSetupReturn(href: string): CardSetupReturn | null;
|
|
2865
2910
|
|
|
2866
2911
|
/**
|
|
2867
2912
|
* Auto top-up: when credits fall below a threshold, billing buys the chosen
|
|
@@ -2869,6 +2914,11 @@ declare function autoTopUpCapNotice(view: Pick<AutoTopUpView, "enabled" | "lastA
|
|
|
2869
2914
|
* it only for workspace or org admins. Renders nothing when the host has no
|
|
2870
2915
|
* `api.fetchAutoTopUp`. `onTopUpSettled` runs when a top-up the card watched
|
|
2871
2916
|
* finishes, so the host can reload the balance.
|
|
2917
|
+
*
|
|
2918
|
+
* With `api.startAutoTopUpCardSetup` it offers "Add card" / "Update card",
|
|
2919
|
+
* which goes to Stripe Checkout and back to this page; on the way back it
|
|
2920
|
+
* confirms the session through `api.confirmAutoTopUpCardSetup` and shows
|
|
2921
|
+
* the new card.
|
|
2872
2922
|
*/
|
|
2873
2923
|
declare function AutoTopUpCard({ onTopUpSettled }?: {
|
|
2874
2924
|
onTopUpSettled?: () => void;
|
|
@@ -3304,4 +3354,4 @@ interface AppSettingsRowProps {
|
|
|
3304
3354
|
}
|
|
3305
3355
|
declare function AppSettingsRow({ title, description, summary, href, onClick, disabled, disabledReason, ariaLabel, trailing }: AppSettingsRowProps): react.JSX.Element;
|
|
3306
3356
|
|
|
3307
|
-
export { APP_KEYS, AUTO_TOPUP_DEFAULTS, type AddCreditPoolMemberInput, AdministrationOverview, type AdministrationOverviewProps, type AdministrativeNavigationOptions, type ApiToken, type AppKey, AppSettingsHeader, type AppSettingsHeaderProps, AppSettingsPage, type AppSettingsPageProps, AppSettingsRow, type AppSettingsRowProps, AppSettingsSection, type AppSettingsSectionProps, AutoTopUpCard, type AutoTopUpSettings, type AutoTopUpValidation, type AutoTopUpView, type AvailableCreditsResponse, BILLING_TABLE_FRAME_STYLE, BILLING_TABLE_MIN_HEIGHT, BILLING_TABLE_PAGER_STYLE, BillingContent, type BillingEntitlement, type BillingEventPayload, type BillingProduct, type BillingSubscription, BuyCreditsModal, type BuyCreditsPayload, type BuyCreditsResponse, ConfirmDeleteModal, ConfirmLeaveModal, type ConnectedApp, ConnectedAppsContent, type CreatedToken, type CreditCycleUnit, type CreditLimitUnit, type CreditLimitValidation, type CreditPoolCandidate, type CreditPoolFormerMember, type CreditPoolMember, CreditPoolMemberModal, type CreditPoolMemberModalProps, type CreditPoolMemberStatus, type CreditPoolMode, type CreditPoolResponse, type CreditPoolSelfShare, type CreditsMeter, type CurrentPlanState, type CustomCreditInfo, type CustomCreditResponse, DEFAULT_PERMISSIONS, DEFAULT_USER_LANGUAGE, EMPTY_USAGE_LOGS_PAGE, ExportDateModal, type FetchUsageLogs, type FetchUsageLogsInRangeOptions, INITIAL_USAGE_LOGS_STATE, INVOICE_DOWNLOAD_FAILED_MESSAGE, INVOICE_NOT_AVAILABLE_MESSAGE, InviteUpdateModal, type InvoiceDownloadKind, type InvoicePdfResponse, type LoginMethodsMember, type LoginMethodsSettings, type LoginMethodsSwitchState, MOCK_REFERRED_USERS, type MemberCreditLimit, MemberCreditLimitModal, type MemberCreditLimitRow, type MemberCreditLimitSource, type MemberCreditLimitsResponse, MemberListFrame, type MemberListFrameProps, type MemberListTab, MemberListToolbar, type MemberListToolbarProps, type MemberPermissionsPayload, OrganizationContent, type OrganizationData, type OrganizationDetails, OrganizationIntegrationsContent, type OrganizationInvite, type OrganizationJoinRequest, type OrganizationJoinableWorkspace, OrganizationLoginMethodsContent, type OrganizationMember, OrganizationMemberModal, type OrganizationMemberModalProps, type OrganizationMemberRole, OrganizationModal, OrganizationPicker, type OrganizationPickerItem, type OrganizationPickerProps, type OrganizationPickerType, type OrganizationView, type OrganizationWorkspaceItem, POOL_ERROR_CODES, POOL_EXPIRY_MAX_MONTHS, POOL_NOTE_MAX_LENGTH, PerUserLimitsView, type PoolEndsAtResult, type PoolErrorCode, type PoolExpiryChoice, type PoolValueValidation, type Price, type PriceMetadata, type ProductsResponse, ProfileAvatar, ProfileTab, REMOVE_REASON_MAX_LENGTH, ReferralHistoryView, type ReferralHistoryViewProps, ReferralTab, type ReferredUser, RemovePoolMemberModal, type RemovePoolMemberModalProps, RemoveSelfShareModal, type RemoveSelfShareModalProps, SCOPE_LABELS, ScopeHeader, type ScopeHeaderProps, type ServiceItem, type SetCreditPoolSelfShareInput, type SettingsAdapters, SettingsAdaptersProvider, type SettingsApiAdapter, type SettingsAuthAdapter, type SettingsAuthUser, SettingsContent, type SettingsContentProps, type SettingsImageUploadAdapter, type SettingsIntegrationsAdapter, type SettingsLoginMethodsAdapter, type SettingsNavigationAdapter, type SettingsOrganizationAdapter, type SettingsOrganizationCreateOptions, type SettingsOrganizationCurrent, type SettingsOrganizationJoinableItem, type SettingsOrganizationListItem, type SettingsOrganizationType, type SettingsOrganizationWorkspaceJoin, type SettingsScope, type SettingsTab, type SettingsToastAdapter, SettingsTooltip, type SettingsTooltipPlacement, type SettingsTooltipProps, type SettingsWorkspaceAdapter, type SettingsWorkspaceCurrent, type SettingsWorkspaceListItem, SharedCreditsView, type SharedPoolBalance, SiconKey, type SponsorShareBalance, type StoreItem, type SubscriptionPlan, type SubscriptionResponse, TAB_DESCRIPTIONS, TAB_LABELS, TAB_SCOPE, TAB_TO_URL, type TeamMember, TeamsContent, type TokenExpiry, TokensContent, URL_TO_TAB, USAGE_LOGS_EXPORT_BATCH_SIZE, USAGE_LOGS_EXPORT_EXTRA_REQUESTS, USAGE_LOGS_EXPORT_MAX_ROWS, USAGE_LOGS_PAGE_SIZE, USER_LANGUAGES, type UpdateCreditPoolMemberInput, type UpdateSubscriptionPayload, type UpdateSubscriptionResponse, type UsageHistoryItem, type UsageHistoryPagination, type UsageHistoryResponse, type UsageLogsAction, type UsageLogsExportResult, type UsageLogsPage, UsageLogsPager, type UsageLogsQuery, type UsageLogsState, UsageLogsTable, type UsedByNamesLoader, type UserLanguage, type UserPermissions, WORKSPACE_CREDIT_LIMIT_REACHED, WORKSPACE_CREDIT_LIMIT_REACHED_MESSAGE, WORKSPACE_LIST_PAGE_SIZE, type WorkspaceCreditLimit, WorkspaceCreditLimitCard, type WorkspaceCreditLimitSummary, type WorkspaceData, WorkspaceGeneralTab, type WorkspaceGeneralTabProps, type WorkspaceInvite, type WorkspaceListOrganization, WorkspaceListTab, type WorkspaceMember, WorkspaceModal, type WorkspaceOrganization, type WorkspaceOrganizationRequest, WorkspacePicker, type WorkspacePickerGroup, type WorkspacePickerItem, type WorkspacePickerProps, WorkspaceTab, type WorkspaceUsageResponse, aboveTotalReason, autoTopUpBlockedReason, autoTopUpCapNotice, autoTopUpCycleText, autoTopUpDisabledMessage, belowUsageReason, canManageOnlyWorkspaceCreditLimit, canShowSharedCredits, capMoney, checkPoolPercentTotal, cleanAutoTopUpInput, cleanCreditLimitInput, cleanPoolValueInput, countLabel, createUsedByNamesLoader, creditCycleUnit, creditsMeter, deriveWorkspaceInvitePermission, describeAllowance, describeDefaultLimit, describeMemberLimit, describeWorkspaceCreditLimit, entitlementFromBody, entitlementFromFailure, expiryChoiceFor, fetchUsageLogsInRange, findBillingError, findPoolError, formatAutoTopUpMoney, formatCreditLimit, formatCredits, formatPackOption, formatPoolEndsAt, formatPoolSplit, groupWorkspaceList, hasPaidFeatures, inviteUpdate, invoiceDownloadKind, isLimitAboveTotal, isLimitBelowUsage, isPaidPlan, isSponsoredEntitlement, isWorkspaceCreditLimitReached, joinMembersWithLimits, lastUsedLabel, limitAboveTotalTotal, limitBelowUsageUsed, limitSourceLabel, loadCurrentPlan, loadWorkspaceOrganization, loginMethodsSwitchState, maximumCreditLimit, memberRoleUpdate, minPoolEndDate, minimumCreditLimit, ownCreditsFirstText, parseBillingEntitlement, parseInviteEmails, pausedOwnCreditsText, poolAllocatedPercent, poolAllocationText, poolEndsAtFrom, poolErrorMessage, poolRenewsAtCycleEnd, poolSharesCredits, poolUnallocatedPercent, poolWorkspaceName, productsForCountry, readSettingsCaller, referralCodeOf, referralCountLabel, referralLink, referralSignupDate, rememberSettingsCaller, resolveSettingsTabFromPath, roundCredits, settingsReturnTarget, sharedPoolBannerText, sharedPoolEndsText, sliceUsageLogsPage, sortReferredUsers, sponsorShareBannerText, sponsorShareDetailText, sponsorShareSpentText, sponsoredCreditsText, ssoLabel, toCsv, toLocalDateInput, usageLogsCsvRows, usageLogsDateRange, usageLogsExportFileName, usageLogsPage, usageLogsReducer, usageLogsReloadPage, usageLogsShowWorkspace, usageLogsSpentByOthers, useBillingEntitlement, useSettingsAdapters, useWorkspaceInvitePermission, useWorkspaceOrganization, usedByNamesFrom, usedByWorkspaceKey, userLanguageLabel, validateAutoTopUpInput, validateCreditLimitInput, validateDefaultCreditLimitInput, validatePoolText, validatePoolValue };
|
|
3357
|
+
export { APP_KEYS, AUTO_TOPUP_DEFAULTS, type AddCreditPoolMemberInput, AdministrationOverview, type AdministrationOverviewProps, type AdministrativeNavigationOptions, type ApiToken, type AppKey, AppSettingsHeader, type AppSettingsHeaderProps, AppSettingsPage, type AppSettingsPageProps, AppSettingsRow, type AppSettingsRowProps, AppSettingsSection, type AppSettingsSectionProps, AutoTopUpCard, type AutoTopUpSettings, type AutoTopUpValidation, type AutoTopUpView, type AvailableCreditsResponse, BILLING_TABLE_FRAME_STYLE, BILLING_TABLE_MIN_HEIGHT, BILLING_TABLE_PAGER_STYLE, BillingContent, type BillingEntitlement, type BillingEventPayload, type BillingProduct, type BillingSubscription, BuyCreditsModal, type BuyCreditsPayload, type BuyCreditsResponse, CARD_SETUP_PARAM, CARD_SETUP_SESSION_PARAM, type CardSetupReturn, ConfirmDeleteModal, ConfirmLeaveModal, type ConnectedApp, ConnectedAppsContent, type CreatedToken, type CreditCycleUnit, type CreditLimitUnit, type CreditLimitValidation, type CreditPoolCandidate, type CreditPoolFormerMember, type CreditPoolMember, CreditPoolMemberModal, type CreditPoolMemberModalProps, type CreditPoolMemberStatus, type CreditPoolMode, type CreditPoolResponse, type CreditPoolSelfShare, type CreditsMeter, type CurrentPlanState, type CustomCreditInfo, type CustomCreditResponse, DEFAULT_PERMISSIONS, DEFAULT_USER_LANGUAGE, EMPTY_USAGE_LOGS_PAGE, ExportDateModal, type FetchUsageLogs, type FetchUsageLogsInRangeOptions, INITIAL_USAGE_LOGS_STATE, INVOICE_DOWNLOAD_FAILED_MESSAGE, INVOICE_NOT_AVAILABLE_MESSAGE, InviteUpdateModal, type InvoiceDownloadKind, type InvoicePdfResponse, type LoginMethodsMember, type LoginMethodsSettings, type LoginMethodsSwitchState, MOCK_REFERRED_USERS, type MemberCreditLimit, MemberCreditLimitModal, type MemberCreditLimitRow, type MemberCreditLimitSource, type MemberCreditLimitsResponse, MemberListFrame, type MemberListFrameProps, type MemberListTab, MemberListToolbar, type MemberListToolbarProps, type MemberPermissionsPayload, OrganizationContent, type OrganizationData, type OrganizationDetails, OrganizationIntegrationsContent, type OrganizationInvite, type OrganizationJoinRequest, type OrganizationJoinableWorkspace, OrganizationLoginMethodsContent, type OrganizationMember, OrganizationMemberModal, type OrganizationMemberModalProps, type OrganizationMemberRole, OrganizationModal, OrganizationPicker, type OrganizationPickerItem, type OrganizationPickerProps, type OrganizationPickerType, type OrganizationView, type OrganizationWorkspaceItem, POOL_ERROR_CODES, POOL_EXPIRY_MAX_MONTHS, POOL_NOTE_MAX_LENGTH, PerUserLimitsView, type PoolEndsAtResult, type PoolErrorCode, type PoolExpiryChoice, type PoolValueValidation, type Price, type PriceMetadata, type ProductsResponse, ProfileAvatar, ProfileTab, REMOVE_REASON_MAX_LENGTH, ReferralHistoryView, type ReferralHistoryViewProps, ReferralTab, type ReferredUser, RemovePoolMemberModal, type RemovePoolMemberModalProps, RemoveSelfShareModal, type RemoveSelfShareModalProps, SCOPE_LABELS, ScopeHeader, type ScopeHeaderProps, type ServiceItem, type SetCreditPoolSelfShareInput, type SettingsAdapters, SettingsAdaptersProvider, type SettingsApiAdapter, type SettingsAuthAdapter, type SettingsAuthUser, SettingsContent, type SettingsContentProps, type SettingsImageUploadAdapter, type SettingsIntegrationsAdapter, type SettingsLoginMethodsAdapter, type SettingsNavigationAdapter, type SettingsOrganizationAdapter, type SettingsOrganizationCreateOptions, type SettingsOrganizationCurrent, type SettingsOrganizationJoinableItem, type SettingsOrganizationListItem, type SettingsOrganizationType, type SettingsOrganizationWorkspaceJoin, type SettingsScope, type SettingsTab, type SettingsToastAdapter, SettingsTooltip, type SettingsTooltipPlacement, type SettingsTooltipProps, type SettingsWorkspaceAdapter, type SettingsWorkspaceCurrent, type SettingsWorkspaceListItem, SharedCreditsView, type SharedPoolBalance, SiconKey, type SponsorShareBalance, type StoreItem, type SubscriptionPlan, type SubscriptionResponse, TAB_DESCRIPTIONS, TAB_LABELS, TAB_SCOPE, TAB_TO_URL, type TeamMember, TeamsContent, type TokenExpiry, TokensContent, URL_TO_TAB, USAGE_LOGS_EXPORT_BATCH_SIZE, USAGE_LOGS_EXPORT_EXTRA_REQUESTS, USAGE_LOGS_EXPORT_MAX_ROWS, USAGE_LOGS_PAGE_SIZE, USER_LANGUAGES, type UpdateCreditPoolMemberInput, type UpdateSubscriptionPayload, type UpdateSubscriptionResponse, type UsageHistoryItem, type UsageHistoryPagination, type UsageHistoryResponse, type UsageLogsAction, type UsageLogsExportResult, type UsageLogsPage, UsageLogsPager, type UsageLogsQuery, type UsageLogsState, UsageLogsTable, type UsedByNamesLoader, type UserLanguage, type UserPermissions, WORKSPACE_CREDIT_LIMIT_REACHED, WORKSPACE_CREDIT_LIMIT_REACHED_MESSAGE, WORKSPACE_LIST_PAGE_SIZE, type WorkspaceCreditLimit, WorkspaceCreditLimitCard, type WorkspaceCreditLimitSummary, type WorkspaceData, WorkspaceGeneralTab, type WorkspaceGeneralTabProps, type WorkspaceInvite, type WorkspaceListOrganization, WorkspaceListTab, type WorkspaceMember, WorkspaceModal, type WorkspaceOrganization, type WorkspaceOrganizationRequest, WorkspacePicker, type WorkspacePickerGroup, type WorkspacePickerItem, type WorkspacePickerProps, WorkspaceTab, type WorkspaceUsageResponse, aboveTotalReason, autoTopUpBlockedReason, autoTopUpCapNotice, autoTopUpCardAction, autoTopUpCycleText, autoTopUpDisabledMessage, belowUsageReason, canManageOnlyWorkspaceCreditLimit, canShowSharedCredits, capMoney, cardSetupReturnUrls, checkPoolPercentTotal, cleanAutoTopUpInput, cleanCreditLimitInput, cleanPoolValueInput, countLabel, createUsedByNamesLoader, creditCycleUnit, creditsMeter, deriveWorkspaceInvitePermission, describeAllowance, describeDefaultLimit, describeMemberLimit, describeWorkspaceCreditLimit, entitlementFromBody, entitlementFromFailure, expiryChoiceFor, fetchUsageLogsInRange, findBillingError, findPoolError, formatAutoTopUpMoney, formatCreditLimit, formatCredits, formatPackOption, formatPoolEndsAt, formatPoolSplit, groupWorkspaceList, hasPaidFeatures, inviteUpdate, invoiceDownloadKind, isLimitAboveTotal, isLimitBelowUsage, isPaidPlan, isSponsoredEntitlement, isWorkspaceCreditLimitReached, joinMembersWithLimits, lastUsedLabel, limitAboveTotalTotal, limitBelowUsageUsed, limitSourceLabel, loadCurrentPlan, loadWorkspaceOrganization, loginMethodsSwitchState, maximumCreditLimit, memberRoleUpdate, minPoolEndDate, minimumCreditLimit, ownCreditsFirstText, parseBillingEntitlement, parseInviteEmails, pausedOwnCreditsText, poolAllocatedPercent, poolAllocationText, poolEndsAtFrom, poolErrorMessage, poolRenewsAtCycleEnd, poolSharesCredits, poolUnallocatedPercent, poolWorkspaceName, productsForCountry, readCardSetupReturn, readSettingsCaller, referralCodeOf, referralCountLabel, referralLink, referralSignupDate, rememberSettingsCaller, resolveSettingsTabFromPath, roundCredits, settingsReturnTarget, sharedPoolBannerText, sharedPoolEndsText, sliceUsageLogsPage, sortReferredUsers, sponsorShareBannerText, sponsorShareDetailText, sponsorShareSpentText, sponsoredCreditsText, ssoLabel, toCsv, toLocalDateInput, usageLogsCsvRows, usageLogsDateRange, usageLogsExportFileName, usageLogsPage, usageLogsReducer, usageLogsReloadPage, usageLogsShowWorkspace, usageLogsSpentByOthers, useBillingEntitlement, useSettingsAdapters, useWorkspaceInvitePermission, useWorkspaceOrganization, usedByNamesFrom, usedByWorkspaceKey, userLanguageLabel, validateAutoTopUpInput, validateCreditLimitInput, validateDefaultCreditLimitInput, validatePoolText, validatePoolValue };
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,8 @@ __export(index_exports, {
|
|
|
33
33
|
BILLING_TABLE_PAGER_STYLE: () => BILLING_TABLE_PAGER_STYLE,
|
|
34
34
|
BillingContent: () => BillingContent,
|
|
35
35
|
BuyCreditsModal: () => BuyCreditsModal,
|
|
36
|
+
CARD_SETUP_PARAM: () => CARD_SETUP_PARAM,
|
|
37
|
+
CARD_SETUP_SESSION_PARAM: () => CARD_SETUP_SESSION_PARAM,
|
|
36
38
|
ConfirmDeleteModal: () => ConfirmDeleteModal,
|
|
37
39
|
ConfirmLeaveModal: () => ConfirmLeaveModal,
|
|
38
40
|
ConnectedAppsContent: () => ConnectedAppsContent,
|
|
@@ -99,12 +101,14 @@ __export(index_exports, {
|
|
|
99
101
|
aboveTotalReason: () => aboveTotalReason,
|
|
100
102
|
autoTopUpBlockedReason: () => autoTopUpBlockedReason,
|
|
101
103
|
autoTopUpCapNotice: () => autoTopUpCapNotice,
|
|
104
|
+
autoTopUpCardAction: () => autoTopUpCardAction,
|
|
102
105
|
autoTopUpCycleText: () => autoTopUpCycleText,
|
|
103
106
|
autoTopUpDisabledMessage: () => autoTopUpDisabledMessage,
|
|
104
107
|
belowUsageReason: () => belowUsageReason,
|
|
105
108
|
canManageOnlyWorkspaceCreditLimit: () => canManageOnlyWorkspaceCreditLimit,
|
|
106
109
|
canShowSharedCredits: () => canShowSharedCredits,
|
|
107
110
|
capMoney: () => capMoney,
|
|
111
|
+
cardSetupReturnUrls: () => cardSetupReturnUrls,
|
|
108
112
|
checkPoolPercentTotal: () => checkPoolPercentTotal,
|
|
109
113
|
cleanAutoTopUpInput: () => cleanAutoTopUpInput,
|
|
110
114
|
cleanCreditLimitInput: () => cleanCreditLimitInput,
|
|
@@ -164,6 +168,7 @@ __export(index_exports, {
|
|
|
164
168
|
poolUnallocatedPercent: () => poolUnallocatedPercent,
|
|
165
169
|
poolWorkspaceName: () => poolWorkspaceName,
|
|
166
170
|
productsForCountry: () => productsForCountry,
|
|
171
|
+
readCardSetupReturn: () => readCardSetupReturn,
|
|
167
172
|
readSettingsCaller: () => readSettingsCaller,
|
|
168
173
|
referralCodeOf: () => referralCodeOf,
|
|
169
174
|
referralCountLabel: () => referralCountLabel,
|
|
@@ -10155,6 +10160,43 @@ function autoTopUpCapNotice(view, now = /* @__PURE__ */ new Date()) {
|
|
|
10155
10160
|
const until = shortDate(view.cycle.end);
|
|
10156
10161
|
return `Cap reached${when ? ` on ${when}` : ""} \u2014 auto top-up is paused${until ? ` until ${until}` : " until the next billing cycle"}. Raise the cap per billing cycle to keep topping up.`;
|
|
10157
10162
|
}
|
|
10163
|
+
function autoTopUpCardAction(view) {
|
|
10164
|
+
if (!view.paidPlan) return null;
|
|
10165
|
+
return view.paymentMethod ? "update" : "add";
|
|
10166
|
+
}
|
|
10167
|
+
var CARD_SETUP_PARAM = "card_setup";
|
|
10168
|
+
var CARD_SETUP_SESSION_PARAM = "session_id";
|
|
10169
|
+
var withoutCardSetupParams = (href) => {
|
|
10170
|
+
const url = new URL(href);
|
|
10171
|
+
url.searchParams.delete(CARD_SETUP_PARAM);
|
|
10172
|
+
url.searchParams.delete(CARD_SETUP_SESSION_PARAM);
|
|
10173
|
+
url.hash = "";
|
|
10174
|
+
return url;
|
|
10175
|
+
};
|
|
10176
|
+
function cardSetupReturnUrls(href) {
|
|
10177
|
+
const base = withoutCardSetupParams(href).toString();
|
|
10178
|
+
const join = base.includes("?") ? "&" : "?";
|
|
10179
|
+
return {
|
|
10180
|
+
successUrl: `${base}${join}${CARD_SETUP_PARAM}=success&${CARD_SETUP_SESSION_PARAM}={CHECKOUT_SESSION_ID}`,
|
|
10181
|
+
cancelUrl: `${base}${join}${CARD_SETUP_PARAM}=cancelled`
|
|
10182
|
+
};
|
|
10183
|
+
}
|
|
10184
|
+
function readCardSetupReturn(href) {
|
|
10185
|
+
let url;
|
|
10186
|
+
try {
|
|
10187
|
+
url = new URL(href);
|
|
10188
|
+
} catch {
|
|
10189
|
+
return null;
|
|
10190
|
+
}
|
|
10191
|
+
const status = url.searchParams.get(CARD_SETUP_PARAM);
|
|
10192
|
+
if (status !== "success" && status !== "cancelled") return null;
|
|
10193
|
+
const clean = withoutCardSetupParams(href);
|
|
10194
|
+
clean.hash = url.hash;
|
|
10195
|
+
const cleanHref = clean.toString();
|
|
10196
|
+
if (status === "cancelled") return { status, cleanHref };
|
|
10197
|
+
const sessionId = url.searchParams.get(CARD_SETUP_SESSION_PARAM) ?? "";
|
|
10198
|
+
return /^cs_(test|live)_[A-Za-z0-9]+$/.test(sessionId) ? { status, sessionId, cleanHref } : { status: "cancelled", cleanHref };
|
|
10199
|
+
}
|
|
10158
10200
|
|
|
10159
10201
|
// src/auto-top-up-card.tsx
|
|
10160
10202
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
@@ -10201,6 +10243,10 @@ var formOf = (view) => ({
|
|
|
10201
10243
|
var sameForm = (a, b) => a.enabled === b.enabled && a.threshold === b.threshold && a.packCredits === b.packCredits && a.cap === b.cap;
|
|
10202
10244
|
var AUTO_TOPUP_FOLLOW_MS = 1500;
|
|
10203
10245
|
var AUTO_TOPUP_FOLLOW_LIMIT_MS = 3e4;
|
|
10246
|
+
var cardLabel = (card2) => {
|
|
10247
|
+
const brand = card2.brand ? `${card2.brand.charAt(0).toUpperCase()}${card2.brand.slice(1)}` : "Card";
|
|
10248
|
+
return card2.last4 ? `${brand} ending ${card2.last4}` : `${brand} on file`;
|
|
10249
|
+
};
|
|
10204
10250
|
var charging = (view) => view.pending || view.lastAttempt?.status === "pending";
|
|
10205
10251
|
function AutoTopUpCard({ onTopUpSettled } = {}) {
|
|
10206
10252
|
const { api, workspace, toast } = useSettingsAdapters();
|
|
@@ -10209,6 +10255,7 @@ function AutoTopUpCard({ onTopUpSettled } = {}) {
|
|
|
10209
10255
|
const [form, setForm] = (0, import_react20.useState)(null);
|
|
10210
10256
|
const [loading, setLoading] = (0, import_react20.useState)(true);
|
|
10211
10257
|
const [saving, setSaving] = (0, import_react20.useState)(false);
|
|
10258
|
+
const [cardBusy, setCardBusy] = (0, import_react20.useState)(null);
|
|
10212
10259
|
const latestLoad = (0, import_react20.useRef)(0);
|
|
10213
10260
|
const workspaceRun = (0, import_react20.useRef)(0);
|
|
10214
10261
|
const shown = (0, import_react20.useRef)({ view: null, form: null });
|
|
@@ -10216,6 +10263,9 @@ function AutoTopUpCard({ onTopUpSettled } = {}) {
|
|
|
10216
10263
|
const settledRef = (0, import_react20.useRef)(onTopUpSettled);
|
|
10217
10264
|
settledRef.current = onTopUpSettled;
|
|
10218
10265
|
const followTimer = (0, import_react20.useRef)(null);
|
|
10266
|
+
const mounted = (0, import_react20.useRef)(false);
|
|
10267
|
+
const currentWorkspace = (0, import_react20.useRef)(workspaceId);
|
|
10268
|
+
currentWorkspace.current = workspaceId;
|
|
10219
10269
|
const stopFollowing = () => {
|
|
10220
10270
|
if (followTimer.current) clearTimeout(followTimer.current);
|
|
10221
10271
|
followTimer.current = null;
|
|
@@ -10270,14 +10320,37 @@ function AutoTopUpCard({ onTopUpSettled } = {}) {
|
|
|
10270
10320
|
setForm(null);
|
|
10271
10321
|
void load();
|
|
10272
10322
|
}, [workspaceId]);
|
|
10273
|
-
(0, import_react20.useEffect)(
|
|
10274
|
-
|
|
10323
|
+
(0, import_react20.useEffect)(() => {
|
|
10324
|
+
mounted.current = true;
|
|
10325
|
+
return () => {
|
|
10326
|
+
mounted.current = false;
|
|
10275
10327
|
latestLoad.current += 1;
|
|
10276
10328
|
workspaceRun.current += 1;
|
|
10277
10329
|
stopFollowing();
|
|
10278
|
-
}
|
|
10279
|
-
|
|
10280
|
-
)
|
|
10330
|
+
};
|
|
10331
|
+
}, []);
|
|
10332
|
+
(0, import_react20.useEffect)(() => {
|
|
10333
|
+
if (typeof window === "undefined") return;
|
|
10334
|
+
const back = readCardSetupReturn(window.location.href);
|
|
10335
|
+
if (!back) return;
|
|
10336
|
+
window.history.replaceState(window.history.state, "", back.cleanHref);
|
|
10337
|
+
if (back.status !== "success" || !api.confirmAutoTopUpCardSetup) return;
|
|
10338
|
+
const forWorkspace = workspaceId;
|
|
10339
|
+
const current = () => mounted.current && currentWorkspace.current === forWorkspace;
|
|
10340
|
+
setCardBusy("confirming");
|
|
10341
|
+
api.confirmAutoTopUpCardSetup(back.sessionId).then((next) => {
|
|
10342
|
+
if (!current()) return;
|
|
10343
|
+
++latestLoad.current;
|
|
10344
|
+
setView(next);
|
|
10345
|
+
setForm(formOf(next));
|
|
10346
|
+
setLoading(false);
|
|
10347
|
+
toast.success("Card saved");
|
|
10348
|
+
}).catch((err) => {
|
|
10349
|
+
if (current()) toast.error(errorMessage(err, { method: "POST" }));
|
|
10350
|
+
}).finally(() => {
|
|
10351
|
+
if (current()) setCardBusy(null);
|
|
10352
|
+
});
|
|
10353
|
+
}, []);
|
|
10281
10354
|
if (!api.fetchAutoTopUp) return null;
|
|
10282
10355
|
const blocked = view ? autoTopUpBlockedReason(view) : null;
|
|
10283
10356
|
const packs = view?.packs.map((pack) => pack.credits) ?? [];
|
|
@@ -10313,6 +10386,20 @@ function AutoTopUpCard({ onTopUpSettled } = {}) {
|
|
|
10313
10386
|
if (run === workspaceRun.current) setSaving(false);
|
|
10314
10387
|
}
|
|
10315
10388
|
};
|
|
10389
|
+
const startCardSetup = async () => {
|
|
10390
|
+
if (!api.startAutoTopUpCardSetup || cardBusy) return;
|
|
10391
|
+
const run = workspaceRun.current;
|
|
10392
|
+
setCardBusy("starting");
|
|
10393
|
+
try {
|
|
10394
|
+
const { url } = await api.startAutoTopUpCardSetup(cardSetupReturnUrls(window.location.href));
|
|
10395
|
+
if (run !== workspaceRun.current) return;
|
|
10396
|
+
window.location.assign(url);
|
|
10397
|
+
} catch (err) {
|
|
10398
|
+
if (run !== workspaceRun.current) return;
|
|
10399
|
+
toast.error(errorMessage(err, { method: "POST" }));
|
|
10400
|
+
setCardBusy(null);
|
|
10401
|
+
}
|
|
10402
|
+
};
|
|
10316
10403
|
const toggle = (next) => {
|
|
10317
10404
|
if (!form || saving) return;
|
|
10318
10405
|
if (next && blocked) return;
|
|
@@ -10323,6 +10410,17 @@ function AutoTopUpCard({ onTopUpSettled } = {}) {
|
|
|
10323
10410
|
const capCredits = form && validation?.ok ? validation.value.cycleCapCredits : null;
|
|
10324
10411
|
const capPrice = view && capCredits !== null ? capMoney(capCredits, view) : null;
|
|
10325
10412
|
const toggleDisabled = saving || !api.setAutoTopUp || !form?.enabled && !!blocked;
|
|
10413
|
+
const cardAction = view && api.startAutoTopUpCardSetup ? autoTopUpCardAction(view) : null;
|
|
10414
|
+
const cardButton = cardAction && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
10415
|
+
import_ui14.ScButton,
|
|
10416
|
+
{
|
|
10417
|
+
text: cardBusy === "starting" ? "Opening Stripe\u2026" : cardBusy === "confirming" ? "Saving card\u2026" : cardAction === "add" ? "Add card" : "Update card",
|
|
10418
|
+
variant: "secondary",
|
|
10419
|
+
size: "sm",
|
|
10420
|
+
state: cardBusy || saving ? "disabled" : "default",
|
|
10421
|
+
onClick: () => void startCardSetup()
|
|
10422
|
+
}
|
|
10423
|
+
);
|
|
10326
10424
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
10327
10425
|
"div",
|
|
10328
10426
|
{
|
|
@@ -10370,7 +10468,13 @@ function AutoTopUpCard({ onTopUpSettled } = {}) {
|
|
|
10370
10468
|
loading ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { style: { ...cellText3, color: T16.muted }, children: "Loading\u2026" }) : !view || !form ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { style: { ...cellText3, color: T16.muted }, children: "Couldn't load auto top-up. Try again later." }) : /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
|
|
10371
10469
|
disabledMessage && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { role: "status", style: { ...cellText3, color: T16.error }, children: disabledMessage }),
|
|
10372
10470
|
capNotice && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { role: "status", style: { ...cellText3, color: T16.warning }, children: capNotice }),
|
|
10373
|
-
!form.enabled && blocked
|
|
10471
|
+
!form.enabled && blocked ? /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex flex-wrap items-center justify-between", style: { gap: 8 }, children: [
|
|
10472
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { style: { ...cellText3, color: T16.muted }, children: blocked }),
|
|
10473
|
+
cardButton
|
|
10474
|
+
] }) : cardButton && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex flex-wrap items-center justify-between", style: { gap: 8 }, children: [
|
|
10475
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { style: { ...cellText3, color: T16.muted }, children: view.paymentMethod ? `${cardLabel(view.paymentMethod)}. It is also the card your subscription is billed to.` : "Add a card to use auto top-up." }),
|
|
10476
|
+
cardButton
|
|
10477
|
+
] }),
|
|
10374
10478
|
form.enabled && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex flex-wrap items-end", style: { gap: 12 }, children: [
|
|
10375
10479
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("label", { className: "flex flex-col", style: { gap: 4, minWidth: 160, flex: "1 1 160px" }, children: [
|
|
10376
10480
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { style: { ...cellText3, color: T16.muted }, children: "When credits fall below" }),
|
package/dist/index.mjs
CHANGED
|
@@ -10019,6 +10019,43 @@ function autoTopUpCapNotice(view, now = /* @__PURE__ */ new Date()) {
|
|
|
10019
10019
|
const until = shortDate(view.cycle.end);
|
|
10020
10020
|
return `Cap reached${when ? ` on ${when}` : ""} \u2014 auto top-up is paused${until ? ` until ${until}` : " until the next billing cycle"}. Raise the cap per billing cycle to keep topping up.`;
|
|
10021
10021
|
}
|
|
10022
|
+
function autoTopUpCardAction(view) {
|
|
10023
|
+
if (!view.paidPlan) return null;
|
|
10024
|
+
return view.paymentMethod ? "update" : "add";
|
|
10025
|
+
}
|
|
10026
|
+
var CARD_SETUP_PARAM = "card_setup";
|
|
10027
|
+
var CARD_SETUP_SESSION_PARAM = "session_id";
|
|
10028
|
+
var withoutCardSetupParams = (href) => {
|
|
10029
|
+
const url = new URL(href);
|
|
10030
|
+
url.searchParams.delete(CARD_SETUP_PARAM);
|
|
10031
|
+
url.searchParams.delete(CARD_SETUP_SESSION_PARAM);
|
|
10032
|
+
url.hash = "";
|
|
10033
|
+
return url;
|
|
10034
|
+
};
|
|
10035
|
+
function cardSetupReturnUrls(href) {
|
|
10036
|
+
const base = withoutCardSetupParams(href).toString();
|
|
10037
|
+
const join = base.includes("?") ? "&" : "?";
|
|
10038
|
+
return {
|
|
10039
|
+
successUrl: `${base}${join}${CARD_SETUP_PARAM}=success&${CARD_SETUP_SESSION_PARAM}={CHECKOUT_SESSION_ID}`,
|
|
10040
|
+
cancelUrl: `${base}${join}${CARD_SETUP_PARAM}=cancelled`
|
|
10041
|
+
};
|
|
10042
|
+
}
|
|
10043
|
+
function readCardSetupReturn(href) {
|
|
10044
|
+
let url;
|
|
10045
|
+
try {
|
|
10046
|
+
url = new URL(href);
|
|
10047
|
+
} catch {
|
|
10048
|
+
return null;
|
|
10049
|
+
}
|
|
10050
|
+
const status = url.searchParams.get(CARD_SETUP_PARAM);
|
|
10051
|
+
if (status !== "success" && status !== "cancelled") return null;
|
|
10052
|
+
const clean = withoutCardSetupParams(href);
|
|
10053
|
+
clean.hash = url.hash;
|
|
10054
|
+
const cleanHref = clean.toString();
|
|
10055
|
+
if (status === "cancelled") return { status, cleanHref };
|
|
10056
|
+
const sessionId = url.searchParams.get(CARD_SETUP_SESSION_PARAM) ?? "";
|
|
10057
|
+
return /^cs_(test|live)_[A-Za-z0-9]+$/.test(sessionId) ? { status, sessionId, cleanHref } : { status: "cancelled", cleanHref };
|
|
10058
|
+
}
|
|
10022
10059
|
|
|
10023
10060
|
// src/auto-top-up-card.tsx
|
|
10024
10061
|
import { Fragment as Fragment10, jsx as jsx26, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
@@ -10065,6 +10102,10 @@ var formOf = (view) => ({
|
|
|
10065
10102
|
var sameForm = (a, b) => a.enabled === b.enabled && a.threshold === b.threshold && a.packCredits === b.packCredits && a.cap === b.cap;
|
|
10066
10103
|
var AUTO_TOPUP_FOLLOW_MS = 1500;
|
|
10067
10104
|
var AUTO_TOPUP_FOLLOW_LIMIT_MS = 3e4;
|
|
10105
|
+
var cardLabel = (card2) => {
|
|
10106
|
+
const brand = card2.brand ? `${card2.brand.charAt(0).toUpperCase()}${card2.brand.slice(1)}` : "Card";
|
|
10107
|
+
return card2.last4 ? `${brand} ending ${card2.last4}` : `${brand} on file`;
|
|
10108
|
+
};
|
|
10068
10109
|
var charging = (view) => view.pending || view.lastAttempt?.status === "pending";
|
|
10069
10110
|
function AutoTopUpCard({ onTopUpSettled } = {}) {
|
|
10070
10111
|
const { api, workspace, toast } = useSettingsAdapters();
|
|
@@ -10073,6 +10114,7 @@ function AutoTopUpCard({ onTopUpSettled } = {}) {
|
|
|
10073
10114
|
const [form, setForm] = useState18(null);
|
|
10074
10115
|
const [loading, setLoading] = useState18(true);
|
|
10075
10116
|
const [saving, setSaving] = useState18(false);
|
|
10117
|
+
const [cardBusy, setCardBusy] = useState18(null);
|
|
10076
10118
|
const latestLoad = useRef11(0);
|
|
10077
10119
|
const workspaceRun = useRef11(0);
|
|
10078
10120
|
const shown = useRef11({ view: null, form: null });
|
|
@@ -10080,6 +10122,9 @@ function AutoTopUpCard({ onTopUpSettled } = {}) {
|
|
|
10080
10122
|
const settledRef = useRef11(onTopUpSettled);
|
|
10081
10123
|
settledRef.current = onTopUpSettled;
|
|
10082
10124
|
const followTimer = useRef11(null);
|
|
10125
|
+
const mounted = useRef11(false);
|
|
10126
|
+
const currentWorkspace = useRef11(workspaceId);
|
|
10127
|
+
currentWorkspace.current = workspaceId;
|
|
10083
10128
|
const stopFollowing = () => {
|
|
10084
10129
|
if (followTimer.current) clearTimeout(followTimer.current);
|
|
10085
10130
|
followTimer.current = null;
|
|
@@ -10134,14 +10179,37 @@ function AutoTopUpCard({ onTopUpSettled } = {}) {
|
|
|
10134
10179
|
setForm(null);
|
|
10135
10180
|
void load();
|
|
10136
10181
|
}, [workspaceId]);
|
|
10137
|
-
useEffect16(
|
|
10138
|
-
|
|
10182
|
+
useEffect16(() => {
|
|
10183
|
+
mounted.current = true;
|
|
10184
|
+
return () => {
|
|
10185
|
+
mounted.current = false;
|
|
10139
10186
|
latestLoad.current += 1;
|
|
10140
10187
|
workspaceRun.current += 1;
|
|
10141
10188
|
stopFollowing();
|
|
10142
|
-
}
|
|
10143
|
-
|
|
10144
|
-
)
|
|
10189
|
+
};
|
|
10190
|
+
}, []);
|
|
10191
|
+
useEffect16(() => {
|
|
10192
|
+
if (typeof window === "undefined") return;
|
|
10193
|
+
const back = readCardSetupReturn(window.location.href);
|
|
10194
|
+
if (!back) return;
|
|
10195
|
+
window.history.replaceState(window.history.state, "", back.cleanHref);
|
|
10196
|
+
if (back.status !== "success" || !api.confirmAutoTopUpCardSetup) return;
|
|
10197
|
+
const forWorkspace = workspaceId;
|
|
10198
|
+
const current = () => mounted.current && currentWorkspace.current === forWorkspace;
|
|
10199
|
+
setCardBusy("confirming");
|
|
10200
|
+
api.confirmAutoTopUpCardSetup(back.sessionId).then((next) => {
|
|
10201
|
+
if (!current()) return;
|
|
10202
|
+
++latestLoad.current;
|
|
10203
|
+
setView(next);
|
|
10204
|
+
setForm(formOf(next));
|
|
10205
|
+
setLoading(false);
|
|
10206
|
+
toast.success("Card saved");
|
|
10207
|
+
}).catch((err) => {
|
|
10208
|
+
if (current()) toast.error(errorMessage(err, { method: "POST" }));
|
|
10209
|
+
}).finally(() => {
|
|
10210
|
+
if (current()) setCardBusy(null);
|
|
10211
|
+
});
|
|
10212
|
+
}, []);
|
|
10145
10213
|
if (!api.fetchAutoTopUp) return null;
|
|
10146
10214
|
const blocked = view ? autoTopUpBlockedReason(view) : null;
|
|
10147
10215
|
const packs = view?.packs.map((pack) => pack.credits) ?? [];
|
|
@@ -10177,6 +10245,20 @@ function AutoTopUpCard({ onTopUpSettled } = {}) {
|
|
|
10177
10245
|
if (run === workspaceRun.current) setSaving(false);
|
|
10178
10246
|
}
|
|
10179
10247
|
};
|
|
10248
|
+
const startCardSetup = async () => {
|
|
10249
|
+
if (!api.startAutoTopUpCardSetup || cardBusy) return;
|
|
10250
|
+
const run = workspaceRun.current;
|
|
10251
|
+
setCardBusy("starting");
|
|
10252
|
+
try {
|
|
10253
|
+
const { url } = await api.startAutoTopUpCardSetup(cardSetupReturnUrls(window.location.href));
|
|
10254
|
+
if (run !== workspaceRun.current) return;
|
|
10255
|
+
window.location.assign(url);
|
|
10256
|
+
} catch (err) {
|
|
10257
|
+
if (run !== workspaceRun.current) return;
|
|
10258
|
+
toast.error(errorMessage(err, { method: "POST" }));
|
|
10259
|
+
setCardBusy(null);
|
|
10260
|
+
}
|
|
10261
|
+
};
|
|
10180
10262
|
const toggle = (next) => {
|
|
10181
10263
|
if (!form || saving) return;
|
|
10182
10264
|
if (next && blocked) return;
|
|
@@ -10187,6 +10269,17 @@ function AutoTopUpCard({ onTopUpSettled } = {}) {
|
|
|
10187
10269
|
const capCredits = form && validation?.ok ? validation.value.cycleCapCredits : null;
|
|
10188
10270
|
const capPrice = view && capCredits !== null ? capMoney(capCredits, view) : null;
|
|
10189
10271
|
const toggleDisabled = saving || !api.setAutoTopUp || !form?.enabled && !!blocked;
|
|
10272
|
+
const cardAction = view && api.startAutoTopUpCardSetup ? autoTopUpCardAction(view) : null;
|
|
10273
|
+
const cardButton = cardAction && /* @__PURE__ */ jsx26(
|
|
10274
|
+
ScButton11,
|
|
10275
|
+
{
|
|
10276
|
+
text: cardBusy === "starting" ? "Opening Stripe\u2026" : cardBusy === "confirming" ? "Saving card\u2026" : cardAction === "add" ? "Add card" : "Update card",
|
|
10277
|
+
variant: "secondary",
|
|
10278
|
+
size: "sm",
|
|
10279
|
+
state: cardBusy || saving ? "disabled" : "default",
|
|
10280
|
+
onClick: () => void startCardSetup()
|
|
10281
|
+
}
|
|
10282
|
+
);
|
|
10190
10283
|
return /* @__PURE__ */ jsxs23(
|
|
10191
10284
|
"div",
|
|
10192
10285
|
{
|
|
@@ -10234,7 +10327,13 @@ function AutoTopUpCard({ onTopUpSettled } = {}) {
|
|
|
10234
10327
|
loading ? /* @__PURE__ */ jsx26("span", { style: { ...cellText3, color: T16.muted }, children: "Loading\u2026" }) : !view || !form ? /* @__PURE__ */ jsx26("span", { style: { ...cellText3, color: T16.muted }, children: "Couldn't load auto top-up. Try again later." }) : /* @__PURE__ */ jsxs23(Fragment10, { children: [
|
|
10235
10328
|
disabledMessage && /* @__PURE__ */ jsx26("span", { role: "status", style: { ...cellText3, color: T16.error }, children: disabledMessage }),
|
|
10236
10329
|
capNotice && /* @__PURE__ */ jsx26("span", { role: "status", style: { ...cellText3, color: T16.warning }, children: capNotice }),
|
|
10237
|
-
!form.enabled && blocked
|
|
10330
|
+
!form.enabled && blocked ? /* @__PURE__ */ jsxs23("div", { className: "flex flex-wrap items-center justify-between", style: { gap: 8 }, children: [
|
|
10331
|
+
/* @__PURE__ */ jsx26("span", { style: { ...cellText3, color: T16.muted }, children: blocked }),
|
|
10332
|
+
cardButton
|
|
10333
|
+
] }) : cardButton && /* @__PURE__ */ jsxs23("div", { className: "flex flex-wrap items-center justify-between", style: { gap: 8 }, children: [
|
|
10334
|
+
/* @__PURE__ */ jsx26("span", { style: { ...cellText3, color: T16.muted }, children: view.paymentMethod ? `${cardLabel(view.paymentMethod)}. It is also the card your subscription is billed to.` : "Add a card to use auto top-up." }),
|
|
10335
|
+
cardButton
|
|
10336
|
+
] }),
|
|
10238
10337
|
form.enabled && /* @__PURE__ */ jsxs23("div", { className: "flex flex-wrap items-end", style: { gap: 12 }, children: [
|
|
10239
10338
|
/* @__PURE__ */ jsxs23("label", { className: "flex flex-col", style: { gap: 4, minWidth: 160, flex: "1 1 160px" }, children: [
|
|
10240
10339
|
/* @__PURE__ */ jsx26("span", { style: { ...cellText3, color: T16.muted }, children: "When credits fall below" }),
|
|
@@ -19286,6 +19385,8 @@ export {
|
|
|
19286
19385
|
BILLING_TABLE_PAGER_STYLE,
|
|
19287
19386
|
BillingContent,
|
|
19288
19387
|
BuyCreditsModal,
|
|
19388
|
+
CARD_SETUP_PARAM,
|
|
19389
|
+
CARD_SETUP_SESSION_PARAM,
|
|
19289
19390
|
ConfirmDeleteModal,
|
|
19290
19391
|
ConfirmLeaveModal,
|
|
19291
19392
|
ConnectedAppsContent,
|
|
@@ -19352,12 +19453,14 @@ export {
|
|
|
19352
19453
|
aboveTotalReason,
|
|
19353
19454
|
autoTopUpBlockedReason,
|
|
19354
19455
|
autoTopUpCapNotice,
|
|
19456
|
+
autoTopUpCardAction,
|
|
19355
19457
|
autoTopUpCycleText,
|
|
19356
19458
|
autoTopUpDisabledMessage,
|
|
19357
19459
|
belowUsageReason,
|
|
19358
19460
|
canManageOnlyWorkspaceCreditLimit,
|
|
19359
19461
|
canShowSharedCredits,
|
|
19360
19462
|
capMoney,
|
|
19463
|
+
cardSetupReturnUrls,
|
|
19361
19464
|
checkPoolPercentTotal,
|
|
19362
19465
|
cleanAutoTopUpInput,
|
|
19363
19466
|
cleanCreditLimitInput,
|
|
@@ -19417,6 +19520,7 @@ export {
|
|
|
19417
19520
|
poolUnallocatedPercent,
|
|
19418
19521
|
poolWorkspaceName,
|
|
19419
19522
|
productsForCountry,
|
|
19523
|
+
readCardSetupReturn,
|
|
19420
19524
|
readSettingsCaller,
|
|
19421
19525
|
referralCodeOf,
|
|
19422
19526
|
referralCountLabel,
|