@pipelex/mthds-ui 0.39.0 → 0.40.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/README.md +3 -1
- package/dist/chunk-7JZBXBZS.js +258 -0
- package/dist/chunk-7JZBXBZS.js.map +1 -0
- package/dist/{chunk-AGFLCOWW.js → chunk-HPARBH6K.js} +14 -197
- package/dist/chunk-HPARBH6K.js.map +1 -0
- package/dist/chunk-N2F62MW7.js +55 -0
- package/dist/chunk-N2F62MW7.js.map +1 -0
- package/dist/chunk-P6IGZVWE.js +155 -0
- package/dist/chunk-P6IGZVWE.js.map +1 -0
- package/dist/chunk-RU3CIXFC.js +1251 -0
- package/dist/chunk-RU3CIXFC.js.map +1 -0
- package/dist/form/react/index.d.ts +1 -1
- package/dist/graph/index.d.ts +19 -3
- package/dist/graph/index.js +20 -12
- package/dist/graph/react/index.d.ts +13 -13
- package/dist/graph/react/index.js +387 -560
- package/dist/graph/react/index.js.map +1 -1
- package/dist/graph/react/viewer/GraphToolbar.css +2 -107
- package/dist/graph/react/viewer/StyleMenu.css +109 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +20 -12
- package/dist/registryJoin-C6Wfkik-.d.ts +441 -0
- package/dist/standalone/graph-standalone.html +171 -166
- package/dist/standalone/graph-viewer.css +74 -69
- package/dist/standalone/graph-viewer.js +97 -97
- package/dist/static-graph/index.d.ts +1 -1
- package/dist/timeline/index.d.ts +240 -77
- package/dist/timeline/index.js +61 -3
- package/dist/timeline/react/RunTimeline.css +48 -0
- package/dist/timeline/react/index.d.ts +46 -4
- package/dist/timeline/react/index.js +774 -105
- package/dist/timeline/react/index.js.map +1 -1
- package/dist/timeline/react/styles/simple/SimpleProgress.css +354 -0
- package/dist/{types-DsrzH6gM.d.ts → types-DLAnYNoi.d.ts} +1 -1
- package/package.json +3 -1
- package/dist/chunk-AGFLCOWW.js.map +0 -1
- package/dist/chunk-ILZJIORT.js +0 -54
- package/dist/chunk-ILZJIORT.js.map +0 -1
- package/dist/chunk-JJG2TO7P.js +0 -473
- package/dist/chunk-JJG2TO7P.js.map +0 -1
- package/dist/progressSnapshot-VZ4PLul9.d.ts +0 -191
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_GRAPH_CONFIG
|
|
3
|
+
} from "./chunk-ENRYQOCO.js";
|
|
4
|
+
import {
|
|
5
|
+
GRAPH_STYLE
|
|
6
|
+
} from "./chunk-4KLE62AN.js";
|
|
7
|
+
|
|
8
|
+
// src/graph/styles/graphStyles.ts
|
|
9
|
+
var GRAPH_STYLES = {
|
|
10
|
+
[GRAPH_STYLE.DETAILED]: {
|
|
11
|
+
id: GRAPH_STYLE.DETAILED,
|
|
12
|
+
name: "Detailed",
|
|
13
|
+
description: "Every pipe with its inputs, outputs and settings",
|
|
14
|
+
capabilities: { controllerFrameToggle: true, foldAll: true }
|
|
15
|
+
},
|
|
16
|
+
[GRAPH_STYLE.SIMPLE]: {
|
|
17
|
+
id: GRAPH_STYLE.SIMPLE,
|
|
18
|
+
name: "Simple",
|
|
19
|
+
description: "The method's steps in plain words",
|
|
20
|
+
capabilities: { controllerFrameToggle: false, foldAll: true },
|
|
21
|
+
layout: {
|
|
22
|
+
nodesep: 28,
|
|
23
|
+
ranksep: 44,
|
|
24
|
+
routeEdges: true,
|
|
25
|
+
groupPadding: { x: 20, top: 40, bottom: 16 }
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var GRAPH_STYLE_IDS = [GRAPH_STYLE.DETAILED, GRAPH_STYLE.SIMPLE];
|
|
30
|
+
function isGraphStyleId(value) {
|
|
31
|
+
return typeof value === "string" && Object.hasOwn(GRAPH_STYLES, value);
|
|
32
|
+
}
|
|
33
|
+
function resolveGraphStyle(styleProp, configStyle) {
|
|
34
|
+
if (isGraphStyleId(styleProp)) return styleProp;
|
|
35
|
+
if (isGraphStyleId(configStyle)) return configStyle;
|
|
36
|
+
return DEFAULT_GRAPH_CONFIG.graphStyle;
|
|
37
|
+
}
|
|
38
|
+
function resolveStyleMenu(styleMenu) {
|
|
39
|
+
if (styleMenu === void 0 || styleMenu === false) return [];
|
|
40
|
+
const requested = styleMenu === true ? GRAPH_STYLE_IDS : styleMenu;
|
|
41
|
+
const offered = [];
|
|
42
|
+
for (const id of requested) {
|
|
43
|
+
if (isGraphStyleId(id) && !offered.includes(id)) offered.push(id);
|
|
44
|
+
}
|
|
45
|
+
return offered.length >= 2 ? offered : [];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
GRAPH_STYLES,
|
|
50
|
+
GRAPH_STYLE_IDS,
|
|
51
|
+
isGraphStyleId,
|
|
52
|
+
resolveGraphStyle,
|
|
53
|
+
resolveStyleMenu
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=chunk-N2F62MW7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/graph/styles/graphStyles.ts"],"sourcesContent":["import type { GraphStyleId, LayoutConfig } from \"@graph/types\";\nimport { GRAPH_STYLE } from \"@graph/types\";\nimport { DEFAULT_GRAPH_CONFIG } from \"@graph/graphConfig\";\n\n// ─── The style registry ─────────────────────────────────────────────────────\n// A closed, typed table: adding a style is a new `GRAPH_STYLE` id, after which\n// the compiler names every table keyed by `GraphStyleId` that needs a row — the\n// descriptor below, the drawing pipeline (`stylePipelines.ts`), the node\n// components and the menu icon in the React layer.\n\n/** Which of the toolbar's controls make sense for a style. */\nexport interface GraphStyleCapabilities {\n /**\n * The toolbar's show/hide controllers toggle applies: the style draws\n * controller frames on demand. A style that decides its own frames hides it.\n */\n controllerFrameToggle: boolean;\n /**\n * Fold-all and expand-all apply. In a style that also has the frame toggle\n * they apply only while the frames are shown, since a fold is undone from a\n * frame.\n */\n foldAll: boolean;\n}\n\n/** What the registry says of one style: what it is called, what it is for, and what it supports. */\nexport interface GraphStyleDescriptor {\n id: GraphStyleId;\n /** The style's name in the toolbar menu. */\n name: string;\n /** One line saying what the style shows, under its name in the menu. */\n description: string;\n capabilities: GraphStyleCapabilities;\n /**\n * How the style lays out: its spacing, which replaces `config.nodesep` and\n * `config.ranksep` for it, the room its frames keep around their steps, and\n * whether its edges follow routes around the nodes in their way. A style\n * that leaves it undefined keeps the host's spacing and the controller\n * groups' padding, and draws free curves of the host's `edgeType`.\n */\n layout?: Required<LayoutConfig>;\n}\n\nexport const GRAPH_STYLES: Record<GraphStyleId, GraphStyleDescriptor> = {\n [GRAPH_STYLE.DETAILED]: {\n id: GRAPH_STYLE.DETAILED,\n name: \"Detailed\",\n description: \"Every pipe with its inputs, outputs and settings\",\n capabilities: { controllerFrameToggle: true, foldAll: true },\n },\n [GRAPH_STYLE.SIMPLE]: {\n id: GRAPH_STYLE.SIMPLE,\n name: \"Simple\",\n description: \"The method's steps in plain words\",\n capabilities: { controllerFrameToggle: false, foldAll: true },\n layout: {\n nodesep: 28,\n ranksep: 44,\n routeEdges: true,\n groupPadding: { x: 20, top: 40, bottom: 16 },\n },\n },\n};\n\n/** Every registered style, in the order the menu lists them. */\nexport const GRAPH_STYLE_IDS: readonly GraphStyleId[] = [GRAPH_STYLE.DETAILED, GRAPH_STYLE.SIMPLE];\n\n/**\n * Whether a value names a registered style. For values that cross an untyped\n * boundary — an editor setting, the standalone page's config embed, a host\n * written in plain JavaScript — before they reach the viewer.\n */\nexport function isGraphStyleId(value: unknown): value is GraphStyleId {\n return typeof value === \"string\" && Object.hasOwn(GRAPH_STYLES, value);\n}\n\n/**\n * Resolve the active style from `(graphStyle prop, config.graphStyle, default)`.\n * Pure + exported so the controlled/reactive precedence is unit-testable\n * without React, under the same contract `resolveExternalThemeMode` holds:\n * - the prop wins when it names a style,\n * - falls back to `config.graphStyle` when the prop is undefined (so a host can\n * hand control back to config after passing the prop),\n * - falls back to the library default (`detailed`) when neither is set.\n *\n * A value naming no registered style is treated as unset rather than thrown\n * on: a style is a preference, and a host relaying a setting written for a\n * newer version of this package should still get a graph.\n */\nexport function resolveGraphStyle(styleProp: unknown, configStyle: unknown): GraphStyleId {\n if (isGraphStyleId(styleProp)) return styleProp;\n if (isGraphStyleId(configStyle)) return configStyle;\n return DEFAULT_GRAPH_CONFIG.graphStyle;\n}\n\n/**\n * The styles the toolbar menu offers, from the viewer's `styleMenu` prop:\n * nothing for `false` or `undefined` (the menu is opt-in), every registered\n * style in registry order for `true`, and for a list the registered styles it\n * names, in its order and without repeats. A menu needs two styles to choose\n * between, so fewer than two offer none.\n */\nexport function resolveStyleMenu(\n styleMenu: boolean | readonly GraphStyleId[] | undefined,\n): GraphStyleId[] {\n if (styleMenu === undefined || styleMenu === false) return [];\n const requested: readonly unknown[] = styleMenu === true ? GRAPH_STYLE_IDS : styleMenu;\n const offered: GraphStyleId[] = [];\n for (const id of requested) {\n if (isGraphStyleId(id) && !offered.includes(id)) offered.push(id);\n }\n return offered.length >= 2 ? offered : [];\n}\n"],"mappings":";;;;;;;;AA2CO,IAAM,eAA2D;AAAA,EACtE,CAAC,YAAY,QAAQ,GAAG;AAAA,IACtB,IAAI,YAAY;AAAA,IAChB,MAAM;AAAA,IACN,aAAa;AAAA,IACb,cAAc,EAAE,uBAAuB,MAAM,SAAS,KAAK;AAAA,EAC7D;AAAA,EACA,CAAC,YAAY,MAAM,GAAG;AAAA,IACpB,IAAI,YAAY;AAAA,IAChB,MAAM;AAAA,IACN,aAAa;AAAA,IACb,cAAc,EAAE,uBAAuB,OAAO,SAAS,KAAK;AAAA,IAC5D,QAAQ;AAAA,MACN,SAAS;AAAA,MACT,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,cAAc,EAAE,GAAG,IAAI,KAAK,IAAI,QAAQ,GAAG;AAAA,IAC7C;AAAA,EACF;AACF;AAGO,IAAM,kBAA2C,CAAC,YAAY,UAAU,YAAY,MAAM;AAO1F,SAAS,eAAe,OAAuC;AACpE,SAAO,OAAO,UAAU,YAAY,OAAO,OAAO,cAAc,KAAK;AACvE;AAeO,SAAS,kBAAkB,WAAoB,aAAoC;AACxF,MAAI,eAAe,SAAS,EAAG,QAAO;AACtC,MAAI,eAAe,WAAW,EAAG,QAAO;AACxC,SAAO,qBAAqB;AAC9B;AASO,SAAS,iBACd,WACgB;AAChB,MAAI,cAAc,UAAa,cAAc,MAAO,QAAO,CAAC;AAC5D,QAAM,YAAgC,cAAc,OAAO,kBAAkB;AAC7E,QAAM,UAA0B,CAAC;AACjC,aAAW,MAAM,WAAW;AAC1B,QAAI,eAAe,EAAE,KAAK,CAAC,QAAQ,SAAS,EAAE,EAAG,SAAQ,KAAK,EAAE;AAAA,EAClE;AACA,SAAO,QAAQ,UAAU,IAAI,UAAU,CAAC;AAC1C;","names":[]}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// src/graph/styles/humanize.ts
|
|
2
|
+
var VOWELED_ACRONYMS = /* @__PURE__ */ new Set([
|
|
3
|
+
"ai",
|
|
4
|
+
"api",
|
|
5
|
+
"faq",
|
|
6
|
+
"iban",
|
|
7
|
+
"id",
|
|
8
|
+
"io",
|
|
9
|
+
"ip",
|
|
10
|
+
"json",
|
|
11
|
+
"kpi",
|
|
12
|
+
"ocr",
|
|
13
|
+
"roi",
|
|
14
|
+
"seo",
|
|
15
|
+
"ui",
|
|
16
|
+
"uri",
|
|
17
|
+
"url",
|
|
18
|
+
"uuid",
|
|
19
|
+
"ux"
|
|
20
|
+
]);
|
|
21
|
+
var VOWELS = /[aeiouy]/;
|
|
22
|
+
var VOWELLESS_WORDS = /* @__PURE__ */ new Set([
|
|
23
|
+
"cfg",
|
|
24
|
+
"cm",
|
|
25
|
+
"cnt",
|
|
26
|
+
"ctx",
|
|
27
|
+
"dr",
|
|
28
|
+
"dst",
|
|
29
|
+
"fn",
|
|
30
|
+
"ft",
|
|
31
|
+
"hmm",
|
|
32
|
+
"hr",
|
|
33
|
+
"kg",
|
|
34
|
+
"km",
|
|
35
|
+
"lb",
|
|
36
|
+
"mg",
|
|
37
|
+
"ml",
|
|
38
|
+
"mm",
|
|
39
|
+
"mr",
|
|
40
|
+
"mrs",
|
|
41
|
+
"ms",
|
|
42
|
+
"msg",
|
|
43
|
+
"nd",
|
|
44
|
+
"nth",
|
|
45
|
+
"pkg",
|
|
46
|
+
"pt",
|
|
47
|
+
"rd",
|
|
48
|
+
"src",
|
|
49
|
+
"st",
|
|
50
|
+
"th",
|
|
51
|
+
"tmp",
|
|
52
|
+
"vs"
|
|
53
|
+
]);
|
|
54
|
+
var SINGULAR_S_ACRONYMS = /* @__PURE__ */ new Set([
|
|
55
|
+
"cms",
|
|
56
|
+
"css",
|
|
57
|
+
"dns",
|
|
58
|
+
"gps",
|
|
59
|
+
"rss",
|
|
60
|
+
"sms"
|
|
61
|
+
]);
|
|
62
|
+
var NATIVE_PLAIN_NAMES = {
|
|
63
|
+
Html: "HTML",
|
|
64
|
+
JSON: "JSON",
|
|
65
|
+
TextAndImages: "Text and images",
|
|
66
|
+
YesNo: "Yes or no",
|
|
67
|
+
SearchResult: "Search result",
|
|
68
|
+
Composite: "Combined results",
|
|
69
|
+
Dynamic: "Data"
|
|
70
|
+
};
|
|
71
|
+
var GENERIC_NATIVES = /* @__PURE__ */ new Set(["Anything", "Dynamic", "Composite"]);
|
|
72
|
+
function isAcronymWord(lower) {
|
|
73
|
+
if (lower.length < 2 || !/^[a-z]+$/.test(lower)) return false;
|
|
74
|
+
if (VOWELLESS_WORDS.has(lower)) return false;
|
|
75
|
+
if (lower.endsWith("s") && VOWELLESS_WORDS.has(lower.slice(0, -1))) return false;
|
|
76
|
+
return !VOWELS.test(lower) || VOWELED_ACRONYMS.has(lower);
|
|
77
|
+
}
|
|
78
|
+
function spellWord(lower, wasAllCaps) {
|
|
79
|
+
if (/^\d+$/.test(lower)) return lower;
|
|
80
|
+
if (wasAllCaps && lower.length >= 2) return lower.toUpperCase();
|
|
81
|
+
if (lower.endsWith("s") && !SINGULAR_S_ACRONYMS.has(lower) && isAcronymWord(lower.slice(0, -1))) {
|
|
82
|
+
return lower.slice(0, -1).toUpperCase() + "s";
|
|
83
|
+
}
|
|
84
|
+
if (isAcronymWord(lower)) return lower.toUpperCase();
|
|
85
|
+
return lower;
|
|
86
|
+
}
|
|
87
|
+
function splitIdentifier(identifier) {
|
|
88
|
+
const parts = identifier.replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/([A-Za-z])(\d)/g, "$1 $2").split(/[\s_\-.]+/).filter((p) => p.length > 0);
|
|
89
|
+
return parts.map((p) => ({
|
|
90
|
+
word: p.toLowerCase(),
|
|
91
|
+
wasAllCaps: p.length >= 2 && p === p.toUpperCase() && /[A-Z]/.test(p)
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
function capitalizeFirst(text) {
|
|
95
|
+
return text.length === 0 ? text : text.charAt(0).toUpperCase() + text.slice(1);
|
|
96
|
+
}
|
|
97
|
+
function stripDomain(ref) {
|
|
98
|
+
const dot = ref.lastIndexOf(".");
|
|
99
|
+
return dot === -1 ? ref : ref.slice(dot + 1);
|
|
100
|
+
}
|
|
101
|
+
function humanizeIdentifier(identifier) {
|
|
102
|
+
const words = splitIdentifier(stripDomain(identifier.trim()));
|
|
103
|
+
if (words.length === 0) return "";
|
|
104
|
+
return capitalizeFirst(words.map((w) => spellWord(w.word, w.wasAllCaps)).join(" "));
|
|
105
|
+
}
|
|
106
|
+
function conceptPlainName(conceptRef) {
|
|
107
|
+
var _a;
|
|
108
|
+
const code = stripDomain(conceptRef.trim());
|
|
109
|
+
return (_a = NATIVE_PLAIN_NAMES[code]) != null ? _a : humanizeIdentifier(code);
|
|
110
|
+
}
|
|
111
|
+
function isGenericConcept(conceptRef) {
|
|
112
|
+
return GENERIC_NATIVES.has(stripDomain(conceptRef.trim()));
|
|
113
|
+
}
|
|
114
|
+
function sentenceCase(text) {
|
|
115
|
+
const collapsed = text.replace(/\s+/g, " ").trim();
|
|
116
|
+
const trimmed = collapsed.endsWith(".") && !collapsed.endsWith("..") ? collapsed.slice(0, -1) : collapsed;
|
|
117
|
+
return capitalizeFirst(trimmed);
|
|
118
|
+
}
|
|
119
|
+
function pipeTitle(description, pipeCode) {
|
|
120
|
+
const described = sentenceCase(description != null ? description : "");
|
|
121
|
+
if (described) return { title: described, fromDescription: true };
|
|
122
|
+
return { title: humanizeIdentifier(pipeCode), fromDescription: false };
|
|
123
|
+
}
|
|
124
|
+
function humanizeInSentence(identifier) {
|
|
125
|
+
var _a;
|
|
126
|
+
const words = humanizeIdentifier(identifier);
|
|
127
|
+
const first = (_a = words.split(" ")[0]) != null ? _a : "";
|
|
128
|
+
return first.length >= 2 && first === first.toUpperCase() ? words : words.charAt(0).toLowerCase() + words.slice(1);
|
|
129
|
+
}
|
|
130
|
+
var OUTCOME_WORDS = {
|
|
131
|
+
true: "Yes",
|
|
132
|
+
false: "No",
|
|
133
|
+
default: "Otherwise"
|
|
134
|
+
};
|
|
135
|
+
function outcomeLabel(outcome) {
|
|
136
|
+
const outcomes = outcome.split("|").map((o) => o.trim()).filter((o) => o.length > 0);
|
|
137
|
+
const labels = outcomes.map((o, index) => {
|
|
138
|
+
var _a;
|
|
139
|
+
const label = (_a = OUTCOME_WORDS[o.toLowerCase()]) != null ? _a : humanizeIdentifier(o);
|
|
140
|
+
return index === 0 ? label : label.charAt(0).toLowerCase() + label.slice(1);
|
|
141
|
+
});
|
|
142
|
+
return labels.join(" or ");
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export {
|
|
146
|
+
stripDomain,
|
|
147
|
+
humanizeIdentifier,
|
|
148
|
+
conceptPlainName,
|
|
149
|
+
isGenericConcept,
|
|
150
|
+
sentenceCase,
|
|
151
|
+
pipeTitle,
|
|
152
|
+
humanizeInSentence,
|
|
153
|
+
outcomeLabel
|
|
154
|
+
};
|
|
155
|
+
//# sourceMappingURL=chunk-P6IGZVWE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/graph/styles/humanize.ts"],"sourcesContent":["// Plain words from identifiers: the simple style's fallback when a method\n// declares nothing better. Pure, deterministic and tested — never a stand-in\n// for an authored description, and never a guess at meaning: an identifier is\n// split, cased and spelled, nothing more.\n\n/**\n * Words spelled as acronyms although they hold a vowel. A word with no vowel at\n * all (`cv`, `pdf`, `rfp`, `html`) is spelled as an acronym without being\n * listed, unless it is one of the `VOWELLESS_WORDS`.\n */\nconst VOWELED_ACRONYMS: ReadonlySet<string> = new Set([\n \"ai\",\n \"api\",\n \"faq\",\n \"iban\",\n \"id\",\n \"io\",\n \"ip\",\n \"json\",\n \"kpi\",\n \"ocr\",\n \"roi\",\n \"seo\",\n \"ui\",\n \"uri\",\n \"url\",\n \"uuid\",\n \"ux\",\n]);\n\nconst VOWELS = /[aeiouy]/;\n\n/**\n * Words with no vowel that are written in lowercase rather than spelled out:\n * abbreviations, units and ordinal suffixes found in identifiers (`weight_kg`\n * is \"Weight kg\", `nth_item` is \"Nth item\"). A plural is covered by its\n * singular (`hrs` by `hr`).\n */\nconst VOWELLESS_WORDS: ReadonlySet<string> = new Set([\n \"cfg\",\n \"cm\",\n \"cnt\",\n \"ctx\",\n \"dr\",\n \"dst\",\n \"fn\",\n \"ft\",\n \"hmm\",\n \"hr\",\n \"kg\",\n \"km\",\n \"lb\",\n \"mg\",\n \"ml\",\n \"mm\",\n \"mr\",\n \"mrs\",\n \"ms\",\n \"msg\",\n \"nd\",\n \"nth\",\n \"pkg\",\n \"pt\",\n \"rd\",\n \"src\",\n \"st\",\n \"th\",\n \"tmp\",\n \"vs\",\n]);\n\n/** Vowelless acronyms that end in `s` without being plurals (`css` is not two `cs`). */\nconst SINGULAR_S_ACRONYMS: ReadonlySet<string> = new Set([\n \"cms\",\n \"css\",\n \"dns\",\n \"gps\",\n \"rss\",\n \"sms\",\n]);\n\n/**\n * The plain names of the natives whose code does not read as words once split\n * (`YesNo` is not \"Yes no\"). Every other native reads well humanized.\n */\nconst NATIVE_PLAIN_NAMES: Readonly<Record<string, string>> = {\n Html: \"HTML\",\n JSON: \"JSON\",\n TextAndImages: \"Text and images\",\n YesNo: \"Yes or no\",\n SearchResult: \"Search result\",\n Composite: \"Combined results\",\n Dynamic: \"Data\",\n};\n\n/**\n * Natives that say what kind of value something is without saying what it is:\n * a final output of one of these is named by its variable, not its concept.\n */\nconst GENERIC_NATIVES: ReadonlySet<string> = new Set([\"Anything\", \"Dynamic\", \"Composite\"]);\n\nfunction isAcronymWord(lower: string): boolean {\n if (lower.length < 2 || !/^[a-z]+$/.test(lower)) return false;\n if (VOWELLESS_WORDS.has(lower)) return false;\n if (lower.endsWith(\"s\") && VOWELLESS_WORDS.has(lower.slice(0, -1))) return false;\n return !VOWELS.test(lower) || VOWELED_ACRONYMS.has(lower);\n}\n\n/** Spell one lowercase word: an acronym in capitals (a plural keeps its `s`), anything else as is. */\nfunction spellWord(lower: string, wasAllCaps: boolean): string {\n if (/^\\d+$/.test(lower)) return lower;\n if (wasAllCaps && lower.length >= 2) return lower.toUpperCase();\n // A plural acronym keeps its lowercase `s`: `cvs` is \"CVs\", not \"CVS\".\n if (lower.endsWith(\"s\") && !SINGULAR_S_ACRONYMS.has(lower) && isAcronymWord(lower.slice(0, -1))) {\n return lower.slice(0, -1).toUpperCase() + \"s\";\n }\n if (isAcronymWord(lower)) return lower.toUpperCase();\n return lower;\n}\n\n/**\n * Split an identifier into its words: on `_`, `-`, `.` and spaces, and at the\n * case boundaries of camel and Pascal case, keeping a run of capitals together\n * (`PDFDocument` is `PDF` and `Document`).\n */\nfunction splitIdentifier(identifier: string): { word: string; wasAllCaps: boolean }[] {\n const parts = identifier\n .replace(/([a-z\\d])([A-Z])/g, \"$1 $2\")\n .replace(/([A-Z]+)([A-Z][a-z])/g, \"$1 $2\")\n .replace(/([A-Za-z])(\\d)/g, \"$1 $2\")\n .split(/[\\s_\\-.]+/)\n .filter((p) => p.length > 0);\n return parts.map((p) => ({\n word: p.toLowerCase(),\n wasAllCaps: p.length >= 2 && p === p.toUpperCase() && /[A-Z]/.test(p),\n }));\n}\n\n/** Capitalize the first letter, leaving the rest as written. */\nfunction capitalizeFirst(text: string): string {\n return text.length === 0 ? text : text.charAt(0).toUpperCase() + text.slice(1);\n}\n\n/** The last segment of a dotted ref: the code without its domain (`recruitment.CandidateProfile` → `CandidateProfile`). */\nexport function stripDomain(ref: string): string {\n const dot = ref.lastIndexOf(\".\");\n return dot === -1 ? ref : ref.slice(dot + 1);\n}\n\n/**\n * An identifier as words in sentence case: `job_offer` → \"Job offer\",\n * `CandidateProfile` → \"Candidate profile\", `pr_url` → \"PR URL\",\n * `cvs` → \"CVs\". A dotted ref is humanized by its last segment.\n */\nexport function humanizeIdentifier(identifier: string): string {\n const words = splitIdentifier(stripDomain(identifier.trim()));\n if (words.length === 0) return \"\";\n return capitalizeFirst(words.map((w) => spellWord(w.word, w.wasAllCaps)).join(\" \"));\n}\n\n/** A concept's plain name, from its code or ref: a native's own plain name, or the humanized code. */\nexport function conceptPlainName(conceptRef: string): string {\n const code = stripDomain(conceptRef.trim());\n return NATIVE_PLAIN_NAMES[code] ?? humanizeIdentifier(code);\n}\n\n/** Whether a concept is a native that names no particular kind of content (`Anything`, `Dynamic`, `Composite`). */\nexport function isGenericConcept(conceptRef: string): boolean {\n return GENERIC_NATIVES.has(stripDomain(conceptRef.trim()));\n}\n\n/**\n * Authored text as a title: whitespace collapsed (descriptions are often\n * written across lines), the first letter capitalized, and a single closing\n * period dropped, since a label in a box reads as a heading. Nothing else is\n * touched: the words are the author's.\n */\nexport function sentenceCase(text: string): string {\n const collapsed = text.replace(/\\s+/g, \" \").trim();\n const trimmed =\n collapsed.endsWith(\".\") && !collapsed.endsWith(\"..\") ? collapsed.slice(0, -1) : collapsed;\n return capitalizeFirst(trimmed);\n}\n\n/**\n * A pipe's title in plain words: its authored description as a title\n * (`sentenceCase`), or its humanized code when it has none. The simple graph\n * style titles its steps this way, and the simple timeline style its lines, so\n * a step reads the same in both. `fromDescription` says which it was.\n */\nexport function pipeTitle(\n description: string | null | undefined,\n pipeCode: string,\n): { title: string; fromDescription: boolean } {\n const described = sentenceCase(description ?? \"\");\n if (described) return { title: described, fromDescription: true };\n return { title: humanizeIdentifier(pipeCode), fromDescription: false };\n}\n\n/**\n * An identifier as words inside a sentence: `humanizeIdentifier`'s words with\n * their first letter in lower case, unless the first word is an acronym\n * (`filing` → \"filing\", `cv_file` → \"CV file\").\n */\nexport function humanizeInSentence(identifier: string): string {\n const words = humanizeIdentifier(identifier);\n const first = words.split(\" \")[0] ?? \"\";\n return first.length >= 2 && first === first.toUpperCase()\n ? words\n : words.charAt(0).toLowerCase() + words.slice(1);\n}\n\n/** The outcome names that read better as other words: a yes-or-no test's, and the default. */\nconst OUTCOME_WORDS: Readonly<Record<string, string>> = {\n true: \"Yes\",\n false: \"No\",\n default: \"Otherwise\",\n};\n\n/**\n * A condition's outcome as an arrow label: `english` → \"English\",\n * `high_priority` → \"High priority\", a yes-or-no test's `true` and `false` →\n * \"Yes\" and \"No\", and the `default` outcome → \"Otherwise\". A branch taken on\n * several outcomes, written `no_fit | default` as the static builder labels it,\n * reads \"No fit or otherwise\".\n */\nexport function outcomeLabel(outcome: string): string {\n const outcomes = outcome\n .split(\"|\")\n .map((o) => o.trim())\n .filter((o) => o.length > 0);\n const labels = outcomes.map((o, index) => {\n const label = OUTCOME_WORDS[o.toLowerCase()] ?? humanizeIdentifier(o);\n return index === 0 ? label : label.charAt(0).toLowerCase() + label.slice(1);\n });\n return labels.join(\" or \");\n}\n"],"mappings":";AAUA,IAAM,mBAAwC,oBAAI,IAAI;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,SAAS;AAQf,IAAM,kBAAuC,oBAAI,IAAI;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA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