@streamoid/settings 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +106 -3
- package/dist/index.d.ts +106 -3
- package/dist/index.js +168 -9
- package/dist/index.mjs +166 -7
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -705,8 +705,28 @@ interface BillingSubscription {
|
|
|
705
705
|
/** Stripe product id; used to look up the matching product in fetched plans. */
|
|
706
706
|
stripeProductId?: string;
|
|
707
707
|
}
|
|
708
|
+
/**
|
|
709
|
+
* Whether the workspace gets paid features, and why: `plan` (its own paid
|
|
710
|
+
* plan) or `pool` (it spends a sponsor's shared credits, on its free plan).
|
|
711
|
+
* The plan and billing actions are unchanged by it; see `./entitlement`.
|
|
712
|
+
*/
|
|
713
|
+
interface BillingEntitlement {
|
|
714
|
+
paid: boolean;
|
|
715
|
+
source: "plan" | "pool" | null;
|
|
716
|
+
/** The sponsor's workspace id, for `pool`. */
|
|
717
|
+
sponsorWorkspaceId?: string;
|
|
718
|
+
sponsorName?: string;
|
|
719
|
+
/** When the sharing ends (ISO); null or absent when it runs until removed. */
|
|
720
|
+
endsAt?: string | null;
|
|
721
|
+
}
|
|
708
722
|
interface SubscriptionResponse {
|
|
709
723
|
data: BillingSubscription | null;
|
|
724
|
+
/**
|
|
725
|
+
* Billing's top-level `entitlement` (beside `data`), passed through.
|
|
726
|
+
* Absent on servers from before it, and from hosts that drop it: then the
|
|
727
|
+
* plan alone decides, as before.
|
|
728
|
+
*/
|
|
729
|
+
entitlement?: BillingEntitlement | null;
|
|
710
730
|
}
|
|
711
731
|
interface PriceMetadata {
|
|
712
732
|
name: string;
|
|
@@ -965,7 +985,10 @@ interface SettingsApiAdapter {
|
|
|
965
985
|
fetchPlans: () => Promise<ProductsResponse>;
|
|
966
986
|
/**
|
|
967
987
|
* Current active subscription. Returns `{ data: null }` when the workspace
|
|
968
|
-
* has no plan yet (free tier).
|
|
988
|
+
* has no plan yet (free tier). Pass billing's top-level `entitlement`
|
|
989
|
+
* through as `entitlement`. For billing's 404 (no subscription) that carries
|
|
990
|
+
* one, resolve `{ data: null, entitlement }`, or throw an error that keeps
|
|
991
|
+
* the response body (`body`, `data` or `response.data`).
|
|
969
992
|
*/
|
|
970
993
|
fetchCurrentPlan: () => Promise<SubscriptionResponse>;
|
|
971
994
|
/** Available credit balance for the active workspace. */
|
|
@@ -1424,7 +1447,7 @@ type IconProps = Omit<SVGProps<SVGSVGElement>, 'color' | 'strokeWidth' | 'width'
|
|
|
1424
1447
|
};
|
|
1425
1448
|
declare const SiconKey: ({ color, strokeWidth, size, ...props }: IconProps) => react.JSX.Element;
|
|
1426
1449
|
|
|
1427
|
-
declare function BillingContent({ embedded, showPlans: showPlansProp, onShowPlansChange, showPerUserLimits: showPerUserLimitsProp, onShowPerUserLimitsChange, showSharedCredits: showSharedCreditsProp, onShowSharedCreditsChange, }?: {
|
|
1450
|
+
declare function BillingContent({ embedded, showPlans: showPlansProp, onShowPlansChange, showPerUserLimits: showPerUserLimitsProp, onShowPerUserLimitsChange, showSharedCredits: showSharedCreditsProp, onShowSharedCreditsChange, onEntitlementChange, }?: {
|
|
1428
1451
|
embedded?: boolean;
|
|
1429
1452
|
/** Controlled "plans" sub-view flag. When provided, the host (settings
|
|
1430
1453
|
* wrapper) owns it so it can hide the sub-nav + show the Plans breadcrumb. */
|
|
@@ -1439,6 +1462,14 @@ declare function BillingContent({ embedded, showPlans: showPlansProp, onShowPlan
|
|
|
1439
1462
|
* workspace is in an organization. */
|
|
1440
1463
|
showSharedCredits?: boolean;
|
|
1441
1464
|
onShowSharedCreditsChange?: (open: boolean) => void;
|
|
1465
|
+
/** Called once the current plan has loaded, and again when it changes:
|
|
1466
|
+
* billing's `entitlement` (null from servers without it) and whether the
|
|
1467
|
+
* workspace gets paid features. A workspace spending a sponsor's shared
|
|
1468
|
+
* credits is `paid` on its free plan; gate features on this, not the plan. */
|
|
1469
|
+
onEntitlementChange?: (state: {
|
|
1470
|
+
entitlement: BillingEntitlement | null;
|
|
1471
|
+
paid: boolean;
|
|
1472
|
+
}) => void;
|
|
1442
1473
|
}): react__default.JSX.Element;
|
|
1443
1474
|
|
|
1444
1475
|
/**
|
|
@@ -2204,6 +2235,78 @@ declare function poolErrorMessage(failure: unknown): string | null;
|
|
|
2204
2235
|
*/
|
|
2205
2236
|
declare function SharedCreditsView(): react.JSX.Element;
|
|
2206
2237
|
|
|
2238
|
+
/**
|
|
2239
|
+
* Whether a workspace gets paid features, and why. Billing reports it at the
|
|
2240
|
+
* top level of the current-subscription answer, beside `data` (200:
|
|
2241
|
+
* `{ success, data, entitlement }`; 404: `{ error, entitlement }`), and
|
|
2242
|
+
* leaves the plan as it is: a workspace spending another's shared credits (a
|
|
2243
|
+
* "sponsored" workspace) still shows the free plan, with
|
|
2244
|
+
* `entitlement.source: 'pool'`.
|
|
2245
|
+
*
|
|
2246
|
+
* So the plan — and every billing action: Upgrade, Cancel downgrade, Buy
|
|
2247
|
+
* credits — stays decided by the plan's amount, and only features are gated
|
|
2248
|
+
* on `entitlement.paid`. Billing servers from before entitlement send none;
|
|
2249
|
+
* then a workspace is paid exactly when its plan is, as before.
|
|
2250
|
+
*/
|
|
2251
|
+
/** `entitlement` as billing sends it, or null when it is absent or malformed. */
|
|
2252
|
+
declare function parseBillingEntitlement(value: unknown): BillingEntitlement | null;
|
|
2253
|
+
/**
|
|
2254
|
+
* The `entitlement` of a current-subscription answer: `body.entitlement`,
|
|
2255
|
+
* never `body.data.entitlement` (`data` is the subscription).
|
|
2256
|
+
*/
|
|
2257
|
+
declare function entitlementFromBody(body: unknown): BillingEntitlement | null;
|
|
2258
|
+
/**
|
|
2259
|
+
* The entitlement a failed read carries: billing's 404 for a workspace with
|
|
2260
|
+
* no subscription of its own still says whether a pool entitles it. The body
|
|
2261
|
+
* is looked for where hosts keep it — the failure itself, `body`, `data`
|
|
2262
|
+
* (`UserFacingError`), `response.data` (axios) and `cause` — to a shallow
|
|
2263
|
+
* depth. Null when there is none.
|
|
2264
|
+
*/
|
|
2265
|
+
declare function entitlementFromFailure(failure: unknown): BillingEntitlement | null;
|
|
2266
|
+
/** Paid by the workspace's own plan: what Buy credits and the plan actions go by. */
|
|
2267
|
+
declare function isPaidPlan(subscription: Pick<BillingSubscription, "plan"> | null | undefined): boolean;
|
|
2268
|
+
/**
|
|
2269
|
+
* Whether the workspace gets paid features: `entitlement.paid` when billing
|
|
2270
|
+
* sent one, else its own plan being paid (servers from before entitlement).
|
|
2271
|
+
*/
|
|
2272
|
+
declare function hasPaidFeatures({ entitlement, subscription, }: {
|
|
2273
|
+
entitlement: BillingEntitlement | null | undefined;
|
|
2274
|
+
subscription: Pick<BillingSubscription, "plan"> | null | undefined;
|
|
2275
|
+
}): boolean;
|
|
2276
|
+
/** A workspace spending another's shared credits, by its entitlement. */
|
|
2277
|
+
declare function isSponsoredEntitlement(entitlement: BillingEntitlement | null | undefined): entitlement is BillingEntitlement & {
|
|
2278
|
+
source: "pool";
|
|
2279
|
+
};
|
|
2280
|
+
/** "Credits shared by Agency." plus " Sharing ends on Mar 1, 2027." when it ends on its own. */
|
|
2281
|
+
declare function sponsoredCreditsText(entitlement: Pick<BillingEntitlement, "sponsorName" | "endsAt">): string;
|
|
2282
|
+
interface CurrentPlanState {
|
|
2283
|
+
/** The workspace's own subscription; null without one. */
|
|
2284
|
+
subscription: BillingSubscription | null;
|
|
2285
|
+
/** Null when billing sent none (servers from before entitlement). */
|
|
2286
|
+
entitlement: BillingEntitlement | null;
|
|
2287
|
+
/** Gate features on this; see `hasPaidFeatures`. */
|
|
2288
|
+
paid: boolean;
|
|
2289
|
+
}
|
|
2290
|
+
/**
|
|
2291
|
+
* Read the current plan and its entitlement through the host's
|
|
2292
|
+
* `fetchCurrentPlan`. A failure that carries an entitlement — billing's 404
|
|
2293
|
+
* for a sponsored workspace with no subscription of its own — is not an
|
|
2294
|
+
* error: it answers no subscription with that entitlement. Any other failure
|
|
2295
|
+
* is thrown, as before.
|
|
2296
|
+
*/
|
|
2297
|
+
declare function loadCurrentPlan(fetchCurrentPlan: () => Promise<SubscriptionResponse>): Promise<CurrentPlanState>;
|
|
2298
|
+
|
|
2299
|
+
/**
|
|
2300
|
+
* `loadCurrentPlan` as a hook, for a host gating features on `paid`. Reloads
|
|
2301
|
+
* when `key` (e.g. the workspace id) changes; `fetchCurrentPlan` may be a new
|
|
2302
|
+
* function every render. `state` is null while loading, after a failure, and
|
|
2303
|
+
* while `key` is null.
|
|
2304
|
+
*/
|
|
2305
|
+
declare function useBillingEntitlement(fetchCurrentPlan: (() => Promise<SubscriptionResponse>) | null | undefined, key: string | null | undefined): {
|
|
2306
|
+
state: CurrentPlanState | null;
|
|
2307
|
+
loading: boolean;
|
|
2308
|
+
};
|
|
2309
|
+
|
|
2207
2310
|
type CreditPoolMemberModalProps = {
|
|
2208
2311
|
kind: "add";
|
|
2209
2312
|
/** Workspaces credits can be shared with. */
|
|
@@ -2331,4 +2434,4 @@ interface AppSettingsRowProps {
|
|
|
2331
2434
|
}
|
|
2332
2435
|
declare function AppSettingsRow({ title, description, summary, href, onClick, disabled, disabledReason, ariaLabel, trailing }: AppSettingsRowProps): react.JSX.Element;
|
|
2333
2436
|
|
|
2334
|
-
export { APP_KEYS, type AddCreditPoolMemberInput, AdministrationOverview, type AdministrationOverviewProps, type AdministrativeNavigationOptions, type ApiToken, type AppKey, AppSettingsHeader, type AppSettingsHeaderProps, AppSettingsPage, type AppSettingsPageProps, AppSettingsRow, type AppSettingsRowProps, AppSettingsSection, type AppSettingsSectionProps, type AvailableCreditsResponse, BillingContent, type BillingEventPayload, type BillingProduct, type BillingSubscription, BuyCreditsModal, type BuyCreditsPayload, type BuyCreditsResponse, ConfirmDeleteModal, ConfirmLeaveModal, type ConnectedApp, ConnectedAppsContent, type CreatedToken, type CreditCycleUnit, type CreditLimitValidation, type CreditPoolCandidate, type CreditPoolFormerMember, type CreditPoolMember, CreditPoolMemberModal, type CreditPoolMemberModalProps, type CreditPoolMemberStatus, type CreditPoolMode, type CreditPoolResponse, type CreditsMeter, type CustomCreditInfo, type CustomCreditResponse, DEFAULT_PERMISSIONS, DEFAULT_USER_LANGUAGE, ExportDateModal, InviteUpdateModal, type InvoicePdfResponse, 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, 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, ReferralTab, RemovePoolMemberModal, type RemovePoolMemberModalProps, SCOPE_LABELS, ScopeHeader, type ScopeHeaderProps, type ServiceItem, type SettingsAdapters, SettingsAdaptersProvider, type SettingsApiAdapter, type SettingsAuthAdapter, type SettingsAuthUser, SettingsContent, type SettingsContentProps, type SettingsImageUploadAdapter, type SettingsIntegrationsAdapter, type SettingsNavigationAdapter, type SettingsOrganizationAdapter, type SettingsOrganizationCreateOptions, type SettingsOrganizationCurrent, type SettingsOrganizationJoinableItem, type SettingsOrganizationListItem, type SettingsOrganizationType, type SettingsScope, type SettingsTab, type SettingsToastAdapter, SettingsTooltip, type SettingsTooltipPlacement, type SettingsTooltipProps, type SettingsWorkspaceAdapter, type SettingsWorkspaceCurrent, type SettingsWorkspaceListItem, SharedCreditsView, type SharedPoolBalance, SiconKey, type StoreItem, type SubscriptionPlan, type SubscriptionResponse, TAB_DESCRIPTIONS, TAB_LABELS, TAB_SCOPE, TAB_TO_URL, type TeamMember, TeamsContent, type TokenExpiry, TokensContent, URL_TO_TAB, USER_LANGUAGES, type UpdateCreditPoolMemberInput, type UpdateSubscriptionPayload, type UpdateSubscriptionResponse, type UsageHistoryItem, type UsageHistoryResponse, type UserLanguage, type UserPermissions, WORKSPACE_LIST_PAGE_SIZE, 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, belowUsageReason, canShowSharedCredits, cleanCreditLimitInput, cleanPoolValueInput, countLabel, creditCycleUnit, creditsMeter, deriveWorkspaceInvitePermission, describeAllowance, describeDefaultLimit, describeMemberLimit, expiryChoiceFor, findBillingError, findPoolError, formatCreditLimit, formatCredits, formatPoolEndsAt, formatPoolSplit, groupWorkspaceList, isLimitBelowUsage, joinMembersWithLimits, lastUsedLabel, limitBelowUsageUsed, limitSourceLabel, loadWorkspaceOrganization, memberRoleUpdate, minPoolEndDate, minimumCreditLimit, ownCreditsFirstText, pausedOwnCreditsText, poolEndsAtFrom, poolErrorMessage, poolRenewsAtCycleEnd, poolWorkspaceName, readSettingsCaller, rememberSettingsCaller, resolveSettingsTabFromPath, roundCredits, settingsReturnTarget, sharedPoolBannerText, sharedPoolEndsText, toLocalDateInput, useSettingsAdapters, useWorkspaceInvitePermission, useWorkspaceOrganization, usedByNamesFrom, usedByWorkspaceKey, userLanguageLabel, validateCreditLimitInput, validateDefaultCreditLimitInput, validatePoolText, validatePoolValue };
|
|
2437
|
+
export { APP_KEYS, type AddCreditPoolMemberInput, AdministrationOverview, type AdministrationOverviewProps, type AdministrativeNavigationOptions, type ApiToken, type AppKey, AppSettingsHeader, type AppSettingsHeaderProps, AppSettingsPage, type AppSettingsPageProps, AppSettingsRow, type AppSettingsRowProps, AppSettingsSection, type AppSettingsSectionProps, type AvailableCreditsResponse, BillingContent, type BillingEntitlement, type BillingEventPayload, type BillingProduct, type BillingSubscription, BuyCreditsModal, type BuyCreditsPayload, type BuyCreditsResponse, ConfirmDeleteModal, ConfirmLeaveModal, type ConnectedApp, ConnectedAppsContent, type CreatedToken, type CreditCycleUnit, type CreditLimitValidation, type CreditPoolCandidate, type CreditPoolFormerMember, type CreditPoolMember, CreditPoolMemberModal, type CreditPoolMemberModalProps, type CreditPoolMemberStatus, type CreditPoolMode, type CreditPoolResponse, type CreditsMeter, type CurrentPlanState, type CustomCreditInfo, type CustomCreditResponse, DEFAULT_PERMISSIONS, DEFAULT_USER_LANGUAGE, ExportDateModal, InviteUpdateModal, type InvoicePdfResponse, 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, 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, ReferralTab, RemovePoolMemberModal, type RemovePoolMemberModalProps, SCOPE_LABELS, ScopeHeader, type ScopeHeaderProps, type ServiceItem, type SettingsAdapters, SettingsAdaptersProvider, type SettingsApiAdapter, type SettingsAuthAdapter, type SettingsAuthUser, SettingsContent, type SettingsContentProps, type SettingsImageUploadAdapter, type SettingsIntegrationsAdapter, type SettingsNavigationAdapter, type SettingsOrganizationAdapter, type SettingsOrganizationCreateOptions, type SettingsOrganizationCurrent, type SettingsOrganizationJoinableItem, type SettingsOrganizationListItem, type SettingsOrganizationType, type SettingsScope, type SettingsTab, type SettingsToastAdapter, SettingsTooltip, type SettingsTooltipPlacement, type SettingsTooltipProps, type SettingsWorkspaceAdapter, type SettingsWorkspaceCurrent, type SettingsWorkspaceListItem, SharedCreditsView, type SharedPoolBalance, SiconKey, type StoreItem, type SubscriptionPlan, type SubscriptionResponse, TAB_DESCRIPTIONS, TAB_LABELS, TAB_SCOPE, TAB_TO_URL, type TeamMember, TeamsContent, type TokenExpiry, TokensContent, URL_TO_TAB, USER_LANGUAGES, type UpdateCreditPoolMemberInput, type UpdateSubscriptionPayload, type UpdateSubscriptionResponse, type UsageHistoryItem, type UsageHistoryResponse, type UserLanguage, type UserPermissions, WORKSPACE_LIST_PAGE_SIZE, 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, belowUsageReason, canShowSharedCredits, cleanCreditLimitInput, cleanPoolValueInput, countLabel, creditCycleUnit, creditsMeter, deriveWorkspaceInvitePermission, describeAllowance, describeDefaultLimit, describeMemberLimit, entitlementFromBody, entitlementFromFailure, expiryChoiceFor, findBillingError, findPoolError, formatCreditLimit, formatCredits, formatPoolEndsAt, formatPoolSplit, groupWorkspaceList, hasPaidFeatures, isLimitBelowUsage, isPaidPlan, isSponsoredEntitlement, joinMembersWithLimits, lastUsedLabel, limitBelowUsageUsed, limitSourceLabel, loadCurrentPlan, loadWorkspaceOrganization, memberRoleUpdate, minPoolEndDate, minimumCreditLimit, ownCreditsFirstText, parseBillingEntitlement, pausedOwnCreditsText, poolEndsAtFrom, poolErrorMessage, poolRenewsAtCycleEnd, poolWorkspaceName, readSettingsCaller, rememberSettingsCaller, resolveSettingsTabFromPath, roundCredits, settingsReturnTarget, sharedPoolBannerText, sharedPoolEndsText, sponsoredCreditsText, toLocalDateInput, useBillingEntitlement, useSettingsAdapters, useWorkspaceInvitePermission, useWorkspaceOrganization, usedByNamesFrom, usedByWorkspaceKey, userLanguageLabel, validateCreditLimitInput, validateDefaultCreditLimitInput, validatePoolText, validatePoolValue };
|
package/dist/index.d.ts
CHANGED
|
@@ -705,8 +705,28 @@ interface BillingSubscription {
|
|
|
705
705
|
/** Stripe product id; used to look up the matching product in fetched plans. */
|
|
706
706
|
stripeProductId?: string;
|
|
707
707
|
}
|
|
708
|
+
/**
|
|
709
|
+
* Whether the workspace gets paid features, and why: `plan` (its own paid
|
|
710
|
+
* plan) or `pool` (it spends a sponsor's shared credits, on its free plan).
|
|
711
|
+
* The plan and billing actions are unchanged by it; see `./entitlement`.
|
|
712
|
+
*/
|
|
713
|
+
interface BillingEntitlement {
|
|
714
|
+
paid: boolean;
|
|
715
|
+
source: "plan" | "pool" | null;
|
|
716
|
+
/** The sponsor's workspace id, for `pool`. */
|
|
717
|
+
sponsorWorkspaceId?: string;
|
|
718
|
+
sponsorName?: string;
|
|
719
|
+
/** When the sharing ends (ISO); null or absent when it runs until removed. */
|
|
720
|
+
endsAt?: string | null;
|
|
721
|
+
}
|
|
708
722
|
interface SubscriptionResponse {
|
|
709
723
|
data: BillingSubscription | null;
|
|
724
|
+
/**
|
|
725
|
+
* Billing's top-level `entitlement` (beside `data`), passed through.
|
|
726
|
+
* Absent on servers from before it, and from hosts that drop it: then the
|
|
727
|
+
* plan alone decides, as before.
|
|
728
|
+
*/
|
|
729
|
+
entitlement?: BillingEntitlement | null;
|
|
710
730
|
}
|
|
711
731
|
interface PriceMetadata {
|
|
712
732
|
name: string;
|
|
@@ -965,7 +985,10 @@ interface SettingsApiAdapter {
|
|
|
965
985
|
fetchPlans: () => Promise<ProductsResponse>;
|
|
966
986
|
/**
|
|
967
987
|
* Current active subscription. Returns `{ data: null }` when the workspace
|
|
968
|
-
* has no plan yet (free tier).
|
|
988
|
+
* has no plan yet (free tier). Pass billing's top-level `entitlement`
|
|
989
|
+
* through as `entitlement`. For billing's 404 (no subscription) that carries
|
|
990
|
+
* one, resolve `{ data: null, entitlement }`, or throw an error that keeps
|
|
991
|
+
* the response body (`body`, `data` or `response.data`).
|
|
969
992
|
*/
|
|
970
993
|
fetchCurrentPlan: () => Promise<SubscriptionResponse>;
|
|
971
994
|
/** Available credit balance for the active workspace. */
|
|
@@ -1424,7 +1447,7 @@ type IconProps = Omit<SVGProps<SVGSVGElement>, 'color' | 'strokeWidth' | 'width'
|
|
|
1424
1447
|
};
|
|
1425
1448
|
declare const SiconKey: ({ color, strokeWidth, size, ...props }: IconProps) => react.JSX.Element;
|
|
1426
1449
|
|
|
1427
|
-
declare function BillingContent({ embedded, showPlans: showPlansProp, onShowPlansChange, showPerUserLimits: showPerUserLimitsProp, onShowPerUserLimitsChange, showSharedCredits: showSharedCreditsProp, onShowSharedCreditsChange, }?: {
|
|
1450
|
+
declare function BillingContent({ embedded, showPlans: showPlansProp, onShowPlansChange, showPerUserLimits: showPerUserLimitsProp, onShowPerUserLimitsChange, showSharedCredits: showSharedCreditsProp, onShowSharedCreditsChange, onEntitlementChange, }?: {
|
|
1428
1451
|
embedded?: boolean;
|
|
1429
1452
|
/** Controlled "plans" sub-view flag. When provided, the host (settings
|
|
1430
1453
|
* wrapper) owns it so it can hide the sub-nav + show the Plans breadcrumb. */
|
|
@@ -1439,6 +1462,14 @@ declare function BillingContent({ embedded, showPlans: showPlansProp, onShowPlan
|
|
|
1439
1462
|
* workspace is in an organization. */
|
|
1440
1463
|
showSharedCredits?: boolean;
|
|
1441
1464
|
onShowSharedCreditsChange?: (open: boolean) => void;
|
|
1465
|
+
/** Called once the current plan has loaded, and again when it changes:
|
|
1466
|
+
* billing's `entitlement` (null from servers without it) and whether the
|
|
1467
|
+
* workspace gets paid features. A workspace spending a sponsor's shared
|
|
1468
|
+
* credits is `paid` on its free plan; gate features on this, not the plan. */
|
|
1469
|
+
onEntitlementChange?: (state: {
|
|
1470
|
+
entitlement: BillingEntitlement | null;
|
|
1471
|
+
paid: boolean;
|
|
1472
|
+
}) => void;
|
|
1442
1473
|
}): react__default.JSX.Element;
|
|
1443
1474
|
|
|
1444
1475
|
/**
|
|
@@ -2204,6 +2235,78 @@ declare function poolErrorMessage(failure: unknown): string | null;
|
|
|
2204
2235
|
*/
|
|
2205
2236
|
declare function SharedCreditsView(): react.JSX.Element;
|
|
2206
2237
|
|
|
2238
|
+
/**
|
|
2239
|
+
* Whether a workspace gets paid features, and why. Billing reports it at the
|
|
2240
|
+
* top level of the current-subscription answer, beside `data` (200:
|
|
2241
|
+
* `{ success, data, entitlement }`; 404: `{ error, entitlement }`), and
|
|
2242
|
+
* leaves the plan as it is: a workspace spending another's shared credits (a
|
|
2243
|
+
* "sponsored" workspace) still shows the free plan, with
|
|
2244
|
+
* `entitlement.source: 'pool'`.
|
|
2245
|
+
*
|
|
2246
|
+
* So the plan — and every billing action: Upgrade, Cancel downgrade, Buy
|
|
2247
|
+
* credits — stays decided by the plan's amount, and only features are gated
|
|
2248
|
+
* on `entitlement.paid`. Billing servers from before entitlement send none;
|
|
2249
|
+
* then a workspace is paid exactly when its plan is, as before.
|
|
2250
|
+
*/
|
|
2251
|
+
/** `entitlement` as billing sends it, or null when it is absent or malformed. */
|
|
2252
|
+
declare function parseBillingEntitlement(value: unknown): BillingEntitlement | null;
|
|
2253
|
+
/**
|
|
2254
|
+
* The `entitlement` of a current-subscription answer: `body.entitlement`,
|
|
2255
|
+
* never `body.data.entitlement` (`data` is the subscription).
|
|
2256
|
+
*/
|
|
2257
|
+
declare function entitlementFromBody(body: unknown): BillingEntitlement | null;
|
|
2258
|
+
/**
|
|
2259
|
+
* The entitlement a failed read carries: billing's 404 for a workspace with
|
|
2260
|
+
* no subscription of its own still says whether a pool entitles it. The body
|
|
2261
|
+
* is looked for where hosts keep it — the failure itself, `body`, `data`
|
|
2262
|
+
* (`UserFacingError`), `response.data` (axios) and `cause` — to a shallow
|
|
2263
|
+
* depth. Null when there is none.
|
|
2264
|
+
*/
|
|
2265
|
+
declare function entitlementFromFailure(failure: unknown): BillingEntitlement | null;
|
|
2266
|
+
/** Paid by the workspace's own plan: what Buy credits and the plan actions go by. */
|
|
2267
|
+
declare function isPaidPlan(subscription: Pick<BillingSubscription, "plan"> | null | undefined): boolean;
|
|
2268
|
+
/**
|
|
2269
|
+
* Whether the workspace gets paid features: `entitlement.paid` when billing
|
|
2270
|
+
* sent one, else its own plan being paid (servers from before entitlement).
|
|
2271
|
+
*/
|
|
2272
|
+
declare function hasPaidFeatures({ entitlement, subscription, }: {
|
|
2273
|
+
entitlement: BillingEntitlement | null | undefined;
|
|
2274
|
+
subscription: Pick<BillingSubscription, "plan"> | null | undefined;
|
|
2275
|
+
}): boolean;
|
|
2276
|
+
/** A workspace spending another's shared credits, by its entitlement. */
|
|
2277
|
+
declare function isSponsoredEntitlement(entitlement: BillingEntitlement | null | undefined): entitlement is BillingEntitlement & {
|
|
2278
|
+
source: "pool";
|
|
2279
|
+
};
|
|
2280
|
+
/** "Credits shared by Agency." plus " Sharing ends on Mar 1, 2027." when it ends on its own. */
|
|
2281
|
+
declare function sponsoredCreditsText(entitlement: Pick<BillingEntitlement, "sponsorName" | "endsAt">): string;
|
|
2282
|
+
interface CurrentPlanState {
|
|
2283
|
+
/** The workspace's own subscription; null without one. */
|
|
2284
|
+
subscription: BillingSubscription | null;
|
|
2285
|
+
/** Null when billing sent none (servers from before entitlement). */
|
|
2286
|
+
entitlement: BillingEntitlement | null;
|
|
2287
|
+
/** Gate features on this; see `hasPaidFeatures`. */
|
|
2288
|
+
paid: boolean;
|
|
2289
|
+
}
|
|
2290
|
+
/**
|
|
2291
|
+
* Read the current plan and its entitlement through the host's
|
|
2292
|
+
* `fetchCurrentPlan`. A failure that carries an entitlement — billing's 404
|
|
2293
|
+
* for a sponsored workspace with no subscription of its own — is not an
|
|
2294
|
+
* error: it answers no subscription with that entitlement. Any other failure
|
|
2295
|
+
* is thrown, as before.
|
|
2296
|
+
*/
|
|
2297
|
+
declare function loadCurrentPlan(fetchCurrentPlan: () => Promise<SubscriptionResponse>): Promise<CurrentPlanState>;
|
|
2298
|
+
|
|
2299
|
+
/**
|
|
2300
|
+
* `loadCurrentPlan` as a hook, for a host gating features on `paid`. Reloads
|
|
2301
|
+
* when `key` (e.g. the workspace id) changes; `fetchCurrentPlan` may be a new
|
|
2302
|
+
* function every render. `state` is null while loading, after a failure, and
|
|
2303
|
+
* while `key` is null.
|
|
2304
|
+
*/
|
|
2305
|
+
declare function useBillingEntitlement(fetchCurrentPlan: (() => Promise<SubscriptionResponse>) | null | undefined, key: string | null | undefined): {
|
|
2306
|
+
state: CurrentPlanState | null;
|
|
2307
|
+
loading: boolean;
|
|
2308
|
+
};
|
|
2309
|
+
|
|
2207
2310
|
type CreditPoolMemberModalProps = {
|
|
2208
2311
|
kind: "add";
|
|
2209
2312
|
/** Workspaces credits can be shared with. */
|
|
@@ -2331,4 +2434,4 @@ interface AppSettingsRowProps {
|
|
|
2331
2434
|
}
|
|
2332
2435
|
declare function AppSettingsRow({ title, description, summary, href, onClick, disabled, disabledReason, ariaLabel, trailing }: AppSettingsRowProps): react.JSX.Element;
|
|
2333
2436
|
|
|
2334
|
-
export { APP_KEYS, type AddCreditPoolMemberInput, AdministrationOverview, type AdministrationOverviewProps, type AdministrativeNavigationOptions, type ApiToken, type AppKey, AppSettingsHeader, type AppSettingsHeaderProps, AppSettingsPage, type AppSettingsPageProps, AppSettingsRow, type AppSettingsRowProps, AppSettingsSection, type AppSettingsSectionProps, type AvailableCreditsResponse, BillingContent, type BillingEventPayload, type BillingProduct, type BillingSubscription, BuyCreditsModal, type BuyCreditsPayload, type BuyCreditsResponse, ConfirmDeleteModal, ConfirmLeaveModal, type ConnectedApp, ConnectedAppsContent, type CreatedToken, type CreditCycleUnit, type CreditLimitValidation, type CreditPoolCandidate, type CreditPoolFormerMember, type CreditPoolMember, CreditPoolMemberModal, type CreditPoolMemberModalProps, type CreditPoolMemberStatus, type CreditPoolMode, type CreditPoolResponse, type CreditsMeter, type CustomCreditInfo, type CustomCreditResponse, DEFAULT_PERMISSIONS, DEFAULT_USER_LANGUAGE, ExportDateModal, InviteUpdateModal, type InvoicePdfResponse, 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, 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, ReferralTab, RemovePoolMemberModal, type RemovePoolMemberModalProps, SCOPE_LABELS, ScopeHeader, type ScopeHeaderProps, type ServiceItem, type SettingsAdapters, SettingsAdaptersProvider, type SettingsApiAdapter, type SettingsAuthAdapter, type SettingsAuthUser, SettingsContent, type SettingsContentProps, type SettingsImageUploadAdapter, type SettingsIntegrationsAdapter, type SettingsNavigationAdapter, type SettingsOrganizationAdapter, type SettingsOrganizationCreateOptions, type SettingsOrganizationCurrent, type SettingsOrganizationJoinableItem, type SettingsOrganizationListItem, type SettingsOrganizationType, type SettingsScope, type SettingsTab, type SettingsToastAdapter, SettingsTooltip, type SettingsTooltipPlacement, type SettingsTooltipProps, type SettingsWorkspaceAdapter, type SettingsWorkspaceCurrent, type SettingsWorkspaceListItem, SharedCreditsView, type SharedPoolBalance, SiconKey, type StoreItem, type SubscriptionPlan, type SubscriptionResponse, TAB_DESCRIPTIONS, TAB_LABELS, TAB_SCOPE, TAB_TO_URL, type TeamMember, TeamsContent, type TokenExpiry, TokensContent, URL_TO_TAB, USER_LANGUAGES, type UpdateCreditPoolMemberInput, type UpdateSubscriptionPayload, type UpdateSubscriptionResponse, type UsageHistoryItem, type UsageHistoryResponse, type UserLanguage, type UserPermissions, WORKSPACE_LIST_PAGE_SIZE, 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, belowUsageReason, canShowSharedCredits, cleanCreditLimitInput, cleanPoolValueInput, countLabel, creditCycleUnit, creditsMeter, deriveWorkspaceInvitePermission, describeAllowance, describeDefaultLimit, describeMemberLimit, expiryChoiceFor, findBillingError, findPoolError, formatCreditLimit, formatCredits, formatPoolEndsAt, formatPoolSplit, groupWorkspaceList, isLimitBelowUsage, joinMembersWithLimits, lastUsedLabel, limitBelowUsageUsed, limitSourceLabel, loadWorkspaceOrganization, memberRoleUpdate, minPoolEndDate, minimumCreditLimit, ownCreditsFirstText, pausedOwnCreditsText, poolEndsAtFrom, poolErrorMessage, poolRenewsAtCycleEnd, poolWorkspaceName, readSettingsCaller, rememberSettingsCaller, resolveSettingsTabFromPath, roundCredits, settingsReturnTarget, sharedPoolBannerText, sharedPoolEndsText, toLocalDateInput, useSettingsAdapters, useWorkspaceInvitePermission, useWorkspaceOrganization, usedByNamesFrom, usedByWorkspaceKey, userLanguageLabel, validateCreditLimitInput, validateDefaultCreditLimitInput, validatePoolText, validatePoolValue };
|
|
2437
|
+
export { APP_KEYS, type AddCreditPoolMemberInput, AdministrationOverview, type AdministrationOverviewProps, type AdministrativeNavigationOptions, type ApiToken, type AppKey, AppSettingsHeader, type AppSettingsHeaderProps, AppSettingsPage, type AppSettingsPageProps, AppSettingsRow, type AppSettingsRowProps, AppSettingsSection, type AppSettingsSectionProps, type AvailableCreditsResponse, BillingContent, type BillingEntitlement, type BillingEventPayload, type BillingProduct, type BillingSubscription, BuyCreditsModal, type BuyCreditsPayload, type BuyCreditsResponse, ConfirmDeleteModal, ConfirmLeaveModal, type ConnectedApp, ConnectedAppsContent, type CreatedToken, type CreditCycleUnit, type CreditLimitValidation, type CreditPoolCandidate, type CreditPoolFormerMember, type CreditPoolMember, CreditPoolMemberModal, type CreditPoolMemberModalProps, type CreditPoolMemberStatus, type CreditPoolMode, type CreditPoolResponse, type CreditsMeter, type CurrentPlanState, type CustomCreditInfo, type CustomCreditResponse, DEFAULT_PERMISSIONS, DEFAULT_USER_LANGUAGE, ExportDateModal, InviteUpdateModal, type InvoicePdfResponse, 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, 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, ReferralTab, RemovePoolMemberModal, type RemovePoolMemberModalProps, SCOPE_LABELS, ScopeHeader, type ScopeHeaderProps, type ServiceItem, type SettingsAdapters, SettingsAdaptersProvider, type SettingsApiAdapter, type SettingsAuthAdapter, type SettingsAuthUser, SettingsContent, type SettingsContentProps, type SettingsImageUploadAdapter, type SettingsIntegrationsAdapter, type SettingsNavigationAdapter, type SettingsOrganizationAdapter, type SettingsOrganizationCreateOptions, type SettingsOrganizationCurrent, type SettingsOrganizationJoinableItem, type SettingsOrganizationListItem, type SettingsOrganizationType, type SettingsScope, type SettingsTab, type SettingsToastAdapter, SettingsTooltip, type SettingsTooltipPlacement, type SettingsTooltipProps, type SettingsWorkspaceAdapter, type SettingsWorkspaceCurrent, type SettingsWorkspaceListItem, SharedCreditsView, type SharedPoolBalance, SiconKey, type StoreItem, type SubscriptionPlan, type SubscriptionResponse, TAB_DESCRIPTIONS, TAB_LABELS, TAB_SCOPE, TAB_TO_URL, type TeamMember, TeamsContent, type TokenExpiry, TokensContent, URL_TO_TAB, USER_LANGUAGES, type UpdateCreditPoolMemberInput, type UpdateSubscriptionPayload, type UpdateSubscriptionResponse, type UsageHistoryItem, type UsageHistoryResponse, type UserLanguage, type UserPermissions, WORKSPACE_LIST_PAGE_SIZE, 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, belowUsageReason, canShowSharedCredits, cleanCreditLimitInput, cleanPoolValueInput, countLabel, creditCycleUnit, creditsMeter, deriveWorkspaceInvitePermission, describeAllowance, describeDefaultLimit, describeMemberLimit, entitlementFromBody, entitlementFromFailure, expiryChoiceFor, findBillingError, findPoolError, formatCreditLimit, formatCredits, formatPoolEndsAt, formatPoolSplit, groupWorkspaceList, hasPaidFeatures, isLimitBelowUsage, isPaidPlan, isSponsoredEntitlement, joinMembersWithLimits, lastUsedLabel, limitBelowUsageUsed, limitSourceLabel, loadCurrentPlan, loadWorkspaceOrganization, memberRoleUpdate, minPoolEndDate, minimumCreditLimit, ownCreditsFirstText, parseBillingEntitlement, pausedOwnCreditsText, poolEndsAtFrom, poolErrorMessage, poolRenewsAtCycleEnd, poolWorkspaceName, readSettingsCaller, rememberSettingsCaller, resolveSettingsTabFromPath, roundCredits, settingsReturnTarget, sharedPoolBannerText, sharedPoolEndsText, sponsoredCreditsText, toLocalDateInput, useBillingEntitlement, useSettingsAdapters, useWorkspaceInvitePermission, useWorkspaceOrganization, usedByNamesFrom, usedByWorkspaceKey, userLanguageLabel, validateCreditLimitInput, validateDefaultCreditLimitInput, validatePoolText, validatePoolValue };
|
package/dist/index.js
CHANGED
|
@@ -85,6 +85,8 @@ __export(index_exports, {
|
|
|
85
85
|
describeAllowance: () => describeAllowance,
|
|
86
86
|
describeDefaultLimit: () => describeDefaultLimit,
|
|
87
87
|
describeMemberLimit: () => describeMemberLimit,
|
|
88
|
+
entitlementFromBody: () => entitlementFromBody,
|
|
89
|
+
entitlementFromFailure: () => entitlementFromFailure,
|
|
88
90
|
expiryChoiceFor: () => expiryChoiceFor,
|
|
89
91
|
findBillingError: () => findBillingError,
|
|
90
92
|
findPoolError: () => findPoolError,
|
|
@@ -93,16 +95,21 @@ __export(index_exports, {
|
|
|
93
95
|
formatPoolEndsAt: () => formatPoolEndsAt,
|
|
94
96
|
formatPoolSplit: () => formatPoolSplit,
|
|
95
97
|
groupWorkspaceList: () => groupWorkspaceList,
|
|
98
|
+
hasPaidFeatures: () => hasPaidFeatures,
|
|
96
99
|
isLimitBelowUsage: () => isLimitBelowUsage,
|
|
100
|
+
isPaidPlan: () => isPaidPlan,
|
|
101
|
+
isSponsoredEntitlement: () => isSponsoredEntitlement,
|
|
97
102
|
joinMembersWithLimits: () => joinMembersWithLimits,
|
|
98
103
|
lastUsedLabel: () => lastUsedLabel,
|
|
99
104
|
limitBelowUsageUsed: () => limitBelowUsageUsed,
|
|
100
105
|
limitSourceLabel: () => limitSourceLabel,
|
|
106
|
+
loadCurrentPlan: () => loadCurrentPlan,
|
|
101
107
|
loadWorkspaceOrganization: () => loadWorkspaceOrganization,
|
|
102
108
|
memberRoleUpdate: () => memberRoleUpdate,
|
|
103
109
|
minPoolEndDate: () => minPoolEndDate,
|
|
104
110
|
minimumCreditLimit: () => minimumCreditLimit,
|
|
105
111
|
ownCreditsFirstText: () => ownCreditsFirstText,
|
|
112
|
+
parseBillingEntitlement: () => parseBillingEntitlement,
|
|
106
113
|
pausedOwnCreditsText: () => pausedOwnCreditsText,
|
|
107
114
|
poolEndsAtFrom: () => poolEndsAtFrom,
|
|
108
115
|
poolErrorMessage: () => poolErrorMessage,
|
|
@@ -115,7 +122,9 @@ __export(index_exports, {
|
|
|
115
122
|
settingsReturnTarget: () => settingsReturnTarget,
|
|
116
123
|
sharedPoolBannerText: () => sharedPoolBannerText,
|
|
117
124
|
sharedPoolEndsText: () => sharedPoolEndsText,
|
|
125
|
+
sponsoredCreditsText: () => sponsoredCreditsText,
|
|
118
126
|
toLocalDateInput: () => toLocalDateInput,
|
|
127
|
+
useBillingEntitlement: () => useBillingEntitlement,
|
|
119
128
|
useSettingsAdapters: () => useSettingsAdapters,
|
|
120
129
|
useWorkspaceInvitePermission: () => useWorkspaceInvitePermission,
|
|
121
130
|
useWorkspaceOrganization: () => useWorkspaceOrganization,
|
|
@@ -10585,6 +10594,71 @@ function SharedCreditsView() {
|
|
|
10585
10594
|
] });
|
|
10586
10595
|
}
|
|
10587
10596
|
|
|
10597
|
+
// src/entitlement.ts
|
|
10598
|
+
function parseBillingEntitlement(value) {
|
|
10599
|
+
if (!value || typeof value !== "object") return null;
|
|
10600
|
+
const raw = value;
|
|
10601
|
+
if (typeof raw.paid !== "boolean") return null;
|
|
10602
|
+
const source = raw.source === "plan" || raw.source === "pool" ? raw.source : null;
|
|
10603
|
+
const entitlement = { paid: raw.paid, source };
|
|
10604
|
+
if (typeof raw.sponsorWorkspaceId === "string") entitlement.sponsorWorkspaceId = raw.sponsorWorkspaceId;
|
|
10605
|
+
if (typeof raw.sponsorName === "string") entitlement.sponsorName = raw.sponsorName;
|
|
10606
|
+
if (typeof raw.endsAt === "string" || raw.endsAt === null) entitlement.endsAt = raw.endsAt;
|
|
10607
|
+
return entitlement;
|
|
10608
|
+
}
|
|
10609
|
+
function entitlementFromBody(body) {
|
|
10610
|
+
if (!body || typeof body !== "object") return null;
|
|
10611
|
+
return parseBillingEntitlement(body.entitlement);
|
|
10612
|
+
}
|
|
10613
|
+
function entitlementFromFailure(failure) {
|
|
10614
|
+
const seen = /* @__PURE__ */ new Set();
|
|
10615
|
+
const visit = (value, depth) => {
|
|
10616
|
+
if (depth > 4 || value == null || typeof value !== "object" || seen.has(value)) return null;
|
|
10617
|
+
seen.add(value);
|
|
10618
|
+
const found = entitlementFromBody(value);
|
|
10619
|
+
if (found) return found;
|
|
10620
|
+
const error = value;
|
|
10621
|
+
const response = error.response;
|
|
10622
|
+
for (const child of [error.body, error.data, response?.data, error.cause]) {
|
|
10623
|
+
const nested = visit(child, depth + 1);
|
|
10624
|
+
if (nested) return nested;
|
|
10625
|
+
}
|
|
10626
|
+
return null;
|
|
10627
|
+
};
|
|
10628
|
+
return visit(failure, 0);
|
|
10629
|
+
}
|
|
10630
|
+
function isPaidPlan(subscription) {
|
|
10631
|
+
const amount = subscription?.plan?.amount;
|
|
10632
|
+
return amount != null && amount > 0;
|
|
10633
|
+
}
|
|
10634
|
+
function hasPaidFeatures({
|
|
10635
|
+
entitlement,
|
|
10636
|
+
subscription
|
|
10637
|
+
}) {
|
|
10638
|
+
return entitlement ? entitlement.paid : isPaidPlan(subscription);
|
|
10639
|
+
}
|
|
10640
|
+
function isSponsoredEntitlement(entitlement) {
|
|
10641
|
+
return entitlement?.source === "pool" && entitlement.paid;
|
|
10642
|
+
}
|
|
10643
|
+
function sponsoredCreditsText(entitlement) {
|
|
10644
|
+
const sponsor = entitlement.sponsorName?.trim() || "another workspace";
|
|
10645
|
+
const ends = entitlement.endsAt ? ` Sharing ends on ${formatPoolEndsAt(entitlement.endsAt)}.` : "";
|
|
10646
|
+
return `Credits shared by ${sponsor}.${ends}`;
|
|
10647
|
+
}
|
|
10648
|
+
async function loadCurrentPlan(fetchCurrentPlan) {
|
|
10649
|
+
let response;
|
|
10650
|
+
try {
|
|
10651
|
+
response = await fetchCurrentPlan();
|
|
10652
|
+
} catch (failure) {
|
|
10653
|
+
const entitlement2 = entitlementFromFailure(failure);
|
|
10654
|
+
if (!entitlement2) throw failure;
|
|
10655
|
+
return { subscription: null, entitlement: entitlement2, paid: entitlement2.paid };
|
|
10656
|
+
}
|
|
10657
|
+
const subscription = response?.data ?? null;
|
|
10658
|
+
const entitlement = entitlementFromBody(response);
|
|
10659
|
+
return { subscription, entitlement, paid: hasPaidFeatures({ entitlement, subscription }) };
|
|
10660
|
+
}
|
|
10661
|
+
|
|
10588
10662
|
// src/billing-content.tsx
|
|
10589
10663
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
10590
10664
|
var DEFAULT_TOPUP_SERVICE = "catalogix";
|
|
@@ -11716,7 +11790,8 @@ function BillingContent({
|
|
|
11716
11790
|
showPerUserLimits: showPerUserLimitsProp,
|
|
11717
11791
|
onShowPerUserLimitsChange,
|
|
11718
11792
|
showSharedCredits: showSharedCreditsProp,
|
|
11719
|
-
onShowSharedCreditsChange
|
|
11793
|
+
onShowSharedCreditsChange,
|
|
11794
|
+
onEntitlementChange
|
|
11720
11795
|
} = {}) {
|
|
11721
11796
|
const { auth, workspace, organization, api, toast, navigation } = useSettingsAdapters();
|
|
11722
11797
|
const user = auth.user;
|
|
@@ -11755,6 +11830,9 @@ function BillingContent({
|
|
|
11755
11830
|
const [showExportModal, setShowExportModal] = (0, import_react23.useState)(false);
|
|
11756
11831
|
const [showBuyCreditsModal, setShowBuyCreditsModal] = (0, import_react23.useState)(false);
|
|
11757
11832
|
const [subscription, setSubscription] = (0, import_react23.useState)(null);
|
|
11833
|
+
const [entitlement, setEntitlement] = (0, import_react23.useState)(
|
|
11834
|
+
null
|
|
11835
|
+
);
|
|
11758
11836
|
const [availableCredits, setAvailableCredits] = (0, import_react23.useState)(null);
|
|
11759
11837
|
const [sharedPool, setSharedPool] = (0, import_react23.useState)(null);
|
|
11760
11838
|
const [usedByNames, setUsedByNames] = (0, import_react23.useState)({});
|
|
@@ -11800,12 +11878,15 @@ function BillingContent({
|
|
|
11800
11878
|
try {
|
|
11801
11879
|
console.log("calling Billing apis");
|
|
11802
11880
|
const [subRes, creditsRes, productsRes, customRes] = await Promise.all([
|
|
11803
|
-
|
|
11881
|
+
// A sponsored workspace with no subscription of its own gets a 404
|
|
11882
|
+
// that carries its entitlement: loadCurrentPlan answers it, not throws.
|
|
11883
|
+
loadCurrentPlan(api.fetchCurrentPlan).catch(() => null),
|
|
11804
11884
|
api.fetchAvailableCredits().catch(() => null),
|
|
11805
11885
|
api.fetchPlans().catch(() => null),
|
|
11806
11886
|
api.getCustomCreditInfo?.().catch(() => null) ?? Promise.resolve(null)
|
|
11807
11887
|
]);
|
|
11808
|
-
if (subRes?.
|
|
11888
|
+
if (subRes?.subscription) setSubscription(subRes.subscription);
|
|
11889
|
+
if (subRes) setEntitlement(subRes.entitlement);
|
|
11809
11890
|
if (creditsRes?.availableCredits != null)
|
|
11810
11891
|
setAvailableCredits(creditsRes.availableCredits);
|
|
11811
11892
|
setSharedPool(creditsRes?.sharedPool ?? null);
|
|
@@ -11975,6 +12056,7 @@ function BillingContent({
|
|
|
11975
12056
|
setInitialFetchTriggered(false);
|
|
11976
12057
|
setBillingOverviewLoaded(false);
|
|
11977
12058
|
setSubscription(null);
|
|
12059
|
+
setEntitlement(null);
|
|
11978
12060
|
setAvailableCredits(null);
|
|
11979
12061
|
setProducts([]);
|
|
11980
12062
|
setTotalCredits(null);
|
|
@@ -12030,7 +12112,16 @@ function BillingContent({
|
|
|
12030
12112
|
subscription?.scheduledDowngradeEffectiveDate
|
|
12031
12113
|
);
|
|
12032
12114
|
const scheduledDowngradeText = subscription?.downgradeScheduled && subscription.plan?.name ? `Downgrades to ${subscription.plan.name}${scheduledDowngradeDateLabel ? ` ${scheduledDowngradeDateLabel}` : ""}` : void 0;
|
|
12033
|
-
const
|
|
12115
|
+
const sponsored = isSponsoredEntitlement(entitlement);
|
|
12116
|
+
const sponsoredWithoutPlan = sponsored && billingOverviewLoaded && !loadingBilling && subscription == null;
|
|
12117
|
+
const isPlanDetailsLoading = sponsoredWithoutPlan ? false : !billingOverviewLoaded || loadingBilling || subscription?.plan == null || !planName || planName === "-" || !planAmount || currentPlanCredits == null;
|
|
12118
|
+
const paidFeatures = hasPaidFeatures({ entitlement, subscription });
|
|
12119
|
+
const onEntitlementChangeRef = (0, import_react23.useRef)(onEntitlementChange);
|
|
12120
|
+
onEntitlementChangeRef.current = onEntitlementChange;
|
|
12121
|
+
(0, import_react23.useEffect)(() => {
|
|
12122
|
+
if (!billingOverviewLoaded) return;
|
|
12123
|
+
onEntitlementChangeRef.current?.({ entitlement, paid: paidFeatures });
|
|
12124
|
+
}, [billingOverviewLoaded, entitlement, paidFeatures]);
|
|
12034
12125
|
const {
|
|
12035
12126
|
used: usedCredits,
|
|
12036
12127
|
remaining: remainingCredits,
|
|
@@ -12267,9 +12358,9 @@ function BillingContent({
|
|
|
12267
12358
|
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
12268
12359
|
import_ui17.ScPlanDetailsCard,
|
|
12269
12360
|
{
|
|
12270
|
-
planName,
|
|
12271
|
-
planCredits: planCreditsText,
|
|
12272
|
-
planPrice: planAmount,
|
|
12361
|
+
planName: sponsoredWithoutPlan ? "Free" : planName,
|
|
12362
|
+
planCredits: sponsoredWithoutPlan ? "Shared credits" : planCreditsText,
|
|
12363
|
+
planPrice: sponsoredWithoutPlan ? `${workspace.current?.country?.trim().toUpperCase() === "IN" ? "\u20B9" : "$"}0.00 / month` : planAmount,
|
|
12273
12364
|
badgeText: "Active",
|
|
12274
12365
|
badgeSubText: scheduledDowngradeText,
|
|
12275
12366
|
currentPlanLabel: "Current plan",
|
|
@@ -12358,6 +12449,50 @@ function BillingContent({
|
|
|
12358
12449
|
)
|
|
12359
12450
|
]
|
|
12360
12451
|
}
|
|
12452
|
+
) : sponsored && entitlement ? (
|
|
12453
|
+
// Billing says a pool entitles it, but the balance carried no
|
|
12454
|
+
// allowance (an older credits answer, or it failed): say whose.
|
|
12455
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
12456
|
+
"div",
|
|
12457
|
+
{
|
|
12458
|
+
role: "status",
|
|
12459
|
+
className: "flex flex-col shrink-0 w-full",
|
|
12460
|
+
style: {
|
|
12461
|
+
gap: 4,
|
|
12462
|
+
padding: 16,
|
|
12463
|
+
backgroundColor: "var(--alias-surface-base)",
|
|
12464
|
+
border: "1px solid var(--alias-border-subtle)",
|
|
12465
|
+
borderRadius: "var(--radius-3xl)"
|
|
12466
|
+
},
|
|
12467
|
+
children: [
|
|
12468
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
12469
|
+
"span",
|
|
12470
|
+
{
|
|
12471
|
+
style: {
|
|
12472
|
+
fontFamily: "var(--font-family-font-family-body)",
|
|
12473
|
+
fontSize: "var(--font-size-font-size-sm)",
|
|
12474
|
+
fontWeight: 500,
|
|
12475
|
+
lineHeight: "var(--line-height-line-height-sm)",
|
|
12476
|
+
color: "var(--alias-text---icons-primary)"
|
|
12477
|
+
},
|
|
12478
|
+
children: sponsoredCreditsText(entitlement)
|
|
12479
|
+
}
|
|
12480
|
+
),
|
|
12481
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
12482
|
+
"span",
|
|
12483
|
+
{
|
|
12484
|
+
style: {
|
|
12485
|
+
fontFamily: "var(--font-family-font-family-body)",
|
|
12486
|
+
fontSize: "var(--font-size-font-size-sm)",
|
|
12487
|
+
lineHeight: "var(--line-height-line-height-sm)",
|
|
12488
|
+
color: "var(--alias-text---icons-muted)"
|
|
12489
|
+
},
|
|
12490
|
+
children: ownCreditsFirstText()
|
|
12491
|
+
}
|
|
12492
|
+
)
|
|
12493
|
+
]
|
|
12494
|
+
}
|
|
12495
|
+
)
|
|
12361
12496
|
) : null,
|
|
12362
12497
|
usage ? /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
12363
12498
|
"div",
|
|
@@ -16732,6 +16867,30 @@ function OrganizationPicker({
|
|
|
16732
16867
|
);
|
|
16733
16868
|
}
|
|
16734
16869
|
|
|
16870
|
+
// src/use-billing-entitlement.ts
|
|
16871
|
+
var import_react30 = require("react");
|
|
16872
|
+
function useBillingEntitlement(fetchCurrentPlan, key) {
|
|
16873
|
+
const fetchRef = (0, import_react30.useRef)(fetchCurrentPlan);
|
|
16874
|
+
fetchRef.current = fetchCurrentPlan;
|
|
16875
|
+
const [state, setState] = (0, import_react30.useState)(null);
|
|
16876
|
+
const [loading, setLoading] = (0, import_react30.useState)(false);
|
|
16877
|
+
(0, import_react30.useEffect)(() => {
|
|
16878
|
+
const fetch2 = fetchRef.current;
|
|
16879
|
+
setState(null);
|
|
16880
|
+
if (!key || !fetch2) {
|
|
16881
|
+
setLoading(false);
|
|
16882
|
+
return;
|
|
16883
|
+
}
|
|
16884
|
+
let live = true;
|
|
16885
|
+
setLoading(true);
|
|
16886
|
+
loadCurrentPlan(fetch2).then((next) => live && setState(next)).catch(() => live && setState(null)).finally(() => live && setLoading(false));
|
|
16887
|
+
return () => {
|
|
16888
|
+
live = false;
|
|
16889
|
+
};
|
|
16890
|
+
}, [key]);
|
|
16891
|
+
return { state, loading };
|
|
16892
|
+
}
|
|
16893
|
+
|
|
16735
16894
|
// src/administration-navigation.ts
|
|
16736
16895
|
var normalizedBase = (base) => base.replace(/\/$/, "");
|
|
16737
16896
|
var returnKey = (base, entryKey) => `streamoid:settings:return:${base}:${entryKey}`;
|
|
@@ -16778,7 +16937,7 @@ function readSettingsCaller(base, state, entryKey, fallback = `${normalizedBase(
|
|
|
16778
16937
|
}
|
|
16779
16938
|
|
|
16780
16939
|
// src/app-settings-page.tsx
|
|
16781
|
-
var
|
|
16940
|
+
var import_react31 = require("react");
|
|
16782
16941
|
var import_icons20 = require("@streamoid/icons");
|
|
16783
16942
|
|
|
16784
16943
|
// src/app-settings-page.module.css
|
|
@@ -16841,7 +17000,7 @@ function AppSettingsSection({ title, action, children }) {
|
|
|
16841
17000
|
] });
|
|
16842
17001
|
}
|
|
16843
17002
|
function AppSettingsRow({ title, description, summary, href, onClick, disabled, disabledReason, ariaLabel, trailing }) {
|
|
16844
|
-
const reasonId = (0,
|
|
17003
|
+
const reasonId = (0, import_react31.useId)();
|
|
16845
17004
|
const content = /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
|
|
16846
17005
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("span", { className: app_settings_page_default.rowCopy, children: [
|
|
16847
17006
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: app_settings_page_default.rowTitle, children: title }),
|
package/dist/index.mjs
CHANGED
|
@@ -10523,6 +10523,71 @@ function SharedCreditsView() {
|
|
|
10523
10523
|
] });
|
|
10524
10524
|
}
|
|
10525
10525
|
|
|
10526
|
+
// src/entitlement.ts
|
|
10527
|
+
function parseBillingEntitlement(value) {
|
|
10528
|
+
if (!value || typeof value !== "object") return null;
|
|
10529
|
+
const raw = value;
|
|
10530
|
+
if (typeof raw.paid !== "boolean") return null;
|
|
10531
|
+
const source = raw.source === "plan" || raw.source === "pool" ? raw.source : null;
|
|
10532
|
+
const entitlement = { paid: raw.paid, source };
|
|
10533
|
+
if (typeof raw.sponsorWorkspaceId === "string") entitlement.sponsorWorkspaceId = raw.sponsorWorkspaceId;
|
|
10534
|
+
if (typeof raw.sponsorName === "string") entitlement.sponsorName = raw.sponsorName;
|
|
10535
|
+
if (typeof raw.endsAt === "string" || raw.endsAt === null) entitlement.endsAt = raw.endsAt;
|
|
10536
|
+
return entitlement;
|
|
10537
|
+
}
|
|
10538
|
+
function entitlementFromBody(body) {
|
|
10539
|
+
if (!body || typeof body !== "object") return null;
|
|
10540
|
+
return parseBillingEntitlement(body.entitlement);
|
|
10541
|
+
}
|
|
10542
|
+
function entitlementFromFailure(failure) {
|
|
10543
|
+
const seen = /* @__PURE__ */ new Set();
|
|
10544
|
+
const visit = (value, depth) => {
|
|
10545
|
+
if (depth > 4 || value == null || typeof value !== "object" || seen.has(value)) return null;
|
|
10546
|
+
seen.add(value);
|
|
10547
|
+
const found = entitlementFromBody(value);
|
|
10548
|
+
if (found) return found;
|
|
10549
|
+
const error = value;
|
|
10550
|
+
const response = error.response;
|
|
10551
|
+
for (const child of [error.body, error.data, response?.data, error.cause]) {
|
|
10552
|
+
const nested = visit(child, depth + 1);
|
|
10553
|
+
if (nested) return nested;
|
|
10554
|
+
}
|
|
10555
|
+
return null;
|
|
10556
|
+
};
|
|
10557
|
+
return visit(failure, 0);
|
|
10558
|
+
}
|
|
10559
|
+
function isPaidPlan(subscription) {
|
|
10560
|
+
const amount = subscription?.plan?.amount;
|
|
10561
|
+
return amount != null && amount > 0;
|
|
10562
|
+
}
|
|
10563
|
+
function hasPaidFeatures({
|
|
10564
|
+
entitlement,
|
|
10565
|
+
subscription
|
|
10566
|
+
}) {
|
|
10567
|
+
return entitlement ? entitlement.paid : isPaidPlan(subscription);
|
|
10568
|
+
}
|
|
10569
|
+
function isSponsoredEntitlement(entitlement) {
|
|
10570
|
+
return entitlement?.source === "pool" && entitlement.paid;
|
|
10571
|
+
}
|
|
10572
|
+
function sponsoredCreditsText(entitlement) {
|
|
10573
|
+
const sponsor = entitlement.sponsorName?.trim() || "another workspace";
|
|
10574
|
+
const ends = entitlement.endsAt ? ` Sharing ends on ${formatPoolEndsAt(entitlement.endsAt)}.` : "";
|
|
10575
|
+
return `Credits shared by ${sponsor}.${ends}`;
|
|
10576
|
+
}
|
|
10577
|
+
async function loadCurrentPlan(fetchCurrentPlan) {
|
|
10578
|
+
let response;
|
|
10579
|
+
try {
|
|
10580
|
+
response = await fetchCurrentPlan();
|
|
10581
|
+
} catch (failure) {
|
|
10582
|
+
const entitlement2 = entitlementFromFailure(failure);
|
|
10583
|
+
if (!entitlement2) throw failure;
|
|
10584
|
+
return { subscription: null, entitlement: entitlement2, paid: entitlement2.paid };
|
|
10585
|
+
}
|
|
10586
|
+
const subscription = response?.data ?? null;
|
|
10587
|
+
const entitlement = entitlementFromBody(response);
|
|
10588
|
+
return { subscription, entitlement, paid: hasPaidFeatures({ entitlement, subscription }) };
|
|
10589
|
+
}
|
|
10590
|
+
|
|
10526
10591
|
// src/billing-content.tsx
|
|
10527
10592
|
import { Fragment as Fragment11, jsx as jsx29, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
10528
10593
|
var DEFAULT_TOPUP_SERVICE = "catalogix";
|
|
@@ -11654,7 +11719,8 @@ function BillingContent({
|
|
|
11654
11719
|
showPerUserLimits: showPerUserLimitsProp,
|
|
11655
11720
|
onShowPerUserLimitsChange,
|
|
11656
11721
|
showSharedCredits: showSharedCreditsProp,
|
|
11657
|
-
onShowSharedCreditsChange
|
|
11722
|
+
onShowSharedCreditsChange,
|
|
11723
|
+
onEntitlementChange
|
|
11658
11724
|
} = {}) {
|
|
11659
11725
|
const { auth, workspace, organization, api, toast, navigation } = useSettingsAdapters();
|
|
11660
11726
|
const user = auth.user;
|
|
@@ -11693,6 +11759,9 @@ function BillingContent({
|
|
|
11693
11759
|
const [showExportModal, setShowExportModal] = useState21(false);
|
|
11694
11760
|
const [showBuyCreditsModal, setShowBuyCreditsModal] = useState21(false);
|
|
11695
11761
|
const [subscription, setSubscription] = useState21(null);
|
|
11762
|
+
const [entitlement, setEntitlement] = useState21(
|
|
11763
|
+
null
|
|
11764
|
+
);
|
|
11696
11765
|
const [availableCredits, setAvailableCredits] = useState21(null);
|
|
11697
11766
|
const [sharedPool, setSharedPool] = useState21(null);
|
|
11698
11767
|
const [usedByNames, setUsedByNames] = useState21({});
|
|
@@ -11738,12 +11807,15 @@ function BillingContent({
|
|
|
11738
11807
|
try {
|
|
11739
11808
|
console.log("calling Billing apis");
|
|
11740
11809
|
const [subRes, creditsRes, productsRes, customRes] = await Promise.all([
|
|
11741
|
-
|
|
11810
|
+
// A sponsored workspace with no subscription of its own gets a 404
|
|
11811
|
+
// that carries its entitlement: loadCurrentPlan answers it, not throws.
|
|
11812
|
+
loadCurrentPlan(api.fetchCurrentPlan).catch(() => null),
|
|
11742
11813
|
api.fetchAvailableCredits().catch(() => null),
|
|
11743
11814
|
api.fetchPlans().catch(() => null),
|
|
11744
11815
|
api.getCustomCreditInfo?.().catch(() => null) ?? Promise.resolve(null)
|
|
11745
11816
|
]);
|
|
11746
|
-
if (subRes?.
|
|
11817
|
+
if (subRes?.subscription) setSubscription(subRes.subscription);
|
|
11818
|
+
if (subRes) setEntitlement(subRes.entitlement);
|
|
11747
11819
|
if (creditsRes?.availableCredits != null)
|
|
11748
11820
|
setAvailableCredits(creditsRes.availableCredits);
|
|
11749
11821
|
setSharedPool(creditsRes?.sharedPool ?? null);
|
|
@@ -11913,6 +11985,7 @@ function BillingContent({
|
|
|
11913
11985
|
setInitialFetchTriggered(false);
|
|
11914
11986
|
setBillingOverviewLoaded(false);
|
|
11915
11987
|
setSubscription(null);
|
|
11988
|
+
setEntitlement(null);
|
|
11916
11989
|
setAvailableCredits(null);
|
|
11917
11990
|
setProducts([]);
|
|
11918
11991
|
setTotalCredits(null);
|
|
@@ -11968,7 +12041,16 @@ function BillingContent({
|
|
|
11968
12041
|
subscription?.scheduledDowngradeEffectiveDate
|
|
11969
12042
|
);
|
|
11970
12043
|
const scheduledDowngradeText = subscription?.downgradeScheduled && subscription.plan?.name ? `Downgrades to ${subscription.plan.name}${scheduledDowngradeDateLabel ? ` ${scheduledDowngradeDateLabel}` : ""}` : void 0;
|
|
11971
|
-
const
|
|
12044
|
+
const sponsored = isSponsoredEntitlement(entitlement);
|
|
12045
|
+
const sponsoredWithoutPlan = sponsored && billingOverviewLoaded && !loadingBilling && subscription == null;
|
|
12046
|
+
const isPlanDetailsLoading = sponsoredWithoutPlan ? false : !billingOverviewLoaded || loadingBilling || subscription?.plan == null || !planName || planName === "-" || !planAmount || currentPlanCredits == null;
|
|
12047
|
+
const paidFeatures = hasPaidFeatures({ entitlement, subscription });
|
|
12048
|
+
const onEntitlementChangeRef = useRef10(onEntitlementChange);
|
|
12049
|
+
onEntitlementChangeRef.current = onEntitlementChange;
|
|
12050
|
+
useEffect18(() => {
|
|
12051
|
+
if (!billingOverviewLoaded) return;
|
|
12052
|
+
onEntitlementChangeRef.current?.({ entitlement, paid: paidFeatures });
|
|
12053
|
+
}, [billingOverviewLoaded, entitlement, paidFeatures]);
|
|
11972
12054
|
const {
|
|
11973
12055
|
used: usedCredits,
|
|
11974
12056
|
remaining: remainingCredits,
|
|
@@ -12205,9 +12287,9 @@ function BillingContent({
|
|
|
12205
12287
|
/* @__PURE__ */ jsx29(
|
|
12206
12288
|
ScPlanDetailsCard,
|
|
12207
12289
|
{
|
|
12208
|
-
planName,
|
|
12209
|
-
planCredits: planCreditsText,
|
|
12210
|
-
planPrice: planAmount,
|
|
12290
|
+
planName: sponsoredWithoutPlan ? "Free" : planName,
|
|
12291
|
+
planCredits: sponsoredWithoutPlan ? "Shared credits" : planCreditsText,
|
|
12292
|
+
planPrice: sponsoredWithoutPlan ? `${workspace.current?.country?.trim().toUpperCase() === "IN" ? "\u20B9" : "$"}0.00 / month` : planAmount,
|
|
12211
12293
|
badgeText: "Active",
|
|
12212
12294
|
badgeSubText: scheduledDowngradeText,
|
|
12213
12295
|
currentPlanLabel: "Current plan",
|
|
@@ -12296,6 +12378,50 @@ function BillingContent({
|
|
|
12296
12378
|
)
|
|
12297
12379
|
]
|
|
12298
12380
|
}
|
|
12381
|
+
) : sponsored && entitlement ? (
|
|
12382
|
+
// Billing says a pool entitles it, but the balance carried no
|
|
12383
|
+
// allowance (an older credits answer, or it failed): say whose.
|
|
12384
|
+
/* @__PURE__ */ jsxs26(
|
|
12385
|
+
"div",
|
|
12386
|
+
{
|
|
12387
|
+
role: "status",
|
|
12388
|
+
className: "flex flex-col shrink-0 w-full",
|
|
12389
|
+
style: {
|
|
12390
|
+
gap: 4,
|
|
12391
|
+
padding: 16,
|
|
12392
|
+
backgroundColor: "var(--alias-surface-base)",
|
|
12393
|
+
border: "1px solid var(--alias-border-subtle)",
|
|
12394
|
+
borderRadius: "var(--radius-3xl)"
|
|
12395
|
+
},
|
|
12396
|
+
children: [
|
|
12397
|
+
/* @__PURE__ */ jsx29(
|
|
12398
|
+
"span",
|
|
12399
|
+
{
|
|
12400
|
+
style: {
|
|
12401
|
+
fontFamily: "var(--font-family-font-family-body)",
|
|
12402
|
+
fontSize: "var(--font-size-font-size-sm)",
|
|
12403
|
+
fontWeight: 500,
|
|
12404
|
+
lineHeight: "var(--line-height-line-height-sm)",
|
|
12405
|
+
color: "var(--alias-text---icons-primary)"
|
|
12406
|
+
},
|
|
12407
|
+
children: sponsoredCreditsText(entitlement)
|
|
12408
|
+
}
|
|
12409
|
+
),
|
|
12410
|
+
/* @__PURE__ */ jsx29(
|
|
12411
|
+
"span",
|
|
12412
|
+
{
|
|
12413
|
+
style: {
|
|
12414
|
+
fontFamily: "var(--font-family-font-family-body)",
|
|
12415
|
+
fontSize: "var(--font-size-font-size-sm)",
|
|
12416
|
+
lineHeight: "var(--line-height-line-height-sm)",
|
|
12417
|
+
color: "var(--alias-text---icons-muted)"
|
|
12418
|
+
},
|
|
12419
|
+
children: ownCreditsFirstText()
|
|
12420
|
+
}
|
|
12421
|
+
)
|
|
12422
|
+
]
|
|
12423
|
+
}
|
|
12424
|
+
)
|
|
12299
12425
|
) : null,
|
|
12300
12426
|
usage ? /* @__PURE__ */ jsxs26(
|
|
12301
12427
|
"div",
|
|
@@ -16676,6 +16802,30 @@ function OrganizationPicker({
|
|
|
16676
16802
|
);
|
|
16677
16803
|
}
|
|
16678
16804
|
|
|
16805
|
+
// src/use-billing-entitlement.ts
|
|
16806
|
+
import { useEffect as useEffect22, useRef as useRef12, useState as useState28 } from "react";
|
|
16807
|
+
function useBillingEntitlement(fetchCurrentPlan, key) {
|
|
16808
|
+
const fetchRef = useRef12(fetchCurrentPlan);
|
|
16809
|
+
fetchRef.current = fetchCurrentPlan;
|
|
16810
|
+
const [state, setState] = useState28(null);
|
|
16811
|
+
const [loading, setLoading] = useState28(false);
|
|
16812
|
+
useEffect22(() => {
|
|
16813
|
+
const fetch2 = fetchRef.current;
|
|
16814
|
+
setState(null);
|
|
16815
|
+
if (!key || !fetch2) {
|
|
16816
|
+
setLoading(false);
|
|
16817
|
+
return;
|
|
16818
|
+
}
|
|
16819
|
+
let live = true;
|
|
16820
|
+
setLoading(true);
|
|
16821
|
+
loadCurrentPlan(fetch2).then((next) => live && setState(next)).catch(() => live && setState(null)).finally(() => live && setLoading(false));
|
|
16822
|
+
return () => {
|
|
16823
|
+
live = false;
|
|
16824
|
+
};
|
|
16825
|
+
}, [key]);
|
|
16826
|
+
return { state, loading };
|
|
16827
|
+
}
|
|
16828
|
+
|
|
16679
16829
|
// src/administration-navigation.ts
|
|
16680
16830
|
var normalizedBase = (base) => base.replace(/\/$/, "");
|
|
16681
16831
|
var returnKey = (base, entryKey) => `streamoid:settings:return:${base}:${entryKey}`;
|
|
@@ -16873,6 +17023,8 @@ export {
|
|
|
16873
17023
|
describeAllowance,
|
|
16874
17024
|
describeDefaultLimit,
|
|
16875
17025
|
describeMemberLimit,
|
|
17026
|
+
entitlementFromBody,
|
|
17027
|
+
entitlementFromFailure,
|
|
16876
17028
|
expiryChoiceFor,
|
|
16877
17029
|
findBillingError,
|
|
16878
17030
|
findPoolError,
|
|
@@ -16881,16 +17033,21 @@ export {
|
|
|
16881
17033
|
formatPoolEndsAt,
|
|
16882
17034
|
formatPoolSplit,
|
|
16883
17035
|
groupWorkspaceList,
|
|
17036
|
+
hasPaidFeatures,
|
|
16884
17037
|
isLimitBelowUsage,
|
|
17038
|
+
isPaidPlan,
|
|
17039
|
+
isSponsoredEntitlement,
|
|
16885
17040
|
joinMembersWithLimits,
|
|
16886
17041
|
lastUsedLabel,
|
|
16887
17042
|
limitBelowUsageUsed,
|
|
16888
17043
|
limitSourceLabel,
|
|
17044
|
+
loadCurrentPlan,
|
|
16889
17045
|
loadWorkspaceOrganization,
|
|
16890
17046
|
memberRoleUpdate,
|
|
16891
17047
|
minPoolEndDate,
|
|
16892
17048
|
minimumCreditLimit,
|
|
16893
17049
|
ownCreditsFirstText,
|
|
17050
|
+
parseBillingEntitlement,
|
|
16894
17051
|
pausedOwnCreditsText,
|
|
16895
17052
|
poolEndsAtFrom,
|
|
16896
17053
|
poolErrorMessage,
|
|
@@ -16903,7 +17060,9 @@ export {
|
|
|
16903
17060
|
settingsReturnTarget,
|
|
16904
17061
|
sharedPoolBannerText,
|
|
16905
17062
|
sharedPoolEndsText,
|
|
17063
|
+
sponsoredCreditsText,
|
|
16906
17064
|
toLocalDateInput,
|
|
17065
|
+
useBillingEntitlement,
|
|
16907
17066
|
useSettingsAdapters,
|
|
16908
17067
|
useWorkspaceInvitePermission,
|
|
16909
17068
|
useWorkspaceOrganization,
|