@kenz1117/dsh-ui-usage-billing 1.1.7 → 1.1.8

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.
@@ -106,6 +106,16 @@ export declare function lastSevenDays(byDay: Record<string, {
106
106
  date: string;
107
107
  cost: number;
108
108
  }[];
109
+ /**
110
+ * 本自然周(周一起算)到 `today` 的累计值(issue #39):标签「本周」的语义是
111
+ * 自然周,近 7 天滚动窗口会在周一把上周用量卷进来(周一时它与当月几乎相等,
112
+ * 用户误解为统计错误)。周一 = `getDay() === 1`;`pick` 决定日行取哪个维度。
113
+ * @param byDay - 按日聚合表(key = `YYYY-MM-DD` 本地时区)。
114
+ * @param today - 今天的本地日期戳。
115
+ * @param pick - 日行取值(缺省取 cost;token 视角传 input+output 合计)。
116
+ * @returns 本周一到今天的合计;`today` 本身不在表里(无调用)时为 0。
117
+ */
118
+ export declare function sinceMondayOf<T>(byDay: Record<string, T>, today: string, pick?: (row: T) => number): number;
109
119
  /** 会话明细行(与服务端 SessionUsageRow 同形;旧快照可能缺失整个 bySession)。 */
110
120
  interface SessionBillingRow {
111
121
  id: string;
@@ -129,9 +129,15 @@ export declare function isPeakHour(beijingHour: number): boolean;
129
129
  */
130
130
  export declare function tierAt(timeMs: number | null | undefined): PriceTierId;
131
131
  /**
132
- * 当前峰谷档位与距下次切换的时长。导出供测试:纯函数。
132
+ * 当前峰谷档位与距下一切换的时长。导出供测试:纯函数。
133
+ *
134
+ * 下一切换点统一定义为档位真正变化的最近边界:自当前时刻起逐天扫描工作日的
135
+ * 09:00 / 12:00 / 14:00 / 18:00,候选时刻的档位由 {@link tierAt} 判定——
136
+ * 周末(周六/周日)北京全天低谷、没有边界,扫描自然跳过;工作日深夜跨周末
137
+ * 时落到周一 09:00 而非周末伪边界(issue #33)。
138
+ * 最坏情形(周五 18:00 后 → 周一 09:00)约 63h,7 天窗口必然覆盖。
133
139
  * @param nowMs - 当前时刻(epoch 毫秒)。
134
- * @returns 当前档位与到下一个切换边界的毫秒数。
140
+ * @returns 当前档位与到下一切换边界的毫秒数。
135
141
  */
136
142
  export declare function tierCountdown(nowMs: number): {
137
143
  tier: PriceTierId;
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.1.7",
4
+ "version": "1.1.8",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },