ccusage 0.3.2 → 0.4.1
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 +29 -0
- package/dist/calculate-cost.d.ts +1 -17
- package/dist/{data-loader-D64xoJ7s.js → data-loader-BBdPk24U.js} +1268 -140
- package/dist/{data-loader-ToqWI8hT.d.ts → data-loader-D1LHcGfa.d.ts} +98 -2
- package/dist/data-loader.d.ts +2 -2
- package/dist/data-loader.js +2 -2
- package/dist/index.js +385 -1184
- package/package.json +1 -1
|
@@ -929,6 +929,71 @@ type PipeItemAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseSch
|
|
|
929
929
|
* Schema without pipe type.
|
|
930
930
|
*/
|
|
931
931
|
|
|
932
|
+
/**
|
|
933
|
+
* Array issue interface.
|
|
934
|
+
*/
|
|
935
|
+
interface ArrayIssue extends BaseIssue<unknown> {
|
|
936
|
+
/**
|
|
937
|
+
* The issue kind.
|
|
938
|
+
*/
|
|
939
|
+
readonly kind: 'schema';
|
|
940
|
+
/**
|
|
941
|
+
* The issue type.
|
|
942
|
+
*/
|
|
943
|
+
readonly type: 'array';
|
|
944
|
+
/**
|
|
945
|
+
* The expected property.
|
|
946
|
+
*/
|
|
947
|
+
readonly expected: 'Array';
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
/**
|
|
951
|
+
* Array schema interface.
|
|
952
|
+
*/
|
|
953
|
+
interface ArraySchema<TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, TMessage extends ErrorMessage<ArrayIssue> | undefined> extends BaseSchema<InferInput<TItem>[], InferOutput<TItem>[], ArrayIssue | InferIssue<TItem>> {
|
|
954
|
+
/**
|
|
955
|
+
* The schema type.
|
|
956
|
+
*/
|
|
957
|
+
readonly type: 'array';
|
|
958
|
+
/**
|
|
959
|
+
* The schema reference.
|
|
960
|
+
*/
|
|
961
|
+
readonly reference: typeof array;
|
|
962
|
+
/**
|
|
963
|
+
* The expected property.
|
|
964
|
+
*/
|
|
965
|
+
readonly expects: 'Array';
|
|
966
|
+
/**
|
|
967
|
+
* The array item schema.
|
|
968
|
+
*/
|
|
969
|
+
readonly item: TItem;
|
|
970
|
+
/**
|
|
971
|
+
* The error message.
|
|
972
|
+
*/
|
|
973
|
+
readonly message: TMessage;
|
|
974
|
+
}
|
|
975
|
+
/**
|
|
976
|
+
* Creates an array schema.
|
|
977
|
+
*
|
|
978
|
+
* @param item The item schema.
|
|
979
|
+
*
|
|
980
|
+
* @returns An array schema.
|
|
981
|
+
*/
|
|
982
|
+
declare function array<const TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>>>(item: TItem): ArraySchema<TItem, undefined>;
|
|
983
|
+
/**
|
|
984
|
+
* Creates an array schema.
|
|
985
|
+
*
|
|
986
|
+
* @param item The item schema.
|
|
987
|
+
* @param message The error message.
|
|
988
|
+
*
|
|
989
|
+
* @returns An array schema.
|
|
990
|
+
*/
|
|
991
|
+
declare function array<const TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, const TMessage extends ErrorMessage<ArrayIssue> | undefined>(item: TItem, message: TMessage): ArraySchema<TItem, TMessage>;
|
|
992
|
+
|
|
993
|
+
/**
|
|
994
|
+
* Array schema interface.
|
|
995
|
+
*/
|
|
996
|
+
|
|
932
997
|
/**
|
|
933
998
|
* Exact optional schema interface.
|
|
934
999
|
*/
|
|
@@ -1418,10 +1483,37 @@ declare function readonly<TInput>(): ReadonlyAction<TInput>;
|
|
|
1418
1483
|
* Array action type.
|
|
1419
1484
|
*/
|
|
1420
1485
|
//#endregion
|
|
1486
|
+
//#region pricing-fetcher.d.ts
|
|
1487
|
+
declare const ModelPricingSchema: ObjectSchema<{
|
|
1488
|
+
readonly input_cost_per_token: OptionalSchema<NumberSchema<undefined>, undefined>;
|
|
1489
|
+
readonly output_cost_per_token: OptionalSchema<NumberSchema<undefined>, undefined>;
|
|
1490
|
+
readonly cache_creation_input_token_cost: OptionalSchema<NumberSchema<undefined>, undefined>;
|
|
1491
|
+
readonly cache_read_input_token_cost: OptionalSchema<NumberSchema<undefined>, undefined>;
|
|
1492
|
+
}, undefined>;
|
|
1493
|
+
type ModelPricing = InferOutput<typeof ModelPricingSchema>;
|
|
1494
|
+
//#endregion
|
|
1495
|
+
//#region types.d.ts
|
|
1496
|
+
interface TokenTotals {
|
|
1497
|
+
inputTokens: number;
|
|
1498
|
+
outputTokens: number;
|
|
1499
|
+
cacheCreationTokens: number;
|
|
1500
|
+
cacheReadTokens: number;
|
|
1501
|
+
totalCost: number;
|
|
1502
|
+
}
|
|
1503
|
+
interface TokenData {
|
|
1504
|
+
inputTokens: number;
|
|
1505
|
+
outputTokens: number;
|
|
1506
|
+
cacheCreationTokens: number;
|
|
1507
|
+
cacheReadTokens: number;
|
|
1508
|
+
}
|
|
1509
|
+
declare const CostModes: readonly ["auto", "calculate", "display"];
|
|
1510
|
+
type CostMode = (typeof CostModes)[number];
|
|
1511
|
+
//#endregion
|
|
1421
1512
|
//#region data-loader.d.ts
|
|
1422
1513
|
declare const getDefaultClaudePath: () => string;
|
|
1423
1514
|
declare const UsageDataSchema: ObjectSchema<{
|
|
1424
1515
|
readonly timestamp: StringSchema<undefined>;
|
|
1516
|
+
readonly version: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
1425
1517
|
readonly message: ObjectSchema<{
|
|
1426
1518
|
readonly usage: ObjectSchema<{
|
|
1427
1519
|
readonly input_tokens: NumberSchema<undefined>;
|
|
@@ -1429,8 +1521,9 @@ declare const UsageDataSchema: ObjectSchema<{
|
|
|
1429
1521
|
readonly cache_creation_input_tokens: OptionalSchema<NumberSchema<undefined>, undefined>;
|
|
1430
1522
|
readonly cache_read_input_tokens: OptionalSchema<NumberSchema<undefined>, undefined>;
|
|
1431
1523
|
}, undefined>;
|
|
1524
|
+
readonly model: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
1432
1525
|
}, undefined>;
|
|
1433
|
-
readonly costUSD: NumberSchema<undefined>;
|
|
1526
|
+
readonly costUSD: OptionalSchema<NumberSchema<undefined>, undefined>;
|
|
1434
1527
|
}, undefined>;
|
|
1435
1528
|
type UsageData = InferOutput<typeof UsageDataSchema>;
|
|
1436
1529
|
declare const DailyUsageSchema: ObjectSchema<{
|
|
@@ -1451,17 +1544,20 @@ declare const SessionUsageSchema: ObjectSchema<{
|
|
|
1451
1544
|
readonly cacheReadTokens: NumberSchema<undefined>;
|
|
1452
1545
|
readonly totalCost: NumberSchema<undefined>;
|
|
1453
1546
|
readonly lastActivity: StringSchema<undefined>;
|
|
1547
|
+
readonly versions: ArraySchema<StringSchema<undefined>, undefined>;
|
|
1454
1548
|
}, undefined>;
|
|
1455
1549
|
type SessionUsage = InferOutput<typeof SessionUsageSchema>;
|
|
1456
1550
|
declare const formatDate: (dateStr: string) => string;
|
|
1551
|
+
declare const calculateCostForEntry: (data: UsageData, mode: CostMode, modelPricing: Record<string, ModelPricing>) => number;
|
|
1457
1552
|
interface DateFilter {
|
|
1458
1553
|
since?: string;
|
|
1459
1554
|
until?: string;
|
|
1460
1555
|
}
|
|
1461
1556
|
interface LoadOptions extends DateFilter {
|
|
1462
1557
|
claudePath?: string;
|
|
1558
|
+
mode?: CostMode;
|
|
1463
1559
|
}
|
|
1464
1560
|
declare function loadUsageData(options?: LoadOptions): Promise<DailyUsage[]>;
|
|
1465
1561
|
declare function loadSessionData(options?: LoadOptions): Promise<SessionUsage[]>;
|
|
1466
1562
|
//#endregion
|
|
1467
|
-
export { DailyUsage, DailyUsageSchema as DailyUsageSchema$1, DateFilter, LoadOptions, SessionUsage, SessionUsageSchema as SessionUsageSchema$1, UsageData, UsageDataSchema as UsageDataSchema$1, formatDate as formatDate$1, getDefaultClaudePath as getDefaultClaudePath$1, loadSessionData as loadSessionData$1, loadUsageData as loadUsageData$1 };
|
|
1563
|
+
export { DailyUsage, DailyUsageSchema as DailyUsageSchema$1, DateFilter, LoadOptions, SessionUsage, SessionUsageSchema as SessionUsageSchema$1, TokenData, TokenTotals, UsageData, UsageDataSchema as UsageDataSchema$1, calculateCostForEntry as calculateCostForEntry$1, formatDate as formatDate$1, getDefaultClaudePath as getDefaultClaudePath$1, loadSessionData as loadSessionData$1, loadUsageData as loadUsageData$1 };
|
package/dist/data-loader.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DailyUsage, DailyUsageSchema$1 as DailyUsageSchema, DateFilter, LoadOptions, SessionUsage, SessionUsageSchema$1 as SessionUsageSchema, UsageData, UsageDataSchema$1 as UsageDataSchema, formatDate$1 as formatDate, getDefaultClaudePath$1 as getDefaultClaudePath, loadSessionData$1 as loadSessionData, loadUsageData$1 as loadUsageData } from "./data-loader-
|
|
2
|
-
export { DailyUsage, DailyUsageSchema, DateFilter, LoadOptions, SessionUsage, SessionUsageSchema, UsageData, UsageDataSchema, formatDate, getDefaultClaudePath, loadSessionData, loadUsageData };
|
|
1
|
+
import { DailyUsage, DailyUsageSchema$1 as DailyUsageSchema, DateFilter, LoadOptions, SessionUsage, SessionUsageSchema$1 as SessionUsageSchema, UsageData, UsageDataSchema$1 as UsageDataSchema, calculateCostForEntry$1 as calculateCostForEntry, formatDate$1 as formatDate, getDefaultClaudePath$1 as getDefaultClaudePath, loadSessionData$1 as loadSessionData, loadUsageData$1 as loadUsageData } from "./data-loader-D1LHcGfa.js";
|
|
2
|
+
export { DailyUsage, DailyUsageSchema, DateFilter, LoadOptions, SessionUsage, SessionUsageSchema, UsageData, UsageDataSchema, calculateCostForEntry, formatDate, getDefaultClaudePath, loadSessionData, loadUsageData };
|
package/dist/data-loader.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { DailyUsageSchema, SessionUsageSchema, UsageDataSchema, formatDate, getDefaultClaudePath, loadSessionData, loadUsageData } from "./data-loader-
|
|
1
|
+
import { DailyUsageSchema, SessionUsageSchema, UsageDataSchema, calculateCostForEntry, formatDate, getDefaultClaudePath, loadSessionData, loadUsageData } from "./data-loader-BBdPk24U.js";
|
|
2
2
|
|
|
3
|
-
export { DailyUsageSchema, SessionUsageSchema, UsageDataSchema, formatDate, getDefaultClaudePath, loadSessionData, loadUsageData };
|
|
3
|
+
export { DailyUsageSchema, SessionUsageSchema, UsageDataSchema, calculateCostForEntry, formatDate, getDefaultClaudePath, loadSessionData, loadUsageData };
|