@streamoid/settings 0.7.9 → 0.7.10

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 CHANGED
@@ -737,6 +737,48 @@ interface BuyCreditsResponse {
737
737
  availableCredits?: number;
738
738
  credits?: number;
739
739
  }
740
+ type MemberCreditLimitSource = "override" | "default" | "none";
741
+ /** One member's per-billing-cycle credit limit and usage. */
742
+ interface MemberCreditLimit {
743
+ /** = `WorkspaceMember.user._id`. */
744
+ userId: string;
745
+ /** The EFFECTIVE limit (override, else the workspace default); `null` = unlimited. */
746
+ limit: number | null;
747
+ /** Where `limit` comes from. Absent on older servers: treat as no default. */
748
+ source?: MemberCreditLimitSource;
749
+ /** `true` only when the member has their own override record. */
750
+ hasLimit: boolean;
751
+ /** Credits used this billing cycle. */
752
+ used: number;
753
+ /** `null` when unlimited. */
754
+ remaining: number | null;
755
+ /** Previous billing cycle usage. */
756
+ lastCycleUsed: number;
757
+ setBy?: string;
758
+ updatedAt?: string;
759
+ }
760
+ interface MemberCreditLimitsResponse {
761
+ cycle: {
762
+ start: string;
763
+ end: string;
764
+ };
765
+ previousCycle: {
766
+ start: string;
767
+ end: string;
768
+ };
769
+ /**
770
+ * The workspace default per-member limit. `null` / absent = no default set
771
+ * (members without an override are unlimited); `limit: null` = the default
772
+ * is Unlimited.
773
+ */
774
+ default?: {
775
+ limit: number | null;
776
+ setBy?: string;
777
+ updatedAt?: string;
778
+ } | null;
779
+ /** Only members with an override or with usage; the rest follow the default. */
780
+ users: MemberCreditLimit[];
781
+ }
740
782
  /**
741
783
  * The API adapter is split into three concern areas (billing / teams /
742
784
  * tokens) but kept flat to match the original spec. Methods are grouped with
@@ -852,6 +894,22 @@ interface SettingsApiAdapter {
852
894
  getHighestRole?: () => Promise<{
853
895
  role: "admin" | "member";
854
896
  }>;
897
+ /**
898
+ * Per-member credit limits and usage for the current billing cycle. When
899
+ * omitted, Billing hides the "Per-user usage limits" entry.
900
+ */
901
+ fetchMemberCreditLimits?: () => Promise<MemberCreditLimitsResponse>;
902
+ /** Set a member's limit per billing cycle; `limit: null` means unlimited.
903
+ * Rejects with code `LIMIT_BELOW_USAGE` when under the member's usage. */
904
+ setMemberCreditLimit?: (input: {
905
+ userId: string;
906
+ limit: number | null;
907
+ }) => Promise<void>;
908
+ /** Remove the override entirely (the member follows the workspace default). */
909
+ removeMemberCreditLimit?: (userId: string) => Promise<void>;
910
+ /** Set the workspace default per-member limit; `null` means Unlimited.
911
+ * Applies to members without their own override. Throws on error. */
912
+ setDefaultCreditLimit?: (limit: number | null) => Promise<void>;
855
913
  fetchTokens: (params?: {
856
914
  showRevoked?: boolean;
857
915
  }) => Promise<ApiToken[]>;
@@ -1118,12 +1176,16 @@ type IconProps = Omit<SVGProps<SVGSVGElement>, 'color' | 'strokeWidth' | 'width'
1118
1176
  };
1119
1177
  declare const SiconKey: ({ color, strokeWidth, size, ...props }: IconProps) => react.JSX.Element;
1120
1178
 
