strom-research 1.37.0-beta.1 → 1.37.0-beta.2
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/CHANGELOG.cs.md +12 -1
- package/CHANGELOG.de.md +14 -1
- package/CHANGELOG.md +13 -1
- package/CHANGELOG.pl.md +12 -1
- package/assets/lang/cs.json +1 -0
- package/assets/lang/de.json +1 -0
- package/assets/lang/pl.json +1 -0
- package/dist/brief/brief.js +32 -0
- package/dist/cli/menu-links.js +3 -2
- package/dist/commands/intake.js +8 -2
- package/dist/commands/links.js +5 -4
- package/dist/commands/media.js +6 -1
- package/dist/core/links.js +7 -1
- package/dist/core/lists.js +117 -0
- package/dist/core/live.js +88 -5
- package/dist/core/mediaqueue.js +1 -1
- package/dist/core/originals.js +28 -9
- package/dist/core/phrases.js +1 -0
- package/dist/core/receive.js +9 -3
- package/dist/core/shortcut.js +2 -1
- package/dist/core/stromapp.js +2 -3
- package/dist/core/sync.js +42 -1
- package/dist/core/text.js +11 -0
- package/dist/core/tree.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.cs.md
CHANGED
|
@@ -7,7 +7,7 @@ Změny každé verze ve zkratce. Úplné poznámky a instalační řádky jsou n
|
|
|
7
7
|
|
|
8
8
|
## 1.37.0
|
|
9
9
|
|
|
10
|
-
*Připravuje se: bety do 1.37.0-beta.
|
|
10
|
+
*Připravuje se: bety do 1.37.0-beta.2. Oddíl bude úplný s vydáním.*
|
|
11
11
|
|
|
12
12
|
- **Záznam archivu už nedrží portál ze seznamu stromu:** kniha s adresou na portálu, který seznam stromu zná (Porta
|
|
13
13
|
fontium, Acta Publica…), už nedělá portál tak přísný jako archiv, pod kterým je zapsaná – portál se řídí svými
|
|
@@ -35,6 +35,17 @@ Změny každé verze ve zkratce. Úplné poznámky a instalační řádky jsou n
|
|
|
35
35
|
osoby – nikdy událostí ani místem, kde osoba žila, a agent je nedostane. Synchronizace s aplikací e-maily přidává
|
|
36
36
|
i odebírá jako jiné úpravy. Nová kontrola `strom fixes contact-residences` převede bydliště, která ze e-mailů udělal
|
|
37
37
|
starší strom, na kontakt (bydliště stažené, nikdy smazané, vrátí ho `strom fixes undo`).
|
|
38
|
+
- **Materiál k seznamu osob:** aplikace Strom může poslat sken k celému seznamu osob (sčítací arch, stránka matriky)
|
|
39
|
+
místo k jedné osobě. Materiál si seznam pamatuje tak, jak byl poslán – název, druh, pravidlo a ID jeho osob; do 50
|
|
40
|
+
osob jsou osobami materiálu, delší seznam je uveden názvem a souborem všech jeho osob. Úkol pro agenta nese název
|
|
41
|
+
seznamu a říká porovnat každé jméno ze skenu nejdřív s těmito osobami, celý strom až potom.
|
|
42
|
+
Poslat se dá i sken pramene: zůstane obrazem pramene, pamatuje si seznam stejně a úkol přečíst ho má osoby seznamu
|
|
43
|
+
(do 50) mezi dotčenými.
|
|
44
|
+
- **Výzkum pro kopii rodokmenu:** odkaz aplikace Strom, který zakládá nový výzkum, může navrhnout jeho název (kopie
|
|
45
|
+
stromu: „… (kopie)“); terminál ho nabídne k ponechání nebo přepsání a most aplikaci řekne složku, kde nové výzkumy
|
|
46
|
+
vznikají. Strom předaný s čísly jiného výzkumu (kopie stromu, který výzkum měl, ze starší aplikace) dostane pro své
|
|
47
|
+
osoby a prameny čísla nového výzkumu podle vlastních značek souboru – nikdy čísla toho druhého výzkumu, citace
|
|
48
|
+
pramenů zůstanou.
|
|
38
49
|
|
|
39
50
|
## 1.36.0
|
|
40
51
|
|
package/CHANGELOG.de.md
CHANGED
|
@@ -7,7 +7,7 @@ Die Änderungen jeder Version in Kürze. Die vollständigen Hinweise und die Ins
|
|
|
7
7
|
|
|
8
8
|
## 1.37.0
|
|
9
9
|
|
|
10
|
-
*In Vorbereitung: die Betas bis 1.37.0-beta.
|
|
10
|
+
*In Vorbereitung: die Betas bis 1.37.0-beta.2. Der Abschnitt ist mit dem Release vollständig.*
|
|
11
11
|
|
|
12
12
|
- **Ein Archiveintrag der Forschung hält kein Portal der Liste von strom mehr:** ein Buch mit einer Adresse auf einem
|
|
13
13
|
Portal, das die Liste von strom kennt (Porta fontium, Acta Publica…), macht das Portal nicht mehr so streng wie das
|
|
@@ -41,6 +41,19 @@ Die Änderungen jeder Version in Kürze. Die vollständigen Hinweise und die Ins
|
|
|
41
41
|
Agenten gegeben. Der Abgleich mit der App fügt E-Mails hinzu und nimmt sie weg wie andere Änderungen. Die neue
|
|
42
42
|
Prüfung `strom fixes contact-residences` macht aus Wohnorten, die ein älterer strom aus E-Mails gemacht hat, den
|
|
43
43
|
Kontakt (zurückgezogen, nie gelöscht, rückgängig mit `strom fixes undo`).
|
|
44
|
+
- **Material zu einer Personenliste:** die Strom-App kann einen Scan statt an eine Person an eine ganze Personenliste
|
|
45
|
+
schicken (einen Zählbogen, eine Matrikenseite). Das Material behält die Liste so, wie sie geschickt wurde – Name,
|
|
46
|
+
Art, Regel und die IDs ihrer Personen; bis zu 50 davon sind die Personen des Materials, eine längere Liste wird mit
|
|
47
|
+
einer Datei aller ihrer Personen genannt. Die Aufgabe des Agenten trägt den Namen der Liste und sagt, jeden Namen vom
|
|
48
|
+
Scan zuerst mit diesen Personen zu vergleichen, erst dann mit dem ganzen Baum.
|
|
49
|
+
Auch der Scan einer Quelle lässt sich so schicken: er bleibt ein Bild der Quelle, behält die Liste ebenso, und die
|
|
50
|
+
Aufgabe, ihn zu lesen, hat die Personen der Liste (bis zu 50) unter den betroffenen.
|
|
51
|
+
- **Eine Forschung für die Kopie eines Stammbaums:** der Link der Strom-App, der eine neue Forschung beginnt, kann ihren
|
|
52
|
+
Namen vorschlagen (Kopie eines Baums: „… (Kopie)“); das Terminal bietet ihn zum Behalten oder Überschreiben an, und
|
|
53
|
+
die Brücke nennt der App den Ordner, in dem neue Forschungen entstehen. Ein Baum, der mit den Nummern einer anderen
|
|
54
|
+
Forschung übergeben wird (Kopie eines Baums mit Forschung, aus einer älteren App), bekommt für seine Personen und
|
|
55
|
+
Quellen die Nummern der neuen Forschung nach den eigenen Marken der Datei – nie die Nummern der anderen Forschung,
|
|
56
|
+
die Zitate der Quellen bleiben.
|
|
44
57
|
|
|
45
58
|
## 1.36.0
|
|
46
59
|
|
package/CHANGELOG.md
CHANGED
|
@@ -7,7 +7,7 @@ The changes of each version in short. The full notes and the install lines are o
|
|
|
7
7
|
|
|
8
8
|
## 1.37.0
|
|
9
9
|
|
|
10
|
-
*In preparation: the betas up to 1.37.0-beta.
|
|
10
|
+
*In preparation: the betas up to 1.37.0-beta.2. The section is complete with the release.*
|
|
11
11
|
|
|
12
12
|
- **A research's archive no longer holds a portal of strom's list:** a book whose address is on a portal strom's list
|
|
13
13
|
knows (Porta fontium, Acta Publica…) no longer makes the portal as strict as the archive the book is recorded under —
|
|
@@ -37,6 +37,18 @@ The changes of each version in short. The full notes and the install lines are o
|
|
|
37
37
|
person show` and on the person's card — never an event or a place the person lived, never given to the agent. Sync
|
|
38
38
|
with the app adds and takes off e-mails like other edits. The new check `strom fixes contact-residences` turns
|
|
39
39
|
residences an older strom made of e-mails into the contact (withdrawn, never deleted, undone by `strom fixes undo`).
|
|
40
|
+
- **Material sent to a list of people:** the Strom app can send a scan to a whole list of people (a census sheet, a
|
|
41
|
+
register page) instead of one person. The material keeps the list as it was sent — its name, kind, rule and the IDs
|
|
42
|
+
of its people; up to 50 of them are the people it is of, a longer list is named with a file of all its people. The
|
|
43
|
+
agent's task is named by the list and says to match each name read on the scan to those people first, the whole
|
|
44
|
+
tree only after.
|
|
45
|
+
A scan of a source can be sent so too: it stays an image of the source, keeps the list the same way, and the task
|
|
46
|
+
to read it has the list's people (up to 50) among those it concerns.
|
|
47
|
+
- **A research for a copy of a family tree:** the Strom app's link that starts a new research may suggest its name (a
|
|
48
|
+
copy of a tree: "… (copy)"), offered in the terminal to keep or write over; the bridge tells the app the folder new
|
|
49
|
+
researches are made in. A tree handed over with the numbers of another research (a copy of a tree that had one, from
|
|
50
|
+
an older app) gets its people and sources the new research's numbers by the file's own marks — never the other
|
|
51
|
+
research's numbers, a source's citations kept.
|
|
40
52
|
|
|
41
53
|
## 1.36.0
|
|
42
54
|
|
package/CHANGELOG.pl.md
CHANGED
|
@@ -7,7 +7,7 @@ Zmiany każdej wersji w skrócie. Pełne informacje o wydaniach i polecenia inst
|
|
|
7
7
|
|
|
8
8
|
## 1.37.0
|
|
9
9
|
|
|
10
|
-
*W przygotowaniu: bety do 1.37.0-beta.
|
|
10
|
+
*W przygotowaniu: bety do 1.37.0-beta.2. Sekcja będzie kompletna z wydaniem.*
|
|
11
11
|
|
|
12
12
|
- **Wpis archiwum w badaniu nie utrzymuje już portalu z listy stroma:** księga z adresem na portalu, który zna lista
|
|
13
13
|
stroma (Porta fontium, Acta Publica…), nie czyni już portalu tak surowym jak archiwum, pod którym jest zapisana –
|
|
@@ -39,6 +39,17 @@ Zmiany każdej wersji w skrócie. Pełne informacje o wydaniach i polecenia inst
|
|
|
39
39
|
do agenta. Synchronizacja z aplikacją dodaje i usuwa e-maile jak inne zmiany. Nowa kontrola `strom fixes
|
|
40
40
|
contact-residences` zamienia miejsca zamieszkania, które starszy strom zrobił z e-maili, na kontakt (wycofane, nigdy
|
|
41
41
|
usunięte, cofa je `strom fixes undo`).
|
|
42
|
+
- **Materiał do listy osób:** aplikacja Strom może wysłać skan do całej listy osób (arkusz spisu, strona księgi
|
|
43
|
+
metrykalnej) zamiast do jednej osoby. Materiał zachowuje listę taką, jaką wysłano – nazwę, rodzaj, regułę i ID jej
|
|
44
|
+
osób; do 50 z nich to osoby materiału, dłuższa lista jest podana nazwą i plikiem wszystkich jej osób. Zadanie agenta
|
|
45
|
+
nosi nazwę listy i każe porównać każde imię ze skanu najpierw z tymi osobami, a dopiero potem z całym drzewem.
|
|
46
|
+
Tak samo można wysłać skan źródła: pozostaje obrazem źródła, zachowuje listę tak samo, a zadanie jego odczytania ma
|
|
47
|
+
osoby z listy (do 50) wśród dotyczących.
|
|
48
|
+
- **Badanie dla kopii drzewa:** link aplikacji Strom, który zakłada nowe badanie, może zaproponować jego nazwę (kopia
|
|
49
|
+
drzewa: „… (kopia)”); terminal proponuje ją do zachowania lub nadpisania, a most podaje aplikacji folder, w którym
|
|
50
|
+
powstają nowe badania. Drzewo przekazane z numerami innego badania (kopia drzewa, które miało badanie, ze starszej
|
|
51
|
+
aplikacji) dostaje dla swoich osób i źródeł numery nowego badania według własnych oznaczeń pliku – nigdy numery
|
|
52
|
+
tamtego badania, cytowania źródeł zostają.
|
|
42
53
|
|
|
43
54
|
## 1.36.0
|
|
44
55
|
|
package/assets/lang/cs.json
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"request.done": "žádost je odeslaná (strom task wait … --on \"<odpověď>\") nebo uživatel rozhodne, že linie tu končí",
|
|
25
25
|
"app.media.what": "Rozebrat {count, plural, one {# soubor poslaný} few {# soubory poslané} other {# souborů poslaných}} z aplikace Strom – {who} ({first}–{last})",
|
|
26
26
|
"app.media.nobody": "pro výzkum",
|
|
27
|
+
"app.media.list": "seznam „{name}“ ({count, plural, one {# osoba} few {# osoby} other {# osob}})",
|
|
27
28
|
"app.media.why": "Originály od uživatele poslané z aplikace Strom (uložené beze změny): zjistit, co každý je, koho se týká a co může doložit.",
|
|
28
29
|
"app.scan.what": "Přečíst snímek, který uživatel poslal k prameni {source} ({title})",
|
|
29
30
|
"app.scan.why": "Uživatel poslal z aplikace Strom samotný záznam: výzkum si ho přečte sám – jeho čtení potvrdí přepis uživatele, nebo odhalí chybu.",
|
package/assets/lang/de.json
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"request.done": "eine Anfrage ist verschickt (strom task wait … --on \"<Antwort>\") oder der Benutzer entscheidet, dass die Linie hier endet",
|
|
25
25
|
"app.media.what": "{count, plural, one {# Datei} other {# Dateien}} auswerten, die der Nutzer aus der Strom-App geschickt hat – {who} ({first}–{last})",
|
|
26
26
|
"app.media.nobody": "für die Forschung",
|
|
27
|
+
"app.media.list": "die Liste „{name}“ ({count, plural, one {# Person} other {# Personen}})",
|
|
27
28
|
"app.media.why": "Originale vom Nutzer, aus der Strom-App geschickt (unverändert aufbewahrt): herausfinden, was jedes ist, wen es betrifft und was es belegen kann.",
|
|
28
29
|
"app.scan.what": "Das Bild lesen, das der Nutzer zur Quelle {source} ({title}) geschickt hat",
|
|
29
30
|
"app.scan.why": "Der Nutzer hat den Eintrag selbst aus der Strom-App geschickt: die Forschung liest ihn selbst – ihre Lesung bestätigt die Abschrift des Nutzers oder zeigt einen Fehler.",
|
package/assets/lang/pl.json
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"request.done": "prośba jest wysłana (strom task wait … --on \"<odpowiedź>\") albo użytkownik zdecyduje, że linia tu się kończy",
|
|
25
25
|
"app.media.what": "Przeanalizować {count, plural, one {# plik przesłany} few {# pliki przesłane} many {# plików przesłanych} other {# plików przesłanych}} z aplikacji Strom – {who} ({first}–{last})",
|
|
26
26
|
"app.media.nobody": "dla badania",
|
|
27
|
+
"app.media.list": "lista „{name}” ({count, plural, one {# osoba} few {# osoby} many {# osób} other {# osoby}})",
|
|
27
28
|
"app.media.why": "Oryginały od użytkownika przesłane z aplikacji Strom (zapisane bez zmian): ustalić, czym jest każdy z nich, kogo dotyczy i czego może dowieść.",
|
|
28
29
|
"app.scan.what": "Odczytać skan, który użytkownik przesłał do źródła {source} ({title})",
|
|
29
30
|
"app.scan.why": "Użytkownik przesłał z aplikacji Strom sam zapis: badanie odczytuje go samodzielnie – ten odczyt potwierdzi transkrypcję użytkownika albo ujawni błąd.",
|
package/dist/brief/brief.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// The brief has a hard token budget; sections come in priority order and
|
|
6
6
|
// what does not fit is cut to a pointer: the command that shows the rest.
|
|
7
7
|
import { noteWhole } from "../core/model.js";
|
|
8
|
+
import { LIST_PEOPLE } from "../core/lists.js";
|
|
8
9
|
import { orderCitations } from "../core/citeorder.js";
|
|
9
10
|
import fs from "node:fs";
|
|
10
11
|
import path from "node:path";
|
|
@@ -428,6 +429,31 @@ function lookAlike(a, b) {
|
|
|
428
429
|
}
|
|
429
430
|
return prev[y.length] <= max;
|
|
430
431
|
}
|
|
432
|
+
/**
|
|
433
|
+
* The list of people the material was sent to (spec 137 K2.4): its name, kind and rule, how many of its people the
|
|
434
|
+
* research has (and has not), and its file — the IDs of all its people as they were sent, when the list is longer than
|
|
435
|
+
* the people it is of (those are in People concerned).
|
|
436
|
+
*/
|
|
437
|
+
function listLine(tree, l, of) {
|
|
438
|
+
const kind = l.kind === "auto" ? `automatic${l.rule ? `, rule: ${l.rule}` : ""}` : l.kind === "work" ? "a working list" : l.kind === "fixed" ? "fixed" : l.rule ? `rule: ${l.rule}` : "";
|
|
439
|
+
const people = `${l.count} ${l.count === 1 ? "person" : "people"}${l.missing ? `, ${l.missing} more not in the research yet` : ""}`;
|
|
440
|
+
return `list: "${l.name}" (${[kind, people, `as sent ${l.at.slice(0, 10)}`].filter(Boolean).join("; ")})${l.count > of ? ` — the IDs of all its people: ${path.join(tree.root, ...l.file.split("/"))} (look them up yourself: strom person show P…)` : ""}`;
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* The list of people a scan of a source the task reads was sent to (spec 137, media.list.source): named, and whom the
|
|
444
|
+
* names read on it are matched to first — up to LIST_PEOPLE of its people are in about, a longer list in its file.
|
|
445
|
+
*/
|
|
446
|
+
function scanLists(tree, task) {
|
|
447
|
+
const lists = task.where
|
|
448
|
+
.map((w) => (/^M\d{4,}$/.test(w) ? tree.get(w) : undefined))
|
|
449
|
+
.filter((m) => !!m && m.type === "media" && !!m.list);
|
|
450
|
+
if (!lists.length)
|
|
451
|
+
return [];
|
|
452
|
+
return [
|
|
453
|
+
...lists.map((m) => `${m.id} ${listLine(tree, m.list, m.list.count <= LIST_PEOPLE ? m.list.count : 0)}`),
|
|
454
|
+
`(the user sent the scan for the list's people: match each name you read on it to them first — only a name none of them fits is looked for in the whole tree, strom find "<name>")`,
|
|
455
|
+
];
|
|
456
|
+
}
|
|
431
457
|
/** The largest file of the material read for its names alone (not shown). */
|
|
432
458
|
const MATERIAL_READ = 5_000_000;
|
|
433
459
|
function materialText(tree, inputs) {
|
|
@@ -1075,6 +1101,7 @@ export function buildBrief(tree, opts) {
|
|
|
1075
1101
|
`why: ${task.why}`,
|
|
1076
1102
|
`done: ${task.doneWhen}`,
|
|
1077
1103
|
task.subject.length ? `about: ${task.subject.join(" ")}` : "",
|
|
1104
|
+
...scanLists(tree, task),
|
|
1078
1105
|
...surnameFormLines(tree, task),
|
|
1079
1106
|
...task.notes.slice(-3).map((n) => `note: ${n.text}`),
|
|
1080
1107
|
task.notes.length > 3 ? `(notes: the last 3 of ${task.notes.length} — all: strom task show ${task.id})` : "",
|
|
@@ -1135,12 +1162,17 @@ export function buildBrief(tree, opts) {
|
|
|
1135
1162
|
read ? `read: ${read}` : "",
|
|
1136
1163
|
i.batch ? `batch: ${i.batch}${i.path ? ` · ${i.path}` : ""}` : "",
|
|
1137
1164
|
i.persons?.length ? `of: ${i.persons.join(", ")}` : "",
|
|
1165
|
+
i.list ? listLine(tree, i.list, (i.persons ?? []).length) : "",
|
|
1138
1166
|
i.sorted ? `sorted: ${i.sorted.as}${i.sorted.source ? ` → ${i.sorted.source}` : ""}${i.sorted.reason ? ` (${i.sorted.reason})` : ""}` : "",
|
|
1139
1167
|
i.imported ? `imported: ${i.imported.persons} persons, ${i.imported.families} families as leads, cited as ${i.source}` : "",
|
|
1140
1168
|
...i.notes.map((n) => `note: ${n.text}`),
|
|
1141
1169
|
i.text ? `text:\n${i.text}` : small ? `text:\n${small}` : "",
|
|
1142
1170
|
].filter(Boolean).join("\n");
|
|
1143
1171
|
}),
|
|
1172
|
+
// whom the names read on it are matched to first (spec 137 K2.2): the people it was sent for, its list's
|
|
1173
|
+
...(inputs.some((i) => i.persons?.length || i.list)
|
|
1174
|
+
? [`(the user sent it for these people${inputs.some((i) => i.list) ? " and the list's" : ""}: match each name you read on it to them first — only a name none of them fits is looked for in the whole tree, strom find "<name>")`]
|
|
1175
|
+
: []),
|
|
1144
1176
|
].join("\n"),
|
|
1145
1177
|
});
|
|
1146
1178
|
}
|
package/dist/cli/menu-links.js
CHANGED
|
@@ -1339,8 +1339,9 @@ export async function newFromApp(ctx, runIn, token, openAt, forward, opts = {})
|
|
|
1339
1339
|
}
|
|
1340
1340
|
}
|
|
1341
1341
|
const joined = Boolean(root);
|
|
1342
|
-
// suggested: the app's
|
|
1343
|
-
|
|
1342
|
+
// suggested: the name the app's link gives (a copy of a tree: its own name, never the original's research), else the
|
|
1343
|
+
// app's tree's name (its move, its line), else the usual one — Enter never ends the handover
|
|
1344
|
+
const suggested = opts.name || (move?.mark.tree || undefined) || appTreeNameFromInstall(ctx.env) || t("ui.tree.default");
|
|
1344
1345
|
const ways = waysHere(agentsHere(ctx.env));
|
|
1345
1346
|
const mine = ctx.settings.agent().value;
|
|
1346
1347
|
let agent = mine;
|
package/dist/commands/intake.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// a tree exported from the Strom app, a text the user types. Inputs are the
|
|
5
5
|
// unchanged BASE of a research; the agent builds the working tree from them
|
|
6
6
|
// through tasks, and the tree it builds is exported as GEDCOM.
|
|
7
|
+
import { takeList } from "../core/lists.js";
|
|
7
8
|
import fs from "node:fs";
|
|
8
9
|
import path from "node:path";
|
|
9
10
|
import { register } from "../cli/registry.js";
|
|
@@ -452,7 +453,7 @@ register({
|
|
|
452
453
|
// the file gone (the shared folder not brought along, deleted by hand): said, never shown as if it were there
|
|
453
454
|
const missing = !!abs && !fs.existsSync(abs);
|
|
454
455
|
const tasks = tree.list("task").filter((t) => t.where.includes(i.id));
|
|
455
|
-
const text = lines(`${i.id} ${i.name} [${i.kind} · ${deleted ? `deleted for good ${deleted.slice(0, 10)}` : i.state}]`, deleted ? "file none: deleted for good by the person (the same content brought again is new material)" : undefined, abs ? `file ${abs}${missing ? ` — missing on this computer: bring back the ${i.file?.startsWith("media:") ? "shared folder from a backup of the whole Strom folder (its subfolder shared)" : "research's folder from a backup"}` : ""}` : undefined, i.from ? `from ${i.from}` : undefined, i.batch ? `batch ${i.batch}${i.path ? ` · ${i.path}` : ""}` : undefined, i.persons?.length ? `of ${i.persons.join(", ")}` : undefined, i.sorted ? `sorted ${i.sorted.as}${i.sorted.source ? ` → ${i.sorted.source}` : ""}${i.sorted.reason ? ` (${i.sorted.reason})` : ""}` : undefined, i.mime ? `type ${i.mime}${i.size !== undefined ? ` · ${Math.round(i.size / 1024)} kB` : ""}` : undefined, i.imported ? `import ${i.imported.persons} persons, ${i.imported.families} families as leads, cited as ${i.source}` : undefined, i.read?.length ? `read ${readingsLine(tree, i)}` : undefined, i.text ? `\n${i.text}` : undefined, !i.text && i.kind === "text" && abs && fs.existsSync(abs) && (i.size ?? 0) < 20_000 && /\.(txt|md|csv)$/i.test(abs) ? `\n${fs.readFileSync(abs, "utf8").trim()}` : undefined, tasks.length ? `\ntasks\n${table(tasks.map((t) => [` ${t.id}`, t.state, truncate(t.what, 60)]))}` : undefined, ...i.notes.map((n) => `note ${n.text}`), i.kind === "document" && abs && !missing && !readingsOf(tree, i).some((r) => r.state === "done")
|
|
456
|
+
const text = lines(`${i.id} ${i.name} [${i.kind} · ${deleted ? `deleted for good ${deleted.slice(0, 10)}` : i.state}]`, deleted ? "file none: deleted for good by the person (the same content brought again is new material)" : undefined, abs ? `file ${abs}${missing ? ` — missing on this computer: bring back the ${i.file?.startsWith("media:") ? "shared folder from a backup of the whole Strom folder (its subfolder shared)" : "research's folder from a backup"}` : ""}` : undefined, i.from ? `from ${i.from}` : undefined, i.batch ? `batch ${i.batch}${i.path ? ` · ${i.path}` : ""}` : undefined, i.persons?.length ? `of ${i.persons.join(", ")}` : undefined, i.list ? `list "${i.list.name}" · ${i.list.count} ${i.list.count === 1 ? "person" : "people"}${i.list.missing ? ` (${i.list.missing} more not in the research)` : ""}${i.list.rule ? ` · rule: ${i.list.rule}` : ""} · ${path.join(tree.root, ...i.list.file.split("/"))}` : undefined, i.sorted ? `sorted ${i.sorted.as}${i.sorted.source ? ` → ${i.sorted.source}` : ""}${i.sorted.reason ? ` (${i.sorted.reason})` : ""}` : undefined, i.mime ? `type ${i.mime}${i.size !== undefined ? ` · ${Math.round(i.size / 1024)} kB` : ""}` : undefined, i.imported ? `import ${i.imported.persons} persons, ${i.imported.families} families as leads, cited as ${i.source}` : undefined, i.read?.length ? `read ${readingsLine(tree, i)}` : undefined, i.text ? `\n${i.text}` : undefined, !i.text && i.kind === "text" && abs && fs.existsSync(abs) && (i.size ?? 0) < 20_000 && /\.(txt|md|csv)$/i.test(abs) ? `\n${fs.readFileSync(abs, "utf8").trim()}` : undefined, tasks.length ? `\ntasks\n${table(tasks.map((t) => [` ${t.id}`, t.state, truncate(t.what, 60)]))}` : undefined, ...i.notes.map((n) => `note ${n.text}`), i.kind === "document" && abs && !missing && !readingsOf(tree, i).some((r) => r.state === "done")
|
|
456
457
|
? `\nread the file (a big image: strom media view ${i.id} --grid, then --crop), then record what it says: strom source add … --input ${i.id}`
|
|
457
458
|
: undefined);
|
|
458
459
|
return { text, data: { input: i, path: abs, ...(deleted ? { deleted } : {}), ...(missing ? { missing: true } : {}), tasks: tasks.map((t) => t.id), ...(i.read?.length ? { readings: readingsOf(tree, i) } : {}) } };
|
|
@@ -700,6 +701,7 @@ register({
|
|
|
700
701
|
{ name: "person", type: "string", multiple: true, value: "<P…>", description: "a person it is of (repeatable)" },
|
|
701
702
|
{ name: "family", type: "string", multiple: true, value: "<F…>", description: "a couple it is of (repeatable): material of both partners" },
|
|
702
703
|
{ name: "note", type: "string", value: "<text>", description: "what the user said of it" },
|
|
704
|
+
{ name: "list", type: "string", value: "<id>", description: "the list of people the app sent it to (the bridge keeps it): kept on the input as sent now, up to 50 of its people its people too" },
|
|
703
705
|
],
|
|
704
706
|
examples: ["strom input amend I0002 --person P0001 --note \"<what the user said of it>\""],
|
|
705
707
|
run(ctx, { args, opts }) {
|
|
@@ -707,7 +709,11 @@ register({
|
|
|
707
709
|
const id = normId(args[0], "input");
|
|
708
710
|
const persons = (Array.isArray(opts.person) ? opts.person : opts.person ? [opts.person] : []).flatMap((p) => String(p).split(",")).map((p) => p.trim().toUpperCase()).filter(Boolean);
|
|
709
711
|
const families = (Array.isArray(opts.family) ? opts.family : opts.family ? [opts.family] : []).flatMap((f) => String(f).split(",")).map((f) => f.trim().toUpperCase()).filter(Boolean);
|
|
710
|
-
const got = tree.withTreeLock(() =>
|
|
712
|
+
const got = tree.withTreeLock(() => {
|
|
713
|
+
// the list it was sent to now: its people up to 50 its people too, after those named
|
|
714
|
+
const sent = typeof opts.list === "string" ? takeList(tree, opts.list) : undefined;
|
|
715
|
+
return amendInput(tree, id, { persons: [...new Set([...persons, ...(sent?.persons ?? [])])], note: typeof opts.note === "string" ? opts.note : undefined, ...(families.length ? { families } : {}), ...(sent ? { list: sent.list } : {}) }, { auto: ctx.settings.intakeAuto(tree.config) });
|
|
716
|
+
});
|
|
711
717
|
return { text: tree.written.length ? lines(...tree.written.map((o) => o.summary)) : `${id}: nothing new`, data: got };
|
|
712
718
|
},
|
|
713
719
|
}, {
|
package/dist/commands/links.js
CHANGED
|
@@ -502,7 +502,7 @@ async function openLink(ctx, link, handed) {
|
|
|
502
502
|
if (ctx.io.tty) {
|
|
503
503
|
const { newFromApp } = await import("../cli/menu-links.js");
|
|
504
504
|
const { openAppAt } = await import("./sync.js");
|
|
505
|
-
const done = await newFromApp(ctx, runnerOf(ctx), link.app, (url) => openAppAt(ctx, url, { holdsTree: true }), () => bringForward(ctx.env), { ...(link.browser ? { browser: link.browser } : {}), ...(link.file ? { file: link.file } : {}) });
|
|
505
|
+
const done = await newFromApp(ctx, runnerOf(ctx), link.app, (url) => openAppAt(ctx, url, { holdsTree: true }), () => bringForward(ctx.env), { ...(link.browser ? { browser: link.browser } : {}), ...(link.file ? { file: link.file } : {}), ...(link.name ? { name: link.name } : {}) });
|
|
506
506
|
if (!done)
|
|
507
507
|
await pause(ctx, ctx.uiLang(), "ui.enter.close");
|
|
508
508
|
return { text: "", data: { done, action: "new" } };
|
|
@@ -670,13 +670,14 @@ register({
|
|
|
670
670
|
" its hash (the bridge's /log head, or its first 8), else the earlier changes to pick from — what returns shown, the\n" +
|
|
671
671
|
" return only on the person's word in the terminal.\n" +
|
|
672
672
|
"strom-research://update|sessions|setup?tree=<id> — strom update, the agent's sessions and their cost, strom setup.\n" +
|
|
673
|
-
"strom-research://new?app=<the app's mark> — a tree of the app becomes a new research: named, made, the app hands the\n" +
|
|
674
|
-
"tree to its bridge (?adopt=, GET/POST /adopt), taken in as leads, sent back to the app.
|
|
673
|
+
"strom-research://new?app=<the app's mark>[&name=<text>] — a tree of the app becomes a new research: named, made, the app hands the\n" +
|
|
674
|
+
"tree to its bridge (?adopt=, GET/POST /adopt), taken in as leads, sent back to the app. name= (one line, at most 120\n" +
|
|
675
|
+
"characters) is only the name suggested in the terminal, the person keeps it or writes another. Family trees here already:\n" +
|
|
675
676
|
"opening one of them in the app (strom app) is offered first; with no terminal the result lists them (trees).\n" +
|
|
676
677
|
"What writes tasks or starts the agent is said and asked in the terminal first; with run.confirm no (the person's,\n" +
|
|
677
678
|
"this computer's) what only starts the agent on the subscription or AI credit starts at once, one line says so — a\n" +
|
|
678
679
|
"price in money, a consent, a deletion, a request sent, the gate and an agent's own command still ask. Any page can open such a link:\n" +
|
|
679
|
-
"each part is checked (only IDs and fixed values, never text), an unknown research, person, task or excerpt is\n" +
|
|
680
|
+
"each part is checked (only IDs and fixed values, never text but new's suggested name), an unknown research, person, task or excerpt is\n" +
|
|
680
681
|
"only said. No link: the menu.\n" +
|
|
681
682
|
"&handoff=<uuid> (any link of a research): the app's id of it — written when the link was taken (the terminal it\n" +
|
|
682
683
|
"opens came up, or what needs none was done) and said by the research's bridge in GET /status (handoffs) for a\n" +
|
package/dist/commands/media.js
CHANGED
|
@@ -2059,7 +2059,7 @@ register({
|
|
|
2059
2059
|
return {
|
|
2060
2060
|
text: lines(`${m.id} ${m.part ? `part ${regionText(partShown(sharedDir(ctx), all, m))} of ` : ""}${b ? `image ${m.image ?? "?"} of ${b.id} ${b.title}` : "image"}${pageLabel(tree, m) ? ` · page ${pageLabel(tree, m)}` : ""}`, `${m.width ? `${m.width}×${m.height} px · ` : ""}${Math.round(m.size / 1024)} kB · ${m.mime}${m.from ? ` · from ${m.from}` : ""}${m.url ? ` · ${m.url}` : ""}`, m.retracted ? `RETRACTED ${localDayOf(m.retracted.at)}: ${m.retracted.reason} — no view, part or excerpt uses it` : undefined, parts.length ? `parts of it, sharper (a view of the image uses them by itself): ${parts.map((p) => `${p.id} ${regionText(partShown(sharedDir(ctx), all, p))}${p.width ? ` ${p.width}×${p.height}` : ""}`).join(" · ")}` : undefined, copies.length
|
|
2061
2061
|
? `other copies of the image: ${copies.map((c) => `${c.id}${c.width ? ` ${c.width}×${c.height}` : ""}`).join(" · ")} — the image is the sharpest (${image.id}); a view of any copy uses it`
|
|
2062
|
-
: undefined, sources.length ? `sources on it: ${sources.map((s) => `${s.id} ${s.title}`).join(" · ")}` : "no source cites it yet", `view: strom media view ${m.id} [--half left|right] [--crop x,y,w,h] [--grid]`),
|
|
2062
|
+
: undefined, sources.length ? `sources on it: ${sources.map((s) => `${s.id} ${s.title}`).join(" · ")}` : "no source cites it yet", m.list ? `sent to the list "${m.list.name}" · ${m.list.count} ${m.list.count === 1 ? "person" : "people"}${m.list.missing ? ` (${m.list.missing} more not in the research)` : ""}${m.list.rule ? ` · rule: ${m.list.rule}` : ""} · ${path.join(tree.root, ...m.list.file.split("/"))}` : undefined, `view: strom media view ${m.id} [--half left|right] [--crop x,y,w,h] [--grid]`),
|
|
2063
2063
|
data: { media: m, parts: parts.map((p) => p.id), copies: copies.map((c) => c.id), sources: sources.map((s) => s.id), page: pageLabel(tree, m) || undefined },
|
|
2064
2064
|
};
|
|
2065
2065
|
},
|
|
@@ -2388,6 +2388,7 @@ register({
|
|
|
2388
2388
|
{ name: "replace", type: "boolean", description: "with --task: another scan at that number replaces the one there (withdrawn and kept, never deleted)" },
|
|
2389
2389
|
{ name: "phone", type: "boolean", description: "sent from a paired phone (its server runs it): material of a phone's batch" },
|
|
2390
2390
|
{ name: "read", type: "boolean", description: "sent to be read at once (strom document read): an input with no intake task" },
|
|
2391
|
+
{ name: "list", type: "string", value: "<id>", description: "the list of people the app sent it to (the bridge keeps it, PUT lists/<id>): kept on the input, up to 50 of its people its people too" },
|
|
2391
2392
|
],
|
|
2392
2393
|
examples: ["strom media original ~/Downloads/dopis.png --name dopis.png --person P0001"],
|
|
2393
2394
|
run(ctx, { args, opts }) {
|
|
@@ -2411,6 +2412,9 @@ register({
|
|
|
2411
2412
|
throw new UsageError("a file for a task is no image of a source and comes in no batch", { hint: "--task alone, with --person, --note" });
|
|
2412
2413
|
if (opts.read && (batch || forTask !== undefined || typeof opts.source === "string"))
|
|
2413
2414
|
throw new UsageError("a file to read is no image of a source, comes in no batch and for no task", { hint: "--read alone, with --person, --note" });
|
|
2415
|
+
const list = typeof opts.list === "string" ? opts.list : undefined;
|
|
2416
|
+
if (list !== undefined && (batch || forTask !== undefined || opts.read))
|
|
2417
|
+
throw new UsageError("a file sent to a list is material of people or a scan of a source: in no batch, for no task, not to read at once", { hint: "--list with --person, --source, --note", code: "media.bad-header", params: { header: "X-Strom-List-Ref" } });
|
|
2414
2418
|
const image = opts.image !== undefined ? Number(opts.image) : undefined;
|
|
2415
2419
|
if (image !== undefined && (!Number.isInteger(image) || image < 1 || image > 999_999))
|
|
2416
2420
|
throw new UsageError("--image is the image's number in the book (1 or more)", { code: "media.bad-header", params: { header: "X-Strom-Image" } });
|
|
@@ -2451,6 +2455,7 @@ register({
|
|
|
2451
2455
|
region: parseRegion(typeof opts.region === "string" ? opts.region : undefined),
|
|
2452
2456
|
note: typeof opts.note === "string" ? opts.note : undefined,
|
|
2453
2457
|
...(opts.read ? { read: true } : {}),
|
|
2458
|
+
...(list ? { list } : {}),
|
|
2454
2459
|
// a task for an agent only where the person turned intake.auto on (spec 130 K1.3)
|
|
2455
2460
|
auto: ctx.settings.intakeAuto(tree.config),
|
|
2456
2461
|
});
|
package/dist/core/links.js
CHANGED
|
@@ -29,6 +29,7 @@ import { ICON } from "./shortcut.js";
|
|
|
29
29
|
import { browserKind } from "./chromium.js";
|
|
30
30
|
import { normalizeKinds } from "./eventkinds.js";
|
|
31
31
|
import { HANDOFF } from "./handoffs.js";
|
|
32
|
+
import { oneLineName } from "./text.js";
|
|
32
33
|
export const LINK_SCHEME = "strom-research";
|
|
33
34
|
/** The scheme of this strom's links: strom-research; a second installation's with a command of its own strom-research-<suffix>. */
|
|
34
35
|
export function linkScheme(env) {
|
|
@@ -177,6 +178,8 @@ const HOST = /^(?=.{1,253}$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:
|
|
|
177
178
|
const TRANSFER_NAME = /^strom-prenos-[A-Za-z0-9_-]{8}\.json$/;
|
|
178
179
|
/** The app's own mark of a tree it hands over (32 random bytes, base64url). */
|
|
179
180
|
export const APP_TOKEN = /^[A-Za-z0-9_-]{22,43}$/;
|
|
181
|
+
/** The longest name a link new suggests (the Strom app's dialog allows 120 characters). */
|
|
182
|
+
export const NEW_NAME_MAX = 120;
|
|
180
183
|
/**
|
|
181
184
|
* The tree of the Strom app the person installed strom for: its mark, given to the installer by the line the app
|
|
182
185
|
* shows (STROM_FROM_APP) — strom installed, that tree becomes a research as from the link new?app=. Only the mark.
|
|
@@ -288,7 +291,10 @@ function linkParts(text, scheme) {
|
|
|
288
291
|
const browser = browserKind(q.get("browser") ?? undefined);
|
|
289
292
|
// the tree's file of a move (Safari: strom-prenos-<8 of its mark>.json) — only a name of that one shape, never a path
|
|
290
293
|
const file = q.get("file") ?? "";
|
|
291
|
-
|
|
294
|
+
// the name the app suggests for the research (a copy of a tree, spec 139 K5.4): the one text a link carries — only
|
|
295
|
+
// offered in the terminal for the person to keep or write over, never acted on; one line, at most 120 characters
|
|
296
|
+
const name = oneLineName(q.get("name"), NEW_NAME_MAX);
|
|
297
|
+
return { action, app, ...(browser ? { browser } : {}), ...(TRANSFER_NAME.test(file) ? { file } : {}), ...(name ? { name } : {}) };
|
|
292
298
|
}
|
|
293
299
|
const tree = q.get("tree") ?? "";
|
|
294
300
|
if (!UUID.test(tree))
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// A list of people the Strom app sends material to (spec 137 K2.2, K2.4; feature media.list).
|
|
2
|
+
//
|
|
3
|
+
// The app puts the list first (PUT <token>/lists/<id>: its name, kind, the rule as it says it, the IDs of its people as
|
|
4
|
+
// they are now) and names it with each file (X-Strom-List-Ref). The bridge keeps it in .strom/lists/<id>.json until a
|
|
5
|
+
// file names it (a later PUT of the same id replaces it); the strom that takes the file writes the list as it was sent
|
|
6
|
+
// into the research, unchanged from then on (notes/lists/<hash>.json, in git), and on the input (Input.list). Up to
|
|
7
|
+
// LIST_PEOPLE people of it are the input's people (People concerned in the brief); a longer list is only named, its
|
|
8
|
+
// people in the file — the agent looks them up itself.
|
|
9
|
+
import * as crypto from "node:crypto";
|
|
10
|
+
import * as fs from "node:fs";
|
|
11
|
+
import * as path from "node:path";
|
|
12
|
+
import { UsageError } from "./errors.js";
|
|
13
|
+
/** A list's mark from the app (as a batch's). */
|
|
14
|
+
export const LIST_ID = /^[A-Za-z0-9-]{1,64}$/;
|
|
15
|
+
/** Up to so many people of a list are the material's people; a longer list is named and its people are in its file. */
|
|
16
|
+
export const LIST_PEOPLE = 50;
|
|
17
|
+
/** The most people a list sent takes. */
|
|
18
|
+
export const LIST_MAX = 100_000;
|
|
19
|
+
/** The largest body of PUT /lists. */
|
|
20
|
+
export const LIST_BODY_MAX = 2 * 1024 * 1024;
|
|
21
|
+
export const LIST_KINDS = ["fixed", "auto", "work"];
|
|
22
|
+
const dirOf = (root) => path.join(root, ".strom", "lists");
|
|
23
|
+
const fileOf = (root, id) => path.join(dirOf(root), `${id}.json`);
|
|
24
|
+
/** A body of PUT /lists checked: the list, else why not (its code). */
|
|
25
|
+
export function checkSentList(id, body) {
|
|
26
|
+
const bad = (why) => ({ code: "list.bad-body", why });
|
|
27
|
+
if (!LIST_ID.test(id))
|
|
28
|
+
return bad("the list's mark: letters, digits, - (at most 64)");
|
|
29
|
+
if (!body || typeof body !== "object" || Array.isArray(body))
|
|
30
|
+
return bad("the body: JSON {name, kind, rule?, persons: [P…], missing?, at?}");
|
|
31
|
+
const b = body;
|
|
32
|
+
const name = typeof b.name === "string" ? b.name.normalize("NFC").replace(/[\p{Cc}]/gu, " ").trim().slice(0, 200) : "";
|
|
33
|
+
if (!name)
|
|
34
|
+
return bad("name: the list's name");
|
|
35
|
+
if (b.kind !== undefined && !LIST_KINDS.includes(b.kind))
|
|
36
|
+
return bad(`kind: ${LIST_KINDS.join(" | ")}`);
|
|
37
|
+
if (b.rule !== undefined && typeof b.rule !== "string")
|
|
38
|
+
return bad("rule: the rule as the app says it (text)");
|
|
39
|
+
if (!Array.isArray(b.persons))
|
|
40
|
+
return bad("persons: [P…], the IDs of its people in the research");
|
|
41
|
+
if (b.persons.length > LIST_MAX)
|
|
42
|
+
return { code: "list.large", why: `at most ${LIST_MAX} people in a list` };
|
|
43
|
+
const persons = [];
|
|
44
|
+
for (const p of b.persons) {
|
|
45
|
+
const id = typeof p === "string" ? p.trim().toUpperCase() : "";
|
|
46
|
+
if (!/^P\d{1,9}$/.test(id))
|
|
47
|
+
return bad("persons: [P…], the IDs of its people in the research");
|
|
48
|
+
if (!persons.includes(id))
|
|
49
|
+
persons.push(id);
|
|
50
|
+
}
|
|
51
|
+
if (b.missing !== undefined && !(Number.isInteger(b.missing) && b.missing >= 0))
|
|
52
|
+
return bad("missing: how many people of the list the research has not got");
|
|
53
|
+
const at = typeof b.at === "string" && !Number.isNaN(Date.parse(b.at)) ? new Date(b.at).toISOString() : new Date().toISOString();
|
|
54
|
+
const rule = typeof b.rule === "string" ? b.rule.normalize("NFC").replace(/[\p{Cc}]/gu, " ").trim().slice(0, 500) : "";
|
|
55
|
+
return {
|
|
56
|
+
id,
|
|
57
|
+
name,
|
|
58
|
+
...(b.kind ? { kind: b.kind } : {}),
|
|
59
|
+
...(rule ? { rule } : {}),
|
|
60
|
+
...(b.ruleData !== undefined ? { ruleData: b.ruleData } : {}),
|
|
61
|
+
persons,
|
|
62
|
+
...(b.missing ? { missing: b.missing } : {}),
|
|
63
|
+
at,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/** Kept by the bridge until a file names it (written whole or not at all). */
|
|
67
|
+
export function keepSentList(root, l) {
|
|
68
|
+
fs.mkdirSync(dirOf(root), { recursive: true });
|
|
69
|
+
const f = fileOf(root, l.id);
|
|
70
|
+
fs.writeFileSync(`${f}.${process.pid}.tmp`, JSON.stringify(l));
|
|
71
|
+
fs.renameSync(`${f}.${process.pid}.tmp`, f);
|
|
72
|
+
}
|
|
73
|
+
export function readSentList(root, id) {
|
|
74
|
+
if (!LIST_ID.test(id))
|
|
75
|
+
return undefined;
|
|
76
|
+
try {
|
|
77
|
+
const l = JSON.parse(fs.readFileSync(fileOf(root, id), "utf8"));
|
|
78
|
+
return l && l.id === id && Array.isArray(l.persons) ? l : undefined;
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/** The person by ID through merges, if the research has them. */
|
|
85
|
+
function personHere(tree, id) {
|
|
86
|
+
let p = tree.get(id);
|
|
87
|
+
for (let hops = 0; p?.mergedInto && hops < 10; hops++)
|
|
88
|
+
p = tree.get(p.mergedInto);
|
|
89
|
+
return p && p.type === "person" && !p.retracted ? p.id : undefined;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The list a file names, written into the research as it was sent (notes/lists/<hash>.json, the same content one file):
|
|
93
|
+
* what the input keeps of it, and its people who are the material's people (all of a list of up to LIST_PEOPLE, else
|
|
94
|
+
* none — the list is named). An ID the research has not got counts as missing. The caller holds the tree lock.
|
|
95
|
+
*/
|
|
96
|
+
export function takeList(tree, id) {
|
|
97
|
+
const sent = readSentList(tree.root, id);
|
|
98
|
+
if (!sent)
|
|
99
|
+
throw new UsageError(`no list ${id} sent to this research`, { hint: "the app sends the list first (PUT lists/<id>), then its files", code: "media.no-list", params: { list: id } });
|
|
100
|
+
const persons = [];
|
|
101
|
+
for (const p of sent.persons) {
|
|
102
|
+
const here = personHere(tree, p);
|
|
103
|
+
if (here && !persons.includes(here))
|
|
104
|
+
persons.push(here);
|
|
105
|
+
}
|
|
106
|
+
const missing = (sent.missing ?? 0) + sent.persons.filter((p) => !personHere(tree, p)).length;
|
|
107
|
+
const kept = { id: sent.id, name: sent.name, ...(sent.kind ? { kind: sent.kind } : {}), ...(sent.rule ? { rule: sent.rule } : {}), ...(sent.ruleData !== undefined ? { ruleData: sent.ruleData } : {}), at: sent.at, ...(missing ? { missing } : {}), persons };
|
|
108
|
+
const text = JSON.stringify(kept, null, 1) + "\n";
|
|
109
|
+
const rel = `notes/lists/${crypto.createHash("sha256").update(text).digest("hex").slice(0, 16)}.json`;
|
|
110
|
+
// a logged, sealed write (committed in an archive too, where notes/ is the person's own and never swept in)
|
|
111
|
+
if (!fs.existsSync(path.join(tree.root, ...rel.split("/"))))
|
|
112
|
+
tree.putFile(rel, text, { op: "list.keep", targets: [], summary: `the list "${sent.name.slice(0, 50)}" (${persons.length} people) the Strom app sent material to` });
|
|
113
|
+
const list = { id: sent.id, name: sent.name, ...(sent.kind ? { kind: sent.kind } : {}), ...(sent.rule ? { rule: sent.rule } : {}), count: persons.length, ...(missing ? { missing } : {}), at: sent.at, file: rel };
|
|
114
|
+
return { list, persons: persons.length <= LIST_PEOPLE ? persons : [] };
|
|
115
|
+
}
|
|
116
|
+
/** The same list (the same people as sent then): sent again it changes nothing. */
|
|
117
|
+
export const sameList = (a, b) => !!a && a.file === b.file && a.id === b.id;
|
package/dist/core/live.js
CHANGED
|
@@ -279,12 +279,22 @@
|
|
|
279
279
|
// the app takes head as its version only when parent is the head it knew
|
|
280
280
|
// GET <token>/media/<sha256>?thumb=128|256|512 a small JPEG preview of a file (core/thumbs.ts, kept in
|
|
281
281
|
// .strom/thumbs): 400 thumb.size, 404, 410 media.gone, 415 thumb.type (none of this kind here)
|
|
282
|
+
// PUT <token>/lists/<id> a list of people material is sent to ({name, kind: fixed|auto|work, rule?: the rule as the
|
|
283
|
+
// app says it, ruleData?, persons: [P…] as they are now, missing?: how many of its people the
|
|
284
|
+
// research has not got, at?}): kept by the bridge (.strom/lists/<id>.json; the same id again
|
|
285
|
+
// replaces it) until a file names it; {list, persons, unknown}. 400 list.bad-body, 413
|
|
286
|
+
// list.large, 403 app.only
|
|
282
287
|
// PUT <token>/media/<sha256> an original from the app, unchanged (the body; X-Strom-Name, -Person, -Source,
|
|
283
288
|
// -Region, -Note): streamed to disk, its hash checked, kept outside git
|
|
284
289
|
// (strom media original) — of a source an image, else material of people; a task for the
|
|
285
290
|
// agent (an intake task, a task to read the scan of a source) only with intake.auto on, else
|
|
286
291
|
// the file waits in the material: {input} or {known, added?} with no task (spec 130 K1.3);
|
|
287
292
|
// X-Strom-Batch, -Path (and -Zip: 1, a ZIP unpacked here): one file of a batch
|
|
293
|
+
// X-Strom-List-Ref: <id> — sent to a list of people (spec 137, media.list) the app put
|
|
294
|
+
// first (below): kept on the input (Input.list, its people as sent in notes/lists/), up to 50
|
|
295
|
+
// of its people the input's people too; with -Source (media.list.source) kept on the scan
|
|
296
|
+
// (Media.list), up to 50 of its people those of its task to read it; not with -Task, -Read,
|
|
297
|
+
// -Batch; 404 media.no-list {list} for a list not sent
|
|
288
298
|
// X-Strom-Family: F… (with commas; X-Strom-Person beside it too) — a couple's original
|
|
289
299
|
// (spec 108 V9, accepts.media.family): material of both partners (Input.families) with an
|
|
290
300
|
// intake task as for a person's with intake.auto on (put aside in an archive); media.bad-header for no F…, 404
|
|
@@ -794,6 +804,7 @@ import { checkDeleteConfirm, checkRetractWith, deleteConfirm, DELETE_MOST_FILES,
|
|
|
794
804
|
import { checkRetractConfirm, keepable, restorable, RETRACT_MOST, retractConfirm, retractImpacts } from "./sourceretract.js";
|
|
795
805
|
import { cachedThumb, THUMB_SIZES } from "./thumbs.js";
|
|
796
806
|
import { checkOriginalMeta, cleanIncoming, freeBytes, knownOriginal, materialWaiting, originalMax, ORIGINAL_RESERVE, ORIGINAL_TYPES, parseRegion } from "./originals.js";
|
|
807
|
+
import { checkSentList, keepSentList, LIST_BODY_MAX, LIST_ID, readSentList } from "./lists.js";
|
|
797
808
|
import { BATCH_ID, batchEstimate, batchLimits, batchPath, batchStatus, idleBatches, readBatch } from "./batches.js";
|
|
798
809
|
/** New images for the app, made for at most so long when the tree changed (the rest the next time). */
|
|
799
810
|
const LIVE_IMAGES_MS = 20_000;
|
|
@@ -910,7 +921,7 @@ const REGION_ID = /^[a-z0-9][a-z0-9-]{0,23}$/u;
|
|
|
910
921
|
function placeOk(v) {
|
|
911
922
|
return typeof v === "string" && !!v.trim() && v.length <= 300 && !/[\u0000-\u001f\u007f]/u.test(v);
|
|
912
923
|
}
|
|
913
|
-
const APP_WRITES = new Set(["sync", "adopt", "media", "batch", "waiting", "group", "material", "read", "history", "experiments", "quality", "places", "directions", "offline", "queue", "census", "intake"]);
|
|
924
|
+
const APP_WRITES = new Set(["sync", "adopt", "media", "lists", "batch", "waiting", "group", "material", "read", "history", "experiments", "quality", "places", "directions", "offline", "queue", "census", "intake"]);
|
|
914
925
|
/** A file refused (its error's code): what the bridge says of it. */
|
|
915
926
|
const REFUSED = {
|
|
916
927
|
"tree.other-research": "ui.sync.bridge.other",
|
|
@@ -932,7 +943,9 @@ function said(lang, key, params = {}) {
|
|
|
932
943
|
* -Path, -Name, -Note, -Task)
|
|
933
944
|
* - `media.bad-region` 400 {region} — X-Strom-Region is no part of an image
|
|
934
945
|
* - `media.no-person` 404 {person} — no such person in the research; `media.no-family` 404 {family} — no such couple
|
|
935
|
-
* (X-Strom-Family); `media.no-source` 404 {source} — no such source
|
|
946
|
+
* (X-Strom-Family); `media.no-source` 404 {source} — no such source; `media.no-list` 404 {list} — no list of that
|
|
947
|
+
* mark sent (X-Strom-List-Ref: PUT lists/<id> first)
|
|
948
|
+
* - `list.bad-body` 400, `list.large` 413 — PUT lists/<id>: a body that is no list, a list too large
|
|
936
949
|
* - `media.no-shared` 500 — the research has no shared folder for files (strom setup)
|
|
937
950
|
* - `media.large` 413 {mb} (and `max`) — larger than the research takes; `media.full` 507 (and `free`) — no room
|
|
938
951
|
* (these two: `error` in the research's language, `text` English — said() above)
|
|
@@ -1874,7 +1887,7 @@ export function tagMatches(req, tag) {
|
|
|
1874
1887
|
const MEDIA_REF_UNKNOWN = "sync.media-ref-unknown";
|
|
1875
1888
|
/** How many hashes POST /media/known takes at once. */
|
|
1876
1889
|
export const MEDIA_KNOWN_MAX = 5000;
|
|
1877
|
-
export const BRIDGE_FEATURES = ["sync.again", "sync.undoneSince", "sync.takenBack", "sync.conflictEdit", "sync.since", "sync.ids", "family.noCouple", "family.alone", "adopt.transfer", "adopt.empty", "material.list", "person.titles", "media.codes", "hypothesis.links", "status.recent", "spend.readers", "hypothesis.intree", "archive.permission", "task.check", "waiting.groups", "waiting.sent", "waiting.note", "batch.kept", "live.end", "whats.new", "terminal.choice", "person.marriedSurname", "phone", "read.now", "read.sync", "excerpt.get", "log.sources", "material.assign", "material.thumb", "seal.foreign", "tree.state", "disk.full", "tree.notDownloaded", "sync.removed", "tree.kind", "experiments", "experiments.off", "experiments.link", "experiments.split", "history.events", "history.hide", "experiments.pace", "history.first", "history.regions", "history.hide.all", "history.skip", "history.map", "history.delete", "history.delete.restore", "stories.history", "history.place", "surnames.suggest", "surnames.read", "lineage.read", "duplicates.judge", "quality.dismiss", "quality.read", "person.primary", "fixes.list", "fixes.towns", "history.back", "places.identify", "places.answer", "places.undo", "tasks.offLine", "status.busy", "history.kinds", "history.align", "places.nameKinds", "directions.edit", "directions.order", "directions.found", "directions.people", "directions.places", "offLine.branches", "queue.own", "story.sources", "queue.page", "status.parts", "waiting.answer", "browser.state", "working.place", "working.family", "working.helps", "hypotheses.decide", "sources.confirm", "read.sourceTask", "read.sourceTask.unsure", "read.choose", "read.choices.now", "read.source", "read.sourceEntry", "read.blindText", "read.kinds", "read.variantKind", "read.readerState", "live.idle", "live.stop", "live.start", "sources.proposal", "sources.proposal.undo", "origin", "origin.ids", "verify", "verify.bulk", "facts.confirm", "verify.stop", "ged.stale", "facts.confirm.value", "ged.etag", "ged.imagesByHash", "hypothesis.decide.link", "hypotheses.accept.link", "sources.fields", "sources.split", "queue.search", "queue.next", "work.link", "run.tasks", "queue.kind", "work.tasks", "verify.tryFirst", "event.share", "citations.order", "sync.notWritten.codes", "citations.main", "citations.remove", "books", "media.app", "material.links", "material.edit", "material.uses", "material.sort", "tasks.audit", "handoffs", "material.sourceOf", "material.left", "material.sameAs", "material.sortRun", "material.delete", "inbox.aside", "source.retract", "material.trees", "census", "name-status", "task.holds", "archive.holds", "media.queued", "media.known", "intake.auto", "run.lines", "run.agents", "run.stop", "run.limit", "directions.move", "sync.mediaRef", "person.contact"];
|
|
1890
|
+
export const BRIDGE_FEATURES = ["sync.again", "sync.undoneSince", "sync.takenBack", "sync.conflictEdit", "sync.since", "sync.ids", "family.noCouple", "family.alone", "adopt.transfer", "adopt.empty", "material.list", "person.titles", "media.codes", "hypothesis.links", "status.recent", "spend.readers", "hypothesis.intree", "archive.permission", "task.check", "waiting.groups", "waiting.sent", "waiting.note", "batch.kept", "live.end", "whats.new", "terminal.choice", "person.marriedSurname", "phone", "read.now", "read.sync", "excerpt.get", "log.sources", "material.assign", "material.thumb", "seal.foreign", "tree.state", "disk.full", "tree.notDownloaded", "sync.removed", "tree.kind", "experiments", "experiments.off", "experiments.link", "experiments.split", "history.events", "history.hide", "experiments.pace", "history.first", "history.regions", "history.hide.all", "history.skip", "history.map", "history.delete", "history.delete.restore", "stories.history", "history.place", "surnames.suggest", "surnames.read", "lineage.read", "duplicates.judge", "quality.dismiss", "quality.read", "person.primary", "fixes.list", "fixes.towns", "history.back", "places.identify", "places.answer", "places.undo", "tasks.offLine", "status.busy", "history.kinds", "history.align", "places.nameKinds", "directions.edit", "directions.order", "directions.found", "directions.people", "directions.places", "offLine.branches", "queue.own", "story.sources", "queue.page", "status.parts", "waiting.answer", "browser.state", "working.place", "working.family", "working.helps", "hypotheses.decide", "sources.confirm", "read.sourceTask", "read.sourceTask.unsure", "read.choose", "read.choices.now", "read.source", "read.sourceEntry", "read.blindText", "read.kinds", "read.variantKind", "read.readerState", "live.idle", "live.stop", "live.start", "sources.proposal", "sources.proposal.undo", "origin", "origin.ids", "verify", "verify.bulk", "facts.confirm", "verify.stop", "ged.stale", "facts.confirm.value", "ged.etag", "ged.imagesByHash", "hypothesis.decide.link", "hypotheses.accept.link", "sources.fields", "sources.split", "queue.search", "queue.next", "work.link", "run.tasks", "queue.kind", "work.tasks", "verify.tryFirst", "event.share", "citations.order", "sync.notWritten.codes", "citations.main", "citations.remove", "books", "media.app", "material.links", "material.edit", "material.uses", "material.sort", "tasks.audit", "handoffs", "material.sourceOf", "material.left", "material.sameAs", "material.sortRun", "material.delete", "inbox.aside", "source.retract", "material.trees", "census", "name-status", "task.holds", "archive.holds", "media.queued", "media.known", "intake.auto", "run.lines", "run.agents", "run.stop", "run.limit", "directions.move", "sync.mediaRef", "person.contact", "media.list", "media.list.source"];
|
|
1878
1891
|
/** What only a research with its agent here does (accepts.read: none in an archive, nor where it waits for its agent). */
|
|
1879
1892
|
const AGENT_FEATURES = new Set(["material.sort", "run.lines", "run.agents", "run.stop", "run.limit", "directions.move"]);
|
|
1880
1893
|
const withoutAgent = (features) => features.filter((f) => !AGENT_FEATURES.has(f));
|
|
@@ -2904,6 +2917,14 @@ export function saidAppVersion(req) {
|
|
|
2904
2917
|
const said = (Array.isArray(header) ? header[0] : header)?.trim() || query?.trim();
|
|
2905
2918
|
return said && isAppVersion(said) ? said : undefined;
|
|
2906
2919
|
}
|
|
2920
|
+
/**
|
|
2921
|
+
* The folder a new research of this computer is made in (strom.trees, else the home: `strom init`'s), for the app to show
|
|
2922
|
+
* where a research of a copy of its tree would go (spec 139 K5.4) — only a text to show; none where nothing is set up.
|
|
2923
|
+
*/
|
|
2924
|
+
function treesRootOf(env, settings = new Settings(env, {})) {
|
|
2925
|
+
const at = settings.trees()?.value;
|
|
2926
|
+
return at ? { treesRoot: at } : {};
|
|
2927
|
+
}
|
|
2907
2928
|
/** What the app shows beside the tree. */
|
|
2908
2929
|
/**
|
|
2909
2930
|
* /status worked out (on the bridge's thread of /status, core/livestatus.ts: it reads the whole research — never on the
|
|
@@ -2920,6 +2941,7 @@ export function status(root, env, version, seen) {
|
|
|
2920
2941
|
...channelOf(env),
|
|
2921
2942
|
tree: { id: config?.id, name: config?.name, lang: config?.lang },
|
|
2922
2943
|
path: root,
|
|
2944
|
+
...treesRootOf(env),
|
|
2923
2945
|
locked: { code: refused.code, reason: refused.message, way: refused.hint, ...(refused.params ?? {}) },
|
|
2924
2946
|
live: liveState(env),
|
|
2925
2947
|
links: links(env),
|
|
@@ -2960,6 +2982,7 @@ export function status(root, env, version, seen) {
|
|
|
2960
2982
|
// what the research is (an archive, a research, one waiting for its agent) — the app says it beside the tree
|
|
2961
2983
|
tree: { id: tree.config.id, name: tree.config.name, lang: tree.lang, state: stateOf(tree), kind: kindOf(tree) },
|
|
2962
2984
|
path: root,
|
|
2985
|
+
...treesRootOf(env, settings),
|
|
2963
2986
|
// sealed on this computer (writing works), or on another (its folder brought here, strom's settings gone): the
|
|
2964
2987
|
// app's writes are refused with seal.foreign until the person takes it over (strom seal adopt, the menu, the link seal)
|
|
2965
2988
|
seal: tree.key ? "here" : "elsewhere",
|
|
@@ -3927,6 +3950,10 @@ export function serveLive(root, env) {
|
|
|
3927
3950
|
receive(req, res, origin, "adopt");
|
|
3928
3951
|
return;
|
|
3929
3952
|
}
|
|
3953
|
+
if (req.method === "PUT" && t === token && what === "lists" && sub && !act) {
|
|
3954
|
+
listPut(req, res, origin, decodeURIComponent(sub));
|
|
3955
|
+
return;
|
|
3956
|
+
}
|
|
3930
3957
|
if (req.method === "PUT" && t === token && what === "media") {
|
|
3931
3958
|
// the warm writer started as the original comes (it loads while the bytes come)
|
|
3932
3959
|
writer.warm();
|
|
@@ -5028,6 +5055,7 @@ export function serveLive(root, env) {
|
|
|
5028
5055
|
let named;
|
|
5029
5056
|
let note;
|
|
5030
5057
|
let meta;
|
|
5058
|
+
let list;
|
|
5031
5059
|
let region;
|
|
5032
5060
|
let batch;
|
|
5033
5061
|
let where;
|
|
@@ -5099,13 +5127,23 @@ export function serveLive(root, env) {
|
|
|
5099
5127
|
read = toRead === "1";
|
|
5100
5128
|
if (families.length && (source || task || batch))
|
|
5101
5129
|
throw new Error("X-Strom-Family: a couple's original comes in no batch, for no task and is no image of a source");
|
|
5130
|
+
at = "X-Strom-List-Ref";
|
|
5131
|
+
// the list of people it is sent to (spec 137, media.list): one the app put first (PUT lists/<id>)
|
|
5132
|
+
list = header("x-strom-list-ref")?.trim() || undefined;
|
|
5133
|
+
if (list !== undefined && !LIST_ID.test(list))
|
|
5134
|
+
throw new Error("X-Strom-List-Ref: the list's mark (PUT lists/<id>)");
|
|
5135
|
+
// (with X-Strom-Source: a scan of a source of the list's people — media.list.source)
|
|
5136
|
+
if (list && (task || batch || read))
|
|
5137
|
+
throw new Error("X-Strom-List-Ref: a file sent to a list comes in no batch, for no task and not to read");
|
|
5138
|
+
if (list && !readSentList(root, list))
|
|
5139
|
+
throw new StromError(`no list ${list} sent here — send the list (PUT lists/${list}) and the file again`, { code: "media.no-list", params: { list } });
|
|
5102
5140
|
meta = checkOriginalMeta(tree, { persons, source, families });
|
|
5103
5141
|
}
|
|
5104
5142
|
catch (e) {
|
|
5105
5143
|
// a person or a source the research has not got: 404, its JSON body telling it from an address that is no bridge's
|
|
5106
5144
|
const m = e.message;
|
|
5107
5145
|
const coded = e instanceof StromError && e.code ? refusal(m, e.code, e.params ?? {}) : refusal(m, "media.bad-header", { header: at });
|
|
5108
|
-
return refuse(/^no (person|source|family)/.test(m) ? 404 : 400, coded);
|
|
5146
|
+
return refuse(/^no (person|source|family|list)/.test(m) ? 404 : 400, coded);
|
|
5109
5147
|
}
|
|
5110
5148
|
// a file for a task (its "Add a file"): only for a task that waits for one — else refused before anything is kept
|
|
5111
5149
|
// (the app offers the inbox folder then)
|
|
@@ -5122,7 +5160,52 @@ export function serveLive(root, env) {
|
|
|
5122
5160
|
// whose answer says what became of it
|
|
5123
5161
|
const later = /(?:^|[,;\s])respond-async(?:$|[,;\s])/i.test(header("prefer") ?? "") && !forTask && !read && !meta.source && !region;
|
|
5124
5162
|
const app = header("x-strom-app-version");
|
|
5125
|
-
receiveOriginal(receiver, req, res, { sha, name, note, persons: meta.persons, ...(meta.families ? { families: meta.families } : {}), source: meta.source, region, batch, where, zip, task: forTask, ...(image !== undefined ? { image } : {}), ...(replace ? { replace } : {}), ...(read ? { read } : {}), ...(later ? { async: { origin, ...(app ? { app } : {}) } } : {}) });
|
|
5163
|
+
receiveOriginal(receiver, req, res, { sha, name, note, persons: meta.persons, ...(meta.families ? { families: meta.families } : {}), ...(list ? { list } : {}), source: meta.source, region, batch, where, zip, task: forTask, ...(image !== undefined ? { image } : {}), ...(replace ? { replace } : {}), ...(read ? { read } : {}), ...(later ? { async: { origin, ...(app ? { app } : {}) } } : {}) });
|
|
5164
|
+
};
|
|
5165
|
+
/**
|
|
5166
|
+
* A list of people the app sends material to (PUT lists/<id>, spec 137, feature media.list): checked and kept by the
|
|
5167
|
+
* bridge (.strom/lists/<id>.json) until a file names it (X-Strom-List-Ref) — the strom that takes the file writes it
|
|
5168
|
+
* into the research. {list, persons, unknown}: how many of its people, how many of them the research has not got.
|
|
5169
|
+
*/
|
|
5170
|
+
const listPut = (req, res, origin, id) => {
|
|
5171
|
+
const json = (code, body) => {
|
|
5172
|
+
if (!res.headersSent)
|
|
5173
|
+
res.writeHead(code, { "Content-Type": "application/json; charset=utf-8", "Cache-Control": "no-store" }).end(JSON.stringify(body));
|
|
5174
|
+
};
|
|
5175
|
+
if (!origin) {
|
|
5176
|
+
req.resume();
|
|
5177
|
+
return json(403, refusal("only the Strom app may send a list here", "app.only"));
|
|
5178
|
+
}
|
|
5179
|
+
const chunks = [];
|
|
5180
|
+
let size = 0;
|
|
5181
|
+
let over = false;
|
|
5182
|
+
req.on("data", (c) => {
|
|
5183
|
+
if (over)
|
|
5184
|
+
return;
|
|
5185
|
+
size += c.length;
|
|
5186
|
+
if (size > LIST_BODY_MAX)
|
|
5187
|
+
over = true;
|
|
5188
|
+
else
|
|
5189
|
+
chunks.push(c);
|
|
5190
|
+
});
|
|
5191
|
+
req.on("end", () => safely(req, res, () => {
|
|
5192
|
+
if (over)
|
|
5193
|
+
return json(413, refusal(`a list's body is at most ${LIST_BODY_MAX} bytes`, "list.large", { max: String(LIST_BODY_MAX) }));
|
|
5194
|
+
let body;
|
|
5195
|
+
try {
|
|
5196
|
+
body = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
5197
|
+
}
|
|
5198
|
+
catch {
|
|
5199
|
+
body = undefined;
|
|
5200
|
+
}
|
|
5201
|
+
const l = checkSentList(id, body);
|
|
5202
|
+
if ("code" in l)
|
|
5203
|
+
return json(l.code === "list.large" ? 413 : 400, refusal(l.why, l.code));
|
|
5204
|
+
keepSentList(root, l);
|
|
5205
|
+
const tree = readTree(root, env);
|
|
5206
|
+
const unknown = l.persons.filter((p) => tree.get(p)?.type !== "person").length;
|
|
5207
|
+
json(200, { list: l.id, persons: l.persons.length, unknown });
|
|
5208
|
+
}));
|
|
5126
5209
|
};
|
|
5127
5210
|
// closed one at a time with the queue's writes: the batch's queued files and its close one commit
|
|
5128
5211
|
const closeBatchNow = (id, extra, reply) => media.close(id, (done) => closeBatchBy(receiver, id, extra, (code, body) => {
|
package/dist/core/mediaqueue.js
CHANGED
|
@@ -289,7 +289,7 @@ export function takeQueued(tree, shared, env, o) {
|
|
|
289
289
|
said.input = got.input;
|
|
290
290
|
}
|
|
291
291
|
else {
|
|
292
|
-
const got = takeOriginal(tree, shared, j.file, j.sha, { name: j.name, persons: j.persons, ...(j.families?.length ? { families: j.families } : {}), note: j.note, auto: !!o.auto });
|
|
292
|
+
const got = takeOriginal(tree, shared, j.file, j.sha, { name: j.name, persons: j.persons, ...(j.families?.length ? { families: j.families } : {}), ...(j.list ? { list: j.list } : {}), note: j.note, auto: !!o.auto });
|
|
293
293
|
if (got.known)
|
|
294
294
|
said.known = got.known;
|
|
295
295
|
else
|
package/dist/core/originals.js
CHANGED
|
@@ -10,6 +10,7 @@ import fs from "node:fs";
|
|
|
10
10
|
import path from "node:path";
|
|
11
11
|
import { UsageError } from "./errors.js";
|
|
12
12
|
import { removeRetrying, retryingHeld } from "./json.js";
|
|
13
|
+
import { sameList, takeList } from "./lists.js";
|
|
13
14
|
import { mimeOf, sharedMediaPath } from "./media.js";
|
|
14
15
|
import { create, update } from "./records.js";
|
|
15
16
|
import { makeNote } from "./actions.js";
|
|
@@ -215,7 +216,12 @@ const displayOf = (p) => `${[p.names[0]?.given, p.names[0]?.surname].filter(Bool
|
|
|
215
216
|
* caller holds the tree lock and commits.
|
|
216
217
|
*/
|
|
217
218
|
export function takeOriginal(tree, shared, file, sha, metaIn) {
|
|
218
|
-
const
|
|
219
|
+
const checked = checkOriginalMeta(tree, metaIn);
|
|
220
|
+
// the list it was sent to (of the material, or of a source's scan): its people up to LIST_PEOPLE are its people too,
|
|
221
|
+
// after those named
|
|
222
|
+
const sent = metaIn.list ? takeList(tree, metaIn.list) : undefined;
|
|
223
|
+
const meta = { ...metaIn, ...checked, ...(sent ? { persons: [...new Set([...checked.persons, ...sent.persons])] } : {}) };
|
|
224
|
+
const list = sent?.list;
|
|
219
225
|
const name = path.basename(metaIn.name.normalize("NFC").replace(/[\\/]+/g, "/")).replace(/[\u0000-\u001f]/g, "").slice(0, 200) || `${sha.slice(0, 12)}`;
|
|
220
226
|
const type = originalType(file, name);
|
|
221
227
|
if (!type)
|
|
@@ -231,8 +237,8 @@ export function takeOriginal(tree, shared, file, sha, metaIn) {
|
|
|
231
237
|
fs.rmSync(file, { force: true });
|
|
232
238
|
// an input of the people: what is said of it now is added (in a batch the batch's tasks see to it)
|
|
233
239
|
if (known.kind === "input" && !meta.batch) {
|
|
234
|
-
const a = amendInput(tree, known.id, { persons: meta.persons, note: meta.note, families: meta.families }, { again: !meta.task && !meta.read, auto: !!meta.auto });
|
|
235
|
-
return { known: known.id, ...(a
|
|
240
|
+
const a = amendInput(tree, known.id, { persons: meta.persons, note: meta.note, families: meta.families, list }, { again: !meta.task && !meta.read, auto: !!meta.auto });
|
|
241
|
+
return { known: known.id, ...(addedAny(a) ? { added: a.added } : {}), ...(a.task ? { task: a.task } : {}) };
|
|
236
242
|
}
|
|
237
243
|
return { known: known.id };
|
|
238
244
|
}
|
|
@@ -263,8 +269,8 @@ export function takeOriginal(tree, shared, file, sha, metaIn) {
|
|
|
263
269
|
update(tree, waiting.id, "input", (x) => ({ ...x, file: `media:${rel}`, size, mime: type.mime }), { op: "input.original", summary: `${waiting.id} its original "${name.slice(0, 50)}" (the Strom app)` });
|
|
264
270
|
if (meta.batch)
|
|
265
271
|
return { known: waiting.id };
|
|
266
|
-
const a = amendInput(tree, waiting.id, { persons: meta.persons, note: meta.note, families: meta.families }, { again: !meta.task && !meta.read, auto: !!meta.auto });
|
|
267
|
-
return { known: waiting.id, ...(a
|
|
272
|
+
const a = amendInput(tree, waiting.id, { persons: meta.persons, note: meta.note, families: meta.families, list }, { again: !meta.task && !meta.read, auto: !!meta.auto });
|
|
273
|
+
return { known: waiting.id, ...(addedAny(a) ? { added: a.added } : {}), ...(a.task ? { task: a.task } : {}) };
|
|
268
274
|
}
|
|
269
275
|
if (s) {
|
|
270
276
|
// an image of the source: the record itself, as the user scanned or photographed it
|
|
@@ -278,7 +284,11 @@ export function takeOriginal(tree, shared, file, sha, metaIn) {
|
|
|
278
284
|
...(type.image && !tree.dryRun ? (imageSizeOfFile(dest) ?? {}) : {}),
|
|
279
285
|
from: `${APP_FROM}: ${name}`,
|
|
280
286
|
accessed: new Date().toISOString().slice(0, 10),
|
|
287
|
+
...(list ? { list } : {}),
|
|
281
288
|
}, (id) => `+${id} image "${name.slice(0, 50)}" of ${s.id} (the Strom app)`, [s.id]);
|
|
289
|
+
// an image the research had (of another source) sent now to a list: the list as sent now kept on it
|
|
290
|
+
if (known?.kind === "media" && list && !sameList(m.list, list))
|
|
291
|
+
update(tree, m.id, "media", (x) => ({ ...x, list }), { op: "media.list", summary: `${m.id} sent to the list "${list.name.slice(0, 50)}" (the Strom app)` });
|
|
282
292
|
// the part the entry is on, where nobody said it yet (another one waits for the reader's word)
|
|
283
293
|
const clip = !!meta.region && !s.clips?.length && !!type.image;
|
|
284
294
|
update(tree, s.id, "source", (x) => ({ ...x, media: [...new Set([...(x.media ?? []), m.id])], ...(clip ? { clips: [{ media: m.id, region: meta.region }] } : {}) }), { op: "source.media", summary: `${s.id} image ${m.id}${clip ? " with the part the entry is on" : ""} (the Strom app)` });
|
|
@@ -315,6 +325,7 @@ export function takeOriginal(tree, shared, file, sha, metaIn) {
|
|
|
315
325
|
state: "new",
|
|
316
326
|
...(meta.persons.length ? { persons: meta.persons } : {}),
|
|
317
327
|
...(meta.families?.length ? { families: meta.families } : {}),
|
|
328
|
+
...(list ? { list } : {}),
|
|
318
329
|
...(meta.batch ? { batch: meta.batch } : {}),
|
|
319
330
|
...(meta.path ? { path: meta.path } : {}),
|
|
320
331
|
...(meta.note?.trim() ? { note: meta.note.trim().slice(0, 500) } : {}),
|
|
@@ -344,7 +355,10 @@ export function gatherTask(tree, input, persons) {
|
|
|
344
355
|
.list("task")
|
|
345
356
|
.filter((t) => t.origin === APP_MEDIA_ORIGIN && (t.state === "open" || (held && t.state === "parked")) && Date.now() - Date.parse(t.created) < GATHER_MS && t.where.length < GATHER_MAX && same(t))
|
|
346
357
|
.pop();
|
|
347
|
-
|
|
358
|
+
// sent to a list: named by it, never by its people one by one (up to 50 of them)
|
|
359
|
+
const who = input.list
|
|
360
|
+
? phrase(lang, "app.media.list", { name: input.list.name, count: input.list.count })
|
|
361
|
+
: persons.map((p) => displayOf(tree.get(p))).join(", ") || phrase(lang, "app.media.nobody");
|
|
348
362
|
if (recent) {
|
|
349
363
|
const where = [...recent.where, input.id];
|
|
350
364
|
update(tree, recent.id, "task", (t) => ({ ...t, where, subject: [...where, ...persons], what: phrase(lang, "app.media.what", { count: where.length, who, first: where[0], last: where.at(-1) }) }), { op: "task.edit", summary: `${recent.id} + ${input.id} (the Strom app)` });
|
|
@@ -384,8 +398,10 @@ export function amendInput(tree, id, more, o = {}) {
|
|
|
384
398
|
const families = (checked.families ?? []).filter((f) => !(input.families ?? []).includes(f));
|
|
385
399
|
const text = more.note?.replace(/[\p{Cc}]/gu, " ").trim().slice(0, 500);
|
|
386
400
|
const note = !!text && !input.notes.some((n) => foldText(n.text) === foldText(text));
|
|
387
|
-
|
|
388
|
-
|
|
401
|
+
// the list it was sent to now (the latest send's, as it was sent then)
|
|
402
|
+
const list = more.list && !sameList(input.list, more.list) ? more.list : undefined;
|
|
403
|
+
const out = { known: id, added: { persons, note, ...(families.length ? { families } : {}), ...(list ? { list: true } : {}) }, ...(kept.length ? { declined: kept } : {}) };
|
|
404
|
+
if (!persons.length && !note && !families.length && !list)
|
|
389
405
|
return out;
|
|
390
406
|
const held = tree.list("task").some((t) => t.where.includes(id) && (t.state === "open" || t.state === "doing" || t.state === "parked" || t.state === "waiting"));
|
|
391
407
|
const again = o.again !== false && !held && !input.batch;
|
|
@@ -394,13 +410,16 @@ export function amendInput(tree, id, more, o = {}) {
|
|
|
394
410
|
...(persons.length ? { persons: [...had, ...persons] } : {}),
|
|
395
411
|
...(persons.some((p) => off.has(p)) ? { declined: (i.declined ?? []).filter((d) => !persons.includes(d.person)) } : {}),
|
|
396
412
|
...(families.length ? { families: [...(i.families ?? []), ...families] } : {}),
|
|
413
|
+
...(list ? { list } : {}),
|
|
397
414
|
...(note ? { notes: [...i.notes, makeNote(tree, text)] } : {}),
|
|
398
415
|
...(again ? { state: "new" } : {}),
|
|
399
|
-
}), { op: "input.amend", summary: `${id}: ${[persons.length ? `+ ${persons.join(", ")}` : "", families.length ? `+ ${families.join(", ")}` : "", note ? "+ a note" : ""].filter(Boolean).join(", ")}${o.app === false ? "" : " (the Strom app)"}`, targets: persons });
|
|
416
|
+
}), { op: "input.amend", summary: `${id}: ${[persons.length ? `+ ${persons.join(", ")}` : "", families.length ? `+ ${families.join(", ")}` : "", list ? `+ the list "${list.name.slice(0, 50)}"` : "", note ? "+ a note" : ""].filter(Boolean).join(", ")}${o.app === false ? "" : " (the Strom app)"}`, targets: persons });
|
|
400
417
|
if (again && o.auto)
|
|
401
418
|
out.task = gatherTask(tree, next, next.persons ?? []);
|
|
402
419
|
return out;
|
|
403
420
|
}
|
|
421
|
+
/** Something came of a file sent again: people, a note, couples or a list. */
|
|
422
|
+
const addedAny = (a) => !!(a.added.persons.length || a.added.note || a.added.families || a.added.list);
|
|
404
423
|
/** The originals from the app (or a phone) nobody has worked through yet: what waits in the research (the bridge's inbox.material). */
|
|
405
424
|
export function materialWaiting(tree) {
|
|
406
425
|
// a file taken back or deleted for good waits for nobody
|
package/dist/core/phrases.js
CHANGED
|
@@ -191,6 +191,7 @@ export const PHRASES = {
|
|
|
191
191
|
"transcript.read": "Transcript written by a reader ({model}) from the entry cut out of its scan and checked by a second reader ({date}, strom transcripts).",
|
|
192
192
|
"app.media.what": "Analyse {count, plural, one {# file} other {# files}} the user sent from the Strom app — {who} ({first}–{last})",
|
|
193
193
|
"app.media.nobody": "for the research",
|
|
194
|
+
"app.media.list": "the list “{name}” ({count, plural, one {# person} other {# people}})",
|
|
194
195
|
"app.media.why": "Originals from the user, sent from the Strom app (kept unchanged): find out what each is, whom it is about and what it can prove.",
|
|
195
196
|
"app.scan.what": "Read the scan the user sent of {source} ({title})",
|
|
196
197
|
"app.scan.why": "The user sent the record itself from the Strom app: the research reads it for itself — its reading confirms the user's transcript or shows a mistake.",
|
package/dist/core/receive.js
CHANGED
|
@@ -151,7 +151,8 @@ export function receiveOriginal(r, req, res, f) {
|
|
|
151
151
|
// an input of the people, said of again — people it lacks, a note it has not got: added by a strom of its own
|
|
152
152
|
// (found live: the app said "Sent" while the research took nothing)
|
|
153
153
|
const had = known.kind === "input" && !batch ? tree.get(known.id) : undefined;
|
|
154
|
-
|
|
154
|
+
// (a list: what it is now is compared by the strom that takes it — sent again it changes nothing)
|
|
155
|
+
const more = had && (!!f.list || f.persons.some((p) => !(had.persons ?? []).includes(p)) || (f.families ?? []).some((x) => !(had.families ?? []).includes(x)) || (!!note?.trim() && !had.notes.some((n) => foldText(n.text) === foldText(note.trim()))));
|
|
155
156
|
// (a file to read: what it is of goes with its reading, never into an intake task)
|
|
156
157
|
// nothing written (or what came again not added): the head as it is, which is its parent too (the bridge's answers)
|
|
157
158
|
const unchanged = () => {
|
|
@@ -161,7 +162,7 @@ export function receiveOriginal(r, req, res, f) {
|
|
|
161
162
|
if (!more || f.read)
|
|
162
163
|
return refuse(200, { known: known.id, kind: known.kind, ...(batch ? { batch } : {}), ...unchanged() });
|
|
163
164
|
req.resume();
|
|
164
|
-
runOf(r)(["input", "amend", known.id, ...f.persons.flatMap((p) => ["--person", p]), ...(f.families ?? []).flatMap((x) => ["--family", x]), ...(note ? [`--note=${note}`] : []), "--json"], ({ code, stdout, error }) => {
|
|
165
|
+
runOf(r)(["input", "amend", known.id, ...f.persons.flatMap((p) => ["--person", p]), ...(f.families ?? []).flatMap((x) => ["--family", x]), ...(f.list ? ["--list", f.list] : []), ...(note ? [`--note=${note}`] : []), "--json"], ({ code, stdout, error }) => {
|
|
165
166
|
if (error)
|
|
166
167
|
return reply(200, { known: known.id, kind: known.kind, ...unchanged() });
|
|
167
168
|
let data = {};
|
|
@@ -176,7 +177,10 @@ export function receiveOriginal(r, req, res, f) {
|
|
|
176
177
|
if (code === EXIT.locked)
|
|
177
178
|
return reply(503, { ...refusal("the research is busy — send it again in a while", "research.busy"), retry: 30 });
|
|
178
179
|
const c = committed(data, () => r.head?.());
|
|
179
|
-
|
|
180
|
+
// added only what came (a list sent again the same: nothing)
|
|
181
|
+
const a = data.added;
|
|
182
|
+
const came = !!a && (!!a.persons?.length || !!a.note || !!a.families?.length || !!a.list);
|
|
183
|
+
reply(200, { known: known.id, kind: known.kind, ...(code === 0 && came ? { added: data.added } : {}), ...(code === 0 && data.task ? { task: data.task } : {}), ...(code === 0 ? { head: c.head, ...(c.parent !== undefined ? { parent: c.parent } : {}) } : unchanged()) });
|
|
180
184
|
});
|
|
181
185
|
return;
|
|
182
186
|
}
|
|
@@ -257,6 +261,7 @@ export function receiveOriginal(r, req, res, f) {
|
|
|
257
261
|
job = enqueue(r.root, part, {
|
|
258
262
|
sha, name, persons: f.persons,
|
|
259
263
|
...(f.families?.length ? { families: f.families } : {}),
|
|
264
|
+
...(f.list ? { list: f.list } : {}),
|
|
260
265
|
...(note ? { note } : {}),
|
|
261
266
|
...(batch ? { batch, path: where ?? batchPath(name) ?? name, ...(zip ? { zip: true } : {}) } : {}),
|
|
262
267
|
client: { ...(f.async.origin ? { origin: f.async.origin } : {}), ...(f.async.app ? { app: f.async.app } : {}) },
|
|
@@ -276,6 +281,7 @@ export function receiveOriginal(r, req, res, f) {
|
|
|
276
281
|
"media", "original", part, "--sha", sha, `--name=${name}`,
|
|
277
282
|
...f.persons.flatMap((p) => ["--person", p]),
|
|
278
283
|
...(f.families ?? []).flatMap((x) => ["--family", x]),
|
|
284
|
+
...(f.list ? ["--list", f.list] : []),
|
|
279
285
|
...(f.source ? ["--source", f.source] : []),
|
|
280
286
|
...(region ? ["--region", region] : []),
|
|
281
287
|
...(note ? [`--note=${note}`] : []),
|
package/dist/core/shortcut.js
CHANGED
|
@@ -127,7 +127,8 @@ export function openInNewTerminal(argv, cwd, env, platform = process.platform, o
|
|
|
127
127
|
// the title without what a shell or a terminal reads as its own (quotes, controls, escapes)
|
|
128
128
|
const title = opts.title?.replace(/[\p{Cc}\p{Cf}"'`$\\%^&|<>!]/gu, "").slice(0, 120);
|
|
129
129
|
if (platform === "win32") {
|
|
130
|
-
|
|
130
|
+
// a .cmd reads %…% as a variable even in quotes (a link's name=, a folder with a %): each % doubled
|
|
131
|
+
const q = (a) => `"${a.replace(/"/g, '""').replace(/%/g, "%%")}"`;
|
|
131
132
|
const file = path.join(dir, `strom-${stamp}.cmd`);
|
|
132
133
|
const lines = ["@echo off", "chcp 65001 >nul", ...(title ? [`title ${title}`] : []), ...marks.map((k) => `set "${k}="`), ...own.map(([k, v]) => `set "${k}=${v}"`), 'set "STROM_HANDOVER=1"', `cd /d ${q(cwd)}`, [command, ...args, ...argv].map(q).join(" "), "if errorlevel 1 pause", ""];
|
|
133
134
|
fs.writeFileSync(file, lines.join("\r\n"));
|
package/dist/core/stromapp.js
CHANGED
|
@@ -9,7 +9,7 @@ import path from "node:path";
|
|
|
9
9
|
import { desktopDir, userHome } from "./paths.js";
|
|
10
10
|
import { appUrlInvalid, checkValue, settingDef, Settings } from "./config.js";
|
|
11
11
|
import { UsageError } from "./errors.js";
|
|
12
|
-
import { foldText } from "./text.js";
|
|
12
|
+
import { foldText, oneLineName } from "./text.js";
|
|
13
13
|
import { compareVersions, updateChannel } from "./update.js";
|
|
14
14
|
export const STROM_APP_URL = "https://stromapp.info/run/";
|
|
15
15
|
/** The Strom app's beta: the copy a strom of the beta channel opens unless strom.app.url says another. */
|
|
@@ -123,8 +123,7 @@ export function appCopyOfInstall(env) {
|
|
|
123
123
|
export function appTreeNameFromInstall(env) {
|
|
124
124
|
if (!env.STROM_FROM_APP?.trim())
|
|
125
125
|
return undefined;
|
|
126
|
-
|
|
127
|
-
return name || undefined;
|
|
126
|
+
return oneLineName(env.STROM_FROM_APP_NAME, 80) || undefined;
|
|
128
127
|
}
|
|
129
128
|
/**
|
|
130
129
|
* The setting strom.app.url (STROM_APP_URL) read and checked as strom config set checks it — from the variable, and
|
package/dist/core/sync.js
CHANGED
|
@@ -609,6 +609,7 @@ export function readGedcom(text, lang = "en", opts = {}) {
|
|
|
609
609
|
const note = children(r, "NOTE").map(noteText).map((t) => t.trim()).filter(Boolean).join("\n\n");
|
|
610
610
|
sources.set(key, {
|
|
611
611
|
key,
|
|
612
|
+
...(key.startsWith("x:") ? {} : { fileId: r.xref.replace(/@/g, "") }),
|
|
612
613
|
title: (val(r, "TITL") ?? "").replace(/\s+/g, " ").trim(),
|
|
613
614
|
...(repoName?.trim() ? { repo: repoName.trim() } : {}),
|
|
614
615
|
...(page ? { page } : {}),
|
|
@@ -786,6 +787,7 @@ export function readGedcom(text, lang = "en", opts = {}) {
|
|
|
786
787
|
const emails = gedcomPersonContact(r, noteText).emails;
|
|
787
788
|
persons.set(key, {
|
|
788
789
|
key,
|
|
790
|
+
...(key.startsWith("x:") ? {} : { fileId: r.xref.replace(/@/g, "") }),
|
|
789
791
|
names,
|
|
790
792
|
...(sex ? { sex } : {}),
|
|
791
793
|
facts,
|
|
@@ -995,6 +997,7 @@ export function readStromJson(data, lang = "en") {
|
|
|
995
997
|
const structured = typeof a.folio === "string" || typeof a.image === "string" || typeof a.callNumber === "string";
|
|
996
998
|
sources.set(key, {
|
|
997
999
|
key,
|
|
1000
|
+
...(key.startsWith("x:") ? {} : { fileId: String(a.id ?? id) }),
|
|
998
1001
|
title: (str(a.title) ?? "").replace(/\s+/g, " "),
|
|
999
1002
|
...(str(a.repository) ? { repo: str(a.repository) } : {}),
|
|
1000
1003
|
...(str(a.reference) ? { page: str(a.reference) } : {}),
|
|
@@ -1128,6 +1131,7 @@ export function readStromJson(data, lang = "en") {
|
|
|
1128
1131
|
const primary = p.primaryName === "birth" ? "birth" : p.primaryName === "married" && married ? `married|${nameKey(married)}` : undefined;
|
|
1129
1132
|
persons.set(key, {
|
|
1130
1133
|
key,
|
|
1134
|
+
...(key.startsWith("x:") ? {} : { fileId: String(p.id) }),
|
|
1131
1135
|
...(primary ? { primary } : {}),
|
|
1132
1136
|
...(titles ? { titles } : {}),
|
|
1133
1137
|
names: names.filter((n, i) => n !== married || names.findIndex((m) => nameKey(m) === nameKey(n)) === i),
|
|
@@ -2243,13 +2247,17 @@ export function checkIdentity(tree, incoming, force = false) {
|
|
|
2243
2247
|
for (const key of strangers) {
|
|
2244
2248
|
const p = incoming.persons.get(key);
|
|
2245
2249
|
incoming.persons.delete(key);
|
|
2246
|
-
|
|
2250
|
+
// the file's own mark of them (a copy of a tree of another research, spec 139 K5.4): what the app learns their new
|
|
2251
|
+
// ID by — the other research's number only where the file gives no mark of its own
|
|
2252
|
+
const own = p.fileId ? `x:${p.fileId}` : undefined;
|
|
2253
|
+
const other = own && !incoming.persons.has(own) ? own : `x:${key}`;
|
|
2247
2254
|
incoming.persons.set(other, { ...p, key: other });
|
|
2248
2255
|
for (const f of incoming.families) {
|
|
2249
2256
|
f.partners = f.partners.map((k) => (k === key ? other : k));
|
|
2250
2257
|
f.children = f.children.map((k) => (k === key ? other : k));
|
|
2251
2258
|
}
|
|
2252
2259
|
}
|
|
2260
|
+
foreignSources(tree, incoming);
|
|
2253
2261
|
// a research with nobody in it yet has nothing to compare with: its first tree is taken (found in an archive: the
|
|
2254
2262
|
// first send from the app refused as "0 of 3 people")
|
|
2255
2263
|
if (!force && !incoming.treeId && tree.countLive("person") > 0 && matched < Math.max(1, incoming.persons.size / 2))
|
|
@@ -2260,6 +2268,39 @@ export function checkIdentity(tree, incoming, force = false) {
|
|
|
2260
2268
|
});
|
|
2261
2269
|
return { matched, strangers };
|
|
2262
2270
|
}
|
|
2271
|
+
/**
|
|
2272
|
+
* The sources the file names by an ID the research never gave (REFN S… of another research: a copy of a tree that had
|
|
2273
|
+
* one, spec 139 K5.4): the file's own, under its own mark — the citations of them too — so what they become is told the
|
|
2274
|
+
* app by the file's xref. Only an ID with no record at all here: a source of the research merged or retracted is its own.
|
|
2275
|
+
*/
|
|
2276
|
+
function foreignSources(tree, incoming) {
|
|
2277
|
+
const sources = incoming.sources;
|
|
2278
|
+
if (!sources?.size)
|
|
2279
|
+
return;
|
|
2280
|
+
const moved = new Map();
|
|
2281
|
+
for (const [key, s] of [...sources]) {
|
|
2282
|
+
if (key.startsWith("x:") || !s.fileId || tree.get(key))
|
|
2283
|
+
continue;
|
|
2284
|
+
const own = `x:${s.fileId}`;
|
|
2285
|
+
if (sources.has(own))
|
|
2286
|
+
continue;
|
|
2287
|
+
sources.delete(key);
|
|
2288
|
+
sources.set(own, { ...s, key: own });
|
|
2289
|
+
moved.set(key, own);
|
|
2290
|
+
}
|
|
2291
|
+
if (!moved.size)
|
|
2292
|
+
return;
|
|
2293
|
+
const cites = (list) => list?.forEach((c) => (c.source = moved.get(c.source) ?? c.source));
|
|
2294
|
+
const facts = (list) => list.forEach((f) => cites(f.cites));
|
|
2295
|
+
for (const p of incoming.persons.values()) {
|
|
2296
|
+
cites(p.cites);
|
|
2297
|
+
facts(p.facts);
|
|
2298
|
+
}
|
|
2299
|
+
for (const f of incoming.families) {
|
|
2300
|
+
cites(f.cites);
|
|
2301
|
+
facts(f.facts);
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2263
2304
|
/** The same name, folded: one of a single letter or digit too ("1", "J."), which shares no word. */
|
|
2264
2305
|
function sameName(a, b) {
|
|
2265
2306
|
const norm = (s) => fold(s.replace(/\//g, " ")).split(" ").filter(Boolean).join(" ");
|
package/dist/core/text.js
CHANGED
|
@@ -145,6 +145,17 @@ export function readable(page) {
|
|
|
145
145
|
at[n] = page.length;
|
|
146
146
|
return { text: parts.join(""), at: at.subarray(0, n + 1) };
|
|
147
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* A name another program gives (the Strom app's tree, a link's name=): one line in NFC, no control or format characters
|
|
150
|
+
* (the joiners of a script or an emoji kept),
|
|
151
|
+
* spaces made one, at most `max` characters (whole characters as people see them: never half of one) — "" when nothing
|
|
152
|
+
* is left.
|
|
153
|
+
*/
|
|
154
|
+
export function oneLineName(raw, max) {
|
|
155
|
+
const line = (raw ?? "").normalize("NFC").replace(/[\p{Cc}\p{Zl}\p{Zp}]|(?![\u200c\u200d])\p{Cf}/gu, " ").replace(/\s+/gu, " ").trim();
|
|
156
|
+
const chars = [...new Intl.Segmenter(undefined, { granularity: "grapheme" }).segment(line)].map((g) => g.segment);
|
|
157
|
+
return chars.length <= max ? line : chars.slice(0, max).join("").trim();
|
|
158
|
+
}
|
|
148
159
|
/** Folder-safe name keeping diacritics (works on Windows, macOS, Linux). */
|
|
149
160
|
export function safeFolderName(name) {
|
|
150
161
|
const cleaned = name
|
package/dist/core/tree.js
CHANGED
|
@@ -32,7 +32,7 @@ export const TREE_FILE = "strom.json";
|
|
|
32
32
|
export const SEAL_FOREIGN = "seal.foreign";
|
|
33
33
|
// between releases the candidate being made (a bridge run from the sources says what it is: the Strom app goes by it);
|
|
34
34
|
// at a release the release's own (package.json)
|
|
35
|
-
export const VERSION = "1.37.0-beta.
|
|
35
|
+
export const VERSION = "1.37.0-beta.2";
|
|
36
36
|
/** What a new research is settled with from the start: nothing an older strom counted otherwise to set right in it. */
|
|
37
37
|
export const NEW_TREE_SETTLED = ["readers-1", "proven-originals-1", "origins-1", "verify-originals-1", "origins-tree-1", "name-status-1"];
|
|
38
38
|
const GITIGNORE = `# Strom Research — local state and large files are not versioned
|