@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/dist/wire/protocol.js
CHANGED
|
@@ -15,6 +15,10 @@ export const methods = {
|
|
|
15
15
|
'blobs.usage': 0x040b,
|
|
16
16
|
'blobs.clear': 0x040c,
|
|
17
17
|
'blobs.read': 0x040d,
|
|
18
|
+
'blobs.directory': 0x040e,
|
|
19
|
+
'blobs.scan': 0x040f,
|
|
20
|
+
'blobs.changes': 0x0410,
|
|
21
|
+
'blobs.forget': 0x0411,
|
|
18
22
|
/**
|
|
19
23
|
* Answers once the store has the message, not once anyone handled it; in a
|
|
20
24
|
* database's transaction, it is handed over once the transaction commits.
|
|
@@ -47,6 +51,7 @@ export const methods = {
|
|
|
47
51
|
'jobs.keep': 0x020b,
|
|
48
52
|
'jobs.watch': 0x020c,
|
|
49
53
|
'jobs.tx': 0x020d,
|
|
54
|
+
'jobs.counts': 0x020e,
|
|
50
55
|
'kv.bucket.open': 0x0101,
|
|
51
56
|
'kv.get': 0x0102,
|
|
52
57
|
'kv.has': 0x0103,
|
|
@@ -244,6 +249,8 @@ export const BackupWritten = message('backup.Written', {
|
|
|
244
249
|
bytes: [2, uint],
|
|
245
250
|
/** the store seals values with a key the backup does not hold */
|
|
246
251
|
keyLeftOut: [3, bool],
|
|
252
|
+
/** the databases opened with backup false, which it holds nothing of */
|
|
253
|
+
excluded: [4, list(str)],
|
|
247
254
|
}, {
|
|
248
255
|
write(w, v) {
|
|
249
256
|
const head = w.openMap();
|
|
@@ -263,12 +270,21 @@ export const BackupWritten = message('backup.Written', {
|
|
|
263
270
|
w.bool(v.keyLeftOut);
|
|
264
271
|
n++;
|
|
265
272
|
}
|
|
273
|
+
if (v.excluded !== undefined) {
|
|
274
|
+
w.field(4);
|
|
275
|
+
w.array(v.excluded.length);
|
|
276
|
+
for (const item0 of v.excluded) {
|
|
277
|
+
w.str(item0);
|
|
278
|
+
}
|
|
279
|
+
n++;
|
|
280
|
+
}
|
|
266
281
|
w.closeMap(head, n);
|
|
267
282
|
},
|
|
268
283
|
read(r) {
|
|
269
284
|
let $files;
|
|
270
285
|
let $bytes;
|
|
271
286
|
let $keyLeftOut;
|
|
287
|
+
let $excluded;
|
|
272
288
|
for (let n = r.message(); n > 0; n--) {
|
|
273
289
|
switch (r.field()) {
|
|
274
290
|
case 1:
|
|
@@ -280,12 +296,21 @@ export const BackupWritten = message('backup.Written', {
|
|
|
280
296
|
case 3:
|
|
281
297
|
$keyLeftOut = r.bool();
|
|
282
298
|
break;
|
|
299
|
+
case 4: {
|
|
300
|
+
const items0 = [];
|
|
301
|
+
for (let i0 = r.array(); i0 > 0; i0--) {
|
|
302
|
+
items0.push(r.str());
|
|
303
|
+
}
|
|
304
|
+
r.leave();
|
|
305
|
+
$excluded = items0;
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
283
308
|
default:
|
|
284
309
|
r.skip();
|
|
285
310
|
}
|
|
286
311
|
}
|
|
287
312
|
r.leave();
|
|
288
|
-
return { files: $files, bytes: $bytes, keyLeftOut: $keyLeftOut };
|
|
313
|
+
return { files: $files, bytes: $bytes, keyLeftOut: $keyLeftOut, excluded: $excluded };
|
|
289
314
|
},
|
|
290
315
|
});
|
|
291
316
|
/**
|
|
@@ -694,10 +719,13 @@ export const BlobsWritten = message('blobs.Written', {
|
|
|
694
719
|
});
|
|
695
720
|
/**
|
|
696
721
|
* A piece of a file's bytes: an upload's DATA from the client, a read's from
|
|
697
|
-
* the server.
|
|
722
|
+
* the server. A piece of a growing directory's file brings the file's size
|
|
723
|
+
* and time as it was read, so that the reader sees it moved.
|
|
698
724
|
*/
|
|
699
725
|
export const BlobsPiece = message('blobs.Piece', {
|
|
700
726
|
bytes: [1, bin],
|
|
727
|
+
size: [2, uint],
|
|
728
|
+
lastModified: [3, int],
|
|
701
729
|
}, {
|
|
702
730
|
write(w, v) {
|
|
703
731
|
const head = w.openMap();
|
|
@@ -707,21 +735,39 @@ export const BlobsPiece = message('blobs.Piece', {
|
|
|
707
735
|
w.bin(v.bytes);
|
|
708
736
|
n++;
|
|
709
737
|
}
|
|
738
|
+
if (v.size !== undefined) {
|
|
739
|
+
w.field(2);
|
|
740
|
+
w.uint(v.size);
|
|
741
|
+
n++;
|
|
742
|
+
}
|
|
743
|
+
if (v.lastModified !== undefined) {
|
|
744
|
+
w.field(3);
|
|
745
|
+
w.int(v.lastModified);
|
|
746
|
+
n++;
|
|
747
|
+
}
|
|
710
748
|
w.closeMap(head, n);
|
|
711
749
|
},
|
|
712
750
|
read(r) {
|
|
713
751
|
let $bytes;
|
|
752
|
+
let $size;
|
|
753
|
+
let $lastModified;
|
|
714
754
|
for (let n = r.message(); n > 0; n--) {
|
|
715
755
|
switch (r.field()) {
|
|
716
756
|
case 1:
|
|
717
757
|
$bytes = r.bytes();
|
|
718
758
|
break;
|
|
759
|
+
case 2:
|
|
760
|
+
$size = r.uint();
|
|
761
|
+
break;
|
|
762
|
+
case 3:
|
|
763
|
+
$lastModified = r.int();
|
|
764
|
+
break;
|
|
719
765
|
default:
|
|
720
766
|
r.skip();
|
|
721
767
|
}
|
|
722
768
|
}
|
|
723
769
|
r.leave();
|
|
724
|
-
return { bytes: $bytes };
|
|
770
|
+
return { bytes: $bytes, size: $size, lastModified: $lastModified };
|
|
725
771
|
},
|
|
726
772
|
});
|
|
727
773
|
/**
|
|
@@ -1356,6 +1402,331 @@ export const BlobsUsage = message('blobs.Usage', {
|
|
|
1356
1402
|
return { count: $count, size: $size };
|
|
1357
1403
|
},
|
|
1358
1404
|
});
|
|
1405
|
+
/**
|
|
1406
|
+
* Opens a directory by name: a folder of the server's machine, which the
|
|
1407
|
+
* store lists and reads and never writes. Its handle takes get, head, list,
|
|
1408
|
+
* usage and read as a set of files' does, each answered from the list the
|
|
1409
|
+
* last scan wrote but a get's and a read's bytes, which come from the disk;
|
|
1410
|
+
* every call that writes a file is invalid. A connection that came with a
|
|
1411
|
+
* token names no path: it opens the directory the server was given under the
|
|
1412
|
+
* name, and one the server was not given is invalid.
|
|
1413
|
+
*/
|
|
1414
|
+
export const BlobsDirectory = message('blobs.Directory', {
|
|
1415
|
+
/** [a-z0-9][a-z0-9_-]{0,63}, never a set of files' name too */
|
|
1416
|
+
name: [1, str],
|
|
1417
|
+
/** the folder on the server's machine; the server's own when absent */
|
|
1418
|
+
path: [2, str],
|
|
1419
|
+
/** a scan on the store's background work, a period apart */
|
|
1420
|
+
every: [3, uint],
|
|
1421
|
+
/** names a scan passes over, * for any run of a name's characters */
|
|
1422
|
+
ignore: [4, list(str)],
|
|
1423
|
+
/** a read holds to no version and goes up to the size now */
|
|
1424
|
+
growing: [5, bool],
|
|
1425
|
+
}, {
|
|
1426
|
+
write(w, v) {
|
|
1427
|
+
const head = w.openMap();
|
|
1428
|
+
let n = 0;
|
|
1429
|
+
if (v.name !== undefined) {
|
|
1430
|
+
w.field(1);
|
|
1431
|
+
w.str(v.name);
|
|
1432
|
+
n++;
|
|
1433
|
+
}
|
|
1434
|
+
if (v.path !== undefined) {
|
|
1435
|
+
w.field(2);
|
|
1436
|
+
w.str(v.path);
|
|
1437
|
+
n++;
|
|
1438
|
+
}
|
|
1439
|
+
if (v.every !== undefined) {
|
|
1440
|
+
w.field(3);
|
|
1441
|
+
w.uint(v.every);
|
|
1442
|
+
n++;
|
|
1443
|
+
}
|
|
1444
|
+
if (v.ignore !== undefined) {
|
|
1445
|
+
w.field(4);
|
|
1446
|
+
w.array(v.ignore.length);
|
|
1447
|
+
for (const item0 of v.ignore) {
|
|
1448
|
+
w.str(item0);
|
|
1449
|
+
}
|
|
1450
|
+
n++;
|
|
1451
|
+
}
|
|
1452
|
+
if (v.growing !== undefined) {
|
|
1453
|
+
w.field(5);
|
|
1454
|
+
w.bool(v.growing);
|
|
1455
|
+
n++;
|
|
1456
|
+
}
|
|
1457
|
+
w.closeMap(head, n);
|
|
1458
|
+
},
|
|
1459
|
+
read(r) {
|
|
1460
|
+
let $name;
|
|
1461
|
+
let $path;
|
|
1462
|
+
let $every;
|
|
1463
|
+
let $ignore;
|
|
1464
|
+
let $growing;
|
|
1465
|
+
for (let n = r.message(); n > 0; n--) {
|
|
1466
|
+
switch (r.field()) {
|
|
1467
|
+
case 1:
|
|
1468
|
+
$name = r.str();
|
|
1469
|
+
break;
|
|
1470
|
+
case 2:
|
|
1471
|
+
$path = r.str();
|
|
1472
|
+
break;
|
|
1473
|
+
case 3:
|
|
1474
|
+
$every = r.uint();
|
|
1475
|
+
break;
|
|
1476
|
+
case 4: {
|
|
1477
|
+
const items0 = [];
|
|
1478
|
+
for (let i0 = r.array(); i0 > 0; i0--) {
|
|
1479
|
+
items0.push(r.str());
|
|
1480
|
+
}
|
|
1481
|
+
r.leave();
|
|
1482
|
+
$ignore = items0;
|
|
1483
|
+
break;
|
|
1484
|
+
}
|
|
1485
|
+
case 5:
|
|
1486
|
+
$growing = r.bool();
|
|
1487
|
+
break;
|
|
1488
|
+
default:
|
|
1489
|
+
r.skip();
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
r.leave();
|
|
1493
|
+
return { name: $name, path: $path, every: $every, ignore: $ignore, growing: $growing };
|
|
1494
|
+
},
|
|
1495
|
+
});
|
|
1496
|
+
/**
|
|
1497
|
+
* What a scan found, and what the list holds once it ended.
|
|
1498
|
+
*/
|
|
1499
|
+
export const BlobsScanned = message('blobs.Scanned', {
|
|
1500
|
+
added: [1, uint],
|
|
1501
|
+
changed: [2, uint],
|
|
1502
|
+
removed: [3, uint],
|
|
1503
|
+
/** what it met and could not list: a link, a folder it cannot read, another disk */
|
|
1504
|
+
skipped: [4, uint],
|
|
1505
|
+
count: [5, uint],
|
|
1506
|
+
size: [6, uint],
|
|
1507
|
+
}, {
|
|
1508
|
+
write(w, v) {
|
|
1509
|
+
const head = w.openMap();
|
|
1510
|
+
let n = 0;
|
|
1511
|
+
if (v.added !== undefined) {
|
|
1512
|
+
w.field(1);
|
|
1513
|
+
w.uint(v.added);
|
|
1514
|
+
n++;
|
|
1515
|
+
}
|
|
1516
|
+
if (v.changed !== undefined) {
|
|
1517
|
+
w.field(2);
|
|
1518
|
+
w.uint(v.changed);
|
|
1519
|
+
n++;
|
|
1520
|
+
}
|
|
1521
|
+
if (v.removed !== undefined) {
|
|
1522
|
+
w.field(3);
|
|
1523
|
+
w.uint(v.removed);
|
|
1524
|
+
n++;
|
|
1525
|
+
}
|
|
1526
|
+
if (v.skipped !== undefined) {
|
|
1527
|
+
w.field(4);
|
|
1528
|
+
w.uint(v.skipped);
|
|
1529
|
+
n++;
|
|
1530
|
+
}
|
|
1531
|
+
if (v.count !== undefined) {
|
|
1532
|
+
w.field(5);
|
|
1533
|
+
w.uint(v.count);
|
|
1534
|
+
n++;
|
|
1535
|
+
}
|
|
1536
|
+
if (v.size !== undefined) {
|
|
1537
|
+
w.field(6);
|
|
1538
|
+
w.uint(v.size);
|
|
1539
|
+
n++;
|
|
1540
|
+
}
|
|
1541
|
+
w.closeMap(head, n);
|
|
1542
|
+
},
|
|
1543
|
+
read(r) {
|
|
1544
|
+
let $added;
|
|
1545
|
+
let $changed;
|
|
1546
|
+
let $removed;
|
|
1547
|
+
let $skipped;
|
|
1548
|
+
let $count;
|
|
1549
|
+
let $size;
|
|
1550
|
+
for (let n = r.message(); n > 0; n--) {
|
|
1551
|
+
switch (r.field()) {
|
|
1552
|
+
case 1:
|
|
1553
|
+
$added = r.uint();
|
|
1554
|
+
break;
|
|
1555
|
+
case 2:
|
|
1556
|
+
$changed = r.uint();
|
|
1557
|
+
break;
|
|
1558
|
+
case 3:
|
|
1559
|
+
$removed = r.uint();
|
|
1560
|
+
break;
|
|
1561
|
+
case 4:
|
|
1562
|
+
$skipped = r.uint();
|
|
1563
|
+
break;
|
|
1564
|
+
case 5:
|
|
1565
|
+
$count = r.uint();
|
|
1566
|
+
break;
|
|
1567
|
+
case 6:
|
|
1568
|
+
$size = r.uint();
|
|
1569
|
+
break;
|
|
1570
|
+
default:
|
|
1571
|
+
r.skip();
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
r.leave();
|
|
1575
|
+
return {
|
|
1576
|
+
added: $added,
|
|
1577
|
+
changed: $changed,
|
|
1578
|
+
removed: $removed,
|
|
1579
|
+
skipped: $skipped,
|
|
1580
|
+
count: $count,
|
|
1581
|
+
size: $size,
|
|
1582
|
+
};
|
|
1583
|
+
},
|
|
1584
|
+
});
|
|
1585
|
+
/**
|
|
1586
|
+
* The changes of a directory past a cursor, from the first file it listed
|
|
1587
|
+
* when absent.
|
|
1588
|
+
*/
|
|
1589
|
+
export const BlobsSince = message('blobs.Since', {
|
|
1590
|
+
handle: [1, uint],
|
|
1591
|
+
/** a page's next */
|
|
1592
|
+
after: [2, str],
|
|
1593
|
+
}, {
|
|
1594
|
+
write(w, v) {
|
|
1595
|
+
const head = w.openMap();
|
|
1596
|
+
let n = 0;
|
|
1597
|
+
if (v.handle !== undefined) {
|
|
1598
|
+
w.field(1);
|
|
1599
|
+
w.uint(v.handle);
|
|
1600
|
+
n++;
|
|
1601
|
+
}
|
|
1602
|
+
if (v.after !== undefined) {
|
|
1603
|
+
w.field(2);
|
|
1604
|
+
w.str(v.after);
|
|
1605
|
+
n++;
|
|
1606
|
+
}
|
|
1607
|
+
w.closeMap(head, n);
|
|
1608
|
+
},
|
|
1609
|
+
read(r) {
|
|
1610
|
+
let $handle;
|
|
1611
|
+
let $after;
|
|
1612
|
+
for (let n = r.message(); n > 0; n--) {
|
|
1613
|
+
switch (r.field()) {
|
|
1614
|
+
case 1:
|
|
1615
|
+
$handle = r.uint();
|
|
1616
|
+
break;
|
|
1617
|
+
case 2:
|
|
1618
|
+
$after = r.str();
|
|
1619
|
+
break;
|
|
1620
|
+
default:
|
|
1621
|
+
r.skip();
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
r.leave();
|
|
1625
|
+
return { handle: $handle, after: $after };
|
|
1626
|
+
},
|
|
1627
|
+
});
|
|
1628
|
+
export const BlobsChange = message('blobs.Change', {
|
|
1629
|
+
/** the whole path in the directory */
|
|
1630
|
+
path: [1, str],
|
|
1631
|
+
/** added, changed or removed */
|
|
1632
|
+
change: [2, str],
|
|
1633
|
+
/** none once removed */
|
|
1634
|
+
info: [3, BlobsInfo],
|
|
1635
|
+
}, {
|
|
1636
|
+
write(w, v) {
|
|
1637
|
+
const head = w.openMap();
|
|
1638
|
+
let n = 0;
|
|
1639
|
+
if (v.path !== undefined) {
|
|
1640
|
+
w.field(1);
|
|
1641
|
+
w.str(v.path);
|
|
1642
|
+
n++;
|
|
1643
|
+
}
|
|
1644
|
+
if (v.change !== undefined) {
|
|
1645
|
+
w.field(2);
|
|
1646
|
+
w.str(v.change);
|
|
1647
|
+
n++;
|
|
1648
|
+
}
|
|
1649
|
+
if (v.info !== undefined) {
|
|
1650
|
+
w.field(3);
|
|
1651
|
+
BlobsInfo.write(w, v.info);
|
|
1652
|
+
n++;
|
|
1653
|
+
}
|
|
1654
|
+
w.closeMap(head, n);
|
|
1655
|
+
},
|
|
1656
|
+
read(r) {
|
|
1657
|
+
let $path;
|
|
1658
|
+
let $change;
|
|
1659
|
+
let $info;
|
|
1660
|
+
for (let n = r.message(); n > 0; n--) {
|
|
1661
|
+
switch (r.field()) {
|
|
1662
|
+
case 1:
|
|
1663
|
+
$path = r.str();
|
|
1664
|
+
break;
|
|
1665
|
+
case 2:
|
|
1666
|
+
$change = r.str();
|
|
1667
|
+
break;
|
|
1668
|
+
case 3:
|
|
1669
|
+
$info = BlobsInfo.read(r);
|
|
1670
|
+
break;
|
|
1671
|
+
default:
|
|
1672
|
+
r.skip();
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
r.leave();
|
|
1676
|
+
return { path: $path, change: $change, info: $info };
|
|
1677
|
+
},
|
|
1678
|
+
});
|
|
1679
|
+
/**
|
|
1680
|
+
* A page of changes in the order the scans wrote them, 1000 at most; next is
|
|
1681
|
+
* always there, with no items the cursor to ask from after the next scan.
|
|
1682
|
+
*/
|
|
1683
|
+
export const BlobsChanges = message('blobs.Changes', {
|
|
1684
|
+
items: [1, list(BlobsChange)],
|
|
1685
|
+
next: [2, str],
|
|
1686
|
+
}, {
|
|
1687
|
+
write(w, v) {
|
|
1688
|
+
const head = w.openMap();
|
|
1689
|
+
let n = 0;
|
|
1690
|
+
if (v.items !== undefined) {
|
|
1691
|
+
w.field(1);
|
|
1692
|
+
w.array(v.items.length);
|
|
1693
|
+
for (const item0 of v.items) {
|
|
1694
|
+
BlobsChange.write(w, item0);
|
|
1695
|
+
}
|
|
1696
|
+
n++;
|
|
1697
|
+
}
|
|
1698
|
+
if (v.next !== undefined) {
|
|
1699
|
+
w.field(2);
|
|
1700
|
+
w.str(v.next);
|
|
1701
|
+
n++;
|
|
1702
|
+
}
|
|
1703
|
+
w.closeMap(head, n);
|
|
1704
|
+
},
|
|
1705
|
+
read(r) {
|
|
1706
|
+
let $items;
|
|
1707
|
+
let $next;
|
|
1708
|
+
for (let n = r.message(); n > 0; n--) {
|
|
1709
|
+
switch (r.field()) {
|
|
1710
|
+
case 1: {
|
|
1711
|
+
const items0 = [];
|
|
1712
|
+
for (let i0 = r.array(); i0 > 0; i0--) {
|
|
1713
|
+
items0.push(BlobsChange.read(r));
|
|
1714
|
+
}
|
|
1715
|
+
r.leave();
|
|
1716
|
+
$items = items0;
|
|
1717
|
+
break;
|
|
1718
|
+
}
|
|
1719
|
+
case 2:
|
|
1720
|
+
$next = r.str();
|
|
1721
|
+
break;
|
|
1722
|
+
default:
|
|
1723
|
+
r.skip();
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
r.leave();
|
|
1727
|
+
return { items: $items, next: $next };
|
|
1728
|
+
},
|
|
1729
|
+
});
|
|
1359
1730
|
/**
|
|
1360
1731
|
* A message published on a channel's branch, as docs/guides/channels/README.md has
|
|
1361
1732
|
* it: every subscription listening there now receives it.
|
|
@@ -2989,11 +3360,13 @@ export const JobsCall = message('jobs.Call', {
|
|
|
2989
3360
|
},
|
|
2990
3361
|
});
|
|
2991
3362
|
/**
|
|
2992
|
-
* The job under an id
|
|
3363
|
+
* The job under an id; or, for a cancel, a job without one by the row a page
|
|
3364
|
+
* gave, its id left out.
|
|
2993
3365
|
*/
|
|
2994
3366
|
export const JobsId = message('jobs.Id', {
|
|
2995
3367
|
handle: [1, uint],
|
|
2996
3368
|
id: [2, str],
|
|
3369
|
+
row: [3, str],
|
|
2997
3370
|
}, {
|
|
2998
3371
|
write(w, v) {
|
|
2999
3372
|
const head = w.openMap();
|
|
@@ -3008,11 +3381,17 @@ export const JobsId = message('jobs.Id', {
|
|
|
3008
3381
|
w.str(v.id);
|
|
3009
3382
|
n++;
|
|
3010
3383
|
}
|
|
3384
|
+
if (v.row !== undefined) {
|
|
3385
|
+
w.field(3);
|
|
3386
|
+
w.str(v.row);
|
|
3387
|
+
n++;
|
|
3388
|
+
}
|
|
3011
3389
|
w.closeMap(head, n);
|
|
3012
3390
|
},
|
|
3013
3391
|
read(r) {
|
|
3014
3392
|
let $handle;
|
|
3015
3393
|
let $id;
|
|
3394
|
+
let $row;
|
|
3016
3395
|
for (let n = r.message(); n > 0; n--) {
|
|
3017
3396
|
switch (r.field()) {
|
|
3018
3397
|
case 1:
|
|
@@ -3021,12 +3400,15 @@ export const JobsId = message('jobs.Id', {
|
|
|
3021
3400
|
case 2:
|
|
3022
3401
|
$id = r.str();
|
|
3023
3402
|
break;
|
|
3403
|
+
case 3:
|
|
3404
|
+
$row = r.str();
|
|
3405
|
+
break;
|
|
3024
3406
|
default:
|
|
3025
3407
|
r.skip();
|
|
3026
3408
|
}
|
|
3027
3409
|
}
|
|
3028
3410
|
r.leave();
|
|
3029
|
-
return { handle: $handle, id: $id };
|
|
3411
|
+
return { handle: $handle, id: $id, row: $row };
|
|
3030
3412
|
},
|
|
3031
3413
|
});
|
|
3032
3414
|
/**
|
|
@@ -3083,6 +3465,10 @@ export const JobsJob = message('jobs.Job', {
|
|
|
3083
3465
|
/** the last run a handler finished */
|
|
3084
3466
|
startedAt: [12, int],
|
|
3085
3467
|
endedAt: [13, int],
|
|
3468
|
+
/** where a job without an id lies, which a cancel names it by */
|
|
3469
|
+
row: [14, str],
|
|
3470
|
+
/** a walk's: why the job's value no longer reads, the job left out */
|
|
3471
|
+
failure: [15, Failure],
|
|
3086
3472
|
}, {
|
|
3087
3473
|
write(w, v) {
|
|
3088
3474
|
const head = w.openMap();
|
|
@@ -3152,6 +3538,16 @@ export const JobsJob = message('jobs.Job', {
|
|
|
3152
3538
|
w.int(v.endedAt);
|
|
3153
3539
|
n++;
|
|
3154
3540
|
}
|
|
3541
|
+
if (v.row !== undefined) {
|
|
3542
|
+
w.field(14);
|
|
3543
|
+
w.str(v.row);
|
|
3544
|
+
n++;
|
|
3545
|
+
}
|
|
3546
|
+
if (v.failure !== undefined) {
|
|
3547
|
+
w.field(15);
|
|
3548
|
+
Failure.write(w, v.failure);
|
|
3549
|
+
n++;
|
|
3550
|
+
}
|
|
3155
3551
|
w.closeMap(head, n);
|
|
3156
3552
|
},
|
|
3157
3553
|
read(r) {
|
|
@@ -3168,6 +3564,8 @@ export const JobsJob = message('jobs.Job', {
|
|
|
3168
3564
|
let $repeat;
|
|
3169
3565
|
let $startedAt;
|
|
3170
3566
|
let $endedAt;
|
|
3567
|
+
let $row;
|
|
3568
|
+
let $failure;
|
|
3171
3569
|
for (let n = r.message(); n > 0; n--) {
|
|
3172
3570
|
switch (r.field()) {
|
|
3173
3571
|
case 1:
|
|
@@ -3209,6 +3607,12 @@ export const JobsJob = message('jobs.Job', {
|
|
|
3209
3607
|
case 13:
|
|
3210
3608
|
$endedAt = r.int();
|
|
3211
3609
|
break;
|
|
3610
|
+
case 14:
|
|
3611
|
+
$row = r.str();
|
|
3612
|
+
break;
|
|
3613
|
+
case 15:
|
|
3614
|
+
$failure = Failure.read(r);
|
|
3615
|
+
break;
|
|
3212
3616
|
default:
|
|
3213
3617
|
r.skip();
|
|
3214
3618
|
}
|
|
@@ -3228,13 +3632,16 @@ export const JobsJob = message('jobs.Job', {
|
|
|
3228
3632
|
repeat: $repeat,
|
|
3229
3633
|
startedAt: $startedAt,
|
|
3230
3634
|
endedAt: $endedAt,
|
|
3635
|
+
row: $row,
|
|
3636
|
+
failure: $failure,
|
|
3231
3637
|
};
|
|
3232
3638
|
},
|
|
3233
3639
|
});
|
|
3234
3640
|
/**
|
|
3235
3641
|
* A page of a queue's jobs: those whose ids start with a prefix, in the byte
|
|
3236
|
-
* order of their ids
|
|
3237
|
-
*
|
|
3642
|
+
* order of their ids; with no prefix every job, those with ids first, then
|
|
3643
|
+
* those without as they run, then those without that failed, the last failed
|
|
3644
|
+
* first; with no prefix and the failed state the failed alone, the last first.
|
|
3238
3645
|
*/
|
|
3239
3646
|
export const JobsList = message('jobs.List', {
|
|
3240
3647
|
handle: [1, uint],
|
|
@@ -3245,6 +3652,8 @@ export const JobsList = message('jobs.List', {
|
|
|
3245
3652
|
after: [4, str],
|
|
3246
3653
|
/** 100 when absent, 1000 at most */
|
|
3247
3654
|
limit: [5, uint],
|
|
3655
|
+
/** a job whose value no longer reads comes as its failure in its place, not the page's */
|
|
3656
|
+
walk: [6, bool],
|
|
3248
3657
|
}, {
|
|
3249
3658
|
write(w, v) {
|
|
3250
3659
|
const head = w.openMap();
|
|
@@ -3274,6 +3683,11 @@ export const JobsList = message('jobs.List', {
|
|
|
3274
3683
|
w.uint(v.limit);
|
|
3275
3684
|
n++;
|
|
3276
3685
|
}
|
|
3686
|
+
if (v.walk !== undefined) {
|
|
3687
|
+
w.field(6);
|
|
3688
|
+
w.bool(v.walk);
|
|
3689
|
+
n++;
|
|
3690
|
+
}
|
|
3277
3691
|
w.closeMap(head, n);
|
|
3278
3692
|
},
|
|
3279
3693
|
read(r) {
|
|
@@ -3282,6 +3696,7 @@ export const JobsList = message('jobs.List', {
|
|
|
3282
3696
|
let $state;
|
|
3283
3697
|
let $after;
|
|
3284
3698
|
let $limit;
|
|
3699
|
+
let $walk;
|
|
3285
3700
|
for (let n = r.message(); n > 0; n--) {
|
|
3286
3701
|
switch (r.field()) {
|
|
3287
3702
|
case 1:
|
|
@@ -3299,12 +3714,22 @@ export const JobsList = message('jobs.List', {
|
|
|
3299
3714
|
case 5:
|
|
3300
3715
|
$limit = r.uint();
|
|
3301
3716
|
break;
|
|
3717
|
+
case 6:
|
|
3718
|
+
$walk = r.bool();
|
|
3719
|
+
break;
|
|
3302
3720
|
default:
|
|
3303
3721
|
r.skip();
|
|
3304
3722
|
}
|
|
3305
3723
|
}
|
|
3306
3724
|
r.leave();
|
|
3307
|
-
return {
|
|
3725
|
+
return {
|
|
3726
|
+
handle: $handle,
|
|
3727
|
+
prefix: $prefix,
|
|
3728
|
+
state: $state,
|
|
3729
|
+
after: $after,
|
|
3730
|
+
limit: $limit,
|
|
3731
|
+
walk: $walk,
|
|
3732
|
+
};
|
|
3308
3733
|
},
|
|
3309
3734
|
});
|
|
3310
3735
|
export const JobsPage = message('jobs.Page', {
|
|
@@ -3354,6 +3779,71 @@ export const JobsPage = message('jobs.Page', {
|
|
|
3354
3779
|
return { jobs: $jobs, next: $next };
|
|
3355
3780
|
},
|
|
3356
3781
|
});
|
|
3782
|
+
/**
|
|
3783
|
+
* How many jobs a queue holds in each state, from one snapshot; a done job
|
|
3784
|
+
* has left it.
|
|
3785
|
+
*/
|
|
3786
|
+
export const JobsCounts = message('jobs.Counts', {
|
|
3787
|
+
/** due later */
|
|
3788
|
+
scheduled: [1, uint],
|
|
3789
|
+
/** due, and no handler runs it yet */
|
|
3790
|
+
waiting: [2, uint],
|
|
3791
|
+
running: [3, uint],
|
|
3792
|
+
/** kept for the queue's keep */
|
|
3793
|
+
failed: [4, uint],
|
|
3794
|
+
}, {
|
|
3795
|
+
write(w, v) {
|
|
3796
|
+
const head = w.openMap();
|
|
3797
|
+
let n = 0;
|
|
3798
|
+
if (v.scheduled !== undefined) {
|
|
3799
|
+
w.field(1);
|
|
3800
|
+
w.uint(v.scheduled);
|
|
3801
|
+
n++;
|
|
3802
|
+
}
|
|
3803
|
+
if (v.waiting !== undefined) {
|
|
3804
|
+
w.field(2);
|
|
3805
|
+
w.uint(v.waiting);
|
|
3806
|
+
n++;
|
|
3807
|
+
}
|
|
3808
|
+
if (v.running !== undefined) {
|
|
3809
|
+
w.field(3);
|
|
3810
|
+
w.uint(v.running);
|
|
3811
|
+
n++;
|
|
3812
|
+
}
|
|
3813
|
+
if (v.failed !== undefined) {
|
|
3814
|
+
w.field(4);
|
|
3815
|
+
w.uint(v.failed);
|
|
3816
|
+
n++;
|
|
3817
|
+
}
|
|
3818
|
+
w.closeMap(head, n);
|
|
3819
|
+
},
|
|
3820
|
+
read(r) {
|
|
3821
|
+
let $scheduled;
|
|
3822
|
+
let $waiting;
|
|
3823
|
+
let $running;
|
|
3824
|
+
let $failed;
|
|
3825
|
+
for (let n = r.message(); n > 0; n--) {
|
|
3826
|
+
switch (r.field()) {
|
|
3827
|
+
case 1:
|
|
3828
|
+
$scheduled = r.uint();
|
|
3829
|
+
break;
|
|
3830
|
+
case 2:
|
|
3831
|
+
$waiting = r.uint();
|
|
3832
|
+
break;
|
|
3833
|
+
case 3:
|
|
3834
|
+
$running = r.uint();
|
|
3835
|
+
break;
|
|
3836
|
+
case 4:
|
|
3837
|
+
$failed = r.uint();
|
|
3838
|
+
break;
|
|
3839
|
+
default:
|
|
3840
|
+
r.skip();
|
|
3841
|
+
}
|
|
3842
|
+
}
|
|
3843
|
+
r.leave();
|
|
3844
|
+
return { scheduled: $scheduled, waiting: $waiting, running: $running, failed: $failed };
|
|
3845
|
+
},
|
|
3846
|
+
});
|
|
3357
3847
|
/**
|
|
3358
3848
|
* Starts the queue's worker for the client: the server claims its jobs as they
|
|
3359
3849
|
* fall due and hands each over as a held job, no more at once than the
|
|
@@ -3697,7 +4187,7 @@ export const JobsKept = message('jobs.Kept', {
|
|
|
3697
4187
|
});
|
|
3698
4188
|
/**
|
|
3699
4189
|
* One write of a transaction: an add, a set or an update with its call, or a
|
|
3700
|
-
* cancel with its id.
|
|
4190
|
+
* cancel with its id or its row.
|
|
3701
4191
|
*/
|
|
3702
4192
|
export const JobsOp = message('jobs.Op', {
|
|
3703
4193
|
/** jobs.add, jobs.set, jobs.update or jobs.cancel */
|
|
@@ -5835,6 +6325,8 @@ export const MetricsAggregateAsked = message('metrics.AggregateAsked', {
|
|
|
5835
6325
|
calendar: [7, str],
|
|
5836
6326
|
/** an IANA name, UTC among them, which calendar takes */
|
|
5837
6327
|
timeZone: [8, str],
|
|
6328
|
+
/** a NaN sample counts in no bucket, which says how many it passed over: skipped */
|
|
6329
|
+
skipNan: [9, bool],
|
|
5838
6330
|
}, {
|
|
5839
6331
|
write(w, v) {
|
|
5840
6332
|
const head = w.openMap();
|
|
@@ -5885,6 +6377,11 @@ export const MetricsAggregateAsked = message('metrics.AggregateAsked', {
|
|
|
5885
6377
|
w.str(v.timeZone);
|
|
5886
6378
|
n++;
|
|
5887
6379
|
}
|
|
6380
|
+
if (v.skipNan !== undefined) {
|
|
6381
|
+
w.field(9);
|
|
6382
|
+
w.bool(v.skipNan);
|
|
6383
|
+
n++;
|
|
6384
|
+
}
|
|
5888
6385
|
w.closeMap(head, n);
|
|
5889
6386
|
},
|
|
5890
6387
|
read(r) {
|
|
@@ -5896,6 +6393,7 @@ export const MetricsAggregateAsked = message('metrics.AggregateAsked', {
|
|
|
5896
6393
|
let $estimate;
|
|
5897
6394
|
let $calendar;
|
|
5898
6395
|
let $timeZone;
|
|
6396
|
+
let $skipNan;
|
|
5899
6397
|
for (let n = r.message(); n > 0; n--) {
|
|
5900
6398
|
switch (r.field()) {
|
|
5901
6399
|
case 1:
|
|
@@ -5934,6 +6432,9 @@ export const MetricsAggregateAsked = message('metrics.AggregateAsked', {
|
|
|
5934
6432
|
case 8:
|
|
5935
6433
|
$timeZone = r.str();
|
|
5936
6434
|
break;
|
|
6435
|
+
case 9:
|
|
6436
|
+
$skipNan = r.bool();
|
|
6437
|
+
break;
|
|
5937
6438
|
default:
|
|
5938
6439
|
r.skip();
|
|
5939
6440
|
}
|
|
@@ -5948,6 +6449,7 @@ export const MetricsAggregateAsked = message('metrics.AggregateAsked', {
|
|
|
5948
6449
|
estimate: $estimate,
|
|
5949
6450
|
calendar: $calendar,
|
|
5950
6451
|
timeZone: $timeZone,
|
|
6452
|
+
skipNan: $skipNan,
|
|
5951
6453
|
};
|
|
5952
6454
|
},
|
|
5953
6455
|
});
|
|
@@ -5969,6 +6471,8 @@ export const MetricsBucket = message('metrics.Bucket', {
|
|
|
5969
6471
|
partial: [8, bool],
|
|
5970
6472
|
/** its first step began before the bucket before it */
|
|
5971
6473
|
gap: [9, bool],
|
|
6474
|
+
/** the NaN samples it passed over, with skipNan */
|
|
6475
|
+
skipped: [10, uint],
|
|
5972
6476
|
}, {
|
|
5973
6477
|
write(w, v) {
|
|
5974
6478
|
const head = w.openMap();
|
|
@@ -6018,6 +6522,11 @@ export const MetricsBucket = message('metrics.Bucket', {
|
|
|
6018
6522
|
w.bool(v.gap);
|
|
6019
6523
|
n++;
|
|
6020
6524
|
}
|
|
6525
|
+
if (v.skipped !== undefined) {
|
|
6526
|
+
w.field(10);
|
|
6527
|
+
w.uint(v.skipped);
|
|
6528
|
+
n++;
|
|
6529
|
+
}
|
|
6021
6530
|
w.closeMap(head, n);
|
|
6022
6531
|
},
|
|
6023
6532
|
read(r) {
|
|
@@ -6030,6 +6539,7 @@ export const MetricsBucket = message('metrics.Bucket', {
|
|
|
6030
6539
|
let $resets;
|
|
6031
6540
|
let $partial;
|
|
6032
6541
|
let $gap;
|
|
6542
|
+
let $skipped;
|
|
6033
6543
|
for (let n = r.message(); n > 0; n--) {
|
|
6034
6544
|
switch (r.field()) {
|
|
6035
6545
|
case 1:
|
|
@@ -6059,6 +6569,9 @@ export const MetricsBucket = message('metrics.Bucket', {
|
|
|
6059
6569
|
case 9:
|
|
6060
6570
|
$gap = r.bool();
|
|
6061
6571
|
break;
|
|
6572
|
+
case 10:
|
|
6573
|
+
$skipped = r.uint();
|
|
6574
|
+
break;
|
|
6062
6575
|
default:
|
|
6063
6576
|
r.skip();
|
|
6064
6577
|
}
|
|
@@ -6074,6 +6587,7 @@ export const MetricsBucket = message('metrics.Bucket', {
|
|
|
6074
6587
|
resets: $resets,
|
|
6075
6588
|
partial: $partial,
|
|
6076
6589
|
gap: $gap,
|
|
6590
|
+
skipped: $skipped,
|
|
6077
6591
|
};
|
|
6078
6592
|
},
|
|
6079
6593
|
});
|
|
@@ -9776,6 +10290,8 @@ export const SearchQuery = message('search.Query', {
|
|
|
9776
10290
|
prefixEvery: [10, bool],
|
|
9777
10291
|
/** utf8, utf16 or chars: each hit says where it matched, counted in that unit */
|
|
9778
10292
|
matches: [11, str],
|
|
10293
|
+
/** the least cosine a document's vector has for the vector to find it */
|
|
10294
|
+
minSimilarity: [12, float],
|
|
9779
10295
|
}, {
|
|
9780
10296
|
write(w, v) {
|
|
9781
10297
|
const head = w.openMap();
|
|
@@ -9835,6 +10351,11 @@ export const SearchQuery = message('search.Query', {
|
|
|
9835
10351
|
w.str(v.matches);
|
|
9836
10352
|
n++;
|
|
9837
10353
|
}
|
|
10354
|
+
if (v.minSimilarity !== undefined) {
|
|
10355
|
+
w.field(12);
|
|
10356
|
+
w.float(v.minSimilarity);
|
|
10357
|
+
n++;
|
|
10358
|
+
}
|
|
9838
10359
|
w.closeMap(head, n);
|
|
9839
10360
|
},
|
|
9840
10361
|
read(r) {
|
|
@@ -9849,6 +10370,7 @@ export const SearchQuery = message('search.Query', {
|
|
|
9849
10370
|
let $prefix;
|
|
9850
10371
|
let $prefixEvery;
|
|
9851
10372
|
let $matches;
|
|
10373
|
+
let $minSimilarity;
|
|
9852
10374
|
for (let n = r.message(); n > 0; n--) {
|
|
9853
10375
|
switch (r.field()) {
|
|
9854
10376
|
case 1:
|
|
@@ -9884,6 +10406,9 @@ export const SearchQuery = message('search.Query', {
|
|
|
9884
10406
|
case 11:
|
|
9885
10407
|
$matches = r.str();
|
|
9886
10408
|
break;
|
|
10409
|
+
case 12:
|
|
10410
|
+
$minSimilarity = r.float();
|
|
10411
|
+
break;
|
|
9887
10412
|
default:
|
|
9888
10413
|
r.skip();
|
|
9889
10414
|
}
|
|
@@ -9901,6 +10426,7 @@ export const SearchQuery = message('search.Query', {
|
|
|
9901
10426
|
prefix: $prefix,
|
|
9902
10427
|
prefixEvery: $prefixEvery,
|
|
9903
10428
|
matches: $matches,
|
|
10429
|
+
minSimilarity: $minSimilarity,
|
|
9904
10430
|
};
|
|
9905
10431
|
},
|
|
9906
10432
|
});
|
|
@@ -10326,7 +10852,8 @@ export const SqlMigration = message('sql.Migration', {
|
|
|
10326
10852
|
});
|
|
10327
10853
|
/**
|
|
10328
10854
|
* Opens a database. Migrations, when given, are applied and checked; without
|
|
10329
|
-
* them the file opens as it is.
|
|
10855
|
+
* them the file opens as it is. One that backups leave out lies in local/
|
|
10856
|
+
* rather than sql/, and a name whose file lies in the other folder is invalid.
|
|
10330
10857
|
*/
|
|
10331
10858
|
export const SqlOpen = message('sql.Open', {
|
|
10332
10859
|
/** [a-z0-9][a-z0-9_-]{0,63} */
|
|
@@ -10334,6 +10861,8 @@ export const SqlOpen = message('sql.Open', {
|
|
|
10334
10861
|
migrations: [2, list(SqlMigration)],
|
|
10335
10862
|
/** full or os: how far its commits go before they return; the store's own when absent */
|
|
10336
10863
|
durability: [3, str],
|
|
10864
|
+
/** false: no backup takes it, nor any node; true when absent */
|
|
10865
|
+
backup: [4, bool],
|
|
10337
10866
|
}, {
|
|
10338
10867
|
write(w, v) {
|
|
10339
10868
|
const head = w.openMap();
|
|
@@ -10356,12 +10885,18 @@ export const SqlOpen = message('sql.Open', {
|
|
|
10356
10885
|
w.str(v.durability);
|
|
10357
10886
|
n++;
|
|
10358
10887
|
}
|
|
10888
|
+
if (v.backup !== undefined) {
|
|
10889
|
+
w.field(4);
|
|
10890
|
+
w.bool(v.backup);
|
|
10891
|
+
n++;
|
|
10892
|
+
}
|
|
10359
10893
|
w.closeMap(head, n);
|
|
10360
10894
|
},
|
|
10361
10895
|
read(r) {
|
|
10362
10896
|
let $name;
|
|
10363
10897
|
let $migrations;
|
|
10364
10898
|
let $durability;
|
|
10899
|
+
let $backup;
|
|
10365
10900
|
for (let n = r.message(); n > 0; n--) {
|
|
10366
10901
|
switch (r.field()) {
|
|
10367
10902
|
case 1:
|
|
@@ -10379,12 +10914,15 @@ export const SqlOpen = message('sql.Open', {
|
|
|
10379
10914
|
case 3:
|
|
10380
10915
|
$durability = r.str();
|
|
10381
10916
|
break;
|
|
10917
|
+
case 4:
|
|
10918
|
+
$backup = r.bool();
|
|
10919
|
+
break;
|
|
10382
10920
|
default:
|
|
10383
10921
|
r.skip();
|
|
10384
10922
|
}
|
|
10385
10923
|
}
|
|
10386
10924
|
r.leave();
|
|
10387
|
-
return { name: $name, migrations: $migrations, durability: $durability };
|
|
10925
|
+
return { name: $name, migrations: $migrations, durability: $durability, backup: $backup };
|
|
10388
10926
|
},
|
|
10389
10927
|
});
|
|
10390
10928
|
/**
|
|
@@ -10523,15 +11061,61 @@ export const SqlStatement = message('sql.Statement', {
|
|
|
10523
11061
|
},
|
|
10524
11062
|
});
|
|
10525
11063
|
/**
|
|
10526
|
-
*
|
|
10527
|
-
|
|
11064
|
+
* A column a statement's rows are ordered by, named as its rows name it.
|
|
11065
|
+
*/
|
|
11066
|
+
export const SqlOrder = message('sql.Order', {
|
|
11067
|
+
column: [1, str],
|
|
11068
|
+
descending: [2, bool],
|
|
11069
|
+
}, {
|
|
11070
|
+
write(w, v) {
|
|
11071
|
+
const head = w.openMap();
|
|
11072
|
+
let n = 0;
|
|
11073
|
+
if (v.column !== undefined) {
|
|
11074
|
+
w.field(1);
|
|
11075
|
+
w.str(v.column);
|
|
11076
|
+
n++;
|
|
11077
|
+
}
|
|
11078
|
+
if (v.descending !== undefined) {
|
|
11079
|
+
w.field(2);
|
|
11080
|
+
w.bool(v.descending);
|
|
11081
|
+
n++;
|
|
11082
|
+
}
|
|
11083
|
+
w.closeMap(head, n);
|
|
11084
|
+
},
|
|
11085
|
+
read(r) {
|
|
11086
|
+
let $column;
|
|
11087
|
+
let $descending;
|
|
11088
|
+
for (let n = r.message(); n > 0; n--) {
|
|
11089
|
+
switch (r.field()) {
|
|
11090
|
+
case 1:
|
|
11091
|
+
$column = r.str();
|
|
11092
|
+
break;
|
|
11093
|
+
case 2:
|
|
11094
|
+
$descending = r.bool();
|
|
11095
|
+
break;
|
|
11096
|
+
default:
|
|
11097
|
+
r.skip();
|
|
11098
|
+
}
|
|
11099
|
+
}
|
|
11100
|
+
r.leave();
|
|
11101
|
+
return { column: $column, descending: $descending };
|
|
11102
|
+
},
|
|
11103
|
+
});
|
|
11104
|
+
/**
|
|
11105
|
+
* What a statement gives back: its rows, one row or none, one value, or each
|
|
11106
|
+
* row as the reader reads it. A write with returning runs on the writer, its
|
|
11107
|
+
* rows given once it is durable. Each reads one snapshot of five seconds at
|
|
11108
|
+
* most; with order, the columns its text orders its rows by, a unique one
|
|
11109
|
+
* last, it reads on past that after the last row it sent, and without it
|
|
11110
|
+
* fails limit there.
|
|
10528
11111
|
*/
|
|
10529
11112
|
export const SqlQuery = message('sql.Query', {
|
|
10530
11113
|
handle: [1, uint],
|
|
10531
11114
|
text: [2, str],
|
|
10532
11115
|
values: [3, list(sqlValue)],
|
|
10533
|
-
/** all, one or
|
|
11116
|
+
/** all, one, scalar or each */
|
|
10534
11117
|
want: [4, str],
|
|
11118
|
+
order: [5, list(SqlOrder)],
|
|
10535
11119
|
}, {
|
|
10536
11120
|
write(w, v) {
|
|
10537
11121
|
const head = w.openMap();
|
|
@@ -10559,6 +11143,14 @@ export const SqlQuery = message('sql.Query', {
|
|
|
10559
11143
|
w.str(v.want);
|
|
10560
11144
|
n++;
|
|
10561
11145
|
}
|
|
11146
|
+
if (v.order !== undefined) {
|
|
11147
|
+
w.field(5);
|
|
11148
|
+
w.array(v.order.length);
|
|
11149
|
+
for (const item0 of v.order) {
|
|
11150
|
+
SqlOrder.write(w, item0);
|
|
11151
|
+
}
|
|
11152
|
+
n++;
|
|
11153
|
+
}
|
|
10562
11154
|
w.closeMap(head, n);
|
|
10563
11155
|
},
|
|
10564
11156
|
read(r) {
|
|
@@ -10566,6 +11158,7 @@ export const SqlQuery = message('sql.Query', {
|
|
|
10566
11158
|
let $text;
|
|
10567
11159
|
let $values;
|
|
10568
11160
|
let $want;
|
|
11161
|
+
let $order;
|
|
10569
11162
|
for (let n = r.message(); n > 0; n--) {
|
|
10570
11163
|
switch (r.field()) {
|
|
10571
11164
|
case 1:
|
|
@@ -10586,12 +11179,21 @@ export const SqlQuery = message('sql.Query', {
|
|
|
10586
11179
|
case 4:
|
|
10587
11180
|
$want = r.str();
|
|
10588
11181
|
break;
|
|
11182
|
+
case 5: {
|
|
11183
|
+
const items0 = [];
|
|
11184
|
+
for (let i0 = r.array(); i0 > 0; i0--) {
|
|
11185
|
+
items0.push(SqlOrder.read(r));
|
|
11186
|
+
}
|
|
11187
|
+
r.leave();
|
|
11188
|
+
$order = items0;
|
|
11189
|
+
break;
|
|
11190
|
+
}
|
|
10589
11191
|
default:
|
|
10590
11192
|
r.skip();
|
|
10591
11193
|
}
|
|
10592
11194
|
}
|
|
10593
11195
|
r.leave();
|
|
10594
|
-
return { handle: $handle, text: $text, values: $values, want: $want };
|
|
11196
|
+
return { handle: $handle, text: $text, values: $values, want: $want, order: $order };
|
|
10595
11197
|
},
|
|
10596
11198
|
});
|
|
10597
11199
|
/**
|
|
@@ -11589,8 +12191,8 @@ export const SearchSetMany = message('search.SetMany', {
|
|
|
11589
12191
|
});
|
|
11590
12192
|
/**
|
|
11591
12193
|
* A hit: a document and its value, or a table's row, a value a column of
|
|
11592
|
-
* the answer's columns, as sql.Rows holds one,
|
|
11593
|
-
* matched it when the query asked.
|
|
12194
|
+
* the answer's columns, as sql.Rows holds one, where the search's words
|
|
12195
|
+
* matched it when the query asked, and what each half of the search gave it.
|
|
11594
12196
|
*/
|
|
11595
12197
|
export const SearchHit = message('search.Hit', {
|
|
11596
12198
|
id: [1, str],
|
|
@@ -11599,6 +12201,10 @@ export const SearchHit = message('search.Hit', {
|
|
|
11599
12201
|
score: [3, float],
|
|
11600
12202
|
row: [4, list(sqlValue)],
|
|
11601
12203
|
matches: [5, list(SearchMatch)],
|
|
12204
|
+
/** its words' score, where they found it among their best */
|
|
12205
|
+
textScore: [6, float],
|
|
12206
|
+
/** its vector's cosine with the search's, where both have one */
|
|
12207
|
+
similarity: [7, float],
|
|
11602
12208
|
}, {
|
|
11603
12209
|
write(w, v) {
|
|
11604
12210
|
const head = w.openMap();
|
|
@@ -11634,6 +12240,16 @@ export const SearchHit = message('search.Hit', {
|
|
|
11634
12240
|
}
|
|
11635
12241
|
n++;
|
|
11636
12242
|
}
|
|
12243
|
+
if (v.textScore !== undefined) {
|
|
12244
|
+
w.field(6);
|
|
12245
|
+
w.float(v.textScore);
|
|
12246
|
+
n++;
|
|
12247
|
+
}
|
|
12248
|
+
if (v.similarity !== undefined) {
|
|
12249
|
+
w.field(7);
|
|
12250
|
+
w.float(v.similarity);
|
|
12251
|
+
n++;
|
|
12252
|
+
}
|
|
11637
12253
|
w.closeMap(head, n);
|
|
11638
12254
|
},
|
|
11639
12255
|
read(r) {
|
|
@@ -11642,6 +12258,8 @@ export const SearchHit = message('search.Hit', {
|
|
|
11642
12258
|
let $score;
|
|
11643
12259
|
let $row;
|
|
11644
12260
|
let $matches;
|
|
12261
|
+
let $textScore;
|
|
12262
|
+
let $similarity;
|
|
11645
12263
|
for (let n = r.message(); n > 0; n--) {
|
|
11646
12264
|
switch (r.field()) {
|
|
11647
12265
|
case 1:
|
|
@@ -11671,12 +12289,26 @@ export const SearchHit = message('search.Hit', {
|
|
|
11671
12289
|
$matches = items0;
|
|
11672
12290
|
break;
|
|
11673
12291
|
}
|
|
12292
|
+
case 6:
|
|
12293
|
+
$textScore = r.float();
|
|
12294
|
+
break;
|
|
12295
|
+
case 7:
|
|
12296
|
+
$similarity = r.float();
|
|
12297
|
+
break;
|
|
11674
12298
|
default:
|
|
11675
12299
|
r.skip();
|
|
11676
12300
|
}
|
|
11677
12301
|
}
|
|
11678
12302
|
r.leave();
|
|
11679
|
-
return {
|
|
12303
|
+
return {
|
|
12304
|
+
id: $id,
|
|
12305
|
+
value: $value,
|
|
12306
|
+
score: $score,
|
|
12307
|
+
row: $row,
|
|
12308
|
+
matches: $matches,
|
|
12309
|
+
textScore: $textScore,
|
|
12310
|
+
similarity: $similarity,
|
|
12311
|
+
};
|
|
11680
12312
|
},
|
|
11681
12313
|
});
|
|
11682
12314
|
export const SearchFound = message('search.Found', {
|