@tinyshed/tinystore 0.4.0 → 0.5.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.
@@ -10239,6 +10239,12 @@ export const SearchQuery = message(
10239
10239
  offset: [7, uint],
10240
10240
  /** 10 when absent; offset and limit together 1000 at most */
10241
10241
  limit: [8, uint],
10242
+ /** the last word read as the start of a word too, as a search box types */
10243
+ prefix: [9, bool],
10244
+ /** every word read so, a document holding a word for each first; in place of prefix */
10245
+ prefixEvery: [10, bool],
10246
+ /** utf8, utf16 or chars: each hit says where it matched, counted in that unit */
10247
+ matches: [11, str],
10242
10248
  },
10243
10249
  {
10244
10250
  write(w, v) {
@@ -10284,6 +10290,21 @@ export const SearchQuery = message(
10284
10290
  w.uint(v.limit)
10285
10291
  n++
10286
10292
  }
10293
+ if (v.prefix !== undefined) {
10294
+ w.field(9)
10295
+ w.bool(v.prefix)
10296
+ n++
10297
+ }
10298
+ if (v.prefixEvery !== undefined) {
10299
+ w.field(10)
10300
+ w.bool(v.prefixEvery)
10301
+ n++
10302
+ }
10303
+ if (v.matches !== undefined) {
10304
+ w.field(11)
10305
+ w.str(v.matches)
10306
+ n++
10307
+ }
10287
10308
  w.closeMap(head, n)
10288
10309
  },
10289
10310
  read(r) {
@@ -10295,6 +10316,9 @@ export const SearchQuery = message(
10295
10316
  let $where: string | undefined
10296
10317
  let $offset: number | undefined
10297
10318
  let $limit: number | undefined
10319
+ let $prefix: boolean | undefined
10320
+ let $prefixEvery: boolean | undefined
10321
+ let $matches: string | undefined
10298
10322
  for (let n = r.message(); n > 0; n--) {
10299
10323
  switch (r.field()) {
10300
10324
  case 1:
@@ -10321,6 +10345,15 @@ export const SearchQuery = message(
10321
10345
  case 8:
10322
10346
  $limit = r.uint()
10323
10347
  break
10348
+ case 9:
10349
+ $prefix = r.bool()
10350
+ break
10351
+ case 10:
10352
+ $prefixEvery = r.bool()
10353
+ break
10354
+ case 11:
10355
+ $matches = r.str()
10356
+ break
10324
10357
  default:
10325
10358
  r.skip()
10326
10359
  }
@@ -10335,157 +10368,93 @@ export const SearchQuery = message(
10335
10368
  where: $where,
10336
10369
  offset: $offset,
10337
10370
  limit: $limit,
10371
+ prefix: $prefix,
10372
+ prefixEvery: $prefixEvery,
10373
+ matches: $matches,
10338
10374
  }
10339
10375
  },
10340
10376
  },
10341
10377
  )
10342
10378
 
10343
10379
  /**
10344
- * A hit: a document and its value, or a table's row, a value a column of
10345
- * the answer's columns, as sql.Rows holds one.
10380
+ * Where a search's word matched a hit: a range of a field's text, or of a
10381
+ * string of a field that holds a list, counted in the unit the query asked:
10382
+ * bytes of UTF-8, units of UTF-16 or code points. The whole word for a word
10383
+ * found as written, by its stem or once corrected; the letters typed for a
10384
+ * word a prefix began.
10346
10385
  */
10347
- export const SearchHit = message(
10348
- 'search.Hit',
10386
+ export const SearchMatch = message(
10387
+ 'search.Match',
10349
10388
  {
10350
- id: [1, str],
10351
- /** null for a table's row */
10352
- value: [2, str],
10353
- score: [3, float],
10354
- row: [4, list(sqlValue)],
10389
+ /** the field's path or the table's column; empty for a document that is its own text */
10390
+ field: [1, str],
10391
+ /** the string's place in a field that holds a list */
10392
+ item: [2, uint],
10393
+ start: [3, uint],
10394
+ end: [4, uint],
10395
+ /** the query's word, as its text wrote it */
10396
+ word: [5, str],
10355
10397
  },
10356
10398
  {
10357
10399
  write(w, v) {
10358
10400
  const head = w.openMap()
10359
10401
  let n = 0
10360
- if (v.id !== undefined) {
10402
+ if (v.field !== undefined) {
10361
10403
  w.field(1)
10362
- w.str(v.id)
10404
+ w.str(v.field)
10363
10405
  n++
10364
10406
  }
10365
- if (v.value !== undefined) {
10407
+ if (v.item !== undefined) {
10366
10408
  w.field(2)
10367
- w.str(v.value)
10409
+ w.uint(v.item)
10368
10410
  n++
10369
10411
  }
10370
- if (v.score !== undefined) {
10412
+ if (v.start !== undefined) {
10371
10413
  w.field(3)
10372
- w.float(v.score)
10414
+ w.uint(v.start)
10373
10415
  n++
10374
10416
  }
10375
- if (v.row !== undefined) {
10417
+ if (v.end !== undefined) {
10376
10418
  w.field(4)
10377
- w.array(v.row.length)
10378
- for (const item0 of v.row) {
10379
- sqlValue.write(w, item0)
10380
- }
10419
+ w.uint(v.end)
10420
+ n++
10421
+ }
10422
+ if (v.word !== undefined) {
10423
+ w.field(5)
10424
+ w.str(v.word)
10381
10425
  n++
10382
10426
  }
10383
10427
  w.closeMap(head, n)
10384
10428
  },
10385
10429
  read(r) {
10386
- let $id: string | undefined
10387
- let $value: string | undefined
10388
- let $score: number | undefined
10389
- let $row: (SqlValue | boolean)[] | undefined
10430
+ let $field: string | undefined
10431
+ let $item: number | undefined
10432
+ let $start: number | undefined
10433
+ let $end: number | undefined
10434
+ let $word: string | undefined
10390
10435
  for (let n = r.message(); n > 0; n--) {
10391
10436
  switch (r.field()) {
10392
10437
  case 1:
10393
- $id = r.str()
10438
+ $field = r.str()
10394
10439
  break
10395
10440
  case 2:
10396
- $value = r.str()
10441
+ $item = r.uint()
10397
10442
  break
10398
10443
  case 3:
10399
- $score = r.float()
10444
+ $start = r.uint()
10400
10445
  break
10401
- case 4: {
10402
- const items0: (SqlValue | boolean)[] = []
10403
- for (let i0 = r.array(); i0 > 0; i0--) {
10404
- items0.push(sqlValue.read(r))
10405
- }
10406
- r.leave()
10407
- $row = items0
10408
- break
10409
- }
10410
- default:
10411
- r.skip()
10412
- }
10413
- }
10414
- r.leave()
10415
- return { id: $id, value: $value, score: $score, row: $row }
10416
- },
10417
- },
10418
- )
10419
-
10420
- export const SearchFound = message(
10421
- 'search.Found',
10422
- {
10423
- hits: [1, list(SearchHit)],
10424
- /** the text the search read in fact, when a word was read as another */
10425
- corrected: [2, str],
10426
- /** the columns of a table's index's rows */
10427
- columns: [3, list(str)],
10428
- },
10429
- {
10430
- write(w, v) {
10431
- const head = w.openMap()
10432
- let n = 0
10433
- if (v.hits !== undefined) {
10434
- w.field(1)
10435
- w.array(v.hits.length)
10436
- for (const item0 of v.hits) {
10437
- SearchHit.write(w, item0)
10438
- }
10439
- n++
10440
- }
10441
- if (v.corrected !== undefined) {
10442
- w.field(2)
10443
- w.str(v.corrected)
10444
- n++
10445
- }
10446
- if (v.columns !== undefined) {
10447
- w.field(3)
10448
- w.array(v.columns.length)
10449
- for (const item0 of v.columns) {
10450
- w.str(item0)
10451
- }
10452
- n++
10453
- }
10454
- w.closeMap(head, n)
10455
- },
10456
- read(r) {
10457
- let $hits: Read<typeof SearchHit.fields>[] | undefined
10458
- let $corrected: string | undefined
10459
- let $columns: string[] | undefined
10460
- for (let n = r.message(); n > 0; n--) {
10461
- switch (r.field()) {
10462
- case 1: {
10463
- const items0: Read<typeof SearchHit.fields>[] = []
10464
- for (let i0 = r.array(); i0 > 0; i0--) {
10465
- items0.push(SearchHit.read(r))
10466
- }
10467
- r.leave()
10468
- $hits = items0
10469
- break
10470
- }
10471
- case 2:
10472
- $corrected = r.str()
10446
+ case 4:
10447
+ $end = r.uint()
10473
10448
  break
10474
- case 3: {
10475
- const items0: string[] = []
10476
- for (let i0 = r.array(); i0 > 0; i0--) {
10477
- items0.push(r.str())
10478
- }
10479
- r.leave()
10480
- $columns = items0
10449
+ case 5:
10450
+ $word = r.str()
10481
10451
  break
10482
- }
10483
10452
  default:
10484
10453
  r.skip()
10485
10454
  }
10486
10455
  }
10487
10456
  r.leave()
10488
- return { hits: $hits, corrected: $corrected, columns: $columns }
10457
+ return { field: $field, item: $item, start: $start, end: $end, word: $word }
10489
10458
  },
10490
10459
  },
10491
10460
  )
@@ -11958,6 +11927,8 @@ export const SearchOpen = message(
11958
11927
  key: [13, str],
11959
11928
  /** the column of each row's vector, a blob of little-endian floats */
11960
11929
  vectorColumn: [14, str],
11930
+ /** the keyboard layouts its readers type with: ru and en, or none */
11931
+ layouts: [15, list(str)],
11961
11932
  },
11962
11933
  {
11963
11934
  write(w, v) {
@@ -12039,6 +12010,14 @@ export const SearchOpen = message(
12039
12010
  w.str(v.vectorColumn)
12040
12011
  n++
12041
12012
  }
12013
+ if (v.layouts !== undefined) {
12014
+ w.field(15)
12015
+ w.array(v.layouts.length)
12016
+ for (const item0 of v.layouts) {
12017
+ w.str(item0)
12018
+ }
12019
+ n++
12020
+ }
12042
12021
  w.closeMap(head, n)
12043
12022
  },
12044
12023
  read(r) {
@@ -12056,6 +12035,7 @@ export const SearchOpen = message(
12056
12035
  let $table: string | undefined
12057
12036
  let $key: string | undefined
12058
12037
  let $vectorColumn: string | undefined
12038
+ let $layouts: string[] | undefined
12059
12039
  for (let n = r.message(); n > 0; n--) {
12060
12040
  switch (r.field()) {
12061
12041
  case 1:
@@ -12112,6 +12092,15 @@ export const SearchOpen = message(
12112
12092
  case 14:
12113
12093
  $vectorColumn = r.str()
12114
12094
  break
12095
+ case 15: {
12096
+ const items0: string[] = []
12097
+ for (let i0 = r.array(); i0 > 0; i0--) {
12098
+ items0.push(r.str())
12099
+ }
12100
+ r.leave()
12101
+ $layouts = items0
12102
+ break
12103
+ }
12115
12104
  default:
12116
12105
  r.skip()
12117
12106
  }
@@ -12132,13 +12121,15 @@ export const SearchOpen = message(
12132
12121
  table: $table,
12133
12122
  key: $key,
12134
12123
  vectorColumn: $vectorColumn,
12124
+ layouts: $layouts,
12135
12125
  }
12136
12126
  },
12137
12127
  },
12138
12128
  )
12139
12129
 
12140
12130
  /**
12141
- * Documents set in one commit, all of them or none: 1,000 and 16 MiB at most.
12131
+ * Documents set in one commit, all of them or none: 1,000 at most, and no more
12132
+ * than one request body holds, 2 MiB from every SDK.
12142
12133
  */
12143
12134
  export const SearchSetMany = message(
12144
12135
  'search.SetMany',
@@ -12192,6 +12183,176 @@ export const SearchSetMany = message(
12192
12183
  },
12193
12184
  )
12194
12185
 
12186
+ /**
12187
+ * A hit: a document and its value, or a table's row, a value a column of
12188
+ * the answer's columns, as sql.Rows holds one, and where the search's words
12189
+ * matched it when the query asked.
12190
+ */
12191
+ export const SearchHit = message(
12192
+ 'search.Hit',
12193
+ {
12194
+ id: [1, str],
12195
+ /** null for a table's row */
12196
+ value: [2, str],
12197
+ score: [3, float],
12198
+ row: [4, list(sqlValue)],
12199
+ matches: [5, list(SearchMatch)],
12200
+ },
12201
+ {
12202
+ write(w, v) {
12203
+ const head = w.openMap()
12204
+ let n = 0
12205
+ if (v.id !== undefined) {
12206
+ w.field(1)
12207
+ w.str(v.id)
12208
+ n++
12209
+ }
12210
+ if (v.value !== undefined) {
12211
+ w.field(2)
12212
+ w.str(v.value)
12213
+ n++
12214
+ }
12215
+ if (v.score !== undefined) {
12216
+ w.field(3)
12217
+ w.float(v.score)
12218
+ n++
12219
+ }
12220
+ if (v.row !== undefined) {
12221
+ w.field(4)
12222
+ w.array(v.row.length)
12223
+ for (const item0 of v.row) {
12224
+ sqlValue.write(w, item0)
12225
+ }
12226
+ n++
12227
+ }
12228
+ if (v.matches !== undefined) {
12229
+ w.field(5)
12230
+ w.array(v.matches.length)
12231
+ for (const item0 of v.matches) {
12232
+ SearchMatch.write(w, item0)
12233
+ }
12234
+ n++
12235
+ }
12236
+ w.closeMap(head, n)
12237
+ },
12238
+ read(r) {
12239
+ let $id: string | undefined
12240
+ let $value: string | undefined
12241
+ let $score: number | undefined
12242
+ let $row: (SqlValue | boolean)[] | undefined
12243
+ let $matches: Read<typeof SearchMatch.fields>[] | undefined
12244
+ for (let n = r.message(); n > 0; n--) {
12245
+ switch (r.field()) {
12246
+ case 1:
12247
+ $id = r.str()
12248
+ break
12249
+ case 2:
12250
+ $value = r.str()
12251
+ break
12252
+ case 3:
12253
+ $score = r.float()
12254
+ break
12255
+ case 4: {
12256
+ const items0: (SqlValue | boolean)[] = []
12257
+ for (let i0 = r.array(); i0 > 0; i0--) {
12258
+ items0.push(sqlValue.read(r))
12259
+ }
12260
+ r.leave()
12261
+ $row = items0
12262
+ break
12263
+ }
12264
+ case 5: {
12265
+ const items0: Read<typeof SearchMatch.fields>[] = []
12266
+ for (let i0 = r.array(); i0 > 0; i0--) {
12267
+ items0.push(SearchMatch.read(r))
12268
+ }
12269
+ r.leave()
12270
+ $matches = items0
12271
+ break
12272
+ }
12273
+ default:
12274
+ r.skip()
12275
+ }
12276
+ }
12277
+ r.leave()
12278
+ return { id: $id, value: $value, score: $score, row: $row, matches: $matches }
12279
+ },
12280
+ },
12281
+ )
12282
+
12283
+ export const SearchFound = message(
12284
+ 'search.Found',
12285
+ {
12286
+ hits: [1, list(SearchHit)],
12287
+ /** the text the search read in fact, when a word was read as another */
12288
+ corrected: [2, str],
12289
+ /** the columns of a table's index's rows */
12290
+ columns: [3, list(str)],
12291
+ },
12292
+ {
12293
+ write(w, v) {
12294
+ const head = w.openMap()
12295
+ let n = 0
12296
+ if (v.hits !== undefined) {
12297
+ w.field(1)
12298
+ w.array(v.hits.length)
12299
+ for (const item0 of v.hits) {
12300
+ SearchHit.write(w, item0)
12301
+ }
12302
+ n++
12303
+ }
12304
+ if (v.corrected !== undefined) {
12305
+ w.field(2)
12306
+ w.str(v.corrected)
12307
+ n++
12308
+ }
12309
+ if (v.columns !== undefined) {
12310
+ w.field(3)
12311
+ w.array(v.columns.length)
12312
+ for (const item0 of v.columns) {
12313
+ w.str(item0)
12314
+ }
12315
+ n++
12316
+ }
12317
+ w.closeMap(head, n)
12318
+ },
12319
+ read(r) {
12320
+ let $hits: Read<typeof SearchHit.fields>[] | undefined
12321
+ let $corrected: string | undefined
12322
+ let $columns: string[] | undefined
12323
+ for (let n = r.message(); n > 0; n--) {
12324
+ switch (r.field()) {
12325
+ case 1: {
12326
+ const items0: Read<typeof SearchHit.fields>[] = []
12327
+ for (let i0 = r.array(); i0 > 0; i0--) {
12328
+ items0.push(SearchHit.read(r))
12329
+ }
12330
+ r.leave()
12331
+ $hits = items0
12332
+ break
12333
+ }
12334
+ case 2:
12335
+ $corrected = r.str()
12336
+ break
12337
+ case 3: {
12338
+ const items0: string[] = []
12339
+ for (let i0 = r.array(); i0 > 0; i0--) {
12340
+ items0.push(r.str())
12341
+ }
12342
+ r.leave()
12343
+ $columns = items0
12344
+ break
12345
+ }
12346
+ default:
12347
+ r.skip()
12348
+ }
12349
+ }
12350
+ r.leave()
12351
+ return { hits: $hits, corrected: $corrected, columns: $columns }
12352
+ },
12353
+ },
12354
+ )
12355
+
12195
12356
  /**
12196
12357
  * A setting's line of explain.
12197
12358
  */