fwdloop 0.35.0 → 0.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/types/send.d.ts CHANGED
@@ -1,28 +1,29 @@
1
1
  /**
2
- * M15 items 3 and am1, am2: the accepted answer as the plain-text file the send writes. `{text}` alone is the text exactly; any other flat object is one
3
- * `Name words: value` line per field; a list of results is one `## Result k` block per result with one line per value, in the order the answer holds
4
- * them, then `from the page: "<quote>"`. Never JSON braces, never check marks. What it throws away: a result's keys other than `quote` and `values`.
5
- * @param {Record<string, any>} content @returns {string}
6
- */
7
- export function renderSentMd(content: Record<string, any>): string;
8
- /**
2
+ * M15 am3: the send writes ONE markdown report per run, `<job name>-YYYY-MM-DD.md` (then `-2`, `-3`, ... when that name is taken, never over a taken file): the title, the `Passed` line and the accepted
9
3
  * @param {string} target - a signed arbiter target, e.g. `file:poc/m0/out`.
10
- * @param {string} filename
11
- * @param {unknown} content - the accepted artifact; hash-checked as its JSON, written as plain text (`renderSentMd`).
4
+ * @param {string} jobName - the job's name: the file's name starts with it
5
+ * @param {unknown} content - the accepted artifact; hash-checked as its JSON (M4b item 4).
12
6
  * @param {string|null} [acceptedSha256] - the sha256 the human's accept recorded
13
7
  * (`answerAsk`, M4b piece 3). Required: none recorded (an answer written by an
14
8
  * older version, or no accept in this process) refuses by name.
15
- * @param {{root?: string, runDir?: string}} [ctx] the flow root and this run's folder, for the destination refusals
16
- * @returns {Promise<{ok:true, path:string, bytes:number, sha256:string} | {ok:false, red:string}>}
9
+ * @param {{root?: string, runDir?: string, report?: {runNo: number|null, now?: Date, body: string}}} [ctx] the flow root and this run's folder, for the destination refusals; the report's body, run number and day
10
+ * @returns {Promise<{ok:true, path:string, name:string, bytes:number, sha256:string, taken:string|null} | {ok:false, red:string}>}
17
11
  */
