@kenz1117/dsh-ui-usage-billing 1.4.3 → 1.4.5
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.en.md +1 -1
- package/README.md +2 -2
- package/lib/client.js +5 -5
- package/lib/index.js +684 -598
- package/lib/types/aggregate.d.ts +3 -2
- package/lib/types/builtin-catalog.d.ts +15 -0
- package/lib/types/client/TrendChart.d.ts +2 -1
- package/lib/types/client/band-dot.d.ts +19 -0
- package/lib/types/client/heatmap.d.ts +12 -6
- package/lib/types/client/label-display.d.ts +19 -0
- package/lib/types/client/locales.d.ts +1 -1
- package/lib/types/client/pricing.d.ts +26 -8
- package/lib/types/client/rate-search.d.ts +19 -0
- package/lib/types/client/round-chart.d.ts +1 -1
- package/lib/types/client/usage-billing-settings.d.ts +32 -0
- package/lib/types/pricing-shared.d.ts +2 -0
- package/package.json +1 -1
- package/lib/types/client/vendor-logos.d.ts +0 -12
package/lib/types/aggregate.d.ts
CHANGED
|
@@ -13,8 +13,9 @@
|
|
|
13
13
|
import { SessionLogOffset } from '@deepseek-ai/dsh-session/types';
|
|
14
14
|
import type { SessionEvent, SessionHeader, SessionId } from '@deepseek-ai/dsh-session/types';
|
|
15
15
|
import type { TokenUsage } from '@deepseek-ai/dsh-llm';
|
|
16
|
-
import {
|
|
17
|
-
|
|
16
|
+
import { resolveCatalogKey } from './client/pricing.ts';
|
|
17
|
+
import { BUILTIN_MODEL_KEY_ALIASES } from './builtin-catalog.ts';
|
|
18
|
+
export { BUILTIN_MODEL_KEY_ALIASES, resolveCatalogKey };
|
|
18
19
|
/**
|
|
19
20
|
* 走订阅套餐(coding / token plan / opencode 订阅)的 provider id:这些通道的
|
|
20
21
|
* 调用按套餐计费,不再按 token 计费,因此即使模型 id 与计费表撞名也一律豁免。
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 内置价格目录与别名表的纯数据模块:只随 node 半构建发布(宿主聚合计价使用),
|
|
3
|
+
* 并经 /api/billing/pricing 下发给客户端注入——client bundle 不携带这份数据
|
|
4
|
+
* (瘦身:lib/client.js 约 -30 KiB)。条目结构与消费逻辑见 ./client/pricing.ts。
|
|
5
|
+
*/
|
|
6
|
+
import type { ModelEntry } from './client/pricing.ts';
|
|
7
|
+
export declare const BUILTIN_MODEL_CATALOG: readonly ModelEntry[];
|
|
8
|
+
/**
|
|
9
|
+
* 真实 provider model id → 计费目录键(`MODEL_CATALOG[].key`)的映射。未知 id
|
|
10
|
+
* 原样保留并落回 `other`(未知模型不估算费用)。聚合层(aggregate.ts)在折叠时
|
|
11
|
+
* 用同一张表把日志里的 model id 归并为目录键,客户端渲染(`modelOf`)也按它
|
|
12
|
+
* 解析,两侧共用一份映射,避免同一模型两侧不一致导致「未收录」。
|
|
13
|
+
*/
|
|
14
|
+
export declare const BUILTIN_MODEL_KEY_ALIASES: Readonly<Record<string, string>>;
|
|
15
|
+
//# sourceMappingURL=builtin-catalog.d.ts.map
|
|
@@ -40,10 +40,11 @@ export type TrendMetric = 'cost' | 'tokens';
|
|
|
40
40
|
* @param props.currency - display currency for the cost labels.
|
|
41
41
|
* @param props.metric - `cost` (stacked per-model CNY, default) or `tokens` (single-color total tokens).
|
|
42
42
|
*/
|
|
43
|
-
export declare function TrendChart({ data, models, currency, metric }: {
|
|
43
|
+
export declare function TrendChart({ data, models, currency, metric, t }: {
|
|
44
44
|
data: readonly TrendPoint[];
|
|
45
45
|
models?: readonly TrendSeriesModel[];
|
|
46
46
|
currency?: CostCurrency;
|
|
47
47
|
metric?: TrendMetric;
|
|
48
|
+
t?: (key: 'trendEmpty' | 'trendTotal' | 'calls') => string;
|
|
48
49
|
}): React.ReactNode;
|
|
49
50
|
//# sourceMappingURL=TrendChart.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 峰谷指示点状态(issue #65 / dots):把 `channelCountdown` 的结果映射成三种
|
|
3
|
+
* 展示状态。纯函数,便于无 DOM 单测;无峰谷的模型返回 null —— 不渲染任何东西,
|
|
4
|
+
* 绝不为「没有档位」的模型臆造一个状态。
|
|
5
|
+
*/
|
|
6
|
+
import type { PriceTierId } from './pricing.ts';
|
|
7
|
+
/** 指示点状态:低谷 / 即将切换 / 高峰。 */
|
|
8
|
+
export type BandState = 'offPeak' | 'soon' | 'peak';
|
|
9
|
+
/**
|
|
10
|
+
* 由倒计时推导指示点状态。
|
|
11
|
+
* @param band - `channelCountdown` 的返回值;null/undefined = 该模型无峰谷。
|
|
12
|
+
* @param leadMs - 「即将切换」的提前量(复用峰谷提醒的 `leadMin`)。
|
|
13
|
+
* @returns 展示状态;无峰谷时为 null。
|
|
14
|
+
*/
|
|
15
|
+
export declare function bandStateOf(band: {
|
|
16
|
+
tier: PriceTierId;
|
|
17
|
+
nextSwitchInMs: number;
|
|
18
|
+
} | null | undefined, leadMs: number): BandState | null;
|
|
19
|
+
//# sourceMappingURL=band-dot.d.ts.map
|
|
@@ -20,18 +20,24 @@ export interface HeatmapDay {
|
|
|
20
20
|
value: number;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
|
-
* Render the month or
|
|
24
|
-
* @param props.days - daily
|
|
25
|
-
*
|
|
23
|
+
* Render the month or week-column heatmap.
|
|
24
|
+
* @param props.days - daily value rows (keys are `YYYY-MM-DD`); the value's
|
|
25
|
+
* meaning follows `props.unit` (CNY cost or raw token count).
|
|
26
|
+
* @param props.currency - display currency for the hover amount (cost unit).
|
|
26
27
|
* @param props.now - anchor date (defaults to today); injectable for tests.
|
|
27
28
|
* @param props.t - locale function (used for the legend labels).
|
|
28
|
-
* @param props.range - `month` (calendar month)
|
|
29
|
+
* @param props.range - `month` (calendar month), `half` (last 26 weeks, large
|
|
30
|
+
* cells — the screenshot-friendly Codex-style view) or `year` (last 52
|
|
31
|
+
* weeks, GitHub style).
|
|
32
|
+
* @param props.unit - value metric: `cost` (default, money formatting) or
|
|
33
|
+
* `tokens` (compact token formatting).
|
|
29
34
|
*/
|
|
30
|
-
export declare function UsageHeatmap({ days, currency, now, t, range }: {
|
|
35
|
+
export declare function UsageHeatmap({ days, currency, now, t, range, unit }: {
|
|
31
36
|
days: readonly HeatmapDay[];
|
|
32
37
|
currency: CostCurrency;
|
|
33
38
|
now?: Date;
|
|
34
|
-
range?: 'month' | 'year';
|
|
39
|
+
range?: 'month' | 'half' | 'year';
|
|
40
|
+
unit?: 'cost' | 'tokens';
|
|
35
41
|
t: (key: 'costAbbr' | 'noData' | 'heatmapLess' | 'heatmapMore') => string;
|
|
36
42
|
}): React.ReactNode;
|
|
37
43
|
//# sourceMappingURL=heatmap.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 费率表附加行文案本地化:目录条目里的 `extraRows` `label`/`note`(`显式缓存创建`、
|
|
3
|
+
* `长期半价` 等)是数据层的中文字面量,同时充当渲染 key。与 provider-display.ts
|
|
4
|
+
* 同样的做法:不改动数据层形态,只在渲染层提供一张「中文文案 → 英文文案」映射,
|
|
5
|
+
* 未收录的字符串原样返回。集中一处便于统一管理与将来扩展第三语言。
|
|
6
|
+
*/
|
|
7
|
+
type LabelLang = 'zh' | 'en';
|
|
8
|
+
/**
|
|
9
|
+
* 把费率表附加行的 label/note 按界面语言本地化:中文映射成英文,其余原样返回。
|
|
10
|
+
* 仅在渲染层调用,不影响数据层的中文字面量与 key 匹配。
|
|
11
|
+
* @param text - 数据层原始文案(可能为 undefined,例如没有 note 的行)。
|
|
12
|
+
* @param lang - 当前界面语言。
|
|
13
|
+
* @returns 本地化后的文案;`undefined` 原样传回。
|
|
14
|
+
*/
|
|
15
|
+
export declare function localizeRowLabel(text: string, lang: LabelLang): string;
|
|
16
|
+
export declare function localizeRowLabel(text: undefined, lang: LabelLang): undefined;
|
|
17
|
+
export declare function localizeRowLabel(text: string | undefined, lang: LabelLang): string | undefined;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=label-display.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Locale dictionaries for the usage billing surface. */
|
|
2
|
-
export type UsageBillingKey = 'title' | 'cost' | 'todayCost' | 'monthCost' | 'yearCost' | 'monthProjected' | 'liveTurn' | 'liveSession' | 'calls' | 'cacheHitRate' | 'tokens' | 'inputTokens' | 'outputTokens' | 'avgCost' | 'kpiRange' | 'avgRangeToday' | 'avgRange7d' | 'avgRangeWeek' | 'avgRangeMonth' | 'avgRangeAll' | 'trend' | 'trend7d' | 'trend30d' | 'trendMetric' | 'trendMetricCost' | 'trendMetricTokens' | 'trendEmpty' | 'budget' | 'budgetRemain' | 'budgetAmount' | 'budgetSummary' | 'sessions' | 'sessionTitle' | 'lastActive' | 'sessionOverflow' | 'budgetTierBody' | 'models' | 'providerBilling' | 'channelUnknown' | 'directTag' | 'relayTag' | 'unknownTag' | 'planCountUnit' | 'actual' | 'pricing' | 'input' | 'output' | 'cacheHit' | 'peak' | 'offPeak' | 'flat' | 'band' | 'close' | 'footer' | 'footerCredit' | 'lastUpdated' | 'noData' | 'todayRate' | 'rateLive' | 'rateBuiltin' | 'promoBadge' | 'promoUntil' | 'promoOpenEnded' | 'pricingTip' | 'pricingUnit' | 'pricingNotes' | 'ubPeak' | 'ubOff' | 'ubStd' | 'peakBand' | 'pricingSource' | 'noteCache' | 'noteBand' | 'noteSource' | 'balance' | 'recharge' | 'rechargeHint' | 'balanceUnconfigured' | 'balanceUnauthorized' | 'balanceUnreachable' | 'uncatalogued' | 'estimatedPricing' | 'balanceDays' | 'balanceLowBody' | 'reconcileDrift' | 'reconcileDismiss' | 'subscriptionNotConfigured' | 'subscriptionUnauthorized' | 'subscriptionUnavailable' | 'subscriptionInvalid' | 'subscriptionRateLimited' | 'subscriptionSession' | 'subscriptionWeekly' | 'subscriptionMonthly' | 'subscriptionBilling' | 'subscriptionRemaining' | 'subscriptionExhausted' | 'subscriptionReset' | 'subscriptionNoApi' | 'floatWindow' | 'floatModeCombined' | 'floatModeSubscription' | 'floatMode' | 'floatTargets' | 'floatWindowHint' | 'floatPrimaryToday' | 'floatPrimaryWeek' | 'floatPrimaryMonth' | 'floatNoTargets' | 'floatNoTargetsHint' | 'cardDisplay' | 'cardDisplayHint' | 'cardMetric' | 'cardMetricMoney' | 'cardMetricTokens' | 'cardSpan' | 'cardSpanDay' | 'cardSpanWeek' | 'cardSpanMonth' | 'triggerMonthTokens' | 'triggerTodayTokens' | 'triggerWeekTokens' | 'subscriptionsStale' | 'staleLedgerNotice' | 'tokenCacheWrite' | 'toolRank' | 'toolName' | 'userPrices' | 'userPricesHint' | 'userPriceSave' | 'userPriceModel' | 'userPriceSource' | 'userPriceSourceHint' | 'userPriceOffPeak' | 'userPriceNormal' | 'userPriceCurrency' | 'userPriceAdd' | 'userPriceRemoveSelected' | 'userPriceSelect' | 'sessionStaleBadge' | 'sessionUntitled' | 'heatmapLess' | 'heatmapMore' | 'currency' | 'currencyCny' | 'currencyUsd' | 'heatmap' | 'rounds' | 'roundsHint' | 'anomaly' | 'model' | 'thModel' | 'thInputMiss' | 'thInputHit' | 'costAbbr' | 'tabOverview' | 'tabTrends' | 'tabProviders' | 'tabPricing' | 'tabSettings' | 'budgetHint' | 'peakAlertHint' | 'peakAlertDescPeak' | 'peakAlertDescOff' | 'peakAlertDescPeakZhipu' | 'peakAlertDescOffZhipu' | 'export' | 'exportCsvDay' | 'exportCsvSession' | 'exportJson' | 'peakShare' | 'peakSharePerCall' | 'offPeakSavings' | 'perfMax' | 'weekCost' | 'roleCost' | 'roleUser' | 'roleAssistant' | 'roleTool' | 'roleHint' | 'tierPeak' | 'tierOff' | 'tierToPeak' | 'tierToOff' | 'tierAlertEnterPeak' | 'tierAlertEnterOff' | 'tierAlertEnterPeakZhipu' | 'tierAlertEnterOffZhipu' | 'peakAlertTitlePeak' | 'peakAlertTitleOff' | 'peakAlert' | 'peakAlertLeadMin' | 'peakAlertPos' | 'peakAlertMode' | 'peakAlertPosCorner' | 'peakAlertPosCenter' | 'peakAlertModePeak' | 'peakAlertModeOff' | 'peakAlertModeBoth' | 'peakAlertWebNotify' | 'peakAlertPreview' | 'planTypeCode' | 'planTypeToken' | 'subscriptionFeePerMonth' | 'triggerToday' | 'triggerMonth' | 'subscriptionTag' | 'free' | 'perfSamples' | 'perfTtft' | 'perfP50' | 'perfP90' | 'perfTps' | 'perfLatency' | 'perfEstimated' | 'perfEmpty' | 'perfTpsUnit' | 'perfTitle' | 'perfHint' | 'perfAll' | 'perfChartEmpty' | 'heatmapYear' | 'heatmapMonth' | 'activeDays' | 'streakDays' | 'subscriptionAutoDetect' | 'pluginAuthor' | 'pluginRepository' | 'pluginNpm' | 'pluginLicense' | 'tabToken' | 'tokenExport' | 'tokenExportCsv' | 'tokenReasoningShare' | 'tokenReasoningShort' | 'tokenIo' | 'tokenPeak' | 'tokenDaily' | 'tokenByModel' | 'tokenMiss' | 'tokenHit' | 'tokenOutput' | 'tokenViewStructure' | 'tokenViewModel' | 'tokenHitShort' | 'tokenMissShort' | 'tokenTotal' | 'tokenShare' | 'usageStatsTool' | 'usageStatsToolHint' | 'balanceGranted' | 'balanceTopped' | 'balanceDaily' | 'balanceDaysLong' | 'balanceDaysUnit' | 'popTodayModel' | 'popNoConsumption' | 'popTitle' | 'popDirectLead' | 'popSubLead' | 'unpricedHint' | 'searchEstimateHint' | 'siteListDisplay' | 'siteListDisplayHint' | 'liveCostBar' | 'liveCostBarHint' | 'liveCostBarPosition' | 'liveCostBarPosBelow' | 'liveCostBarPosAbove' | 'liveCostBarPosToolbar' | 'exportCsvSite' | 'panelRelayQuota' | 'relayBalance' | 'relayNoQuota' | 'relayWindowUsed' | 'relayKindNewApi' | 'relayKindSub2Api' | 'relayKindUnknown';
|
|
2
|
+
export type UsageBillingKey = 'title' | 'cost' | 'todayCost' | 'monthCost' | 'yearCost' | 'monthProjected' | 'liveTurn' | 'liveSession' | 'calls' | 'cacheHitRate' | 'tokens' | 'inputTokens' | 'outputTokens' | 'avgCost' | 'kpiRange' | 'avgRangeToday' | 'avgRange7d' | 'avgRangeWeek' | 'avgRangeMonth' | 'avgRangeAll' | 'trend' | 'trend7d' | 'trend30d' | 'trendMetric' | 'trendMetricCost' | 'trendMetricTokens' | 'pricingSearch' | 'bandPinHint' | 'trendEmpty' | 'trendTotal' | 'roundsUnit' | 'healthModelsLive' | 'healthVendorsDown' | 'healthVendorsUnavailable' | 'budget' | 'budgetRemain' | 'budgetAmount' | 'budgetSummary' | 'sessions' | 'sessionTitle' | 'lastActive' | 'sessionOverflow' | 'budgetTierBody' | 'models' | 'providerBilling' | 'channelUnknown' | 'directTag' | 'relayTag' | 'unknownTag' | 'planCountUnit' | 'actual' | 'pricing' | 'input' | 'output' | 'cacheHit' | 'peak' | 'offPeak' | 'flat' | 'band' | 'close' | 'footer' | 'footerCredit' | 'lastUpdated' | 'noData' | 'todayRate' | 'rateLive' | 'rateBuiltin' | 'pricingSyncedAt' | 'pricingSyncNow' | 'pricingSyncing' | 'promoBadge' | 'promoUntil' | 'promoOpenEnded' | 'pricingTip' | 'pricingUnit' | 'pricingNotes' | 'ubPeak' | 'ubOff' | 'ubStd' | 'peakBand' | 'pricingSource' | 'noteCache' | 'noteBand' | 'noteSource' | 'balance' | 'recharge' | 'rechargeHint' | 'balanceUnconfigured' | 'balanceUnauthorized' | 'balanceUnreachable' | 'uncatalogued' | 'estimatedPricing' | 'balanceDays' | 'balanceLowBody' | 'reconcileDrift' | 'reconcileDismiss' | 'subscriptionNotConfigured' | 'subscriptionUnauthorized' | 'subscriptionUnavailable' | 'subscriptionInvalid' | 'subscriptionRateLimited' | 'subscriptionSession' | 'subscriptionWeekly' | 'subscriptionMonthly' | 'subscriptionBilling' | 'subscriptionRemaining' | 'subscriptionExhausted' | 'subscriptionReset' | 'subscriptionNoApi' | 'floatWindow' | 'floatModeCombined' | 'floatModeSubscription' | 'floatMode' | 'floatTargets' | 'floatWindowHint' | 'floatPrimaryToday' | 'floatPrimaryWeek' | 'floatPrimaryMonth' | 'floatNoTargets' | 'floatNoTargetsHint' | 'cardDisplay' | 'cardDisplayHint' | 'cardMetric' | 'cardMetricMoney' | 'cardMetricTokens' | 'cardSpan' | 'cardSpanDay' | 'cardSpanWeek' | 'cardSpanMonth' | 'triggerMonthTokens' | 'triggerTodayTokens' | 'triggerWeekTokens' | 'subscriptionsStale' | 'staleLedgerNotice' | 'tokenCacheWrite' | 'toolRank' | 'toolName' | 'userPrices' | 'userPricesHint' | 'userPriceSave' | 'userPriceModel' | 'userPriceSource' | 'userPriceSourceHint' | 'userPriceOffPeak' | 'userPriceNormal' | 'userPriceCurrency' | 'userPriceAdd' | 'userPriceRemoveSelected' | 'userPriceSelect' | 'sessionStaleBadge' | 'sessionUntitled' | 'heatmapLess' | 'heatmapMore' | 'currency' | 'currencyCny' | 'currencyUsd' | 'currencyEur' | 'language' | 'heatmap' | 'rounds' | 'roundsHint' | 'anomaly' | 'model' | 'thModel' | 'thInputMiss' | 'thInputHit' | 'costAbbr' | 'tabOverview' | 'tabTrends' | 'tabProviders' | 'tabPricing' | 'tabSettings' | 'budgetHint' | 'peakAlertHint' | 'peakAlertDescPeak' | 'peakAlertDescOff' | 'peakAlertDescPeakZhipu' | 'peakAlertDescOffZhipu' | 'export' | 'exportCsvDay' | 'exportCsvSession' | 'exportJson' | 'peakShare' | 'peakSharePerCall' | 'offPeakSavings' | 'perfMax' | 'weekCost' | 'roleCost' | 'roleUser' | 'roleAssistant' | 'roleTool' | 'roleHint' | 'tierPeak' | 'tierOff' | 'tierToPeak' | 'tierToOff' | 'tierAlertEnterPeak' | 'tierAlertEnterOff' | 'tierAlertEnterPeakZhipu' | 'tierAlertEnterOffZhipu' | 'peakAlertTitlePeak' | 'peakAlertTitleOff' | 'peakAlert' | 'peakAlertLeadMin' | 'peakAlertPos' | 'peakAlertMode' | 'peakAlertPosCorner' | 'peakAlertPosCenter' | 'peakAlertModePeak' | 'peakAlertModeOff' | 'peakAlertModeBoth' | 'peakAlertWebNotify' | 'peakAlertPreview' | 'planTypeCode' | 'planTypeToken' | 'subscriptionFeePerMonth' | 'triggerToday' | 'triggerMonth' | 'subscriptionTag' | 'free' | 'perfSamples' | 'perfTtft' | 'perfP50' | 'perfP90' | 'perfTps' | 'perfLatency' | 'perfEstimated' | 'perfEmpty' | 'perfTpsUnit' | 'perfTitle' | 'perfHint' | 'perfAll' | 'perfChartEmpty' | 'heatmapYear' | 'heatmapHalf' | 'heatmapMonth' | 'metricCost' | 'metricTokens' | 'heatmapTotal' | 'activeDays' | 'streakDays' | 'subscriptionAutoDetect' | 'pluginAuthor' | 'pluginRepository' | 'pluginNpm' | 'pluginLicense' | 'tabToken' | 'tokenExport' | 'tokenExportCsv' | 'tokenReasoningShare' | 'tokenReasoningShort' | 'tokenIo' | 'tokenPeak' | 'tokenDaily' | 'tokenByModel' | 'tokenMiss' | 'tokenHit' | 'tokenOutput' | 'tokenViewStructure' | 'tokenViewModel' | 'tokenHitShort' | 'tokenMissShort' | 'tokenTotal' | 'tokenShare' | 'usageStatsTool' | 'usageStatsToolHint' | 'balanceGranted' | 'balanceTopped' | 'balanceDaily' | 'balanceDaysLong' | 'balanceDaysUnit' | 'popTodayModel' | 'popNoConsumption' | 'popTitle' | 'popDirectLead' | 'popSubLead' | 'unpricedHint' | 'searchEstimateHint' | 'siteListDisplay' | 'siteListDisplayHint' | 'liveCostBar' | 'liveCostBarHint' | 'liveCostBarPosition' | 'liveCostBarPosBelow' | 'liveCostBarPosAbove' | 'liveCostBarPosToolbar' | 'exportCsvSite' | 'panelRelayQuota' | 'relayBalance' | 'relayNoQuota' | 'relayWindowUsed' | 'relayKindNewApi' | 'relayKindSub2Api' | 'relayKindUnknown';
|
|
3
3
|
export declare const NS = "usageBilling";
|
|
4
4
|
export declare const zh: Record<UsageBillingKey, string>;
|
|
5
5
|
export declare const en: Record<UsageBillingKey, string>;
|
|
@@ -26,6 +26,8 @@ import type { LivePricing } from '../pricing-shared.ts';
|
|
|
26
26
|
* live rate arrives the built-in value stays in force.
|
|
27
27
|
*/
|
|
28
28
|
export declare const USD_TO_CNY = 6.79;
|
|
29
|
+
/** 内置 EUR→CNY 汇率(实时汇率不可用时的兑底,与 USD_TO_CNY 同口径)。 */
|
|
30
|
+
export declare const EUR_TO_CNY = 7.71;
|
|
29
31
|
/**
|
|
30
32
|
* 注入用户自定义模型别名(node 半区在插件启动时调用一次)。纯内存状态:
|
|
31
33
|
* 聚合折叠与客户端渲染共用同一份(两侧一致性由同一注入点保证)。
|
|
@@ -137,6 +139,11 @@ export declare function getRateInfo(): {
|
|
|
137
139
|
rate: number;
|
|
138
140
|
live: boolean;
|
|
139
141
|
};
|
|
142
|
+
/** 欧元汇率与其是否为实时值(与 {@link getRateInfo} 同形)。 */
|
|
143
|
+
export declare function getEurRateInfo(): {
|
|
144
|
+
rate: number;
|
|
145
|
+
live: boolean;
|
|
146
|
+
};
|
|
140
147
|
/** Default share of traffic assumed to fall in the peak band (0..1). */
|
|
141
148
|
export declare const DEFAULT_PEAK_SHARE = 0.5;
|
|
142
149
|
/**
|
|
@@ -165,7 +172,7 @@ export declare const FLASH_REPRICE_MS: number;
|
|
|
165
172
|
/** 计费时段档位:高峰 / 空闲(官方 DeepSeek 刊例价:高峰 = 空闲 × 2)。 */
|
|
166
173
|
export type PriceTierId = 'peak' | 'offPeak';
|
|
167
174
|
/** 成本显示币种:人民币(国内模型直价)/ 美元(国外模型直价或换算显示)。 */
|
|
168
|
-
export type CostCurrency = 'cny' | 'usd';
|
|
175
|
+
export type CostCurrency = 'cny' | 'usd' | 'eur';
|
|
169
176
|
/**
|
|
170
177
|
* 工作日高峰时段判定(北京时间,UTC+8,无夏令时):09:00–12:00、14:00–18:00。
|
|
171
178
|
* 周末(周六/周日)北京全天为低谷,不调用本函数判定峰/平。
|
|
@@ -341,14 +348,17 @@ export interface ModelEntry {
|
|
|
341
348
|
*/
|
|
342
349
|
retired?: boolean;
|
|
343
350
|
}
|
|
344
|
-
export declare const MODEL_CATALOG: readonly ModelEntry[];
|
|
345
351
|
/**
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
*
|
|
352
|
+
* 注入内置目录与别名表(两侧各调用一次:宿主 activate、客户端首个 pricing 响应)。
|
|
353
|
+
* 重复注入整体替换并重建归一化索引。
|
|
354
|
+
* @param catalog - 内置目录条目(BUILTIN_MODEL_CATALOG 全量)。
|
|
355
|
+
* @param aliases - 内置别名表(BUILTIN_MODEL_KEY_ALIASES 全量)。
|
|
350
356
|
*/
|
|
351
|
-
export declare
|
|
357
|
+
export declare function applyBuiltinCatalog(catalog: readonly ModelEntry[], aliases: Readonly<Record<string, string>>): void;
|
|
358
|
+
/** 内置目录当前快照:未注入为空数组(client 首帧前渲染加载态)。 */
|
|
359
|
+
export declare function modelCatalog(): readonly ModelEntry[];
|
|
360
|
+
/** 内置别名表当前快照:未注入为空对象。 */
|
|
361
|
+
export declare function modelKeyAliases(): Readonly<Record<string, string>>;
|
|
352
362
|
/**
|
|
353
363
|
* 模型 id 归一化:小写、去括号附注(如 `gpt5.6 luna(go)` 只看主体)、再去所有
|
|
354
364
|
* 非字母数字分隔符(空格 / 横杠 / 点 / 下划线)。用于日志里的模型 id 与计费
|
|
@@ -433,6 +443,14 @@ export declare function computeCostAt(entry: ModelEntry, buckets: TokenUsageBuck
|
|
|
433
443
|
/** 人民币 → 美元(显示换算用):用当前生效汇率(实时优先,缺失回退内置),
|
|
434
444
|
* 与计价链路的 `currentRate()` 同口径,避免实时汇率生效时 USD 显示与计价不一致。 */
|
|
435
445
|
export declare function cnyToUsd(cny: number): number;
|
|
446
|
+
/**
|
|
447
|
+
* 人民币金额换算到展示币种。目录以 CNY/USD 为原生币种,费用统一以
|
|
448
|
+
* 人民币累计,展示层再按所选币种换算——EUR 与 USD 同一口径,不改变存储与聚合。
|
|
449
|
+
* @param cny - 人民币金额。
|
|
450
|
+
* @param currency - 目标展示币种。
|
|
451
|
+
* @returns 换算后的金额(汇率不可用时原值返回)。
|
|
452
|
+
*/
|
|
453
|
+
export declare function convertFromCny(cny: number, currency: CostCurrency): number;
|
|
436
454
|
/**
|
|
437
455
|
* Format an amount with adaptive precision and the given currency symbol.
|
|
438
456
|
* @param amount - the amount (CNY by default; pass `usd` for dollar display).
|
|
@@ -443,7 +461,7 @@ export declare function formatMoney(amount: number, currency?: CostCurrency): st
|
|
|
443
461
|
* Format a per-1M-token price in its native currency (free when the rate is
|
|
444
462
|
* zero): CNY for domestic models, USD for overseas ones.
|
|
445
463
|
*/
|
|
446
|
-
export declare function formatUnitPrice(price: number, currency?: 'CNY' | 'USD'): string;
|
|
464
|
+
export declare function formatUnitPrice(price: number, currency?: 'CNY' | 'USD' | 'EUR'): string;
|
|
447
465
|
/**
|
|
448
466
|
* 把一条「每百万 token」单价从原生币种换算到目标展示币种(按 USD→CNY 汇率)。
|
|
449
467
|
* 汇率缺失/非法时回退原值,避免 0 汇率把价格算没。
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 费率表搜索:目录 + models.dev 补充条目约 3000 行,无过滤时只能靠滚动定位
|
|
3
|
+
* 单个模型(issue #66)。判定抽成纯函数,便于无 DOM 单测;匹配目录键、显示名
|
|
4
|
+
* 与厂商三个字段,大小写不敏感,空查询原样返回(默认视图与现状一致)。
|
|
5
|
+
*/
|
|
6
|
+
/** 搜索可匹配的最小条目形状(ModelEntry 的子集,便于测试构造)。 */
|
|
7
|
+
export interface SearchableEntry {
|
|
8
|
+
key: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
provider?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 按查询过滤费率表行。
|
|
14
|
+
* @param entries - 待过滤的目录条目。
|
|
15
|
+
* @param query - 用户输入(首尾空白忽略)。
|
|
16
|
+
* @returns 命中的条目;查询为空/全空白时原样返回入参引用。
|
|
17
|
+
*/
|
|
18
|
+
export declare function filterRateRows<T extends SearchableEntry>(entries: readonly T[], query: string): readonly T[];
|
|
19
|
+
//# sourceMappingURL=rate-search.d.ts.map
|
|
@@ -32,6 +32,6 @@ export declare function RoundCostChart({ rounds, flags, currency, t }: {
|
|
|
32
32
|
rounds: readonly RoundChartRow[];
|
|
33
33
|
flags: readonly AnomalyFlag[];
|
|
34
34
|
currency: CostCurrency;
|
|
35
|
-
t: (key: 'model' | 'costAbbr') => string;
|
|
35
|
+
t: (key: 'model' | 'costAbbr' | 'roundsUnit') => string;
|
|
36
36
|
}): React.ReactNode;
|
|
37
37
|
//# sourceMappingURL=round-chart.d.ts.map
|
|
@@ -121,6 +121,38 @@ export declare const DEFAULT_CURRENCY: CostCurrency;
|
|
|
121
121
|
export declare function loadCurrency(): CostCurrency;
|
|
122
122
|
/** 写入显示币种。失败静默(展示偏好非关键)。 */
|
|
123
123
|
export declare function saveCurrency(currency: CostCurrency): void;
|
|
124
|
+
/**
|
|
125
|
+
* 被固定的模型(峰谷指示点):费率表里点击圆点固定,固定后在输入框旁常驻显示。
|
|
126
|
+
* 与币种偏好同一套做法:localStorage + CustomEvent,因为胶囊与弹窗分属两棵 React 树。
|
|
127
|
+
*/
|
|
128
|
+
export declare const PINNED_MODELS_STORAGE_KEY = "dsh.ui-usage-billing.pinned";
|
|
129
|
+
/** 固定列表变更后派发的 CustomEvent 名。 */
|
|
130
|
+
export declare const PINNED_MODELS_EVENT = "dsh.ui-usage-billing.pinned-pref";
|
|
131
|
+
/** 读取固定模型列表(损坏/非数组/非字符串项一律丢弃)。 */
|
|
132
|
+
export declare function loadPinnedModels(): string[];
|
|
133
|
+
/** 写入固定模型列表。失败静默(展示偏好非关键)。 */
|
|
134
|
+
export declare function savePinnedModels(keys: readonly string[]): void;
|
|
135
|
+
/** 界面语言(与币种解耦后独立持久化)。 */
|
|
136
|
+
export type BillingLanguage = 'zh' | 'en';
|
|
137
|
+
/** localStorage key(与其他 `dsh.ui-usage-billing.*` 偏好同命名空间)。 */
|
|
138
|
+
export declare const LANGUAGE_STORAGE_KEY = "dsh.ui-usage-billing.language";
|
|
139
|
+
/** 语言切换后派发的 CustomEvent 名(另一棵树监听它即时重读)。 */
|
|
140
|
+
export declare const LANGUAGE_PREF_EVENT = "dsh.ui-usage-billing.language-pref";
|
|
141
|
+
/**
|
|
142
|
+
* 读取界面语言。**迁移关键**:历史版本的语言是从币种推导的(选 $ 就是英文),
|
|
143
|
+
* 因此当尚无语言偏好时,**从已存的币种播种一次**并写回;升级后没有任何人
|
|
144
|
+
* 的界面语言会静默改变,且播种只发生一次。
|
|
145
|
+
* @returns 界面语言。
|
|
146
|
+
*/
|
|
147
|
+
export declare function loadLanguage(): BillingLanguage;
|
|
148
|
+
/** 写入界面语言。失败静默(展示偏好非关键)。 */
|
|
149
|
+
export declare function saveLanguage(language: BillingLanguage): void;
|
|
150
|
+
/**
|
|
151
|
+
* 切换某个模型的固定状态。
|
|
152
|
+
* @param key - 目录键。
|
|
153
|
+
* @returns 切换后的列表(已写入)。
|
|
154
|
+
*/
|
|
155
|
+
export declare function togglePinnedModel(key: string): string[];
|
|
124
156
|
/** 用户自定义单价(与 client/pricing.ts 的 `UserPriceEntry` 同形;type import,无运行时依赖)。 */
|
|
125
157
|
export type StoredUserPrice = UserPriceEntry;
|
|
126
158
|
/** 自定义价表:模型(+可选来源)→ 单价,条目列表(支持同名模型绑定不同中转站 origin)。 */
|
|
@@ -19,6 +19,8 @@ export interface LivePricing {
|
|
|
19
19
|
source: 'live' | 'builtin';
|
|
20
20
|
/** USD → CNY mid rate (present when the rate fetch succeeded). */
|
|
21
21
|
rate?: number;
|
|
22
|
+
/** EUR → CNY mid rate (present when the euro rate fetch succeeded). */
|
|
23
|
+
rateEur?: number;
|
|
22
24
|
/** Overrides keyed by built-in catalog key (present when router matches succeeded). */
|
|
23
25
|
prices?: Record<string, LivePrice>;
|
|
24
26
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kenz1117/dsh-ui-usage-billing",
|
|
3
3
|
"description": "Usage billing dashboard for DeepSeek Harness: sidebar cost metrics plus a full dashboard modal, priced from a current multi-provider catalog with real usage aggregated from session logs.",
|
|
4
|
-
"version": "1.4.
|
|
4
|
+
"version": "1.4.5",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deepseek-harness",
|
|
7
7
|
"deepseek",
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Vendor logos: inlined data URIs fetched from models.dev /logos/{id}.svg.
|
|
3
|
-
* Kept to the highest-traffic providers only to hold the client bundle under the
|
|
4
|
-
* DSH Store 256 KiB single-file cap. Every other provider falls back to a
|
|
5
|
-
* brand-color letter badge in the UI (see VendorLogo in UsageBilling.tsx), so no
|
|
6
|
-
* external asset or copyright risk is introduced for unlisted vendors. 月之暗面 is
|
|
7
|
-
* a hand-redrawn minimal crescent — its official SVG is a multi-thousand-node path
|
|
8
|
-
* that alone cost ~6.8 KiB.
|
|
9
|
-
*/
|
|
10
|
-
export declare const VENDOR_LOGOS: Readonly<Record<string, string>>;
|
|
11
|
-
export declare function vendorLogoOf(provider: string): string | undefined;
|
|
12
|
-
//# sourceMappingURL=vendor-logos.d.ts.map
|