ccusage 0.6.1 → 0.6.2
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 +3 -4
- package/dist/calculate-cost.d.ts +2 -2
- package/dist/{data-loader-VdEcqJHc.d.ts → data-loader-B0tJZeHI.d.ts} +77 -4
- package/dist/{data-loader-DP5qBPn6.js → data-loader-BfnzLKGl.js} +491 -139
- package/dist/data-loader.d.ts +2 -2
- package/dist/data-loader.js +4 -4
- package/dist/{debug-C_5Qx11m.js → debug-Bf6GUNZE.js} +42 -37
- package/dist/debug.js +5 -5
- package/dist/{dist-C0-Tf5eD.js → dist-BEQ1tJCL.js} +1 -18
- package/dist/{dist-LwbOR2Yw.js → dist-DAarI-SJ.js} +1 -1
- package/dist/{effect-WSjEuzC9-CJfWUy0j.js → effect-WSjEuzC9-ChJ5OQQf.js} +1 -1
- package/dist/{index-CISmcbXk-DCA05NUL.js → index-CISmcbXk-x9eVmhGM.js} +4 -4
- package/dist/index.js +7 -16
- package/dist/{logger-DsQC4OvA.js → logger-DixU80sg.js} +1 -1
- package/dist/logger.js +1 -1
- package/dist/{mcp-BQdv12mr.js → mcp-nXxiNurt.js} +15 -9
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +6 -6
- package/dist/pricing-fetcher-BY3-ryVq.js +79 -0
- package/dist/{pricing-fetcher-CfEgfzSr.d.ts → pricing-fetcher-Dq-OLBp4.d.ts} +22 -10
- package/dist/pricing-fetcher.d.ts +2 -2
- package/dist/pricing-fetcher.js +4 -4
- package/dist/{sury-DmrZ3_Oj-CCL_DlTt.js → sury-DmrZ3_Oj-l0qqtY-f.js} +1 -1
- package/dist/valibot-CQk-M5rL-BNHzwpA0.js +10 -0
- package/dist/{zod-Db63SLXj-Dyc_OWjq.js → zod-Db63SLXj-N1oN-yiY.js} +1 -1
- package/package.json +1 -1
- package/dist/pricing-fetcher-BPUgMrB_.js +0 -60
- package/dist/valibot-CQk-M5rL-CkjrLVu1.js +0 -10
package/README.md
CHANGED
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
> **ccusage(claude-code-usage)**
|
|
4
4
|
|
|
5
5
|
[](https://npmjs.com/package/ccusage)
|
|
6
|
-
[](https://
|
|
7
|
-
[](https://deepwiki.com/ryoppippi/ccusage)
|
|
8
|
-
|
|
9
|
-
<!-- DeepWiki badge generated by https://deepwiki.ryoppippi.com/ -->
|
|
6
|
+
[](https://tanstack.com/stats/npm?packageGroups=%5B%7B%22packages%22:%5B%7B%22name%22:%22ccusage%22%7D%5D%7D%5D&range=30-days&transform=none&binType=daily&showDataMode=all&height=400)
|
|
7
|
+
[](https://deepwiki.com/ryoppippi/ccusage)<!-- DeepWiki badge generated by https://deepwiki.ryoppippi.com/ -->
|
|
8
|
+
[](https://github.com/hesreallyhim/awesome-claude-code)
|
|
10
9
|
|
|
11
10
|
<div align="center">
|
|
12
11
|
<img src="https://github.com/ryoppippi/ccusage/blob/main/docs/screenshot.png?raw=true">
|
package/dist/calculate-cost.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import
|
|
1
|
+
import { DailyUsage, MonthlyUsage, SessionUsage } from "./data-loader-B0tJZeHI.js";
|
|
2
|
+
import "./pricing-fetcher-Dq-OLBp4.js";
|
|
3
3
|
|
|
4
4
|
//#region src/calculate-cost.d.ts
|
|
5
5
|
type TokenData = {
|
|
@@ -1,10 +1,83 @@
|
|
|
1
|
-
import { ArraySchema, InferOutput,
|
|
1
|
+
import { ArraySchema, InferOutput, NumberSchema, ObjectSchema, OptionalSchema, PricingFetcher, RegexAction, SchemaWithPipe, StringSchema } from "./pricing-fetcher-Dq-OLBp4.js";
|
|
2
2
|
|
|
3
|
+
//#region node_modules/type-fest/source/observable-like.d.ts
|
|
4
|
+
declare global {
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
6
|
+
interface SymbolConstructor {
|
|
7
|
+
readonly observable: symbol;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
@remarks
|
|
13
|
+
The TC39 observable proposal defines a `closed` property, but some implementations (such as xstream) do not as of 10/08/2021.
|
|
14
|
+
As well, some guidance on making an `Observable` to not include `closed` property.
|
|
15
|
+
@see https://github.com/tc39/proposal-observable/blob/master/src/Observable.js#L129-L130
|
|
16
|
+
@see https://github.com/staltz/xstream/blob/6c22580c1d84d69773ee4b0905df44ad464955b3/src/index.ts#L79-L85
|
|
17
|
+
@see https://github.com/benlesh/symbol-observable#making-an-object-observable
|
|
18
|
+
|
|
19
|
+
@category Observable
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region node_modules/type-fest/source/tuple-to-union.d.ts
|
|
24
|
+
/**
|
|
25
|
+
Convert a tuple/array into a union type of its elements.
|
|
26
|
+
|
|
27
|
+
This can be useful when you have a fixed set of allowed values and want a type defining only the allowed values, but do not want to repeat yourself.
|
|
28
|
+
|
|
29
|
+
@example
|
|
30
|
+
```
|
|
31
|
+
import type {TupleToUnion} from 'type-fest';
|
|
32
|
+
|
|
33
|
+
const destinations = ['a', 'b', 'c'] as const;
|
|
34
|
+
|
|
35
|
+
type Destination = TupleToUnion<typeof destinations>;
|
|
36
|
+
//=> 'a' | 'b' | 'c'
|
|
37
|
+
|
|
38
|
+
function verifyDestination(destination: unknown): destination is Destination {
|
|
39
|
+
return destinations.includes(destination as any);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
type RequestBody = {
|
|
43
|
+
deliverTo: Destination;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
function verifyRequestBody(body: unknown): body is RequestBody {
|
|
47
|
+
const deliverTo = (body as any).deliverTo;
|
|
48
|
+
return typeof body === 'object' && body !== null && verifyDestination(deliverTo);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Alternatively, you may use `typeof destinations[number]`. If `destinations` is a tuple, there is no difference. However if `destinations` is a string, the resulting type will the union of the characters in the string. Other types of `destinations` may result in a compile error. In comparison, TupleToUnion will return `never` if a tuple is not provided.
|
|
53
|
+
|
|
54
|
+
@example
|
|
55
|
+
```
|
|
56
|
+
const destinations = ['a', 'b', 'c'] as const;
|
|
57
|
+
|
|
58
|
+
type Destination = typeof destinations[number];
|
|
59
|
+
//=> 'a' | 'b' | 'c'
|
|
60
|
+
|
|
61
|
+
const erroringType = new Set(['a', 'b', 'c']);
|
|
62
|
+
|
|
63
|
+
type ErroringType = typeof erroringType[number];
|
|
64
|
+
//=> Type 'Set<string>' has no matching index signature for type 'number'. ts(2537)
|
|
65
|
+
|
|
66
|
+
const numberBool: { [n: number]: boolean } = { 1: true };
|
|
67
|
+
|
|
68
|
+
type NumberBool = typeof numberBool[number];
|
|
69
|
+
//=> boolean
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
@category Array
|
|
73
|
+
*/
|
|
74
|
+
type TupleToUnion<ArrayType> = ArrayType extends readonly unknown[] ? ArrayType[number] : never;
|
|
75
|
+
//#endregion
|
|
3
76
|
//#region src/types.internal.d.ts
|
|
4
77
|
declare const CostModes: readonly ["auto", "calculate", "display"];
|
|
5
|
-
type CostMode =
|
|
78
|
+
type CostMode = TupleToUnion<typeof CostModes>;
|
|
6
79
|
declare const SortOrders: readonly ["desc", "asc"];
|
|
7
|
-
type SortOrder =
|
|
80
|
+
type SortOrder = TupleToUnion<typeof SortOrders>;
|
|
8
81
|
//#endregion
|
|
9
82
|
//#region src/data-loader.d.ts
|
|
10
83
|
declare function getDefaultClaudePath(): string;
|
|
@@ -54,7 +127,7 @@ declare const MonthlyUsageSchema: ObjectSchema<{
|
|
|
54
127
|
}, undefined>;
|
|
55
128
|
type MonthlyUsage = InferOutput<typeof MonthlyUsageSchema>;
|
|
56
129
|
declare function formatDate(dateStr: string): string;
|
|
57
|
-
declare function calculateCostForEntry(data: UsageData, mode: CostMode,
|
|
130
|
+
declare function calculateCostForEntry(data: UsageData, mode: CostMode, fetcher: PricingFetcher): Promise<number>;
|
|
58
131
|
type DateFilter = {
|
|
59
132
|
since?: string;
|
|
60
133
|
until?: string;
|