@diogonzafe/tokenwatch 0.2.0 → 0.4.0

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/dist/index.d.cts CHANGED
@@ -1,8 +1,25 @@
1
- import { T as TrackerConfig, a as Tracker, b as TrackingMeta } from './index-BQZaFcHQ.cjs';
2
- export { I as IStorage, M as ModelPrice, c as ModelStats, P as PriceMap, d as PricesFile, R as Report, S as SessionStats, U as UsageEntry, e as UserStats } from './index-BQZaFcHQ.cjs';
1
+ import { T as TrackerConfig, a as Tracker, L as LazyTracker, b as TrackingMeta } from './index-CJKk1hHw.cjs';
2
+ export { B as BudgetConfig, C as CostForecast, F as FeatureStats, c as ForecastOptions, I as IStorage, M as ModelPrice, d as ModelStats, P as PriceMap, e as PricesFile, R as Report, f as ReportOptions, S as SessionStats, U as UsageEntry, g as UserStats } from './index-CJKk1hHw.cjs';
3
3
 
4
4
  declare function createTracker(config?: TrackerConfig): Tracker;
5
5
 
6
+ /**
7
+ * Creates a lazy tracker that acts as a silent no-op until `init()` is called.
8
+ *
9
+ * Ideal for module-level singletons where the tracker is imported before `createTracker()`
10
+ * can be called (e.g. Jest test environments, top-level module imports).
11
+ *
12
+ * @example
13
+ * // tracker.ts — safe to import anywhere, even before init
14
+ * export const tracker = createLazyTracker()
15
+ *
16
+ * // app.ts — initialize once at startup
17
+ * tracker.init({ storage: 'sqlite', syncPrices: true })
18
+ *
19
+ * // test.ts — never call init() and track() becomes a silent no-op
20
+ */
21
+ declare function createLazyTracker(): LazyTracker;
22
+
6
23
  interface CompletionsLike {
7
24
  create(params: Record<string, unknown>): Promise<unknown>;
8
25
  }
@@ -98,4 +115,4 @@ interface GenAILike {
98
115
  */
99
116
  declare function wrapGemini<T extends GenAILike>(client: T, tracker: Tracker): T;
100
117
 
101
- export { Tracker, TrackerConfig, TrackingMeta, createTracker, wrapAnthropic, wrapOpenAI as wrapDeepSeek, wrapGemini, wrapOpenAI };
118
+ export { LazyTracker, Tracker, TrackerConfig, TrackingMeta, createLazyTracker, createTracker, wrapAnthropic, wrapOpenAI as wrapDeepSeek, wrapGemini, wrapOpenAI };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,25 @@
1
- import { T as TrackerConfig, a as Tracker, b as TrackingMeta } from './index-BQZaFcHQ.js';
2
- export { I as IStorage, M as ModelPrice, c as ModelStats, P as PriceMap, d as PricesFile, R as Report, S as SessionStats, U as UsageEntry, e as UserStats } from './index-BQZaFcHQ.js';
1
+ import { T as TrackerConfig, a as Tracker, L as LazyTracker, b as TrackingMeta } from './index-CJKk1hHw.js';
2
+ export { B as BudgetConfig, C as CostForecast, F as FeatureStats, c as ForecastOptions, I as IStorage, M as ModelPrice, d as ModelStats, P as PriceMap, e as PricesFile, R as Report, f as ReportOptions, S as SessionStats, U as UsageEntry, g as UserStats } from './index-CJKk1hHw.js';
3
3
 
4
4
  declare function createTracker(config?: TrackerConfig): Tracker;
5
5
 
6
+ /**
7
+ * Creates a lazy tracker that acts as a silent no-op until `init()` is called.
8
+ *
9
+ * Ideal for module-level singletons where the tracker is imported before `createTracker()`
10
+ * can be called (e.g. Jest test environments, top-level module imports).
11
+ *
12
+ * @example
13
+ * // tracker.ts — safe to import anywhere, even before init
14
+ * export const tracker = createLazyTracker()
15
+ *
16
+ * // app.ts — initialize once at startup
17
+ * tracker.init({ storage: 'sqlite', syncPrices: true })
18
+ *
19
+ * // test.ts — never call init() and track() becomes a silent no-op
20
+ */
21
+ declare function createLazyTracker(): LazyTracker;
22
+
6
23
  interface CompletionsLike {
7
24
  create(params: Record<string, unknown>): Promise<unknown>;
8
25
  }
@@ -98,4 +115,4 @@ interface GenAILike {
98
115
  */
99
116
  declare function wrapGemini<T extends GenAILike>(client: T, tracker: Tracker): T;
100
117
 
101
- export { Tracker, TrackerConfig, TrackingMeta, createTracker, wrapAnthropic, wrapOpenAI as wrapDeepSeek, wrapGemini, wrapOpenAI };
118
+ export { LazyTracker, Tracker, TrackerConfig, TrackingMeta, createLazyTracker, createTracker, wrapAnthropic, wrapOpenAI as wrapDeepSeek, wrapGemini, wrapOpenAI };