@tinyshed/tinystore 0.4.1 → 0.5.1
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.
- package/dist/errors.d.ts +79 -20
- package/dist/errors.js +75 -20
- package/dist/index.d.ts +1 -1
- package/dist/kv.d.ts +15 -0
- package/dist/kv.js +149 -91
- package/dist/runtime/addon.js +51 -41
- package/dist/runtime/pipe.js +116 -87
- package/dist/search.d.ts +43 -3
- package/dist/search.js +38 -8
- package/dist/session.js +13 -3
- package/dist/wire/protocol.d.ts +110 -28
- package/dist/wire/protocol.js +247 -103
- package/package.json +8 -8
- package/src/errors.ts +83 -21
- package/src/index.ts +2 -0
- package/src/kv.ts +167 -99
- package/src/runtime/addon.ts +52 -41
- package/src/runtime/pipe.ts +136 -104
- package/src/search.ts +88 -11
- package/src/session.ts +18 -2
- package/src/wire/protocol.ts +258 -109
package/dist/wire/protocol.js
CHANGED
|
@@ -9490,6 +9490,10 @@ export const SearchQuery = message('search.Query', {
|
|
|
9490
9490
|
limit: [8, uint],
|
|
9491
9491
|
/** the last word read as the start of a word too, as a search box types */
|
|
9492
9492
|
prefix: [9, bool],
|
|
9493
|
+
/** every word read so, a document holding a word for each first; in place of prefix */
|
|
9494
|
+
prefixEvery: [10, bool],
|
|
9495
|
+
/** utf8, utf16 or chars: each hit says where it matched, counted in that unit */
|
|
9496
|
+
matches: [11, str],
|
|
9493
9497
|
}, {
|
|
9494
9498
|
write(w, v) {
|
|
9495
9499
|
const head = w.openMap();
|
|
@@ -9539,6 +9543,16 @@ export const SearchQuery = message('search.Query', {
|
|
|
9539
9543
|
w.bool(v.prefix);
|
|
9540
9544
|
n++;
|
|
9541
9545
|
}
|
|
9546
|
+
if (v.prefixEvery !== undefined) {
|
|
9547
|
+
w.field(10);
|
|
9548
|
+
w.bool(v.prefixEvery);
|
|
9549
|
+
n++;
|
|
9550
|
+
}
|
|
9551
|
+
if (v.matches !== undefined) {
|
|
9552
|
+
w.field(11);
|
|
9553
|
+
w.str(v.matches);
|
|
9554
|
+
n++;
|
|
9555
|
+
}
|
|
9542
9556
|
w.closeMap(head, n);
|
|
9543
9557
|
},
|
|
9544
9558
|
read(r) {
|
|
@@ -9551,6 +9565,8 @@ export const SearchQuery = message('search.Query', {
|
|
|
9551
9565
|
let $offset;
|
|
9552
9566
|
let $limit;
|
|
9553
9567
|
let $prefix;
|
|
9568
|
+
let $prefixEvery;
|
|
9569
|
+
let $matches;
|
|
9554
9570
|
for (let n = r.message(); n > 0; n--) {
|
|
9555
9571
|
switch (r.field()) {
|
|
9556
9572
|
case 1:
|
|
@@ -9580,6 +9596,12 @@ export const SearchQuery = message('search.Query', {
|
|
|
9580
9596
|
case 9:
|
|
9581
9597
|
$prefix = r.bool();
|
|
9582
9598
|
break;
|
|
9599
|
+
case 10:
|
|
9600
|
+
$prefixEvery = r.bool();
|
|
9601
|
+
break;
|
|
9602
|
+
case 11:
|
|
9603
|
+
$matches = r.str();
|
|
9604
|
+
break;
|
|
9583
9605
|
default:
|
|
9584
9606
|
r.skip();
|
|
9585
9607
|
}
|
|
@@ -9595,147 +9617,87 @@ export const SearchQuery = message('search.Query', {
|
|
|
9595
9617
|
offset: $offset,
|
|
9596
9618
|
limit: $limit,
|
|
9597
9619
|
prefix: $prefix,
|
|
9620
|
+
prefixEvery: $prefixEvery,
|
|
9621
|
+
matches: $matches,
|
|
9598
9622
|
};
|
|
9599
9623
|
},
|
|
9600
9624
|
});
|
|
9601
9625
|
/**
|
|
9602
|
-
*
|
|
9603
|
-
*
|
|
9626
|
+
* Where a search's word matched a hit: a range of a field's text, or of a
|
|
9627
|
+
* string of a field that holds a list, counted in the unit the query asked:
|
|
9628
|
+
* bytes of UTF-8, units of UTF-16 or code points. The whole word for a word
|
|
9629
|
+
* found as written, by its stem or once corrected; the letters typed for a
|
|
9630
|
+
* word a prefix began.
|
|
9604
9631
|
*/
|
|
9605
|
-
export const
|
|
9606
|
-
|
|
9607
|
-
|
|
9608
|
-
|
|
9609
|
-
|
|
9610
|
-
|
|
9632
|
+
export const SearchMatch = message('search.Match', {
|
|
9633
|
+
/** the field's path or the table's column; empty for a document that is its own text */
|
|
9634
|
+
field: [1, str],
|
|
9635
|
+
/** the string's place in a field that holds a list */
|
|
9636
|
+
item: [2, uint],
|
|
9637
|
+
start: [3, uint],
|
|
9638
|
+
end: [4, uint],
|
|
9639
|
+
/** the query's word, as its text wrote it */
|
|
9640
|
+
word: [5, str],
|
|
9611
9641
|
}, {
|
|
9612
9642
|
write(w, v) {
|
|
9613
9643
|
const head = w.openMap();
|
|
9614
9644
|
let n = 0;
|
|
9615
|
-
if (v.
|
|
9645
|
+
if (v.field !== undefined) {
|
|
9616
9646
|
w.field(1);
|
|
9617
|
-
w.str(v.
|
|
9647
|
+
w.str(v.field);
|
|
9618
9648
|
n++;
|
|
9619
9649
|
}
|
|
9620
|
-
if (v.
|
|
9650
|
+
if (v.item !== undefined) {
|
|
9621
9651
|
w.field(2);
|
|
9622
|
-
w.
|
|
9652
|
+
w.uint(v.item);
|
|
9623
9653
|
n++;
|
|
9624
9654
|
}
|
|
9625
|
-
if (v.
|
|
9655
|
+
if (v.start !== undefined) {
|
|
9626
9656
|
w.field(3);
|
|
9627
|
-
w.
|
|
9657
|
+
w.uint(v.start);
|
|
9628
9658
|
n++;
|
|
9629
9659
|
}
|
|
9630
|
-
if (v.
|
|
9660
|
+
if (v.end !== undefined) {
|
|
9631
9661
|
w.field(4);
|
|
9632
|
-
w.
|
|
9633
|
-
|
|
9634
|
-
|
|
9635
|
-
|
|
9662
|
+
w.uint(v.end);
|
|
9663
|
+
n++;
|
|
9664
|
+
}
|
|
9665
|
+
if (v.word !== undefined) {
|
|
9666
|
+
w.field(5);
|
|
9667
|
+
w.str(v.word);
|
|
9636
9668
|
n++;
|
|
9637
9669
|
}
|
|
9638
9670
|
w.closeMap(head, n);
|
|
9639
9671
|
},
|
|
9640
9672
|
read(r) {
|
|
9641
|
-
let $
|
|
9642
|
-
let $
|
|
9643
|
-
let $
|
|
9644
|
-
let $
|
|
9673
|
+
let $field;
|
|
9674
|
+
let $item;
|
|
9675
|
+
let $start;
|
|
9676
|
+
let $end;
|
|
9677
|
+
let $word;
|
|
9645
9678
|
for (let n = r.message(); n > 0; n--) {
|
|
9646
9679
|
switch (r.field()) {
|
|
9647
9680
|
case 1:
|
|
9648
|
-
$
|
|
9681
|
+
$field = r.str();
|
|
9649
9682
|
break;
|
|
9650
9683
|
case 2:
|
|
9651
|
-
$
|
|
9684
|
+
$item = r.uint();
|
|
9652
9685
|
break;
|
|
9653
9686
|
case 3:
|
|
9654
|
-
$
|
|
9655
|
-
break;
|
|
9656
|
-
case 4: {
|
|
9657
|
-
const items0 = [];
|
|
9658
|
-
for (let i0 = r.array(); i0 > 0; i0--) {
|
|
9659
|
-
items0.push(sqlValue.read(r));
|
|
9660
|
-
}
|
|
9661
|
-
r.leave();
|
|
9662
|
-
$row = items0;
|
|
9663
|
-
break;
|
|
9664
|
-
}
|
|
9665
|
-
default:
|
|
9666
|
-
r.skip();
|
|
9667
|
-
}
|
|
9668
|
-
}
|
|
9669
|
-
r.leave();
|
|
9670
|
-
return { id: $id, value: $value, score: $score, row: $row };
|
|
9671
|
-
},
|
|
9672
|
-
});
|
|
9673
|
-
export const SearchFound = message('search.Found', {
|
|
9674
|
-
hits: [1, list(SearchHit)],
|
|
9675
|
-
/** the text the search read in fact, when a word was read as another */
|
|
9676
|
-
corrected: [2, str],
|
|
9677
|
-
/** the columns of a table's index's rows */
|
|
9678
|
-
columns: [3, list(str)],
|
|
9679
|
-
}, {
|
|
9680
|
-
write(w, v) {
|
|
9681
|
-
const head = w.openMap();
|
|
9682
|
-
let n = 0;
|
|
9683
|
-
if (v.hits !== undefined) {
|
|
9684
|
-
w.field(1);
|
|
9685
|
-
w.array(v.hits.length);
|
|
9686
|
-
for (const item0 of v.hits) {
|
|
9687
|
-
SearchHit.write(w, item0);
|
|
9688
|
-
}
|
|
9689
|
-
n++;
|
|
9690
|
-
}
|
|
9691
|
-
if (v.corrected !== undefined) {
|
|
9692
|
-
w.field(2);
|
|
9693
|
-
w.str(v.corrected);
|
|
9694
|
-
n++;
|
|
9695
|
-
}
|
|
9696
|
-
if (v.columns !== undefined) {
|
|
9697
|
-
w.field(3);
|
|
9698
|
-
w.array(v.columns.length);
|
|
9699
|
-
for (const item0 of v.columns) {
|
|
9700
|
-
w.str(item0);
|
|
9701
|
-
}
|
|
9702
|
-
n++;
|
|
9703
|
-
}
|
|
9704
|
-
w.closeMap(head, n);
|
|
9705
|
-
},
|
|
9706
|
-
read(r) {
|
|
9707
|
-
let $hits;
|
|
9708
|
-
let $corrected;
|
|
9709
|
-
let $columns;
|
|
9710
|
-
for (let n = r.message(); n > 0; n--) {
|
|
9711
|
-
switch (r.field()) {
|
|
9712
|
-
case 1: {
|
|
9713
|
-
const items0 = [];
|
|
9714
|
-
for (let i0 = r.array(); i0 > 0; i0--) {
|
|
9715
|
-
items0.push(SearchHit.read(r));
|
|
9716
|
-
}
|
|
9717
|
-
r.leave();
|
|
9718
|
-
$hits = items0;
|
|
9687
|
+
$start = r.uint();
|
|
9719
9688
|
break;
|
|
9720
|
-
|
|
9721
|
-
|
|
9722
|
-
$corrected = r.str();
|
|
9689
|
+
case 4:
|
|
9690
|
+
$end = r.uint();
|
|
9723
9691
|
break;
|
|
9724
|
-
case
|
|
9725
|
-
|
|
9726
|
-
for (let i0 = r.array(); i0 > 0; i0--) {
|
|
9727
|
-
items0.push(r.str());
|
|
9728
|
-
}
|
|
9729
|
-
r.leave();
|
|
9730
|
-
$columns = items0;
|
|
9692
|
+
case 5:
|
|
9693
|
+
$word = r.str();
|
|
9731
9694
|
break;
|
|
9732
|
-
}
|
|
9733
9695
|
default:
|
|
9734
9696
|
r.skip();
|
|
9735
9697
|
}
|
|
9736
9698
|
}
|
|
9737
9699
|
r.leave();
|
|
9738
|
-
return {
|
|
9700
|
+
return { field: $field, item: $item, start: $start, end: $end, word: $word };
|
|
9739
9701
|
},
|
|
9740
9702
|
});
|
|
9741
9703
|
/**
|
|
@@ -11089,6 +11051,8 @@ export const SearchOpen = message('search.Open', {
|
|
|
11089
11051
|
key: [13, str],
|
|
11090
11052
|
/** the column of each row's vector, a blob of little-endian floats */
|
|
11091
11053
|
vectorColumn: [14, str],
|
|
11054
|
+
/** the keyboard layouts its readers type with: ru and en, or none */
|
|
11055
|
+
layouts: [15, list(str)],
|
|
11092
11056
|
}, {
|
|
11093
11057
|
write(w, v) {
|
|
11094
11058
|
const head = w.openMap();
|
|
@@ -11169,6 +11133,14 @@ export const SearchOpen = message('search.Open', {
|
|
|
11169
11133
|
w.str(v.vectorColumn);
|
|
11170
11134
|
n++;
|
|
11171
11135
|
}
|
|
11136
|
+
if (v.layouts !== undefined) {
|
|
11137
|
+
w.field(15);
|
|
11138
|
+
w.array(v.layouts.length);
|
|
11139
|
+
for (const item0 of v.layouts) {
|
|
11140
|
+
w.str(item0);
|
|
11141
|
+
}
|
|
11142
|
+
n++;
|
|
11143
|
+
}
|
|
11172
11144
|
w.closeMap(head, n);
|
|
11173
11145
|
},
|
|
11174
11146
|
read(r) {
|
|
@@ -11186,6 +11158,7 @@ export const SearchOpen = message('search.Open', {
|
|
|
11186
11158
|
let $table;
|
|
11187
11159
|
let $key;
|
|
11188
11160
|
let $vectorColumn;
|
|
11161
|
+
let $layouts;
|
|
11189
11162
|
for (let n = r.message(); n > 0; n--) {
|
|
11190
11163
|
switch (r.field()) {
|
|
11191
11164
|
case 1:
|
|
@@ -11242,6 +11215,15 @@ export const SearchOpen = message('search.Open', {
|
|
|
11242
11215
|
case 14:
|
|
11243
11216
|
$vectorColumn = r.str();
|
|
11244
11217
|
break;
|
|
11218
|
+
case 15: {
|
|
11219
|
+
const items0 = [];
|
|
11220
|
+
for (let i0 = r.array(); i0 > 0; i0--) {
|
|
11221
|
+
items0.push(r.str());
|
|
11222
|
+
}
|
|
11223
|
+
r.leave();
|
|
11224
|
+
$layouts = items0;
|
|
11225
|
+
break;
|
|
11226
|
+
}
|
|
11245
11227
|
default:
|
|
11246
11228
|
r.skip();
|
|
11247
11229
|
}
|
|
@@ -11262,11 +11244,13 @@ export const SearchOpen = message('search.Open', {
|
|
|
11262
11244
|
table: $table,
|
|
11263
11245
|
key: $key,
|
|
11264
11246
|
vectorColumn: $vectorColumn,
|
|
11247
|
+
layouts: $layouts,
|
|
11265
11248
|
};
|
|
11266
11249
|
},
|
|
11267
11250
|
});
|
|
11268
11251
|
/**
|
|
11269
|
-
* Documents set in one commit, all of them or none: 1,000
|
|
11252
|
+
* Documents set in one commit, all of them or none: 1,000 at most, and no more
|
|
11253
|
+
* than one request body holds, 2 MiB from every SDK.
|
|
11270
11254
|
*/
|
|
11271
11255
|
export const SearchSetMany = message('search.SetMany', {
|
|
11272
11256
|
handle: [1, uint],
|
|
@@ -11315,6 +11299,166 @@ export const SearchSetMany = message('search.SetMany', {
|
|
|
11315
11299
|
return { handle: $handle, documents: $documents };
|
|
11316
11300
|
},
|
|
11317
11301
|
});
|
|
11302
|
+
/**
|
|
11303
|
+
* A hit: a document and its value, or a table's row, a value a column of
|
|
11304
|
+
* the answer's columns, as sql.Rows holds one, and where the search's words
|
|
11305
|
+
* matched it when the query asked.
|
|
11306
|
+
*/
|
|
11307
|
+
export const SearchHit = message('search.Hit', {
|
|
11308
|
+
id: [1, str],
|
|
11309
|
+
/** null for a table's row */
|
|
11310
|
+
value: [2, str],
|
|
11311
|
+
score: [3, float],
|
|
11312
|
+
row: [4, list(sqlValue)],
|
|
11313
|
+
matches: [5, list(SearchMatch)],
|
|
11314
|
+
}, {
|
|
11315
|
+
write(w, v) {
|
|
11316
|
+
const head = w.openMap();
|
|
11317
|
+
let n = 0;
|
|
11318
|
+
if (v.id !== undefined) {
|
|
11319
|
+
w.field(1);
|
|
11320
|
+
w.str(v.id);
|
|
11321
|
+
n++;
|
|
11322
|
+
}
|
|
11323
|
+
if (v.value !== undefined) {
|
|
11324
|
+
w.field(2);
|
|
11325
|
+
w.str(v.value);
|
|
11326
|
+
n++;
|
|
11327
|
+
}
|
|
11328
|
+
if (v.score !== undefined) {
|
|
11329
|
+
w.field(3);
|
|
11330
|
+
w.float(v.score);
|
|
11331
|
+
n++;
|
|
11332
|
+
}
|
|
11333
|
+
if (v.row !== undefined) {
|
|
11334
|
+
w.field(4);
|
|
11335
|
+
w.array(v.row.length);
|
|
11336
|
+
for (const item0 of v.row) {
|
|
11337
|
+
sqlValue.write(w, item0);
|
|
11338
|
+
}
|
|
11339
|
+
n++;
|
|
11340
|
+
}
|
|
11341
|
+
if (v.matches !== undefined) {
|
|
11342
|
+
w.field(5);
|
|
11343
|
+
w.array(v.matches.length);
|
|
11344
|
+
for (const item0 of v.matches) {
|
|
11345
|
+
SearchMatch.write(w, item0);
|
|
11346
|
+
}
|
|
11347
|
+
n++;
|
|
11348
|
+
}
|
|
11349
|
+
w.closeMap(head, n);
|
|
11350
|
+
},
|
|
11351
|
+
read(r) {
|
|
11352
|
+
let $id;
|
|
11353
|
+
let $value;
|
|
11354
|
+
let $score;
|
|
11355
|
+
let $row;
|
|
11356
|
+
let $matches;
|
|
11357
|
+
for (let n = r.message(); n > 0; n--) {
|
|
11358
|
+
switch (r.field()) {
|
|
11359
|
+
case 1:
|
|
11360
|
+
$id = r.str();
|
|
11361
|
+
break;
|
|
11362
|
+
case 2:
|
|
11363
|
+
$value = r.str();
|
|
11364
|
+
break;
|
|
11365
|
+
case 3:
|
|
11366
|
+
$score = r.float();
|
|
11367
|
+
break;
|
|
11368
|
+
case 4: {
|
|
11369
|
+
const items0 = [];
|
|
11370
|
+
for (let i0 = r.array(); i0 > 0; i0--) {
|
|
11371
|
+
items0.push(sqlValue.read(r));
|
|
11372
|
+
}
|
|
11373
|
+
r.leave();
|
|
11374
|
+
$row = items0;
|
|
11375
|
+
break;
|
|
11376
|
+
}
|
|
11377
|
+
case 5: {
|
|
11378
|
+
const items0 = [];
|
|
11379
|
+
for (let i0 = r.array(); i0 > 0; i0--) {
|
|
11380
|
+
items0.push(SearchMatch.read(r));
|
|
11381
|
+
}
|
|
11382
|
+
r.leave();
|
|
11383
|
+
$matches = items0;
|
|
11384
|
+
break;
|
|
11385
|
+
}
|
|
11386
|
+
default:
|
|
11387
|
+
r.skip();
|
|
11388
|
+
}
|
|
11389
|
+
}
|
|
11390
|
+
r.leave();
|
|
11391
|
+
return { id: $id, value: $value, score: $score, row: $row, matches: $matches };
|
|
11392
|
+
},
|
|
11393
|
+
});
|
|
11394
|
+
export const SearchFound = message('search.Found', {
|
|
11395
|
+
hits: [1, list(SearchHit)],
|
|
11396
|
+
/** the text the search read in fact, when a word was read as another */
|
|
11397
|
+
corrected: [2, str],
|
|
11398
|
+
/** the columns of a table's index's rows */
|
|
11399
|
+
columns: [3, list(str)],
|
|
11400
|
+
}, {
|
|
11401
|
+
write(w, v) {
|
|
11402
|
+
const head = w.openMap();
|
|
11403
|
+
let n = 0;
|
|
11404
|
+
if (v.hits !== undefined) {
|
|
11405
|
+
w.field(1);
|
|
11406
|
+
w.array(v.hits.length);
|
|
11407
|
+
for (const item0 of v.hits) {
|
|
11408
|
+
SearchHit.write(w, item0);
|
|
11409
|
+
}
|
|
11410
|
+
n++;
|
|
11411
|
+
}
|
|
11412
|
+
if (v.corrected !== undefined) {
|
|
11413
|
+
w.field(2);
|
|
11414
|
+
w.str(v.corrected);
|
|
11415
|
+
n++;
|
|
11416
|
+
}
|
|
11417
|
+
if (v.columns !== undefined) {
|
|
11418
|
+
w.field(3);
|
|
11419
|
+
w.array(v.columns.length);
|
|
11420
|
+
for (const item0 of v.columns) {
|
|
11421
|
+
w.str(item0);
|
|
11422
|
+
}
|
|
11423
|
+
n++;
|
|
11424
|
+
}
|
|
11425
|
+
w.closeMap(head, n);
|
|
11426
|
+
},
|
|
11427
|
+
read(r) {
|
|
11428
|
+
let $hits;
|
|
11429
|
+
let $corrected;
|
|
11430
|
+
let $columns;
|
|
11431
|
+
for (let n = r.message(); n > 0; n--) {
|
|
11432
|
+
switch (r.field()) {
|
|
11433
|
+
case 1: {
|
|
11434
|
+
const items0 = [];
|
|
11435
|
+
for (let i0 = r.array(); i0 > 0; i0--) {
|
|
11436
|
+
items0.push(SearchHit.read(r));
|
|
11437
|
+
}
|
|
11438
|
+
r.leave();
|
|
11439
|
+
$hits = items0;
|
|
11440
|
+
break;
|
|
11441
|
+
}
|
|
11442
|
+
case 2:
|
|
11443
|
+
$corrected = r.str();
|
|
11444
|
+
break;
|
|
11445
|
+
case 3: {
|
|
11446
|
+
const items0 = [];
|
|
11447
|
+
for (let i0 = r.array(); i0 > 0; i0--) {
|
|
11448
|
+
items0.push(r.str());
|
|
11449
|
+
}
|
|
11450
|
+
r.leave();
|
|
11451
|
+
$columns = items0;
|
|
11452
|
+
break;
|
|
11453
|
+
}
|
|
11454
|
+
default:
|
|
11455
|
+
r.skip();
|
|
11456
|
+
}
|
|
11457
|
+
}
|
|
11458
|
+
r.leave();
|
|
11459
|
+
return { hits: $hits, corrected: $corrected, columns: $columns };
|
|
11460
|
+
},
|
|
11461
|
+
});
|
|
11318
11462
|
/**
|
|
11319
11463
|
* A setting's line of explain.
|
|
11320
11464
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinyshed/tinystore",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "TinyStore for Bun and Node: kv, jobs, blobs, SQL, records and metrics in one directory, served by a sidecar",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://tinyshed.org/tinystore",
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
"README.md"
|
|
32
32
|
],
|
|
33
33
|
"optionalDependencies": {
|
|
34
|
-
"@tinyshed/tinystore-linux-x64": "0.
|
|
35
|
-
"@tinyshed/tinystore-linux-arm64": "0.
|
|
36
|
-
"@tinyshed/tinystore-linux-x64-musl": "0.
|
|
37
|
-
"@tinyshed/tinystore-linux-arm64-musl": "0.
|
|
38
|
-
"@tinyshed/tinystore-darwin-arm64": "0.
|
|
39
|
-
"@tinyshed/tinystore-darwin-x64": "0.
|
|
40
|
-
"@tinyshed/tinystore-win32-x64": "0.
|
|
34
|
+
"@tinyshed/tinystore-linux-x64": "0.5.1",
|
|
35
|
+
"@tinyshed/tinystore-linux-arm64": "0.5.1",
|
|
36
|
+
"@tinyshed/tinystore-linux-x64-musl": "0.5.1",
|
|
37
|
+
"@tinyshed/tinystore-linux-arm64-musl": "0.5.1",
|
|
38
|
+
"@tinyshed/tinystore-darwin-arm64": "0.5.1",
|
|
39
|
+
"@tinyshed/tinystore-darwin-x64": "0.5.1",
|
|
40
|
+
"@tinyshed/tinystore-win32-x64": "0.5.1"
|
|
41
41
|
}
|
|
42
42
|
}
|
package/src/errors.ts
CHANGED
|
@@ -98,9 +98,10 @@ export class InvalidError extends TinystoreError {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
|
-
* A bound: memory, size or count. Later, or smaller, it may go through.
|
|
102
|
-
*
|
|
103
|
-
*
|
|
101
|
+
* A bound: memory, size or count. Later, or smaller, it may go through. The
|
|
102
|
+
* error names the bound, what the call would have taken of it, and the
|
|
103
|
+
* bound: `set_many documents`, 1001, 1000. `limits` holds the bounds a call
|
|
104
|
+
* meets by those names.
|
|
104
105
|
*/
|
|
105
106
|
export class LimitError extends TinystoreError {
|
|
106
107
|
readonly limit: string | undefined
|
|
@@ -115,30 +116,91 @@ export class LimitError extends TinystoreError {
|
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
|
|
119
|
+
/** A bound one call meets: its name, as a LimitError's `limit` says it, and the most it takes. */
|
|
120
|
+
export interface Limit {
|
|
121
|
+
readonly name: string
|
|
122
|
+
readonly bound: number
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const limit = (name: string, bound: number): Limit => Object.freeze({ name, bound })
|
|
126
|
+
|
|
118
127
|
/**
|
|
119
|
-
* The
|
|
120
|
-
* `tinystore
|
|
128
|
+
* The bounds one call meets, the same in every SDK and in Rust's
|
|
129
|
+
* `tinystore::limits`. A program cuts its batches to them before it calls,
|
|
130
|
+
* and tells which bound a LimitError met without reading its text:
|
|
121
131
|
*
|
|
122
132
|
* ```ts
|
|
123
|
-
*
|
|
133
|
+
* for (let at = 0; at < courses.length; at += limits.setManyDocuments.bound) { … }
|
|
134
|
+
* if (err instanceof LimitError && err.limit === limits.requestBytes.name) { … }
|
|
124
135
|
* ```
|
|
136
|
+
*
|
|
137
|
+
* A bound the store's options set, its memory (`store memory`) or its
|
|
138
|
+
* `maxSeries` (`series in a store`), is named the same way and is not here.
|
|
125
139
|
*/
|
|
126
140
|
export const limits = Object.freeze({
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
141
|
+
/** A bucket's value, as it is stored. */
|
|
142
|
+
valueBytes: limit('value bytes', 1 << 20),
|
|
143
|
+
/** A live setting's change, as JSON. */
|
|
144
|
+
settingBytes: limit('setting bytes', 16 << 10),
|
|
145
|
+
/** Every change a config keeps, together. */
|
|
146
|
+
configBytes: limit('config bytes', 256 << 10),
|
|
147
|
+
/** The callers that wait for one lock or semaphore at once. */
|
|
148
|
+
lockWaiters: limit('lock waiters', 10_000),
|
|
149
|
+
/** The subscriptions to the store's channels at once. */
|
|
150
|
+
subscriptions: limit('subscriptions', 10_000),
|
|
151
|
+
/** A job's payload, its result or a step's answer, as JSON. */
|
|
152
|
+
jobBytes: limit('job bytes', 1 << 20),
|
|
153
|
+
/** A run's progress, as JSON. */
|
|
154
|
+
progressBytes: limit('progress bytes', 4 << 10),
|
|
155
|
+
/** The values one call reads from a database: past them, read a page at a time. */
|
|
156
|
+
rowsBytes: limit("bytes of a call's rows", 64 << 20),
|
|
157
|
+
/** One event, its name, fields and text together. */
|
|
158
|
+
eventBytes: limit('event bytes', 256 << 10),
|
|
159
|
+
/** The events of one append together. */
|
|
160
|
+
appendBytes: limit('append bytes', 4 << 20),
|
|
161
|
+
/** The rows one `aggregate` answers. */
|
|
162
|
+
aggregateRows: limit('aggregate rows', 10_000),
|
|
163
|
+
/** The different values one `top` or `distinct` holds, as JSON. */
|
|
164
|
+
countBytes: limit('count bytes', 64 << 20),
|
|
165
|
+
/** The samples of one `ingest`. */
|
|
166
|
+
ingestSamples: limit('ingest samples', 10_000),
|
|
167
|
+
/** The bytes of one `ingest`'s samples, each with its labels. */
|
|
168
|
+
ingestBytes: limit('ingest bytes', 4 << 20),
|
|
169
|
+
/** The samples of one exporter's text. */
|
|
170
|
+
textSamples: limit('text samples', 100_000),
|
|
171
|
+
/** One exporter's text, and the bytes of its samples. */
|
|
172
|
+
textBytes: limit('text bytes', 32 << 20),
|
|
173
|
+
/** The series one query finds. */
|
|
174
|
+
querySeries: limit('series', 1000),
|
|
175
|
+
/** What one query reads from the file. */
|
|
176
|
+
queryBytes: limit('bytes read', 16 << 20),
|
|
177
|
+
/** The samples one query decodes. */
|
|
178
|
+
querySamples: limit('samples decoded', 1 << 20),
|
|
179
|
+
/** The samples or buckets one query answers. */
|
|
180
|
+
queryAnswer: limit('answer', 100_000),
|
|
181
|
+
/** The documents of one `setMany`. */
|
|
182
|
+
setManyDocuments: limit('set_many documents', 1000),
|
|
183
|
+
/** The documents of one `setMany` as JSON; one request body, `requestBytes`, bounds it first. */
|
|
184
|
+
setManyBytes: limit('set_many bytes', 16 << 20),
|
|
185
|
+
/** One document as JSON, or a table's row as its index reads it. */
|
|
186
|
+
documentBytes: limit('document bytes', 1 << 20),
|
|
187
|
+
/** The hits a search reaches, its offset and its limit together. */
|
|
188
|
+
searchHits: limit('search hits', 1000),
|
|
189
|
+
/** A search's text, in bytes. */
|
|
190
|
+
searchText: limit('search text', 1 << 10),
|
|
191
|
+
/** The conditions of one search's filter. */
|
|
192
|
+
filterConditions: limit('filter conditions', 8),
|
|
193
|
+
/** The values the lists of one search's conditions hold together. */
|
|
194
|
+
filterValues: limit('filter values', 100),
|
|
195
|
+
/** A text a filter keeps or asks for, in bytes. */
|
|
196
|
+
filterText: limit('filter text', 256),
|
|
197
|
+
/** A vector's dimensions. */
|
|
198
|
+
vectorDimensions: limit('vector dimensions', 4096),
|
|
199
|
+
/** One request, its message as the SDK sends it: a larger one fails before it is sent. */
|
|
200
|
+
requestBytes: limit('request bytes', 2 << 20),
|
|
201
|
+
/** One answer, its message as the store sends it. */
|
|
202
|
+
answerBytes: limit('answer bytes', 2 << 20),
|
|
203
|
+
})
|
|
142
204
|
|
|
143
205
|
/** What the call needs is not there: a file to copy or rename. */
|
|
144
206
|
export class NotFoundError extends TinystoreError {
|