G2 token-stand-in-goes (TypeScript half): at each start while a token file remains and once this start's token is held, the forge's token lists are read before any token is deleted, a pair is matched by the token's last eight characters and its scopes, revoked by its id and deleted; a .tmp goes with its pair, a cut one unrevoked; a pair that stays is the finding token-file-unrevoked. findingKey and findingValue move to findings.ts. Builds: design 47 H2 H-A-575, H-A-602, H-A-642, H-A-699
20 lines
1.2 KiB
TypeScript
20 lines
1.2 KiB
TypeScript
// The key and the value of a finding a part writes into its own state `findings`, as the condition keeper reads it
|
|
// (kept apart from catalog.ts, which loads the catalog seat's contract, so a part that only writes a finding loads nothing else).
|
|
|
|
import type { Finding } from "@novox/mesh-sdk/views";
|
|
|
|
/** The key of a finding about a module: scope, the id's dotted parts, and the kind, each part made safe (mesh-sdk health.Key). */
|
|
export function findingKey(scope: string, id: string, kind: string): string {
|
|
return [scope, ...id.split("."), kind].map((p) => p.trim().replace(/[^A-Za-z0-9_=/-]/g, "_") || "_").join(".");
|
|
}
|
|
|
|
/** A finding as the condition keeper reads it from the module's state `findings`: its key and its value. */
|
|
export function findingValue(f: Finding): { key: string; value: Record<string, unknown> } {
|
|
const key = findingKey("module", f.id, f.kind);
|
|
return { key, value: {
|
|
v: 1, key, kind: f.kind, subject: { scope: "module", id: f.id }, severity: "warning", summary: f.summary, headline: f.headline,
|
|
explanation: f.explanation, resolved: "", evidence: [{ at: f.at, said: f.summary }], source: `${f.observer}.${f.kind}`,
|
|
observer: f.observer, at: f.at,
|
|
} };
|
|
}
|