18
- export function sendViaPrimitive(target: string, filename: string, content: unknown, acceptedSha256?: string | null, ctx?: {
12
+ export function sendViaPrimitive(target: string, jobName: string, content: unknown, acceptedSha256?: string | null, ctx?: {
19
13
  root?: string;
20
14
  runDir?: string;
15
+ report?: {
16
+ runNo: number | null;
17
+ now?: Date;
18
+ body: string;
19
+ };
21
20
  }): Promise<{
22
21
  ok: true;
23
22
  path: string;
23
+ name: string;
24
24
  bytes: number;
25
25
  sha256: string;
26
+ taken: string | null;
26
27
  } | {
27
28
  ok: false;
28
29
  red: string;
@@ -25,3 +25,18 @@ export function sheetBrief(checks: any[]): {
25
25
  answer: string;
26
26
  fields: Record<string, Record<string, any>>;
27
27
  };
28
+ /**
29
+ * The plain lines the report carries for each sumIf / countIf check: `Count of rows 3, 5, 9: 3 (computed by code from the rows named)` and `Total of rows 3, 5, 9: 1,234.50 (computed by code from the rows named)`.
30
+ * Computed from the FROZEN table and the rows the step named in the `rows` check of the same table and `where` (M15 am3a), never from a number the step wrote. A check with no such `rows` check, or whose box holds no list
31
+ * of integers, writes no line. A named row that is no row of the sheet adds nothing; a blank cell is skipped; a cell that is no strict number makes the total "not computed", naming the row and the column.
32
+ * @param {any[]} checks the step's sheet checks as signed @param {any} claims the step's boxes by claim name @param {Record<string, {header: string[], rows: {rowNumber: number, cells: string[]}[]}>} tables by input label
33
+ * @returns {string[]}
34
+ */
35
+ export function sheetTotalLines(checks: any[], claims: any, tables: Record<string, {
36
+ header: string[];
37
+ rows: {
38
+ rowNumber: number;
39
+ cells: string[];
40
+ }[];
41
+ }>): string[];
42
+ export const ROW_MATH_OPS: readonly string[];
@@ -13,6 +13,7 @@ export function findColumn(csvText: string, word: string): FoundHeader | FoundAs
13
13
  /** a column fits when a plain number fills at least this share of the rows (F71 (b)) */
14
14
  export const FIT_RATIO: 0.9;
15
15
  export function columnQuestion(word: string, found: FoundAsk, line: number, tied?: boolean): string;
16
+ export function columnTieQuestion(word: string, columns: string[], line: number): string;
16
17
  export function columnTail(line: number, tied?: boolean): string;
17
18
  /**
18
19
  * the word IS a column (nothing to ask)
@@ -15,15 +15,44 @@ export function wholeJobAskIndex({ steps, askLines, sendLines }: {
15
15
  sendLines: Map<number, any>;
16
16
  }): number;
17
17
  /**
18
- * @param {{ steps: { fromLine: number, goal: string, emits?: string }[], askLines: Map<number, any>, lastAskIndex: number,
19
- * readResult: (id: string) => ({ ok: true, value: any } | { ok: false, missing: true } | { ok: false, missing: false, red: string }) }} p
18
+ * Is the prose of this step checked by code (M15 am3 item 2: `### The answer` instead of the not-checked heading)? Only when code really checked the step's own text (a green close with a words-per-section
19
+ * or picked check on it) AND the signed list holds no Not checked `~` rule on the line. A non-empty / `happened` check alone is no prose check, nor is a sheet or quote check (they check cells and quotes).
20
+ * @param {any} step @param {any[]|null|undefined} [checkList] the plan's signed list (`declaration.checkList`)
21
+ * @returns {boolean}
22
+ */
23
+ export function proseCheckedOf(step: any, checkList?: any[] | null | undefined): boolean;
24
+ /**
25
+ * What the report needs besides the steps: the signed lines' own words (the `~` rules), the run's frozen sheets and which sheet checks passed. Read once from the run folder.
26
+ * @param {{ runDir: string, steps: any[], jobLines: any[]|null|undefined, checkList?: any[]|null }} p
27
+ * @returns {{ ok: true, jobLines: any[], checkList: any[]|null, tables: Record<string, any>, okIdsOf: (n: number) => Set<string>|null } | { ok: false, red: string }}
28
+ */
29
+ export function reportContextOf({ runDir, steps, jobLines, checkList }: {
30
+ runDir: string;
31
+ steps: any[];
32
+ jobLines: any[] | null | undefined;
33
+ checkList?: any[] | null;
34
+ }): {
35
+ ok: true;
36
+ jobLines: any[];
37
+ checkList: any[] | null;
38
+ tables: Record<string, any>;
39
+ okIdsOf: (n: number) => Set<string> | null;
40
+ } | {
41
+ ok: false;
42
+ red: string;
43
+ };
44
+ /**
45
+ * @param {{ steps: { fromLine: number, goal: string, emits?: string, close?: any }[], askLines: Map<number, any>, lastAskIndex: number,
46
+ * readResult: (id: string) => ({ ok: true, value: any } | { ok: false, missing: true } | { ok: false, missing: false, red: string }),
47
+ * context: ReturnType<typeof reportContextOf> }} p
20
48
  * @returns {{ ok: true, value: { text: string } } | { ok: false, red: string }}
21
49
  */
22
- export function wholeJobText({ steps, askLines, lastAskIndex, readResult }: {
50
+ export function wholeJobText({ steps, askLines, lastAskIndex, readResult, context }: {
23
51
  steps: {
24
52
  fromLine: number;
25
53
  goal: string;
26
54
  emits?: string;
55
+ close?: any;
27
56
  }[];
28
57
  askLines: Map<number, any>;
29
58
  lastAskIndex: number;
@@ -38,6 +67,7 @@ export function wholeJobText({ steps, askLines, lastAskIndex, readResult }: {
38
67
  missing: false;
39
68
  red: string;
40
69
  });
70
+ context: ReturnType<typeof reportContextOf>;
41
71
  }): {
42
72
  ok: true;
43
73
  value: {
@@ -47,6 +77,26 @@ export function wholeJobText({ steps, askLines, lastAskIndex, readResult }: {
47
77
  ok: false;
48
78
  red: string;
49
79
  };
80
+ /**
81
+ * M15 am3 item 6: the body the send writes. A plan whose last Ask shows the whole job (`wholeIdx` >= 0) was accepted AS that text: the body is `{text}` exactly, never rebuilt. A plan signed before
82
+ * M13 am9 (or a job with no Ask) sends the one step right before the send: its section is written from the accepted artifact, the line being that step's own (or, past an Ask, the step the Ask read).
83
+ * @param {{ content: any, wholeIdx: number, steps: any[], sendIndex: number, askLines: Map<number, any>, context: ReturnType<typeof reportContextOf> }} p
84
+ * @returns {{ ok: true, body: string } | { ok: false, red: string }}
85
+ */
86
+ export function sendBodyOf({ content, wholeIdx, steps, sendIndex, askLines, context }: {
87
+ content: any;
88
+ wholeIdx: number;
89
+ steps: any[];
90
+ sendIndex: number;
91
+ askLines: Map<number, any>;
92
+ context: ReturnType<typeof reportContextOf>;
93
+ }): {
94
+ ok: true;
95
+ body: string;
96
+ } | {
97
+ ok: false;
98
+ red: string;
99
+ };
50
100
  /**
51
101
  * M13 am9 item 4: the plan shows the last Ask as reading every step. Code sets the Ask's `reads` to every work step's emits before it (the nearest one first, so a
52
102
  * redo still re-runs the step just before the Ask; the rest in job order). Only for the Ask right before the action; any other plan comes back as it was.