@tinyshed/tinystore 0.7.0 → 0.8.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.
@@ -3472,8 +3472,9 @@ export const JobsJob = message(
3472
3472
 
3473
3473
  /**
3474
3474
  * A page of a queue's jobs: those whose ids start with a prefix, in the byte
3475
- * order of their ids, or with no prefix and the failed state, the last failed
3476
- * first.
3475
+ * order of their ids; with no prefix every job, those with ids first, then
3476
+ * those without as they run, then those without that failed, the last failed
3477
+ * first; with no prefix and the failed state the failed alone, the last first.
3477
3478
  */
3478
3479
  export const JobsList = message(
3479
3480
  'jobs.List',
@@ -10552,6 +10553,8 @@ export const SearchQuery = message(
10552
10553
  prefixEvery: [10, bool],
10553
10554
  /** utf8, utf16 or chars: each hit says where it matched, counted in that unit */
10554
10555
  matches: [11, str],
10556
+ /** the least cosine a document's vector has for the vector to find it */
10557
+ minSimilarity: [12, float],
10555
10558
  },
10556
10559
  {
10557
10560
  write(w, v) {
@@ -10612,6 +10615,11 @@ export const SearchQuery = message(
10612
10615
  w.str(v.matches)
10613
10616
  n++
10614
10617
  }
10618
+ if (v.minSimilarity !== undefined) {
10619
+ w.field(12)
10620
+ w.float(v.minSimilarity)
10621
+ n++
10622
+ }
10615
10623
  w.closeMap(head, n)
10616
10624
  },
10617
10625
  read(r) {
@@ -10626,6 +10634,7 @@ export const SearchQuery = message(
10626
10634
  let $prefix: boolean | undefined
10627
10635
  let $prefixEvery: boolean | undefined
10628
10636
  let $matches: string | undefined
10637
+ let $minSimilarity: number | undefined
10629
10638
  for (let n = r.message(); n > 0; n--) {
10630
10639
  switch (r.field()) {
10631
10640
  case 1:
@@ -10661,6 +10670,9 @@ export const SearchQuery = message(
10661
10670
  case 11:
10662
10671
  $matches = r.str()
10663
10672
  break
10673
+ case 12:
10674
+ $minSimilarity = r.float()
10675
+ break
10664
10676
  default:
10665
10677
  r.skip()
10666
10678
  }
@@ -10678,6 +10690,7 @@ export const SearchQuery = message(
10678
10690
  prefix: $prefix,
10679
10691
  prefixEvery: $prefixEvery,
10680
10692
  matches: $matches,
10693
+ minSimilarity: $minSimilarity,
10681
10694
  }
10682
10695
  },
10683
10696
  },
@@ -12498,8 +12511,8 @@ export const SearchSetMany = message(
12498
12511
 
12499
12512
  /**
12500
12513
  * A hit: a document and its value, or a table's row, a value a column of
12501
- * the answer's columns, as sql.Rows holds one, and where the search's words
12502
- * matched it when the query asked.
12514
+ * the answer's columns, as sql.Rows holds one, where the search's words
12515
+ * matched it when the query asked, and what each half of the search gave it.
12503
12516
  */
12504
12517
  export const SearchHit = message(
12505
12518
  'search.Hit',
@@ -12510,6 +12523,10 @@ export const SearchHit = message(
12510
12523
  score: [3, float],
12511
12524
  row: [4, list(sqlValue)],
12512
12525
  matches: [5, list(SearchMatch)],
12526
+ /** its words' score, where they found it among their best */
12527
+ textScore: [6, float],
12528
+ /** its vector's cosine with the search's, where both have one */
12529
+ similarity: [7, float],
12513
12530
  },
12514
12531
  {
12515
12532
  write(w, v) {
@@ -12546,6 +12563,16 @@ export const SearchHit = message(
12546
12563
  }
12547
12564
  n++
12548
12565
  }
12566
+ if (v.textScore !== undefined) {
12567
+ w.field(6)
12568
+ w.float(v.textScore)
12569
+ n++
12570
+ }
12571
+ if (v.similarity !== undefined) {
12572
+ w.field(7)
12573
+ w.float(v.similarity)
12574
+ n++
12575
+ }
12549
12576
  w.closeMap(head, n)
12550
12577
  },
12551
12578
  read(r) {
@@ -12554,6 +12581,8 @@ export const SearchHit = message(
12554
12581
  let $score: number | undefined
12555
12582
  let $row: (SqlValue | boolean)[] | undefined
12556
12583
  let $matches: Read<typeof SearchMatch.fields>[] | undefined
12584
+ let $textScore: number | undefined
12585
+ let $similarity: number | undefined
12557
12586
  for (let n = r.message(); n > 0; n--) {
12558
12587
  switch (r.field()) {
12559
12588
  case 1:
@@ -12583,12 +12612,26 @@ export const SearchHit = message(
12583
12612
  $matches = items0
12584
12613
  break
12585
12614
  }
12615
+ case 6:
12616
+ $textScore = r.float()
12617
+ break
12618
+ case 7:
12619
+ $similarity = r.float()
12620
+ break
12586
12621
  default:
12587
12622
  r.skip()
12588
12623
  }
12589
12624
  }
12590
12625
  r.leave()
12591
- return { id: $id, value: $value, score: $score, row: $row, matches: $matches }
12626
+ return {
12627
+ id: $id,
12628
+ value: $value,
12629
+ score: $score,
12630
+ row: $row,
12631
+ matches: $matches,
12632
+ textScore: $textScore,
12633
+ similarity: $similarity,
12634
+ }
12592
12635
  },
12593
12636
  },
12594
12637
  )