@streamoid/settings 0.22.2 → 0.22.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -2
- package/dist/index.d.mts +60 -10
- package/dist/index.d.ts +60 -10
- package/dist/index.js +72 -29
- package/dist/index.mjs +72 -29
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -173,8 +173,15 @@ Billing hides an entry whose adapter method is absent:
|
|
|
173
173
|
`removeCreditPoolMember` and `fetchCreditPoolCandidates` light up the rest.
|
|
174
174
|
Only organization admins change them; the server says so with `canManage`.
|
|
175
175
|
A member's balance (`fetchAvailableCredits`) carries `sharedPool`, which
|
|
176
|
-
Billing shows as a banner
|
|
177
|
-
|
|
176
|
+
Billing shows as a banner. A workspace whose pool has `members` or
|
|
177
|
+
`formerMembers` (`poolSharesCredits`) gets a Workspace column in its usage
|
|
178
|
+
logs, on every page: "This workspace", or "Used by <name>" for rows whose
|
|
179
|
+
`meta.usedBy` is another workspace, named from those members. Without
|
|
180
|
+
`fetchCreditPool`, or when it fails (a 403 for a member who is not a
|
|
181
|
+
workspace admin; not asked again after a 4xx such as 401/403, once more
|
|
182
|
+
after a network error (no status, or status 0) or 5xx), the column shows from the first loaded page with such a
|
|
183
|
+
row (every row, for an adapter that sends them all) and stays on every page
|
|
184
|
+
until the workspace changes; those rows read "Used by another workspace".
|
|
178
185
|
`setCreditPoolSelfShare` and `removeCreditPoolSelfShare` (mirroring
|
|
179
186
|
`PUT|DELETE /workspace/:id/credit-pool/self`) add a "This workspace" row:
|
|
180
187
|
the share the sponsor keeps for itself. A percent self share counts in the
|
package/dist/index.d.mts
CHANGED
|
@@ -1700,6 +1700,25 @@ type IconProps = Omit<SVGProps<SVGSVGElement>, 'color' | 'strokeWidth' | 'width'
|
|
|
1700
1700
|
};
|
|
1701
1701
|
declare const SiconKey: ({ color, strokeWidth, size, ...props }: IconProps) => react.JSX.Element;
|
|
1702
1702
|
|
|
1703
|
+
declare function UsageLogsTable({ logs, userMap, loading, error, onRetry, currentWorkspaceId, usedByNames, showWorkspace, }: {
|
|
1704
|
+
/** One page of rows: the table renders every row it is given. */
|
|
1705
|
+
logs: UsageHistoryItem[];
|
|
1706
|
+
userMap: Record<string, string>;
|
|
1707
|
+
loading: boolean;
|
|
1708
|
+
/** Shown in place of the rows when the page could not be loaded. */
|
|
1709
|
+
error?: string | null;
|
|
1710
|
+
onRetry?: () => void;
|
|
1711
|
+
/** Rows another workspace spent from this one's shared credits name it. */
|
|
1712
|
+
currentWorkspaceId?: string | null;
|
|
1713
|
+
/** Those workspaces' names, by lower-cased id. */
|
|
1714
|
+
usedByNames?: Record<string, string>;
|
|
1715
|
+
/**
|
|
1716
|
+
* A "Workspace" column: which workspace spent each row, for a workspace that
|
|
1717
|
+
* shares its credits (`poolSharesCredits`). The table's own decision, not
|
|
1718
|
+
* the rows': every page has the same columns.
|
|
1719
|
+
*/
|
|
1720
|
+
showWorkspace?: boolean;
|
|
1721
|
+
}): react__default.JSX.Element;
|
|
1703
1722
|
/** Previous / Next under the Usage logs table, with the page and the total. */
|
|
1704
1723
|
declare function UsageLogsPager({ page, totalPages, total, loading, onPageChange, }: {
|
|
1705
1724
|
/** 1-based. */
|
|
@@ -1825,6 +1844,12 @@ interface UsageLogsState {
|
|
|
1825
1844
|
requestedPage: number;
|
|
1826
1845
|
loading: boolean;
|
|
1827
1846
|
error: string | null;
|
|
1847
|
+
/**
|
|
1848
|
+
* Some page loaded for this workspace had a row another workspace spent
|
|
1849
|
+
* (`usageLogsSpentByOthers`); stays true until `reset`. The Workspace
|
|
1850
|
+
* column's decision for a host without `fetchCreditPool`.
|
|
1851
|
+
*/
|
|
1852
|
+
spentByOthers: boolean;
|
|
1828
1853
|
}
|
|
1829
1854
|
declare const INITIAL_USAGE_LOGS_STATE: UsageLogsState;
|
|
1830
1855
|
type UsageLogsAction =
|
|
@@ -1833,10 +1858,11 @@ type UsageLogsAction =
|
|
|
1833
1858
|
type: "request";
|
|
1834
1859
|
page: number;
|
|
1835
1860
|
}
|
|
1836
|
-
/** The page asked for arrived
|
|
1861
|
+
/** The page asked for arrived, for workspace `workspaceId`. */
|
|
1837
1862
|
| {
|
|
1838
1863
|
type: "loaded";
|
|
1839
1864
|
logs: UsageLogsPage;
|
|
1865
|
+
workspaceId?: string | null;
|
|
1840
1866
|
}
|
|
1841
1867
|
/** The page asked for did not; the one on screen stays. */
|
|
1842
1868
|
| {
|
|
@@ -1863,9 +1889,23 @@ declare function usageLogsReloadPage(state: UsageLogsState): number;
|
|
|
1863
1889
|
/**
|
|
1864
1890
|
* Whether the usage logs in hand have a row another workspace spent from this
|
|
1865
1891
|
* one's shared credits. Every row an unpaged adapter sent counts, not only the
|
|
1866
|
-
* page on screen.
|
|
1892
|
+
* page on screen. The Workspace column's decision without a credit pool to
|
|
1893
|
+
* read.
|
|
1867
1894
|
*/
|
|
1868
1895
|
declare function usageLogsSpentByOthers(logs: UsageLogsPage, workspaceId: string | null | undefined): boolean;
|
|
1896
|
+
/**
|
|
1897
|
+
* Whether the Usage logs table shows its Workspace column: the same on every
|
|
1898
|
+
* page of a workspace's logs. With `fetchCreditPool`, whether the workspace
|
|
1899
|
+
* shares its credits or did (`poolSharesCredits`). Without it, or when the
|
|
1900
|
+
* pool could not be read (`failed`: a member who is not a workspace admin gets
|
|
1901
|
+
* a 403), whether any page loaded for the workspace so far had a row another
|
|
1902
|
+
* workspace spent: once shown it stays, on every page, until another workspace.
|
|
1903
|
+
*/
|
|
1904
|
+
declare function usageLogsShowWorkspace(state: Pick<UsageLogsState, "spentByOthers">, pool: {
|
|
1905
|
+
hasCreditPool: boolean;
|
|
1906
|
+
sharesCredits: boolean;
|
|
1907
|
+
failed?: boolean;
|
|
1908
|
+
}): boolean;
|
|
1869
1909
|
interface UsedByNamesLoader {
|
|
1870
1910
|
/** Look up `workspaceId`'s names, unless they are saved or being looked up. */
|
|
1871
1911
|
load: (workspaceId: string, fetchCreditPool: () => Promise<CreditPoolResponse>) => Promise<void>;
|
|
@@ -1876,14 +1916,18 @@ interface UsedByNamesLoader {
|
|
|
1876
1916
|
reset: () => void;
|
|
1877
1917
|
}
|
|
1878
1918
|
/**
|
|
1879
|
-
* Looks up
|
|
1880
|
-
*
|
|
1919
|
+
* Looks up a workspace's credit pool, once per workspace: the names of the
|
|
1920
|
+
* workspaces that spent its shared credits, and the pool itself (whether it
|
|
1921
|
+
* shares them at all). `save` gets each answer and says whether it
|
|
1881
1922
|
* kept it (false: that workspace is no longer shown); only a kept answer ends
|
|
1882
|
-
* the lookups for that workspace.
|
|
1883
|
-
*
|
|
1884
|
-
*
|
|
1885
|
-
|
|
1886
|
-
|
|
1923
|
+
* the lookups for that workspace. An unkept lookup is tried again on the next
|
|
1924
|
+
* call. A failed one calls `failed` (the Workspace column falls back to the
|
|
1925
|
+
* rows) and is tried once more on a later call when it was the network
|
|
1926
|
+
* (status 0 included) or a 5xx; a 4xx such as 401/403, or a second failure,
|
|
1927
|
+
* ends the lookups for that workspace until `reset`, so turning pages does not ask again. A call while
|
|
1928
|
+
* one for the same workspace is under way starts no other.
|
|
1929
|
+
*/
|
|
1930
|
+
declare function createUsedByNamesLoader(save: (workspaceId: string, names: Record<string, string>, pool: CreditPoolResponse) => boolean, failed?: (workspaceId: string) => void): UsedByNamesLoader;
|
|
1887
1931
|
/** The CSV file name for a picked day range, from its local calendar days. */
|
|
1888
1932
|
declare function usageLogsExportFileName(start: Date, end: Date): string;
|
|
1889
1933
|
/**
|
|
@@ -2860,6 +2904,12 @@ declare function usedByWorkspaceKey(log: Pick<UsageHistoryItem, "meta">, current
|
|
|
2860
2904
|
* whose rows stay in its history.
|
|
2861
2905
|
*/
|
|
2862
2906
|
declare function usedByNamesFrom(pool: Pick<CreditPoolResponse, "members" | "formerMembers"> | null | undefined): Record<string, string>;
|
|
2907
|
+
/**
|
|
2908
|
+
* Whether other workspaces may have spent this one's credits: it shares them,
|
|
2909
|
+
* or did. The usage logs table's "Workspace" column follows this, the same on
|
|
2910
|
+
* every page, never the rows of the page on screen.
|
|
2911
|
+
*/
|
|
2912
|
+
declare function poolSharesCredits(pool: Pick<CreditPoolResponse, "members" | "formerMembers"> | null | undefined): boolean;
|
|
2863
2913
|
declare const POOL_ERROR_CODES: readonly ["SPONSOR_ON_FREE_PLAN", "POOL_NOT_ALLOWED"];
|
|
2864
2914
|
type PoolErrorCode = (typeof POOL_ERROR_CODES)[number];
|
|
2865
2915
|
/** The billing pool error in a failure: its code, details and server message. */
|
|
@@ -3115,4 +3165,4 @@ interface AppSettingsRowProps {
|
|
|
3115
3165
|
}
|
|
3116
3166
|
declare function AppSettingsRow({ title, description, summary, href, onClick, disabled, disabledReason, ariaLabel, trailing }: AppSettingsRowProps): react.JSX.Element;
|
|
3117
3167
|
|
|
3118
|
-
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, BILLING_TABLE_FRAME_STYLE, BILLING_TABLE_MIN_HEIGHT, BILLING_TABLE_PAGER_STYLE, BillingContent, type BillingEntitlement, type BillingEventPayload, type BillingProduct, type BillingSubscription, BuyCreditsModal, type BuyCreditsPayload, type BuyCreditsResponse, ConfirmDeleteModal, ConfirmLeaveModal, type ConnectedApp, ConnectedAppsContent, type CreatedToken, type CreditCycleUnit, type CreditLimitUnit, type CreditLimitValidation, type CreditPoolCandidate, type CreditPoolFormerMember, type CreditPoolMember, CreditPoolMemberModal, type CreditPoolMemberModalProps, type CreditPoolMemberStatus, type CreditPoolMode, type CreditPoolResponse, type CreditPoolSelfShare, type CreditsMeter, type CurrentPlanState, type CustomCreditInfo, type CustomCreditResponse, DEFAULT_PERMISSIONS, DEFAULT_USER_LANGUAGE, EMPTY_USAGE_LOGS_PAGE, ExportDateModal, type FetchUsageLogs, type FetchUsageLogsInRangeOptions, INITIAL_USAGE_LOGS_STATE, INVOICE_DOWNLOAD_FAILED_MESSAGE, INVOICE_NOT_AVAILABLE_MESSAGE, InviteUpdateModal, type InvoiceDownloadKind, type InvoicePdfResponse, type LoginMethodsMember, type LoginMethodsSettings, type LoginMethodsSwitchState, MOCK_REFERRED_USERS, type MemberCreditLimit, MemberCreditLimitModal, type MemberCreditLimitRow, type MemberCreditLimitSource, type MemberCreditLimitsResponse, MemberListFrame, type MemberListFrameProps, type MemberListTab, MemberListToolbar, type MemberListToolbarProps, type MemberPermissionsPayload, OrganizationContent, type OrganizationData, type OrganizationDetails, OrganizationIntegrationsContent, type OrganizationInvite, type OrganizationJoinRequest, type OrganizationJoinableWorkspace, OrganizationLoginMethodsContent, type OrganizationMember, OrganizationMemberModal, type OrganizationMemberModalProps, type OrganizationMemberRole, OrganizationModal, OrganizationPicker, type OrganizationPickerItem, type OrganizationPickerProps, type OrganizationPickerType, type OrganizationView, type OrganizationWorkspaceItem, POOL_ERROR_CODES, POOL_EXPIRY_MAX_MONTHS, POOL_NOTE_MAX_LENGTH, PerUserLimitsView, type PoolEndsAtResult, type PoolErrorCode, type PoolExpiryChoice, type PoolValueValidation, type Price, type PriceMetadata, type ProductsResponse, ProfileAvatar, ProfileTab, REMOVE_REASON_MAX_LENGTH, ReferralHistoryView, type ReferralHistoryViewProps, ReferralTab, type ReferredUser, RemovePoolMemberModal, type RemovePoolMemberModalProps, RemoveSelfShareModal, type RemoveSelfShareModalProps, SCOPE_LABELS, ScopeHeader, type ScopeHeaderProps, type ServiceItem, type SetCreditPoolSelfShareInput, type SettingsAdapters, SettingsAdaptersProvider, type SettingsApiAdapter, type SettingsAuthAdapter, type SettingsAuthUser, SettingsContent, type SettingsContentProps, type SettingsImageUploadAdapter, type SettingsIntegrationsAdapter, type SettingsLoginMethodsAdapter, type SettingsNavigationAdapter, type SettingsOrganizationAdapter, type SettingsOrganizationCreateOptions, type SettingsOrganizationCurrent, type SettingsOrganizationJoinableItem, type SettingsOrganizationListItem, type SettingsOrganizationType, type SettingsScope, type SettingsTab, type SettingsToastAdapter, SettingsTooltip, type SettingsTooltipPlacement, type SettingsTooltipProps, type SettingsWorkspaceAdapter, type SettingsWorkspaceCurrent, type SettingsWorkspaceListItem, SharedCreditsView, type SharedPoolBalance, SiconKey, type SponsorShareBalance, type StoreItem, type SubscriptionPlan, type SubscriptionResponse, TAB_DESCRIPTIONS, TAB_LABELS, TAB_SCOPE, TAB_TO_URL, type TeamMember, TeamsContent, type TokenExpiry, TokensContent, URL_TO_TAB, USAGE_LOGS_EXPORT_BATCH_SIZE, USAGE_LOGS_EXPORT_EXTRA_REQUESTS, USAGE_LOGS_EXPORT_MAX_ROWS, USAGE_LOGS_PAGE_SIZE, USER_LANGUAGES, type UpdateCreditPoolMemberInput, type UpdateSubscriptionPayload, type UpdateSubscriptionResponse, type UsageHistoryItem, type UsageHistoryPagination, type UsageHistoryResponse, type UsageLogsAction, type UsageLogsExportResult, type UsageLogsPage, UsageLogsPager, type UsageLogsQuery, type UsageLogsState, type UsedByNamesLoader, type UserLanguage, type UserPermissions, WORKSPACE_CREDIT_LIMIT_REACHED, WORKSPACE_CREDIT_LIMIT_REACHED_MESSAGE, WORKSPACE_LIST_PAGE_SIZE, type WorkspaceCreditLimit, WorkspaceCreditLimitCard, type WorkspaceCreditLimitSummary, type WorkspaceData, WorkspaceGeneralTab, type WorkspaceGeneralTabProps, type WorkspaceInvite, type WorkspaceListOrganization, WorkspaceListTab, type WorkspaceMember, WorkspaceModal, type WorkspaceOrganization, type WorkspaceOrganizationRequest, WorkspacePicker, type WorkspacePickerGroup, type WorkspacePickerItem, type WorkspacePickerProps, WorkspaceTab, type WorkspaceUsageResponse, aboveTotalReason, belowUsageReason, canManageOnlyWorkspaceCreditLimit, canShowSharedCredits, checkPoolPercentTotal, cleanCreditLimitInput, cleanPoolValueInput, countLabel, createUsedByNamesLoader, creditCycleUnit, creditsMeter, deriveWorkspaceInvitePermission, describeAllowance, describeDefaultLimit, describeMemberLimit, describeWorkspaceCreditLimit, entitlementFromBody, entitlementFromFailure, expiryChoiceFor, fetchUsageLogsInRange, findBillingError, findPoolError, formatCreditLimit, formatCredits, formatPoolEndsAt, formatPoolSplit, groupWorkspaceList, hasPaidFeatures, inviteUpdate, invoiceDownloadKind, isLimitAboveTotal, isLimitBelowUsage, isPaidPlan, isSponsoredEntitlement, isWorkspaceCreditLimitReached, joinMembersWithLimits, lastUsedLabel, limitAboveTotalTotal, limitBelowUsageUsed, limitSourceLabel, loadCurrentPlan, loadWorkspaceOrganization, loginMethodsSwitchState, maximumCreditLimit, memberRoleUpdate, minPoolEndDate, minimumCreditLimit, ownCreditsFirstText, parseBillingEntitlement, parseInviteEmails, pausedOwnCreditsText, poolAllocatedPercent, poolAllocationText, poolEndsAtFrom, poolErrorMessage, poolRenewsAtCycleEnd, poolUnallocatedPercent, poolWorkspaceName, productsForCountry, readSettingsCaller, referralCodeOf, referralCountLabel, referralLink, referralSignupDate, rememberSettingsCaller, resolveSettingsTabFromPath, roundCredits, settingsReturnTarget, sharedPoolBannerText, sharedPoolEndsText, sliceUsageLogsPage, sortReferredUsers, sponsorShareBannerText, sponsorShareDetailText, sponsorShareSpentText, sponsoredCreditsText, ssoLabel, toCsv, toLocalDateInput, usageLogsCsvRows, usageLogsDateRange, usageLogsExportFileName, usageLogsPage, usageLogsReducer, usageLogsReloadPage, usageLogsSpentByOthers, useBillingEntitlement, useSettingsAdapters, useWorkspaceInvitePermission, useWorkspaceOrganization, usedByNamesFrom, usedByWorkspaceKey, userLanguageLabel, validateCreditLimitInput, validateDefaultCreditLimitInput, validatePoolText, validatePoolValue };
|
|
3168
|
+
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, BILLING_TABLE_FRAME_STYLE, BILLING_TABLE_MIN_HEIGHT, BILLING_TABLE_PAGER_STYLE, BillingContent, type BillingEntitlement, type BillingEventPayload, type BillingProduct, type BillingSubscription, BuyCreditsModal, type BuyCreditsPayload, type BuyCreditsResponse, ConfirmDeleteModal, ConfirmLeaveModal, type ConnectedApp, ConnectedAppsContent, type CreatedToken, type CreditCycleUnit, type CreditLimitUnit, type CreditLimitValidation, type CreditPoolCandidate, type CreditPoolFormerMember, type CreditPoolMember, CreditPoolMemberModal, type CreditPoolMemberModalProps, type CreditPoolMemberStatus, type CreditPoolMode, type CreditPoolResponse, type CreditPoolSelfShare, type CreditsMeter, type CurrentPlanState, type CustomCreditInfo, type CustomCreditResponse, DEFAULT_PERMISSIONS, DEFAULT_USER_LANGUAGE, EMPTY_USAGE_LOGS_PAGE, ExportDateModal, type FetchUsageLogs, type FetchUsageLogsInRangeOptions, INITIAL_USAGE_LOGS_STATE, INVOICE_DOWNLOAD_FAILED_MESSAGE, INVOICE_NOT_AVAILABLE_MESSAGE, InviteUpdateModal, type InvoiceDownloadKind, type InvoicePdfResponse, type LoginMethodsMember, type LoginMethodsSettings, type LoginMethodsSwitchState, MOCK_REFERRED_USERS, type MemberCreditLimit, MemberCreditLimitModal, type MemberCreditLimitRow, type MemberCreditLimitSource, type MemberCreditLimitsResponse, MemberListFrame, type MemberListFrameProps, type MemberListTab, MemberListToolbar, type MemberListToolbarProps, type MemberPermissionsPayload, OrganizationContent, type OrganizationData, type OrganizationDetails, OrganizationIntegrationsContent, type OrganizationInvite, type OrganizationJoinRequest, type OrganizationJoinableWorkspace, OrganizationLoginMethodsContent, type OrganizationMember, OrganizationMemberModal, type OrganizationMemberModalProps, type OrganizationMemberRole, OrganizationModal, OrganizationPicker, type OrganizationPickerItem, type OrganizationPickerProps, type OrganizationPickerType, type OrganizationView, type OrganizationWorkspaceItem, POOL_ERROR_CODES, POOL_EXPIRY_MAX_MONTHS, POOL_NOTE_MAX_LENGTH, PerUserLimitsView, type PoolEndsAtResult, type PoolErrorCode, type PoolExpiryChoice, type PoolValueValidation, type Price, type PriceMetadata, type ProductsResponse, ProfileAvatar, ProfileTab, REMOVE_REASON_MAX_LENGTH, ReferralHistoryView, type ReferralHistoryViewProps, ReferralTab, type ReferredUser, RemovePoolMemberModal, type RemovePoolMemberModalProps, RemoveSelfShareModal, type RemoveSelfShareModalProps, SCOPE_LABELS, ScopeHeader, type ScopeHeaderProps, type ServiceItem, type SetCreditPoolSelfShareInput, type SettingsAdapters, SettingsAdaptersProvider, type SettingsApiAdapter, type SettingsAuthAdapter, type SettingsAuthUser, SettingsContent, type SettingsContentProps, type SettingsImageUploadAdapter, type SettingsIntegrationsAdapter, type SettingsLoginMethodsAdapter, type SettingsNavigationAdapter, type SettingsOrganizationAdapter, type SettingsOrganizationCreateOptions, type SettingsOrganizationCurrent, type SettingsOrganizationJoinableItem, type SettingsOrganizationListItem, type SettingsOrganizationType, type SettingsScope, type SettingsTab, type SettingsToastAdapter, SettingsTooltip, type SettingsTooltipPlacement, type SettingsTooltipProps, type SettingsWorkspaceAdapter, type SettingsWorkspaceCurrent, type SettingsWorkspaceListItem, SharedCreditsView, type SharedPoolBalance, SiconKey, type SponsorShareBalance, type StoreItem, type SubscriptionPlan, type SubscriptionResponse, TAB_DESCRIPTIONS, TAB_LABELS, TAB_SCOPE, TAB_TO_URL, type TeamMember, TeamsContent, type TokenExpiry, TokensContent, URL_TO_TAB, USAGE_LOGS_EXPORT_BATCH_SIZE, USAGE_LOGS_EXPORT_EXTRA_REQUESTS, USAGE_LOGS_EXPORT_MAX_ROWS, USAGE_LOGS_PAGE_SIZE, USER_LANGUAGES, type UpdateCreditPoolMemberInput, type UpdateSubscriptionPayload, type UpdateSubscriptionResponse, type UsageHistoryItem, type UsageHistoryPagination, type UsageHistoryResponse, type UsageLogsAction, type UsageLogsExportResult, type UsageLogsPage, UsageLogsPager, type UsageLogsQuery, type UsageLogsState, UsageLogsTable, type UsedByNamesLoader, type UserLanguage, type UserPermissions, WORKSPACE_CREDIT_LIMIT_REACHED, WORKSPACE_CREDIT_LIMIT_REACHED_MESSAGE, WORKSPACE_LIST_PAGE_SIZE, type WorkspaceCreditLimit, WorkspaceCreditLimitCard, type WorkspaceCreditLimitSummary, type WorkspaceData, WorkspaceGeneralTab, type WorkspaceGeneralTabProps, type WorkspaceInvite, type WorkspaceListOrganization, WorkspaceListTab, type WorkspaceMember, WorkspaceModal, type WorkspaceOrganization, type WorkspaceOrganizationRequest, WorkspacePicker, type WorkspacePickerGroup, type WorkspacePickerItem, type WorkspacePickerProps, WorkspaceTab, type WorkspaceUsageResponse, aboveTotalReason, belowUsageReason, canManageOnlyWorkspaceCreditLimit, canShowSharedCredits, checkPoolPercentTotal, cleanCreditLimitInput, cleanPoolValueInput, countLabel, createUsedByNamesLoader, creditCycleUnit, creditsMeter, deriveWorkspaceInvitePermission, describeAllowance, describeDefaultLimit, describeMemberLimit, describeWorkspaceCreditLimit, entitlementFromBody, entitlementFromFailure, expiryChoiceFor, fetchUsageLogsInRange, findBillingError, findPoolError, formatCreditLimit, formatCredits, formatPoolEndsAt, formatPoolSplit, groupWorkspaceList, hasPaidFeatures, inviteUpdate, invoiceDownloadKind, isLimitAboveTotal, isLimitBelowUsage, isPaidPlan, isSponsoredEntitlement, isWorkspaceCreditLimitReached, joinMembersWithLimits, lastUsedLabel, limitAboveTotalTotal, limitBelowUsageUsed, limitSourceLabel, loadCurrentPlan, loadWorkspaceOrganization, loginMethodsSwitchState, maximumCreditLimit, memberRoleUpdate, minPoolEndDate, minimumCreditLimit, ownCreditsFirstText, parseBillingEntitlement, parseInviteEmails, pausedOwnCreditsText, poolAllocatedPercent, poolAllocationText, poolEndsAtFrom, poolErrorMessage, poolRenewsAtCycleEnd, poolSharesCredits, poolUnallocatedPercent, poolWorkspaceName, productsForCountry, readSettingsCaller, referralCodeOf, referralCountLabel, referralLink, referralSignupDate, rememberSettingsCaller, resolveSettingsTabFromPath, roundCredits, settingsReturnTarget, sharedPoolBannerText, sharedPoolEndsText, sliceUsageLogsPage, sortReferredUsers, sponsorShareBannerText, sponsorShareDetailText, sponsorShareSpentText, sponsoredCreditsText, ssoLabel, toCsv, toLocalDateInput, usageLogsCsvRows, usageLogsDateRange, usageLogsExportFileName, usageLogsPage, usageLogsReducer, usageLogsReloadPage, usageLogsShowWorkspace, usageLogsSpentByOthers, useBillingEntitlement, useSettingsAdapters, useWorkspaceInvitePermission, useWorkspaceOrganization, usedByNamesFrom, usedByWorkspaceKey, userLanguageLabel, validateCreditLimitInput, validateDefaultCreditLimitInput, validatePoolText, validatePoolValue };
|
package/dist/index.d.ts
CHANGED
|
@@ -1700,6 +1700,25 @@ type IconProps = Omit<SVGProps<SVGSVGElement>, 'color' | 'strokeWidth' | 'width'
|
|
|
1700
1700
|
};
|
|
1701
1701
|
declare const SiconKey: ({ color, strokeWidth, size, ...props }: IconProps) => react.JSX.Element;
|
|
1702
1702
|
|
|
1703
|
+
declare function UsageLogsTable({ logs, userMap, loading, error, onRetry, currentWorkspaceId, usedByNames, showWorkspace, }: {
|
|
1704
|
+
/** One page of rows: the table renders every row it is given. */
|
|
1705
|
+
logs: UsageHistoryItem[];
|
|
1706
|
+
userMap: Record<string, string>;
|
|
1707
|
+
loading: boolean;
|
|
1708
|
+
/** Shown in place of the rows when the page could not be loaded. */
|
|
1709
|
+
error?: string | null;
|
|
1710
|
+
onRetry?: () => void;
|
|
1711
|
+
/** Rows another workspace spent from this one's shared credits name it. */
|
|
1712
|
+
currentWorkspaceId?: string | null;
|
|
1713
|
+
/** Those workspaces' names, by lower-cased id. */
|
|
1714
|
+
usedByNames?: Record<string, string>;
|
|
1715
|
+
/**
|
|
1716
|
+
* A "Workspace" column: which workspace spent each row, for a workspace that
|
|
1717
|
+
* shares its credits (`poolSharesCredits`). The table's own decision, not
|
|
1718
|
+
* the rows': every page has the same columns.
|
|
1719
|
+
*/
|
|
1720
|
+
showWorkspace?: boolean;
|
|
1721
|
+
}): react__default.JSX.Element;
|
|
1703
1722
|
/** Previous / Next under the Usage logs table, with the page and the total. */
|
|
1704
1723
|
declare function UsageLogsPager({ page, totalPages, total, loading, onPageChange, }: {
|
|
1705
1724
|
/** 1-based. */
|
|
@@ -1825,6 +1844,12 @@ interface UsageLogsState {
|
|
|
1825
1844
|
requestedPage: number;
|
|
1826
1845
|
loading: boolean;
|
|
1827
1846
|
error: string | null;
|
|
1847
|
+
/**
|
|
1848
|
+
* Some page loaded for this workspace had a row another workspace spent
|
|
1849
|
+
* (`usageLogsSpentByOthers`); stays true until `reset`. The Workspace
|
|
1850
|
+
* column's decision for a host without `fetchCreditPool`.
|
|
1851
|
+
*/
|
|
1852
|
+
spentByOthers: boolean;
|
|
1828
1853
|
}
|
|
1829
1854
|
declare const INITIAL_USAGE_LOGS_STATE: UsageLogsState;
|
|
1830
1855
|
type UsageLogsAction =
|
|
@@ -1833,10 +1858,11 @@ type UsageLogsAction =
|
|
|
1833
1858
|
type: "request";
|
|
1834
1859
|
page: number;
|
|
1835
1860
|
}
|
|
1836
|
-
/** The page asked for arrived
|
|
1861
|
+
/** The page asked for arrived, for workspace `workspaceId`. */
|
|
1837
1862
|
| {
|
|
1838
1863
|
type: "loaded";
|
|
1839
1864
|
logs: UsageLogsPage;
|
|
1865
|
+
workspaceId?: string | null;
|
|
1840
1866
|
}
|
|
1841
1867
|
/** The page asked for did not; the one on screen stays. */
|
|
1842
1868
|
| {
|
|
@@ -1863,9 +1889,23 @@ declare function usageLogsReloadPage(state: UsageLogsState): number;
|
|
|
1863
1889
|
/**
|
|
1864
1890
|
* Whether the usage logs in hand have a row another workspace spent from this
|
|
1865
1891
|
* one's shared credits. Every row an unpaged adapter sent counts, not only the
|
|
1866
|
-
* page on screen.
|
|
1892
|
+
* page on screen. The Workspace column's decision without a credit pool to
|
|
1893
|
+
* read.
|
|
1867
1894
|
*/
|
|
1868
1895
|
declare function usageLogsSpentByOthers(logs: UsageLogsPage, workspaceId: string | null | undefined): boolean;
|
|
1896
|
+
/**
|
|
1897
|
+
* Whether the Usage logs table shows its Workspace column: the same on every
|
|
1898
|
+
* page of a workspace's logs. With `fetchCreditPool`, whether the workspace
|
|
1899
|
+
* shares its credits or did (`poolSharesCredits`). Without it, or when the
|
|
1900
|
+
* pool could not be read (`failed`: a member who is not a workspace admin gets
|
|
1901
|
+
* a 403), whether any page loaded for the workspace so far had a row another
|
|
1902
|
+
* workspace spent: once shown it stays, on every page, until another workspace.
|
|
1903
|
+
*/
|
|
1904
|
+
declare function usageLogsShowWorkspace(state: Pick<UsageLogsState, "spentByOthers">, pool: {
|
|
1905
|
+
hasCreditPool: boolean;
|
|
1906
|
+
sharesCredits: boolean;
|
|
1907
|
+
failed?: boolean;
|
|
1908
|
+
}): boolean;
|
|
1869
1909
|
interface UsedByNamesLoader {
|
|
1870
1910
|
/** Look up `workspaceId`'s names, unless they are saved or being looked up. */
|
|
1871
1911
|
load: (workspaceId: string, fetchCreditPool: () => Promise<CreditPoolResponse>) => Promise<void>;
|
|
@@ -1876,14 +1916,18 @@ interface UsedByNamesLoader {
|
|
|
1876
1916
|
reset: () => void;
|
|
1877
1917
|
}
|
|
1878
1918
|
/**
|
|
1879
|
-
* Looks up
|
|
1880
|
-
*
|
|
1919
|
+
* Looks up a workspace's credit pool, once per workspace: the names of the
|
|
1920
|
+
* workspaces that spent its shared credits, and the pool itself (whether it
|
|
1921
|
+
* shares them at all). `save` gets each answer and says whether it
|
|
1881
1922
|
* kept it (false: that workspace is no longer shown); only a kept answer ends
|
|
1882
|
-
* the lookups for that workspace.
|
|
1883
|
-
*
|
|
1884
|
-
*
|
|
1885
|
-
|
|
1886
|
-
|
|
1923
|
+
* the lookups for that workspace. An unkept lookup is tried again on the next
|
|
1924
|
+
* call. A failed one calls `failed` (the Workspace column falls back to the
|
|
1925
|
+
* rows) and is tried once more on a later call when it was the network
|
|
1926
|
+
* (status 0 included) or a 5xx; a 4xx such as 401/403, or a second failure,
|
|
1927
|
+
* ends the lookups for that workspace until `reset`, so turning pages does not ask again. A call while
|
|
1928
|
+
* one for the same workspace is under way starts no other.
|
|
1929
|
+
*/
|
|
1930
|
+
declare function createUsedByNamesLoader(save: (workspaceId: string, names: Record<string, string>, pool: CreditPoolResponse) => boolean, failed?: (workspaceId: string) => void): UsedByNamesLoader;
|
|
1887
1931
|
/** The CSV file name for a picked day range, from its local calendar days. */
|
|
1888
1932
|
declare function usageLogsExportFileName(start: Date, end: Date): string;
|
|
1889
1933
|
/**
|
|
@@ -2860,6 +2904,12 @@ declare function usedByWorkspaceKey(log: Pick<UsageHistoryItem, "meta">, current
|
|
|
2860
2904
|
* whose rows stay in its history.
|
|
2861
2905
|
*/
|
|
2862
2906
|
declare function usedByNamesFrom(pool: Pick<CreditPoolResponse, "members" | "formerMembers"> | null | undefined): Record<string, string>;
|
|
2907
|
+
/**
|
|
2908
|
+
* Whether other workspaces may have spent this one's credits: it shares them,
|
|
2909
|
+
* or did. The usage logs table's "Workspace" column follows this, the same on
|
|
2910
|
+
* every page, never the rows of the page on screen.
|
|
2911
|
+
*/
|
|
2912
|
+
declare function poolSharesCredits(pool: Pick<CreditPoolResponse, "members" | "formerMembers"> | null | undefined): boolean;
|
|
2863
2913
|
declare const POOL_ERROR_CODES: readonly ["SPONSOR_ON_FREE_PLAN", "POOL_NOT_ALLOWED"];
|
|
2864
2914
|
type PoolErrorCode = (typeof POOL_ERROR_CODES)[number];
|
|
2865
2915
|
/** The billing pool error in a failure: its code, details and server message. */
|
|
@@ -3115,4 +3165,4 @@ interface AppSettingsRowProps {
|
|
|
3115
3165
|
}
|
|
3116
3166
|
declare function AppSettingsRow({ title, description, summary, href, onClick, disabled, disabledReason, ariaLabel, trailing }: AppSettingsRowProps): react.JSX.Element;
|
|
3117
3167
|
|
|
3118
|
-
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, BILLING_TABLE_FRAME_STYLE, BILLING_TABLE_MIN_HEIGHT, BILLING_TABLE_PAGER_STYLE, BillingContent, type BillingEntitlement, type BillingEventPayload, type BillingProduct, type BillingSubscription, BuyCreditsModal, type BuyCreditsPayload, type BuyCreditsResponse, ConfirmDeleteModal, ConfirmLeaveModal, type ConnectedApp, ConnectedAppsContent, type CreatedToken, type CreditCycleUnit, type CreditLimitUnit, type CreditLimitValidation, type CreditPoolCandidate, type CreditPoolFormerMember, type CreditPoolMember, CreditPoolMemberModal, type CreditPoolMemberModalProps, type CreditPoolMemberStatus, type CreditPoolMode, type CreditPoolResponse, type CreditPoolSelfShare, type CreditsMeter, type CurrentPlanState, type CustomCreditInfo, type CustomCreditResponse, DEFAULT_PERMISSIONS, DEFAULT_USER_LANGUAGE, EMPTY_USAGE_LOGS_PAGE, ExportDateModal, type FetchUsageLogs, type FetchUsageLogsInRangeOptions, INITIAL_USAGE_LOGS_STATE, INVOICE_DOWNLOAD_FAILED_MESSAGE, INVOICE_NOT_AVAILABLE_MESSAGE, InviteUpdateModal, type InvoiceDownloadKind, type InvoicePdfResponse, type LoginMethodsMember, type LoginMethodsSettings, type LoginMethodsSwitchState, MOCK_REFERRED_USERS, type MemberCreditLimit, MemberCreditLimitModal, type MemberCreditLimitRow, type MemberCreditLimitSource, type MemberCreditLimitsResponse, MemberListFrame, type MemberListFrameProps, type MemberListTab, MemberListToolbar, type MemberListToolbarProps, type MemberPermissionsPayload, OrganizationContent, type OrganizationData, type OrganizationDetails, OrganizationIntegrationsContent, type OrganizationInvite, type OrganizationJoinRequest, type OrganizationJoinableWorkspace, OrganizationLoginMethodsContent, type OrganizationMember, OrganizationMemberModal, type OrganizationMemberModalProps, type OrganizationMemberRole, OrganizationModal, OrganizationPicker, type OrganizationPickerItem, type OrganizationPickerProps, type OrganizationPickerType, type OrganizationView, type OrganizationWorkspaceItem, POOL_ERROR_CODES, POOL_EXPIRY_MAX_MONTHS, POOL_NOTE_MAX_LENGTH, PerUserLimitsView, type PoolEndsAtResult, type PoolErrorCode, type PoolExpiryChoice, type PoolValueValidation, type Price, type PriceMetadata, type ProductsResponse, ProfileAvatar, ProfileTab, REMOVE_REASON_MAX_LENGTH, ReferralHistoryView, type ReferralHistoryViewProps, ReferralTab, type ReferredUser, RemovePoolMemberModal, type RemovePoolMemberModalProps, RemoveSelfShareModal, type RemoveSelfShareModalProps, SCOPE_LABELS, ScopeHeader, type ScopeHeaderProps, type ServiceItem, type SetCreditPoolSelfShareInput, type SettingsAdapters, SettingsAdaptersProvider, type SettingsApiAdapter, type SettingsAuthAdapter, type SettingsAuthUser, SettingsContent, type SettingsContentProps, type SettingsImageUploadAdapter, type SettingsIntegrationsAdapter, type SettingsLoginMethodsAdapter, type SettingsNavigationAdapter, type SettingsOrganizationAdapter, type SettingsOrganizationCreateOptions, type SettingsOrganizationCurrent, type SettingsOrganizationJoinableItem, type SettingsOrganizationListItem, type SettingsOrganizationType, type SettingsScope, type SettingsTab, type SettingsToastAdapter, SettingsTooltip, type SettingsTooltipPlacement, type SettingsTooltipProps, type SettingsWorkspaceAdapter, type SettingsWorkspaceCurrent, type SettingsWorkspaceListItem, SharedCreditsView, type SharedPoolBalance, SiconKey, type SponsorShareBalance, type StoreItem, type SubscriptionPlan, type SubscriptionResponse, TAB_DESCRIPTIONS, TAB_LABELS, TAB_SCOPE, TAB_TO_URL, type TeamMember, TeamsContent, type TokenExpiry, TokensContent, URL_TO_TAB, USAGE_LOGS_EXPORT_BATCH_SIZE, USAGE_LOGS_EXPORT_EXTRA_REQUESTS, USAGE_LOGS_EXPORT_MAX_ROWS, USAGE_LOGS_PAGE_SIZE, USER_LANGUAGES, type UpdateCreditPoolMemberInput, type UpdateSubscriptionPayload, type UpdateSubscriptionResponse, type UsageHistoryItem, type UsageHistoryPagination, type UsageHistoryResponse, type UsageLogsAction, type UsageLogsExportResult, type UsageLogsPage, UsageLogsPager, type UsageLogsQuery, type UsageLogsState, type UsedByNamesLoader, type UserLanguage, type UserPermissions, WORKSPACE_CREDIT_LIMIT_REACHED, WORKSPACE_CREDIT_LIMIT_REACHED_MESSAGE, WORKSPACE_LIST_PAGE_SIZE, type WorkspaceCreditLimit, WorkspaceCreditLimitCard, type WorkspaceCreditLimitSummary, type WorkspaceData, WorkspaceGeneralTab, type WorkspaceGeneralTabProps, type WorkspaceInvite, type WorkspaceListOrganization, WorkspaceListTab, type WorkspaceMember, WorkspaceModal, type WorkspaceOrganization, type WorkspaceOrganizationRequest, WorkspacePicker, type WorkspacePickerGroup, type WorkspacePickerItem, type WorkspacePickerProps, WorkspaceTab, type WorkspaceUsageResponse, aboveTotalReason, belowUsageReason, canManageOnlyWorkspaceCreditLimit, canShowSharedCredits, checkPoolPercentTotal, cleanCreditLimitInput, cleanPoolValueInput, countLabel, createUsedByNamesLoader, creditCycleUnit, creditsMeter, deriveWorkspaceInvitePermission, describeAllowance, describeDefaultLimit, describeMemberLimit, describeWorkspaceCreditLimit, entitlementFromBody, entitlementFromFailure, expiryChoiceFor, fetchUsageLogsInRange, findBillingError, findPoolError, formatCreditLimit, formatCredits, formatPoolEndsAt, formatPoolSplit, groupWorkspaceList, hasPaidFeatures, inviteUpdate, invoiceDownloadKind, isLimitAboveTotal, isLimitBelowUsage, isPaidPlan, isSponsoredEntitlement, isWorkspaceCreditLimitReached, joinMembersWithLimits, lastUsedLabel, limitAboveTotalTotal, limitBelowUsageUsed, limitSourceLabel, loadCurrentPlan, loadWorkspaceOrganization, loginMethodsSwitchState, maximumCreditLimit, memberRoleUpdate, minPoolEndDate, minimumCreditLimit, ownCreditsFirstText, parseBillingEntitlement, parseInviteEmails, pausedOwnCreditsText, poolAllocatedPercent, poolAllocationText, poolEndsAtFrom, poolErrorMessage, poolRenewsAtCycleEnd, poolUnallocatedPercent, poolWorkspaceName, productsForCountry, readSettingsCaller, referralCodeOf, referralCountLabel, referralLink, referralSignupDate, rememberSettingsCaller, resolveSettingsTabFromPath, roundCredits, settingsReturnTarget, sharedPoolBannerText, sharedPoolEndsText, sliceUsageLogsPage, sortReferredUsers, sponsorShareBannerText, sponsorShareDetailText, sponsorShareSpentText, sponsoredCreditsText, ssoLabel, toCsv, toLocalDateInput, usageLogsCsvRows, usageLogsDateRange, usageLogsExportFileName, usageLogsPage, usageLogsReducer, usageLogsReloadPage, usageLogsSpentByOthers, useBillingEntitlement, useSettingsAdapters, useWorkspaceInvitePermission, useWorkspaceOrganization, usedByNamesFrom, usedByWorkspaceKey, userLanguageLabel, validateCreditLimitInput, validateDefaultCreditLimitInput, validatePoolText, validatePoolValue };
|
|
3168
|
+
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, BILLING_TABLE_FRAME_STYLE, BILLING_TABLE_MIN_HEIGHT, BILLING_TABLE_PAGER_STYLE, BillingContent, type BillingEntitlement, type BillingEventPayload, type BillingProduct, type BillingSubscription, BuyCreditsModal, type BuyCreditsPayload, type BuyCreditsResponse, ConfirmDeleteModal, ConfirmLeaveModal, type ConnectedApp, ConnectedAppsContent, type CreatedToken, type CreditCycleUnit, type CreditLimitUnit, type CreditLimitValidation, type CreditPoolCandidate, type CreditPoolFormerMember, type CreditPoolMember, CreditPoolMemberModal, type CreditPoolMemberModalProps, type CreditPoolMemberStatus, type CreditPoolMode, type CreditPoolResponse, type CreditPoolSelfShare, type CreditsMeter, type CurrentPlanState, type CustomCreditInfo, type CustomCreditResponse, DEFAULT_PERMISSIONS, DEFAULT_USER_LANGUAGE, EMPTY_USAGE_LOGS_PAGE, ExportDateModal, type FetchUsageLogs, type FetchUsageLogsInRangeOptions, INITIAL_USAGE_LOGS_STATE, INVOICE_DOWNLOAD_FAILED_MESSAGE, INVOICE_NOT_AVAILABLE_MESSAGE, InviteUpdateModal, type InvoiceDownloadKind, type InvoicePdfResponse, type LoginMethodsMember, type LoginMethodsSettings, type LoginMethodsSwitchState, MOCK_REFERRED_USERS, type MemberCreditLimit, MemberCreditLimitModal, type MemberCreditLimitRow, type MemberCreditLimitSource, type MemberCreditLimitsResponse, MemberListFrame, type MemberListFrameProps, type MemberListTab, MemberListToolbar, type MemberListToolbarProps, type MemberPermissionsPayload, OrganizationContent, type OrganizationData, type OrganizationDetails, OrganizationIntegrationsContent, type OrganizationInvite, type OrganizationJoinRequest, type OrganizationJoinableWorkspace, OrganizationLoginMethodsContent, type OrganizationMember, OrganizationMemberModal, type OrganizationMemberModalProps, type OrganizationMemberRole, OrganizationModal, OrganizationPicker, type OrganizationPickerItem, type OrganizationPickerProps, type OrganizationPickerType, type OrganizationView, type OrganizationWorkspaceItem, POOL_ERROR_CODES, POOL_EXPIRY_MAX_MONTHS, POOL_NOTE_MAX_LENGTH, PerUserLimitsView, type PoolEndsAtResult, type PoolErrorCode, type PoolExpiryChoice, type PoolValueValidation, type Price, type PriceMetadata, type ProductsResponse, ProfileAvatar, ProfileTab, REMOVE_REASON_MAX_LENGTH, ReferralHistoryView, type ReferralHistoryViewProps, ReferralTab, type ReferredUser, RemovePoolMemberModal, type RemovePoolMemberModalProps, RemoveSelfShareModal, type RemoveSelfShareModalProps, SCOPE_LABELS, ScopeHeader, type ScopeHeaderProps, type ServiceItem, type SetCreditPoolSelfShareInput, type SettingsAdapters, SettingsAdaptersProvider, type SettingsApiAdapter, type SettingsAuthAdapter, type SettingsAuthUser, SettingsContent, type SettingsContentProps, type SettingsImageUploadAdapter, type SettingsIntegrationsAdapter, type SettingsLoginMethodsAdapter, type SettingsNavigationAdapter, type SettingsOrganizationAdapter, type SettingsOrganizationCreateOptions, type SettingsOrganizationCurrent, type SettingsOrganizationJoinableItem, type SettingsOrganizationListItem, type SettingsOrganizationType, type SettingsScope, type SettingsTab, type SettingsToastAdapter, SettingsTooltip, type SettingsTooltipPlacement, type SettingsTooltipProps, type SettingsWorkspaceAdapter, type SettingsWorkspaceCurrent, type SettingsWorkspaceListItem, SharedCreditsView, type SharedPoolBalance, SiconKey, type SponsorShareBalance, type StoreItem, type SubscriptionPlan, type SubscriptionResponse, TAB_DESCRIPTIONS, TAB_LABELS, TAB_SCOPE, TAB_TO_URL, type TeamMember, TeamsContent, type TokenExpiry, TokensContent, URL_TO_TAB, USAGE_LOGS_EXPORT_BATCH_SIZE, USAGE_LOGS_EXPORT_EXTRA_REQUESTS, USAGE_LOGS_EXPORT_MAX_ROWS, USAGE_LOGS_PAGE_SIZE, USER_LANGUAGES, type UpdateCreditPoolMemberInput, type UpdateSubscriptionPayload, type UpdateSubscriptionResponse, type UsageHistoryItem, type UsageHistoryPagination, type UsageHistoryResponse, type UsageLogsAction, type UsageLogsExportResult, type UsageLogsPage, UsageLogsPager, type UsageLogsQuery, type UsageLogsState, UsageLogsTable, type UsedByNamesLoader, type UserLanguage, type UserPermissions, WORKSPACE_CREDIT_LIMIT_REACHED, WORKSPACE_CREDIT_LIMIT_REACHED_MESSAGE, WORKSPACE_LIST_PAGE_SIZE, type WorkspaceCreditLimit, WorkspaceCreditLimitCard, type WorkspaceCreditLimitSummary, type WorkspaceData, WorkspaceGeneralTab, type WorkspaceGeneralTabProps, type WorkspaceInvite, type WorkspaceListOrganization, WorkspaceListTab, type WorkspaceMember, WorkspaceModal, type WorkspaceOrganization, type WorkspaceOrganizationRequest, WorkspacePicker, type WorkspacePickerGroup, type WorkspacePickerItem, type WorkspacePickerProps, WorkspaceTab, type WorkspaceUsageResponse, aboveTotalReason, belowUsageReason, canManageOnlyWorkspaceCreditLimit, canShowSharedCredits, checkPoolPercentTotal, cleanCreditLimitInput, cleanPoolValueInput, countLabel, createUsedByNamesLoader, creditCycleUnit, creditsMeter, deriveWorkspaceInvitePermission, describeAllowance, describeDefaultLimit, describeMemberLimit, describeWorkspaceCreditLimit, entitlementFromBody, entitlementFromFailure, expiryChoiceFor, fetchUsageLogsInRange, findBillingError, findPoolError, formatCreditLimit, formatCredits, formatPoolEndsAt, formatPoolSplit, groupWorkspaceList, hasPaidFeatures, inviteUpdate, invoiceDownloadKind, isLimitAboveTotal, isLimitBelowUsage, isPaidPlan, isSponsoredEntitlement, isWorkspaceCreditLimitReached, joinMembersWithLimits, lastUsedLabel, limitAboveTotalTotal, limitBelowUsageUsed, limitSourceLabel, loadCurrentPlan, loadWorkspaceOrganization, loginMethodsSwitchState, maximumCreditLimit, memberRoleUpdate, minPoolEndDate, minimumCreditLimit, ownCreditsFirstText, parseBillingEntitlement, parseInviteEmails, pausedOwnCreditsText, poolAllocatedPercent, poolAllocationText, poolEndsAtFrom, poolErrorMessage, poolRenewsAtCycleEnd, poolSharesCredits, poolUnallocatedPercent, poolWorkspaceName, productsForCountry, readSettingsCaller, referralCodeOf, referralCountLabel, referralLink, referralSignupDate, rememberSettingsCaller, resolveSettingsTabFromPath, roundCredits, settingsReturnTarget, sharedPoolBannerText, sharedPoolEndsText, sliceUsageLogsPage, sortReferredUsers, sponsorShareBannerText, sponsorShareDetailText, sponsorShareSpentText, sponsoredCreditsText, ssoLabel, toCsv, toLocalDateInput, usageLogsCsvRows, usageLogsDateRange, usageLogsExportFileName, usageLogsPage, usageLogsReducer, usageLogsReloadPage, usageLogsShowWorkspace, usageLogsSpentByOthers, useBillingEntitlement, useSettingsAdapters, useWorkspaceInvitePermission, useWorkspaceOrganization, usedByNamesFrom, usedByWorkspaceKey, userLanguageLabel, validateCreditLimitInput, validateDefaultCreditLimitInput, validatePoolText, validatePoolValue };
|
package/dist/index.js
CHANGED
|
@@ -84,6 +84,7 @@ __export(index_exports, {
|
|
|
84
84
|
USAGE_LOGS_PAGE_SIZE: () => USAGE_LOGS_PAGE_SIZE,
|
|
85
85
|
USER_LANGUAGES: () => USER_LANGUAGES,
|
|
86
86
|
UsageLogsPager: () => UsageLogsPager,
|
|
87
|
+
UsageLogsTable: () => UsageLogsTable,
|
|
87
88
|
WORKSPACE_CREDIT_LIMIT_REACHED: () => WORKSPACE_CREDIT_LIMIT_REACHED,
|
|
88
89
|
WORKSPACE_CREDIT_LIMIT_REACHED_MESSAGE: () => WORKSPACE_CREDIT_LIMIT_REACHED_MESSAGE,
|
|
89
90
|
WORKSPACE_LIST_PAGE_SIZE: () => WORKSPACE_LIST_PAGE_SIZE,
|
|
@@ -149,6 +150,7 @@ __export(index_exports, {
|
|
|
149
150
|
poolEndsAtFrom: () => poolEndsAtFrom,
|
|
150
151
|
poolErrorMessage: () => poolErrorMessage,
|
|
151
152
|
poolRenewsAtCycleEnd: () => poolRenewsAtCycleEnd,
|
|
153
|
+
poolSharesCredits: () => poolSharesCredits,
|
|
152
154
|
poolUnallocatedPercent: () => poolUnallocatedPercent,
|
|
153
155
|
poolWorkspaceName: () => poolWorkspaceName,
|
|
154
156
|
productsForCountry: () => productsForCountry,
|
|
@@ -178,6 +180,7 @@ __export(index_exports, {
|
|
|
178
180
|
usageLogsPage: () => usageLogsPage,
|
|
179
181
|
usageLogsReducer: () => usageLogsReducer,
|
|
180
182
|
usageLogsReloadPage: () => usageLogsReloadPage,
|
|
183
|
+
usageLogsShowWorkspace: () => usageLogsShowWorkspace,
|
|
181
184
|
usageLogsSpentByOthers: () => usageLogsSpentByOthers,
|
|
182
185
|
useBillingEntitlement: () => useBillingEntitlement,
|
|
183
186
|
useSettingsAdapters: () => useSettingsAdapters,
|
|
@@ -10361,6 +10364,9 @@ function usedByNamesFrom(pool) {
|
|
|
10361
10364
|
}
|
|
10362
10365
|
return names;
|
|
10363
10366
|
}
|
|
10367
|
+
function poolSharesCredits(pool) {
|
|
10368
|
+
return (pool?.members?.length ?? 0) > 0 || (pool?.formerMembers?.length ?? 0) > 0;
|
|
10369
|
+
}
|
|
10364
10370
|
var POOL_ERROR_CODES = ["SPONSOR_ON_FREE_PLAN", "POOL_NOT_ALLOWED"];
|
|
10365
10371
|
function findPoolError(failure) {
|
|
10366
10372
|
const error = findBillingError(failure, POOL_ERROR_CODES);
|
|
@@ -11513,7 +11519,8 @@ var INITIAL_USAGE_LOGS_STATE = {
|
|
|
11513
11519
|
logs: EMPTY_USAGE_LOGS_PAGE,
|
|
11514
11520
|
requestedPage: 1,
|
|
11515
11521
|
loading: false,
|
|
11516
|
-
error: null
|
|
11522
|
+
error: null,
|
|
11523
|
+
spentByOthers: false
|
|
11517
11524
|
};
|
|
11518
11525
|
function usageLogsReducer(state, action) {
|
|
11519
11526
|
switch (action.type) {
|
|
@@ -11524,7 +11531,8 @@ function usageLogsReducer(state, action) {
|
|
|
11524
11531
|
logs: action.logs,
|
|
11525
11532
|
requestedPage: action.logs.page,
|
|
11526
11533
|
loading: false,
|
|
11527
|
-
error: null
|
|
11534
|
+
error: null,
|
|
11535
|
+
spentByOthers: state.spentByOthers || usageLogsSpentByOthers(action.logs, action.workspaceId)
|
|
11528
11536
|
};
|
|
11529
11537
|
case "failed":
|
|
11530
11538
|
return { ...state, loading: false, error: action.error };
|
|
@@ -11545,21 +11553,40 @@ function usageLogsSpentByOthers(logs, workspaceId) {
|
|
|
11545
11553
|
(log) => usedByWorkspaceKey(log, workspaceId) !== null
|
|
11546
11554
|
);
|
|
11547
11555
|
}
|
|
11548
|
-
function
|
|
11556
|
+
function usageLogsShowWorkspace(state, pool) {
|
|
11557
|
+
return pool.hasCreditPool && !pool.failed ? pool.sharesCredits : state.spentByOthers;
|
|
11558
|
+
}
|
|
11559
|
+
function creditPoolFailureRetryable(failure) {
|
|
11560
|
+
const error = failure;
|
|
11561
|
+
const status = [error?.status, error?.statusCode, error?.response?.status].find(
|
|
11562
|
+
(value) => typeof value === "number" && Number.isFinite(value) && value > 0
|
|
11563
|
+
);
|
|
11564
|
+
return status === void 0 || status < 400 || status >= 500;
|
|
11565
|
+
}
|
|
11566
|
+
function createUsedByNamesLoader(save, failed) {
|
|
11549
11567
|
let savedFor = null;
|
|
11550
11568
|
let inFlight = null;
|
|
11569
|
+
let failedFor = null;
|
|
11551
11570
|
return {
|
|
11552
11571
|
async load(workspaceId, fetchCreditPool) {
|
|
11553
11572
|
if (savedFor === workspaceId || inFlight?.workspaceId === workspaceId) {
|
|
11554
11573
|
return;
|
|
11555
11574
|
}
|
|
11575
|
+
if (failedFor?.workspaceId === workspaceId && !failedFor.retry) return;
|
|
11556
11576
|
const lookup = { workspaceId };
|
|
11557
11577
|
inFlight = lookup;
|
|
11558
11578
|
try {
|
|
11559
11579
|
const pool = await fetchCreditPool();
|
|
11560
11580
|
if (inFlight !== lookup) return;
|
|
11561
|
-
if (save(workspaceId, usedByNamesFrom(pool))) savedFor = workspaceId;
|
|
11562
|
-
} catch {
|
|
11581
|
+
if (save(workspaceId, usedByNamesFrom(pool), pool)) savedFor = workspaceId;
|
|
11582
|
+
} catch (failure) {
|
|
11583
|
+
if (inFlight !== lookup) return;
|
|
11584
|
+
const retried = failedFor?.workspaceId === workspaceId;
|
|
11585
|
+
failedFor = {
|
|
11586
|
+
workspaceId,
|
|
11587
|
+
retry: !retried && creditPoolFailureRetryable(failure)
|
|
11588
|
+
};
|
|
11589
|
+
failed?.(workspaceId);
|
|
11563
11590
|
} finally {
|
|
11564
11591
|
if (inFlight === lookup) inFlight = null;
|
|
11565
11592
|
}
|
|
@@ -11567,6 +11594,7 @@ function createUsedByNamesLoader(save) {
|
|
|
11567
11594
|
reset() {
|
|
11568
11595
|
savedFor = null;
|
|
11569
11596
|
inFlight = null;
|
|
11597
|
+
failedFor = null;
|
|
11570
11598
|
}
|
|
11571
11599
|
};
|
|
11572
11600
|
}
|
|
@@ -12539,9 +12567,9 @@ function UsageLogsTable({
|
|
|
12539
12567
|
error = null,
|
|
12540
12568
|
onRetry,
|
|
12541
12569
|
currentWorkspaceId = null,
|
|
12542
|
-
usedByNames = {}
|
|
12570
|
+
usedByNames = {},
|
|
12571
|
+
showWorkspace = false
|
|
12543
12572
|
}) {
|
|
12544
|
-
const showWorkspace = logs.some((log) => usedByWorkspaceKey(log, currentWorkspaceId));
|
|
12545
12573
|
if (loading) {
|
|
12546
12574
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
12547
12575
|
"div",
|
|
@@ -12931,6 +12959,8 @@ function BillingContent({
|
|
|
12931
12959
|
const [sharedPool, setSharedPool] = (0, import_react24.useState)(null);
|
|
12932
12960
|
const [sponsorShare, setSponsorShare] = (0, import_react24.useState)(null);
|
|
12933
12961
|
const [usedByNames, setUsedByNames] = (0, import_react24.useState)({});
|
|
12962
|
+
const [sharesCredits, setSharesCredits] = (0, import_react24.useState)(false);
|
|
12963
|
+
const [creditPoolFailed, setCreditPoolFailed] = (0, import_react24.useState)(false);
|
|
12934
12964
|
const [allProducts, setProducts] = (0, import_react24.useState)([]);
|
|
12935
12965
|
const workspaceCountry = workspace.current?.country;
|
|
12936
12966
|
const products = (0, import_react24.useMemo)(
|
|
@@ -12954,11 +12984,18 @@ function BillingContent({
|
|
|
12954
12984
|
const workspaceIdRef = (0, import_react24.useRef)(workspaceId);
|
|
12955
12985
|
workspaceIdRef.current = workspaceId;
|
|
12956
12986
|
const loadUsedByNamesRef = (0, import_react24.useRef)(null);
|
|
12957
|
-
loadUsedByNamesRef.current ??= createUsedByNamesLoader(
|
|
12958
|
-
|
|
12959
|
-
|
|
12960
|
-
|
|
12961
|
-
|
|
12987
|
+
loadUsedByNamesRef.current ??= createUsedByNamesLoader(
|
|
12988
|
+
(forWorkspace, names, pool) => {
|
|
12989
|
+
if (forWorkspace !== workspaceIdRef.current) return false;
|
|
12990
|
+
setUsedByNames(names);
|
|
12991
|
+
setSharesCredits(poolSharesCredits(pool));
|
|
12992
|
+
setCreditPoolFailed(false);
|
|
12993
|
+
return true;
|
|
12994
|
+
},
|
|
12995
|
+
(forWorkspace) => {
|
|
12996
|
+
if (forWorkspace === workspaceIdRef.current) setCreditPoolFailed(true);
|
|
12997
|
+
}
|
|
12998
|
+
);
|
|
12962
12999
|
const [userMap, setUserMap] = (0, import_react24.useState)({});
|
|
12963
13000
|
const [customPlanCredits, setCustomPlanCredits] = (0, import_react24.useState)(
|
|
12964
13001
|
null
|
|
@@ -13047,19 +13084,14 @@ function BillingContent({
|
|
|
13047
13084
|
} catch {
|
|
13048
13085
|
}
|
|
13049
13086
|
}, [api]);
|
|
13050
|
-
const ensureUsedByNames = (0, import_react24.useCallback)(
|
|
13051
|
-
|
|
13052
|
-
|
|
13053
|
-
|
|
13054
|
-
|
|
13055
|
-
|
|
13056
|
-
|
|
13057
|
-
|
|
13058
|
-
() => fetchCreditPool.call(api)
|
|
13059
|
-
);
|
|
13060
|
-
},
|
|
13061
|
-
[api, workspaceId]
|
|
13062
|
-
);
|
|
13087
|
+
const ensureUsedByNames = (0, import_react24.useCallback)(() => {
|
|
13088
|
+
const fetchCreditPool = api.fetchCreditPool;
|
|
13089
|
+
if (!fetchCreditPool || !workspaceId) return;
|
|
13090
|
+
void loadUsedByNamesRef.current?.load(
|
|
13091
|
+
workspaceId,
|
|
13092
|
+
() => fetchCreditPool.call(api)
|
|
13093
|
+
);
|
|
13094
|
+
}, [api, workspaceId]);
|
|
13063
13095
|
const loadUsageLogsPage = (0, import_react24.useCallback)(
|
|
13064
13096
|
async (page) => {
|
|
13065
13097
|
const request = ++usageLogsRequestRef.current;
|
|
@@ -13068,6 +13100,7 @@ function BillingContent({
|
|
|
13068
13100
|
return;
|
|
13069
13101
|
}
|
|
13070
13102
|
dispatchUsageLogs({ type: "request", page });
|
|
13103
|
+
ensureUsedByNames();
|
|
13071
13104
|
try {
|
|
13072
13105
|
const res = await api.fetchUsageLogs({
|
|
13073
13106
|
page,
|
|
@@ -13075,8 +13108,11 @@ function BillingContent({
|
|
|
13075
13108
|
});
|
|
13076
13109
|
if (request !== usageLogsRequestRef.current) return;
|
|
13077
13110
|
const next = usageLogsPage(res, page);
|
|
13078
|
-
dispatchUsageLogs({
|
|
13079
|
-
|
|
13111
|
+
dispatchUsageLogs({
|
|
13112
|
+
type: "loaded",
|
|
13113
|
+
logs: next,
|
|
13114
|
+
workspaceId: workspaceIdRef.current
|
|
13115
|
+
});
|
|
13080
13116
|
} catch (err) {
|
|
13081
13117
|
if (request !== usageLogsRequestRef.current) return;
|
|
13082
13118
|
dispatchUsageLogs({
|
|
@@ -13091,7 +13127,7 @@ function BillingContent({
|
|
|
13091
13127
|
(page) => {
|
|
13092
13128
|
if (usageLogs.unpaged && !usageLogsError) {
|
|
13093
13129
|
dispatchUsageLogs({ type: "turn", page });
|
|
13094
|
-
ensureUsedByNames(
|
|
13130
|
+
ensureUsedByNames();
|
|
13095
13131
|
return;
|
|
13096
13132
|
}
|
|
13097
13133
|
void loadUsageLogsPage(page);
|
|
@@ -13241,6 +13277,8 @@ function BillingContent({
|
|
|
13241
13277
|
usageLogsStateRef.current = INITIAL_USAGE_LOGS_STATE;
|
|
13242
13278
|
loadUsedByNamesRef.current?.reset();
|
|
13243
13279
|
setUsedByNames({});
|
|
13280
|
+
setSharesCredits(false);
|
|
13281
|
+
setCreditPoolFailed(false);
|
|
13244
13282
|
}, [workspaceId]);
|
|
13245
13283
|
(0, import_react24.useEffect)(() => {
|
|
13246
13284
|
setInitialFetchTriggered(true);
|
|
@@ -13945,7 +13983,12 @@ function BillingContent({
|
|
|
13945
13983
|
error: usageLogsError,
|
|
13946
13984
|
onRetry: () => void loadUsageLogsPage(usageLogsState.requestedPage),
|
|
13947
13985
|
currentWorkspaceId: workspaceId,
|
|
13948
|
-
usedByNames
|
|
13986
|
+
usedByNames,
|
|
13987
|
+
showWorkspace: usageLogsShowWorkspace(usageLogsState, {
|
|
13988
|
+
hasCreditPool: Boolean(api.fetchCreditPool),
|
|
13989
|
+
sharesCredits,
|
|
13990
|
+
failed: creditPoolFailed
|
|
13991
|
+
})
|
|
13949
13992
|
}
|
|
13950
13993
|
),
|
|
13951
13994
|
!usageLogsError && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
package/dist/index.mjs
CHANGED
|
@@ -10239,6 +10239,9 @@ function usedByNamesFrom(pool) {
|
|
|
10239
10239
|
}
|
|
10240
10240
|
return names;
|
|
10241
10241
|
}
|
|
10242
|
+
function poolSharesCredits(pool) {
|
|
10243
|
+
return (pool?.members?.length ?? 0) > 0 || (pool?.formerMembers?.length ?? 0) > 0;
|
|
10244
|
+
}
|
|
10242
10245
|
var POOL_ERROR_CODES = ["SPONSOR_ON_FREE_PLAN", "POOL_NOT_ALLOWED"];
|
|
10243
10246
|
function findPoolError(failure) {
|
|
10244
10247
|
const error = findBillingError(failure, POOL_ERROR_CODES);
|
|
@@ -11391,7 +11394,8 @@ var INITIAL_USAGE_LOGS_STATE = {
|
|
|
11391
11394
|
logs: EMPTY_USAGE_LOGS_PAGE,
|
|
11392
11395
|
requestedPage: 1,
|
|
11393
11396
|
loading: false,
|
|
11394
|
-
error: null
|
|
11397
|
+
error: null,
|
|
11398
|
+
spentByOthers: false
|
|
11395
11399
|
};
|
|
11396
11400
|
function usageLogsReducer(state, action) {
|
|
11397
11401
|
switch (action.type) {
|
|
@@ -11402,7 +11406,8 @@ function usageLogsReducer(state, action) {
|
|
|
11402
11406
|
logs: action.logs,
|
|
11403
11407
|
requestedPage: action.logs.page,
|
|
11404
11408
|
loading: false,
|
|
11405
|
-
error: null
|
|
11409
|
+
error: null,
|
|
11410
|
+
spentByOthers: state.spentByOthers || usageLogsSpentByOthers(action.logs, action.workspaceId)
|
|
11406
11411
|
};
|
|
11407
11412
|
case "failed":
|
|
11408
11413
|
return { ...state, loading: false, error: action.error };
|
|
@@ -11423,21 +11428,40 @@ function usageLogsSpentByOthers(logs, workspaceId) {
|
|
|
11423
11428
|
(log) => usedByWorkspaceKey(log, workspaceId) !== null
|
|
11424
11429
|
);
|
|
11425
11430
|
}
|
|
11426
|
-
function
|
|
11431
|
+
function usageLogsShowWorkspace(state, pool) {
|
|
11432
|
+
return pool.hasCreditPool && !pool.failed ? pool.sharesCredits : state.spentByOthers;
|
|
11433
|
+
}
|
|
11434
|
+
function creditPoolFailureRetryable(failure) {
|
|
11435
|
+
const error = failure;
|
|
11436
|
+
const status = [error?.status, error?.statusCode, error?.response?.status].find(
|
|
11437
|
+
(value) => typeof value === "number" && Number.isFinite(value) && value > 0
|
|
11438
|
+
);
|
|
11439
|
+
return status === void 0 || status < 400 || status >= 500;
|
|
11440
|
+
}
|
|
11441
|
+
function createUsedByNamesLoader(save, failed) {
|
|
11427
11442
|
let savedFor = null;
|
|
11428
11443
|
let inFlight = null;
|
|
11444
|
+
let failedFor = null;
|
|
11429
11445
|
return {
|
|
11430
11446
|
async load(workspaceId, fetchCreditPool) {
|
|
11431
11447
|
if (savedFor === workspaceId || inFlight?.workspaceId === workspaceId) {
|
|
11432
11448
|
return;
|
|
11433
11449
|
}
|
|
11450
|
+
if (failedFor?.workspaceId === workspaceId && !failedFor.retry) return;
|
|
11434
11451
|
const lookup = { workspaceId };
|
|
11435
11452
|
inFlight = lookup;
|
|
11436
11453
|
try {
|
|
11437
11454
|
const pool = await fetchCreditPool();
|
|
11438
11455
|
if (inFlight !== lookup) return;
|
|
11439
|
-
if (save(workspaceId, usedByNamesFrom(pool))) savedFor = workspaceId;
|
|
11440
|
-
} catch {
|
|
11456
|
+
if (save(workspaceId, usedByNamesFrom(pool), pool)) savedFor = workspaceId;
|
|
11457
|
+
} catch (failure) {
|
|
11458
|
+
if (inFlight !== lookup) return;
|
|
11459
|
+
const retried = failedFor?.workspaceId === workspaceId;
|
|
11460
|
+
failedFor = {
|
|
11461
|
+
workspaceId,
|
|
11462
|
+
retry: !retried && creditPoolFailureRetryable(failure)
|
|
11463
|
+
};
|
|
11464
|
+
failed?.(workspaceId);
|
|
11441
11465
|
} finally {
|
|
11442
11466
|
if (inFlight === lookup) inFlight = null;
|
|
11443
11467
|
}
|
|
@@ -11445,6 +11469,7 @@ function createUsedByNamesLoader(save) {
|
|
|
11445
11469
|
reset() {
|
|
11446
11470
|
savedFor = null;
|
|
11447
11471
|
inFlight = null;
|
|
11472
|
+
failedFor = null;
|
|
11448
11473
|
}
|
|
11449
11474
|
};
|
|
11450
11475
|
}
|
|
@@ -12417,9 +12442,9 @@ function UsageLogsTable({
|
|
|
12417
12442
|
error = null,
|
|
12418
12443
|
onRetry,
|
|
12419
12444
|
currentWorkspaceId = null,
|
|
12420
|
-
usedByNames = {}
|
|
12445
|
+
usedByNames = {},
|
|
12446
|
+
showWorkspace = false
|
|
12421
12447
|
}) {
|
|
12422
|
-
const showWorkspace = logs.some((log) => usedByWorkspaceKey(log, currentWorkspaceId));
|
|
12423
12448
|
if (loading) {
|
|
12424
12449
|
return /* @__PURE__ */ jsx30(
|
|
12425
12450
|
"div",
|
|
@@ -12809,6 +12834,8 @@ function BillingContent({
|
|
|
12809
12834
|
const [sharedPool, setSharedPool] = useState22(null);
|
|
12810
12835
|
const [sponsorShare, setSponsorShare] = useState22(null);
|
|
12811
12836
|
const [usedByNames, setUsedByNames] = useState22({});
|
|
12837
|
+
const [sharesCredits, setSharesCredits] = useState22(false);
|
|
12838
|
+
const [creditPoolFailed, setCreditPoolFailed] = useState22(false);
|
|
12812
12839
|
const [allProducts, setProducts] = useState22([]);
|
|
12813
12840
|
const workspaceCountry = workspace.current?.country;
|
|
12814
12841
|
const products = useMemo4(
|
|
@@ -12832,11 +12859,18 @@ function BillingContent({
|
|
|
12832
12859
|
const workspaceIdRef = useRef12(workspaceId);
|
|
12833
12860
|
workspaceIdRef.current = workspaceId;
|
|
12834
12861
|
const loadUsedByNamesRef = useRef12(null);
|
|
12835
|
-
loadUsedByNamesRef.current ??= createUsedByNamesLoader(
|
|
12836
|
-
|
|
12837
|
-
|
|
12838
|
-
|
|
12839
|
-
|
|
12862
|
+
loadUsedByNamesRef.current ??= createUsedByNamesLoader(
|
|
12863
|
+
(forWorkspace, names, pool) => {
|
|
12864
|
+
if (forWorkspace !== workspaceIdRef.current) return false;
|
|
12865
|
+
setUsedByNames(names);
|
|
12866
|
+
setSharesCredits(poolSharesCredits(pool));
|
|
12867
|
+
setCreditPoolFailed(false);
|
|
12868
|
+
return true;
|
|
12869
|
+
},
|
|
12870
|
+
(forWorkspace) => {
|
|
12871
|
+
if (forWorkspace === workspaceIdRef.current) setCreditPoolFailed(true);
|
|
12872
|
+
}
|
|
12873
|
+
);
|
|
12840
12874
|
const [userMap, setUserMap] = useState22({});
|
|
12841
12875
|
const [customPlanCredits, setCustomPlanCredits] = useState22(
|
|
12842
12876
|
null
|
|
@@ -12925,19 +12959,14 @@ function BillingContent({
|
|
|
12925
12959
|
} catch {
|
|
12926
12960
|
}
|
|
12927
12961
|
}, [api]);
|
|
12928
|
-
const ensureUsedByNames = useCallback9(
|
|
12929
|
-
|
|
12930
|
-
|
|
12931
|
-
|
|
12932
|
-
|
|
12933
|
-
|
|
12934
|
-
|
|
12935
|
-
|
|
12936
|
-
() => fetchCreditPool.call(api)
|
|
12937
|
-
);
|
|
12938
|
-
},
|
|
12939
|
-
[api, workspaceId]
|
|
12940
|
-
);
|
|
12962
|
+
const ensureUsedByNames = useCallback9(() => {
|
|
12963
|
+
const fetchCreditPool = api.fetchCreditPool;
|
|
12964
|
+
if (!fetchCreditPool || !workspaceId) return;
|
|
12965
|
+
void loadUsedByNamesRef.current?.load(
|
|
12966
|
+
workspaceId,
|
|
12967
|
+
() => fetchCreditPool.call(api)
|
|
12968
|
+
);
|
|
12969
|
+
}, [api, workspaceId]);
|
|
12941
12970
|
const loadUsageLogsPage = useCallback9(
|
|
12942
12971
|
async (page) => {
|
|
12943
12972
|
const request = ++usageLogsRequestRef.current;
|
|
@@ -12946,6 +12975,7 @@ function BillingContent({
|
|
|
12946
12975
|
return;
|
|
12947
12976
|
}
|
|
12948
12977
|
dispatchUsageLogs({ type: "request", page });
|
|
12978
|
+
ensureUsedByNames();
|
|
12949
12979
|
try {
|
|
12950
12980
|
const res = await api.fetchUsageLogs({
|
|
12951
12981
|
page,
|
|
@@ -12953,8 +12983,11 @@ function BillingContent({
|
|
|
12953
12983
|
});
|
|
12954
12984
|
if (request !== usageLogsRequestRef.current) return;
|
|
12955
12985
|
const next = usageLogsPage(res, page);
|
|
12956
|
-
dispatchUsageLogs({
|
|
12957
|
-
|
|
12986
|
+
dispatchUsageLogs({
|
|
12987
|
+
type: "loaded",
|
|
12988
|
+
logs: next,
|
|
12989
|
+
workspaceId: workspaceIdRef.current
|
|
12990
|
+
});
|
|
12958
12991
|
} catch (err) {
|
|
12959
12992
|
if (request !== usageLogsRequestRef.current) return;
|
|
12960
12993
|
dispatchUsageLogs({
|
|
@@ -12969,7 +13002,7 @@ function BillingContent({
|
|
|
12969
13002
|
(page) => {
|
|
12970
13003
|
if (usageLogs.unpaged && !usageLogsError) {
|
|
12971
13004
|
dispatchUsageLogs({ type: "turn", page });
|
|
12972
|
-
ensureUsedByNames(
|
|
13005
|
+
ensureUsedByNames();
|
|
12973
13006
|
return;
|
|
12974
13007
|
}
|
|
12975
13008
|
void loadUsageLogsPage(page);
|
|
@@ -13119,6 +13152,8 @@ function BillingContent({
|
|
|
13119
13152
|
usageLogsStateRef.current = INITIAL_USAGE_LOGS_STATE;
|
|
13120
13153
|
loadUsedByNamesRef.current?.reset();
|
|
13121
13154
|
setUsedByNames({});
|
|
13155
|
+
setSharesCredits(false);
|
|
13156
|
+
setCreditPoolFailed(false);
|
|
13122
13157
|
}, [workspaceId]);
|
|
13123
13158
|
useEffect19(() => {
|
|
13124
13159
|
setInitialFetchTriggered(true);
|
|
@@ -13823,7 +13858,12 @@ function BillingContent({
|
|
|
13823
13858
|
error: usageLogsError,
|
|
13824
13859
|
onRetry: () => void loadUsageLogsPage(usageLogsState.requestedPage),
|
|
13825
13860
|
currentWorkspaceId: workspaceId,
|
|
13826
|
-
usedByNames
|
|
13861
|
+
usedByNames,
|
|
13862
|
+
showWorkspace: usageLogsShowWorkspace(usageLogsState, {
|
|
13863
|
+
hasCreditPool: Boolean(api.fetchCreditPool),
|
|
13864
|
+
sharesCredits,
|
|
13865
|
+
failed: creditPoolFailed
|
|
13866
|
+
})
|
|
13827
13867
|
}
|
|
13828
13868
|
),
|
|
13829
13869
|
!usageLogsError && /* @__PURE__ */ jsx30(
|
|
@@ -18733,6 +18773,7 @@ export {
|
|
|
18733
18773
|
USAGE_LOGS_PAGE_SIZE,
|
|
18734
18774
|
USER_LANGUAGES,
|
|
18735
18775
|
UsageLogsPager,
|
|
18776
|
+
UsageLogsTable,
|
|
18736
18777
|
WORKSPACE_CREDIT_LIMIT_REACHED,
|
|
18737
18778
|
WORKSPACE_CREDIT_LIMIT_REACHED_MESSAGE,
|
|
18738
18779
|
WORKSPACE_LIST_PAGE_SIZE,
|
|
@@ -18798,6 +18839,7 @@ export {
|
|
|
18798
18839
|
poolEndsAtFrom,
|
|
18799
18840
|
poolErrorMessage,
|
|
18800
18841
|
poolRenewsAtCycleEnd,
|
|
18842
|
+
poolSharesCredits,
|
|
18801
18843
|
poolUnallocatedPercent,
|
|
18802
18844
|
poolWorkspaceName,
|
|
18803
18845
|
productsForCountry,
|
|
@@ -18827,6 +18869,7 @@ export {
|
|
|
18827
18869
|
usageLogsPage,
|
|
18828
18870
|
usageLogsReducer,
|
|
18829
18871
|
usageLogsReloadPage,
|
|
18872
|
+
usageLogsShowWorkspace,
|
|
18830
18873
|
usageLogsSpentByOthers,
|
|
18831
18874
|
useBillingEntitlement,
|
|
18832
18875
|
useSettingsAdapters,
|