@shaxpir/duiduidui-models 1.28.1 → 1.30.0

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.
@@ -12,7 +12,7 @@ import { Conditions } from './Condition';
12
12
  export interface SearchState {
13
13
  query?: string;
14
14
  senseRank?: number;
15
- phraseId?: number;
15
+ entryId?: string;
16
16
  conditions?: Conditions;
17
17
  }
18
18
  /**
@@ -46,6 +46,6 @@ export declare function createEmptySearchHistory(): SearchHistory;
46
46
  */
47
47
  export declare function areSearchStatesEqual(a: SearchState | undefined, b: SearchState | undefined): boolean;
48
48
  /**
49
- * Checks if a SearchState is empty (no query, no phraseId, no conditions).
49
+ * Checks if a SearchState is empty (no query, no entryId, no conditions).
50
50
  */
51
51
  export declare function isEmptySearchState(state: SearchState | undefined): boolean;
@@ -35,8 +35,8 @@ function areSearchStatesEqual(a, b) {
35
35
  // Compare senseRank
36
36
  if (a.senseRank !== b.senseRank)
37
37
  return false;
38
- // Compare phraseId
39
- if (a.phraseId !== b.phraseId)
38
+ // Compare entryId
39
+ if (a.entryId !== b.entryId)
40
40
  return false;
41
41
  // Compare conditions using JSON serialization (with sorted keys for consistency)
42
42
  const conditionsA = a.conditions ? JSON.stringify(sortConditions(a.conditions)) : undefined;
@@ -62,13 +62,13 @@ function sortConditions(conditions) {
62
62
  return sorted;
63
63
  }
64
64
  /**
65
- * Checks if a SearchState is empty (no query, no phraseId, no conditions).
65
+ * Checks if a SearchState is empty (no query, no entryId, no conditions).
66
66
  */
67
67
  function isEmptySearchState(state) {
68
68
  if (!state)
69
69
  return true;
70
70
  return !state.query?.trim() &&
71
- !state.phraseId &&
71
+ !state.entryId &&
72
72
  !state.conditions?.any?.length &&
73
73
  !state.conditions?.all?.length &&
74
74
  !state.conditions?.none?.length;
@@ -21,6 +21,7 @@ export interface TermSummary {
21
21
  implied_review_count: number;
22
22
  last_review_utc: CompactDateTime;
23
23
  user_tag_count: number;
24
+ is_user_created?: boolean;
24
25
  }
25
26
  export interface TermPayload extends BayesianScore {
26
27
  text: string;
@@ -48,6 +49,7 @@ export interface TermPayload extends BayesianScore {
48
49
  components?: PhraseExample[];
49
50
  examples?: PhraseExample[];
50
51
  keywords?: string[];
52
+ is_user_created?: boolean;
51
53
  pending_subtasks?: Record<string, {
52
54
  started_at: CompactDateTime;
53
55
  started_by: string;
@@ -64,7 +66,9 @@ export declare class Term extends Content {
64
66
  private _userTagsView;
65
67
  constructor(doc: Doc, shouldAcquire: boolean, shareSync: ShareSync);
66
68
  static forUserPhrase(userId: ContentId, text: string, senseRank: number, difficulty: number, type: RecordType, phraseId?: number): Term;
67
- static forUserPhrase(userId: ContentId, phrase: Phrase, type: RecordType): Term;
69
+ static forUserPhrase(userId: ContentId, phrase: Phrase, type: RecordType, options?: {
70
+ starred_at?: CompactDateTime | null;
71
+ }): Term;
68
72
  static forBuiltinPhrase(userId: ContentId, phrase: BuiltInPhrase): Term;
69
73
  get payload(): TermPayload;
70
74
  get text(): string;
@@ -19,16 +19,17 @@ class Term extends Content_1.Content {
19
19
  this._impliedReviewsView = new ArrayView_1.ArrayView(this, ['payload', 'implied_reviews']);
20
20
  this._userTagsView = new ArrayView_1.ArrayView(this, ['payload', 'user_tags']);
21
21
  }
22
- static forUserPhrase(userId, textOrPhrase, senseRankOrType, difficultyOrNothing, typeOrPhraseId, phraseId) {
22
+ static forUserPhrase(userId, textOrPhrase, senseRankOrType, difficultyOrOptions, typeOrPhraseId, phraseId) {
23
23
  const now = shaxpir_common_1.ClockService.getClock().now();
24
24
  // Handle overloaded parameters
25
25
  let phrase;
26
26
  let recordType;
27
27
  let resolvedPhraseId;
28
+ let starredAt = null;
28
29
  if (typeof textOrPhrase === 'string') {
29
30
  // First overload: (userId, text, senseRank, difficulty, type, phraseId?)
30
31
  const senseRank = senseRankOrType;
31
- const difficulty = difficultyOrNothing;
32
+ const difficulty = difficultyOrOptions;
32
33
  recordType = typeOrPhraseId;
33
34
  resolvedPhraseId = phraseId;
34
35
  // Create a minimal Phrase object from individual parameters
@@ -47,10 +48,12 @@ class Term extends Content_1.Content {
47
48
  };
48
49
  }
49
50
  else {
50
- // Second overload: (userId, phrase, type)
51
+ // Second overload: (userId, phrase, type, options?)
51
52
  phrase = textOrPhrase;
52
53
  recordType = senseRankOrType;
53
54
  resolvedPhraseId = undefined;
55
+ const options = difficultyOrOptions;
56
+ starredAt = options?.starred_at ?? null;
54
57
  }
55
58
  const termId = Term.makeTermId(userId, recordType, phrase.text, phrase.sense_rank);
56
59
  return repo_1.ShareSyncFactory.get().createContent({
@@ -78,7 +81,7 @@ class Term extends Content_1.Content {
78
81
  keywords: phrase.keywords,
79
82
  user_tags: phrase.tags || [],
80
83
  user_tag_count: (phrase.tags || []).length,
81
- starred_at: null,
84
+ starred_at: starredAt,
82
85
  alpha: 0.5,
83
86
  beta: 0.5,
84
87
  theta: 0.5,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shaxpir/duiduidui-models",
3
- "version": "1.28.1",
3
+ "version": "1.30.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/shaxpir/duiduidui-models"