1121
- declare function BillingContent({ embedded, showPlans: showPlansProp, onShowPlansChange, }?: {
1179
+ declare function BillingContent({ embedded, showPlans: showPlansProp, onShowPlansChange, showPerUserLimits: showPerUserLimitsProp, onShowPerUserLimitsChange, }?: {
1122
1180
  embedded?: boolean;
1123
1181
  /** Controlled "plans" sub-view flag. When provided, the host (settings
1124
1182
  * wrapper) owns it so it can hide the sub-nav + show the Plans breadcrumb. */
1125
1183
  showPlans?: boolean;
1126
1184
  onShowPlansChange?: (open: boolean) => void;
1185
+ /** Controlled "per-user limits" sub-view flag; same contract as `showPlans`.
1186
+ * Only reachable when `api.fetchMemberCreditLimits` exists. */
1187
+ showPerUserLimits?: boolean;
1188
+ onShowPerUserLimitsChange?: (open: boolean) => void;
1127
1189
  }): react__default.JSX.Element;
1128
1190
 
1129
1191
  declare function TeamsContent({ embedded, onInviteOpen, onInviteOpenChange, workspaceName, workspaceImageUrl, organizationName, hiddenApps, }?: {
@@ -1481,6 +1543,118 @@ interface ExportDateModalProps {
1481
1543
  }
1482
1544
  declare function ExportDateModal({ title, onClose, onExport, }: ExportDateModalProps): react.JSX.Element;
1483
1545
 
1546
+ type CreditCycleUnit = "month" | "year";
1547
+ type CreditLimitValidation = {
1548
+ ok: true;
1549
+ value: number;
1550
+ } | {
1551
+ ok: false;
1552
+ reason: string;
1553
+ };
1554
+ /** A member joined with their (possibly absent) limit record. */
1555
+ interface MemberCreditLimitRow {
1556
+ member: WorkspaceMember;
1557
+ userId: string;
1558
+ /** Effective limit: the override, else the workspace default. */
1559
+ limit: number | null;
1560
+ source: MemberCreditLimitSource;
1561
+ /** True only when the member has their own override. */
1562
+ hasLimit: boolean;
1563
+ used: number;
1564
+ lastCycleUsed: number;
1565
+ }
1566
+ /** "year" for a cycle longer than ~200 days, otherwise "month". */
1567
+ declare function creditCycleUnit(cycle?: {
1568
+ start: string;
1569
+ end: string;
1570
+ } | null): CreditCycleUnit;
1571
+ /** `1000, "month"` → "1,000 credits / month"; `null` → "Unlimited". */
1572
+ declare function formatCreditLimit(limit: number | null, unit: CreditCycleUnit): string;
1573
+ /**
1574
+ * Credits used, as billing counts them: two decimals. Sums of two-decimal
1575
+ * amounts arrive with float noise (3.0000000000000004), which would otherwise
1576
+ * refuse a limit of 3.
1577
+ */
1578
+ declare function roundCredits(value: number): number;
1579
+ /** The smallest whole-number limit allowed over `used`: what the input can take. */
1580
+ declare function minimumCreditLimit(used: number): number;
1581
+ /** Credits for display: grouped, at most two decimals. */
1582
+ declare function formatCredits(value: number): string;
1583
+ /** The default limit has no usage floor: lowering it under usage is allowed. */
1584
+ declare function validateDefaultCreditLimitInput(raw: string): CreditLimitValidation;
1585
+ /** Digits-only input, an integer, and not below what was already used. */
1586
+ declare function validateCreditLimitInput(raw: string, used: number): CreditLimitValidation;
1587
+ /** Why a limit was refused for being under `used`, naming the least it can be. */
1588
+ declare function belowUsageReason(used: number): string;
1589
+ /** The default limit as text: "500 credits / month", or "Unlimited" (also when unset). */
1590
+ declare function describeDefaultLimit(response: MemberCreditLimitsResponse | null | undefined, unit: CreditCycleUnit): string;
1591
+ /** A member's effective limit as text: "500 credits / month" or "Unlimited". */
1592
+ declare function describeMemberLimit(row: Pick<MemberCreditLimitRow, "limit">, unit: CreditCycleUnit): string;
1593
+ /** "Custom" for an override, "Default" when following the default, else null. */
1594
+ declare function limitSourceLabel(row: Pick<MemberCreditLimitRow, "source">): "Custom" | "Default" | null;
1595
+ /**
1596
+ * Members listed by the server keep its figures. Members it does not list
1597
+ * follow the workspace default (none set = unlimited), with no usage.
1598
+ */
1599
+ declare function joinMembersWithLimits(members: WorkspaceMember[], response: MemberCreditLimitsResponse | null | undefined): MemberCreditLimitRow[];
1600
+
1601
+ /**
1602
+ * True when a per-user credit limit was rejected for being under what the
1603
+ * member already used this cycle. The raw server code does not survive
1604
+ * `UserFacingError` normalization in `err.code` (that is rewritten to a
1605
+ * category), so the original body is searched too: `code`, `error.code`,
1606
+ * `body.*`, `data.*`, `publicError.*` and `cause`, to a shallow depth.
1607
+ */
1608
+ declare function isLimitBelowUsage(failure: unknown): boolean;
1609
+ /**
1610
+ * What the server says the member has used, from a `LIMIT_BELOW_USAGE`
1611
+ * rejection: fresher than the figure the list was loaded with, when they have
1612
+ * spent more since. `null` when the failure is not one, or carries no figure.
1613
+ */
1614
+ declare function limitBelowUsageUsed(failure: unknown): number | null;
1615
+
1616
+ /** Billing sub-view: per-member credit limits for the current billing cycle. */
1617
+ declare function PerUserLimitsView(): react.JSX.Element;
1618
+
1619
+ interface MemberCreditLimitModalProps {
1620
+ open: boolean;
1621
+ /** Modal title; defaults to "Set custom usage limit". */
1622
+ title?: string;
1623
+ /** Explanatory text under the title block (e.g. for the workspace default). */
1624
+ description?: string;
1625
+ /** Whose limit this is. Omit for the workspace default: no member block, no usage line. */
1626
+ subject?: {
1627
+ name?: string;
1628
+ email: string;
1629
+ };
1630
+ /** Changing this resets the form (a different member, say). */
1631
+ resetKey?: string;
1632
+ /** Credits used this billing cycle; 0 for the default, so no "at least" rule. */
1633
+ used: number;
1634
+ /** Limit to pre-select; `null` = Unlimited. */
1635
+ initialLimit: number | null;
1636
+ /** Whether a stored value exists. When false, saving is always allowed (it creates one). */
1637
+ isSet: boolean;
1638
+ unit: CreditCycleUnit;
1639
+ /** Persist the limit (`null` = Unlimited). Throw on failure. */
1640
+ onSave: (limit: number | null) => Promise<void>;
1641
+ /** Persist removal. When omitted, no Remove button. */
1642
+ onRemove?: () => Promise<void>;
1643
+ /** Remove button label; defaults to "Remove". */
1644
+ removeLabel?: string;
1645
+ /** Muted line explaining what Remove does. */
1646
+ removeHint?: string;
1647
+ saveSuccessMessage?: string;
1648
+ removeSuccessMessage?: string;
1649
+ onClose: () => void;
1650
+ /** Called after a successful save/remove; the parent refetches. */
1651
+ onSaved: () => void;
1652
+ /** Called when the server's figures differ from the ones shown; the parent refetches. */
1653
+ onStale?: () => void;
1654
+ }
1655
+ /** A fixed number of credits per cycle, or unlimited — for one member or the workspace default. */
1656
+ declare function MemberCreditLimitModal({ open, title, description, subject, resetKey, used, initialLimit, isSet, unit, onSave, onRemove, removeLabel, removeHint, saveSuccessMessage, removeSuccessMessage, onClose, onSaved, onStale, }: MemberCreditLimitModalProps): react.JSX.Element | null;
1657
+
1484
1658
  declare function SettingsAdaptersProvider({ adapters, children, }: {
1485
1659
  adapters: SettingsAdapters;
1486
1660
  children: ReactNode;
@@ -1492,4 +1666,4 @@ declare function SettingsAdaptersProvider({ adapters, children, }: {
1492
1666
  */
1493
1667
  declare function useSettingsAdapters(): SettingsAdapters;
1494
1668
 
1495
- export { APP_KEYS, type ApiToken, type AppKey, type AvailableCreditsResponse, BillingContent, type BillingEventPayload, type BillingProduct, type BillingSubscription, BuyCreditsModal, type BuyCreditsPayload, type BuyCreditsResponse, ConfirmDeleteModal, ConfirmLeaveModal, type CreatedToken, type CustomCreditInfo, type CustomCreditResponse, DEFAULT_PERMISSIONS, DEFAULT_USER_LANGUAGE, ExportDateModal, InviteUpdateModal, type InvoicePdfResponse, MemberListFrame, type MemberListFrameProps, type MemberListTab, MemberListToolbar, type MemberListToolbarProps, type MemberPermissionsPayload, OrganizationContent, type OrganizationData, type OrganizationInvite, type OrganizationJoinRequest, type OrganizationJoinableWorkspace, type OrganizationMember, OrganizationMemberModal, type OrganizationMemberModalProps, OrganizationModal, type OrganizationView, type OrganizationWorkspaceItem, type Price, type PriceMetadata, type ProductsResponse, ProfileAvatar, ProfileTab, ReferralTab, SCOPE_LABELS, ScopeHeader, type ScopeHeaderProps, type ServiceItem, type SettingsAdapters, SettingsAdaptersProvider, type SettingsApiAdapter, type SettingsAuthAdapter, type SettingsAuthUser, SettingsContent, type SettingsContentProps, type SettingsImageUploadAdapter, type SettingsNavigationAdapter, type SettingsOrganizationAdapter, type SettingsOrganizationCurrent, type SettingsOrganizationListItem, type SettingsScope, type SettingsTab, type SettingsToastAdapter, SettingsTooltip, type SettingsTooltipPlacement, type SettingsTooltipProps, type SettingsWorkspaceAdapter, type SettingsWorkspaceCurrent, type SettingsWorkspaceListItem, 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 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 WorkspacePickerItem, type WorkspacePickerProps, WorkspaceTab, type WorkspaceUsageResponse, countLabel, groupWorkspaceList, loadWorkspaceOrganization, resolveSettingsTabFromPath, useSettingsAdapters, useWorkspaceOrganization, userLanguageLabel };
1669
+ export { APP_KEYS, type ApiToken, type AppKey, type AvailableCreditsResponse, BillingContent, type BillingEventPayload, type BillingProduct, type BillingSubscription, BuyCreditsModal, type BuyCreditsPayload, type BuyCreditsResponse, ConfirmDeleteModal, ConfirmLeaveModal, type CreatedToken, type CreditCycleUnit, type CreditLimitValidation, 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 OrganizationInvite, type OrganizationJoinRequest, type OrganizationJoinableWorkspace, type OrganizationMember, OrganizationMemberModal, type OrganizationMemberModalProps, OrganizationModal, type OrganizationView, type OrganizationWorkspaceItem, PerUserLimitsView, type Price, type PriceMetadata, type ProductsResponse, ProfileAvatar, ProfileTab, ReferralTab, SCOPE_LABELS, ScopeHeader, type ScopeHeaderProps, type ServiceItem, type SettingsAdapters, SettingsAdaptersProvider, type SettingsApiAdapter, type SettingsAuthAdapter, type SettingsAuthUser, SettingsContent, type SettingsContentProps, type SettingsImageUploadAdapter, type SettingsNavigationAdapter, type SettingsOrganizationAdapter, type SettingsOrganizationCurrent, type SettingsOrganizationListItem, type SettingsScope, type SettingsTab, type SettingsToastAdapter, SettingsTooltip, type SettingsTooltipPlacement, type SettingsTooltipProps, type SettingsWorkspaceAdapter, type SettingsWorkspaceCurrent, type SettingsWorkspaceListItem, 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 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 WorkspacePickerItem, type WorkspacePickerProps, WorkspaceTab, type WorkspaceUsageResponse, belowUsageReason, countLabel, creditCycleUnit, describeDefaultLimit, describeMemberLimit, formatCreditLimit, formatCredits, groupWorkspaceList, isLimitBelowUsage, joinMembersWithLimits, limitBelowUsageUsed, limitSourceLabel, loadWorkspaceOrganization, minimumCreditLimit, resolveSettingsTabFromPath, roundCredits, useSettingsAdapters, useWorkspaceOrganization, userLanguageLabel, validateCreditLimitInput, validateDefaultCreditLimitInput };
package/dist/index.d.ts CHANGED
@@ -737,6 +737,48 @@ interface BuyCreditsResponse {
737
737
  availableCredits?: number;
738
738
  credits?: number;
739
739
  }
740
+ type MemberCreditLimitSource = "override" | "default" | "none";
741
+ /** One member's per-billing-cycle credit limit and usage. */
742
+ interface MemberCreditLimit {
743
+ /** = `WorkspaceMember.user._id`. */
744
+ userId: string;
745
+ /** The EFFECTIVE limit (override, else the workspace default); `null` = unlimited. */
746
+ limit: number | null;
747
+ /** Where `limit` comes from. Absent on older servers: treat as no default. */
748
+ source?: MemberCreditLimitSource;
749
+ /** `true` only when the member has their own override record. */
750
+ hasLimit: boolean;
751
+ /** Credits used this billing cycle. */
752
+ used: number;
753
+ /** `null` when unlimited. */
754
+ remaining: number | null;
755
+ /** Previous billing cycle usage. */
756
+ lastCycleUsed: number;
757
+ setBy?: string;
758
+ updatedAt?: string;
759
+ }
760
+ interface MemberCreditLimitsResponse {
761
+ cycle: {
762
+ start: string;
763
+ end: string;
764
+ };
765
+ previousCycle: {
766
+ start: string;
767
+ end: string;
768
+ };
769
+ /**
770
+ * The workspace default per-member limit. `null` / absent = no default set
771
+ * (members without an override are unlimited); `limit: null` = the default
772
+ * is Unlimited.
773
+ */
774
+ default?: {
775
+ limit: number | null;
776
+ setBy?: string;
777
+ updatedAt?: string;
778
+ } | null;
779
+ /** Only members with an override or with usage; the rest follow the default. */
780
+ users: MemberCreditLimit[];
781
+ }
740
782
  /**
741
783
  * The API adapter is split into three concern areas (billing / teams /
742
784
  * tokens) but kept flat to match the original spec. Methods are grouped with
@@ -852,6 +894,22 @@ interface SettingsApiAdapter {
852
894
  getHighestRole?: () => Promise<{
853
895
  role: "admin" | "member";
854
896
  }>;
897
+ /**
898
+ * Per-member credit limits and usage for the current billing cycle. When
899
+ * omitted, Billing hides the "Per-user usage limits" entry.
900
+ */
901
+ fetchMemberCreditLimits?: () => Promise<MemberCreditLimitsResponse>;
902
+ /** Set a member's limit per billing cycle; `limit: null` means unlimited.
903
+ * Rejects with code `LIMIT_BELOW_USAGE` when under the member's usage. */
904
+ setMemberCreditLimit?: (input: {
905
+ userId: string;
906
+ limit: number | null;
907
+ }) => Promise<void>;
908
+ /** Remove the override entirely (the member follows the workspace default). */
909
+ removeMemberCreditLimit?: (userId: string) => Promise<void>;
910
+ /** Set the workspace default per-member limit; `null` means Unlimited.
911
+ * Applies to members without their own override. Throws on error. */
912
+ setDefaultCreditLimit?: (limit: number | null) => Promise<void>;
855
913
  fetchTokens: (params?: {
856
914
  showRevoked?: boolean;
857
915
  }) => Promise<ApiToken[]>;
@@ -1118,12 +1176,16 @@ type IconProps = Omit<SVGProps<SVGSVGElement>, 'color' | 'strokeWidth' | 'width'
1118
1176
  };
1119
1177
  declare const SiconKey: ({ color, strokeWidth, size, ...props }: IconProps) => react.JSX.Element;
1120
1178
 
1121
- declare function BillingContent({ embedded, showPlans: showPlansProp, onShowPlansChange, }?: {
1179
+ declare function BillingContent({ embedded, showPlans: showPlansProp, onShowPlansChange, showPerUserLimits: showPerUserLimitsProp, onShowPerUserLimitsChange, }?: {
1122
1180
  embedded?: boolean;
1123
1181
  /** Controlled "plans" sub-view flag. When provided, the host (settings
1124
1182
  * wrapper) owns it so it can hide the sub-nav + show the Plans breadcrumb. */
1125
1183
  showPlans?: boolean;
1126
1184
  onShowPlansChange?: (open: boolean) => void;
1185
+ /** Controlled "per-user limits" sub-view flag; same contract as `showPlans`.
1186
+ * Only reachable when `api.fetchMemberCreditLimits` exists. */
1187
+ showPerUserLimits?: boolean;
1188
+ onShowPerUserLimitsChange?: (open: boolean) => void;
1127
1189
  }): react__default.JSX.Element;
1128
1190
 
1129
1191
  declare function TeamsContent({ embedded, onInviteOpen, onInviteOpenChange, workspaceName, workspaceImageUrl, organizationName, hiddenApps, }?: {
@@ -1481,6 +1543,118 @@ interface ExportDateModalProps {
1481
1543
  }
1482
1544
  declare function ExportDateModal({ title, onClose, onExport, }: ExportDateModalProps): react.JSX.Element;
1483
1545
 
1546
+ type CreditCycleUnit = "month" | "year";
1547
+ type CreditLimitValidation = {
1548
+ ok: true;
1549
+ value: number;
1550
+ } | {
1551
+ ok: false;
1552
+ reason: string;
1553
+ };
1554
+ /** A member joined with their (possibly absent) limit record. */
1555
+ interface MemberCreditLimitRow {
1556
+ member: WorkspaceMember;
1557
+ userId: string;
1558
+ /** Effective limit: the override, else the workspace default. */
1559
+ limit: number | null;
1560
+ source: MemberCreditLimitSource;
1561
+ /** True only when the member has their own override. */
1562
+ hasLimit: boolean;
1563
+ used: number;
1564
+ lastCycleUsed: number;
1565
+ }
1566
+ /** "year" for a cycle longer than ~200 days, otherwise "month". */
1567
+ declare function creditCycleUnit(cycle?: {
1568
+ start: string;
1569
+ end: string;
1570
+ } | null): CreditCycleUnit;
1571
+ /** `1000, "month"` → "1,000 credits / month"; `null` → "Unlimited". */
1572
+ declare function formatCreditLimit(limit: number | null, unit: CreditCycleUnit): string;
1573
+ /**
1574
+ * Credits used, as billing counts them: two decimals. Sums of two-decimal
1575
+ * amounts arrive with float noise (3.0000000000000004), which would otherwise
1576
+ * refuse a limit of 3.
1577
+ */
1578
+ declare function roundCredits(value: number): number;
1579
+ /** The smallest whole-number limit allowed over `used`: what the input can take. */
1580
+ declare function minimumCreditLimit(used: number): number;
1581
+ /** Credits for display: grouped, at most two decimals. */
1582
+ declare function formatCredits(value: number): string;
1583
+ /** The default limit has no usage floor: lowering it under usage is allowed. */
1584
+ declare function validateDefaultCreditLimitInput(raw: string): CreditLimitValidation;
1585
+ /** Digits-only input, an integer, and not below what was already used. */
1586
+ declare function validateCreditLimitInput(raw: string, used: number): CreditLimitValidation;
1587
+ /** Why a limit was refused for being under `used`, naming the least it can be. */
1588
+ declare function belowUsageReason(used: number): string;
1589
+ /** The default limit as text: "500 credits / month", or "Unlimited" (also when unset). */
1590
+ declare function describeDefaultLimit(response: MemberCreditLimitsResponse | null | undefined, unit: CreditCycleUnit): string;
1591
+ /** A member's effective limit as text: "500 credits / month" or "Unlimited". */
1592
+ declare function describeMemberLimit(row: Pick<MemberCreditLimitRow, "limit">, unit: CreditCycleUnit): string;
1593
+ /** "Custom" for an override, "Default" when following the default, else null. */
1594
+ declare function limitSourceLabel(row: Pick<MemberCreditLimitRow, "source">): "Custom" | "Default" | null;
1595
+ /**
1596
+ * Members listed by the server keep its figures. Members it does not list
1597
+ * follow the workspace default (none set = unlimited), with no usage.
1598
+ */
1599
+ declare function joinMembersWithLimits(members: WorkspaceMember[], response: MemberCreditLimitsResponse | null | undefined): MemberCreditLimitRow[];
1600
+
1601
+ /**
1602
+ * True when a per-user credit limit was rejected for being under what the
1603
+ * member already used this cycle. The raw server code does not survive
1604
+ * `UserFacingError` normalization in `err.code` (that is rewritten to a
1605
+ * category), so the original body is searched too: `code`, `error.code`,
1606
+ * `body.*`, `data.*`, `publicError.*` and `cause`, to a shallow depth.
1607
+ */
1608
+ declare function isLimitBelowUsage(failure: unknown): boolean;
1609
+ /**
1610
+ * What the server says the member has used, from a `LIMIT_BELOW_USAGE`
1611
+ * rejection: fresher than the figure the list was loaded with, when they have
1612
+ * spent more since. `null` when the failure is not one, or carries no figure.
1613
+ */
1614
+ declare function limitBelowUsageUsed(failure: unknown): number | null;
1615
+
1616
+ /** Billing sub-view: per-member credit limits for the current billing cycle. */
1617
+ declare function PerUserLimitsView(): react.JSX.Element;
1618
+
1619
+ interface MemberCreditLimitModalProps {
1620
+ open: boolean;
1621
+ /** Modal title; defaults to "Set custom usage limit". */
1622
+ title?: string;
1623
+ /** Explanatory text under the title block (e.g. for the workspace default). */
1624
+ description?: string;
1625
+ /** Whose limit this is. Omit for the workspace default: no member block, no usage line. */
1626
+ subject?: {
1627
+ name?: string;
1628
+ email: string;
1629
+ };
1630
+ /** Changing this resets the form (a different member, say). */
1631
+ resetKey?: string;
1632
+ /** Credits used this billing cycle; 0 for the default, so no "at least" rule. */
1633
+ used: number;
1634
+ /** Limit to pre-select; `null` = Unlimited. */
1635
+ initialLimit: number | null;
1636
+ /** Whether a stored value exists. When false, saving is always allowed (it creates one). */
1637
+ isSet: boolean;
1638
+ unit: CreditCycleUnit;
1639
+ /** Persist the limit (`null` = Unlimited). Throw on failure. */
1640
+ onSave: (limit: number | null) => Promise<void>;
1641
+ /** Persist removal. When omitted, no Remove button. */
1642
+ onRemove?: () => Promise<void>;
1643
+ /** Remove button label; defaults to "Remove". */
1644
+ removeLabel?: string;
1645
+ /** Muted line explaining what Remove does. */
1646
+ removeHint?: string;
1647
+ saveSuccessMessage?: string;
1648
+ removeSuccessMessage?: string;
1649
+ onClose: () => void;
1650
+ /** Called after a successful save/remove; the parent refetches. */
1651
+ onSaved: () => void;
1652
+ /** Called when the server's figures differ from the ones shown; the parent refetches. */
1653
+ onStale?: () => void;
1654
+ }
1655
+ /** A fixed number of credits per cycle, or unlimited — for one member or the workspace default. */
1656
+ declare function MemberCreditLimitModal({ open, title, description, subject, resetKey, used, initialLimit, isSet, unit, onSave, onRemove, removeLabel, removeHint, saveSuccessMessage, removeSuccessMessage, onClose, onSaved, onStale, }: MemberCreditLimitModalProps): react.JSX.Element | null;
1657
+
1484
1658
  declare function SettingsAdaptersProvider({ adapters, children, }: {
1485
1659
  adapters: SettingsAdapters;
1486
1660
  children: ReactNode;
@@ -1492,4 +1666,4 @@ declare function SettingsAdaptersProvider({ adapters, children, }: {
1492
1666
  */
1493
1667
  declare function useSettingsAdapters(): SettingsAdapters;
1494
1668
 
1495
- export { APP_KEYS, type ApiToken, type AppKey, type AvailableCreditsResponse, BillingContent, type BillingEventPayload, type BillingProduct, type BillingSubscription, BuyCreditsModal, type BuyCreditsPayload, type BuyCreditsResponse, ConfirmDeleteModal, ConfirmLeaveModal, type CreatedToken, type CustomCreditInfo, type CustomCreditResponse, DEFAULT_PERMISSIONS, DEFAULT_USER_LANGUAGE, ExportDateModal, InviteUpdateModal, type InvoicePdfResponse, MemberListFrame, type MemberListFrameProps, type MemberListTab, MemberListToolbar, type MemberListToolbarProps, type MemberPermissionsPayload, OrganizationContent, type OrganizationData, type OrganizationInvite, type OrganizationJoinRequest, type OrganizationJoinableWorkspace, type OrganizationMember, OrganizationMemberModal, type OrganizationMemberModalProps, OrganizationModal, type OrganizationView, type OrganizationWorkspaceItem, type Price, type PriceMetadata, type ProductsResponse, ProfileAvatar, ProfileTab, ReferralTab, SCOPE_LABELS, ScopeHeader, type ScopeHeaderProps, type ServiceItem, type SettingsAdapters, SettingsAdaptersProvider, type SettingsApiAdapter, type SettingsAuthAdapter, type SettingsAuthUser, SettingsContent, type SettingsContentProps, type SettingsImageUploadAdapter, type SettingsNavigationAdapter, type SettingsOrganizationAdapter, type SettingsOrganizationCurrent, type SettingsOrganizationListItem, type SettingsScope, type SettingsTab, type SettingsToastAdapter, SettingsTooltip, type SettingsTooltipPlacement, type SettingsTooltipProps, type SettingsWorkspaceAdapter, type SettingsWorkspaceCurrent, type SettingsWorkspaceListItem, 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 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 WorkspacePickerItem, type WorkspacePickerProps, WorkspaceTab, type WorkspaceUsageResponse, countLabel, groupWorkspaceList, loadWorkspaceOrganization, resolveSettingsTabFromPath, useSettingsAdapters, useWorkspaceOrganization, userLanguageLabel };
1669
+ export { APP_KEYS, type ApiToken, type AppKey, type AvailableCreditsResponse, BillingContent, type BillingEventPayload, type BillingProduct, type BillingSubscription, BuyCreditsModal, type BuyCreditsPayload, type BuyCreditsResponse, ConfirmDeleteModal, ConfirmLeaveModal, type CreatedToken, type CreditCycleUnit, type CreditLimitValidation, 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 OrganizationInvite, type OrganizationJoinRequest, type OrganizationJoinableWorkspace, type OrganizationMember, OrganizationMemberModal, type OrganizationMemberModalProps, OrganizationModal, type OrganizationView, type OrganizationWorkspaceItem, PerUserLimitsView, type Price, type PriceMetadata, type ProductsResponse, ProfileAvatar, ProfileTab, ReferralTab, SCOPE_LABELS, ScopeHeader, type ScopeHeaderProps, type ServiceItem, type SettingsAdapters, SettingsAdaptersProvider, type SettingsApiAdapter, type SettingsAuthAdapter, type SettingsAuthUser, SettingsContent, type SettingsContentProps, type SettingsImageUploadAdapter, type SettingsNavigationAdapter, type SettingsOrganizationAdapter, type SettingsOrganizationCurrent, type SettingsOrganizationListItem, type SettingsScope, type SettingsTab, type SettingsToastAdapter, SettingsTooltip, type SettingsTooltipPlacement, type SettingsTooltipProps, type SettingsWorkspaceAdapter, type SettingsWorkspaceCurrent, type SettingsWorkspaceListItem, 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 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 WorkspacePickerItem, type WorkspacePickerProps, WorkspaceTab, type WorkspaceUsageResponse, belowUsageReason, countLabel, creditCycleUnit, describeDefaultLimit, describeMemberLimit, formatCreditLimit, formatCredits, groupWorkspaceList, isLimitBelowUsage, joinMembersWithLimits, limitBelowUsageUsed, limitSourceLabel, loadWorkspaceOrganization, minimumCreditLimit, resolveSettingsTabFromPath, roundCredits, useSettingsAdapters, useWorkspaceOrganization, userLanguageLabel, validateCreditLimitInput, validateDefaultCreditLimitInput };