@shaxpir/duiduidui-models 1.5.11 → 1.5.13

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.
@@ -37,4 +37,5 @@ export interface AnnotatedPhrase extends Phrase {
37
37
  theta: number;
38
38
  uncertainty: number;
39
39
  reviews: ReviewLike[];
40
+ user_tags: string[];
40
41
  }
@@ -18,7 +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
+ user_tag_count: number;
22
22
  }
23
23
  export interface TermPayload extends BayesianScore {
24
24
  text: string;
@@ -30,8 +30,8 @@ export interface TermPayload extends BayesianScore {
30
30
  beta: number;
31
31
  theta: number;
32
32
  uncertainty: number;
33
- tags: string[];
34
- tag_count: number;
33
+ user_tags: string[];
34
+ user_tag_count: number;
35
35
  reviews: ReviewLike[];
36
36
  review_count: number;
37
37
  last_review_utc: CompactDateTime;
@@ -55,7 +55,7 @@ export declare class Term extends Content {
55
55
  static makeTermId(userId: ContentId, text: string, senseRank: number): ContentId;
56
56
  private _reviewsView;
57
57
  private _impliedReviewsView;
58
- private _tagsView;
58
+ private _userTagsView;
59
59
  constructor(doc: Doc, shouldAcquire: boolean, shareSync: ShareSync);
60
60
  static forUserPhrase(userId: ContentId, text: string, senseRank: number, difficulty: number, phraseId?: number): Term;
61
61
  static forUserPhrase(userId: ContentId, phrase: Phrase): Term;
@@ -69,11 +69,11 @@ export declare class Term extends Content {
69
69
  get theta(): number;
70
70
  get uncertainty(): number;
71
71
  get starredAt(): CompactDateTime | null;
72
- get tags(): string[];
73
- get tagCount(): number;
72
+ get userTags(): string[];
73
+ get userTagCount(): number;
74
74
  private _updateTagCount;
75
- addTag(value: string): void;
76
- removeTag(value: string): void;
75
+ addUserTag(value: string): void;
76
+ removeUserTag(value: string): void;
77
77
  get lastReviewUtc(): CompactDateTime | null;
78
78
  setStarredAt(value: CompactDateTime | null): void;
79
79
  updateBayesianScore(alpha: number, beta: number, theta: number): void;
@@ -16,7 +16,7 @@ class Term extends Content_1.Content {
16
16
  super(doc, shouldAcquire, shareSync);
17
17
  this._reviewsView = new ArrayView_1.ArrayView(this, ['payload', 'reviews']);
18
18
  this._impliedReviewsView = new ArrayView_1.ArrayView(this, ['payload', 'implied_reviews']);
19
- this._tagsView = new ArrayView_1.ArrayView(this, ['payload', 'tags']);
19
+ this._userTagsView = new ArrayView_1.ArrayView(this, ['payload', 'user_tags']);
20
20
  }
21
21
  static forUserPhrase(userId, textOrPhrase, senseRank, difficulty, phraseId) {
22
22
  const now = shaxpir_common_1.ClockService.getClock().now();
@@ -65,8 +65,8 @@ class Term extends Content_1.Content {
65
65
  notes: phrase.notes,
66
66
  examples: phrase.examples,
67
67
  keywords: phrase.keywords,
68
- tags: phrase.tags,
69
- tag_count: phrase.tags.length,
68
+ user_tags: phrase.tags || [],
69
+ user_tag_count: (phrase.tags || []).length,
70
70
  starred_at: null,
71
71
  alpha: 0.5,
72
72
  beta: 0.5,
@@ -98,8 +98,8 @@ class Term extends Content_1.Content {
98
98
  difficulty: phrase.difficulty,
99
99
  phrase_id: phrase.id,
100
100
  starred_at: null,
101
- tags: [],
102
- tag_count: 0,
101
+ user_tags: [],
102
+ user_tag_count: 0,
103
103
  alpha: 0.5,
104
104
  beta: 0.5,
105
105
  theta: 0.5,
@@ -148,36 +148,50 @@ class Term extends Content_1.Content {
148
148
  this.checkDisposed("Term.starredAt");
149
149
  return this.payload.starred_at;
150
150
  }
151
- get tags() {
152
- this.checkDisposed("Term.tags");
153
- return this._tagsView.values;
151
+ get userTags() {
152
+ this.checkDisposed("Term.userTags");
153
+ return this._userTagsView.values;
154
154
  }
155
- get tagCount() {
156
- this.checkDisposed("Term.tagCount");
157
- return this.payload.tag_count;
155
+ get userTagCount() {
156
+ this.checkDisposed("Term.userTagCount");
157
+ return this.payload.user_tag_count;
158
158
  }
159
159
  _updateTagCount() {
160
- const newCount = this._tagsView.length;
161
- if (this.payload.tag_count !== newCount) {
160
+ const newCount = this._userTagsView.length;
161
+ if (this.payload.user_tag_count !== newCount) {
162
162
  const batch = new Operation_1.BatchOperation(this);
163
- batch.setPathValue(['payload', 'tag_count'], newCount);
163
+ batch.setPathValue(['payload', 'user_tag_count'], newCount);
164
164
  batch.commit();
165
165
  }
166
166
  }
167
- addTag(value) {
168
- this.checkDisposed("Term.addTag");
169
- const index = this._tagsView.indexOf(value);
167
+ addUserTag(value) {
168
+ this.checkDisposed("Term.addUserTag");
169
+ console.log('[Term.addUserTag] Adding tag:', value);
170
+ console.log('[Term.addUserTag] Current tags:', this._userTagsView.values);
171
+ const index = this._userTagsView.indexOf(value);
170
172
  if (index === -1) {
171
- this._tagsView.push(value);
173
+ this._userTagsView.push(value);
172
174
  this._updateTagCount();
175
+ console.log('[Term.addUserTag] Tag added, new tags:', this._userTagsView.values);
176
+ console.log('[Term.addUserTag] Document data after add:', JSON.stringify(this.doc.data.payload.user_tags));
177
+ }
178
+ else {
179
+ console.log('[Term.addUserTag] Tag already exists, skipping');
173
180
  }
174
181
  }
175
- removeTag(value) {
176
- this.checkDisposed("Term.removeTag");
177
- const index = this._tagsView.indexOf(value);
182
+ removeUserTag(value) {
183
+ this.checkDisposed("Term.removeUserTag");
184
+ console.log('[Term.removeUserTag] Removing tag:', value);
185
+ console.log('[Term.removeUserTag] Current tags:', this._userTagsView.values);
186
+ const index = this._userTagsView.indexOf(value);
178
187
  if (index !== -1) {
179
- this._tagsView.removeAt(index);
188
+ this._userTagsView.removeAt(index);
180
189
  this._updateTagCount();
190
+ console.log('[Term.removeUserTag] Tag removed, new tags:', this._userTagsView.values);
191
+ console.log('[Term.removeUserTag] Document data after remove:', JSON.stringify(this.doc.data.payload.user_tags));
192
+ }
193
+ else {
194
+ console.log('[Term.removeUserTag] Tag not found, skipping');
181
195
  }
182
196
  }
183
197
  get lastReviewUtc() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shaxpir/duiduidui-models",
3
- "version": "1.5.11",
3
+ "version": "1.5.13",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/shaxpir/duiduidui-models"