@shaxpir/duiduidui-models 1.9.6 → 1.9.8

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.
@@ -16,6 +16,7 @@ interface BaseQueueItem {
16
16
  export interface AudioDownloadQueueItem extends BaseQueueItem {
17
17
  type: 'audio';
18
18
  text: string;
19
+ pronunciation?: string;
19
20
  }
20
21
  export interface ImageDownloadQueueItem extends BaseQueueItem {
21
22
  type: 'image';
@@ -67,8 +68,8 @@ export declare class Device extends Content {
67
68
  addToDownloadQueue(item: AudioDownloadQueueItem | ImageDownloadQueueItem): void;
68
69
  removeFromDownloadQueue(predicate: (item: DownloadQueueItem) => boolean): void;
69
70
  updateDownloadQueueItem(predicate: (item: DownloadQueueItem) => boolean, updates: Partial<BaseQueueItem>): void;
70
- addAudioToDownloadQueue(text: string): void;
71
- removeAudioFromDownloadQueue(text: string): void;
71
+ addAudioToDownloadQueue(text: string, pronunciation?: string): void;
72
+ removeAudioFromDownloadQueue(text: string, pronunciation?: string): void;
72
73
  get uploadQueue(): UploadQueueItem[];
73
74
  get uploadQueueLength(): number;
74
75
  addToUploadQueue(item: UploadQueueItem): void;
@@ -142,7 +142,7 @@ class Device extends Content_1.Content {
142
142
  // Check if item already exists in queue
143
143
  const existingIndex = this._downloadQueueView.values.findIndex(queueItem => {
144
144
  if (queueItem.type === 'audio' && item.type === 'audio') {
145
- return queueItem.text === item.text;
145
+ return queueItem.text === item.text && queueItem.pronunciation === item.pronunciation;
146
146
  }
147
147
  else if (queueItem.type === 'image' && item.type === 'image') {
148
148
  return queueItem.image_id === item.image_id;
@@ -175,17 +175,18 @@ class Device extends Content_1.Content {
175
175
  }
176
176
  }
177
177
  // Convenience methods for audio downloads (backward compatibility)
178
- addAudioToDownloadQueue(text) {
178
+ addAudioToDownloadQueue(text, pronunciation) {
179
179
  const now = shaxpir_common_1.ClockService.getClock().utc();
180
180
  this.addToDownloadQueue({
181
181
  type: 'audio',
182
182
  text,
183
+ ...(pronunciation && { pronunciation }),
183
184
  added_at: now,
184
185
  retry_count: 0
185
186
  });
186
187
  }
187
- removeAudioFromDownloadQueue(text) {
188
- this.removeFromDownloadQueue(item => item.type === 'audio' && item.text === text);
188
+ removeAudioFromDownloadQueue(text, pronunciation) {
189
+ this.removeFromDownloadQueue(item => item.type === 'audio' && item.text === text && item.pronunciation === pronunciation);
189
190
  }
190
191
  // Upload Queue Methods
191
192
  get uploadQueue() {
@@ -7,7 +7,8 @@ declare enum DatabaseVersionBrand {
7
7
  */
8
8
  export type DatabaseVersion = string & DatabaseVersionBrand;
9
9
  /**
10
- * Describes a version of the built-in database available for download
10
+ * Describes a version of the built-in database available for download.
11
+ * Stored in S3 as `duiduidui-{version}.json` alongside `duiduidui-{version}.sqlite.gz`.
11
12
  */
12
13
  export interface BuiltInDbMetadata {
13
14
  version: DatabaseVersion;
@@ -18,6 +19,14 @@ export interface BuiltInDbMetadata {
18
19
  published_at: CompactDateTime;
19
20
  min_app_version: string;
20
21
  }
22
+ /**
23
+ * Top-level pointer to the current database version.
24
+ * Stored in S3 as `meta.json`.
25
+ * Clients fetch this first, then fetch the version-specific manifest.
26
+ */
27
+ export interface DatabaseVersionPointer {
28
+ database_version: DatabaseVersion;
29
+ }
21
30
  /**
22
31
  * Tracks the state of the built-in database on a device
23
32
  * Stored in Device model's payload.builtin_db field
@@ -121,4 +130,10 @@ export declare const BUILTIN_DB_CONSTANTS: {
121
130
  * getBuiltInDbFilename("20250118a", false) -> "duiduidui-20250118a.sqlite"
122
131
  */
123
132
  export declare function getBuiltInDbFilename(version: DatabaseVersion, compressed?: boolean): string;
133
+ /**
134
+ * Helper to generate metadata filename for a database version
135
+ * Examples:
136
+ * getBuiltInDbMetadataFilename("20250118a") -> "duiduidui-20250118a.json"
137
+ */
138
+ export declare function getBuiltInDbMetadataFilename(version: DatabaseVersion): string;
124
139
  export {};
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.BUILTIN_DB_CONSTANTS = exports.DatabaseVersionModel = exports.Checksum = void 0;
5
5
  exports.getBuiltInDbFilename = getBuiltInDbFilename;
6
+ exports.getBuiltInDbMetadataFilename = getBuiltInDbMetadataFilename;
6
7
  var DatabaseVersionBrand;
7
8
  (function (DatabaseVersionBrand) {
8
9
  })(DatabaseVersionBrand || (DatabaseVersionBrand = {}));
@@ -133,3 +134,11 @@ function getBuiltInDbFilename(version, compressed = true) {
133
134
  const base = `${exports.BUILTIN_DB_CONSTANTS.FILE_PREFIX}${version}${exports.BUILTIN_DB_CONSTANTS.FILE_EXTENSION}`;
134
135
  return compressed ? `${base}.gz` : base;
135
136
  }
137
+ /**
138
+ * Helper to generate metadata filename for a database version
139
+ * Examples:
140
+ * getBuiltInDbMetadataFilename("20250118a") -> "duiduidui-20250118a.json"
141
+ */
142
+ function getBuiltInDbMetadataFilename(version) {
143
+ return `${exports.BUILTIN_DB_CONSTANTS.FILE_PREFIX}${version}.json`;
144
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shaxpir/duiduidui-models",
3
- "version": "1.9.6",
3
+ "version": "1.9.8",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/shaxpir/duiduidui-models"