@tinyshed/tinystore 0.4.1 → 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.
@@ -10241,6 +10241,10 @@ export const SearchQuery = message(
10241
10241
  limit: [8, uint],
10242
10242
  /** the last word read as the start of a word too, as a search box types */
10243
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],
10244
10248
  },
10245
10249
  {
10246
10250
  write(w, v) {
@@ -10291,6 +10295,16 @@ export const SearchQuery = message(
10291
10295
  w.bool(v.prefix)
10292
10296
  n++
10293
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
+ }
10294
10308
  w.closeMap(head, n)
10295
10309
  },
10296
10310
  read(r) {
@@ -10303,6 +10317,8 @@ export const SearchQuery = message(
10303
10317
  let $offset: number | undefined
10304
10318
  let $limit: number | undefined
10305
10319
  let $prefix: boolean | undefined
10320
+ let $prefixEvery: boolean | undefined
10321
+ let $matches: string | undefined
10306
10322
  for (let n = r.message(); n > 0; n--) {
10307
10323
  switch (r.field()) {
10308
10324
  case 1:
@@ -10332,6 +10348,12 @@ export const SearchQuery = message(
10332
10348
  case 9:
10333
10349
  $prefix = r.bool()
10334
10350
  break
10351
+ case 10:
10352
+ $prefixEvery = r.bool()
10353
+ break
10354
+ case 11:
10355
+ $matches = r.str()
10356
+ break
10335
10357
  default:
10336
10358
  r.skip()
10337
10359
  }
@@ -10347,157 +10369,92 @@ export const SearchQuery = message(
10347
10369
  offset: $offset,
10348
10370
  limit: $limit,
10349
10371
  prefix: $prefix,
10372
+ prefixEvery: $prefixEvery,
10373
+ matches: $matches,
10350
10374
  }
10351
10375
  },
10352
10376
  },
10353
10377
  )
10354
10378
 
10355
10379
  /**
10356
- * A hit: a document and its value, or a table's row, a value a column of
10357
- * 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.
10358
10385
  */
10359
- export const SearchHit = message(
10360
- 'search.Hit',
10386
+ export const SearchMatch = message(
10387
+ 'search.Match',
10361
10388
  {
10362
- id: [1, str],
10363
- /** null for a table's row */
10364
- value: [2, str],
10365
- score: [3, float],
10366
- 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],
10367
10397
  },
10368
10398
  {
10369
10399
  write(w, v) {
10370
10400
  const head = w.openMap()
10371
10401
  let n = 0
10372
- if (v.id !== undefined) {
10402
+ if (v.field !== undefined) {
10373
10403
  w.field(1)
10374
- w.str(v.id)
10404
+ w.str(v.field)
10375
10405
  n++
10376
10406
  }
10377
- if (v.value !== undefined) {
10407
+ if (v.item !== undefined) {
10378
10408
  w.field(2)
10379
- w.str(v.value)
10409
+ w.uint(v.item)
10380
10410
  n++
10381
10411
  }
10382
- if (v.score !== undefined) {
10412
+ if (v.start !== undefined) {
10383
10413
  w.field(3)
10384
- w.float(v.score)
10414
+ w.uint(v.start)
10385
10415
  n++
10386
10416
  }
10387
- if (v.row !== undefined) {
10417
+ if (v.end !== undefined) {
10388
10418
  w.field(4)
10389
- w.array(v.row.length)
10390
- for (const item0 of v.row) {
10391
- sqlValue.write(w, item0)
10392
- }
10419
+ w.uint(v.end)
10420
+ n++
10421
+ }
10422
+ if (v.word !== undefined) {
10423
+ w.field(5)
10424
+ w.str(v.word)
10393
10425
  n++
10394
10426
  }
10395
10427
  w.closeMap(head, n)
10396
10428
  },
10397
10429
  read(r) {
10398
- let $id: string | undefined
10399
- let $value: string | undefined
10400
- let $score: number | undefined
10401
- 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
10402
10435
  for (let n = r.message(); n > 0; n--) {
10403
10436
  switch (r.field()) {
10404
10437
  case 1:
10405
- $id = r.str()
10438
+ $field = r.str()
10406
10439
  break
10407
10440
  case 2:
10408
- $value = r.str()
10441
+ $item = r.uint()
10409
10442
  break
10410
10443
  case 3:
10411
- $score = r.float()
10412
- break
10413
- case 4: {
10414
- const items0: (SqlValue | boolean)[] = []
10415
- for (let i0 = r.array(); i0 > 0; i0--) {
10416
- items0.push(sqlValue.read(r))
10417
- }
10418
- r.leave()
10419
- $row = items0
10420
- break
10421
- }
10422
- default:
10423
- r.skip()
10424
- }
10425
- }
10426
- r.leave()
10427
- return { id: $id, value: $value, score: $score, row: $row }
10428
- },
10429
- },
10430
- )
10431
-
10432
- export const SearchFound = message(
10433
- 'search.Found',
10434
- {
10435
- hits: [1, list(SearchHit)],
10436
- /** the text the search read in fact, when a word was read as another */
10437
- corrected: [2, str],
10438
- /** the columns of a table's index's rows */
10439
- columns: [3, list(str)],
10440
- },
10441
- {
10442
- write(w, v) {
10443
- const head = w.openMap()
10444
- let n = 0
10445
- if (v.hits !== undefined) {
10446
- w.field(1)
10447
- w.array(v.hits.length)
10448
- for (const item0 of v.hits) {
10449
- SearchHit.write(w, item0)
10450
- }
10451
- n++
10452
- }
10453
- if (v.corrected !== undefined) {
10454
- w.field(2)
10455
- w.str(v.corrected)
10456
- n++
10457
- }
10458
- if (v.columns !== undefined) {
10459
- w.field(3)
10460
- w.array(v.columns.length)
10461
- for (const item0 of v.columns) {
10462
- w.str(item0)
10463
- }
10464
- n++
10465
- }
10466
- w.closeMap(head, n)
10467
- },
10468
- read(r) {
10469
- let $hits: Read<typeof SearchHit.fields>[] | undefined
10470
- let $corrected: string | undefined
10471
- let $columns: string[] | undefined
10472
- for (let n = r.message(); n > 0; n--) {
10473
- switch (r.field()) {
10474
- case 1: {
10475
- const items0: Read<typeof SearchHit.fields>[] = []
10476
- for (let i0 = r.array(); i0 > 0; i0--) {
10477
- items0.push(SearchHit.read(r))
10478
- }
10479
- r.leave()
10480
- $hits = items0
10444
+ $start = r.uint()
10481
10445
  break
10482
- }
10483
- case 2:
10484
- $corrected = r.str()
10446
+ case 4:
10447
+ $end = r.uint()
10485
10448
  break
10486
- case 3: {
10487
- const items0: string[] = []
10488
- for (let i0 = r.array(); i0 > 0; i0--) {
10489
- items0.push(r.str())
10490
- }
10491
- r.leave()
10492
- $columns = items0
10449
+ case 5:
10450
+ $word = r.str()
10493
10451
  break
10494
- }
10495
10452
  default:
10496
10453
  r.skip()
10497
10454
  }
10498
10455
  }
10499
10456
  r.leave()
10500
- return { hits: $hits, corrected: $corrected, columns: $columns }
10457
+ return { field: $field, item: $item, start: $start, end: $end, word: $word }
10501
10458
  },
10502
10459
  },
10503
10460
  )
@@ -11970,6 +11927,8 @@ export const SearchOpen = message(
11970
11927
  key: [13, str],
11971
11928
  /** the column of each row's vector, a blob of little-endian floats */
11972
11929
  vectorColumn: [14, str],
11930
+ /** the keyboard layouts its readers type with: ru and en, or none */
11931
+ layouts: [15, list(str)],
11973
11932
  },
11974
11933
  {
11975
11934
  write(w, v) {
@@ -12051,6 +12010,14 @@ export const SearchOpen = message(
12051
12010
  w.str(v.vectorColumn)
12052
12011
  n++
12053
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
+ }
12054
12021
  w.closeMap(head, n)
12055
12022
  },
12056
12023
  read(r) {
@@ -12068,6 +12035,7 @@ export const SearchOpen = message(
12068
12035
  let $table: string | undefined
12069
12036
  let $key: string | undefined
12070
12037
  let $vectorColumn: string | undefined
12038
+ let $layouts: string[] | undefined
12071
12039
  for (let n = r.message(); n > 0; n--) {
12072
12040
  switch (r.field()) {
12073
12041
  case 1:
@@ -12124,6 +12092,15 @@ export const SearchOpen = message(
12124
12092
  case 14:
12125
12093
  $vectorColumn = r.str()
12126
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
+ }
12127
12104
  default:
12128
12105
  r.skip()
12129
12106
  }
@@ -12144,13 +12121,15 @@ export const SearchOpen = message(
12144
12121
  table: $table,
12145
12122
  key: $key,
12146
12123
  vectorColumn: $vectorColumn,
12124
+ layouts: $layouts,
12147
12125
  }
12148
12126
  },
12149
12127
  },
12150
12128
  )
12151
12129
 
12152
12130
  /**
12153
- * 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.
12154
12133
  */
12155
12134
  export const SearchSetMany = message(
12156
12135
  'search.SetMany',
@@ -12204,6 +12183,176 @@ export const SearchSetMany = message(
12204
12183
  },
12205
12184
  )
12206
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
+
12207
12356
  /**
12208
12357
  * A setting's line of explain.
12209
12358
  */