@nodii/dev 0.6.182 → 0.6.183
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 +48 -0
- package/dist/cli.js +21 -1
- package/dist/core.js +1 -1
- package/dist/figma.js +89 -0
- package/dist/flags.js +1 -0
- package/dist/surface.js +26 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -347,6 +347,7 @@ nodii-dev figma apply CHANGE_SET --figma-version VERSION
|
|
|
347
347
|
nodii-dev figma published FILE_KEY|CHANGE_SET --figma-version VERSION
|
|
348
348
|
nodii-dev figma abandon CHANGE_SET
|
|
349
349
|
nodii-dev figma withdraw CHANGE_SET # take back a submit before anything is decided
|
|
350
|
+
nodii-dev figma split CHANGE_SET --nodes NODE[,NODE] --title TEXT # move written nodes to a new set
|
|
350
351
|
nodii-dev figma resubmit CHANGE_SET PAYLOAD.json # round 2: re-submit every rejected item
|
|
351
352
|
nodii-dev figma changeset show CHANGE_SET # items, variants, round, decision, comment
|
|
352
353
|
nodii-dev figma release FILE_KEY
|
|
@@ -435,6 +436,34 @@ library publish's version id). Dev holds back a set whose component an
|
|
|
435
436
|
unfinished set now holds, and flags any published component from an
|
|
436
437
|
unfinished set. `figma published CS-123 ...` keeps the per-set route.
|
|
437
438
|
|
|
439
|
+
`figma split CS --nodes NODE[,NODE] --title TEXT` moves written nodes out of an
|
|
440
|
+
editing set's write log into a new set you hold (Dev's `splitDesignChangeSet`,
|
|
441
|
+
hub-572). Use it when the write log holds more Surface sets than one review
|
|
442
|
+
should take, and a submit that names items for only some of them is refused
|
|
443
|
+
`WRITE_OUTSIDE_DECLARED`.
|
|
444
|
+
|
|
445
|
+
How a split works:
|
|
446
|
+
- **What you name:** written node ids. Read a Surface set's written ids through
|
|
447
|
+
the MCP; Dev can't place a written node by component set without Figma.
|
|
448
|
+
- **What moves:** the receipts for those nodes and for anything inside them.
|
|
449
|
+
A receipt moves and is never copied.
|
|
450
|
+
- **The new set:** the same file, base version and base seal state as the
|
|
451
|
+
source.
|
|
452
|
+
- **What stays with the source:** the lock (one lock per file per agent).
|
|
453
|
+
Restore one on the new set with `figma lock` once the source releases the
|
|
454
|
+
file.
|
|
455
|
+
- **Scopes:** a held scope rooted exactly at a moved node moves with it.
|
|
456
|
+
- **Record:** both sets record the split.
|
|
457
|
+
|
|
458
|
+
The title follows the change-set title rule (`CHANGE_SET_TITLE_STYLE`).
|
|
459
|
+
|
|
460
|
+
Dev refuses with:
|
|
461
|
+
- `SPLIT_NODE_IN_ITEM` for a node that an item of the source names;
|
|
462
|
+
- `SPLIT_NODE_NOT_WRITTEN` for a node that isn't in the write log;
|
|
463
|
+
- `SPLIT_NOTHING_TO_MOVE` when nothing is named;
|
|
464
|
+
- `CHANGE_SET_NOT_EDITABLE` while the set is in review or its submit is running;
|
|
465
|
+
- `CHANGE_SET_HOLDER_REQUIRED` for anyone but the holder.
|
|
466
|
+
|
|
438
467
|
`figma withdraw` moves a change set you hold from `in_review` back to
|
|
439
468
|
`editing`, as long as no item has been decided (Dev's
|
|
440
469
|
`withdrawDesignChangeSet`). Dev refuses when the change set doesn't exist
|
|
@@ -501,6 +530,25 @@ outside its item (the CLI lists each item and the variants outside it). When
|
|
|
501
530
|
Figma can't answer that check, Dev refuses with `503 FIGMA_UNAVAILABLE`; the CLI
|
|
502
531
|
says when to retry (`details.retryAfter` seconds).
|
|
503
532
|
|
|
533
|
+
A change set changes only what was asked (MW6-22). Every removal of a
|
|
534
|
+
control, action, data, role view, metric, section or page, and every component
|
|
535
|
+
swap, is a line in `writeUp` or in the item's `context`, and quotes the
|
|
536
|
+
operator's ask behind it verbatim and dated:
|
|
537
|
+
|
|
538
|
+
```
|
|
539
|
+
Removed: <what> · ask: "<verbatim quote>" (<who>, <date>)
|
|
540
|
+
Replaced: <old> → <new> · ask: "<verbatim quote>" (<who>, <date>)
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
The date may be `19 Nov 2026`, `19 November`, `19th Nov`, `19 Nov`, `Nov 19, 2026`,
|
|
544
|
+
`19/11/2026` or `2026-11-19`. A `Removed:` or
|
|
545
|
+
`Replaced:` line with no quoted ask, or with an ask but no date, is refused
|
|
546
|
+
before Dev is called (exit `2`, `CHANGE_SET_SCOPE_UNASKED`), naming the item
|
|
547
|
+
and the line. `figma submit`, `figma resubmit` and `figma submit --dry-run` all
|
|
548
|
+
run this check, and Dev refuses the same. A removal or swap that no ask names
|
|
549
|
+
is not drawn: put it back, or ask the coordinator to put the question on the
|
|
550
|
+
operator's sheet (MW6-24).
|
|
551
|
+
|
|
504
552
|
`figma resubmit` is round 2 inside the same change set (Dev's
|
|
505
553
|
`resubmitDesignChangeSet`). When every item is decided and some were
|
|
506
554
|
rejected, the set is `applying`: rework the rejected items in Figma (the lock
|
package/dist/cli.js
CHANGED
|
@@ -68,6 +68,10 @@ import {
|
|
|
68
68
|
removedNodesFrom,
|
|
69
69
|
removedNodesInReads,
|
|
70
70
|
withdrawItemsFrom,
|
|
71
|
+
figmaSplit,
|
|
72
|
+
figmaSplitText,
|
|
73
|
+
listFlag,
|
|
74
|
+
SPLIT_USAGE,
|
|
71
75
|
checkSubmitPayload,
|
|
72
76
|
assertContext,
|
|
73
77
|
resubmitPayload,
|
|
@@ -260,7 +264,10 @@ Usage: nodii-dev <command> [options] [--json]
|
|
|
260
264
|
# variants: [{ nodeId, name, context, afterPngBase64 }] }] } (DEC-0204);
|
|
261
265
|
# a missing writeUp, context or variant name, or an item with no variants,
|
|
262
266
|
# is refused before Dev is called (writeUp <= 2000, context <= 500, name <= 120;
|
|
263
|
-
# never a bare node id).
|
|
267
|
+
# never a bare node id). Each removal or swap line in writeUp or an item's
|
|
268
|
+
# context quotes its ask, verbatim and dated (MW6-22), or the CLI and Dev
|
|
269
|
+
# refuse CHANGE_SET_SCOPE_UNASKED: Removed: <what> · ask: "<quote>" (<who>,
|
|
270
|
+
# <date>), or Replaced: <old> → <new> · ask: ... The CLI adds evidence { baseVersion, finishVersion,
|
|
264
271
|
# nodes: [{ nodeId, afterSha256 }] }: list any node written beyond the variants
|
|
265
272
|
# in the body's evidence.nodes, or Dev refuses WRITE_OUTSIDE_DECLARED
|
|
266
273
|
figma checked CHANGE_SET --unused-properties --stale-placeholders --dialog-body # the hand checks the submit nudge asks for
|
|
@@ -271,6 +278,11 @@ Usage: nodii-dev <command> [options] [--json]
|
|
|
271
278
|
# coordinator or staff: move an open set, with its lock and scopes, to a live
|
|
272
279
|
# lane's agent, even from a stopped lane. The target can hold no other lock on
|
|
273
280
|
# the file (TARGET_HOLDS_FILE_LOCK)
|
|
281
|
+
figma split CHANGE_SET --nodes NODE[,NODE] --title TEXT
|
|
282
|
+
# holder: move written nodes (and what is inside them) out of an editing set's
|
|
283
|
+
# write log into a new set you hold on the same file, base and seal; receipts
|
|
284
|
+
# move, never copied. A node an item names stays (SPLIT_NODE_IN_ITEM); the lock
|
|
285
|
+
# stays with the source. hub-572
|
|
274
286
|
figma withdraw CHANGE_SET # holder takes back a submit: in_review -> editing (or a re-submit -> applying)
|
|
275
287
|
figma withdraw CHANGE_SET --items ID[,ID] --reason TEXT [--lane-reads FILE [--removed-nodes NODE[,NODE]]]
|
|
276
288
|
# holder, coordinator or operator: take rejected items (item or node ids)
|
|
@@ -1818,6 +1830,14 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
1818
1830
|
throw new CliError("USAGE", `--reason goes with --items: ${WITHDRAW_ITEMS_USAGE} (a whole submit is withdrawn with: figma withdraw CHANGE_SET)`, 2);
|
|
1819
1831
|
return emit(await figmaWithdraw(rest[0]), json, (p) => `Withdrew ${rest[0]}; it is back in ${p.data?.state ?? "editing"}.`);
|
|
1820
1832
|
}
|
|
1833
|
+
if (action === "split") {
|
|
1834
|
+
if (rest.length !== 1) throw new CliError("USAGE", SPLIT_USAGE, 2);
|
|
1835
|
+
return emit(
|
|
1836
|
+
await figmaSplit(rest[0], { nodeIds: listFlag(f, "nodes"), title: f.title === true ? "" : f.title }),
|
|
1837
|
+
json,
|
|
1838
|
+
(p) => figmaSplitText(rest[0], p.data),
|
|
1839
|
+
);
|
|
1840
|
+
}
|
|
1821
1841
|
if (action === "resubmit")
|
|
1822
1842
|
return emit(await figmaResubmit(rest[0], rest[1], { sync: submitMode(f), ...(f["lane-reads"] ? { laneReads: await readLaneReads(f["lane-reads"]) } : {}) }), json, (p) =>
|
|
1823
1843
|
[`Re-submitted ${rest[0]}; it is ${p.data.state}.`, figmaChangeSetText(p.data), ...conformanceLines({ warnings: p.warnings })].join("\n"));
|
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.183";
|
|
8
8
|
export const configPath = () =>
|
|
9
9
|
process.env.NODII_DEV_CONFIG_PATH ??
|
|
10
10
|
join(homedir(), ".config/nodii-dev/config.json");
|
package/dist/figma.js
CHANGED
|
@@ -137,6 +137,45 @@ function assertEvidenceShape(evidence, file) {
|
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
// MW6-22 (DEC-0509): a change set changes only what was asked. Every removal
|
|
141
|
+
// or component swap in the write-up names the ask behind it, verbatim and
|
|
142
|
+
// dated, in this form; one with no ask is not drawn.
|
|
143
|
+
export const SCOPE_ASK_FORMAT = 'Removed: <what> · ask: "<verbatim quote>" (<who>, <date>) | Replaced: <old> → <new> · ask: "<verbatim quote>" (<who>, <date>)';
|
|
144
|
+
const SCOPE_LINE = /(?:^|\n)[ \t]*[-*]?[ \t]*((?:Removed|Replaced)[ \t]*:[^\n]*)/gi;
|
|
145
|
+
const MONTH = "(?:jan|feb|mar|apr|may|jun|jul|aug|sep|sept|oct|nov|dec)[a-z]*";
|
|
146
|
+
// The forms Dev's check takes (Dev's scope-asks check, hub #698): 2026-11-19, 19/11/2026,
|
|
147
|
+
// 19 Nov 2026, 19 November, 19th Nov, 19 Nov, Nov 19 and Nov 19, 2026.
|
|
148
|
+
const ASK_DATE = new RegExp(`\\b(?:\\d{4}-\\d{2}-\\d{2}|\\d{1,2}/\\d{1,2}/\\d{4}|\\d{1,2}(?:st|nd|rd|th)?\\s+${MONTH}(?:\\s+\\d{4})?|${MONTH}\\s+\\d{1,2}(?:st|nd|rd|th)?(?:,?\\s+\\d{4})?)\\b`, "i");
|
|
149
|
+
|
|
150
|
+
/** Each Removed: or Replaced: line of a write-up or item context that lacks a verbatim, dated ask (MW6-22). */
|
|
151
|
+
export function scopeAskProblems(body) {
|
|
152
|
+
const problems = [];
|
|
153
|
+
const scan = (text, at) => {
|
|
154
|
+
for (const [, line] of String(text ?? "").matchAll(SCOPE_LINE)) {
|
|
155
|
+
const ask = /\bask\s*:\s*["“]([^"”]+)["”]\s*(?:\(([^)]*)\))?/i.exec(line);
|
|
156
|
+
const problem = !ask ? "no_ask" : !ASK_DATE.test(ask[2] ?? "") ? "no_date" : null;
|
|
157
|
+
if (problem) problems.push({ ...at, line: line.trim(), problem });
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
scan(body?.writeUp, { field: "writeUp" });
|
|
161
|
+
(Array.isArray(body?.items) ? body.items : []).forEach((item, itemIndex) =>
|
|
162
|
+
scan(item?.context, { field: "item.context", itemIndex, figmaNodeId: item?.figmaNodeId ?? null }));
|
|
163
|
+
return problems;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** One plain-English line per unasked removal or swap. */
|
|
167
|
+
export function scopeAskLines(lines = []) {
|
|
168
|
+
return lines.map((l) => {
|
|
169
|
+
const where = l.field === "writeUp" ? "writeUp" : `${itemLabel(l)} context`;
|
|
170
|
+
return ` ${where}: ${JSON.stringify(l.line)} ${l.problem === "no_date" ? "has an ask with no date" : "has no ask"}`;
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const scopeAskHelp = () => [
|
|
175
|
+
`Quote the operator's ask behind each one, verbatim and dated: ${SCOPE_ASK_FORMAT}`,
|
|
176
|
+
"A removal or swap no ask names is not drawn: put it back, or ask the coordinator to put the question on the operator's sheet (MW6-22, MW6-24).",
|
|
177
|
+
];
|
|
178
|
+
|
|
140
179
|
export function assertContext(body, { resubmit = false, file = "the payload" } = {}) {
|
|
141
180
|
assertEvidenceShape(body.evidence, file);
|
|
142
181
|
const { items, problems } = contextProblems(body, { resubmit });
|
|
@@ -155,11 +194,20 @@ export function assertContext(body, { resubmit = false, file = "the payload" } =
|
|
|
155
194
|
2,
|
|
156
195
|
{ problems },
|
|
157
196
|
);
|
|
197
|
+
const unasked = scopeAskProblems(body);
|
|
198
|
+
if (unasked.length)
|
|
199
|
+
throw new CliError(
|
|
200
|
+
"CHANGE_SET_SCOPE_UNASKED",
|
|
201
|
+
[`${file}: ${unasked.length} removal or swap line(s) carry no verbatim, dated operator ask (MW6-22); nothing was sent:`, ...scopeAskLines(unasked), ...scopeAskHelp()].join("\n"),
|
|
202
|
+
2,
|
|
203
|
+
{ lines: unasked },
|
|
204
|
+
);
|
|
158
205
|
return body;
|
|
159
206
|
}
|
|
160
207
|
|
|
161
208
|
// Dev's refusals of a submit or re-submit's context and component scope (DEC-0204), with what to do next.
|
|
162
209
|
const CONTEXT_REFUSALS = {
|
|
210
|
+
CHANGE_SET_SCOPE_UNASKED: (message, details) => [message, ...scopeAskLines(details?.lines), ...scopeAskHelp()].join("\n"),
|
|
163
211
|
CHANGE_SET_ITEM_NO_VARIANTS: (message, details) => [message, ...noVariantLines(details?.items)].join("\n"),
|
|
164
212
|
CHANGE_SET_CONTEXT_MISSING: (message, details) => [message, ...contextProblemLines(details?.problems)].join("\n"),
|
|
165
213
|
CHANGE_SET_MIXED_COMPONENTS: (message, details) =>
|
|
@@ -1064,6 +1112,47 @@ export async function figmaWithdrawItems(id, items, reason, { request = devReque
|
|
|
1064
1112
|
}
|
|
1065
1113
|
}
|
|
1066
1114
|
|
|
1115
|
+
// hub-572: move part of a set's write log, by written node, into a new set
|
|
1116
|
+
// held by the same lane (splitDesignChangeSet). Dev places no written node by
|
|
1117
|
+
// component set without Figma, so the lane reads a Surface set's written node
|
|
1118
|
+
// ids through the MCP and names them.
|
|
1119
|
+
export const SPLIT_USAGE = "figma split CHANGE_SET --nodes NODE[,NODE] --title TEXT";
|
|
1120
|
+
|
|
1121
|
+
/** A repeatable, comma-separated list flag; [] when absent. */
|
|
1122
|
+
export function listFlag(flags, name) {
|
|
1123
|
+
const given = [flags[name]].flat().filter((x) => x !== undefined);
|
|
1124
|
+
if (given.some((x) => x === true)) throw new CliError("USAGE", `--${name} needs values: ${SPLIT_USAGE}`, 2);
|
|
1125
|
+
return [...new Set(given.flatMap((x) => String(x).split(",")).map((x) => x.trim()).filter(Boolean))];
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
const SPLIT_REFUSALS = {
|
|
1129
|
+
SPLIT_NODE_IN_ITEM: (id, details) => `${(details?.nodeIds ?? []).join(", ") || "A node you named"} is named by an item of ${id}, so it stays in ${id}. Withdraw or edit that item first, or leave the node out.`,
|
|
1130
|
+
SPLIT_NODE_NOT_WRITTEN: (id, details) => `${(details?.nodeIds ?? []).join(", ") || "A node you named"} is not in ${id}'s write log, so there is no write to move. Name written node ids (figma changeset show ${id}).`,
|
|
1131
|
+
SPLIT_NOTHING_TO_MOVE: (id) => `nothing to move: no write in ${id}'s write log matches what you named.`,
|
|
1132
|
+
CHANGE_SET_NOT_EDITABLE: (id) => `${id} is not editing (or its submit is running), so its write log can't be split. Withdraw the submit first (figma withdraw ${id}).`,
|
|
1133
|
+
CHANGE_SET_HOLDER_REQUIRED: (id) => `You don't hold ${id}; only its holder can split it.`,
|
|
1134
|
+
};
|
|
1135
|
+
|
|
1136
|
+
export async function figmaSplit(id, { nodeIds = [], title } = {}, { request = devRequest } = {}) {
|
|
1137
|
+
if (!id) throw new CliError("USAGE", SPLIT_USAGE, 2);
|
|
1138
|
+
if (typeof title !== "string" || !title.trim()) throw new CliError("USAGE", `--title needs the new set's name: ${SPLIT_USAGE}`, 2);
|
|
1139
|
+
if (!nodeIds.length) throw new CliError("USAGE", `name the written nodes that move with --nodes: ${SPLIT_USAGE}`, 2);
|
|
1140
|
+
try {
|
|
1141
|
+
return await request("POST", `/api/v1/design/change-sets/${encode(id)}/split`, { nodeIds, title: title.trim() });
|
|
1142
|
+
} catch (error) {
|
|
1143
|
+
const say = SPLIT_REFUSALS[error?.code];
|
|
1144
|
+
if (say) throw new CliError(error.code, say(id, error.details), error.exitCode ?? 1, error.details);
|
|
1145
|
+
throw error;
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
export function figmaSplitText(id, data) {
|
|
1150
|
+
const moved = data?.moved ?? {};
|
|
1151
|
+
const count = moved.nodeIds?.length ?? 0;
|
|
1152
|
+
const created = data?.created ?? {};
|
|
1153
|
+
return `Moved ${count} node${count === 1 ? "" : "s"} (${moved.receipts ?? 0} write receipt${moved.receipts === 1 ? "" : "s"}) from ${id} to ${created.id} "${created.title}". Both sets are yours and editing; each submits with its own items.`;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1067
1156
|
/**
|
|
1068
1157
|
* Apply on the lane's reads (MW1-57.11): the reads' Figma version unless one
|
|
1069
1158
|
* is named. Reads over a chunk go up to the set first and are named by
|
package/dist/flags.js
CHANGED
|
@@ -83,6 +83,7 @@ export const COMMAND_FLAGS = {
|
|
|
83
83
|
"figma submit": ["file", "figma-version", ...SUBMIT_MODE, "dry-run", "lane-reads"],
|
|
84
84
|
"figma resubmit": [...SUBMIT_MODE, "dry-run", "lane-reads"],
|
|
85
85
|
"figma withdraw": ["items", "reason", "lane-reads", "removed-nodes"],
|
|
86
|
+
"figma split": ["nodes", "title"],
|
|
86
87
|
"figma lane-reads-script": ["nodes"],
|
|
87
88
|
"figma abandon": ["file"],
|
|
88
89
|
// hub-260: list takes these; show takes none.
|
package/dist/surface.js
CHANGED
|
@@ -34,7 +34,7 @@ import { MIN_FIGMA_INTERVAL_MS, figmaRest } from "./figma-rest.js";
|
|
|
34
34
|
import { createRenderer } from "./vendor/render-templates.mjs";
|
|
35
35
|
|
|
36
36
|
/** Bumped whenever the emitted code changes shape for the same inputs. */
|
|
37
|
-
export const GENERATOR_FORMAT =
|
|
37
|
+
export const GENERATOR_FORMAT = 42;
|
|
38
38
|
export const TREE_DIR = "docs/figma-ux-ds/figma/surface-trees";
|
|
39
39
|
export const GENERATED_SUFFIX = ".surface.generated.tsx";
|
|
40
40
|
/** Where every generated product page lives, as a git glob (NODII-DEV-CLI-77). */
|
|
@@ -326,6 +326,9 @@ function catalogStateJoin(entry, row, version) {
|
|
|
326
326
|
return (variant) => variantToState.get(variant.id) ?? null;
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
+
/** The saved-tree format trimTree writes: 2 keeps nested slot content (NODII-DEV-CLI-226). */
|
|
330
|
+
export const TREE_FORMAT = 2;
|
|
331
|
+
|
|
329
332
|
export function trimTree(entry, { row, version }) {
|
|
330
333
|
const components = entry.components ?? {};
|
|
331
334
|
const sets = entry.componentSets ?? {};
|
|
@@ -479,6 +482,10 @@ export function trimTree(entry, { row, version }) {
|
|
|
479
482
|
return {
|
|
480
483
|
$comment: "Generated by `nodii-dev surface generate --fetch --write` from Figma's REST nodes API (read-only). The input of the product page's generated file; never edit by hand.",
|
|
481
484
|
generator: "nodii-dev surface generate",
|
|
485
|
+
// Format 2 keeps nested slot content: an exposed or overridden nested instance keeps its
|
|
486
|
+
// slots (#379), so the corpus gate no longer counts the tree as shallow input. A tree with
|
|
487
|
+
// no treeFormat is format 1 and still generates (NODII-DEV-CLI-226, lane gen-tree).
|
|
488
|
+
treeFormat: TREE_FORMAT,
|
|
482
489
|
fileKey: row.fileKey,
|
|
483
490
|
componentSetKey: row.componentSetKey,
|
|
484
491
|
componentSetName: doc.name,
|
|
@@ -2061,7 +2068,7 @@ function dataProps(views, propsType) {
|
|
|
2061
2068
|
const ref = `${m[1]}.${m[2]}`;
|
|
2062
2069
|
const mixed = mixedPiiExpressions(body).find(expression => m.index >= expression.at && m.index < expression.end)?.expression;
|
|
2063
2070
|
const alternatives = mixed ? [
|
|
2064
|
-
`{ kind: "person" } & ${
|
|
2071
|
+
`{ kind: "person" } & ${piiRowField(PII_UNION_KIND)}`,
|
|
2065
2072
|
...(mixed.includes(`${ref}.kind === "text"`) ? ['{ kind: "text"; text: string }'] : []),
|
|
2066
2073
|
...(mixed.includes(`${ref}.kind === "badge"`) ? ['{ kind: "badge"; text: string }'] : []),
|
|
2067
2074
|
].join(" | ") : null;
|
|
@@ -2781,7 +2788,14 @@ function tabStrip(run, ctx) {
|
|
|
2781
2788
|
* PiiText's is offered, so a row can never force a value visible (U05; cli-140).
|
|
2782
2789
|
*/
|
|
2783
2790
|
const PII_KINDS = new Set(["name", "email", "phone", "address", "dob", "document", "text"]);
|
|
2784
|
-
const
|
|
2791
|
+
const piiRowField = (kindField) =>
|
|
2792
|
+
`{ ${[`${kindField}?`, "maskHint?", "model", "relation", "value"].map((k) => `${k}: ComponentProps<typeof PiiText>[${JSON.stringify(k === `${kindField}?` ? "kind" : k.replace("?", ""))}]`).join("; ")} }`;
|
|
2793
|
+
const PII_ROW_FIELD = piiRowField("kind");
|
|
2794
|
+
/**
|
|
2795
|
+
* In a person-or-text union `kind` is the discriminant, so the person's PiiText kind is
|
|
2796
|
+
* `piiKind` there: `{ kind: "person" } & { kind?: PiiKind }` is never (NODII-DEV-CLI-225).
|
|
2797
|
+
*/
|
|
2798
|
+
const PII_UNION_KIND = "piiKind";
|
|
2785
2799
|
const PII_ROW_READ = /<PiiText value=\{([a-z][A-Za-z0-9]*)\.([A-Za-z][A-Za-z0-9]*)\.value\} kind=/g;
|
|
2786
2800
|
|
|
2787
2801
|
/**
|
|
@@ -2947,7 +2961,7 @@ function piiTreeKind(cell) {
|
|
|
2947
2961
|
}
|
|
2948
2962
|
|
|
2949
2963
|
/** That cell's PiiText, reading the served pair at `ref` (`row.employee`), with the kind the tree states for it. */
|
|
2950
|
-
function piiCellText({ cell, code }, ref) {
|
|
2964
|
+
function piiCellText({ cell, code }, ref, kindField = "kind") {
|
|
2951
2965
|
const { attrs = "", before = "", after = "" } = piiCellParts({ code }) ?? {};
|
|
2952
2966
|
const kind = piiTreeKind(cell);
|
|
2953
2967
|
const size = /\ssize="\w+"/.exec(attrs)?.[0] ?? "";
|
|
@@ -2955,7 +2969,7 @@ function piiCellText({ cell, code }, ref) {
|
|
|
2955
2969
|
// a permissive ambient provider. Keep the served self relation unchanged.
|
|
2956
2970
|
// The kind is the record's (a contact column lists emails and phones): the row may say
|
|
2957
2971
|
// its own, and the kind Figma drew is the default (NODII-DEV-CLI-223).
|
|
2958
|
-
return `${before}<PiiText value={${ref}.value} kind={${ref}
|
|
2972
|
+
return `${before}<PiiText value={${ref}.value} kind={${ref}.${kindField} ?? "${kind}"} model={${ref}.model} relation={${ref}.relation} maskHint={${ref}.maskHint} surface="bulk"${size} />${after}`;
|
|
2959
2973
|
}
|
|
2960
2974
|
|
|
2961
2975
|
/** A non-person alternative must be plain text or a plain Badge, never arbitrary JSX. */
|
|
@@ -2969,7 +2983,7 @@ function plainPiiAlternative(part) {
|
|
|
2969
2983
|
}
|
|
2970
2984
|
|
|
2971
2985
|
function mixedPiiText(mixed, ref) {
|
|
2972
|
-
const branches = [`${ref}.kind === "person" ? (${piiCellText(mixed.sample, ref)})`];
|
|
2986
|
+
const branches = [`${ref}.kind === "person" ? (${piiCellText(mixed.sample, ref, PII_UNION_KIND)})`];
|
|
2973
2987
|
if (mixed.text) branches.push(`${ref}.kind === "text" ? (<>{${ref}.text}</>)`);
|
|
2974
2988
|
if (mixed.badge) branches.push(`${ref}.kind === "badge" ? (${mixed.badge.replace("__plainCellText__", `${ref}.text`)})`);
|
|
2975
2989
|
return `{${branches.join(" : ")} : null}`;
|
|
@@ -3019,11 +3033,16 @@ export function columnWidth(cell) {
|
|
|
3019
3033
|
return null;
|
|
3020
3034
|
}
|
|
3021
3035
|
const widthAttr = (w) => (w === null ? "" : typeof w === "number" ? ` width={${w}}` : ` width="${w}"`);
|
|
3036
|
+
/**
|
|
3037
|
+
* The DS Table parts that take a column width (`TableColumnWidthProps`). Others, such as
|
|
3038
|
+
* TableSelectionCell, have no `width` prop, so they never get one (hub-573).
|
|
3039
|
+
*/
|
|
3040
|
+
const COLUMN_WIDTH_PART = /^\s*<(?:TableHead|TableSortHead|TableCell)[\s>/]/;
|
|
3022
3041
|
/** Add `width` to a TableHead/TableCell's opening tag, unless its template already declares one. */
|
|
3023
3042
|
function withWidth(code, w) {
|
|
3024
3043
|
if (!code) return code;
|
|
3025
3044
|
// A cell whose sizing says no width takes none: the placeholder is never left for the page to fill.
|
|
3026
|
-
if (w === null) return code.replace(/^(\s*<Table[A-Za-z]*\b[^>]*?)\swidth=\{(?:__s\d+_)?width\}/, "$1");
|
|
3045
|
+
if (w === null || !COLUMN_WIDTH_PART.test(code)) return code.replace(/^(\s*<Table[A-Za-z]*\b[^>]*?)\swidth=\{(?:__s\d+_)?width\}/, "$1");
|
|
3027
3046
|
const m = /^(\s*<Table[A-Za-z]*)([\s>/])/.exec(code);
|
|
3028
3047
|
if (!m) return code;
|
|
3029
3048
|
const tagEnd = code.indexOf(">", m[0].length - 1);
|