pi-straw-boss 0.88.2 → 0.88.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server/main.mjs +8 -3
- package/package.json +1 -1
- package/src/server/carbook.ts +9 -3
package/dist/server/main.mjs
CHANGED
|
@@ -19406,6 +19406,11 @@ var iso2 = (ms3) => new Date(ms3).toISOString();
|
|
|
19406
19406
|
var noticeName = (name2) => name2.replace(/\.json$/, ".notice.json");
|
|
19407
19407
|
var PAST = "#";
|
|
19408
19408
|
var changedAt = (held2) => held2.file.states.at(-1)?.at ?? "";
|
|
19409
|
+
var newestFiles = (list2) => {
|
|
19410
|
+
if (list2.length <= MAX_FILES) return list2;
|
|
19411
|
+
const keep2 = new Set([...list2].sort((a, b) => changedAt(a) < changedAt(b) ? 1 : changedAt(a) > changedAt(b) ? -1 : 0).slice(0, MAX_FILES));
|
|
19412
|
+
return list2.filter((h) => keep2.has(h));
|
|
19413
|
+
};
|
|
19409
19414
|
var blankUser = (text14) => text14.replace(/\/\/[^/@\s'"]+@/g, "//***@");
|
|
19410
19415
|
var firstLine = (error) => blankUser(String(error.stderr || error.message).trim().split("\n")[0]).slice(0, 200);
|
|
19411
19416
|
function reachClass(line4) {
|
|
@@ -19678,9 +19683,9 @@ var CarBook = class {
|
|
|
19678
19683
|
return { reg, setter: { role, name: look2.name, session: reg.session, ...look2.workspace ? { workspace: look2.workspace } : {} }, look: look2, ...look2.train ? { train: look2.train } : {} };
|
|
19679
19684
|
}
|
|
19680
19685
|
// ---- reading
|
|
19681
|
-
/**
|
|
19686
|
+
/** The newest `MAX_FILES` car files of a project with their notice records: for the sender's own bookkeeping and the tests. A caller over the socket gets `readFor`. */
|
|
19682
19687
|
read(project) {
|
|
19683
|
-
return [...this.cars.get(project)?.values() ?? []]
|
|
19688
|
+
return newestFiles([...this.cars.get(project)?.values() ?? []]).map((h) => ({ file: structuredClone(h.file), ...h.notice ? { notice: structuredClone(h.notice) } : {} }));
|
|
19684
19689
|
}
|
|
19685
19690
|
/** The book's own record of one car (no copy; read only): the yard's notice line comes from here, and from the journal on disk only for a car this server's life has not seen (TB-F005). */
|
|
19686
19691
|
viewOf(project, app, head) {
|
|
@@ -19709,7 +19714,7 @@ var CarBook = class {
|
|
|
19709
19714
|
});
|
|
19710
19715
|
}
|
|
19711
19716
|
const mine = (h) => h.file.states.some((s2) => s2.by.session === setter.session) || this.forwardOf(h.file.car.head, setter.session) !== void 0;
|
|
19712
|
-
return [...this.cars.get(project)?.values() ?? []].filter(mine)
|
|
19717
|
+
return newestFiles([...this.cars.get(project)?.values() ?? []].filter(mine)).map(view);
|
|
19713
19718
|
}
|
|
19714
19719
|
/**
|
|
19715
19720
|
* The life of a car (by its head) a train acts on and reads: the newest one the integrator received for this train, else the life the car lives now. A car that was dropped and then sent again rides another train in a new life (#14),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-straw-boss",
|
|
3
|
-
"version": "0.88.
|
|
3
|
+
"version": "0.88.3",
|
|
4
4
|
"description": "Straw Boss coordination for pi in Herdr: sessions join a tab's net by choice, the first joiner is its main agent, a workspace tower opens on demand with a live monitoring dashboard, and boss_broadcast reaches the rest",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/src/server/carbook.ts
CHANGED
|
@@ -124,6 +124,12 @@ const noticeName = (name: string) => name.replace(/\.json$/, ".notice.json");
|
|
|
124
124
|
/** What follows a car file's name in the key of an earlier life (`<name>#<n>`); no file name holds it. */
|
|
125
125
|
const PAST = "#";
|
|
126
126
|
const changedAt = (held: Held) => held.file.states.at(-1)?.at ?? "";
|
|
127
|
+
/** The `MAX_FILES` cars whose newest state is newest, in the book's order: the book's order after a restart is the journal's file names, so a plain slice of it would drop a car that just changed (MP-5664 was invisible to the integrator that received it). */
|
|
128
|
+
const newestFiles = (list: Held[]): Held[] => {
|
|
129
|
+
if (list.length <= MAX_FILES) return list;
|
|
130
|
+
const keep = new Set([...list].sort((a, b) => (changedAt(a) < changedAt(b) ? 1 : changedAt(a) > changedAt(b) ? -1 : 0)).slice(0, MAX_FILES));
|
|
131
|
+
return list.filter((h) => keep.has(h));
|
|
132
|
+
};
|
|
127
133
|
/** git's first line of stderr, else the error's message (sb's own timeout names the command and its URL), with a URL's userinfo blanked (`blankUser`, also on the remotes a moved-remote refusal names): a token used as the https username goes into no tool text or log (R0772-F002, R0773-F001). */
|
|
128
134
|
const blankUser = (text: string) => text.replace(/\/\/[^/@\s'"]+@/g, "//***@");
|
|
129
135
|
const firstLine = (error: unknown) => blankUser(String((error as { stderr?: unknown }).stderr || (error as Error).message).trim().split("\n")[0]!).slice(0, 200);
|
|
@@ -392,9 +398,9 @@ export class CarBook {
|
|
|
392
398
|
|
|
393
399
|
// ---- reading
|
|
394
400
|
|
|
395
|
-
/**
|
|
401
|
+
/** The newest `MAX_FILES` car files of a project with their notice records: for the sender's own bookkeeping and the tests. A caller over the socket gets `readFor`. */
|
|
396
402
|
read(project: string): CarView[] {
|
|
397
|
-
return [...(this.cars.get(project)?.values() ?? [])]
|
|
403
|
+
return newestFiles([...(this.cars.get(project)?.values() ?? [])]).map((h) => ({ file: structuredClone(h.file), ...(h.notice ? { notice: structuredClone(h.notice) } : {}) }));
|
|
398
404
|
}
|
|
399
405
|
/** The book's own record of one car (no copy; read only): the yard's notice line comes from here, and from the journal on disk only for a car this server's life has not seen (TB-F005). */
|
|
400
406
|
viewOf(project: string, app: string, head: string): CarView | undefined {
|
|
@@ -416,7 +422,7 @@ export class CarBook {
|
|
|
416
422
|
return [...new Set(this.trainOf(project, train!.code)?.heads ?? [])].flatMap((head) => { const life = this.lifeFor(project, head, train!.code); return life ? [view(life[1])] : []; });
|
|
417
423
|
}
|
|
418
424
|
const mine = (h: Held) => h.file.states.some((s) => s.by.session === setter.session) || this.forwardOf(h.file.car.head, setter.session) !== undefined;
|
|
419
|
-
return [...(this.cars.get(project)?.values() ?? [])].filter(mine)
|
|
425
|
+
return newestFiles([...(this.cars.get(project)?.values() ?? [])].filter(mine)).map(view);
|
|
420
426
|
}
|
|
421
427
|
/**
|
|
422
428
|
* The life of a car (by its head) a train acts on and reads: the newest one the integrator received for this train, else the life the car lives now. A car that was dropped and then sent again rides another train in a new life (#14),
|