@shaxpir/duiduidui-models 1.5.10 → 1.5.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.
@@ -6,18 +6,27 @@ import { ConditionFilters } from './Condition';
6
6
  export interface LastSync {
7
7
  at_utc_time: CompactDateTime | null;
8
8
  }
9
+ export interface AudioDownloadQueueItem {
10
+ text: string;
11
+ added_at: CompactDateTime;
12
+ retry_count: number;
13
+ next_retry_at?: CompactDateTime;
14
+ last_error?: string;
15
+ }
9
16
  export interface DevicePayload {
10
17
  last_sync?: LastSync;
11
18
  chinese_font?: string;
12
19
  raw_search_text?: string;
13
20
  star_filter?: boolean;
14
21
  conditions?: ConditionFilters;
22
+ audio_download_queue?: AudioDownloadQueueItem[];
15
23
  }
16
24
  export interface DeviceBody extends ContentBody {
17
25
  meta: ContentMeta;
18
26
  payload: DevicePayload;
19
27
  }
20
28
  export declare class Device extends Content {
29
+ private _audioDownloadQueueView;
21
30
  static create(userId: ContentId, deviceId: ContentId): Device;
22
31
  constructor(doc: Doc, shouldAcquire: boolean, shareSync: ShareSync);
23
32
  get payload(): DevicePayload;
@@ -25,4 +34,9 @@ export declare class Device extends Content {
25
34
  setLastSyncAtUtcTime(value: CompactDateTime): void;
26
35
  get chineseFont(): string;
27
36
  setChineseFont(value: string): void;
37
+ get audioDownloadQueue(): AudioDownloadQueueItem[];
38
+ get audioDownloadQueueLength(): number;
39
+ addToAudioDownloadQueue(text: string): void;
40
+ removeFromAudioDownloadQueue(text: string): void;
41
+ updateAudioDownloadQueueItem(text: string, updates: Partial<AudioDownloadQueueItem>): void;
28
42
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Device = void 0;
4
4
  const shaxpir_common_1 = require("@shaxpir/shaxpir-common");
5
5
  const repo_1 = require("../repo");
6
+ const ArrayView_1 = require("./ArrayView");
6
7
  const Content_1 = require("./Content");
7
8
  const ContentKind_1 = require("./ContentKind");
8
9
  const Operation_1 = require("./Operation");
@@ -19,12 +20,14 @@ class Device extends Content_1.Content {
19
20
  updated_at: now
20
21
  },
21
22
  payload: {
22
- last_sync: { at_utc_time: null }
23
+ last_sync: { at_utc_time: null },
24
+ audio_download_queue: []
23
25
  }
24
26
  });
25
27
  }
26
28
  constructor(doc, shouldAcquire, shareSync) {
27
29
  super(doc, shouldAcquire, shareSync);
30
+ this._audioDownloadQueueView = new ArrayView_1.ArrayView(this, ['payload', 'audio_download_queue']);
28
31
  }
29
32
  get payload() {
30
33
  this.checkDisposed("Device.payload");
@@ -54,5 +57,50 @@ class Device extends Content_1.Content {
54
57
  batch.commit();
55
58
  }
56
59
  }
60
+ get audioDownloadQueue() {
61
+ this.checkDisposed("Device.audioDownloadQueue");
62
+ return this._audioDownloadQueueView.values;
63
+ }
64
+ get audioDownloadQueueLength() {
65
+ this.checkDisposed("Device.audioDownloadQueueLength");
66
+ return this._audioDownloadQueueView.length;
67
+ }
68
+ addToAudioDownloadQueue(text) {
69
+ this.checkDisposed("Device.addToAudioDownloadQueue");
70
+ // Check if item already exists in queue
71
+ const existingIndex = this._audioDownloadQueueView.values.findIndex(item => item.text === text);
72
+ if (existingIndex !== -1) {
73
+ console.log(`Audio download already queued for: ${text}`);
74
+ return;
75
+ }
76
+ const now = shaxpir_common_1.ClockService.getClock().utc();
77
+ const newItem = {
78
+ text,
79
+ added_at: now,
80
+ retry_count: 0
81
+ };
82
+ this._audioDownloadQueueView.push(newItem);
83
+ console.log(`Added to audio download queue: ${text}`);
84
+ }
85
+ removeFromAudioDownloadQueue(text) {
86
+ this.checkDisposed("Device.removeFromAudioDownloadQueue");
87
+ // Find the item index
88
+ const itemIndex = this._audioDownloadQueueView.values.findIndex(item => item.text === text);
89
+ if (itemIndex !== -1) {
90
+ this._audioDownloadQueueView.removeAt(itemIndex);
91
+ console.log(`Removed from audio download queue: ${text}`);
92
+ }
93
+ }
94
+ updateAudioDownloadQueueItem(text, updates) {
95
+ this.checkDisposed("Device.updateAudioDownloadQueueItem");
96
+ const itemIndex = this._audioDownloadQueueView.values.findIndex(item => item.text === text);
97
+ if (itemIndex !== -1) {
98
+ // Update each field in the updates object
99
+ for (const [key, value] of Object.entries(updates)) {
100
+ this._audioDownloadQueueView.setObjectValueAtIndex(itemIndex, key, value);
101
+ }
102
+ console.log(`Updated audio download queue item: ${text}`, updates);
103
+ }
104
+ }
57
105
  }
58
106
  exports.Device = Device;
@@ -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,35 +148,35 @@ 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
+ const index = this._userTagsView.indexOf(value);
170
170
  if (index === -1) {
171
- this._tagsView.push(value);
171
+ this._userTagsView.push(value);
172
172
  this._updateTagCount();
173
173
  }
174
174
  }
175
- removeTag(value) {
176
- this.checkDisposed("Term.removeTag");
177
- const index = this._tagsView.indexOf(value);
175
+ removeUserTag(value) {
176
+ this.checkDisposed("Term.removeUserTag");
177
+ const index = this._userTagsView.indexOf(value);
178
178
  if (index !== -1) {
179
- this._tagsView.removeAt(index);
179
+ this._userTagsView.removeAt(index);
180
180
  this._updateTagCount();
181
181
  }
182
182
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shaxpir/duiduidui-models",
3
- "version": "1.5.10",
3
+ "version": "1.5.12",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/shaxpir/duiduidui-models"