@shaxpir/duiduidui-models 1.9.29 → 1.9.31

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.
@@ -89,11 +89,12 @@ export declare class Device extends Content {
89
89
  get currentSearchState(): SearchState | undefined;
90
90
  /**
91
91
  * Returns true if back navigation is possible.
92
- * Only returns true if the previous entry is non-empty (has query or conditions).
92
+ * Skips over empty entries to find a non-empty one.
93
93
  */
94
94
  get canGoBack(): boolean;
95
95
  /**
96
96
  * Returns true if forward navigation is possible.
97
+ * Skips over empty entries to find a non-empty one.
97
98
  */
98
99
  get canGoForward(): boolean;
99
100
  /**
@@ -106,12 +107,12 @@ export declare class Device extends Content {
106
107
  */
107
108
  pushSearchState(state: SearchState): SearchState | undefined;
108
109
  /**
109
- * Navigates back in search history.
110
+ * Navigates back in search history, skipping over empty entries.
110
111
  * @returns The search state at the new cursor position, or undefined if can't go back
111
112
  */
112
113
  goBack(): SearchState | undefined;
113
114
  /**
114
- * Navigates forward in search history.
115
+ * Navigates forward in search history, skipping over empty entries.
115
116
  * @returns The search state at the new cursor position, or undefined if can't go forward
116
117
  */
117
118
  goForward(): SearchState | undefined;
@@ -267,24 +267,33 @@ class Device extends Content_1.Content {
267
267
  }
268
268
  /**
269
269
  * Returns true if back navigation is possible.
270
- * Only returns true if the previous entry is non-empty (has query or conditions).
270
+ * Skips over empty entries to find a non-empty one.
271
271
  */
272
272
  get canGoBack() {
273
273
  this.checkDisposed("Device.canGoBack");
274
274
  const history = this.searchHistory;
275
- if (history.cursor <= 0)
276
- return false;
277
- // Check if the entry we'd navigate to is non-empty
278
- const prevEntry = history.entries[history.cursor - 1];
279
- return !(0, SearchState_1.isEmptySearchState)(prevEntry);
275
+ // Look for any non-empty entry before the cursor
276
+ for (let i = history.cursor - 1; i >= 0; i--) {
277
+ if (!(0, SearchState_1.isEmptySearchState)(history.entries[i])) {
278
+ return true;
279
+ }
280
+ }
281
+ return false;
280
282
  }
281
283
  /**
282
284
  * Returns true if forward navigation is possible.
285
+ * Skips over empty entries to find a non-empty one.
283
286
  */
284
287
  get canGoForward() {
285
288
  this.checkDisposed("Device.canGoForward");
286
289
  const history = this.searchHistory;
287
- return history.cursor < history.entries.length - 1;
290
+ // Look for any non-empty entry after the cursor
291
+ for (let i = history.cursor + 1; i < history.entries.length; i++) {
292
+ if (!(0, SearchState_1.isEmptySearchState)(history.entries[i])) {
293
+ return true;
294
+ }
295
+ }
296
+ return false;
288
297
  }
289
298
  /**
290
299
  * Pushes a new search state onto the history stack.
@@ -328,7 +337,7 @@ class Device extends Content_1.Content {
328
337
  return state;
329
338
  }
330
339
  /**
331
- * Navigates back in search history.
340
+ * Navigates back in search history, skipping over empty entries.
332
341
  * @returns The search state at the new cursor position, or undefined if can't go back
333
342
  */
334
343
  goBack() {
@@ -337,14 +346,21 @@ class Device extends Content_1.Content {
337
346
  return undefined;
338
347
  }
339
348
  const history = this.searchHistory;
340
- const newCursor = history.cursor - 1;
349
+ // Find the first non-empty entry before the cursor
350
+ let newCursor = history.cursor - 1;
351
+ while (newCursor >= 0 && (0, SearchState_1.isEmptySearchState)(history.entries[newCursor])) {
352
+ newCursor--;
353
+ }
354
+ if (newCursor < 0) {
355
+ return undefined;
356
+ }
341
357
  const batch = new Operation_1.BatchOperation(this);
342
358
  batch.setPathValue(['payload', 'search_history', 'cursor'], newCursor);
343
359
  batch.commit();
344
360
  return history.entries[newCursor];
345
361
  }
346
362
  /**
347
- * Navigates forward in search history.
363
+ * Navigates forward in search history, skipping over empty entries.
348
364
  * @returns The search state at the new cursor position, or undefined if can't go forward
349
365
  */
350
366
  goForward() {
@@ -353,7 +369,14 @@ class Device extends Content_1.Content {
353
369
  return undefined;
354
370
  }
355
371
  const history = this.searchHistory;
356
- const newCursor = history.cursor + 1;
372
+ // Find the first non-empty entry after the cursor
373
+ let newCursor = history.cursor + 1;
374
+ while (newCursor < history.entries.length && (0, SearchState_1.isEmptySearchState)(history.entries[newCursor])) {
375
+ newCursor++;
376
+ }
377
+ if (newCursor >= history.entries.length) {
378
+ return undefined;
379
+ }
357
380
  const batch = new Operation_1.BatchOperation(this);
358
381
  batch.setPathValue(['payload', 'search_history', 'cursor'], newCursor);
359
382
  batch.commit();
@@ -40,6 +40,24 @@ export declare class Logger {
40
40
  withClientServiceName(serviceName: string): Logger;
41
41
  withClientNodeName(nodeName: string): Logger;
42
42
  withClientVersion(version: string): Logger;
43
+ withPlatform(platform: string): Logger;
44
+ withDeviceModel(model: string): Logger;
45
+ withDeviceBrand(brand: string): Logger;
46
+ withOsVersion(version: string): Logger;
47
+ withScreenWidth(width: number): Logger;
48
+ withScreenHeight(height: number): Logger;
49
+ withPixelRatio(ratio: number): Logger;
50
+ withLocale(locale: string): Logger;
51
+ withTimezone(timezone: string): Logger;
52
+ withIsTablet(isTablet: boolean): Logger;
53
+ withDeviceYearClass(yearClass: number): Logger;
54
+ withQueryName(queryName: string): Logger;
55
+ withResultCount(count: number): Logger;
56
+ withRowCount(count: number): Logger;
57
+ withRequestedCount(count: number): Logger;
58
+ withFromCache(fromCache: boolean): Logger;
59
+ withSearchQuery(query: string): Logger;
60
+ withSuccess(success: boolean): Logger;
43
61
  withTopic(topic: string): Logger;
44
62
  withSubtopic(subtopic: string): Logger;
45
63
  withName(name: string): Logger;
@@ -79,6 +97,24 @@ export interface LogFields {
79
97
  client_service_name?: string;
80
98
  client_node_name?: string;
81
99
  client_version?: string;
100
+ platform?: string;
101
+ device_model?: string;
102
+ device_brand?: string;
103
+ os_version?: string;
104
+ screen_width?: number;
105
+ screen_height?: number;
106
+ pixel_ratio?: number;
107
+ locale?: string;
108
+ timezone?: string;
109
+ is_tablet?: boolean;
110
+ device_year_class?: number;
111
+ query_name?: string;
112
+ result_count?: number;
113
+ row_count?: number;
114
+ requested_count?: number;
115
+ from_cache?: boolean;
116
+ search_query?: string;
117
+ success?: boolean;
82
118
  context?: string;
83
119
  name?: string;
84
120
  topic?: string;
@@ -139,6 +139,78 @@ class Logger {
139
139
  this.withField('client_version', version);
140
140
  return this;
141
141
  }
142
+ withPlatform(platform) {
143
+ this.withField('platform', platform);
144
+ return this;
145
+ }
146
+ withDeviceModel(model) {
147
+ this.withField('device_model', model);
148
+ return this;
149
+ }
150
+ withDeviceBrand(brand) {
151
+ this.withField('device_brand', brand);
152
+ return this;
153
+ }
154
+ withOsVersion(version) {
155
+ this.withField('os_version', version);
156
+ return this;
157
+ }
158
+ withScreenWidth(width) {
159
+ this.withField('screen_width', width);
160
+ return this;
161
+ }
162
+ withScreenHeight(height) {
163
+ this.withField('screen_height', height);
164
+ return this;
165
+ }
166
+ withPixelRatio(ratio) {
167
+ this.withField('pixel_ratio', ratio);
168
+ return this;
169
+ }
170
+ withLocale(locale) {
171
+ this.withField('locale', locale);
172
+ return this;
173
+ }
174
+ withTimezone(timezone) {
175
+ this.withField('timezone', timezone);
176
+ return this;
177
+ }
178
+ withIsTablet(isTablet) {
179
+ this.withField('is_tablet', isTablet);
180
+ return this;
181
+ }
182
+ withDeviceYearClass(yearClass) {
183
+ this.withField('device_year_class', yearClass);
184
+ return this;
185
+ }
186
+ withQueryName(queryName) {
187
+ this.withField('query_name', queryName);
188
+ return this;
189
+ }
190
+ withResultCount(count) {
191
+ this.withField('result_count', count);
192
+ return this;
193
+ }
194
+ withRowCount(count) {
195
+ this.withField('row_count', count);
196
+ return this;
197
+ }
198
+ withRequestedCount(count) {
199
+ this.withField('requested_count', count);
200
+ return this;
201
+ }
202
+ withFromCache(fromCache) {
203
+ this.withField('from_cache', fromCache);
204
+ return this;
205
+ }
206
+ withSearchQuery(query) {
207
+ this.withField('search_query', query);
208
+ return this;
209
+ }
210
+ withSuccess(success) {
211
+ this.withField('success', success);
212
+ return this;
213
+ }
142
214
  withTopic(topic) {
143
215
  this.withField('topic', topic);
144
216
  return this;
@@ -347,6 +419,14 @@ class Logger {
347
419
  case 'client_service_name':
348
420
  case 'client_node_name':
349
421
  case 'client_version':
422
+ case 'platform':
423
+ case 'device_model':
424
+ case 'device_brand':
425
+ case 'os_version':
426
+ case 'locale':
427
+ case 'timezone':
428
+ case 'query_name':
429
+ case 'search_query':
350
430
  case 'context':
351
431
  case 'topic':
352
432
  case 'subtopic':
@@ -386,6 +466,9 @@ class Logger {
386
466
  case 'using_jwt':
387
467
  case 'using_pass_hash':
388
468
  case 'ignore_conflict':
469
+ case 'is_tablet':
470
+ case 'from_cache':
471
+ case 'success':
389
472
  if (value != null && value != undefined && typeof value !== 'boolean') {
390
473
  ;
391
474
  throw new Error(Logger.makeTypeErrorMessage(key, value, 'boolean'));
@@ -396,6 +479,13 @@ class Logger {
396
479
  case 'duration_millis':
397
480
  case 'file_size':
398
481
  case 'doc_version':
482
+ case 'screen_width':
483
+ case 'screen_height':
484
+ case 'pixel_ratio':
485
+ case 'device_year_class':
486
+ case 'result_count':
487
+ case 'row_count':
488
+ case 'requested_count':
399
489
  if (value != null && value != undefined && typeof value !== 'number') {
400
490
  throw new Error(Logger.makeTypeErrorMessage(key, value, 'number'));
401
491
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shaxpir/duiduidui-models",
3
- "version": "1.9.29",
3
+ "version": "1.9.31",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/shaxpir/duiduidui-models"