@kenz1117/dsh-ui-usage-billing 1.0.19 → 1.0.20
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 +2 -2
- package/README.md +2 -2
- package/lib/client.js +3 -3
- package/lib/index.js +16 -6
- package/lib/types/balance.d.ts +6 -0
- package/lib/types/client/heatmap.d.ts +1 -1
- package/lib/types/client/locales.d.ts +1 -1
- package/lib/types/client/round-chart.d.ts +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -3258,18 +3258,28 @@ function evalExtract(rule, data) {
|
|
|
3258
3258
|
}
|
|
3259
3259
|
return base;
|
|
3260
3260
|
}
|
|
3261
|
-
/**
|
|
3261
|
+
/**
|
|
3262
|
+
* 请求头占位符解析:值中任意位置的 `{{ENV_NAME}}` 经凭据 seam 替换(如
|
|
3263
|
+
* `Bearer {{KEY}}`、`token={{KEY}}`、一处多占位符);被引用的任一凭据缺失
|
|
3264
|
+
* 或为空 → 返回 null(fail-closed,与完整占位符形态的历史语义一致)。
|
|
3265
|
+
*/
|
|
3262
3266
|
async function resolveHeaders(ctx, headers) {
|
|
3263
3267
|
const resolved = {};
|
|
3264
3268
|
for (const [key, value] of Object.entries(headers)) {
|
|
3265
|
-
const
|
|
3266
|
-
if (
|
|
3269
|
+
const matches = [...value.matchAll(/\{\{([A-Z0-9_]+)\}\}/gi)];
|
|
3270
|
+
if (matches.length === 0) {
|
|
3267
3271
|
resolved[key] = value;
|
|
3268
3272
|
continue;
|
|
3269
3273
|
}
|
|
3270
|
-
const
|
|
3271
|
-
|
|
3272
|
-
|
|
3274
|
+
const hits = /* @__PURE__ */ new Map();
|
|
3275
|
+
for (const m of matches) {
|
|
3276
|
+
const name = m[1] ?? "";
|
|
3277
|
+
if (hits.has(name)) continue;
|
|
3278
|
+
const hit = await ctx.credentials.resolve(credentialRef(name));
|
|
3279
|
+
if (hit === void 0 || hit.value === "") return null;
|
|
3280
|
+
hits.set(name, hit.value);
|
|
3281
|
+
}
|
|
3282
|
+
resolved[key] = value.replace(/\{\{([A-Z0-9_]+)\}\}/gi, (raw, name) => hits.get(name) ?? raw);
|
|
3273
3283
|
}
|
|
3274
3284
|
return resolved;
|
|
3275
3285
|
}
|
package/lib/types/balance.d.ts
CHANGED
|
@@ -52,6 +52,12 @@ export declare function pickRemainingQuota(source: unknown): number | undefined;
|
|
|
52
52
|
* @returns 数值;取不到或结果非有限数返回 undefined。
|
|
53
53
|
*/
|
|
54
54
|
export declare function evalExtract(rule: CustomBalanceExtract, data: unknown): number | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* 请求头占位符解析:值中任意位置的 `{{ENV_NAME}}` 经凭据 seam 替换(如
|
|
57
|
+
* `Bearer {{KEY}}`、`token={{KEY}}`、一处多占位符);被引用的任一凭据缺失
|
|
58
|
+
* 或为空 → 返回 null(fail-closed,与完整占位符形态的历史语义一致)。
|
|
59
|
+
*/
|
|
60
|
+
export declare function resolveHeaders(ctx: Context, headers: Record<string, string>): Promise<Record<string, string> | null>;
|
|
55
61
|
/**
|
|
56
62
|
* 查询自定义 Provider 余额(插件 config 的 `customBalances`)。每个条目独立
|
|
57
63
|
* 成败:占位符凭据缺失 → unconfigured;401/403 → unauthorized;网络或提取
|
|
@@ -32,6 +32,6 @@ export declare function UsageHeatmap({ days, currency, now, t, range }: {
|
|
|
32
32
|
currency: CostCurrency;
|
|
33
33
|
now?: Date;
|
|
34
34
|
range?: 'month' | 'year';
|
|
35
|
-
t: (key: '
|
|
35
|
+
t: (key: 'costAbbr' | 'noData' | 'heatmapLess' | 'heatmapMore') => string;
|
|
36
36
|
}): React.ReactNode;
|
|
37
37
|
//# sourceMappingURL=heatmap.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Locale dictionaries for the usage billing surface. */
|
|
2
|
-
export type UsageBillingKey = '
|
|
2
|
+
export type UsageBillingKey = 'title' | 'cost' | 'todayCost' | 'monthCost' | 'yearCost' | 'monthProjected' | 'liveTurn' | 'liveSession' | 'calls' | 'cacheHitRate' | 'tokens' | 'inputTokens' | 'outputTokens' | 'avgCost' | 'trend' | 'trend7d' | 'trend30d' | 'trendMetric' | 'trendMetricCost' | 'trendMetricTokens' | 'trendEmpty' | 'budget' | 'budgetAmount' | 'budgetSummary' | 'sessions' | 'sessionTitle' | 'project' | 'lastActive' | 'sessionOverflow' | 'budgetTierBody' | 'models' | 'providerBilling' | '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' | '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' | 'floatNoTargets' | 'floatNoTargetsHint' | 'cardDisplay' | 'cardDisplayHint' | 'cardMetric' | 'cardMetricMoney' | 'cardMetricTokens' | 'triggerMonthTokens' | 'subscriptionsStale' | 'staleLedgerNotice' | 'tokenCacheWrite' | 'toolRank' | 'toolName' | 'userPrices' | 'userPricesHint' | 'userPriceSave' | 'userPriceModel' | 'userPriceSource' | 'userPriceSourceHint' | 'userPriceOffPeak' | 'userPriceCurrency' | 'userPriceAdd' | 'userPriceRemove' | 'sessionStaleBadge' | 'heatmapLess' | 'heatmapMore' | 'currency' | 'currencyCny' | 'currencyUsd' | 'heatmap' | 'rounds' | 'roundsHint' | 'anomaly' | 'workspaces' | 'workspacesHint' | 'model' | 'thModel' | 'thInputMiss' | 'thInputHit' | 'costAbbr' | 'tabOverview' | 'tabTrends' | 'tabProviders' | 'tabPricing' | 'tabSettings' | 'budgetHint' | 'peakAlertHint' | 'peakAlertDescPeak' | 'peakAlertDescOff' | 'export' | 'exportCsvDay' | 'exportCsvSession' | 'exportJson' | 'peakShare' | 'peakSharePerCall' | 'offPeakSavings' | 'perfMax' | 'weekCost' | 'roleCost' | 'roleUser' | 'roleAssistant' | 'roleTool' | 'roleHint' | 'tierPeak' | 'tierOff' | 'tierToPeak' | 'tierToOff' | 'tierAlertEnterPeak' | 'tierAlertEnterOff' | 'peakAlertTitlePeak' | 'peakAlertTitleOff' | 'peakAlert' | 'peakAlertLeadMin' | 'peakAlertPos' | 'peakAlertMode' | 'peakAlertPosCorner' | 'peakAlertPosCenter' | 'peakAlertModePeak' | 'peakAlertModeOff' | 'peakAlertModeBoth' | 'peakAlertWebNotify' | 'peakAlertPreview' | 'planTypeCode' | 'planTypeToken' | 'subscriptionFeePerMonth' | 'triggerToday' | 'triggerMonth' | 'subscriptionIncluded' | 'free' | 'official' | 'thirdParty' | 'perfSamples' | 'perfTtft' | 'perfP50' | 'perfP90' | 'perfTps' | 'perfLatency' | 'perfEstimated' | 'perfEmpty' | 'perfTpsUnit' | 'perfTitle' | 'perfHint' | 'perfAll' | 'perfChartEmpty' | 'heatmapYear' | 'heatmapMonth' | 'activeDays' | 'streakDays' | 'subscriptionAutoDetect' | 'pluginVersion' | 'pluginAuthor' | 'pluginRepository' | 'pluginNpm' | 'pluginLicense' | 'tabToken' | 'tokenExport' | 'tokenExportCsv' | 'tokenCacheHitRate' | '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' | '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>;
|
|
@@ -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: '
|
|
35
|
+
t: (key: 'model' | 'costAbbr') => string;
|
|
36
36
|
}): React.ReactNode;
|
|
37
37
|
//# sourceMappingURL=round-chart.d.ts.map
|
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.0.
|
|
4
|
+
"version": "1.0.20",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|