@shaxpir/duiduidui-models 1.36.1 → 1.36.3

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.
@@ -44,6 +44,7 @@ export interface BillingPayload {
44
44
  grant_note: string | null;
45
45
  feature_grants: Record<string, FeatureGrant>;
46
46
  redeemed_codes: string[];
47
+ usage_ceilings: Record<string, number>;
47
48
  transactions: Transaction[];
48
49
  }
49
50
  export interface BillingBody extends ContentBody {
@@ -62,6 +63,8 @@ export declare class Billing extends Content {
62
63
  get featureGrants(): Record<string, FeatureGrant>;
63
64
  get redeemedCodes(): string[];
64
65
  get transactions(): Transaction[];
66
+ get usageCeilings(): Record<string, number>;
67
+ getUsageCeiling(usageName: string): number;
65
68
  isActive(): boolean;
66
69
  isTrialing(): boolean;
67
70
  isLifetimeFree(): boolean;
@@ -24,6 +24,7 @@ class Billing extends Content_1.Content {
24
24
  grant_note: null,
25
25
  feature_grants: {},
26
26
  redeemed_codes: [],
27
+ usage_ceilings: {},
27
28
  transactions: []
28
29
  };
29
30
  }
@@ -69,6 +70,12 @@ class Billing extends Content_1.Content {
69
70
  get transactions() {
70
71
  return this.payload.transactions ?? [];
71
72
  }
73
+ get usageCeilings() {
74
+ return this.payload.usage_ceilings ?? {};
75
+ }
76
+ getUsageCeiling(usageName) {
77
+ return this.usageCeilings[usageName] ?? 0;
78
+ }
72
79
  isActive() {
73
80
  const status = this.subscriptionStatus;
74
81
  return status === 'active' || status === 'trialing' || status === 'grace_period';
@@ -37,6 +37,7 @@ export interface CollectionPayload {
37
37
  term_scores: {
38
38
  [termKey: string]: number;
39
39
  };
40
+ engagement_score: number;
40
41
  total_cards: number;
41
42
  last_activity_utc: CompactDateTime | null;
42
43
  is_visible: boolean;
@@ -96,6 +97,12 @@ export declare class Collection extends Content {
96
97
  get termScores(): {
97
98
  [termKey: string]: number;
98
99
  };
100
+ /**
101
+ * Cached sum of all term_scores values. Maintained incrementally by
102
+ * setTermScore() and removeTermScore() so that engagement-based sorting
103
+ * doesn't need to iterate the full map.
104
+ */
105
+ get engagementScore(): number;
99
106
  /**
100
107
  * Get the number of unique terms the user has reviewed in this collection.
101
108
  */
@@ -59,6 +59,7 @@ class Collection extends Content_1.Content {
59
59
  proficiency: SkillLevel_1.SkillLevelModel.createDefault(),
60
60
  // Empty term scores map - populated as user reviews cards
61
61
  term_scores: {},
62
+ engagement_score: 0,
62
63
  // Progress starts at zero
63
64
  total_cards: 0,
64
65
  last_activity_utc: null,
@@ -141,6 +142,15 @@ class Collection extends Content_1.Content {
141
142
  this.checkDisposed("Collection.termScores");
142
143
  return this.payload.term_scores;
143
144
  }
145
+ /**
146
+ * Cached sum of all term_scores values. Maintained incrementally by
147
+ * setTermScore() and removeTermScore() so that engagement-based sorting
148
+ * doesn't need to iterate the full map.
149
+ */
150
+ get engagementScore() {
151
+ this.checkDisposed("Collection.engagementScore");
152
+ return this.payload.engagement_score ?? 0;
153
+ }
144
154
  /**
145
155
  * Get the number of unique terms the user has reviewed in this collection.
146
156
  */
@@ -274,8 +284,11 @@ class Collection extends Content_1.Content {
274
284
  setTermScore(text, senseRank, theta) {
275
285
  this.checkDisposed("Collection.setTermScore");
276
286
  const termKey = Collection.encodeTermKey(text, senseRank);
287
+ const prevTheta = this.payload.term_scores[termKey] ?? 0;
288
+ const prevEngagement = this.payload.engagement_score ?? 0;
277
289
  const batch = new Operation_1.BatchOperation(this);
278
290
  batch.setPathValue(['payload', 'term_scores', termKey], theta);
291
+ batch.setPathValue(['payload', 'engagement_score'], prevEngagement - prevTheta + theta);
279
292
  batch.commit();
280
293
  }
281
294
  /**
@@ -284,9 +297,12 @@ class Collection extends Content_1.Content {
284
297
  removeTermScore(text, senseRank) {
285
298
  this.checkDisposed("Collection.removeTermScore");
286
299
  const termKey = Collection.encodeTermKey(text, senseRank);
287
- if (this.payload.term_scores[termKey] !== undefined) {
300
+ const prevTheta = this.payload.term_scores[termKey];
301
+ if (prevTheta !== undefined) {
302
+ const prevEngagement = this.payload.engagement_score ?? 0;
288
303
  const batch = new Operation_1.BatchOperation(this);
289
304
  batch.removeValueAtPath(['payload', 'term_scores', termKey]);
305
+ batch.setPathValue(['payload', 'engagement_score'], prevEngagement - prevTheta);
290
306
  batch.commit();
291
307
  }
292
308
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shaxpir/duiduidui-models",
3
- "version": "1.36.1",
3
+ "version": "1.36.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/shaxpir/duiduidui-models"