@kortix/ui 0.15.5 → 0.15.7

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.
Files changed (56) hide show
  1. package/dist/customize/providers/provider-accordion.js +3 -2
  2. package/dist/customize/providers/provider-connect.d.ts +7 -0
  3. package/dist/customize/providers/provider-connect.js +21 -2
  4. package/dist/customize/providers/provider-sheet.js +3 -2
  5. package/dist/customize/sections/gateway-view.d.ts +1 -1
  6. package/dist/customize/sections/gateway-view.js +29 -14
  7. package/dist/customize/sections/llm-provider/chatgpt-subscription-connect.d.ts +3 -1
  8. package/dist/customize/sections/llm-provider/chatgpt-subscription-connect.js +2 -2
  9. package/dist/customize/sections/view/account-secret-resources-panel.js +4 -3
  10. package/dist/customize/sections/view/review-center-connected.js +15 -3
  11. package/dist/customize/sections/view/subscription-usage.d.ts +288 -7
  12. package/dist/customize/sections/view/subscription-usage.js +257 -30
  13. package/dist/i18n/en.d.ts +37 -47
  14. package/dist/i18n/en.js +40 -50
  15. package/dist/i18n/ui-catalog/app-registry-translation-keys.generated.js +5 -0
  16. package/dist/internal/auth/auth-primitives.d.ts +27 -0
  17. package/dist/internal/auth/auth-primitives.js +21 -0
  18. package/dist/internal/billing/index.d.ts +1 -0
  19. package/dist/internal/billing/index.js +2 -0
  20. package/dist/internal/billing/use-free-grant-unspent.d.ts +10 -0
  21. package/dist/internal/billing/use-free-grant-unspent.js +20 -0
  22. package/dist/internal/lib/billing/billing-gate-state.d.ts +20 -0
  23. package/dist/internal/lib/billing/billing-gate-state.js +22 -0
  24. package/dist/internal/lib/error-handler.js +0 -2
  25. package/dist/internal/notifications/notification-inbox.js +1 -1
  26. package/dist/internal/stores/upgrade-dialog-store.d.ts +0 -2
  27. package/dist/internal/stores/upgrade-dialog-store.js +0 -2
  28. package/dist/markdown/setup-links/approval-decision.d.ts +1 -1
  29. package/dist/markdown/setup-links/approval-decision.js +1 -1
  30. package/dist/session/prompts/ask-deck.d.ts +14 -2
  31. package/dist/session/prompts/ask-deck.js +6 -2
  32. package/dist/styles.css +1 -1
  33. package/dist/test-utils/intl.d.ts +37 -47
  34. package/dist/workspace/admin/settings-search.js +4 -12
  35. package/dist/workspace/inbox/workspace-inbox.js +11 -2
  36. package/dist/workspace/layout/new-session-create.d.ts +4 -2
  37. package/dist/workspace/layout/new-session-create.js +11 -0
  38. package/dist/workspace/review/approval-modal.d.ts +6 -6
  39. package/dist/workspace/review/approval-modal.js +10 -14
  40. package/dist/workspace/review/review-center.d.ts +9 -2
  41. package/dist/workspace/review/review-center.js +257 -125
  42. package/dist/workspace/review/review-detail.d.ts +20 -10
  43. package/dist/workspace/review/review-detail.js +39 -44
  44. package/dist/workspace/review/review-meta.d.ts +27 -6
  45. package/dist/workspace/review/review-meta.js +46 -34
  46. package/dist/workspace/sidebar/footer/project-download-app-nav.d.ts +10 -0
  47. package/dist/workspace/sidebar/footer/project-download-app-nav.js +53 -0
  48. package/dist/workspace/sidebar/footer/promo-nav-row.d.ts +2 -1
  49. package/dist/workspace/sidebar/footer/promo-nav-row.js +1 -1
  50. package/dist/workspace/sidebar/project-sidebar.d.ts +6 -1
  51. package/dist/workspace/sidebar/project-sidebar.js +3 -2
  52. package/dist/workspace/sidebar/workspace-menu-model.d.ts +19 -13
  53. package/dist/workspace/sidebar/workspace-menu-model.js +7 -8
  54. package/package.json +3 -3
  55. package/dist/customize/sections/view/subscription-usage-tab.d.ts +0 -25
  56. package/dist/customize/sections/view/subscription-usage-tab.js +0 -121
