@mulingai-npm/redis 3.38.10 → 3.38.12

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.
@@ -69,8 +69,4 @@ export declare class DemoRoomPoolManager {
69
69
  * Increment IP rate limit counter with 24h TTL.
70
70
  */
71
71
  incrementIpRateLimit(ipHash: string): Promise<void>;
72
- /**
73
- * Get demo chunks for export.
74
- */
75
- getDemoChunks(demoSessionId: string): Promise<string[]>;
76
72
  }
@@ -169,12 +169,5 @@ class DemoRoomPoolManager {
169
169
  await this.redisClient.incr(key);
170
170
  await this.redisClient.expire(key, 86400);
171
171
  }
172
- /**
173
- * Get demo chunks for export.
174
- */
175
- async getDemoChunks(demoSessionId) {
176
- const key = `demo:session:${demoSessionId}:chunks`;
177
- return await this.redisClient.lrange(key, 0, -1);
178
- }
179
172
  }
180
173
  exports.DemoRoomPoolManager = DemoRoomPoolManager;
@@ -7,6 +7,8 @@ export interface PendingUsageData {
7
7
  billingMs: number;
8
8
  roomDurations: Record<string, number>;
9
9
  lastUpdated: number;
10
+ paygCreditsUsed: number;
11
+ planCreditsUsed: number;
10
12
  }
11
13
  /**
12
14
  * Usage Data Manager
@@ -36,6 +38,11 @@ export declare class UsageDataManager {
36
38
  * Called by pipeline-service every 5 seconds during streaming
37
39
  */
38
40
  addUsage(userId: string, roomId: string, durationMs: number): Promise<void>;
41
+ /**
42
+ * Update credit split tracking (plan vs PAYG) — called every 5 seconds alongside addUsage
43
+ * These are cumulative totals for the current session (not deltas)
44
+ */
45
+ updateCreditSplit(userId: string, planCreditsUsed: number, paygCreditsUsed: number): Promise<void>;
39
46
  /**
40
47
  * Get all users with pending usage
41
48
  */
@@ -47,6 +47,17 @@ class UsageDataManager {
47
47
  await this.redisClient.sadd(this.usersSetKey(), userId);
48
48
  await this.redisClient.expire(this.usersSetKey(), this.EXPIRATION);
49
49
  }
50
+ /**
51
+ * Update credit split tracking (plan vs PAYG) — called every 5 seconds alongside addUsage
52
+ * These are cumulative totals for the current session (not deltas)
53
+ */
54
+ async updateCreditSplit(userId, planCreditsUsed, paygCreditsUsed) {
55
+ const key = this.userKey(userId);
56
+ await this.redisClient.hset(key, {
57
+ planCreditsUsed: planCreditsUsed.toFixed(4),
58
+ paygCreditsUsed: paygCreditsUsed.toFixed(4)
59
+ });
60
+ }
50
61
  /**
51
62
  * Get all users with pending usage
52
63
  */
@@ -65,6 +76,8 @@ class UsageDataManager {
65
76
  }
66
77
  const billingMs = parseInt(data.billingMs || '0', 10);
67
78
  const lastUpdated = parseInt(data.lastUpdated || '0', 10);
79
+ const planCreditsUsed = parseFloat(data.planCreditsUsed || '0');
80
+ const paygCreditsUsed = parseFloat(data.paygCreditsUsed || '0');
68
81
  // Extract room durations (keys starting with "room:")
69
82
  const roomDurations = {};
70
83
  for (const [field, value] of Object.entries(data)) {
@@ -77,7 +90,9 @@ class UsageDataManager {
77
90
  userId,
78
91
  billingMs,
79
92
  roomDurations,
80
- lastUpdated
93
+ lastUpdated,
94
+ planCreditsUsed,
95
+ paygCreditsUsed
81
96
  };
82
97
  }
83
98
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mulingai-npm/redis",
3
- "version": "3.38.10",
3
+ "version": "3.38.12",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {