@dogsbay/format-fluidtopics-rest 0.2.0-beta.101
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 +87 -0
- package/dist/assets.d.ts +13 -0
- package/dist/assets.d.ts.map +1 -0
- package/dist/assets.js +53 -0
- package/dist/assets.js.map +1 -0
- package/dist/cli.d.ts +9 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +28 -0
- package/dist/cli.js.map +1 -0
- package/dist/frontmatter.d.ts +36 -0
- package/dist/frontmatter.d.ts.map +1 -0
- package/dist/frontmatter.js +78 -0
- package/dist/frontmatter.js.map +1 -0
- package/dist/headings.d.ts +13 -0
- package/dist/headings.d.ts.map +1 -0
- package/dist/headings.js +76 -0
- package/dist/headings.js.map +1 -0
- package/dist/html-to-tree.d.ts +17 -0
- package/dist/html-to-tree.d.ts.map +1 -0
- package/dist/html-to-tree.js +309 -0
- package/dist/html-to-tree.js.map +1 -0
- package/dist/importer.d.ts +87 -0
- package/dist/importer.d.ts.map +1 -0
- package/dist/importer.js +354 -0
- package/dist/importer.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/inline-html.d.ts +52 -0
- package/dist/inline-html.d.ts.map +1 -0
- package/dist/inline-html.js +157 -0
- package/dist/inline-html.js.map +1 -0
- package/dist/khub.d.ts +86 -0
- package/dist/khub.d.ts.map +1 -0
- package/dist/khub.js +111 -0
- package/dist/khub.js.map +1 -0
- package/dist/links.d.ts +13 -0
- package/dist/links.d.ts.map +1 -0
- package/dist/links.js +55 -0
- package/dist/links.js.map +1 -0
- package/dist/nav.d.ts +7 -0
- package/dist/nav.d.ts.map +1 -0
- package/dist/nav.js +15 -0
- package/dist/nav.js.map +1 -0
- package/dist/single-page.d.ts +70 -0
- package/dist/single-page.d.ts.map +1 -0
- package/dist/single-page.js +77 -0
- package/dist/single-page.js.map +1 -0
- package/dist/tree.d.ts +2 -0
- package/dist/tree.d.ts.map +1 -0
- package/dist/tree.js +2 -0
- package/dist/tree.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a DITA-OT **HTML5** topic (as served by FT's khub `…/content`
|
|
3
|
+
* endpoint) into Dogsbay TreeNode[].
|
|
4
|
+
*
|
|
5
|
+
* DITA-OT's HTML5 transtype preserves the DITA element vocabulary in `class`
|
|
6
|
+
* names, so the conversion is deterministic:
|
|
7
|
+
* div.body.conbody|taskbody|refbody → topic type (concept/task/reference)
|
|
8
|
+
* p.shortdesc / p.p / p → paragraph
|
|
9
|
+
* section.section + h2.sectiontitle → flattened to heading + content
|
|
10
|
+
* table.table (CALS) → table/thead/tbody/tr/th/td
|
|
11
|
+
* ul/ol/li, dl/dt/dd, pre/codeblock, note → lists / deflists / code / callout
|
|
12
|
+
* span.ph etc. → inline (see inline-html.ts)
|
|
13
|
+
* FT chrome (zDocs*, ai-summary, toggle/summary/tooltip, css-…) is stripped.
|
|
14
|
+
*/
|
|
15
|
+
import { load } from "cheerio";
|
|
16
|
+
import { inlineFromChildren, textContent } from "./inline-html.js";
|
|
17
|
+
const CHROME_CLASS = /\b(zDocs[\w-]*|ai-summary[\w-]*|summarize[\w-]*|summary-[\w-]*|toggle-[\w-]*|tooltip[\w-]*|disclaimer[\w-]*|sparkle[\w-]*|info-icon|info-tooltip[\w-]*|table--title-label|spacer)\b/;
|
|
18
|
+
const SKIP_TAGS = new Set(["script", "style", "svg", "button", "nav", "head", "noscript"]);
|
|
19
|
+
/** Block-level tags — a list item containing any of these is walked as blocks. */
|
|
20
|
+
const BLOCK_TAGS = new Set([
|
|
21
|
+
"p", "ul", "ol", "dl", "table", "pre", "div", "section", "figure", "fig", "blockquote",
|
|
22
|
+
"h1", "h2", "h3", "h4", "h5", "h6", "note",
|
|
23
|
+
]);
|
|
24
|
+
export function htmlToTree(html, opts = {}) {
|
|
25
|
+
const $ = load(html);
|
|
26
|
+
const title = $("h1.topictitle1").first().text().trim() || $("h1").first().text().trim() || undefined;
|
|
27
|
+
const bodyEl = ($("div.body").get(0) ?? $("article").get(0) ?? $("main").get(0) ?? $("body").get(0));
|
|
28
|
+
const topicType = bodyTypeFrom(bodyEl);
|
|
29
|
+
const tree = bodyEl ? walkBlocks(bodyEl.children ?? [], opts) : [];
|
|
30
|
+
return { tree, title, topicType };
|
|
31
|
+
}
|
|
32
|
+
function bodyTypeFrom(el) {
|
|
33
|
+
const cls = el?.attribs?.class ?? "";
|
|
34
|
+
if (/\bconbody\b/.test(cls))
|
|
35
|
+
return "concept";
|
|
36
|
+
if (/\btaskbody\b/.test(cls))
|
|
37
|
+
return "task";
|
|
38
|
+
if (/\b(refbody|reference)\b/.test(cls))
|
|
39
|
+
return "reference";
|
|
40
|
+
if (/\bglossbody\b/.test(cls))
|
|
41
|
+
return "glossentry";
|
|
42
|
+
return "topic";
|
|
43
|
+
}
|
|
44
|
+
function isChrome(n) {
|
|
45
|
+
const name = (n.name ?? "").toLowerCase();
|
|
46
|
+
if (SKIP_TAGS.has(name))
|
|
47
|
+
return true;
|
|
48
|
+
const cls = n.attribs?.class ?? "";
|
|
49
|
+
if (name === "details" && /ai-summary/.test(cls))
|
|
50
|
+
return true;
|
|
51
|
+
if (CHROME_CLASS.test(cls))
|
|
52
|
+
return true;
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
/** An element is "inline" if it isn't a block tag or a heading. */
|
|
56
|
+
function isInline(name) {
|
|
57
|
+
return !BLOCK_TAGS.has(name) && !/^h[1-6]$/.test(name);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Extract a YouTube video id from an embed/watch/short URL, else undefined.
|
|
61
|
+
* Handles youtube.com/embed/<id>, youtube-nocookie.com/embed/<id>,
|
|
62
|
+
* youtu.be/<id>, and watch?v=<id>.
|
|
63
|
+
*/
|
|
64
|
+
export function youtubeIdFromUrl(url) {
|
|
65
|
+
const m = url.match(/(?:youtube(?:-nocookie)?\.com\/embed\/|youtu\.be\/|youtube\.com\/watch\?(?:[^"]*&)?v=)([\w-]{6,})/);
|
|
66
|
+
return m?.[1];
|
|
67
|
+
}
|
|
68
|
+
function walkBlocks(nodes, opts) {
|
|
69
|
+
const out = [];
|
|
70
|
+
// Accumulate consecutive inline-level children (text, spans, xref spans,
|
|
71
|
+
// <a>, <img>, emphasis…) and flush them as ONE paragraph via the inline
|
|
72
|
+
// walker — so a mixed-content block (e.g. an <li> with "Updated the <xref>
|
|
73
|
+
// section:" followed by a nested <ul>) keeps its prose together and its
|
|
74
|
+
// xref spans resolve to links, instead of fragmenting into one-word paragraphs.
|
|
75
|
+
let buf = [];
|
|
76
|
+
const flush = () => {
|
|
77
|
+
if (buf.length === 0)
|
|
78
|
+
return;
|
|
79
|
+
const inline = inlineFromChildren(buf, opts);
|
|
80
|
+
buf = [];
|
|
81
|
+
if (inline.length)
|
|
82
|
+
out.push(paragraph(inline));
|
|
83
|
+
};
|
|
84
|
+
for (const n of nodes) {
|
|
85
|
+
if (n.type === "text") {
|
|
86
|
+
buf.push(n);
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (n.type !== "tag")
|
|
90
|
+
continue;
|
|
91
|
+
if (isChrome(n))
|
|
92
|
+
continue;
|
|
93
|
+
const name = (n.name ?? "").toLowerCase();
|
|
94
|
+
const cls = n.attribs?.class ?? "";
|
|
95
|
+
// Video embed → a `youtube` node. FT embeds training videos as
|
|
96
|
+
// `<iframe src="…youtube(-nocookie).com/embed/<id>…">`. The default walker
|
|
97
|
+
// classifies the iframe as inline and drops it (no inline rep), losing the
|
|
98
|
+
// video entirely (e.g. the FT101 lessons). Intercept before the inline gate.
|
|
99
|
+
if (name === "iframe") {
|
|
100
|
+
const id = youtubeIdFromUrl(n.attribs?.src ?? "");
|
|
101
|
+
if (id) {
|
|
102
|
+
flush();
|
|
103
|
+
const title = (n.attribs?.title ?? "").trim();
|
|
104
|
+
out.push({ type: "youtube", props: title ? { id, title } : { id } });
|
|
105
|
+
}
|
|
106
|
+
// Non-YouTube iframes are dropped (no safe generic embed); revisit if a
|
|
107
|
+
// portal uses Vimeo/Wistia etc.
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
// Inline element (incl. <img>, xref spans) → accumulate into the run.
|
|
111
|
+
if (isInline(name)) {
|
|
112
|
+
buf.push(n);
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
// Block element → flush the pending inline run, then handle the block.
|
|
116
|
+
flush();
|
|
117
|
+
const hm = /^h([1-6])$/.exec(name);
|
|
118
|
+
if (hm) {
|
|
119
|
+
out.push({
|
|
120
|
+
type: "heading",
|
|
121
|
+
props: { level: Number(hm[1]) },
|
|
122
|
+
children: [{ type: "prose", inline: inlineFromChildren(n.children, opts) }],
|
|
123
|
+
});
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
switch (name) {
|
|
127
|
+
case "p": {
|
|
128
|
+
const inline = inlineFromChildren(n.children, opts);
|
|
129
|
+
if (inline.length)
|
|
130
|
+
out.push(paragraph(inline));
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
case "section":
|
|
134
|
+
case "div": {
|
|
135
|
+
if (/\bnote\b/.test(cls)) {
|
|
136
|
+
out.push({
|
|
137
|
+
type: "callout",
|
|
138
|
+
props: { variant: noteVariant(cls) },
|
|
139
|
+
children: walkBlocks(n.children ?? [], opts),
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
// section.section, div.p wrapper, fig wrapper, generic div → unwrap
|
|
144
|
+
out.push(...walkBlocks(n.children ?? [], opts));
|
|
145
|
+
}
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
case "ul":
|
|
149
|
+
case "ol": {
|
|
150
|
+
const items = (n.children ?? [])
|
|
151
|
+
.filter((c) => c.type === "tag" && (c.name ?? "").toLowerCase() === "li")
|
|
152
|
+
.map((li) => {
|
|
153
|
+
// Inline-only <li> → one tight prose item; <li> with block children
|
|
154
|
+
// (e.g. a nested list) → walk as blocks (inline runs coalesce there too).
|
|
155
|
+
const hasBlock = (li.children ?? []).some((c) => c.type === "tag" && BLOCK_TAGS.has((c.name ?? "").toLowerCase()));
|
|
156
|
+
const children = hasBlock
|
|
157
|
+
? walkBlocks(li.children ?? [], opts)
|
|
158
|
+
: [{ type: "prose", inline: inlineFromChildren(li.children, opts) }];
|
|
159
|
+
return { type: "list-item", children };
|
|
160
|
+
});
|
|
161
|
+
out.push({ type: name === "ol" ? "ordered-list" : "unordered-list", children: items });
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
case "dl": {
|
|
165
|
+
const children = [];
|
|
166
|
+
for (const c of n.children ?? []) {
|
|
167
|
+
const cn = (c.name ?? "").toLowerCase();
|
|
168
|
+
// Canonical dt shape is inline-on-the-node (matches the parser +
|
|
169
|
+
// renderDeflist, which reads dt.inline); dd carries block children.
|
|
170
|
+
if (cn === "dt")
|
|
171
|
+
children.push({ type: "dt", inline: inlineFromChildren(c.children, opts) });
|
|
172
|
+
else if (cn === "dd")
|
|
173
|
+
children.push({ type: "dd", children: walkBlocks(c.children ?? [], opts) });
|
|
174
|
+
}
|
|
175
|
+
out.push({ type: "deflist", children });
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
case "pre": {
|
|
179
|
+
out.push({ type: "code", props: { code: rawText(n), lang: langFrom(cls) } });
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
case "table": {
|
|
183
|
+
out.push(convertTable(n, opts));
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
case "figure":
|
|
187
|
+
case "fig":
|
|
188
|
+
default:
|
|
189
|
+
out.push(...walkBlocks(n.children ?? [], opts));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
flush();
|
|
193
|
+
return out;
|
|
194
|
+
}
|
|
195
|
+
function convertTable(t, opts) {
|
|
196
|
+
const caption = findFirst(t, "caption");
|
|
197
|
+
const children = [];
|
|
198
|
+
const section = (name) => {
|
|
199
|
+
const sec = findFirst(t, name);
|
|
200
|
+
if (!sec)
|
|
201
|
+
return null;
|
|
202
|
+
const rows = childrenNamed(sec, "tr").map((tr) => ({
|
|
203
|
+
type: "tr",
|
|
204
|
+
children: childrenNamed(tr, name === "thead" ? "th" : "td", true).map((cell) => {
|
|
205
|
+
const node = {
|
|
206
|
+
type: name === "thead" ? "th" : "td",
|
|
207
|
+
// Cells can hold block content (lists, multiple paragraphs) — walk as
|
|
208
|
+
// blocks when present so structure survives; else a single prose run.
|
|
209
|
+
children: cellChildren(cell, opts),
|
|
210
|
+
};
|
|
211
|
+
// Carry CALS spans (DITA-OT emits them as HTML colspan/rowspan) so the
|
|
212
|
+
// serializer can emit a spanning HTML table — otherwise every cell
|
|
213
|
+
// below a row-spanned cell shifts into the wrong column.
|
|
214
|
+
const spans = cellSpans(cell);
|
|
215
|
+
if (spans)
|
|
216
|
+
node.props = spans;
|
|
217
|
+
return node;
|
|
218
|
+
}),
|
|
219
|
+
}));
|
|
220
|
+
return rows.length ? { type: name, children: rows } : null;
|
|
221
|
+
};
|
|
222
|
+
const thead = section("thead");
|
|
223
|
+
const tbody = section("tbody");
|
|
224
|
+
if (thead)
|
|
225
|
+
children.push(thead);
|
|
226
|
+
if (tbody)
|
|
227
|
+
children.push(tbody);
|
|
228
|
+
const node = { type: "table", children };
|
|
229
|
+
if (caption) {
|
|
230
|
+
const cap = textContent(caption);
|
|
231
|
+
if (cap)
|
|
232
|
+
node.props = { caption: cap };
|
|
233
|
+
}
|
|
234
|
+
return node;
|
|
235
|
+
}
|
|
236
|
+
// ── helpers ─────────────────────────────────────────────
|
|
237
|
+
/** Read a cell's colspan/rowspan into TreeNode props (only when > 1). */
|
|
238
|
+
function cellSpans(cell) {
|
|
239
|
+
const cs = parseInt(cell.attribs?.colspan ?? "", 10);
|
|
240
|
+
const rs = parseInt(cell.attribs?.rowspan ?? "", 10);
|
|
241
|
+
const props = {};
|
|
242
|
+
if (Number.isFinite(cs) && cs > 1)
|
|
243
|
+
props.colspan = cs;
|
|
244
|
+
if (Number.isFinite(rs) && rs > 1)
|
|
245
|
+
props.rowspan = rs;
|
|
246
|
+
return Object.keys(props).length ? props : undefined;
|
|
247
|
+
}
|
|
248
|
+
/** Cell content: block-walk when it has block children (lists, paragraphs), else inline. */
|
|
249
|
+
function cellChildren(cell, opts) {
|
|
250
|
+
const hasBlock = (cell.children ?? []).some((c) => c.type === "tag" && BLOCK_TAGS.has((c.name ?? "").toLowerCase()));
|
|
251
|
+
return hasBlock
|
|
252
|
+
? walkBlocks(cell.children ?? [], opts)
|
|
253
|
+
: [{ type: "prose", inline: inlineFromChildren(cell.children, opts) }];
|
|
254
|
+
}
|
|
255
|
+
function paragraph(inline) {
|
|
256
|
+
return { type: "paragraph", children: [{ type: "prose", inline }] };
|
|
257
|
+
}
|
|
258
|
+
function noteVariant(cls) {
|
|
259
|
+
const m = /\bnote_(\w+)\b/.exec(cls) || /\b(warning|caution|danger|tip|important|note)\b/.exec(cls);
|
|
260
|
+
return m ? (m[1] === "note" ? "note" : m[1]) : "note";
|
|
261
|
+
}
|
|
262
|
+
function langFrom(cls) {
|
|
263
|
+
const m = /\blanguage-([\w+-]+)\b/.exec(cls);
|
|
264
|
+
return m ? m[1] : undefined;
|
|
265
|
+
}
|
|
266
|
+
/** Raw text (no whitespace collapse) — for code blocks. */
|
|
267
|
+
function rawText(n) {
|
|
268
|
+
let s = "";
|
|
269
|
+
const rec = (nodes) => {
|
|
270
|
+
for (const c of nodes) {
|
|
271
|
+
if (c.type === "text")
|
|
272
|
+
s += c.data ?? "";
|
|
273
|
+
else if (c.children)
|
|
274
|
+
rec(c.children);
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
rec(n.children ?? []);
|
|
278
|
+
return s.replace(/^\n+|\s+$/g, "");
|
|
279
|
+
}
|
|
280
|
+
/** First descendant element with the given tag name. */
|
|
281
|
+
function findFirst(n, name) {
|
|
282
|
+
for (const c of n.children ?? []) {
|
|
283
|
+
if (c.type === "tag") {
|
|
284
|
+
if ((c.name ?? "").toLowerCase() === name)
|
|
285
|
+
return c;
|
|
286
|
+
const deep = findFirst(c, name);
|
|
287
|
+
if (deep)
|
|
288
|
+
return deep;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return undefined;
|
|
292
|
+
}
|
|
293
|
+
/** Direct (or near) child elements with the given tag name. `deep` searches descendants. */
|
|
294
|
+
function childrenNamed(n, name, deep = false) {
|
|
295
|
+
const out = [];
|
|
296
|
+
const scan = (nodes) => {
|
|
297
|
+
for (const c of nodes) {
|
|
298
|
+
if (c.type !== "tag")
|
|
299
|
+
continue;
|
|
300
|
+
if ((c.name ?? "").toLowerCase() === name)
|
|
301
|
+
out.push(c);
|
|
302
|
+
else if (deep && c.children)
|
|
303
|
+
scan(c.children);
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
scan(n.children ?? []);
|
|
307
|
+
return out;
|
|
308
|
+
}
|
|
309
|
+
//# sourceMappingURL=html-to-tree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html-to-tree.js","sourceRoot":"","sources":["../src/html-to-tree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAoC,MAAM,kBAAkB,CAAC;AAUrG,MAAM,YAAY,GAChB,qLAAqL,CAAC;AACxL,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;AAC3F,kFAAkF;AAClF,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IACzB,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE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;QACxB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AACD,4FAA4F;AAC5F,SAAS,aAAa,CAAC,CAAU,EAAE,IAAY,EAAE,IAAI,GAAG,KAAK;IAC3D,MAAM,GAAG,GAAc,EAAE,CAAC;IAC1B,MAAM,IAAI,GAAG,CAAC,KAAgB,EAAE,EAAE;QAChC,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;YACtB,IAAI,CAAC,CAAC,IAAI,KAAK,KAAK;gBAAE,SAAS;YAC/B,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,KAAK,IAAI;gBAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;iBAClD,IAAI,IAAI,IAAI,CAAC,CAAC,QAAQ;gBAAE,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;QAChD,CAAC;IACH,CAAC,CAAC;IACF,IAAI,CAAC,CAAC,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;IACvB,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fluid Topics REST importer.
|
|
3
|
+
*
|
|
4
|
+
* Harvests a live FT portal via the khub API and reverse-engineers each topic's
|
|
5
|
+
* DITA-OT HTML5 into Dogsbay TreeNode[] — producing ExportPage[] + NavItem[].
|
|
6
|
+
* Works on any *public* FT portal (ServiceNow, Johnson Controls /bas, FT's own
|
|
7
|
+
* docs); gated portals throw KhubAuthError.
|
|
8
|
+
*/
|
|
9
|
+
import type { ExportPage, NavItem } from "@dogsbay/types";
|
|
10
|
+
import { KhubClient } from "./khub.js";
|
|
11
|
+
export interface RestImportOptions {
|
|
12
|
+
/** Portal root or `…/api/khub` URL (ignored if `client` is given). */
|
|
13
|
+
portalBase?: string;
|
|
14
|
+
/** Inject a client (tests). */
|
|
15
|
+
client?: KhubClient;
|
|
16
|
+
/** Limit to these map ids; else import every map the portal lists. */
|
|
17
|
+
maps?: string[];
|
|
18
|
+
/** Filter listed maps by case-insensitive title substring. */
|
|
19
|
+
titleFilter?: string;
|
|
20
|
+
lang?: string;
|
|
21
|
+
hrefPrefix?: string;
|
|
22
|
+
throttleMs?: number;
|
|
23
|
+
fetchImpl?: typeof fetch;
|
|
24
|
+
taxonomyNames?: readonly string[];
|
|
25
|
+
onProgress?: (msg: string) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Roll each map into ONE page (whole book) instead of one page per topic.
|
|
28
|
+
* TOC nodes become nested headings; internal xrefs become in-page anchors.
|
|
29
|
+
*/
|
|
30
|
+
singlePage?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Group the (otherwise flat) per-map nav under one or more metadata facets —
|
|
33
|
+
* the khub `/maps` list carries faceted metadata (`Category`, `Product`,
|
|
34
|
+
* `audience`, …). Comma-separated for multi-level (e.g. "Product,Category").
|
|
35
|
+
* - undefined → AUTO: group by `Category` (then `Product`) when it's present
|
|
36
|
+
* on most maps with >1 distinct value; else stay flat.
|
|
37
|
+
* - "none" / "flat" / "" → force flat (one top-level item per map).
|
|
38
|
+
*/
|
|
39
|
+
groupBy?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Mark book-type maps (metadata `ft:editorialType === "book"`) with the
|
|
42
|
+
* granularity `single-page: yes` nav annotation, so the build emits an
|
|
43
|
+
* additive "Read as single page" rollup for each multi-topic guide while
|
|
44
|
+
* single-topic articles (Screencasts, At a Glance) stay per-topic. The
|
|
45
|
+
* build-time size cap skips any rollup that's too large. Composes with
|
|
46
|
+
* `groupBy`. (This is the additive-view annotation, NOT the import-time
|
|
47
|
+
* whole-book `singlePage` mode above.)
|
|
48
|
+
*/
|
|
49
|
+
singlePageBooks?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* FT khubs often carry stale duplicate publications: the same guide published
|
|
52
|
+
* more than once with the same title + version, distinguished only by
|
|
53
|
+
* `ft:lastEdition`. They slug identically, so their pages collapse (last-wins)
|
|
54
|
+
* but the nav gets one entry per map → visible duplicate guides. By default we
|
|
55
|
+
* keep only the freshest edition per (title, Version_FT). Set this to keep all
|
|
56
|
+
* maps (no dedup).
|
|
57
|
+
*/
|
|
58
|
+
keepDuplicateMaps?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Extra FT topic-metadata keys to lift into page frontmatter verbatim, beyond
|
|
61
|
+
* the curated set (subject/product/author/category/audience/version/…). The
|
|
62
|
+
* importer fetches per-topic metadata from `/maps/{id}/topics` (one request
|
|
63
|
+
* per map) regardless; this only widens which keys are kept.
|
|
64
|
+
*/
|
|
65
|
+
metadataAllow?: readonly string[];
|
|
66
|
+
/**
|
|
67
|
+
* Fetch FULL per-topic metadata (one request PER TOPIC) so each page gets its
|
|
68
|
+
* own `ft:wordCount` / `ft:outputSize` and a per-topic `updated`
|
|
69
|
+
* (`ft:lastTechChange`). Off by default — the cheap path (one `/topics` call
|
|
70
|
+
* per map) only carries the facet keys, so without this the technical
|
|
71
|
+
* numerics are emitted at book level only. Roughly doubles request count.
|
|
72
|
+
*/
|
|
73
|
+
fullTopicMetadata?: boolean;
|
|
74
|
+
}
|
|
75
|
+
export interface RestImportResult {
|
|
76
|
+
pages: ExportPage[];
|
|
77
|
+
nav: NavItem[];
|
|
78
|
+
unresolved: Record<string, string[]>;
|
|
79
|
+
mapsProcessed: number;
|
|
80
|
+
/** Extracted `data:` images, as content-relative paths + bytes to write. */
|
|
81
|
+
assets: {
|
|
82
|
+
path: string;
|
|
83
|
+
data: Buffer;
|
|
84
|
+
}[];
|
|
85
|
+
}
|
|
86
|
+
export declare function importFluidTopicsRest(opts: RestImportOptions): Promise<RestImportResult>;
|
|
87
|
+
//# sourceMappingURL=importer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"importer.d.ts","sourceRoot":"","sources":["../src/importer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,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