@@ -1,25 +0,0 @@
1
- import type { AccountSecretResource, SubscriptionUsage } from '@kortix/sdk';
2
- /** The props-only card also lets the design-system preview use synthetic data. */
3
- export declare function SubscriptionUsageCard({ secret, usage, fetching, error, onRefresh, onConnect, showLabel, }: {
4
- secret: AccountSecretResource;
5
- usage: SubscriptionUsage | null;
6
- fetching: boolean;
7
- error: boolean;
8
- onRefresh: () => void;
9
- onConnect?: () => void;
10
- /** Name the login under the provider: two logins of one provider look alike otherwise. */
11
- showLabel?: boolean;
12
- }): import("react").JSX.Element;
13
- /**
14
- * Whether the project has a ChatGPT or Claude subscription login to report on.
15
- * `ready` is false until the answer is known, so a caller can wait instead of
16
- * hiding, then showing, the Usage tab.
17
- */
18
- export declare function useHasSubscriptions(projectId: string, enabled?: boolean): {
19
- ready: boolean;
20
- has: boolean;
21
- };
22
- export declare function SubscriptionUsageTab({ projectId, onConnect, }: {
23
- projectId: string;
24
- onConnect: () => void;
25
- }): import("react").JSX.Element;
@@ -1,121 +0,0 @@
1
- 'use client';
2
- import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { useLocale, useTranslations } from '../../../i18n/index.js';
4
- import { useSubscriptionConnections, useSubscriptionUsage, } from '@kortix/sdk/react';
5
- import { ArrowClockwiseIcon, ChartBarIcon } from '@phosphor-icons/react';
6
- import { usePooledProviderIds } from '../../providers/provider-connect.js';
7
- import { Button } from '../../../primitives/button.js';
8
- import { Badge } from '../../../primitives/badge.js';
9
- import { EmptyState } from '../../../primitives/empty-state.js';
10
- import Loading from '../../../primitives/loading.js';
11
- import { ProviderLogo } from '../../../internal/lib/provider-branding.js';
12
- import { Progress } from '../../../primitives/progress.js';
13
- import { isSubscriptionLogin, shownUsage, formatReset, weeklyModel, usageTone, } from './subscription-usage.js';
14
- const PROVIDER_NAME = {
15
- codex: 'ChatGPT',
16
- 'claude-agent': 'Claude Code',
17
- };
18
- const TONE_BAR = {
19
- ok: 'bg-primary',
20
- near: 'bg-kortix-orange',
21
- critical: 'bg-kortix-red',
22
- limited: 'bg-kortix-red',
23
- };
24
- /** One plan window: its name, how much is used, a bar, and when it resets. */
25
- function UsageWindowMeter({ window, limited, now, lead, }) {
26
- const locale = useLocale();
27
- const t = useTranslations('subscriptionUsage');
28
- const model = weeklyModel(window.id);
29
- const label = window.id === 'five_hour'
30
- ? t('fiveHour')
31
- : window.id === 'weekly'
32
- ? t('weekly')
33
- : model
34
- ? t('weeklyModel', { model })
35
- : window.id.replaceAll('_', ' ');
36
- const expired = Boolean(window.resets_at && Date.parse(window.resets_at) <= now);
37
- const percent = Math.max(0, Math.min(100, Math.round(window.used_percent)));
38
- return (_jsxs("div", { className: "flex flex-col gap-2", children: [lead ? (_jsxs("div", { className: "flex items-baseline justify-between gap-3", children: [_jsxs("span", { className: "text-2xl font-semibold tracking-tight tabular-nums", children: [percent, "%"] }), _jsx("span", { className: "text-xs text-muted-foreground", children: label })] })) : (_jsxs("div", { className: "flex items-baseline justify-between gap-3 text-sm", children: [_jsx("span", { children: label }), _jsxs("span", { className: "tabular-nums font-medium", children: [percent, "%"] })] })), _jsx(Progress, { value: percent, "aria-label": t('meterLabel', { label, percent }), className: "h-1.5 bg-muted", indicatorClassName: expired ? 'bg-muted-foreground' : TONE_BAR[usageTone(window, limited)] }), _jsx("p", { className: "text-xs text-muted-foreground", children: expired
39
- ? t('text9')
40
- : window.resets_at
41
- ? t('resets', { time: formatReset(window.resets_at, now, locale) })
42
- : t('text10') }), model === 'Fable' && (_jsx("p", { className: "text-xs text-muted-foreground", children: t('fableIncluded') }))] }));
43
- }
44
- /** The props-only card also lets the design-system preview use synthetic data. */
45
- export function SubscriptionUsageCard({ secret, usage, fetching, error, onRefresh, onConnect, showLabel = false, }) {
46
- const locale = useLocale();
47
- const t = useTranslations('subscriptionUsage');
48
- const now = Date.now();
49
- const reconnect = Boolean(secret.needs_reauth_at || secret.status === 'undecryptable');
50
- // A rejection in a snapshot whose reset has passed is no current limit.
51
- const rejectionIsCurrent = Boolean(usage?.limited &&
52
- !usage.windows.some((window) => window.resets_at && Date.parse(window.resets_at) <= now));
53
- const exhausted = rejectionIsCurrent ||
54
- Boolean(usage?.windows.some((w) => w.used_percent >= 100 &&
55
- (!w.resets_at || Date.parse(w.resets_at) > now)));
56
- const stale = Boolean(usage && now - Date.parse(usage.observed_at) > 10 * 60_000);
57
- // The badge appears only when something needs attention.
58
- const status = reconnect
59
- ? t('text0')
60
- : !secret.active
61
- ? t('text1')
62
- : error
63
- ? t('text2')
64
- : exhausted
65
- ? t('text4')
66
- : stale
67
- ? t('text5')
68
- : null;
69
- const windows = usage?.windows ?? [];
70
- // The window closest to its limit leads; the rest keep the provider's order.
71
- const lead = windows.reduce((best, window) => !best || window.used_percent > best.used_percent ? window : best, null);
72
- const rest = windows.filter((window) => window !== lead);
73
- return (_jsxs("article", { className: "rounded-md border border-border p-4 flex flex-col gap-4 min-w-0", children: [_jsxs("header", { className: "flex items-center justify-between gap-3", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [_jsx(ProviderLogo, { providerID: secret.provider_id ?? '', size: "small", tone: "light" }), _jsxs("div", { className: "min-w-0", children: [_jsxs("h3", { className: "text-sm font-medium truncate", children: [PROVIDER_NAME[secret.provider_id ?? ''] ?? secret.label, ' ', _jsx("span", { className: "text-muted-foreground font-normal capitalize", children: secret.provider_account?.plan ?? t('text7') })] }), showLabel && (_jsx("p", { className: "text-xs text-muted-foreground truncate", children: secret.label }))] })] }), _jsxs("div", { className: "flex shrink-0 items-center gap-2", children: [status && (_jsx(Badge, { size: "sm", variant: reconnect || exhausted ? 'warning' : 'secondary', children: status })), reconnect ? (_jsx(Button, { variant: "outline", size: "sm", onClick: onConnect, children: t('reconnect') })) : (_jsx(Button, { variant: "ghost", size: "icon-sm", disabled: fetching || !secret.active, onClick: onRefresh, "aria-label": t('refreshLabel', { label: secret.label }), title: fetching ? t('text15') : t('text16'), children: fetching ? _jsx(Loading, {}) : _jsx(ArrowClockwiseIcon, {}) }))] })] }), lead && usage ? (_jsxs(_Fragment, { children: [_jsx(UsageWindowMeter, { window: lead, limited: usage.limited, now: now, lead: true }), rest.length > 0 && (_jsx("div", { className: "flex flex-col gap-4 border-t border-border pt-4", children: rest.map((window) => (_jsx(UsageWindowMeter, { window: window, limited: usage.limited, now: now }, window.id))) }))] })) : (_jsx("p", { className: "text-sm text-muted-foreground", children: fetching ? t('text11') : error ? t('text2') : t('text12') })), usage && (error || stale) && (_jsx("p", { className: "text-xs text-muted-foreground", children: error
74
- ? t('text13')
75
- : t('observed', {
76
- time: new Date(usage.observed_at).toLocaleString(locale, {
77
- month: 'short',
78
- day: 'numeric',
79
- hour: 'numeric',
80
- minute: '2-digit',
81
- }),
82
- }) }))] }));
83
- }
84
- function ConnectedSubscription({ accountId, projectId, secret, onConnect, showLabel, }) {
85
- const live = useSubscriptionUsage(accountId, secret.secret_id, {
86
- projectId,
87
- storage: secret.storage,
88
- enabled: secret.can_use &&
89
- secret.active &&
90
- !secret.needs_reauth_at &&
91
- secret.status !== 'undecryptable',
92
- });
93
- return (_jsx(SubscriptionUsageCard, { secret: {
94
- ...secret,
95
- provider_account: live.data?.provider_account ?? secret.provider_account,
96
- }, usage: shownUsage(live.data?.usage, secret.usage), fetching: live.isFetching, error: live.isError, onRefresh: () => void live.refetch(), onConnect: onConnect, showLabel: showLabel }));
97
- }
98
- /**
99
- * Whether the project has a ChatGPT or Claude subscription login to report on.
100
- * `ready` is false until the answer is known, so a caller can wait instead of
101
- * hiding, then showing, the Usage tab.
102
- */
103
- export function useHasSubscriptions(projectId, enabled = true) {
104
- const pooled = usePooledProviderIds(projectId, enabled);
105
- const resources = useSubscriptionConnections(enabled ? pooled.accountId : null, projectId);
106
- const subscriptions = (resources.data?.subscriptions ?? []).filter((secret) => secret.can_use && isSubscriptionLogin(secret));
107
- const ready = !pooled.isLoading &&
108
- (!pooled.pooledSecretsEnabled || !pooled.accountId || !resources.isLoading);
109
- return { ready, has: subscriptions.length > 0 };
110
- }
111
- export function SubscriptionUsageTab({ projectId, onConnect, }) {
112
- const t = useTranslations('subscriptionUsage');
113
- const pooled = usePooledProviderIds(projectId, true);
114
- const resources = useSubscriptionConnections(pooled.accountId, projectId);
115
- // Every connected ChatGPT and Claude login, side by side.
116
- const subscriptions = (resources.data?.subscriptions ?? []).filter((secret) => secret.can_use && isSubscriptionLogin(secret));
117
- return (_jsxs("section", { className: "@container space-y-6 pb-6", children: [_jsx("h2", { className: "text-lg font-medium", children: t('text17') }), pooled.isLoading || (pooled.accountId && resources.isLoading) ? (_jsx(Loading, {})) : pooled.isError || resources.isError ? (_jsx(EmptyState, { title: t('text19'), description: t('text20'), action: _jsx(Button, { variant: "outline", onClick: () => {
118
- void pooled.refetch();
119
- void resources.refetch();
120
- }, children: t('text21') }) })) : !pooled.pooledSecretsEnabled ? (_jsx(EmptyState, { icon: ChartBarIcon, title: t('disabledTitle'), description: t('disabledDescription') })) : !subscriptions.length ? (_jsx(EmptyState, { icon: ChartBarIcon, title: t('text22'), description: t('text23'), action: _jsx(Button, { variant: "outline", onClick: onConnect, children: t('text24') }) })) : (_jsx("div", { className: "grid grid-flow-dense grid-cols-1 @3xl:grid-cols-2 items-start gap-4", children: subscriptions.map((secret) => (_jsx(ConnectedSubscription, { projectId: projectId, accountId: pooled.accountId, secret: secret, onConnect: onConnect, showLabel: subscriptions.filter((other) => other.provider_id === secret.provider_id).length > 1 }, `${secret.storage}:${secret.secret_id}`))) }))] }));
121
- }