@nodii/dev 0.6.165 → 0.6.168
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/cli.js +13 -0
- package/dist/core.js +1 -1
- package/dist/red-run.js +307 -0
- package/dist/review.js +32 -23
- package/dist/surface.js +171 -28
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -105,6 +105,7 @@ nodii-dev lane check KEY --gate 'pnpm typecheck' --gate 'pnpm lint' --gate 'nodi
|
|
|
105
105
|
- Each package runs its tests with its own `test` script's runner and flags, and the selected files replace the script's paths. A script that is not one runner call (`bun run gate && bun test`) runs whole.
|
|
106
106
|
- `lane check` refuses a full-suite gate (`GATE_FULL_SUITE`) unless `--full-suite` is passed. A whole suite also means one workspace's or project's whole suite (`npm test -w X`, `pnpm --filter X test`, `jest --selectProjects web`), a runner given no path (`node --test`, `npx playwright test`, `pytest`, `go test ./...`), and any of these inside `sh -c`. From a lane's own config, `--full-suite` is refused too (`FULL_SUITE_LANE_REFUSED`, hub-485).
|
|
107
107
|
- The review body carries the gates receipt (`gates`): each gate's command, exit code and commit for this head and base, so Dev can refuse a whole-suite gate itself (hub-485). A `gates` field in a hand-written review file is never sent.
|
|
108
|
+
- Red, then green (hub-485). Before the change, `nodii-dev lane test KEY --red -- 'node --test test/a.test.js'` records the tests for it failing at a clean commit, as a signed red `test` receipt on the lane (`--check NAME` for work with no behaviour to test). Each green gate in the receipt names the repo-relative `files` it ran, so Dev can check that every red test is green at the head; a named check is green when a gate runs its exact command.
|
|
108
109
|
|
|
109
110
|
## Heavy work: one machine-wide slot queue
|
|
110
111
|
|
package/dist/cli.js
CHANGED
|
@@ -116,6 +116,7 @@ import {
|
|
|
116
116
|
nextCommand,
|
|
117
117
|
peopleCommand,
|
|
118
118
|
} from "./lanes.js";
|
|
119
|
+
import { laneTestCommand } from "./red-run.js";
|
|
119
120
|
import {
|
|
120
121
|
amendmentGuard,
|
|
121
122
|
amendLaneCommand,
|
|
@@ -480,6 +481,11 @@ Usage: nodii-dev <command> [options] [--json]
|
|
|
480
481
|
# locked decision that settles it (MW4-27), deferred an open issue. Records the
|
|
481
482
|
# round once nothing blocks; Dev checks each citation and refuses code-check
|
|
482
483
|
# findings, blockers, and security, tenancy, PII and money findings (MW2-41)
|
|
484
|
+
lane test <key> --red [--check NAME] -- <command>
|
|
485
|
+
# hub-485: before the change, record the tests for it failing at a clean
|
|
486
|
+
# commit; attaches a signed red test receipt. Names the test files
|
|
487
|
+
# (or --check NAME for work with no behaviour to test); refuses a whole
|
|
488
|
+
# suite, a masked exit status and a run that passes
|
|
483
489
|
lane check <key> [--gate CMD ...] [--critical] [--max-iterations N] [--picker agent]
|
|
484
490
|
# from the lane's worktree: the rules, Figma and code checks over the
|
|
485
491
|
# diff against origin/main (DEV-REV); --gate runs gates 1-5 in order
|
|
@@ -936,6 +942,13 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
936
942
|
process.exitCode = exitCode;
|
|
937
943
|
return;
|
|
938
944
|
}
|
|
945
|
+
// hub-485: lane test reads its own words (its --check takes a value, and the command follows `--`).
|
|
946
|
+
if (argv[0] === "lane" && argv[1] === "test") {
|
|
947
|
+
const result = await laneTestCommand(argv.slice(2));
|
|
948
|
+
emit(result.payload, argv.slice(0, argv.includes("--") ? argv.indexOf("--") : argv.length).includes("--json"), result.human);
|
|
949
|
+
if (result.exitCode) process.exitCode = result.exitCode;
|
|
950
|
+
return;
|
|
951
|
+
}
|
|
939
952
|
const { args, flags: f } = parseArgs(argv);
|
|
940
953
|
const json = Boolean(f.json);
|
|
941
954
|
const [command, action, ...rest] = args;
|
package/dist/core.js
CHANGED
|
@@ -4,7 +4,7 @@ import { chmod, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
|
4
4
|
import { homedir, platform } from "node:os";
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
6
6
|
|
|
7
|
-
export const VERSION = "0.6.
|
|
7
|
+
export const VERSION = "0.6.168";
|
|
8
8
|
export const configPath = () =>
|
|
9
9
|
process.env.NODII_DEV_CONFIG_PATH ??
|
|
10
10
|
join(homedir(), ".config/nodii-dev/config.json");
|
package/dist/red-run.js
ADDED
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hub-485, the red-run half (MW2-20; the operator, 15 Nov 2026: "the lanes starts with red tests and to pass must make
|
|
3
|
+
* a test green"). A lane declares the tests for its change by recording them failing before it builds:
|
|
4
|
+
* `nodii-dev lane test <key> --red -- <command>` attaches a signed `test` receipt with `red: true`, the
|
|
5
|
+
* commit, and the repo-relative files it ran. lane check's gates receipt then says which red files and
|
|
6
|
+
* named checks each gate ran green at the head, and Dev refuses a passing review that leaves one uncovered.
|
|
7
|
+
* The shape is agreed with the hub on the issue; Dev classifies and checks every command itself.
|
|
8
|
+
*/
|
|
9
|
+
import { posix } from "node:path";
|
|
10
|
+
import { CliError, devRequest, encode } from "./core.js";
|
|
11
|
+
import { inferGitContext } from "./lanes.js";
|
|
12
|
+
import { readPolicy as readRepoPolicy } from "./repo-policy.js";
|
|
13
|
+
import { devDown, queuePending, receiptEvidenceBody, redactCommand, writeReceipt as writeSignedReceipt } from "./receipt.js";
|
|
14
|
+
import { fullSuiteGate, operandsOf, privateStore, runnerWords, selfSizedGate, shellCommands, shellScript, worktreeCommitted } from "./review.js";
|
|
15
|
+
|
|
16
|
+
/** The lane's red runs in this worktree's git dir, by lane: a local record; Dev holds the signed receipts. */
|
|
17
|
+
export const RED_RUNS = "nodii-red-runs.json";
|
|
18
|
+
export const LANE_TEST_USAGE = "nodii-dev lane test <key> --red [--check NAME] -- <command>";
|
|
19
|
+
|
|
20
|
+
const PACKAGE_MANAGERS = new Set(["npm", "pnpm", "yarn", "bun"]);
|
|
21
|
+
// A path names a file or a directory (`test/a.test.js`, `internal/billing`); a bare word is a name filter.
|
|
22
|
+
const pathLike = (word) => word.includes("/") || /\.[A-Za-z0-9]+$/.test(word);
|
|
23
|
+
|
|
24
|
+
/** The paths one simple command (already unwrapped) hands a test runner, as it wrote them. */
|
|
25
|
+
function handed(words) {
|
|
26
|
+
const [tool, ...args] = words;
|
|
27
|
+
const name = (tool ?? "").split("/").pop();
|
|
28
|
+
const operands = operandsOf(args, { pm: PACKAGE_MANAGERS.has(name) });
|
|
29
|
+
if (name === "bun" && operands[0] === "test") return operands.slice(1);
|
|
30
|
+
if (PACKAGE_MANAGERS.has(name)) {
|
|
31
|
+
// `npm test -- a.test.js`, `npm run test:unit -- a.test.js`: the script gets the paths.
|
|
32
|
+
if (["run", "run-script"].includes(operands[0])) return operands.slice(2);
|
|
33
|
+
return operands[0] === "test" || operands[0] === "t" ? operands.slice(1) : [];
|
|
34
|
+
}
|
|
35
|
+
if (name === "node") return args.includes("--test") ? operands : [];
|
|
36
|
+
if (["vitest", "jest"].includes(name)) return operands.filter((word) => !["run", "watch"].includes(word));
|
|
37
|
+
if (name === "playwright" || name === "go") return operands[0] === "test" ? operands.slice(1) : [];
|
|
38
|
+
if (name === "pytest") return operands;
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// A package manager's flags that run the script in another directory (not a workspace name).
|
|
43
|
+
const DIRECTORY_FLAGS = new Set(["--prefix", "-C", "--dir", "--cwd"]);
|
|
44
|
+
/** DIR joined with a `cd` or directory-flag TARGET, or null when it leaves the repository or cannot be placed. */
|
|
45
|
+
function placeDir(dir, target) {
|
|
46
|
+
if (dir === null || !target || /^[/~-]/.test(target) || /[$`]/.test(target)) return null;
|
|
47
|
+
const joined = posix.normalize(posix.join(dir, target)).replace(/\/+$/, "");
|
|
48
|
+
if (joined === ".." || joined.startsWith("../")) return null;
|
|
49
|
+
return joined === "." ? "" : joined;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The repo-relative paths a command hands a test runner, and whether any could not be placed in the repository. */
|
|
53
|
+
function runnerScan(command, cwd = "") {
|
|
54
|
+
const paths = [];
|
|
55
|
+
let outside = false;
|
|
56
|
+
let dir = cwd;
|
|
57
|
+
for (const part of shellCommands(String(command ?? "").trim())) {
|
|
58
|
+
const nested = shellScript(part);
|
|
59
|
+
if (nested !== null) { const inner = runnerScan(nested, dir); paths.push(...inner.paths); outside ||= inner.outside; continue; }
|
|
60
|
+
const words = runnerWords(part);
|
|
61
|
+
if (words[0] === "cd") { dir = placeDir(dir, words[1]); outside ||= dir === null; continue; }
|
|
62
|
+
let here = dir;
|
|
63
|
+
const name = (words[0] ?? "").split("/").pop();
|
|
64
|
+
if (PACKAGE_MANAGERS.has(name)) {
|
|
65
|
+
// `npm --prefix packages/dev test -- a.test.js`: the script runs in packages/dev.
|
|
66
|
+
for (const [i, word] of words.entries()) {
|
|
67
|
+
const [flag, inline] = word.split("=");
|
|
68
|
+
if (DIRECTORY_FLAGS.has(flag)) { here = placeDir(here, inline ?? words[i + 1]); outside ||= here === null; }
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
for (const word of handed(words).filter(pathLike)) {
|
|
72
|
+
const path = word.startsWith("/") ? null : placeDir(here, word);
|
|
73
|
+
if (path) paths.push(path); else outside = true;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return { paths: [...new Set(paths)], outside };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The repo-relative test paths a command hands a test runner (agreed on the issue: paths read against the `cd`): `cd packages/dev &&
|
|
81
|
+
* node --test test/a.test.js` names `packages/dev/test/a.test.js`. CWD is the command's directory relative
|
|
82
|
+
* to the repository root. A path outside the repository, or under a directory this tool cannot place, is
|
|
83
|
+
* dropped, never sent.
|
|
84
|
+
*/
|
|
85
|
+
export const runnerPaths = (command, cwd = "") => runnerScan(command, cwd).paths;
|
|
86
|
+
|
|
87
|
+
// Governor pass: flags that load code of the agent's own before the tests (`node -r ./boom.js` can fail every run).
|
|
88
|
+
// The hub's parity list adds node's `-e`, `--eval` and `--print`.
|
|
89
|
+
// Kebab-case spellings (jest, vitest), pytest's `-o` ini override, and node's env files, which can set NODE_OPTIONS.
|
|
90
|
+
const CODE_FLAGS = new Set(["-r", "--require", "--import", "--loader", "--experimental-loader", "--preload", "--setupFiles", "--setupFilesAfterEnv", "--globalSetup", "--globalTeardown",
|
|
91
|
+
"--setup-files", "--setup-files-after-env", "--global-setup", "--global-teardown", "-p", "-e", "--eval", "--print", "-o", "--override-ini", "--env-file", "--env-file-if-exists"]);
|
|
92
|
+
// Flags a wrapper (npm, npx) takes before the runner: runnerWords drops some of them, so they are read from the raw words.
|
|
93
|
+
const RAW_CODE_FLAGS = new Set(["--node-options", "--env-file", "--env-file-if-exists"]);
|
|
94
|
+
// go's `-race`, `-run`, `-p N` and `-parallel N` load nothing; `-exec` and `-toolexec` run a program of the agent's choosing.
|
|
95
|
+
const GO_CODE_FLAGS = new Set(["-exec", "-toolexec"]);
|
|
96
|
+
// go reads `--run` as `-run` and `-test.run` as the test binary's own `-run`; `-args` hands the rest to the binary.
|
|
97
|
+
const GO_NO_COVER_FLAGS = new Set(["-run", "-skip", "-list", "-args"]);
|
|
98
|
+
const goFlag = (word) => word.split("=")[0].replace(/^--/, "-").replace(/^-test\./, "-");
|
|
99
|
+
// Environment variables that make a runner load code or take flags before the tests: node, bun, npm, go and pytest.
|
|
100
|
+
const CODE_ENV = /^['"]?(NODE_OPTIONS|BUN_OPTIONS|GOFLAGS|PYTEST_ADDOPTS|PYTEST_PLUGINS|npm_config_node_options)=/i;
|
|
101
|
+
// Governor pass: flags that select or skip tests by name, so a gate that has them may have run no test at all.
|
|
102
|
+
const FILTER_FLAGS = new Set(["-t", "--testNamePattern", "--test-name-pattern", "--test-skip-pattern", "--test-only", "--passWithNoTests", "--pass-with-no-tests", "-k", "-run", "--grep", "-g", "--grep-invert",
|
|
103
|
+
"--testPathIgnorePatterns", "--test-path-ignore-patterns", "--testPathPattern", "--test-path-pattern"]);
|
|
104
|
+
// Parity with the hub: flags that list, shard, pick or skip test files, or print help, so the gate may have run none of its paths.
|
|
105
|
+
const NO_COVER_FLAGS = new Set([...FILTER_FLAGS, "--listTests", "--list-tests", "--list", "--collect-only", "--co", "--help", "-h", "--version", "--shard", "--test-shard", "--only", "--exclude"]);
|
|
106
|
+
|
|
107
|
+
/** The package-manager command's own words: those before its first operand (the script or subcommand name). */
|
|
108
|
+
const ownWords = (words) => { const at = words.findIndex((word, i) => i > 0 && !word.startsWith("-")); return at === -1 ? words.length : at; };
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* What in one simple command (not yet unwrapped) loads code before the tests: a code flag, a joined `-r…`/`-p…`,
|
|
112
|
+
* a wrapper's node options or env file, or a runner's options in the environment (NODE_OPTIONS, GOFLAGS, …).
|
|
113
|
+
*/
|
|
114
|
+
function codeLoads(part) {
|
|
115
|
+
const raw = part.split(/\s+/).map((word) => word.replace(/^['"]+|['"]+$/g, ""));
|
|
116
|
+
const env = raw.map((word) => CODE_ENV.exec(word)?.[1]).filter(Boolean);
|
|
117
|
+
const wrapped = raw.filter((word) => RAW_CODE_FLAGS.has(word.split("=")[0]));
|
|
118
|
+
const words = runnerWords(part);
|
|
119
|
+
const name = (words[0] ?? "").split("/").pop();
|
|
120
|
+
// npm, pnpm and yarn take `-r` (--recursive) before the script; after it, or after `--`, it is the runner's --require.
|
|
121
|
+
const own = ["npm", "pnpm", "yarn"].includes(name) ? ownWords(words) : 0;
|
|
122
|
+
const flags = words.slice(1).filter((word, i) => {
|
|
123
|
+
const flag = word.split("=")[0];
|
|
124
|
+
if (name === "go") return GO_CODE_FLAGS.has(goFlag(word));
|
|
125
|
+
if (word === "-r" && i + 1 < own) return false;
|
|
126
|
+
if (CODE_FLAGS.has(flag)) return true;
|
|
127
|
+
// `-r./boom.js`, `-p./boom.js`: a joined value. pytest's joined `-rA` picks the report.
|
|
128
|
+
return /^-[rp][^-]/.test(word) && !(name === "pytest" && word.startsWith("-r"));
|
|
129
|
+
});
|
|
130
|
+
return [...new Set([...env, ...wrapped, ...flags])];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Whether a green gate may have run none of the paths it names: it filters, lists, shards or loads code first. */
|
|
134
|
+
function coversNothing(command, depth = 0) {
|
|
135
|
+
return shellCommands(String(command ?? "").trim()).some((part) => {
|
|
136
|
+
const nested = shellScript(part);
|
|
137
|
+
if (nested !== null) return depth < 4 && coversNothing(nested, depth + 1);
|
|
138
|
+
const words = runnerWords(part);
|
|
139
|
+
const name = (words[0] ?? "").split("/").pop();
|
|
140
|
+
if (name === "go") { if (words.some((word) => GO_NO_COVER_FLAGS.has(goFlag(word)))) return true; }
|
|
141
|
+
else if (words.some((word) => word.startsWith("-") && (NO_COVER_FLAGS.has(word.split("=")[0]) || /^-[tk][^-]/.test(word)))) return true;
|
|
142
|
+
if (name === "vitest" && words.slice(1).includes("list")) return true;
|
|
143
|
+
return codeLoads(part).length > 0;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Why a red run's command is not one test run of its own, or null. A red run is at most one `cd DIR &&` and
|
|
149
|
+
* then one command, which loads no code of the agent's own: anything chained after it (`&& false`) or
|
|
150
|
+
* loaded before the tests (`-r ./boom.js`) could fail every time, whatever the tests do.
|
|
151
|
+
*/
|
|
152
|
+
function notOneRunner(command, { named }) {
|
|
153
|
+
const text = String(command).trim();
|
|
154
|
+
const parts = shellCommands(text);
|
|
155
|
+
const nested = parts.length === 1 ? shellScript(parts[0]) : null;
|
|
156
|
+
if (nested !== null) return notOneRunner(nested, { named });
|
|
157
|
+
if (parts.length > 2 || (parts.length === 2 && runnerWords(parts[0])[0] !== "cd")) return "it chains more than one `cd DIR &&` and one command";
|
|
158
|
+
const last = runnerWords(parts.at(-1));
|
|
159
|
+
if (last[0] === "cd") return "it runs nothing after `cd`";
|
|
160
|
+
const loads = codeLoads(parts.at(-1));
|
|
161
|
+
if (loads.length) return `${loads.join(", ")} loads code before the tests`;
|
|
162
|
+
if (!named && !handed(last).length) return "it hands no test runner a test path";
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const GIT_VALUE_FLAGS = new Set(["-c", "-C", "--git-dir", "--work-tree", "--namespace"]);
|
|
167
|
+
/**
|
|
168
|
+
* What decides a command's exit status other than the command itself, or null (MW2-16): a pipe, `||`, `;`,
|
|
169
|
+
* a background `&`, a newline, `!`, `eval`, `trap`, a command substitution, a here-doc or here-string, or a
|
|
170
|
+
* chained commit or push. Dev refuses such a gate and ignores such a red run, so this tool refuses it first.
|
|
171
|
+
*/
|
|
172
|
+
export function maskedCommand(command, depth = 0) {
|
|
173
|
+
const text = String(command ?? "").trim();
|
|
174
|
+
let quote = null;
|
|
175
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
176
|
+
const char = text[i];
|
|
177
|
+
if (quote) { if (char === quote) quote = null; else if (quote === '"' && (char === "`" || text.startsWith("$(", i))) return char === "`" ? "`" : "$("; continue; }
|
|
178
|
+
if (char === "'" || char === '"') { quote = char; continue; }
|
|
179
|
+
const two = text.slice(i, i + 2);
|
|
180
|
+
if (two === "&&") { i += 1; continue; }
|
|
181
|
+
if (two === "||") return "||";
|
|
182
|
+
if (two === "$(") return "$(";
|
|
183
|
+
if (two === "<<") return "<<";
|
|
184
|
+
if (char === "`") return "`";
|
|
185
|
+
if (char === ";") return ";";
|
|
186
|
+
if (char === "\n") return "newline";
|
|
187
|
+
if (char === "|" && text[i - 1] !== ">") return "|";
|
|
188
|
+
if (char === "&" && text[i - 1] !== ">" && text[i + 1] !== ">") return "&";
|
|
189
|
+
}
|
|
190
|
+
for (const part of shellCommands(text)) {
|
|
191
|
+
const nested = shellScript(part);
|
|
192
|
+
if (nested !== null) { const inner = depth < 4 ? maskedCommand(nested, depth + 1) : null; if (inner) return inner; continue; }
|
|
193
|
+
const words = part.split(/\s+/);
|
|
194
|
+
if (words[0] === "!") return "!";
|
|
195
|
+
const [tool, ...args] = runnerWords(part);
|
|
196
|
+
const name = (tool ?? "").split("/").pop();
|
|
197
|
+
if (name === "trap") return "trap";
|
|
198
|
+
if (name === "eval") return "eval";
|
|
199
|
+
if (name === "git") {
|
|
200
|
+
const sub = args.find((word, i) => !word.startsWith("-") && !GIT_VALUE_FLAGS.has(args[i - 1] ?? ""));
|
|
201
|
+
if (sub === "commit" || sub === "push") return `git ${sub}`;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* What a gate ran green at the head, for Dev to match against the lane's red runs (agreed on the issue: paths read against the `cd`): the
|
|
209
|
+
* repo-relative files it ran. `nodii-dev test affected --run` works out its files before it runs, so they
|
|
210
|
+
* come from that analysis on the gate's own base, with each package it ran whole. A gate that filters tests
|
|
211
|
+
* by name, lists, shards or picks them, or loads code first, may have run none, so it names no file. Named checks are matched on Dev by the gate's exact
|
|
212
|
+
* command (governor pass: a check name from a local file would be the agent's own say-so).
|
|
213
|
+
*/
|
|
214
|
+
export async function greenFields(command, { exitCode, affectedTests } = {}) {
|
|
215
|
+
if (exitCode !== 0) return {};
|
|
216
|
+
if (coversNothing(command)) return {};
|
|
217
|
+
let files = runnerPaths(command);
|
|
218
|
+
if (selfSizedGate(command) && affectedTests) {
|
|
219
|
+
const words = String(command).trim().split(/\s+/);
|
|
220
|
+
const at = words.findIndex((word) => word === "--base" || word.startsWith("--base="));
|
|
221
|
+
const base = at === -1 ? undefined : words[at].includes("=") ? words[at].slice(7) : words[at + 1];
|
|
222
|
+
const result = await affectedTests(base).catch(() => null);
|
|
223
|
+
files = result ? [...new Set([...(result.tests ?? []), ...(result.jobs ?? []).filter((job) => job.full && job.dir).map((job) => job.dir)])] : [];
|
|
224
|
+
}
|
|
225
|
+
// Dev takes at most 500 files a run.
|
|
226
|
+
return files.length ? { files: files.slice(0, 500) } : {};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const usage = (message) => new CliError("USAGE", `${message}. ${LANE_TEST_USAGE}`, 2);
|
|
230
|
+
|
|
231
|
+
/** `lane test` reads its own words: `--check NAME` here is a value, where elsewhere `--check` is a switch. */
|
|
232
|
+
function parseLaneTest(argv) {
|
|
233
|
+
const boundary = argv.indexOf("--");
|
|
234
|
+
const options = boundary === -1 ? argv : argv.slice(0, boundary);
|
|
235
|
+
const command = boundary === -1 ? "" : argv.slice(boundary + 1).join(" ").trim();
|
|
236
|
+
const parsed = { key: null, red: false, checks: [], count: null, json: false };
|
|
237
|
+
for (let i = 0; i < options.length; i += 1) {
|
|
238
|
+
const word = options[i];
|
|
239
|
+
if (word === "--red") parsed.red = true;
|
|
240
|
+
else if (word === "--json") parsed.json = true;
|
|
241
|
+
else if (word === "--check" || word === "--count") {
|
|
242
|
+
const value = options[i + 1];
|
|
243
|
+
if (!value || value.startsWith("--")) throw usage(`${word} needs a value`);
|
|
244
|
+
if (word === "--check") parsed.checks.push(value); else parsed.count = value;
|
|
245
|
+
i += 1;
|
|
246
|
+
} else if (word.startsWith("-")) throw usage(`lane test does not take ${word}`);
|
|
247
|
+
else if (parsed.key === null) parsed.key = word;
|
|
248
|
+
else throw usage(`lane test takes one <key>, got ${word} too; put the command after \`--\``);
|
|
249
|
+
}
|
|
250
|
+
if (!parsed.key) throw usage("lane test needs <key>");
|
|
251
|
+
if (!parsed.red) throw usage("lane test needs --red: the green run is lane check's --gate");
|
|
252
|
+
if (!command) throw usage("lane test needs the command after `--`");
|
|
253
|
+
return { ...parsed, command };
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/** `nodii-dev lane test <key> --red [--check NAME] -- <command>`. */
|
|
257
|
+
export async function laneTestCommand(argv, deps = {}) {
|
|
258
|
+
const {
|
|
259
|
+
gitContext = inferGitContext, committed = worktreeCommitted, store: givenStore, writeReceipt = writeSignedReceipt,
|
|
260
|
+
evidenceBody = receiptEvidenceBody, request = devRequest, readPolicy = readRepoPolicy, queue = queuePending,
|
|
261
|
+
} = deps;
|
|
262
|
+
const { key, checks, count, command } = parseLaneTest(argv);
|
|
263
|
+
if (count !== null)
|
|
264
|
+
throw new CliError("RED_COUNT_NOT_BUILT", `${key}: --count is not built yet. Dev counts a red run only from a failing test receipt, and a count command exits 0, so how a count's red run is marked is still to be agreed with the hub on hub-485. Record the tests or a named check that fails (--check NAME) instead.`, 2);
|
|
265
|
+
const context = await gitContext();
|
|
266
|
+
const cwd = context.worktree;
|
|
267
|
+
if (!(await committed(cwd)))
|
|
268
|
+
throw new CliError("RED_RUN_DIRTY", `${key}: commit the red tests first. A red run names the commit it ran at, so Dev can tell it from the head that makes it green (MW2-20); this worktree has uncommitted or untracked changes.`, 2);
|
|
269
|
+
const fullScript = (await readPolicy(cwd).catch(() => null))?.tests?.full ?? "test";
|
|
270
|
+
if (fullSuiteGate(command, fullScript))
|
|
271
|
+
throw new CliError("GATE_FULL_SUITE", `${key}: \`${command}\` runs the whole test suite, which would declare every test as this change's (MW2-20). Name the test files for this change.`, 2, { command });
|
|
272
|
+
const masked = maskedCommand(command);
|
|
273
|
+
if (masked)
|
|
274
|
+
throw new CliError("GATE_EXIT_MASKED", `${key}: in \`${command}\`, ${masked} decides the exit status, not the tests (MW2-16), so Dev would not count it as red. Run the tests on their own.`, 2, { command, masked });
|
|
275
|
+
const shape = notOneRunner(command, { named: checks.length > 0 });
|
|
276
|
+
if (shape)
|
|
277
|
+
throw new CliError("RED_RUN_NOT_ONE_RUNNER", `${key}: \`${command}\` is not one test run of its own: ${shape}. A red run is at most \`cd DIR &&\` and then the tests, so only they decide that it fails (MW2-20).`, 2, { command });
|
|
278
|
+
const { paths: files, outside } = runnerScan(command);
|
|
279
|
+
if (outside)
|
|
280
|
+
throw new CliError("RED_RUN_PATH_OUTSIDE", `${key}: \`${command}\` runs from or names a path outside this repository, or one this tool cannot place (\`/\`, \`~\`, \`..\`, a variable). Dev reads red files relative to the repository root; run from the root or \`cd\` into a directory below it.`, 2, { command });
|
|
281
|
+
if (checks.length && redactCommand(command) !== command)
|
|
282
|
+
throw new CliError("RED_CHECK_COMMAND_REDACTED", `${key}: Dev matches a named check by its exact command, and \`${command}\` would be stored redacted (it carries a NAME=value, a --flag=value or a secret-shaped word), so no gate could ever match it. Move the value into the environment or a file the command reads.`, 2);
|
|
283
|
+
if (!files.length && !checks.length)
|
|
284
|
+
throw new CliError("RED_RUN_EMPTY", `${key}: \`${command}\` hands a test runner no test file or directory, so it declares nothing. Name the test files (node --test test/a.test.js), or pass --check NAME for work with no behaviour to test.`, 2, { command });
|
|
285
|
+
const details = { red: true, authPosture: "component", scope: { files, testCount: null, checks } };
|
|
286
|
+
const { receipt, path, failed } = await writeReceipt({ kind: "test", lane: key, run: command, details }, { cwd });
|
|
287
|
+
if (!failed)
|
|
288
|
+
throw new CliError("RED_RUN_PASSED", `${key}: \`${command}\` passed at ${receipt.commit ?? "this commit"}, so it is not red and nothing was attached. Write the test first, commit it, and record it failing before the change (MW2-20).`, 1);
|
|
289
|
+
const body = await evidenceBody(path, key);
|
|
290
|
+
const url = `/api/v1/lanes/${encode(key)}/evidence`;
|
|
291
|
+
let queued = null;
|
|
292
|
+
try {
|
|
293
|
+
await request("POST", url, body);
|
|
294
|
+
} catch (error) {
|
|
295
|
+
if (!devDown(error)) throw error;
|
|
296
|
+
queued = await queue(url, body, { lane: key });
|
|
297
|
+
}
|
|
298
|
+
const store = givenStore ?? privateStore(cwd);
|
|
299
|
+
const kept = (await store.read(RED_RUNS).catch(() => null)) ?? {};
|
|
300
|
+
await store.write(RED_RUNS, { ...kept, [key]: [...(kept[key] ?? []), { commit: receipt.commit, command, files, checks }] });
|
|
301
|
+
const named = [...files, ...checks.map((check) => `check ${check}`)].join(", ");
|
|
302
|
+
return {
|
|
303
|
+
payload: { data: { red: true, commit: receipt.commit, files, checks, receipt: path, ...(queued ? { queued } : {}) } },
|
|
304
|
+
human: `${key}: red at ${receipt.commit}: ${named}.${queued ? ` Dev is unreachable; the receipt waits at ${queued} for nodii-dev sync pending (MW1-64).` : " Recorded on Dev."} Make them green and pass them as lane check gates.`,
|
|
305
|
+
exitCode: 0,
|
|
306
|
+
};
|
|
307
|
+
}
|
package/dist/review.js
CHANGED
|
@@ -15,7 +15,8 @@ import { componentSetsIn, designCatalogSets } from "./figma-scope.js";
|
|
|
15
15
|
import { holdsSet, scopeText } from "./figma.js";
|
|
16
16
|
import { gitPrivatePath } from "./safety.js";
|
|
17
17
|
import { GENERATED_PAGE_GLOB, GENERATED_SUFFIX, hasGeneratedPageStamp } from "./surface.js";
|
|
18
|
-
import { VALUE_FLAGS } from "./impact.js";
|
|
18
|
+
import { VALUE_FLAGS, affected } from "./impact.js";
|
|
19
|
+
import { greenFields } from "./red-run.js";
|
|
19
20
|
import { heavySlotArgv } from "./heavy.js";
|
|
20
21
|
|
|
21
22
|
const execFileAsync = promisify(execFile);
|
|
@@ -119,22 +120,7 @@ export function fullSuiteGate(command, fullScript = "test") {
|
|
|
119
120
|
for (const part of shellCommands(text)) {
|
|
120
121
|
const nested = shellScript(part);
|
|
121
122
|
if (nested !== null) { if (fullSuiteGate(nested, fullScript)) return true; continue; }
|
|
122
|
-
|
|
123
|
-
// `npx vitest`, `bunx jest`, `pnpm exec vitest run`, `python -m pytest`: the tool they start.
|
|
124
|
-
for (;;) {
|
|
125
|
-
const first = (words[0] ?? "").split("/").pop();
|
|
126
|
-
if (["npx", "bunx", "pnpx"].includes(first)) words = words.slice(1).filter((word, i) => i > 0 || !word.startsWith("-"));
|
|
127
|
-
else if (["npm", "pnpm", "yarn"].includes(first) && ["exec", "dlx"].includes(words.find((word, i) => i > 0 && !word.startsWith("-")))) words = words.slice(words.findIndex((word) => ["exec", "dlx"].includes(word)) + 1);
|
|
128
|
-
else if (/^python[0-9.]*$/.test(first) && words[1] === "-m") words = words.slice(2);
|
|
129
|
-
// `env CI=1 npm test`, `timeout 600 npm test`, `nice -n 10 jest`: the command they wrap.
|
|
130
|
-
else if (["env", "time", "nohup", "exec"].includes(first)) words = words.slice(1);
|
|
131
|
-
// `nodii-dev heavy run -- CMD`: the queue runs CMD.
|
|
132
|
-
else if (/^nodii-dev(?:\.js)?$/.test(first) && words[1] === "heavy" && words[2] === "run") words = words.slice(words.includes("--") ? words.indexOf("--") + 1 : 3);
|
|
133
|
-
else if (first === "timeout") { words = words.slice(1); while (words[0]?.startsWith("-")) words = words.slice(1); words = words.slice(1); }
|
|
134
|
-
else if (first === "nice") { words = words.slice(1); if (words[0] === "-n") words = words.slice(2); }
|
|
135
|
-
else break;
|
|
136
|
-
while (words[0]?.startsWith("-")) words = words.slice(1);
|
|
137
|
-
}
|
|
123
|
+
const words = runnerWords(part);
|
|
138
124
|
const [tool, ...args] = words;
|
|
139
125
|
const name = (tool ?? "").split("/").pop();
|
|
140
126
|
// A package manager's `-r` is --recursive, not node's --require: it takes no value.
|
|
@@ -160,11 +146,32 @@ export function fullSuiteGate(command, fullScript = "test") {
|
|
|
160
146
|
return false;
|
|
161
147
|
}
|
|
162
148
|
|
|
149
|
+
/** The words of one simple command, from the tool it starts: `npx vitest`, `env CI=1 npm test`, `nodii-dev heavy run -- CMD`. */
|
|
150
|
+
export function runnerWords(part) {
|
|
151
|
+
let words = part.split(/\s+/).map((word) => word.replace(/^['"]+|['"]+$/g, "")).filter((word) => word && !/^[A-Z_][A-Z0-9_]*=/.test(word) && !/^(?:[0-9]?>|\|)/.test(word));
|
|
152
|
+
// `npx vitest`, `bunx jest`, `pnpm exec vitest run`, `python -m pytest`: the tool they start.
|
|
153
|
+
for (;;) {
|
|
154
|
+
const first = (words[0] ?? "").split("/").pop();
|
|
155
|
+
if (["npx", "bunx", "pnpx"].includes(first)) words = words.slice(1).filter((word, i) => i > 0 || !word.startsWith("-"));
|
|
156
|
+
else if (["npm", "pnpm", "yarn"].includes(first) && ["exec", "dlx"].includes(words.find((word, i) => i > 0 && !word.startsWith("-")))) words = words.slice(words.findIndex((word) => ["exec", "dlx"].includes(word)) + 1);
|
|
157
|
+
else if (/^python[0-9.]*$/.test(first) && words[1] === "-m") words = words.slice(2);
|
|
158
|
+
// `env CI=1 npm test`, `timeout 600 npm test`, `nice -n 10 jest`: the command they wrap.
|
|
159
|
+
else if (["env", "time", "nohup", "exec"].includes(first)) words = words.slice(1);
|
|
160
|
+
// `nodii-dev heavy run -- CMD`: the queue runs CMD.
|
|
161
|
+
else if (/^nodii-dev(?:\.js)?$/.test(first) && words[1] === "heavy" && words[2] === "run") words = words.slice(words.includes("--") ? words.indexOf("--") + 1 : 3);
|
|
162
|
+
else if (first === "timeout") { words = words.slice(1); while (words[0]?.startsWith("-")) words = words.slice(1); words = words.slice(1); }
|
|
163
|
+
else if (first === "nice") { words = words.slice(1); if (words[0] === "-n") words = words.slice(2); }
|
|
164
|
+
else break;
|
|
165
|
+
while (words[0]?.startsWith("-")) words = words.slice(1);
|
|
166
|
+
}
|
|
167
|
+
return words;
|
|
168
|
+
}
|
|
169
|
+
|
|
163
170
|
/**
|
|
164
171
|
* The simple commands of a shell line: split on `&&`, `||`, `;` and `|` outside quotes, so
|
|
165
172
|
* `sh -c 'a && b' && sh -c 'npm test'` is two commands, each with its own script.
|
|
166
173
|
*/
|
|
167
|
-
function shellCommands(text) {
|
|
174
|
+
export function shellCommands(text) {
|
|
168
175
|
const parts = [];
|
|
169
176
|
let current = "";
|
|
170
177
|
let quote = null;
|
|
@@ -185,13 +192,13 @@ function shellCommands(text) {
|
|
|
185
192
|
// jest's and vitest's own changed-files modes already run only the tests a change reaches.
|
|
186
193
|
const CHANGED_FLAGS = new Set(["--onlyChanged", "-o", "--changedSince", "--findRelatedTests", "--changed", "--related"]);
|
|
187
194
|
// `sh -c 'npm test'`, `bash -lc "…"`: the script the shell runs, or null.
|
|
188
|
-
const shellScript = (text) => text.match(/^(?:\S*\/)?(?:ba|z|da)?sh\s+-[a-z]*c[a-z]*\s+(['"])([\s\S]*)\1$/)?.[2] ?? null;
|
|
195
|
+
export const shellScript = (text) => text.match(/^(?:\S*\/)?(?:ba|z|da)?sh\s+-[a-z]*c[a-z]*\s+(['"])([\s\S]*)\1$/)?.[2] ?? null;
|
|
189
196
|
// A package manager's own flags that take a value: the workspace, filter or directory it runs in.
|
|
190
197
|
const SCOPE_FLAGS = new Set(["--workspace", "-w", "--filter", "-F", "--dir", "-C", "--prefix", "--cwd"]);
|
|
191
198
|
// jest's --selectProjects takes every word after it, up to the next flag.
|
|
192
199
|
const VARIADIC_FLAGS = new Set(["--selectProjects"]);
|
|
193
200
|
/** Operands: not a flag, and not the value of one (`--timeout 30000`, `--config ./jest.config.mjs`, `--filter web`). */
|
|
194
|
-
function operandsOf(args, { pm = false } = {}) {
|
|
201
|
+
export function operandsOf(args, { pm = false } = {}) {
|
|
195
202
|
const operands = [];
|
|
196
203
|
let variadic = false;
|
|
197
204
|
for (const [i, word] of args.entries()) {
|
|
@@ -226,14 +233,15 @@ export const diffDigest = (text) => createHash("sha256").update(text).digest("he
|
|
|
226
233
|
* writes the receipt; without --gate only a receipt for this head, base and
|
|
227
234
|
* diff counts. Returns the diff the receipt covers, which is the one reviewed.
|
|
228
235
|
*/
|
|
229
|
-
export async function gatesReceipt(commands, { cwd, current, store, diff, run = runGate, now = () => new Date().toISOString(), fullSuite = false }) {
|
|
236
|
+
export async function gatesReceipt(commands, { cwd, current, store, diff, run = runGate, now = () => new Date().toISOString(), fullSuite = false, affectedTests = (base) => affected(cwd, base ? { base } : {}) }) {
|
|
230
237
|
const changed = await diff(cwd);
|
|
231
238
|
const digest = diffDigest(changed.text);
|
|
232
239
|
if (commands.length) {
|
|
233
240
|
const runs = [];
|
|
234
241
|
for (const command of commands) {
|
|
235
242
|
const { code, tail } = await run(command, cwd);
|
|
236
|
-
|
|
243
|
+
// hub-485, red runs: what the gate ran green, for Dev to match against the lane's red runs.
|
|
244
|
+
runs.push({ command, exitCode: code, ...(await greenFields(command, { exitCode: code, affectedTests })) });
|
|
237
245
|
if (code !== 0)
|
|
238
246
|
throw new CliError("GATES_NOT_GREEN", `Gate \`${command}\` exited ${code}; nothing was reviewed or recorded. Make it green and rerun lane check.${tail ? `\n${tail.trimEnd().split("\n").slice(-20).join("\n")}` : ""}`, 1, { command, exitCode: code });
|
|
239
247
|
}
|
|
@@ -257,7 +265,8 @@ export async function gatesReceipt(commands, { cwd, current, store, diff, run =
|
|
|
257
265
|
export function reviewGates(receipt) {
|
|
258
266
|
if (!receipt || !Array.isArray(receipt.runs ?? receipt.commands)) return null;
|
|
259
267
|
const runs = receipt.runs ?? receipt.commands.map((command) => ({ command, exitCode: 0 }));
|
|
260
|
-
|
|
268
|
+
// hub-485, red runs: the files a run made green go with it, when it names any.
|
|
269
|
+
return { base: receipt.base, diff: receipt.diff, runs: runs.map(({ command, exitCode, files }) => ({ command, exitCode, commit: receipt.commit, ...(files?.length ? { files } : {}) })) };
|
|
261
270
|
}
|
|
262
271
|
|
|
263
272
|
/**
|
package/dist/surface.js
CHANGED
|
@@ -32,7 +32,7 @@ import { CliError, VERSION, devRequest, readConfig } from "./core.js";
|
|
|
32
32
|
import { createRenderer } from "./vendor/render-templates.mjs";
|
|
33
33
|
|
|
34
34
|
/** Bumped whenever the emitted code changes shape for the same inputs. */
|
|
35
|
-
export const GENERATOR_FORMAT =
|
|
35
|
+
export const GENERATOR_FORMAT = 36;
|
|
36
36
|
export const TREE_DIR = "docs/figma-ux-ds/figma/surface-trees";
|
|
37
37
|
export const GENERATED_SUFFIX = ".surface.generated.tsx";
|
|
38
38
|
/** Where every generated product page lives, as a git glob (NODII-DEV-CLI-77). */
|
|
@@ -1942,7 +1942,14 @@ function dataProps(views, propsType) {
|
|
|
1942
1942
|
if (list) {
|
|
1943
1943
|
const field = member(entry(list), m[2]);
|
|
1944
1944
|
const nullable = / == null \? \("(?:[^"\\]|\\.)*"\) : \((?:<div\b[^>]*>\s*)*$/.test(body.slice(0, m.index)) || field.get("\u0000pii")?.raw.endsWith(" | null");
|
|
1945
|
-
|
|
1945
|
+
const ref = `${m[1]}.${m[2]}`;
|
|
1946
|
+
const mixed = mixedPiiExpressions(body).find(expression => m.index >= expression.at && m.index < expression.end)?.expression;
|
|
1947
|
+
const alternatives = mixed ? [
|
|
1948
|
+
`{ kind: "person" } & ${PII_ROW_FIELD}`,
|
|
1949
|
+
...(mixed.includes(`${ref}.kind === "text"`) ? ['{ kind: "text"; text: string }'] : []),
|
|
1950
|
+
...(mixed.includes(`${ref}.kind === "badge"`) ? ['{ kind: "badge"; text: string }'] : []),
|
|
1951
|
+
].join(" | ") : null;
|
|
1952
|
+
field.set("\u0000pii", { raw: alternatives ?? PII_ROW_FIELD + (nullable ? " | null" : "") });
|
|
1946
1953
|
}
|
|
1947
1954
|
}
|
|
1948
1955
|
for (const m of body.matchAll(/(^|>)\s*\{([a-z][A-Za-z0-9]*)\}/gm)) {
|
|
@@ -2041,9 +2048,9 @@ function drawnRef({ tag, attr, keys, literals, raw }) {
|
|
|
2041
2048
|
/** The type the generated file declares for drawnProps (see there). */
|
|
2042
2049
|
const DRAWN_TYPE = [
|
|
2043
2050
|
"/** A DS component's props, narrowed to the member of their union this call draws: every required prop passed, every literal one fitting. */",
|
|
2044
|
-
"type Drawn<P, K extends PropertyKey, L =
|
|
2051
|
+
"type Drawn<P, K extends PropertyKey, L = Record<never, never>> = [DrawnOf<P, K, L>] extends [never] ? P : DrawnOf<P, K, L>;",
|
|
2045
2052
|
"type DrawnOf<P, K extends PropertyKey, L> = P extends unknown",
|
|
2046
|
-
" ? [Exclude<{ [k in keyof P]-?:
|
|
2053
|
+
" ? [Exclude<{ [k in keyof P]-?: Record<never, never> extends Pick<P, k> ? never : k }[keyof P], K>] extends [never]",
|
|
2047
2054
|
" ? [{ [k in keyof L]: k extends keyof P ? (L[k] extends P[k] ? never : k) : never }[keyof L]] extends [never]",
|
|
2048
2055
|
" ? P",
|
|
2049
2056
|
" : never",
|
|
@@ -2059,6 +2066,7 @@ const DRAWN_TYPE = [
|
|
|
2059
2066
|
function tagAttributes(body, at) {
|
|
2060
2067
|
const names = [];
|
|
2061
2068
|
const literals = new Map();
|
|
2069
|
+
const values = new Map();
|
|
2062
2070
|
let i = at;
|
|
2063
2071
|
const skipString = (q) => {
|
|
2064
2072
|
for (i++; i < body.length && body[i] !== q; i++) if (body[i] === "\\") i++;
|
|
@@ -2079,8 +2087,8 @@ function tagAttributes(body, at) {
|
|
|
2079
2087
|
};
|
|
2080
2088
|
while (i < body.length) {
|
|
2081
2089
|
while (/\s/.test(body[i] ?? "")) i++;
|
|
2082
|
-
if (body.startsWith("/>", i)) return { names, literals, selfClosing: true };
|
|
2083
|
-
if (body[i] === ">") return { names, literals, selfClosing: false };
|
|
2090
|
+
if (body.startsWith("/>", i)) return { names, literals, values, end: i + 2, selfClosing: true };
|
|
2091
|
+
if (body[i] === ">") return { names, literals, values, selfClosing: false };
|
|
2084
2092
|
if (body[i] === "{") return null;
|
|
2085
2093
|
const name = /^[A-Za-z_][\w:-]*/.exec(body.slice(i))?.[0];
|
|
2086
2094
|
if (!name) return null;
|
|
@@ -2088,6 +2096,7 @@ function tagAttributes(body, at) {
|
|
|
2088
2096
|
i += name.length;
|
|
2089
2097
|
if (body[i] !== "=") {
|
|
2090
2098
|
literals.set(name, "true");
|
|
2099
|
+
values.set(name, "true");
|
|
2091
2100
|
continue;
|
|
2092
2101
|
}
|
|
2093
2102
|
i++;
|
|
@@ -2095,12 +2104,27 @@ function tagAttributes(body, at) {
|
|
|
2095
2104
|
const from = i;
|
|
2096
2105
|
skipString(body[i]);
|
|
2097
2106
|
literals.set(name, JSON.stringify(body.slice(from + 1, i - 1)));
|
|
2107
|
+
// JSX quoted attributes decode entities; object-property strings do not.
|
|
2108
|
+
const quoted = body.slice(from + 1, i - 1);
|
|
2109
|
+
let unsupportedEntity = false;
|
|
2110
|
+
const decoded = quoted.replace(/&(#x[0-9a-f]+|#\d+|[a-z][a-z0-9]+);/gi, (entity, key) => {
|
|
2111
|
+
const named = { amp: "&", quot: '"', apos: "'", lt: "<", gt: ">", nbsp: "\u00a0" };
|
|
2112
|
+
if (Object.hasOwn(named, key)) return named[key];
|
|
2113
|
+
const point = key.startsWith("#x") ? Number.parseInt(key.slice(2), 16) : key.startsWith("#") ? Number(key.slice(1)) : NaN;
|
|
2114
|
+
if (Number.isInteger(point) && point > 0 && point <= 0x10ffff && !(point >= 0xd800 && point <= 0xdfff)) return String.fromCodePoint(point);
|
|
2115
|
+
unsupportedEntity = true;
|
|
2116
|
+
return entity;
|
|
2117
|
+
});
|
|
2118
|
+
if (unsupportedEntity) literals.delete(name);
|
|
2119
|
+
else literals.set(name, JSON.stringify(decoded));
|
|
2120
|
+
values.set(name, unsupportedEntity ? null : JSON.stringify(decoded));
|
|
2098
2121
|
continue;
|
|
2099
2122
|
}
|
|
2100
2123
|
if (body[i] !== "{") return null;
|
|
2101
2124
|
const inner = braced();
|
|
2102
2125
|
if (inner === null) return null;
|
|
2103
2126
|
const value = inner.trim();
|
|
2127
|
+
values.set(name, value);
|
|
2104
2128
|
if (/^(true|false|-?\d+(\.\d+)?|"(?:[^"\\\n]|\\.)*")$/.test(value)) literals.set(name, value);
|
|
2105
2129
|
}
|
|
2106
2130
|
return null;
|
|
@@ -2325,21 +2349,40 @@ function emitNode(node, ctx) {
|
|
|
2325
2349
|
const sizing = ctx.bare || node.instance.set === "Detail Section / Row" ? [] : sizeClasses(node, parent, false);
|
|
2326
2350
|
// A data slot passed straight to a prop is that prop (`trailing={<>{trailing}</>}` → `trailing={trailing}`).
|
|
2327
2351
|
let own = rendered.code.trim().replace(/=\{<>\{([a-z][A-Za-z0-9]*)\}<\/>\}/g, "={$1}");
|
|
2328
|
-
// The toolbar
|
|
2329
|
-
// Preserve
|
|
2330
|
-
if (node.instance.set === "Data Table Toolbar" && /^<DataTableToolbarBlock\b/.test(own)
|
|
2352
|
+
// The toolbar owns table rendering, so its template does not emit this slot.
|
|
2353
|
+
// Preserve its drawn failure or zero-row composition through the supported props.
|
|
2354
|
+
if (node.instance.set === "Data Table Toolbar" && /^<DataTableToolbarBlock\b/.test(own)) {
|
|
2331
2355
|
const tableSlot = (node.children ?? []).find(c => c.type === "SLOT" && c.slot === "table" && c.visible !== false);
|
|
2332
|
-
const
|
|
2356
|
+
const states = [];
|
|
2333
2357
|
const collect = (current) => {
|
|
2334
2358
|
if (current.visible === false) return;
|
|
2335
|
-
if (current.instance?.remote &&
|
|
2359
|
+
if (current.instance?.remote && ["Error State Page", "Empty State"].includes(current.instance.set)) states.push(current);
|
|
2336
2360
|
else for (const child of current.children ?? []) collect(child);
|
|
2337
2361
|
};
|
|
2338
2362
|
if (tableSlot) collect(tableSlot);
|
|
2339
|
-
if (
|
|
2340
|
-
const
|
|
2341
|
-
|
|
2342
|
-
|
|
2363
|
+
if (tableSlot && /\bcolumns=\{(?:__s\d+_)?columns\}/.test(own)) {
|
|
2364
|
+
const containsTable = (current) => current.visible !== false && (
|
|
2365
|
+
(current.instance?.remote && ["Table", "Table Rich Cell"].includes(current.instance.set)) ||
|
|
2366
|
+
(current.children ?? []).some(containsTable)
|
|
2367
|
+
);
|
|
2368
|
+
if (containsTable(tableSlot)) note(`${path} › table`, "table", "drawn toolbar columns remain caller-owned: column labels, presentation and person-cell contracts are not generated");
|
|
2369
|
+
}
|
|
2370
|
+
if (states.length === 1) {
|
|
2371
|
+
const error = states[0].instance.set === "Error State Page" || /(?:^|-)error(?:$|-)/.test(ctx.state ?? "");
|
|
2372
|
+
const prop = error ? "errorState" : "emptyState";
|
|
2373
|
+
if (!new RegExp(`\\b${prop}=`).test(own)) {
|
|
2374
|
+
const code = emitNode(states[0], { ...ctx, depth: 0, parent: tableSlot, grand: node, path: `${path} › table`, root: false, bare: true, inTable: false, inSlot: true, chain: [...chain, tableSlot] });
|
|
2375
|
+
if (error && code) own = own.replace(/^<DataTableToolbarBlock\b/, `<DataTableToolbarBlock errorState={${code}}`);
|
|
2376
|
+
else if (code?.startsWith("<EmptyState")) {
|
|
2377
|
+
const parsed = tagAttributes(code, "<EmptyState".length);
|
|
2378
|
+
const allowed = new Set(["title", "description", "actionLabel", "onAction", "actionDisabled", "actionDisabledReason", "illustration", "secondaryAction"]);
|
|
2379
|
+
if (parsed?.selfClosing && !code.slice(parsed.end).trim() && parsed.names.every(name => allowed.has(name) && parsed.values.get(name) !== null)) {
|
|
2380
|
+
const props = [...parsed.values].map(([name, value]) => `${name}: ${value}`).join(", ");
|
|
2381
|
+
own = own.replace(/^<DataTableToolbarBlock\b/, `<DataTableToolbarBlock emptyState={{ ${props} }}`);
|
|
2382
|
+
} else note(`${path} › table`, "slot", "drawn Empty State has props outside the toolbar emptyState contract");
|
|
2383
|
+
} else note(`${path} › table`, "slot", "drawn Empty State cannot be mapped to the toolbar emptyState contract");
|
|
2384
|
+
}
|
|
2385
|
+
} else if (states.length > 1) note(`${path} › table`, "slot", "multiple empty/error instances in one toolbar table slot: choose one state");
|
|
2343
2386
|
}
|
|
2344
2387
|
// A tab strip the page controls (tabOf reads the template's own strip first, to gather a run).
|
|
2345
2388
|
if (!ctx.tabProbe) own = own.replace(/<Tabs panelless(?: defaultValue="[^"]*")?>/g, CONTROLLED_TABS("tab", "onTabChange"));
|
|
@@ -2621,6 +2664,18 @@ const PII_ROW_READ = /<PiiText value=\{([a-z][A-Za-z0-9]*)\.([A-Za-z][A-Za-z0-9]
|
|
|
2621
2664
|
* placeholder, so both are `column1`) cannot share a safe contract. Report a mapping
|
|
2622
2665
|
* failure in every affected column instead of discarding its PiiText protection.
|
|
2623
2666
|
*/
|
|
2667
|
+
function mixedPiiExpressions(body) {
|
|
2668
|
+
const flat = maskStrings(body);
|
|
2669
|
+
return [...body.matchAll(/\{([a-z][A-Za-z0-9]*)\.([A-Za-z][A-Za-z0-9]*)\.kind === "person" \? \(/g)].map(match => {
|
|
2670
|
+
let depth = 0, end = match.index;
|
|
2671
|
+
for (; end < flat.length; end++) {
|
|
2672
|
+
if (flat[end] === "{") depth++;
|
|
2673
|
+
if (flat[end] === "}" && --depth === 0) break;
|
|
2674
|
+
}
|
|
2675
|
+
return { at: match.index, end: end + 1, param: match[1], key: match[2], expression: body.slice(match.index, end + 1) };
|
|
2676
|
+
});
|
|
2677
|
+
}
|
|
2678
|
+
|
|
2624
2679
|
function settlePiiColumns(views, unmapped) {
|
|
2625
2680
|
const NODE_READ = /(^|>)\s*\{([a-z][A-Za-z0-9]*)\.([A-Za-z][A-Za-z0-9]*)\}/gm;
|
|
2626
2681
|
const PII_CELL = />\n[ \t]*(?:<div\b[^>]*>\s*)*<PiiText value=\{([a-z][A-Za-z0-9]*)\.([A-Za-z][A-Za-z0-9]*)\.value\} kind="[^\n]*\/>\s*(?:<\/div>\s*)*<\/TableCell>/g;
|
|
@@ -2642,7 +2697,56 @@ function settlePiiColumns(views, unmapped) {
|
|
|
2642
2697
|
}
|
|
2643
2698
|
for (const m of view.body.matchAll(NODE_READ)) count(view, openers, m.index, m[2], m[3], "node");
|
|
2644
2699
|
}
|
|
2645
|
-
|
|
2700
|
+
// A mixed cell declares its supported alternatives explicitly. Reuse that contract
|
|
2701
|
+
// in views which happen to draw only people or only the plain alternative.
|
|
2702
|
+
for (const view of views) {
|
|
2703
|
+
const openers = listOpeners(view.body);
|
|
2704
|
+
for (const m of mixedPiiExpressions(view.body)) {
|
|
2705
|
+
const r = reads.get(`${listAt(openers, m.at, m.param)}.${m.key}`);
|
|
2706
|
+
if (r) {
|
|
2707
|
+
const { expression } = m;
|
|
2708
|
+
const branches = expression.slice(1, -' : null}'.length).split(/ : (?=[a-z][A-Za-z0-9]*\.[A-Za-z][A-Za-z0-9]*\.kind === ")/);
|
|
2709
|
+
r.alternatives ??= new Map();
|
|
2710
|
+
for (const branch of branches) {
|
|
2711
|
+
const kind = /\.kind === "([^"]+)"/.exec(branch)?.[1];
|
|
2712
|
+
if (r.alternatives.has(kind) && r.alternatives.get(kind) !== branch) r.conflictingMixed = true;
|
|
2713
|
+
r.alternatives.set(kind, branch);
|
|
2714
|
+
}
|
|
2715
|
+
r.mixed = `{${[...r.alternatives.values()].join(" : ")} : null}`;
|
|
2716
|
+
}
|
|
2717
|
+
}
|
|
2718
|
+
}
|
|
2719
|
+
for (const view of views) {
|
|
2720
|
+
const openers = listOpeners(view.body);
|
|
2721
|
+
const replacements = [];
|
|
2722
|
+
for (const m of mixedPiiExpressions(view.body)) {
|
|
2723
|
+
const r = reads.get(`${listAt(openers, m.at, m.param)}.${m.key}`);
|
|
2724
|
+
if (r) replacements.push([m.at, m.end, r.conflictingMixed ? comment(`unmapped: incompatible mixed cell ${r.key}`) : r.mixed]);
|
|
2725
|
+
}
|
|
2726
|
+
for (const [start, end, replacement] of replacements.reverse()) view.body = view.body.slice(0, start) + replacement + view.body.slice(end);
|
|
2727
|
+
}
|
|
2728
|
+
for (const r of reads.values()) if (r.conflictingMixed) {
|
|
2729
|
+
unmapped.push({ variant: r.variant, path: r.list, kind: "table", detail: `column ${r.key} has incompatible mixed-cell templates across views` });
|
|
2730
|
+
r.mixed = comment(`unmapped: incompatible mixed cell ${r.key}`);
|
|
2731
|
+
}
|
|
2732
|
+
const mixed = new Map([...reads].filter(([, r]) => r.pii && r.node && !r.mixed));
|
|
2733
|
+
for (const view of views) {
|
|
2734
|
+
const openers = listOpeners(view.body);
|
|
2735
|
+
view.body = view.body.replace(PII_CELL, (all, param, key, at) => {
|
|
2736
|
+
const r = reads.get(`${listAt(openers, at, param)}.${key}`);
|
|
2737
|
+
return r?.mixed ? `>\n ${r.mixed}\n</TableCell>` : all;
|
|
2738
|
+
});
|
|
2739
|
+
const nullableOpeners = listOpeners(view.body);
|
|
2740
|
+
view.body = view.body.replace(/>\n[ \t]*\{([a-z][A-Za-z0-9]*)\.([A-Za-z][A-Za-z0-9]*) == null \? \("(?:[^"\\]|\\.)*"\) : \((?:<div\b[^>]*>\s*)*<PiiText[^\n]*\/>\s*(?:<\/div>\s*)*\)\}\n[ \t]*<\/TableCell>/g, (all, param, key, at) => {
|
|
2741
|
+
const r = reads.get(`${listAt(nullableOpeners, at, param)}.${key}`);
|
|
2742
|
+
return r?.mixed ? `>\n ${r.mixed}\n</TableCell>` : all;
|
|
2743
|
+
});
|
|
2744
|
+
const plainOpeners = listOpeners(view.body);
|
|
2745
|
+
view.body = view.body.replace(NODE_READ, (all, open, param, key, at) => {
|
|
2746
|
+
const r = reads.get(`${listAt(plainOpeners, at, param)}.${key}`);
|
|
2747
|
+
return r?.mixed ? `${open}${r.mixed}` : all;
|
|
2748
|
+
});
|
|
2749
|
+
}
|
|
2646
2750
|
// All views share the row type. Once nullable, every view must guard its read.
|
|
2647
2751
|
for (const view of views) {
|
|
2648
2752
|
const openers = listOpeners(view.body);
|
|
@@ -2726,6 +2830,23 @@ function piiCellText({ cell, code }, ref) {
|
|
|
2726
2830
|
return `${before}<PiiText value={${ref}.value} kind="${kind}" model={${ref}.model} relation={${ref}.relation} maskHint={${ref}.maskHint} surface="bulk"${size} />${after}`;
|
|
2727
2831
|
}
|
|
2728
2832
|
|
|
2833
|
+
/** A non-person alternative must be plain text or a plain Badge, never arbitrary JSX. */
|
|
2834
|
+
function plainPiiAlternative(part) {
|
|
2835
|
+
if (part.held || !/^<TableCell\b/.test(part.code ?? "")) return null;
|
|
2836
|
+
const inner = part.code.slice(openTagEnd(part.code) + 1).replace(/<\/TableCell>$/, "").trim();
|
|
2837
|
+
if (/^\{("(?:[^"\\]|\\.)*")\}$/.test(inner)) return { kind: "text" };
|
|
2838
|
+
const badge = /^<Badge([^<>]*)>(?:\{("(?:[^"\\]|\\.)*")\}|([^<>{}]*))<\/Badge>$/.exec(inner);
|
|
2839
|
+
if (!badge || /[{}]/.test(badge[1])) return null;
|
|
2840
|
+
return { kind: "badge", template: `<Badge${badge[1]}>{__plainCellText__}</Badge>` };
|
|
2841
|
+
}
|
|
2842
|
+
|
|
2843
|
+
function mixedPiiText(mixed, ref) {
|
|
2844
|
+
const branches = [`${ref}.kind === "person" ? (${piiCellText(mixed.sample, ref)})`];
|
|
2845
|
+
if (mixed.text) branches.push(`${ref}.kind === "text" ? (<>{${ref}.text}</>)`);
|
|
2846
|
+
if (mixed.badge) branches.push(`${ref}.kind === "badge" ? (${mixed.badge.replace("__plainCellText__", `${ref}.text`)})`);
|
|
2847
|
+
return `{${branches.join(" : ")} : null}`;
|
|
2848
|
+
}
|
|
2849
|
+
|
|
2729
2850
|
/** Only a plain literal empty cell is compatible with a nullable person. */
|
|
2730
2851
|
function emptyPiiCell(part) {
|
|
2731
2852
|
if (part.held || !/^<TableCell\b/.test(part.code ?? "")) return null;
|
|
@@ -2874,6 +2995,13 @@ function treeTableOf(node, ctx) {
|
|
|
2874
2995
|
].join("\n"), ctx.depth);
|
|
2875
2996
|
}
|
|
2876
2997
|
|
|
2998
|
+
// The cell template uses a row wrapper to demonstrate Selected in isolation.
|
|
2999
|
+
// Assembly owns that row; lift its selection state once for the whole record.
|
|
3000
|
+
function selectedCell(code) {
|
|
3001
|
+
const match = /^<TableRow selected>\s*([\s\S]*?)\s*<\/TableRow>$/.exec(code?.trim() ?? "");
|
|
3002
|
+
return match && /^<Table(?:Cell|RowActions|SelectionCell)\b/.test(match[1]) ? match[1] : null;
|
|
3003
|
+
}
|
|
3004
|
+
|
|
2877
3005
|
function tableOf(node, ctx) {
|
|
2878
3006
|
const shown = (node.children ?? []).filter((c) => c.visible !== false);
|
|
2879
3007
|
// What follows the rows (a table's Empty State, bare or in its own frame) follows the Table:
|
|
@@ -2892,7 +3020,9 @@ function tableOf(node, ctx) {
|
|
|
2892
3020
|
for (const cell of (row.children ?? []).filter((c) => c.visible !== false)) {
|
|
2893
3021
|
if (cell.instance?.remote) {
|
|
2894
3022
|
const local = [];
|
|
2895
|
-
const
|
|
3023
|
+
const emitted = emitNode(cell, { ...ctx, depth: 0, parent: null, path: `${ctx.path} › ${row.name}`, root: false, bare: true, inTable: true, imports: local, note: () => {} });
|
|
3024
|
+
const selected = selectedCell(emitted);
|
|
3025
|
+
const code = selected ?? emitted;
|
|
2896
3026
|
if (isSkeleton(code?.trim())) {
|
|
2897
3027
|
imports.push(...local);
|
|
2898
3028
|
cells.push({ cell, code: code.trim(), loading: true });
|
|
@@ -2910,7 +3040,7 @@ function tableOf(node, ctx) {
|
|
|
2910
3040
|
// Rich Cell) keeps its own template code, as a cell of that row.
|
|
2911
3041
|
kind = kind === "head" || part === "head" ? "head" : part;
|
|
2912
3042
|
imports.push(...local);
|
|
2913
|
-
cells.push({ cell, code });
|
|
3043
|
+
cells.push({ cell, code, selected: selected !== null });
|
|
2914
3044
|
} else if (cell.layout || cell.type === "TEXT") cells.push({ cell, code: null });
|
|
2915
3045
|
else return null;
|
|
2916
3046
|
}
|
|
@@ -2987,7 +3117,7 @@ function tableOf(node, ctx) {
|
|
|
2987
3117
|
const density = declaredDensity(parsed.find((p) => p.row === row)?.cells ?? []) ?? tableDensity;
|
|
2988
3118
|
return `${widthAttr(w)}${density ? ` density="${density}"` : ""}`;
|
|
2989
3119
|
};
|
|
2990
|
-
const cellCode = ({ cell, code, held }, row, d, column = null) => {
|
|
3120
|
+
const cellCode = ({ cell, code, held, selected }, row, d, column = null) => {
|
|
2991
3121
|
const w = columnWidth(cell);
|
|
2992
3122
|
if (held) {
|
|
2993
3123
|
const inner = emitNode(cell, { ...ctx, depth: d + 1, parent: null, path: `${ctx.path} › ${row.name}`, root: false, bare: true, inTable: true });
|
|
@@ -2995,7 +3125,8 @@ function tableOf(node, ctx) {
|
|
|
2995
3125
|
}
|
|
2996
3126
|
if (code) {
|
|
2997
3127
|
// Re-emit for real, so the cell's own unmapped layers are reported.
|
|
2998
|
-
|
|
3128
|
+
const emitted = emitNode(cell, { ...ctx, depth: d, parent: null, path: `${ctx.path} › ${row.name}`, root: false, bare: true, inTable: true, column });
|
|
3129
|
+
return withWidth(selected ? indent(selectedCell(emitted), d) : emitted, w);
|
|
2999
3130
|
}
|
|
3000
3131
|
// The frame stood in for the cell: its size and padding are the TableCell's now.
|
|
3001
3132
|
const inner = emitNode({ ...cell, sizing: ["HUG", "HUG"], x: undefined, fills: undefined, strokes: undefined, radius: undefined, ...(cell.layout ? { layout: { ...cell.layout, padding: [0, 0, 0, 0] } } : {}) }, { ...ctx, depth: d + 1, parent: null, path: `${ctx.path} › ${row.name}`, root: false, inTable: true });
|
|
@@ -3067,6 +3198,9 @@ function tableOf(node, ctx) {
|
|
|
3067
3198
|
const first = dataRows[0];
|
|
3068
3199
|
const keys = columnKeys(first.cells.length);
|
|
3069
3200
|
const rowsName = mark(ctx, listName, "rows", null);
|
|
3201
|
+
let selectedKey = "isSelected";
|
|
3202
|
+
while (keys.includes(selectedKey)) selectedKey += "Row";
|
|
3203
|
+
const selection = dataRows.some(p => p.cells.some(c => c.selected)) ? ` selected={row.${selectedKey}}` : "";
|
|
3070
3204
|
// A row is a door to its record when the page passes a handler (U03-7; NODII-DEV-CLI-83).
|
|
3071
3205
|
const rowClick = mark(ctx, listName, "onRowClick", null);
|
|
3072
3206
|
const inert = mark(ctx, listName, "isRowInert", null);
|
|
@@ -3074,10 +3208,11 @@ function tableOf(node, ctx) {
|
|
|
3074
3208
|
ctx.note(ctx.path, LIFTED, `${dataRows.length} body row${dataRows.length === 1 ? "" : "s"} lifted as data: rows of { id, ${keys.join(", ")} } (NODII-DEV-CLI-82)`);
|
|
3075
3209
|
// A column whose every body cell is a PiiText is a person's value: its row field is the
|
|
3076
3210
|
// served pair and the cell draws PiiText from it, never a node the page could fill with a
|
|
3077
|
-
// raw name (U05; cli-140).
|
|
3078
|
-
//
|
|
3211
|
+
// raw name (U05; cli-140). Plain text and plain badges form typed alternatives;
|
|
3212
|
+
// unsupported mixed content remains an explicit mapping failure.
|
|
3079
3213
|
const invalidPii = new Map();
|
|
3080
3214
|
const nullablePii = new Map();
|
|
3215
|
+
const mixedPii = new Map();
|
|
3081
3216
|
const personSamples = new Map();
|
|
3082
3217
|
const piiColumn = keys.map((key, i) => {
|
|
3083
3218
|
const people = dataRows.filter((p) => piiCellAttrs(p.cells[i]) !== null);
|
|
@@ -3091,13 +3226,19 @@ function tableOf(node, ctx) {
|
|
|
3091
3226
|
const empties = others.map(p => emptyPiiCell(p.cells[i]));
|
|
3092
3227
|
const nullable = drawn > 0 && others.length > 0 && empties.every(value => value !== null) && new Set(empties).size === 1;
|
|
3093
3228
|
if (nullable) nullablePii.set(i, { sample: people[0].cells[i], empty: empties[0] });
|
|
3094
|
-
|
|
3229
|
+
const plain = others.map(p => plainPiiAlternative(p.cells[i]));
|
|
3230
|
+
const mixed = drawn > 0 && others.length > 0 && !nullable && plain.every(Boolean);
|
|
3231
|
+
if (mixed) {
|
|
3232
|
+
const badges = plain.filter(p => p.kind === "badge");
|
|
3233
|
+
if (new Set(badges.map(p => p.template)).size <= 1) mixedPii.set(i, { sample: people[0].cells[i], badge: badges[0]?.template, text: plain.some(p => p.kind === "text") });
|
|
3234
|
+
}
|
|
3235
|
+
if (drawn > 0 && drawn < dataRows.length && !nullable && !mixedPii.has(i)) {
|
|
3095
3236
|
const why = `column ${key} mixes PiiText with incompatible non-person content`;
|
|
3096
3237
|
ctx.note(ctx.path, "table", `${why}: left unmapped (U05; cli-140)`);
|
|
3097
3238
|
invalidPii.set(i, why);
|
|
3098
3239
|
return false;
|
|
3099
3240
|
}
|
|
3100
|
-
if (drawn === dataRows.length || nullable) {
|
|
3241
|
+
if (drawn === dataRows.length || nullable || mixedPii.has(i)) {
|
|
3101
3242
|
const kinds = people.map((p) => piiTreeKind(p.cells[i].cell));
|
|
3102
3243
|
const why = kinds.some((kind) => !PII_KINDS.has(kind))
|
|
3103
3244
|
? `column ${key} has no recognised PiiText kind in one or more body rows`
|
|
@@ -3108,7 +3249,7 @@ function tableOf(node, ctx) {
|
|
|
3108
3249
|
return false;
|
|
3109
3250
|
}
|
|
3110
3251
|
}
|
|
3111
|
-
return drawn === dataRows.length || nullable;
|
|
3252
|
+
return drawn === dataRows.length || nullable || mixedPii.has(i);
|
|
3112
3253
|
});
|
|
3113
3254
|
const secondaryKeys = new Set(keys);
|
|
3114
3255
|
const cells = first.cells.map((c, i) => {
|
|
@@ -3116,7 +3257,8 @@ function tableOf(node, ctx) {
|
|
|
3116
3257
|
let open = `<TableCell${wrapperAttrs(w, first.row)}>`;
|
|
3117
3258
|
let close = "</TableCell>";
|
|
3118
3259
|
if (c.code && !c.held) {
|
|
3119
|
-
const
|
|
3260
|
+
const emitted = emitNode(c.cell, { ...ctx, depth: 0, parent: null, path: `${ctx.path} › ${first.row.name}`, root: false, bare: true, inTable: true, scopes: null, note: () => {} });
|
|
3261
|
+
const own = withWidth(c.selected ? selectedCell(emitted) : emitted, w).trim();
|
|
3120
3262
|
const end = openTagEnd(own);
|
|
3121
3263
|
const tag = /^<([A-Za-z]+)/.exec(own)[1];
|
|
3122
3264
|
open = own.slice(0, end + 1).replace(/\s*\/>$/, ">");
|
|
@@ -3136,14 +3278,15 @@ function tableOf(node, ctx) {
|
|
|
3136
3278
|
if (piiColumn[i]) {
|
|
3137
3279
|
const nullable = nullablePii.get(i);
|
|
3138
3280
|
const ref = `row.${keys[i]}`;
|
|
3139
|
-
const
|
|
3281
|
+
const mixed = mixedPii.get(i);
|
|
3282
|
+
const content = mixed ? mixedPiiText(mixed, ref) : nullable ? `{${ref} == null ? (${nullable.empty}) : (${piiCellText(nullable.sample, ref)})}` : piiCellText(personSamples.get(i) ?? c, ref);
|
|
3140
3283
|
return indent(`${open}\n ${content}\n${close}`, depth + 4);
|
|
3141
3284
|
}
|
|
3142
3285
|
return indent(`${open}{row.${keys[i]}}${close}`, depth + 4);
|
|
3143
3286
|
});
|
|
3144
3287
|
return [
|
|
3145
3288
|
indent(`{${rowsName}.map((row) => (`, depth + 2),
|
|
3146
|
-
indent(`<TableRow key={row.id} onClick={${inert}?.(row) ? undefined : ${getClick} ? ${getClick}(row) : ${rowClick} && (() => ${rowClick}(row))}>`, depth + 3),
|
|
3289
|
+
indent(`<TableRow key={row.id}${selection} onClick={${inert}?.(row) ? undefined : ${getClick} ? ${getClick}(row) : ${rowClick} && (() => ${rowClick}(row))}>`, depth + 3),
|
|
3147
3290
|
...cells,
|
|
3148
3291
|
indent("</TableRow>", depth + 3),
|
|
3149
3292
|
indent("))}", depth + 2),
|