@tinyshed/tinystore 0.7.1 → 0.9.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 +1 -1
- package/dist/backup.d.ts +2 -0
- package/dist/backup.js +1 -0
- package/dist/blobs.d.ts +18 -1
- package/dist/blobs.js +52 -45
- package/dist/console.d.ts +6 -3
- package/dist/console.js +53 -14
- package/dist/directory.d.ts +72 -0
- package/dist/directory.js +121 -0
- package/dist/index.d.ts +2 -1
- package/dist/jobs.d.ts +42 -14
- package/dist/jobs.js +146 -39
- package/dist/locks.js +18 -0
- package/dist/metrics.d.ts +5 -1
- package/dist/metrics.js +2 -0
- package/dist/query.d.ts +8 -1
- package/dist/query.js +56 -19
- package/dist/search.d.ts +17 -1
- package/dist/search.js +11 -2
- package/dist/sql.d.ts +33 -2
- package/dist/sql.js +91 -11
- package/dist/store.d.ts +9 -0
- package/dist/store.js +11 -0
- package/dist/wire/protocol.d.ts +219 -11
- package/dist/wire/protocol.js +650 -18
- package/package.json +8 -8
- package/src/backup.ts +3 -0
- package/src/blobs.ts +66 -45
- package/src/console.ts +56 -16
- package/src/directory.ts +235 -0
- package/src/index.ts +9 -0
- package/src/jobs.ts +187 -46
- package/src/locks.ts +22 -0
- package/src/metrics.ts +7 -1
- package/src/query.ts +68 -24
- package/src/search.ts +28 -5
- package/src/sql.ts +105 -11
- package/src/store.ts +12 -0
- package/src/wire/protocol.ts +685 -18
package/src/wire/protocol.ts
CHANGED
|
@@ -36,6 +36,10 @@ export const methods = {
|
|
|
36
36
|
'blobs.usage': 0x040b,
|
|
37
37
|
'blobs.clear': 0x040c,
|
|
38
38
|
'blobs.read': 0x040d,
|
|
39
|
+
'blobs.directory': 0x040e,
|
|
40
|
+
'blobs.scan': 0x040f,
|
|
41
|
+
'blobs.changes': 0x0410,
|
|
42
|
+
'blobs.forget': 0x0411,
|
|
39
43
|
/**
|
|
40
44
|
* Answers once the store has the message, not once anyone handled it; in a
|
|
41
45
|
* database's transaction, it is handed over once the transaction commits.
|
|
@@ -68,6 +72,7 @@ export const methods = {
|
|
|
68
72
|
'jobs.keep': 0x020b,
|
|
69
73
|
'jobs.watch': 0x020c,
|
|
70
74
|
'jobs.tx': 0x020d,
|
|
75
|
+
'jobs.counts': 0x020e,
|
|
71
76
|
'kv.bucket.open': 0x0101,
|
|
72
77
|
'kv.get': 0x0102,
|
|
73
78
|
'kv.has': 0x0103,
|
|
@@ -280,6 +285,8 @@ export const BackupWritten = message(
|
|
|
280
285
|
bytes: [2, uint],
|
|
281
286
|
/** the store seals values with a key the backup does not hold */
|
|
282
287
|
keyLeftOut: [3, bool],
|
|
288
|
+
/** the databases opened with backup false, which it holds nothing of */
|
|
289
|
+
excluded: [4, list(str)],
|
|
283
290
|
},
|
|
284
291
|
{
|
|
285
292
|
write(w, v) {
|
|
@@ -300,12 +307,21 @@ export const BackupWritten = message(
|
|
|
300
307
|
w.bool(v.keyLeftOut)
|
|
301
308
|
n++
|
|
302
309
|
}
|
|
310
|
+
if (v.excluded !== undefined) {
|
|
311
|
+
w.field(4)
|
|
312
|
+
w.array(v.excluded.length)
|
|
313
|
+
for (const item0 of v.excluded) {
|
|
314
|
+
w.str(item0)
|
|
315
|
+
}
|
|
316
|
+
n++
|
|
317
|
+
}
|
|
303
318
|
w.closeMap(head, n)
|
|
304
319
|
},
|
|
305
320
|
read(r) {
|
|
306
321
|
let $files: number | undefined
|
|
307
322
|
let $bytes: number | undefined
|
|
308
323
|
let $keyLeftOut: boolean | undefined
|
|
324
|
+
let $excluded: string[] | undefined
|
|
309
325
|
for (let n = r.message(); n > 0; n--) {
|
|
310
326
|
switch (r.field()) {
|
|
311
327
|
case 1:
|
|
@@ -317,12 +333,21 @@ export const BackupWritten = message(
|
|
|
317
333
|
case 3:
|
|
318
334
|
$keyLeftOut = r.bool()
|
|
319
335
|
break
|
|
336
|
+
case 4: {
|
|
337
|
+
const items0: string[] = []
|
|
338
|
+
for (let i0 = r.array(); i0 > 0; i0--) {
|
|
339
|
+
items0.push(r.str())
|
|
340
|
+
}
|
|
341
|
+
r.leave()
|
|
342
|
+
$excluded = items0
|
|
343
|
+
break
|
|
344
|
+
}
|
|
320
345
|
default:
|
|
321
346
|
r.skip()
|
|
322
347
|
}
|
|
323
348
|
}
|
|
324
349
|
r.leave()
|
|
325
|
-
return { files: $files, bytes: $bytes, keyLeftOut: $keyLeftOut }
|
|
350
|
+
return { files: $files, bytes: $bytes, keyLeftOut: $keyLeftOut, excluded: $excluded }
|
|
326
351
|
},
|
|
327
352
|
},
|
|
328
353
|
)
|
|
@@ -758,12 +783,15 @@ export const BlobsWritten = message(
|
|
|
758
783
|
|
|
759
784
|
/**
|
|
760
785
|
* A piece of a file's bytes: an upload's DATA from the client, a read's from
|
|
761
|
-
* the server.
|
|
786
|
+
* the server. A piece of a growing directory's file brings the file's size
|
|
787
|
+
* and time as it was read, so that the reader sees it moved.
|
|
762
788
|
*/
|
|
763
789
|
export const BlobsPiece = message(
|
|
764
790
|
'blobs.Piece',
|
|
765
791
|
{
|
|
766
792
|
bytes: [1, bin],
|
|
793
|
+
size: [2, uint],
|
|
794
|
+
lastModified: [3, int],
|
|
767
795
|
},
|
|
768
796
|
{
|
|
769
797
|
write(w, v) {
|
|
@@ -774,21 +802,39 @@ export const BlobsPiece = message(
|
|
|
774
802
|
w.bin(v.bytes)
|
|
775
803
|
n++
|
|
776
804
|
}
|
|
805
|
+
if (v.size !== undefined) {
|
|
806
|
+
w.field(2)
|
|
807
|
+
w.uint(v.size)
|
|
808
|
+
n++
|
|
809
|
+
}
|
|
810
|
+
if (v.lastModified !== undefined) {
|
|
811
|
+
w.field(3)
|
|
812
|
+
w.int(v.lastModified)
|
|
813
|
+
n++
|
|
814
|
+
}
|
|
777
815
|
w.closeMap(head, n)
|
|
778
816
|
},
|
|
779
817
|
read(r) {
|
|
780
818
|
let $bytes: Uint8Array | undefined
|
|
819
|
+
let $size: number | undefined
|
|
820
|
+
let $lastModified: number | undefined
|
|
781
821
|
for (let n = r.message(); n > 0; n--) {
|
|
782
822
|
switch (r.field()) {
|
|
783
823
|
case 1:
|
|
784
824
|
$bytes = r.bytes()
|
|
785
825
|
break
|
|
826
|
+
case 2:
|
|
827
|
+
$size = r.uint()
|
|
828
|
+
break
|
|
829
|
+
case 3:
|
|
830
|
+
$lastModified = r.int()
|
|
831
|
+
break
|
|
786
832
|
default:
|
|
787
833
|
r.skip()
|
|
788
834
|
}
|
|
789
835
|
}
|
|
790
836
|
r.leave()
|
|
791
|
-
return { bytes: $bytes }
|
|
837
|
+
return { bytes: $bytes, size: $size, lastModified: $lastModified }
|
|
792
838
|
},
|
|
793
839
|
},
|
|
794
840
|
)
|
|
@@ -1480,6 +1526,356 @@ export const BlobsUsage = message(
|
|
|
1480
1526
|
},
|
|
1481
1527
|
)
|
|
1482
1528
|
|
|
1529
|
+
/**
|
|
1530
|
+
* Opens a directory by name: a folder of the server's machine, which the
|
|
1531
|
+
* store lists and reads and never writes. Its handle takes get, head, list,
|
|
1532
|
+
* usage and read as a set of files' does, each answered from the list the
|
|
1533
|
+
* last scan wrote but a get's and a read's bytes, which come from the disk;
|
|
1534
|
+
* every call that writes a file is invalid. A connection that came with a
|
|
1535
|
+
* token names no path: it opens the directory the server was given under the
|
|
1536
|
+
* name, and one the server was not given is invalid.
|
|
1537
|
+
*/
|
|
1538
|
+
export const BlobsDirectory = message(
|
|
1539
|
+
'blobs.Directory',
|
|
1540
|
+
{
|
|
1541
|
+
/** [a-z0-9][a-z0-9_-]{0,63}, never a set of files' name too */
|
|
1542
|
+
name: [1, str],
|
|
1543
|
+
/** the folder on the server's machine; the server's own when absent */
|
|
1544
|
+
path: [2, str],
|
|
1545
|
+
/** a scan on the store's background work, a period apart */
|
|
1546
|
+
every: [3, uint],
|
|
1547
|
+
/** names a scan passes over, * for any run of a name's characters */
|
|
1548
|
+
ignore: [4, list(str)],
|
|
1549
|
+
/** a read holds to no version and goes up to the size now */
|
|
1550
|
+
growing: [5, bool],
|
|
1551
|
+
},
|
|
1552
|
+
{
|
|
1553
|
+
write(w, v) {
|
|
1554
|
+
const head = w.openMap()
|
|
1555
|
+
let n = 0
|
|
1556
|
+
if (v.name !== undefined) {
|
|
1557
|
+
w.field(1)
|
|
1558
|
+
w.str(v.name)
|
|
1559
|
+
n++
|
|
1560
|
+
}
|
|
1561
|
+
if (v.path !== undefined) {
|
|
1562
|
+
w.field(2)
|
|
1563
|
+
w.str(v.path)
|
|
1564
|
+
n++
|
|
1565
|
+
}
|
|
1566
|
+
if (v.every !== undefined) {
|
|
1567
|
+
w.field(3)
|
|
1568
|
+
w.uint(v.every)
|
|
1569
|
+
n++
|
|
1570
|
+
}
|
|
1571
|
+
if (v.ignore !== undefined) {
|
|
1572
|
+
w.field(4)
|
|
1573
|
+
w.array(v.ignore.length)
|
|
1574
|
+
for (const item0 of v.ignore) {
|
|
1575
|
+
w.str(item0)
|
|
1576
|
+
}
|
|
1577
|
+
n++
|
|
1578
|
+
}
|
|
1579
|
+
if (v.growing !== undefined) {
|
|
1580
|
+
w.field(5)
|
|
1581
|
+
w.bool(v.growing)
|
|
1582
|
+
n++
|
|
1583
|
+
}
|
|
1584
|
+
w.closeMap(head, n)
|
|
1585
|
+
},
|
|
1586
|
+
read(r) {
|
|
1587
|
+
let $name: string | undefined
|
|
1588
|
+
let $path: string | undefined
|
|
1589
|
+
let $every: number | undefined
|
|
1590
|
+
let $ignore: string[] | undefined
|
|
1591
|
+
let $growing: boolean | undefined
|
|
1592
|
+
for (let n = r.message(); n > 0; n--) {
|
|
1593
|
+
switch (r.field()) {
|
|
1594
|
+
case 1:
|
|
1595
|
+
$name = r.str()
|
|
1596
|
+
break
|
|
1597
|
+
case 2:
|
|
1598
|
+
$path = r.str()
|
|
1599
|
+
break
|
|
1600
|
+
case 3:
|
|
1601
|
+
$every = r.uint()
|
|
1602
|
+
break
|
|
1603
|
+
case 4: {
|
|
1604
|
+
const items0: string[] = []
|
|
1605
|
+
for (let i0 = r.array(); i0 > 0; i0--) {
|
|
1606
|
+
items0.push(r.str())
|
|
1607
|
+
}
|
|
1608
|
+
r.leave()
|
|
1609
|
+
$ignore = items0
|
|
1610
|
+
break
|
|
1611
|
+
}
|
|
1612
|
+
case 5:
|
|
1613
|
+
$growing = r.bool()
|
|
1614
|
+
break
|
|
1615
|
+
default:
|
|
1616
|
+
r.skip()
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
r.leave()
|
|
1620
|
+
return { name: $name, path: $path, every: $every, ignore: $ignore, growing: $growing }
|
|
1621
|
+
},
|
|
1622
|
+
},
|
|
1623
|
+
)
|
|
1624
|
+
|
|
1625
|
+
/**
|
|
1626
|
+
* What a scan found, and what the list holds once it ended.
|
|
1627
|
+
*/
|
|
1628
|
+
export const BlobsScanned = message(
|
|
1629
|
+
'blobs.Scanned',
|
|
1630
|
+
{
|
|
1631
|
+
added: [1, uint],
|
|
1632
|
+
changed: [2, uint],
|
|
1633
|
+
removed: [3, uint],
|
|
1634
|
+
/** what it met and could not list: a link, a folder it cannot read, another disk */
|
|
1635
|
+
skipped: [4, uint],
|
|
1636
|
+
count: [5, uint],
|
|
1637
|
+
size: [6, uint],
|
|
1638
|
+
},
|
|
1639
|
+
{
|
|
1640
|
+
write(w, v) {
|
|
1641
|
+
const head = w.openMap()
|
|
1642
|
+
let n = 0
|
|
1643
|
+
if (v.added !== undefined) {
|
|
1644
|
+
w.field(1)
|
|
1645
|
+
w.uint(v.added)
|
|
1646
|
+
n++
|
|
1647
|
+
}
|
|
1648
|
+
if (v.changed !== undefined) {
|
|
1649
|
+
w.field(2)
|
|
1650
|
+
w.uint(v.changed)
|
|
1651
|
+
n++
|
|
1652
|
+
}
|
|
1653
|
+
if (v.removed !== undefined) {
|
|
1654
|
+
w.field(3)
|
|
1655
|
+
w.uint(v.removed)
|
|
1656
|
+
n++
|
|
1657
|
+
}
|
|
1658
|
+
if (v.skipped !== undefined) {
|
|
1659
|
+
w.field(4)
|
|
1660
|
+
w.uint(v.skipped)
|
|
1661
|
+
n++
|
|
1662
|
+
}
|
|
1663
|
+
if (v.count !== undefined) {
|
|
1664
|
+
w.field(5)
|
|
1665
|
+
w.uint(v.count)
|
|
1666
|
+
n++
|
|
1667
|
+
}
|
|
1668
|
+
if (v.size !== undefined) {
|
|
1669
|
+
w.field(6)
|
|
1670
|
+
w.uint(v.size)
|
|
1671
|
+
n++
|
|
1672
|
+
}
|
|
1673
|
+
w.closeMap(head, n)
|
|
1674
|
+
},
|
|
1675
|
+
read(r) {
|
|
1676
|
+
let $added: number | undefined
|
|
1677
|
+
let $changed: number | undefined
|
|
1678
|
+
let $removed: number | undefined
|
|
1679
|
+
let $skipped: number | undefined
|
|
1680
|
+
let $count: number | undefined
|
|
1681
|
+
let $size: number | undefined
|
|
1682
|
+
for (let n = r.message(); n > 0; n--) {
|
|
1683
|
+
switch (r.field()) {
|
|
1684
|
+
case 1:
|
|
1685
|
+
$added = r.uint()
|
|
1686
|
+
break
|
|
1687
|
+
case 2:
|
|
1688
|
+
$changed = r.uint()
|
|
1689
|
+
break
|
|
1690
|
+
case 3:
|
|
1691
|
+
$removed = r.uint()
|
|
1692
|
+
break
|
|
1693
|
+
case 4:
|
|
1694
|
+
$skipped = r.uint()
|
|
1695
|
+
break
|
|
1696
|
+
case 5:
|
|
1697
|
+
$count = r.uint()
|
|
1698
|
+
break
|
|
1699
|
+
case 6:
|
|
1700
|
+
$size = r.uint()
|
|
1701
|
+
break
|
|
1702
|
+
default:
|
|
1703
|
+
r.skip()
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
r.leave()
|
|
1707
|
+
return {
|
|
1708
|
+
added: $added,
|
|
1709
|
+
changed: $changed,
|
|
1710
|
+
removed: $removed,
|
|
1711
|
+
skipped: $skipped,
|
|
1712
|
+
count: $count,
|
|
1713
|
+
size: $size,
|
|
1714
|
+
}
|
|
1715
|
+
},
|
|
1716
|
+
},
|
|
1717
|
+
)
|
|
1718
|
+
|
|
1719
|
+
/**
|
|
1720
|
+
* The changes of a directory past a cursor, from the first file it listed
|
|
1721
|
+
* when absent.
|
|
1722
|
+
*/
|
|
1723
|
+
export const BlobsSince = message(
|
|
1724
|
+
'blobs.Since',
|
|
1725
|
+
{
|
|
1726
|
+
handle: [1, uint],
|
|
1727
|
+
/** a page's next */
|
|
1728
|
+
after: [2, str],
|
|
1729
|
+
},
|
|
1730
|
+
{
|
|
1731
|
+
write(w, v) {
|
|
1732
|
+
const head = w.openMap()
|
|
1733
|
+
let n = 0
|
|
1734
|
+
if (v.handle !== undefined) {
|
|
1735
|
+
w.field(1)
|
|
1736
|
+
w.uint(v.handle)
|
|
1737
|
+
n++
|
|
1738
|
+
}
|
|
1739
|
+
if (v.after !== undefined) {
|
|
1740
|
+
w.field(2)
|
|
1741
|
+
w.str(v.after)
|
|
1742
|
+
n++
|
|
1743
|
+
}
|
|
1744
|
+
w.closeMap(head, n)
|
|
1745
|
+
},
|
|
1746
|
+
read(r) {
|
|
1747
|
+
let $handle: number | undefined
|
|
1748
|
+
let $after: string | undefined
|
|
1749
|
+
for (let n = r.message(); n > 0; n--) {
|
|
1750
|
+
switch (r.field()) {
|
|
1751
|
+
case 1:
|
|
1752
|
+
$handle = r.uint()
|
|
1753
|
+
break
|
|
1754
|
+
case 2:
|
|
1755
|
+
$after = r.str()
|
|
1756
|
+
break
|
|
1757
|
+
default:
|
|
1758
|
+
r.skip()
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
r.leave()
|
|
1762
|
+
return { handle: $handle, after: $after }
|
|
1763
|
+
},
|
|
1764
|
+
},
|
|
1765
|
+
)
|
|
1766
|
+
|
|
1767
|
+
export const BlobsChange = message(
|
|
1768
|
+
'blobs.Change',
|
|
1769
|
+
{
|
|
1770
|
+
/** the whole path in the directory */
|
|
1771
|
+
path: [1, str],
|
|
1772
|
+
/** added, changed or removed */
|
|
1773
|
+
change: [2, str],
|
|
1774
|
+
/** none once removed */
|
|
1775
|
+
info: [3, BlobsInfo],
|
|
1776
|
+
},
|
|
1777
|
+
{
|
|
1778
|
+
write(w, v) {
|
|
1779
|
+
const head = w.openMap()
|
|
1780
|
+
let n = 0
|
|
1781
|
+
if (v.path !== undefined) {
|
|
1782
|
+
w.field(1)
|
|
1783
|
+
w.str(v.path)
|
|
1784
|
+
n++
|
|
1785
|
+
}
|
|
1786
|
+
if (v.change !== undefined) {
|
|
1787
|
+
w.field(2)
|
|
1788
|
+
w.str(v.change)
|
|
1789
|
+
n++
|
|
1790
|
+
}
|
|
1791
|
+
if (v.info !== undefined) {
|
|
1792
|
+
w.field(3)
|
|
1793
|
+
BlobsInfo.write(w, v.info)
|
|
1794
|
+
n++
|
|
1795
|
+
}
|
|
1796
|
+
w.closeMap(head, n)
|
|
1797
|
+
},
|
|
1798
|
+
read(r) {
|
|
1799
|
+
let $path: string | undefined
|
|
1800
|
+
let $change: string | undefined
|
|
1801
|
+
let $info: Read<typeof BlobsInfo.fields> | undefined
|
|
1802
|
+
for (let n = r.message(); n > 0; n--) {
|
|
1803
|
+
switch (r.field()) {
|
|
1804
|
+
case 1:
|
|
1805
|
+
$path = r.str()
|
|
1806
|
+
break
|
|
1807
|
+
case 2:
|
|
1808
|
+
$change = r.str()
|
|
1809
|
+
break
|
|
1810
|
+
case 3:
|
|
1811
|
+
$info = BlobsInfo.read(r)
|
|
1812
|
+
break
|
|
1813
|
+
default:
|
|
1814
|
+
r.skip()
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
r.leave()
|
|
1818
|
+
return { path: $path, change: $change, info: $info }
|
|
1819
|
+
},
|
|
1820
|
+
},
|
|
1821
|
+
)
|
|
1822
|
+
|
|
1823
|
+
/**
|
|
1824
|
+
* A page of changes in the order the scans wrote them, 1000 at most; next is
|
|
1825
|
+
* always there, with no items the cursor to ask from after the next scan.
|
|
1826
|
+
*/
|
|
1827
|
+
export const BlobsChanges = message(
|
|
1828
|
+
'blobs.Changes',
|
|
1829
|
+
{
|
|
1830
|
+
items: [1, list(BlobsChange)],
|
|
1831
|
+
next: [2, str],
|
|
1832
|
+
},
|
|
1833
|
+
{
|
|
1834
|
+
write(w, v) {
|
|
1835
|
+
const head = w.openMap()
|
|
1836
|
+
let n = 0
|
|
1837
|
+
if (v.items !== undefined) {
|
|
1838
|
+
w.field(1)
|
|
1839
|
+
w.array(v.items.length)
|
|
1840
|
+
for (const item0 of v.items) {
|
|
1841
|
+
BlobsChange.write(w, item0)
|
|
1842
|
+
}
|
|
1843
|
+
n++
|
|
1844
|
+
}
|
|
1845
|
+
if (v.next !== undefined) {
|
|
1846
|
+
w.field(2)
|
|
1847
|
+
w.str(v.next)
|
|
1848
|
+
n++
|
|
1849
|
+
}
|
|
1850
|
+
w.closeMap(head, n)
|
|
1851
|
+
},
|
|
1852
|
+
read(r) {
|
|
1853
|
+
let $items: Read<typeof BlobsChange.fields>[] | undefined
|
|
1854
|
+
let $next: string | undefined
|
|
1855
|
+
for (let n = r.message(); n > 0; n--) {
|
|
1856
|
+
switch (r.field()) {
|
|
1857
|
+
case 1: {
|
|
1858
|
+
const items0: Read<typeof BlobsChange.fields>[] = []
|
|
1859
|
+
for (let i0 = r.array(); i0 > 0; i0--) {
|
|
1860
|
+
items0.push(BlobsChange.read(r))
|
|
1861
|
+
}
|
|
1862
|
+
r.leave()
|
|
1863
|
+
$items = items0
|
|
1864
|
+
break
|
|
1865
|
+
}
|
|
1866
|
+
case 2:
|
|
1867
|
+
$next = r.str()
|
|
1868
|
+
break
|
|
1869
|
+
default:
|
|
1870
|
+
r.skip()
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1873
|
+
r.leave()
|
|
1874
|
+
return { items: $items, next: $next }
|
|
1875
|
+
},
|
|
1876
|
+
},
|
|
1877
|
+
)
|
|
1878
|
+
|
|
1483
1879
|
/**
|
|
1484
1880
|
* A message published on a channel's branch, as docs/guides/channels/README.md has
|
|
1485
1881
|
* it: every subscription listening there now receives it.
|
|
@@ -3213,13 +3609,15 @@ export const JobsCall = message(
|
|
|
3213
3609
|
)
|
|
3214
3610
|
|
|
3215
3611
|
/**
|
|
3216
|
-
* The job under an id
|
|
3612
|
+
* The job under an id; or, for a cancel, a job without one by the row a page
|
|
3613
|
+
* gave, its id left out.
|
|
3217
3614
|
*/
|
|
3218
3615
|
export const JobsId = message(
|
|
3219
3616
|
'jobs.Id',
|
|
3220
3617
|
{
|
|
3221
3618
|
handle: [1, uint],
|
|
3222
3619
|
id: [2, str],
|
|
3620
|
+
row: [3, str],
|
|
3223
3621
|
},
|
|
3224
3622
|
{
|
|
3225
3623
|
write(w, v) {
|
|
@@ -3235,11 +3633,17 @@ export const JobsId = message(
|
|
|
3235
3633
|
w.str(v.id)
|
|
3236
3634
|
n++
|
|
3237
3635
|
}
|
|
3636
|
+
if (v.row !== undefined) {
|
|
3637
|
+
w.field(3)
|
|
3638
|
+
w.str(v.row)
|
|
3639
|
+
n++
|
|
3640
|
+
}
|
|
3238
3641
|
w.closeMap(head, n)
|
|
3239
3642
|
},
|
|
3240
3643
|
read(r) {
|
|
3241
3644
|
let $handle: number | undefined
|
|
3242
3645
|
let $id: string | undefined
|
|
3646
|
+
let $row: string | undefined
|
|
3243
3647
|
for (let n = r.message(); n > 0; n--) {
|
|
3244
3648
|
switch (r.field()) {
|
|
3245
3649
|
case 1:
|
|
@@ -3248,12 +3652,15 @@ export const JobsId = message(
|
|
|
3248
3652
|
case 2:
|
|
3249
3653
|
$id = r.str()
|
|
3250
3654
|
break
|
|
3655
|
+
case 3:
|
|
3656
|
+
$row = r.str()
|
|
3657
|
+
break
|
|
3251
3658
|
default:
|
|
3252
3659
|
r.skip()
|
|
3253
3660
|
}
|
|
3254
3661
|
}
|
|
3255
3662
|
r.leave()
|
|
3256
|
-
return { handle: $handle, id: $id }
|
|
3663
|
+
return { handle: $handle, id: $id, row: $row }
|
|
3257
3664
|
},
|
|
3258
3665
|
},
|
|
3259
3666
|
)
|
|
@@ -3319,6 +3726,10 @@ export const JobsJob = message(
|
|
|
3319
3726
|
/** the last run a handler finished */
|
|
3320
3727
|
startedAt: [12, int],
|
|
3321
3728
|
endedAt: [13, int],
|
|
3729
|
+
/** where a job without an id lies, which a cancel names it by */
|
|
3730
|
+
row: [14, str],
|
|
3731
|
+
/** a walk's: why the job's value no longer reads, the job left out */
|
|
3732
|
+
failure: [15, Failure],
|
|
3322
3733
|
},
|
|
3323
3734
|
{
|
|
3324
3735
|
write(w, v) {
|
|
@@ -3389,6 +3800,16 @@ export const JobsJob = message(
|
|
|
3389
3800
|
w.int(v.endedAt)
|
|
3390
3801
|
n++
|
|
3391
3802
|
}
|
|
3803
|
+
if (v.row !== undefined) {
|
|
3804
|
+
w.field(14)
|
|
3805
|
+
w.str(v.row)
|
|
3806
|
+
n++
|
|
3807
|
+
}
|
|
3808
|
+
if (v.failure !== undefined) {
|
|
3809
|
+
w.field(15)
|
|
3810
|
+
Failure.write(w, v.failure)
|
|
3811
|
+
n++
|
|
3812
|
+
}
|
|
3392
3813
|
w.closeMap(head, n)
|
|
3393
3814
|
},
|
|
3394
3815
|
read(r) {
|
|
@@ -3405,6 +3826,8 @@ export const JobsJob = message(
|
|
|
3405
3826
|
let $repeat: string | undefined
|
|
3406
3827
|
let $startedAt: number | undefined
|
|
3407
3828
|
let $endedAt: number | undefined
|
|
3829
|
+
let $row: string | undefined
|
|
3830
|
+
let $failure: Read<typeof Failure.fields> | undefined
|
|
3408
3831
|
for (let n = r.message(); n > 0; n--) {
|
|
3409
3832
|
switch (r.field()) {
|
|
3410
3833
|
case 1:
|
|
@@ -3446,6 +3869,12 @@ export const JobsJob = message(
|
|
|
3446
3869
|
case 13:
|
|
3447
3870
|
$endedAt = r.int()
|
|
3448
3871
|
break
|
|
3872
|
+
case 14:
|
|
3873
|
+
$row = r.str()
|
|
3874
|
+
break
|
|
3875
|
+
case 15:
|
|
3876
|
+
$failure = Failure.read(r)
|
|
3877
|
+
break
|
|
3449
3878
|
default:
|
|
3450
3879
|
r.skip()
|
|
3451
3880
|
}
|
|
@@ -3465,6 +3894,8 @@ export const JobsJob = message(
|
|
|
3465
3894
|
repeat: $repeat,
|
|
3466
3895
|
startedAt: $startedAt,
|
|
3467
3896
|
endedAt: $endedAt,
|
|
3897
|
+
row: $row,
|
|
3898
|
+
failure: $failure,
|
|
3468
3899
|
}
|
|
3469
3900
|
},
|
|
3470
3901
|
},
|
|
@@ -3472,8 +3903,9 @@ export const JobsJob = message(
|
|
|
3472
3903
|
|
|
3473
3904
|
/**
|
|
3474
3905
|
* A page of a queue's jobs: those whose ids start with a prefix, in the byte
|
|
3475
|
-
* order of their ids
|
|
3476
|
-
*
|
|
3906
|
+
* order of their ids; with no prefix every job, those with ids first, then
|
|
3907
|
+
* those without as they run, then those without that failed, the last failed
|
|
3908
|
+
* first; with no prefix and the failed state the failed alone, the last first.
|
|
3477
3909
|
*/
|
|
3478
3910
|
export const JobsList = message(
|
|
3479
3911
|
'jobs.List',
|
|
@@ -3486,6 +3918,8 @@ export const JobsList = message(
|
|
|
3486
3918
|
after: [4, str],
|
|
3487
3919
|
/** 100 when absent, 1000 at most */
|
|
3488
3920
|
limit: [5, uint],
|
|
3921
|
+
/** a job whose value no longer reads comes as its failure in its place, not the page's */
|
|
3922
|
+
walk: [6, bool],
|
|
3489
3923
|
},
|
|
3490
3924
|
{
|
|
3491
3925
|
write(w, v) {
|
|
@@ -3516,6 +3950,11 @@ export const JobsList = message(
|
|
|
3516
3950
|
w.uint(v.limit)
|
|
3517
3951
|
n++
|
|
3518
3952
|
}
|
|
3953
|
+
if (v.walk !== undefined) {
|
|
3954
|
+
w.field(6)
|
|
3955
|
+
w.bool(v.walk)
|
|
3956
|
+
n++
|
|
3957
|
+
}
|
|
3519
3958
|
w.closeMap(head, n)
|
|
3520
3959
|
},
|
|
3521
3960
|
read(r) {
|
|
@@ -3524,6 +3963,7 @@ export const JobsList = message(
|
|
|
3524
3963
|
let $state: string | undefined
|
|
3525
3964
|
let $after: string | undefined
|
|
3526
3965
|
let $limit: number | undefined
|
|
3966
|
+
let $walk: boolean | undefined
|
|
3527
3967
|
for (let n = r.message(); n > 0; n--) {
|
|
3528
3968
|
switch (r.field()) {
|
|
3529
3969
|
case 1:
|
|
@@ -3541,12 +3981,22 @@ export const JobsList = message(
|
|
|
3541
3981
|
case 5:
|
|
3542
3982
|
$limit = r.uint()
|
|
3543
3983
|
break
|
|
3984
|
+
case 6:
|
|
3985
|
+
$walk = r.bool()
|
|
3986
|
+
break
|
|
3544
3987
|
default:
|
|
3545
3988
|
r.skip()
|
|
3546
3989
|
}
|
|
3547
3990
|
}
|
|
3548
3991
|
r.leave()
|
|
3549
|
-
return {
|
|
3992
|
+
return {
|
|
3993
|
+
handle: $handle,
|
|
3994
|
+
prefix: $prefix,
|
|
3995
|
+
state: $state,
|
|
3996
|
+
after: $after,
|
|
3997
|
+
limit: $limit,
|
|
3998
|
+
walk: $walk,
|
|
3999
|
+
}
|
|
3550
4000
|
},
|
|
3551
4001
|
},
|
|
3552
4002
|
)
|
|
@@ -3603,6 +4053,76 @@ export const JobsPage = message(
|
|
|
3603
4053
|
},
|
|
3604
4054
|
)
|
|
3605
4055
|
|
|
4056
|
+
/**
|
|
4057
|
+
* How many jobs a queue holds in each state, from one snapshot; a done job
|
|
4058
|
+
* has left it.
|
|
4059
|
+
*/
|
|
4060
|
+
export const JobsCounts = message(
|
|
4061
|
+
'jobs.Counts',
|
|
4062
|
+
{
|
|
4063
|
+
/** due later */
|
|
4064
|
+
scheduled: [1, uint],
|
|
4065
|
+
/** due, and no handler runs it yet */
|
|
4066
|
+
waiting: [2, uint],
|
|
4067
|
+
running: [3, uint],
|
|
4068
|
+
/** kept for the queue's keep */
|
|
4069
|
+
failed: [4, uint],
|
|
4070
|
+
},
|
|
4071
|
+
{
|
|
4072
|
+
write(w, v) {
|
|
4073
|
+
const head = w.openMap()
|
|
4074
|
+
let n = 0
|
|
4075
|
+
if (v.scheduled !== undefined) {
|
|
4076
|
+
w.field(1)
|
|
4077
|
+
w.uint(v.scheduled)
|
|
4078
|
+
n++
|
|
4079
|
+
}
|
|
4080
|
+
if (v.waiting !== undefined) {
|
|
4081
|
+
w.field(2)
|
|
4082
|
+
w.uint(v.waiting)
|
|
4083
|
+
n++
|
|
4084
|
+
}
|
|
4085
|
+
if (v.running !== undefined) {
|
|
4086
|
+
w.field(3)
|
|
4087
|
+
w.uint(v.running)
|
|
4088
|
+
n++
|
|
4089
|
+
}
|
|
4090
|
+
if (v.failed !== undefined) {
|
|
4091
|
+
w.field(4)
|
|
4092
|
+
w.uint(v.failed)
|
|
4093
|
+
n++
|
|
4094
|
+
}
|
|
4095
|
+
w.closeMap(head, n)
|
|
4096
|
+
},
|
|
4097
|
+
read(r) {
|
|
4098
|
+
let $scheduled: number | undefined
|
|
4099
|
+
let $waiting: number | undefined
|
|
4100
|
+
let $running: number | undefined
|
|
4101
|
+
let $failed: number | undefined
|
|
4102
|
+
for (let n = r.message(); n > 0; n--) {
|
|
4103
|
+
switch (r.field()) {
|
|
4104
|
+
case 1:
|
|
4105
|
+
$scheduled = r.uint()
|
|
4106
|
+
break
|
|
4107
|
+
case 2:
|
|
4108
|
+
$waiting = r.uint()
|
|
4109
|
+
break
|
|
4110
|
+
case 3:
|
|
4111
|
+
$running = r.uint()
|
|
4112
|
+
break
|
|
4113
|
+
case 4:
|
|
4114
|
+
$failed = r.uint()
|
|
4115
|
+
break
|
|
4116
|
+
default:
|
|
4117
|
+
r.skip()
|
|
4118
|
+
}
|
|
4119
|
+
}
|
|
4120
|
+
r.leave()
|
|
4121
|
+
return { scheduled: $scheduled, waiting: $waiting, running: $running, failed: $failed }
|
|
4122
|
+
},
|
|
4123
|
+
},
|
|
4124
|
+
)
|
|
4125
|
+
|
|
3606
4126
|
/**
|
|
3607
4127
|
* Starts the queue's worker for the client: the server claims its jobs as they
|
|
3608
4128
|
* fall due and hands each over as a held job, no more at once than the
|
|
@@ -3971,7 +4491,7 @@ export const JobsKept = message(
|
|
|
3971
4491
|
|
|
3972
4492
|
/**
|
|
3973
4493
|
* One write of a transaction: an add, a set or an update with its call, or a
|
|
3974
|
-
* cancel with its id.
|
|
4494
|
+
* cancel with its id or its row.
|
|
3975
4495
|
*/
|
|
3976
4496
|
export const JobsOp = message(
|
|
3977
4497
|
'jobs.Op',
|
|
@@ -6291,6 +6811,8 @@ export const MetricsAggregateAsked = message(
|
|
|
6291
6811
|
calendar: [7, str],
|
|
6292
6812
|
/** an IANA name, UTC among them, which calendar takes */
|
|
6293
6813
|
timeZone: [8, str],
|
|
6814
|
+
/** a NaN sample counts in no bucket, which says how many it passed over: skipped */
|
|
6815
|
+
skipNan: [9, bool],
|
|
6294
6816
|
},
|
|
6295
6817
|
{
|
|
6296
6818
|
write(w, v) {
|
|
@@ -6342,6 +6864,11 @@ export const MetricsAggregateAsked = message(
|
|
|
6342
6864
|
w.str(v.timeZone)
|
|
6343
6865
|
n++
|
|
6344
6866
|
}
|
|
6867
|
+
if (v.skipNan !== undefined) {
|
|
6868
|
+
w.field(9)
|
|
6869
|
+
w.bool(v.skipNan)
|
|
6870
|
+
n++
|
|
6871
|
+
}
|
|
6345
6872
|
w.closeMap(head, n)
|
|
6346
6873
|
},
|
|
6347
6874
|
read(r) {
|
|
@@ -6353,6 +6880,7 @@ export const MetricsAggregateAsked = message(
|
|
|
6353
6880
|
let $estimate: boolean | undefined
|
|
6354
6881
|
let $calendar: string | undefined
|
|
6355
6882
|
let $timeZone: string | undefined
|
|
6883
|
+
let $skipNan: boolean | undefined
|
|
6356
6884
|
for (let n = r.message(); n > 0; n--) {
|
|
6357
6885
|
switch (r.field()) {
|
|
6358
6886
|
case 1:
|
|
@@ -6391,6 +6919,9 @@ export const MetricsAggregateAsked = message(
|
|
|
6391
6919
|
case 8:
|
|
6392
6920
|
$timeZone = r.str()
|
|
6393
6921
|
break
|
|
6922
|
+
case 9:
|
|
6923
|
+
$skipNan = r.bool()
|
|
6924
|
+
break
|
|
6394
6925
|
default:
|
|
6395
6926
|
r.skip()
|
|
6396
6927
|
}
|
|
@@ -6405,6 +6936,7 @@ export const MetricsAggregateAsked = message(
|
|
|
6405
6936
|
estimate: $estimate,
|
|
6406
6937
|
calendar: $calendar,
|
|
6407
6938
|
timeZone: $timeZone,
|
|
6939
|
+
skipNan: $skipNan,
|
|
6408
6940
|
}
|
|
6409
6941
|
},
|
|
6410
6942
|
},
|
|
@@ -6430,6 +6962,8 @@ export const MetricsBucket = message(
|
|
|
6430
6962
|
partial: [8, bool],
|
|
6431
6963
|
/** its first step began before the bucket before it */
|
|
6432
6964
|
gap: [9, bool],
|
|
6965
|
+
/** the NaN samples it passed over, with skipNan */
|
|
6966
|
+
skipped: [10, uint],
|
|
6433
6967
|
},
|
|
6434
6968
|
{
|
|
6435
6969
|
write(w, v) {
|
|
@@ -6480,6 +7014,11 @@ export const MetricsBucket = message(
|
|
|
6480
7014
|
w.bool(v.gap)
|
|
6481
7015
|
n++
|
|
6482
7016
|
}
|
|
7017
|
+
if (v.skipped !== undefined) {
|
|
7018
|
+
w.field(10)
|
|
7019
|
+
w.uint(v.skipped)
|
|
7020
|
+
n++
|
|
7021
|
+
}
|
|
6483
7022
|
w.closeMap(head, n)
|
|
6484
7023
|
},
|
|
6485
7024
|
read(r) {
|
|
@@ -6492,6 +7031,7 @@ export const MetricsBucket = message(
|
|
|
6492
7031
|
let $resets: number | undefined
|
|
6493
7032
|
let $partial: boolean | undefined
|
|
6494
7033
|
let $gap: boolean | undefined
|
|
7034
|
+
let $skipped: number | undefined
|
|
6495
7035
|
for (let n = r.message(); n > 0; n--) {
|
|
6496
7036
|
switch (r.field()) {
|
|
6497
7037
|
case 1:
|
|
@@ -6521,6 +7061,9 @@ export const MetricsBucket = message(
|
|
|
6521
7061
|
case 9:
|
|
6522
7062
|
$gap = r.bool()
|
|
6523
7063
|
break
|
|
7064
|
+
case 10:
|
|
7065
|
+
$skipped = r.uint()
|
|
7066
|
+
break
|
|
6524
7067
|
default:
|
|
6525
7068
|
r.skip()
|
|
6526
7069
|
}
|
|
@@ -6536,6 +7079,7 @@ export const MetricsBucket = message(
|
|
|
6536
7079
|
resets: $resets,
|
|
6537
7080
|
partial: $partial,
|
|
6538
7081
|
gap: $gap,
|
|
7082
|
+
skipped: $skipped,
|
|
6539
7083
|
}
|
|
6540
7084
|
},
|
|
6541
7085
|
},
|
|
@@ -10552,6 +11096,8 @@ export const SearchQuery = message(
|
|
|
10552
11096
|
prefixEvery: [10, bool],
|
|
10553
11097
|
/** utf8, utf16 or chars: each hit says where it matched, counted in that unit */
|
|
10554
11098
|
matches: [11, str],
|
|
11099
|
+
/** the least cosine a document's vector has for the vector to find it */
|
|
11100
|
+
minSimilarity: [12, float],
|
|
10555
11101
|
},
|
|
10556
11102
|
{
|
|
10557
11103
|
write(w, v) {
|
|
@@ -10612,6 +11158,11 @@ export const SearchQuery = message(
|
|
|
10612
11158
|
w.str(v.matches)
|
|
10613
11159
|
n++
|
|
10614
11160
|
}
|
|
11161
|
+
if (v.minSimilarity !== undefined) {
|
|
11162
|
+
w.field(12)
|
|
11163
|
+
w.float(v.minSimilarity)
|
|
11164
|
+
n++
|
|
11165
|
+
}
|
|
10615
11166
|
w.closeMap(head, n)
|
|
10616
11167
|
},
|
|
10617
11168
|
read(r) {
|
|
@@ -10626,6 +11177,7 @@ export const SearchQuery = message(
|
|
|
10626
11177
|
let $prefix: boolean | undefined
|
|
10627
11178
|
let $prefixEvery: boolean | undefined
|
|
10628
11179
|
let $matches: string | undefined
|
|
11180
|
+
let $minSimilarity: number | undefined
|
|
10629
11181
|
for (let n = r.message(); n > 0; n--) {
|
|
10630
11182
|
switch (r.field()) {
|
|
10631
11183
|
case 1:
|
|
@@ -10661,6 +11213,9 @@ export const SearchQuery = message(
|
|
|
10661
11213
|
case 11:
|
|
10662
11214
|
$matches = r.str()
|
|
10663
11215
|
break
|
|
11216
|
+
case 12:
|
|
11217
|
+
$minSimilarity = r.float()
|
|
11218
|
+
break
|
|
10664
11219
|
default:
|
|
10665
11220
|
r.skip()
|
|
10666
11221
|
}
|
|
@@ -10678,6 +11233,7 @@ export const SearchQuery = message(
|
|
|
10678
11233
|
prefix: $prefix,
|
|
10679
11234
|
prefixEvery: $prefixEvery,
|
|
10680
11235
|
matches: $matches,
|
|
11236
|
+
minSimilarity: $minSimilarity,
|
|
10681
11237
|
}
|
|
10682
11238
|
},
|
|
10683
11239
|
},
|
|
@@ -11145,7 +11701,8 @@ export const SqlMigration = message(
|
|
|
11145
11701
|
|
|
11146
11702
|
/**
|
|
11147
11703
|
* Opens a database. Migrations, when given, are applied and checked; without
|
|
11148
|
-
* them the file opens as it is.
|
|
11704
|
+
* them the file opens as it is. One that backups leave out lies in local/
|
|
11705
|
+
* rather than sql/, and a name whose file lies in the other folder is invalid.
|
|
11149
11706
|
*/
|
|
11150
11707
|
export const SqlOpen = message(
|
|
11151
11708
|
'sql.Open',
|
|
@@ -11155,6 +11712,8 @@ export const SqlOpen = message(
|
|
|
11155
11712
|
migrations: [2, list(SqlMigration)],
|
|
11156
11713
|
/** full or os: how far its commits go before they return; the store's own when absent */
|
|
11157
11714
|
durability: [3, str],
|
|
11715
|
+
/** false: no backup takes it, nor any node; true when absent */
|
|
11716
|
+
backup: [4, bool],
|
|
11158
11717
|
},
|
|
11159
11718
|
{
|
|
11160
11719
|
write(w, v) {
|
|
@@ -11178,12 +11737,18 @@ export const SqlOpen = message(
|
|
|
11178
11737
|
w.str(v.durability)
|
|
11179
11738
|
n++
|
|
11180
11739
|
}
|
|
11740
|
+
if (v.backup !== undefined) {
|
|
11741
|
+
w.field(4)
|
|
11742
|
+
w.bool(v.backup)
|
|
11743
|
+
n++
|
|
11744
|
+
}
|
|
11181
11745
|
w.closeMap(head, n)
|
|
11182
11746
|
},
|
|
11183
11747
|
read(r) {
|
|
11184
11748
|
let $name: string | undefined
|
|
11185
11749
|
let $migrations: Read<typeof SqlMigration.fields>[] | undefined
|
|
11186
11750
|
let $durability: string | undefined
|
|
11751
|
+
let $backup: boolean | undefined
|
|
11187
11752
|
for (let n = r.message(); n > 0; n--) {
|
|
11188
11753
|
switch (r.field()) {
|
|
11189
11754
|
case 1:
|
|
@@ -11201,12 +11766,15 @@ export const SqlOpen = message(
|
|
|
11201
11766
|
case 3:
|
|
11202
11767
|
$durability = r.str()
|
|
11203
11768
|
break
|
|
11769
|
+
case 4:
|
|
11770
|
+
$backup = r.bool()
|
|
11771
|
+
break
|
|
11204
11772
|
default:
|
|
11205
11773
|
r.skip()
|
|
11206
11774
|
}
|
|
11207
11775
|
}
|
|
11208
11776
|
r.leave()
|
|
11209
|
-
return { name: $name, migrations: $migrations, durability: $durability }
|
|
11777
|
+
return { name: $name, migrations: $migrations, durability: $durability, backup: $backup }
|
|
11210
11778
|
},
|
|
11211
11779
|
},
|
|
11212
11780
|
)
|
|
@@ -11357,8 +11925,58 @@ export const SqlStatement = message(
|
|
|
11357
11925
|
)
|
|
11358
11926
|
|
|
11359
11927
|
/**
|
|
11360
|
-
*
|
|
11361
|
-
|
|
11928
|
+
* A column a statement's rows are ordered by, named as its rows name it.
|
|
11929
|
+
*/
|
|
11930
|
+
export const SqlOrder = message(
|
|
11931
|
+
'sql.Order',
|
|
11932
|
+
{
|
|
11933
|
+
column: [1, str],
|
|
11934
|
+
descending: [2, bool],
|
|
11935
|
+
},
|
|
11936
|
+
{
|
|
11937
|
+
write(w, v) {
|
|
11938
|
+
const head = w.openMap()
|
|
11939
|
+
let n = 0
|
|
11940
|
+
if (v.column !== undefined) {
|
|
11941
|
+
w.field(1)
|
|
11942
|
+
w.str(v.column)
|
|
11943
|
+
n++
|
|
11944
|
+
}
|
|
11945
|
+
if (v.descending !== undefined) {
|
|
11946
|
+
w.field(2)
|
|
11947
|
+
w.bool(v.descending)
|
|
11948
|
+
n++
|
|
11949
|
+
}
|
|
11950
|
+
w.closeMap(head, n)
|
|
11951
|
+
},
|
|
11952
|
+
read(r) {
|
|
11953
|
+
let $column: string | undefined
|
|
11954
|
+
let $descending: boolean | undefined
|
|
11955
|
+
for (let n = r.message(); n > 0; n--) {
|
|
11956
|
+
switch (r.field()) {
|
|
11957
|
+
case 1:
|
|
11958
|
+
$column = r.str()
|
|
11959
|
+
break
|
|
11960
|
+
case 2:
|
|
11961
|
+
$descending = r.bool()
|
|
11962
|
+
break
|
|
11963
|
+
default:
|
|
11964
|
+
r.skip()
|
|
11965
|
+
}
|
|
11966
|
+
}
|
|
11967
|
+
r.leave()
|
|
11968
|
+
return { column: $column, descending: $descending }
|
|
11969
|
+
},
|
|
11970
|
+
},
|
|
11971
|
+
)
|
|
11972
|
+
|
|
11973
|
+
/**
|
|
11974
|
+
* What a statement gives back: its rows, one row or none, one value, or each
|
|
11975
|
+
* row as the reader reads it. A write with returning runs on the writer, its
|
|
11976
|
+
* rows given once it is durable. Each reads one snapshot of five seconds at
|
|
11977
|
+
* most; with order, the columns its text orders its rows by, a unique one
|
|
11978
|
+
* last, it reads on past that after the last row it sent, and without it
|
|
11979
|
+
* fails limit there.
|
|
11362
11980
|
*/
|
|
11363
11981
|
export const SqlQuery = message(
|
|
11364
11982
|
'sql.Query',
|
|
@@ -11366,8 +11984,9 @@ export const SqlQuery = message(
|
|
|
11366
11984
|
handle: [1, uint],
|
|
11367
11985
|
text: [2, str],
|
|
11368
11986
|
values: [3, list(sqlValue)],
|
|
11369
|
-
/** all, one or
|
|
11987
|
+
/** all, one, scalar or each */
|
|
11370
11988
|
want: [4, str],
|
|
11989
|
+
order: [5, list(SqlOrder)],
|
|
11371
11990
|
},
|
|
11372
11991
|
{
|
|
11373
11992
|
write(w, v) {
|
|
@@ -11396,6 +12015,14 @@ export const SqlQuery = message(
|
|
|
11396
12015
|
w.str(v.want)
|
|
11397
12016
|
n++
|
|
11398
12017
|
}
|
|
12018
|
+
if (v.order !== undefined) {
|
|
12019
|
+
w.field(5)
|
|
12020
|
+
w.array(v.order.length)
|
|
12021
|
+
for (const item0 of v.order) {
|
|
12022
|
+
SqlOrder.write(w, item0)
|
|
12023
|
+
}
|
|
12024
|
+
n++
|
|
12025
|
+
}
|
|
11399
12026
|
w.closeMap(head, n)
|
|
11400
12027
|
},
|
|
11401
12028
|
read(r) {
|
|
@@ -11403,6 +12030,7 @@ export const SqlQuery = message(
|
|
|
11403
12030
|
let $text: string | undefined
|
|
11404
12031
|
let $values: (SqlValue | boolean)[] | undefined
|
|
11405
12032
|
let $want: string | undefined
|
|
12033
|
+
let $order: Read<typeof SqlOrder.fields>[] | undefined
|
|
11406
12034
|
for (let n = r.message(); n > 0; n--) {
|
|
11407
12035
|
switch (r.field()) {
|
|
11408
12036
|
case 1:
|
|
@@ -11423,12 +12051,21 @@ export const SqlQuery = message(
|
|
|
11423
12051
|
case 4:
|
|
11424
12052
|
$want = r.str()
|
|
11425
12053
|
break
|
|
12054
|
+
case 5: {
|
|
12055
|
+
const items0: Read<typeof SqlOrder.fields>[] = []
|
|
12056
|
+
for (let i0 = r.array(); i0 > 0; i0--) {
|
|
12057
|
+
items0.push(SqlOrder.read(r))
|
|
12058
|
+
}
|
|
12059
|
+
r.leave()
|
|
12060
|
+
$order = items0
|
|
12061
|
+
break
|
|
12062
|
+
}
|
|
11426
12063
|
default:
|
|
11427
12064
|
r.skip()
|
|
11428
12065
|
}
|
|
11429
12066
|
}
|
|
11430
12067
|
r.leave()
|
|
11431
|
-
return { handle: $handle, text: $text, values: $values, want: $want }
|
|
12068
|
+
return { handle: $handle, text: $text, values: $values, want: $want, order: $order }
|
|
11432
12069
|
},
|
|
11433
12070
|
},
|
|
11434
12071
|
)
|
|
@@ -12498,8 +13135,8 @@ export const SearchSetMany = message(
|
|
|
12498
13135
|
|
|
12499
13136
|
/**
|
|
12500
13137
|
* 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,
|
|
12502
|
-
* matched it when the query asked.
|
|
13138
|
+
* the answer's columns, as sql.Rows holds one, where the search's words
|
|
13139
|
+
* matched it when the query asked, and what each half of the search gave it.
|
|
12503
13140
|
*/
|
|
12504
13141
|
export const SearchHit = message(
|
|
12505
13142
|
'search.Hit',
|
|
@@ -12510,6 +13147,10 @@ export const SearchHit = message(
|
|
|
12510
13147
|
score: [3, float],
|
|
12511
13148
|
row: [4, list(sqlValue)],
|
|
12512
13149
|
matches: [5, list(SearchMatch)],
|
|
13150
|
+
/** its words' score, where they found it among their best */
|
|
13151
|
+
textScore: [6, float],
|
|
13152
|
+
/** its vector's cosine with the search's, where both have one */
|
|
13153
|
+
similarity: [7, float],
|
|
12513
13154
|
},
|
|
12514
13155
|
{
|
|
12515
13156
|
write(w, v) {
|
|
@@ -12546,6 +13187,16 @@ export const SearchHit = message(
|
|
|
12546
13187
|
}
|
|
12547
13188
|
n++
|
|
12548
13189
|
}
|
|
13190
|
+
if (v.textScore !== undefined) {
|
|
13191
|
+
w.field(6)
|
|
13192
|
+
w.float(v.textScore)
|
|
13193
|
+
n++
|
|
13194
|
+
}
|
|
13195
|
+
if (v.similarity !== undefined) {
|
|
13196
|
+
w.field(7)
|
|
13197
|
+
w.float(v.similarity)
|
|
13198
|
+
n++
|
|
13199
|
+
}
|
|
12549
13200
|
w.closeMap(head, n)
|
|
12550
13201
|
},
|
|
12551
13202
|
read(r) {
|
|
@@ -12554,6 +13205,8 @@ export const SearchHit = message(
|
|
|
12554
13205
|
let $score: number | undefined
|
|
12555
13206
|
let $row: (SqlValue | boolean)[] | undefined
|
|
12556
13207
|
let $matches: Read<typeof SearchMatch.fields>[] | undefined
|
|
13208
|
+
let $textScore: number | undefined
|
|
13209
|
+
let $similarity: number | undefined
|
|
12557
13210
|
for (let n = r.message(); n > 0; n--) {
|
|
12558
13211
|
switch (r.field()) {
|
|
12559
13212
|
case 1:
|
|
@@ -12583,12 +13236,26 @@ export const SearchHit = message(
|
|
|
12583
13236
|
$matches = items0
|
|
12584
13237
|
break
|
|
12585
13238
|
}
|
|
13239
|
+
case 6:
|
|
13240
|
+
$textScore = r.float()
|
|
13241
|
+
break
|
|
13242
|
+
case 7:
|
|
13243
|
+
$similarity = r.float()
|
|
13244
|
+
break
|
|
12586
13245
|
default:
|
|
12587
13246
|
r.skip()
|
|
12588
13247
|
}
|
|
12589
13248
|
}
|
|
12590
13249
|
r.leave()
|
|
12591
|
-
return {
|
|
13250
|
+
return {
|
|
13251
|
+
id: $id,
|
|
13252
|
+
value: $value,
|
|
13253
|
+
score: $score,
|
|
13254
|
+
row: $row,
|
|
13255
|
+
matches: $matches,
|
|
13256
|
+
textScore: $textScore,
|
|
13257
|
+
similarity: $similarity,
|
|
13258
|
+
}
|
|
12592
13259
|
},
|
|
12593
13260
|
},
|
|
12594
13261
|
)
|