@tinyshed/tinystore 0.2.0 → 0.4.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.
- package/README.md +2 -2
- package/dist/blobs.d.ts +19 -2
- package/dist/blobs.js +58 -9
- package/dist/connection.d.ts +2 -0
- package/dist/connection.js +7 -1
- package/dist/index.d.ts +1 -1
- package/dist/kv.d.ts +9 -0
- package/dist/kv.js +14 -1
- package/dist/metrics.d.ts +34 -3
- package/dist/metrics.js +52 -9
- package/dist/sql.d.ts +11 -0
- package/dist/sql.js +20 -1
- package/dist/store.d.ts +8 -0
- package/dist/store.js +1 -0
- package/dist/wire/protocol.d.ts +31 -3
- package/dist/wire/protocol.js +140 -6
- package/package.json +8 -8
- package/src/blobs.ts +88 -11
- package/src/connection.ts +9 -1
- package/src/index.ts +2 -0
- package/src/kv.ts +21 -0
- package/src/metrics.ts +101 -13
- package/src/sql.ts +26 -3
- package/src/store.ts +9 -0
- package/src/wire/protocol.ts +145 -6
package/src/wire/protocol.ts
CHANGED
|
@@ -78,6 +78,7 @@ export const methods = {
|
|
|
78
78
|
'kv.expire': 0x0108,
|
|
79
79
|
'kv.clear': 0x0109,
|
|
80
80
|
'kv.list': 0x010a,
|
|
81
|
+
'kv.reseal': 0x010b,
|
|
81
82
|
'kv.counters.open': 0x0110,
|
|
82
83
|
'kv.counters.add': 0x0111,
|
|
83
84
|
'kv.counters.get': 0x0112,
|
|
@@ -332,6 +333,8 @@ export const BlobsOpen = message(
|
|
|
332
333
|
ttl: [2, uint],
|
|
333
334
|
/** the largest file a write may leave */
|
|
334
335
|
maxFileSize: [3, uint],
|
|
336
|
+
/** a database's handle: the files live in its file, and put, head, delete, copy and rename join its transactions; blobs.db when absent */
|
|
337
|
+
database: [4, uint],
|
|
335
338
|
},
|
|
336
339
|
{
|
|
337
340
|
write(w, v) {
|
|
@@ -352,12 +355,18 @@ export const BlobsOpen = message(
|
|
|
352
355
|
w.uint(v.maxFileSize)
|
|
353
356
|
n++
|
|
354
357
|
}
|
|
358
|
+
if (v.database !== undefined) {
|
|
359
|
+
w.field(4)
|
|
360
|
+
w.uint(v.database)
|
|
361
|
+
n++
|
|
362
|
+
}
|
|
355
363
|
w.closeMap(head, n)
|
|
356
364
|
},
|
|
357
365
|
read(r) {
|
|
358
366
|
let $name: string | undefined
|
|
359
367
|
let $ttl: number | undefined
|
|
360
368
|
let $maxFileSize: number | undefined
|
|
369
|
+
let $database: number | undefined
|
|
361
370
|
for (let n = r.message(); n > 0; n--) {
|
|
362
371
|
switch (r.field()) {
|
|
363
372
|
case 1:
|
|
@@ -369,12 +378,15 @@ export const BlobsOpen = message(
|
|
|
369
378
|
case 3:
|
|
370
379
|
$maxFileSize = r.uint()
|
|
371
380
|
break
|
|
381
|
+
case 4:
|
|
382
|
+
$database = r.uint()
|
|
383
|
+
break
|
|
372
384
|
default:
|
|
373
385
|
r.skip()
|
|
374
386
|
}
|
|
375
387
|
}
|
|
376
388
|
r.leave()
|
|
377
|
-
return { name: $name, ttl: $ttl, maxFileSize: $maxFileSize }
|
|
389
|
+
return { name: $name, ttl: $ttl, maxFileSize: $maxFileSize, database: $database }
|
|
378
390
|
},
|
|
379
391
|
},
|
|
380
392
|
)
|
|
@@ -1665,6 +1677,8 @@ export const ConfigOpen = message(
|
|
|
1665
1677
|
layers: [3, str],
|
|
1666
1678
|
/** a kept change that no longer fits refuses the open */
|
|
1667
1679
|
strict: [4, bool],
|
|
1680
|
+
/** as kv.db keeps it, for a command: the last declaration a program opened it with, */
|
|
1681
|
+
kept: [5, bool],
|
|
1668
1682
|
},
|
|
1669
1683
|
{
|
|
1670
1684
|
write(w, v) {
|
|
@@ -1690,6 +1704,11 @@ export const ConfigOpen = message(
|
|
|
1690
1704
|
w.bool(v.strict)
|
|
1691
1705
|
n++
|
|
1692
1706
|
}
|
|
1707
|
+
if (v.kept !== undefined) {
|
|
1708
|
+
w.field(5)
|
|
1709
|
+
w.bool(v.kept)
|
|
1710
|
+
n++
|
|
1711
|
+
}
|
|
1693
1712
|
w.closeMap(head, n)
|
|
1694
1713
|
},
|
|
1695
1714
|
read(r) {
|
|
@@ -1697,6 +1716,7 @@ export const ConfigOpen = message(
|
|
|
1697
1716
|
let $declaration: string | undefined
|
|
1698
1717
|
let $layers: string | undefined
|
|
1699
1718
|
let $strict: boolean | undefined
|
|
1719
|
+
let $kept: boolean | undefined
|
|
1700
1720
|
for (let n = r.message(); n > 0; n--) {
|
|
1701
1721
|
switch (r.field()) {
|
|
1702
1722
|
case 1:
|
|
@@ -1711,12 +1731,21 @@ export const ConfigOpen = message(
|
|
|
1711
1731
|
case 4:
|
|
1712
1732
|
$strict = r.bool()
|
|
1713
1733
|
break
|
|
1734
|
+
case 5:
|
|
1735
|
+
$kept = r.bool()
|
|
1736
|
+
break
|
|
1714
1737
|
default:
|
|
1715
1738
|
r.skip()
|
|
1716
1739
|
}
|
|
1717
1740
|
}
|
|
1718
1741
|
r.leave()
|
|
1719
|
-
return {
|
|
1742
|
+
return {
|
|
1743
|
+
name: $name,
|
|
1744
|
+
declaration: $declaration,
|
|
1745
|
+
layers: $layers,
|
|
1746
|
+
strict: $strict,
|
|
1747
|
+
kept: $kept,
|
|
1748
|
+
}
|
|
1720
1749
|
},
|
|
1721
1750
|
},
|
|
1722
1751
|
)
|
|
@@ -2265,6 +2294,8 @@ export const StoreOptions = message(
|
|
|
2265
2294
|
withoutSystem: [14, bool],
|
|
2266
2295
|
/** the metrics series the store holds at most; 100,000 when absent */
|
|
2267
2296
|
maxSeries: [15, uint],
|
|
2297
|
+
/** the files of the store's older keys, which open the values they sealed and seal none */
|
|
2298
|
+
olderEncryptionKeys: [16, list(str)],
|
|
2268
2299
|
},
|
|
2269
2300
|
{
|
|
2270
2301
|
write(w, v) {
|
|
@@ -2354,6 +2385,14 @@ export const StoreOptions = message(
|
|
|
2354
2385
|
w.uint(v.maxSeries)
|
|
2355
2386
|
n++
|
|
2356
2387
|
}
|
|
2388
|
+
if (v.olderEncryptionKeys !== undefined) {
|
|
2389
|
+
w.field(16)
|
|
2390
|
+
w.array(v.olderEncryptionKeys.length)
|
|
2391
|
+
for (const item0 of v.olderEncryptionKeys) {
|
|
2392
|
+
w.str(item0)
|
|
2393
|
+
}
|
|
2394
|
+
n++
|
|
2395
|
+
}
|
|
2357
2396
|
w.closeMap(head, n)
|
|
2358
2397
|
},
|
|
2359
2398
|
read(r) {
|
|
@@ -2372,6 +2411,7 @@ export const StoreOptions = message(
|
|
|
2372
2411
|
let $selfMetrics: boolean | undefined
|
|
2373
2412
|
let $withoutSystem: boolean | undefined
|
|
2374
2413
|
let $maxSeries: number | undefined
|
|
2414
|
+
let $olderEncryptionKeys: string[] | undefined
|
|
2375
2415
|
for (let n = r.message(); n > 0; n--) {
|
|
2376
2416
|
switch (r.field()) {
|
|
2377
2417
|
case 1:
|
|
@@ -2437,6 +2477,15 @@ export const StoreOptions = message(
|
|
|
2437
2477
|
case 15:
|
|
2438
2478
|
$maxSeries = r.uint()
|
|
2439
2479
|
break
|
|
2480
|
+
case 16: {
|
|
2481
|
+
const items0: string[] = []
|
|
2482
|
+
for (let i0 = r.array(); i0 > 0; i0--) {
|
|
2483
|
+
items0.push(r.str())
|
|
2484
|
+
}
|
|
2485
|
+
r.leave()
|
|
2486
|
+
$olderEncryptionKeys = items0
|
|
2487
|
+
break
|
|
2488
|
+
}
|
|
2440
2489
|
default:
|
|
2441
2490
|
r.skip()
|
|
2442
2491
|
}
|
|
@@ -2458,6 +2507,7 @@ export const StoreOptions = message(
|
|
|
2458
2507
|
selfMetrics: $selfMetrics,
|
|
2459
2508
|
withoutSystem: $withoutSystem,
|
|
2460
2509
|
maxSeries: $maxSeries,
|
|
2510
|
+
olderEncryptionKeys: $olderEncryptionKeys,
|
|
2461
2511
|
}
|
|
2462
2512
|
},
|
|
2463
2513
|
},
|
|
@@ -4442,6 +4492,42 @@ export const KvFound = message(
|
|
|
4442
4492
|
},
|
|
4443
4493
|
)
|
|
4444
4494
|
|
|
4495
|
+
/**
|
|
4496
|
+
* How many values a reseal sealed again with the sealing key.
|
|
4497
|
+
*/
|
|
4498
|
+
export const KvResealed = message(
|
|
4499
|
+
'kv.Resealed',
|
|
4500
|
+
{
|
|
4501
|
+
count: [1, uint],
|
|
4502
|
+
},
|
|
4503
|
+
{
|
|
4504
|
+
write(w, v) {
|
|
4505
|
+
const head = w.openMap()
|
|
4506
|
+
let n = 0
|
|
4507
|
+
if (v.count !== undefined) {
|
|
4508
|
+
w.field(1)
|
|
4509
|
+
w.uint(v.count)
|
|
4510
|
+
n++
|
|
4511
|
+
}
|
|
4512
|
+
w.closeMap(head, n)
|
|
4513
|
+
},
|
|
4514
|
+
read(r) {
|
|
4515
|
+
let $count: number | undefined
|
|
4516
|
+
for (let n = r.message(); n > 0; n--) {
|
|
4517
|
+
switch (r.field()) {
|
|
4518
|
+
case 1:
|
|
4519
|
+
$count = r.uint()
|
|
4520
|
+
break
|
|
4521
|
+
default:
|
|
4522
|
+
r.skip()
|
|
4523
|
+
}
|
|
4524
|
+
}
|
|
4525
|
+
r.leave()
|
|
4526
|
+
return { count: $count }
|
|
4527
|
+
},
|
|
4528
|
+
},
|
|
4529
|
+
)
|
|
4530
|
+
|
|
4445
4531
|
/**
|
|
4446
4532
|
* A branch of a handle, for a clear.
|
|
4447
4533
|
*/
|
|
@@ -5825,6 +5911,10 @@ export const MetricsQuery = message(
|
|
|
5825
5911
|
from: [4, int],
|
|
5826
5912
|
/** excluded; now, a sample taken now in the range, unless given */
|
|
5827
5913
|
to: [5, int],
|
|
5914
|
+
/** a page's samples or buckets at most, 100,000 at most: a page, which read and aggregate take */
|
|
5915
|
+
limit: [6, uint],
|
|
5916
|
+
/** a page's next, with limit */
|
|
5917
|
+
after: [7, str],
|
|
5828
5918
|
},
|
|
5829
5919
|
{
|
|
5830
5920
|
write(w, v) {
|
|
@@ -5855,6 +5945,16 @@ export const MetricsQuery = message(
|
|
|
5855
5945
|
w.int(v.to)
|
|
5856
5946
|
n++
|
|
5857
5947
|
}
|
|
5948
|
+
if (v.limit !== undefined) {
|
|
5949
|
+
w.field(6)
|
|
5950
|
+
w.uint(v.limit)
|
|
5951
|
+
n++
|
|
5952
|
+
}
|
|
5953
|
+
if (v.after !== undefined) {
|
|
5954
|
+
w.field(7)
|
|
5955
|
+
w.str(v.after)
|
|
5956
|
+
n++
|
|
5957
|
+
}
|
|
5858
5958
|
w.closeMap(head, n)
|
|
5859
5959
|
},
|
|
5860
5960
|
read(r) {
|
|
@@ -5863,6 +5963,8 @@ export const MetricsQuery = message(
|
|
|
5863
5963
|
let $since: number | undefined
|
|
5864
5964
|
let $from: number | undefined
|
|
5865
5965
|
let $to: number | undefined
|
|
5966
|
+
let $limit: number | undefined
|
|
5967
|
+
let $after: string | undefined
|
|
5866
5968
|
for (let n = r.message(); n > 0; n--) {
|
|
5867
5969
|
switch (r.field()) {
|
|
5868
5970
|
case 1:
|
|
@@ -5880,12 +5982,26 @@ export const MetricsQuery = message(
|
|
|
5880
5982
|
case 5:
|
|
5881
5983
|
$to = r.int()
|
|
5882
5984
|
break
|
|
5985
|
+
case 6:
|
|
5986
|
+
$limit = r.uint()
|
|
5987
|
+
break
|
|
5988
|
+
case 7:
|
|
5989
|
+
$after = r.str()
|
|
5990
|
+
break
|
|
5883
5991
|
default:
|
|
5884
5992
|
r.skip()
|
|
5885
5993
|
}
|
|
5886
5994
|
}
|
|
5887
5995
|
r.leave()
|
|
5888
|
-
return {
|
|
5996
|
+
return {
|
|
5997
|
+
name: $name,
|
|
5998
|
+
where: $where,
|
|
5999
|
+
since: $since,
|
|
6000
|
+
from: $from,
|
|
6001
|
+
to: $to,
|
|
6002
|
+
limit: $limit,
|
|
6003
|
+
after: $after,
|
|
6004
|
+
}
|
|
5889
6005
|
},
|
|
5890
6006
|
},
|
|
5891
6007
|
)
|
|
@@ -5905,7 +6021,7 @@ export const MetricsSeries = message(
|
|
|
5905
6021
|
times: [4, bin],
|
|
5906
6022
|
/** a float64 a sample */
|
|
5907
6023
|
values: [5, bin],
|
|
5908
|
-
/** the next part goes on with this series */
|
|
6024
|
+
/** the next part goes on with this series; on a page's last, the next page's first */
|
|
5909
6025
|
more: [6, bool],
|
|
5910
6026
|
},
|
|
5911
6027
|
{
|
|
@@ -5992,6 +6108,8 @@ export const MetricsRead = message(
|
|
|
5992
6108
|
'metrics.Read',
|
|
5993
6109
|
{
|
|
5994
6110
|
series: [1, list(MetricsSeries)],
|
|
6111
|
+
/** on the last part of a page that has more, to a request that gave limit */
|
|
6112
|
+
next: [2, str],
|
|
5995
6113
|
},
|
|
5996
6114
|
{
|
|
5997
6115
|
write(w, v) {
|
|
@@ -6005,10 +6123,16 @@ export const MetricsRead = message(
|
|
|
6005
6123
|
}
|
|
6006
6124
|
n++
|
|
6007
6125
|
}
|
|
6126
|
+
if (v.next !== undefined) {
|
|
6127
|
+
w.field(2)
|
|
6128
|
+
w.str(v.next)
|
|
6129
|
+
n++
|
|
6130
|
+
}
|
|
6008
6131
|
w.closeMap(head, n)
|
|
6009
6132
|
},
|
|
6010
6133
|
read(r) {
|
|
6011
6134
|
let $series: Read<typeof MetricsSeries.fields>[] | undefined
|
|
6135
|
+
let $next: string | undefined
|
|
6012
6136
|
for (let n = r.message(); n > 0; n--) {
|
|
6013
6137
|
switch (r.field()) {
|
|
6014
6138
|
case 1: {
|
|
@@ -6020,12 +6144,15 @@ export const MetricsRead = message(
|
|
|
6020
6144
|
$series = items0
|
|
6021
6145
|
break
|
|
6022
6146
|
}
|
|
6147
|
+
case 2:
|
|
6148
|
+
$next = r.str()
|
|
6149
|
+
break
|
|
6023
6150
|
default:
|
|
6024
6151
|
r.skip()
|
|
6025
6152
|
}
|
|
6026
6153
|
}
|
|
6027
6154
|
r.leave()
|
|
6028
|
-
return { series: $series }
|
|
6155
|
+
return { series: $series, next: $next }
|
|
6029
6156
|
},
|
|
6030
6157
|
},
|
|
6031
6158
|
)
|
|
@@ -6418,6 +6545,7 @@ export const MetricsGroup = message(
|
|
|
6418
6545
|
name: [1, str],
|
|
6419
6546
|
labels: [2, names(str)],
|
|
6420
6547
|
buckets: [3, list(MetricsBucket)],
|
|
6548
|
+
/** the next part goes on with this group; on a page's last, the next page's first */
|
|
6421
6549
|
more: [4, bool],
|
|
6422
6550
|
},
|
|
6423
6551
|
{
|
|
@@ -6488,6 +6616,8 @@ export const MetricsAggregates = message(
|
|
|
6488
6616
|
'metrics.Aggregates',
|
|
6489
6617
|
{
|
|
6490
6618
|
groups: [1, list(MetricsGroup)],
|
|
6619
|
+
/** on the last part of a page that has more, to a request that gave limit */
|
|
6620
|
+
next: [2, str],
|
|
6491
6621
|
},
|
|
6492
6622
|
{
|
|
6493
6623
|
write(w, v) {
|
|
@@ -6501,10 +6631,16 @@ export const MetricsAggregates = message(
|
|
|
6501
6631
|
}
|
|
6502
6632
|
n++
|
|
6503
6633
|
}
|
|
6634
|
+
if (v.next !== undefined) {
|
|
6635
|
+
w.field(2)
|
|
6636
|
+
w.str(v.next)
|
|
6637
|
+
n++
|
|
6638
|
+
}
|
|
6504
6639
|
w.closeMap(head, n)
|
|
6505
6640
|
},
|
|
6506
6641
|
read(r) {
|
|
6507
6642
|
let $groups: Read<typeof MetricsGroup.fields>[] | undefined
|
|
6643
|
+
let $next: string | undefined
|
|
6508
6644
|
for (let n = r.message(); n > 0; n--) {
|
|
6509
6645
|
switch (r.field()) {
|
|
6510
6646
|
case 1: {
|
|
@@ -6516,12 +6652,15 @@ export const MetricsAggregates = message(
|
|
|
6516
6652
|
$groups = items0
|
|
6517
6653
|
break
|
|
6518
6654
|
}
|
|
6655
|
+
case 2:
|
|
6656
|
+
$next = r.str()
|
|
6657
|
+
break
|
|
6519
6658
|
default:
|
|
6520
6659
|
r.skip()
|
|
6521
6660
|
}
|
|
6522
6661
|
}
|
|
6523
6662
|
r.leave()
|
|
6524
|
-
return { groups: $groups }
|
|
6663
|
+
return { groups: $groups, next: $next }
|
|
6525
6664
|
},
|
|
6526
6665
|
},
|
|
6527
6666
|
)
|