@shaxpir/duiduidui-models 1.5.8 → 1.5.10

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.
@@ -32,7 +32,12 @@ export interface StarredCondition extends BaseCondition {
32
32
  type: 'starred';
33
33
  value: boolean;
34
34
  }
35
- export type AnyCondition = TagCondition | GradeCondition | ThetaCondition | TemporalCondition | CountCondition | StarredCondition;
35
+ export interface DifficultyCondition extends BaseCondition {
36
+ type: 'difficulty';
37
+ min?: number;
38
+ max?: number;
39
+ }
40
+ export type AnyCondition = TagCondition | GradeCondition | ThetaCondition | TemporalCondition | CountCondition | StarredCondition | DifficultyCondition;
36
41
  export interface ConditionFilters {
37
42
  all?: AnyCondition[];
38
43
  any?: AnyCondition[];
@@ -61,4 +66,10 @@ export declare const Condition: {
61
66
  wellPracticed: (minReviews?: number) => CountCondition;
62
67
  starred: () => StarredCondition;
63
68
  notStarred: () => StarredCondition;
69
+ difficulty: (min?: number, max?: number) => DifficultyCondition;
70
+ beginner: () => DifficultyCondition;
71
+ elementary: () => DifficultyCondition;
72
+ intermediate: () => DifficultyCondition;
73
+ advanced: () => DifficultyCondition;
74
+ expert: () => DifficultyCondition;
64
75
  };
@@ -30,5 +30,12 @@ exports.Condition = {
30
30
  wellPracticed: (minReviews = 10) => ({ type: 'count', field: 'review_count', operator: '>', value: minReviews }),
31
31
  // Starred condition
32
32
  starred: () => ({ type: 'starred', value: true }),
33
- notStarred: () => ({ type: 'starred', value: false })
33
+ notStarred: () => ({ type: 'starred', value: false }),
34
+ // Difficulty conditions
35
+ difficulty: (min, max) => ({ type: 'difficulty', min, max }),
36
+ beginner: () => ({ type: 'difficulty', max: 100 }), // Very easy content
37
+ elementary: () => ({ type: 'difficulty', min: 100, max: 500 }), // Easy
38
+ intermediate: () => ({ type: 'difficulty', min: 500, max: 1500 }), // Medium
39
+ advanced: () => ({ type: 'difficulty', min: 1500, max: 3000 }), // Hard
40
+ expert: () => ({ type: 'difficulty', min: 3000 }) // Very hard
34
41
  };
@@ -18,6 +18,7 @@ export interface TermSummary {
18
18
  review_count: number;
19
19
  implied_review_count: number;
20
20
  last_review_utc: CompactDateTime;
21
+ tag_count: number;
21
22
  }
22
23
  export interface TermPayload extends BayesianScore {
23
24
  text: string;
@@ -30,6 +31,7 @@ export interface TermPayload extends BayesianScore {
30
31
  theta: number;
31
32
  uncertainty: number;
32
33
  tags: string[];
34
+ tag_count: number;
33
35
  reviews: ReviewLike[];
34
36
  review_count: number;
35
37
  last_review_utc: CompactDateTime;
@@ -68,6 +70,8 @@ export declare class Term extends Content {
68
70
  get uncertainty(): number;
69
71
  get starredAt(): CompactDateTime | null;
70
72
  get tags(): string[];
73
+ get tagCount(): number;
74
+ private _updateTagCount;
71
75
  addTag(value: string): void;
72
76
  removeTag(value: string): void;
73
77
  get lastReviewUtc(): CompactDateTime | null;
@@ -66,6 +66,7 @@ class Term extends Content_1.Content {
66
66
  examples: phrase.examples,
67
67
  keywords: phrase.keywords,
68
68
  tags: phrase.tags,
69
+ tag_count: phrase.tags.length,
69
70
  starred_at: null,
70
71
  alpha: 0.5,
71
72
  beta: 0.5,
@@ -98,6 +99,7 @@ class Term extends Content_1.Content {
98
99
  phrase_id: phrase.id,
99
100
  starred_at: null,
100
101
  tags: [],
102
+ tag_count: 0,
101
103
  alpha: 0.5,
102
104
  beta: 0.5,
103
105
  theta: 0.5,
@@ -150,11 +152,24 @@ class Term extends Content_1.Content {
150
152
  this.checkDisposed("Term.tags");
151
153
  return this._tagsView.values;
152
154
  }
155
+ get tagCount() {
156
+ this.checkDisposed("Term.tagCount");
157
+ return this.payload.tag_count;
158
+ }
159
+ _updateTagCount() {
160
+ const newCount = this._tagsView.length;
161
+ if (this.payload.tag_count !== newCount) {
162
+ const batch = new Operation_1.BatchOperation(this);
163
+ batch.setPathValue(['payload', 'tag_count'], newCount);
164
+ batch.commit();
165
+ }
166
+ }
153
167
  addTag(value) {
154
168
  this.checkDisposed("Term.addTag");
155
169
  const index = this._tagsView.indexOf(value);
156
170
  if (index === -1) {
157
171
  this._tagsView.push(value);
172
+ this._updateTagCount();
158
173
  }
159
174
  }
160
175
  removeTag(value) {
@@ -162,6 +177,7 @@ class Term extends Content_1.Content {
162
177
  const index = this._tagsView.indexOf(value);
163
178
  if (index !== -1) {
164
179
  this._tagsView.removeAt(index);
180
+ this._updateTagCount();
165
181
  }
166
182
  }
167
183
  get lastReviewUtc() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shaxpir/duiduidui-models",
3
- "version": "1.5.8",
3
+ "version": "1.5.10",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/shaxpir/duiduidui-models"