@wix/web5-core 1.63.7 → 1.63.9
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/dist/cjs/component/componentDefinitions/CalloutSectionDefinition.js +102 -5
- package/dist/cjs/component/componentDefinitions/CalloutSectionDefinition.js.map +1 -1
- package/dist/cjs/component/componentDefinitions/index.js +8 -2
- package/dist/cjs/component/componentDefinitions/index.js.map +1 -1
- package/dist/cjs/component/componentDefinitions/parse-utils.js +14 -6
- package/dist/cjs/component/componentDefinitions/parse-utils.js.map +1 -1
- package/dist/cjs/entity/index.js +3 -1
- package/dist/cjs/entity/index.js.map +1 -1
- package/dist/cjs/entity/listEntityItems.js +15 -22
- package/dist/cjs/entity/listEntityItems.js.map +1 -1
- package/dist/cjs/entity/mergeEntityData.js +69 -0
- package/dist/cjs/entity/mergeEntityData.js.map +1 -0
- package/dist/cjs/index.js +5 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/callout.js +11 -1
- package/dist/cjs/types/callout.js.map +1 -1
- package/dist/esm/component/componentDefinitions/CalloutSectionDefinition.js +104 -6
- package/dist/esm/component/componentDefinitions/CalloutSectionDefinition.js.map +1 -1
- package/dist/esm/component/componentDefinitions/index.js +8 -2
- package/dist/esm/component/componentDefinitions/index.js.map +1 -1
- package/dist/esm/component/componentDefinitions/parse-utils.js +14 -6
- package/dist/esm/component/componentDefinitions/parse-utils.js.map +1 -1
- package/dist/esm/entity/index.js +1 -0
- package/dist/esm/entity/index.js.map +1 -1
- package/dist/esm/entity/listEntityItems.js +15 -22
- package/dist/esm/entity/listEntityItems.js.map +1 -1
- package/dist/esm/entity/mergeEntityData.js +65 -0
- package/dist/esm/entity/mergeEntityData.js.map +1 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/callout.js +10 -0
- package/dist/esm/types/callout.js.map +1 -1
- package/dist/types/component/componentDefinitions/CalloutSectionDefinition.d.ts +37 -2
- package/dist/types/component/componentDefinitions/CalloutSectionDefinition.d.ts.map +1 -1
- package/dist/types/component/componentDefinitions/index.d.ts.map +1 -1
- package/dist/types/component/componentDefinitions/parse-utils.d.ts +8 -1
- package/dist/types/component/componentDefinitions/parse-utils.d.ts.map +1 -1
- package/dist/types/entity/index.d.ts +1 -0
- package/dist/types/entity/index.d.ts.map +1 -1
- package/dist/types/entity/listEntityItems.d.ts.map +1 -1
- package/dist/types/entity/mergeEntityData.d.ts +4 -0
- package/dist/types/entity/mergeEntityData.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types/callout.d.ts +11 -0
- package/dist/types/types/callout.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -6,16 +6,59 @@ exports.CalloutSectionDefinition = void 0;
|
|
|
6
6
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
7
7
|
var _parseUtils = require("./parse-utils");
|
|
8
8
|
var _parts = require("../../parts/parts");
|
|
9
|
+
var _callout = require("../../types/callout");
|
|
10
|
+
var _sectionDefinition = require("../section-definition");
|
|
11
|
+
/**
|
|
12
|
+
* Callout — the page's dialog layer, written by the orchestrator itself rather
|
|
13
|
+
* than by a per-section model.
|
|
14
|
+
*
|
|
15
|
+
* Two markdown forms reach this definition, and both must keep working:
|
|
16
|
+
*
|
|
17
|
+
* 1. **Descriptor + plain prose** (current). `semantic` carries the kind:
|
|
18
|
+
*
|
|
19
|
+
* <!-- section:callout, semantic:tip -->
|
|
20
|
+
* Prefer a gentle daily ritual? The 4 oz size is the one to sample with.
|
|
21
|
+
*
|
|
22
|
+
* 2. **GFM alert blockquote** (legacy). Still emitted by sites pinned to an
|
|
23
|
+
* older prompt, and present in every historical page, so it is parsed
|
|
24
|
+
* verbatim rather than migrated:
|
|
25
|
+
*
|
|
26
|
+
* <!-- section:callout -->
|
|
27
|
+
* > [!TIP] Prefer a gentle daily ritual? …
|
|
28
|
+
*
|
|
29
|
+
* The two forms differ in one way that matters. A blockquote collapses to a
|
|
30
|
+
* single `callout` part carrying the whole line in `meta.markdown`, so inline
|
|
31
|
+
* ask links survive for free and `getLinks` finds nothing to harvest. A
|
|
32
|
+
* paragraph is *unwrapped* into its inline children (`markdownBlocks.ts`), so
|
|
33
|
+
* prose with a link arrives as `t + link + t` — separate parts. Reading only
|
|
34
|
+
* the `t` parts would delete the link's url and label (DL #134's list bug) and
|
|
35
|
+
* `getLinks` would then re-surface it as a footer link, showing the visitor the
|
|
36
|
+
* same link twice. `inlinePartsToMarkdown` is what keeps the link inline, and
|
|
37
|
+
* the prose path deliberately harvests no `relatedLinks` at all.
|
|
38
|
+
*/
|
|
9
39
|
class CalloutSectionDefinition {
|
|
10
40
|
constructor() {
|
|
11
41
|
(0, _defineProperty2.default)(this, "sectionType", 'callout');
|
|
12
|
-
(0, _defineProperty2.default)(this, "patterns", [
|
|
42
|
+
(0, _defineProperty2.default)(this, "patterns", [
|
|
43
|
+
// Descriptor-led prose. `link` must be in the alternation or a callout
|
|
44
|
+
// carrying an ask link fails to match and falls through to the fallback.
|
|
45
|
+
'html_comment[section="callout"] > (t | link)+',
|
|
46
|
+
// Legacy blockquote.
|
|
47
|
+
'html_comment? > callout+']);
|
|
13
48
|
(0, _defineProperty2.default)(this, "defaults", {
|
|
14
49
|
callouts: [{
|
|
15
50
|
text: 'This is a callout.'
|
|
16
51
|
}]
|
|
17
52
|
});
|
|
18
53
|
(0, _defineProperty2.default)(this, "fixtures", [{
|
|
54
|
+
markdown: '<!-- section:callout, semantic:tip -->\nThis is a callout paragraph.',
|
|
55
|
+
expected: {
|
|
56
|
+
callouts: [{
|
|
57
|
+
text: 'This is a callout paragraph.',
|
|
58
|
+
kind: 'TIP'
|
|
59
|
+
}]
|
|
60
|
+
}
|
|
61
|
+
}, {
|
|
19
62
|
markdown: '> This is a callout blockquote.',
|
|
20
63
|
expected: {
|
|
21
64
|
callouts: [{
|
|
@@ -25,10 +68,45 @@ class CalloutSectionDefinition {
|
|
|
25
68
|
}]);
|
|
26
69
|
}
|
|
27
70
|
parse(parts) {
|
|
71
|
+
const calloutParts = (0, _parts.getPartsByType)(parts, 'callout');
|
|
72
|
+
return calloutParts.length > 0 ? this.parseBlockquote(calloutParts, parts) : this.parseProse(parts);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Descriptor + plain prose. The kind comes from the descriptor's `semantic`,
|
|
77
|
+
* and every link in the body is inline prose — never a `relatedLinks` footer.
|
|
78
|
+
*/
|
|
79
|
+
parseProse(parts) {
|
|
80
|
+
var _parts$find;
|
|
81
|
+
const descriptor = (_parts$find = parts.find(p => p.type === 'htmlComment' && p.meta)) == null ? void 0 : _parts$find.meta;
|
|
82
|
+
|
|
83
|
+
// The pattern already gates on this; re-checking keeps a direct
|
|
84
|
+
// `parse()` call (and any future pattern edit) from mislabelling a
|
|
85
|
+
// different section's prose as a callout.
|
|
86
|
+
if ((descriptor == null ? void 0 : descriptor.section) !== 'callout') {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
const text = (0, _parseUtils.inlinePartsToMarkdown)(parts.filter(p => p.type !== 'htmlComment')).trim();
|
|
90
|
+
|
|
91
|
+
// Matched, but there is nothing to say. DROP_SECTION consumes the nodes
|
|
92
|
+
// and renders nothing; returning null would hand the descriptor to the
|
|
93
|
+
// fallback, which renders it as stray text.
|
|
94
|
+
if (!text) {
|
|
95
|
+
return _sectionDefinition.DROP_SECTION;
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
callouts: [{
|
|
99
|
+
text,
|
|
100
|
+
...(semanticToKind(descriptor.semantic) ?? {})
|
|
101
|
+
}]
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Legacy GFM alert blockquote. */
|
|
106
|
+
parseBlockquote(calloutParts, parts) {
|
|
28
107
|
const callouts = [];
|
|
29
108
|
const relatedLinks = [];
|
|
30
109
|
const seenUrls = new Set();
|
|
31
|
-
const calloutParts = (0, _parts.getPartsByType)(parts, 'callout');
|
|
32
110
|
for (const c of calloutParts) {
|
|
33
111
|
var _c$meta, _c$content;
|
|
34
112
|
const text = ((_c$meta = c.meta) == null || (_c$meta = _c$meta.markdown) == null ? void 0 : _c$meta.trim()) || ((_c$content = c.content) == null ? void 0 : _c$content.trim());
|
|
@@ -42,10 +120,13 @@ class CalloutSectionDefinition {
|
|
|
42
120
|
}
|
|
43
121
|
}
|
|
44
122
|
}
|
|
123
|
+
if (callouts.length === 0) {
|
|
124
|
+
return _sectionDefinition.DROP_SECTION;
|
|
125
|
+
}
|
|
45
126
|
|
|
46
|
-
//
|
|
47
|
-
|
|
48
|
-
for (const link of
|
|
127
|
+
// A blockquote yields no sibling link parts, so anything found here arrived
|
|
128
|
+
// alongside the quote and is a genuine footer link.
|
|
129
|
+
for (const link of (0, _parts.getLinks)(parts)) {
|
|
49
130
|
var _link$meta, _link$content;
|
|
50
131
|
const href = (_link$meta = link.meta) == null ? void 0 : _link$meta.href;
|
|
51
132
|
const text = (_link$content = link.content) == null ? void 0 : _link$content.trim();
|
|
@@ -63,5 +144,21 @@ class CalloutSectionDefinition {
|
|
|
63
144
|
};
|
|
64
145
|
}
|
|
65
146
|
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* `semantic:tip` → `{ kind: 'TIP' }`. Uppercased so the new form lands on the
|
|
150
|
+
* same vocabulary the legacy `[!TIP]` marker produced, which is what any
|
|
151
|
+
* kind-aware renderer already switches on. An unrecognised value carries no
|
|
152
|
+
* kind rather than an invented one.
|
|
153
|
+
*/
|
|
66
154
|
exports.CalloutSectionDefinition = CalloutSectionDefinition;
|
|
155
|
+
function semanticToKind(semantic) {
|
|
156
|
+
const value = semantic == null ? void 0 : semantic.trim().toLowerCase();
|
|
157
|
+
if (!value) {
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
return _callout.CALLOUT_SEMANTICS.includes(value) ? {
|
|
161
|
+
kind: value.toUpperCase()
|
|
162
|
+
} : undefined;
|
|
163
|
+
}
|
|
67
164
|
//# sourceMappingURL=CalloutSectionDefinition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_parseUtils","require","_parts","CalloutSectionDefinition","constructor","_defineProperty2","default","callouts","text","markdown","expected","parse","parts","relatedLinks","seenUrls","Set","calloutParts","getPartsByType","c","_c$meta","_c$content","meta","trim","content","parsed","parseCalloutTag","push","kind","links","getLinks","link","_link$meta","_link$content","href","has","add","url","length","undefined","exports"],"sources":["../../../../src/component/componentDefinitions/CalloutSectionDefinition.ts"],"sourcesContent":["import { parseCalloutTag } from './parse-utils';\nimport { getPartsByType, getLinks, type Part } from '../../parts/parts';\nimport type { Callout } from '../../types/callout';\nimport type {\n CalloutCompProps,\n CalloutSectionComponent,\n SectionFixture,\n} from '../types';\nimport type { SectionDefinition } from '../section-definition';\n\nexport class CalloutSectionDefinition\n implements SectionDefinition<CalloutSectionComponent>\n{\n sectionType = 'callout' as const;\n patterns = ['html_comment? > callout+'];\n\n defaults: CalloutCompProps = {\n callouts: [{ text: 'This is a callout.' }],\n };\n\n fixtures: SectionFixture<CalloutCompProps>[] = [\n {\n markdown: '> This is a callout blockquote.',\n expected: {\n callouts: [{ text: 'This is a callout blockquote.' }],\n },\n },\n ];\n\n parse(parts: Part[]): CalloutCompProps {\n const callouts: Callout[] = [];\n const relatedLinks: { text: string; url: string }[] = [];\n const seenUrls = new Set<string>();\n\n const calloutParts = getPartsByType<Part>(parts, 'callout');\n for (const c of calloutParts) {\n const text = (c.meta?.markdown as string)?.trim() || c.content?.trim();\n if (text) {\n const parsed = parseCalloutTag(text);\n if (parsed.text) {\n callouts.push({ text: parsed.text, kind: parsed.kind });\n }\n }\n }\n\n // Extract links from all parts\n const links = getLinks(parts);\n for (const link of links) {\n const href = link.meta?.href;\n const text = link.content?.trim();\n if (text && href && !seenUrls.has(href)) {\n seenUrls.add(href);\n relatedLinks.push({ text, url: href });\n }\n }\n\n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E;UACfD,QAAQ,CAACmB,IAAI,CAAC;YAAElB,IAAI,EAAEgB,MAAM,CAAChB,IAAI;YAAEmB,IAAI,EAAEH,MAAM,CAACG;UAAK,CAAC,CAAC;QACzD;MACF;IACF;;IAEA;IACA,MAAMC,KAAK,GAAG,IAAAC,eAAQ,EAACjB,KAAK,CAAC;IAC7B,KAAK,MAAMkB,IAAI,IAAIF,KAAK,EAAE;MAAA,IAAAG,UAAA,EAAAC,aAAA;MACxB,MAAMC,IAAI,IAAAF,UAAA,GAAGD,IAAI,CAACT,IAAI,qBAATU,UAAA,CAAWE,IAAI;MAC5B,MAAMzB,IAAI,IAAAwB,aAAA,GAAGF,IAAI,CAACP,OAAO,qBAAZS,aAAA,CAAcV,IAAI,CAAC,CAAC;MACjC,IAAId,IAAI,IAAIyB,IAAI,IAAI,CAACnB,QAAQ,CAACoB,GAAG,CAACD,IAAI,CAAC,EAAE;QACvCnB,QAAQ,CAACqB,GAAG,CAACF,IAAI,CAAC;QAClBpB,YAAY,CAACa,IAAI,CAAC;UAAElB,IAAI;UAAE4B,GAAG,EAAEH;QAAK,CAAC,CAAC;MACxC;IACF;IAEA,OAAO;MACL1B,QAAQ;MACRM,YAAY,EAAEA,YAAY,CAACwB,MAAM,GAAG,CAAC,GAAGxB,YAAY,GAAGyB;IACzD,CAAC;EACH;AACF;AAACC,OAAA,CAAApC,wBAAA,GAAAA,wBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_parseUtils","require","_parts","_callout","_sectionDefinition","CalloutSectionDefinition","constructor","_defineProperty2","default","callouts","text","markdown","expected","kind","parse","parts","calloutParts","getPartsByType","length","parseBlockquote","parseProse","_parts$find","descriptor","find","p","type","meta","section","inlinePartsToMarkdown","filter","trim","DROP_SECTION","semanticToKind","semantic","relatedLinks","seenUrls","Set","c","_c$meta","_c$content","content","parsed","parseCalloutTag","push","link","getLinks","_link$meta","_link$content","href","has","add","url","undefined","exports","value","toLowerCase","CALLOUT_SEMANTICS","includes","toUpperCase"],"sources":["../../../../src/component/componentDefinitions/CalloutSectionDefinition.ts"],"sourcesContent":["import { inlinePartsToMarkdown, parseCalloutTag } from './parse-utils';\nimport { getPartsByType, getLinks, type Part } from '../../parts/parts';\nimport { CALLOUT_SEMANTICS, type Callout } from '../../types/callout';\nimport type {\n CalloutCompProps,\n CalloutSectionComponent,\n SectionFixture,\n} from '../types';\nimport {\n DROP_SECTION,\n type DropSection,\n type SectionDefinition,\n} from '../section-definition';\n\n/**\n * Callout — the page's dialog layer, written by the orchestrator itself rather\n * than by a per-section model.\n *\n * Two markdown forms reach this definition, and both must keep working:\n *\n * 1. **Descriptor + plain prose** (current). `semantic` carries the kind:\n *\n * <!-- section:callout, semantic:tip -->\n * Prefer a gentle daily ritual? The 4 oz size is the one to sample with.\n *\n * 2. **GFM alert blockquote** (legacy). Still emitted by sites pinned to an\n * older prompt, and present in every historical page, so it is parsed\n * verbatim rather than migrated:\n *\n * <!-- section:callout -->\n * > [!TIP] Prefer a gentle daily ritual? …\n *\n * The two forms differ in one way that matters. A blockquote collapses to a\n * single `callout` part carrying the whole line in `meta.markdown`, so inline\n * ask links survive for free and `getLinks` finds nothing to harvest. A\n * paragraph is *unwrapped* into its inline children (`markdownBlocks.ts`), so\n * prose with a link arrives as `t + link + t` — separate parts. Reading only\n * the `t` parts would delete the link's url and label (DL #134's list bug) and\n * `getLinks` would then re-surface it as a footer link, showing the visitor the\n * same link twice. `inlinePartsToMarkdown` is what keeps the link inline, and\n * the prose path deliberately harvests no `relatedLinks` at all.\n */\nexport class CalloutSectionDefinition\n implements SectionDefinition<CalloutSectionComponent>\n{\n sectionType = 'callout' as const;\n patterns = [\n // Descriptor-led prose. `link` must be in the alternation or a callout\n // carrying an ask link fails to match and falls through to the fallback.\n 'html_comment[section=\"callout\"] > (t | link)+',\n // Legacy blockquote.\n 'html_comment? > callout+',\n ];\n\n defaults: CalloutCompProps = {\n callouts: [{ text: 'This is a callout.' }],\n };\n\n fixtures: SectionFixture<CalloutCompProps>[] = [\n {\n markdown:\n '<!-- section:callout, semantic:tip -->\\nThis is a callout paragraph.',\n expected: {\n callouts: [{ text: 'This is a callout paragraph.', kind: 'TIP' }],\n },\n },\n {\n markdown: '> This is a callout blockquote.',\n expected: {\n callouts: [{ text: 'This is a callout blockquote.' }],\n },\n },\n ];\n\n parse(parts: Part[]): CalloutCompProps | null | DropSection {\n const calloutParts = getPartsByType<Part>(parts, 'callout');\n\n return calloutParts.length > 0\n ? this.parseBlockquote(calloutParts, parts)\n : this.parseProse(parts);\n }\n\n /**\n * Descriptor + plain prose. The kind comes from the descriptor's `semantic`,\n * and every link in the body is inline prose — never a `relatedLinks` footer.\n */\n private parseProse(parts: Part[]): CalloutCompProps | null | DropSection {\n const descriptor = parts.find((p) => p.type === 'htmlComment' && p.meta)\n ?.meta as Record<string, string> | undefined;\n\n // The pattern already gates on this; re-checking keeps a direct\n // `parse()` call (and any future pattern edit) from mislabelling a\n // different section's prose as a callout.\n if (descriptor?.section !== 'callout') {\n return null;\n }\n\n const text = inlinePartsToMarkdown(\n parts.filter((p) => p.type !== 'htmlComment'),\n ).trim();\n\n // Matched, but there is nothing to say. DROP_SECTION consumes the nodes\n // and renders nothing; returning null would hand the descriptor to the\n // fallback, which renders it as stray text.\n if (!text) {\n return DROP_SECTION;\n }\n\n return {\n callouts: [{ text, ...(semanticToKind(descriptor.semantic) ?? {}) }],\n };\n }\n\n /** Legacy GFM alert blockquote. */\n private parseBlockquote(\n calloutParts: Part[],\n parts: Part[],\n ): CalloutCompProps | null | DropSection {\n const callouts: Callout[] = [];\n const relatedLinks: { text: string; url: string }[] = [];\n const seenUrls = new Set<string>();\n\n for (const c of calloutParts) {\n const text = (c.meta?.markdown as string)?.trim() || c.content?.trim();\n if (text) {\n const parsed = parseCalloutTag(text);\n if (parsed.text) {\n callouts.push({ text: parsed.text, kind: parsed.kind });\n }\n }\n }\n\n if (callouts.length === 0) {\n return DROP_SECTION;\n }\n\n // A blockquote yields no sibling link parts, so anything found here arrived\n // alongside the quote and is a genuine footer link.\n for (const link of getLinks(parts)) {\n const href = link.meta?.href;\n const text = link.content?.trim();\n if (text && href && !seenUrls.has(href)) {\n seenUrls.add(href);\n relatedLinks.push({ text, url: href });\n }\n }\n\n return {\n callouts,\n relatedLinks: relatedLinks.length > 0 ? relatedLinks : undefined,\n };\n }\n}\n\n/**\n * `semantic:tip` → `{ kind: 'TIP' }`. Uppercased so the new form lands on the\n * same vocabulary the legacy `[!TIP]` marker produced, which is what any\n * kind-aware renderer already switches on. An unrecognised value carries no\n * kind rather than an invented one.\n */\nfunction semanticToKind(semantic?: string): { kind: string } | undefined {\n const value = semantic?.trim().toLowerCase();\n if (!value) {\n return undefined;\n }\n return (CALLOUT_SEMANTICS as readonly string[]).includes(value)\n ? { kind: value.toUpperCase() }\n : undefined;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAMA,IAAAG,kBAAA,GAAAH,OAAA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMI,wBAAwB,CAErC;EAAAC,YAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,uBACgB,SAAS;IAAA,IAAAD,gBAAA,CAAAC,OAAA,oBACZ;IACT;IACA;IACA,+CAA+C;IAC/C;IACA,0BAA0B,CAC3B;IAAA,IAAAD,gBAAA,CAAAC,OAAA,oBAE4B;MAC3BC,QAAQ,EAAE,CAAC;QAAEC,IAAI,EAAE;MAAqB,CAAC;IAC3C,CAAC;IAAA,IAAAH,gBAAA,CAAAC,OAAA,oBAE8C,CAC7C;MACEG,QAAQ,EACN,sEAAsE;MACxEC,QAAQ,EAAE;QACRH,QAAQ,EAAE,CAAC;UAAEC,IAAI,EAAE,8BAA8B;UA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,IAAI,CAAC;UAAEjC,IAAI;UAAEyC,GAAG,EAAEH;QAAK,CAAC,CAAC;MACxC;IACF;IAEA,OAAO;MACLvC,QAAQ;MACRyB,YAAY,EAAEA,YAAY,CAAChB,MAAM,GAAG,CAAC,GAAGgB,YAAY,GAAGkB;IACzD,CAAC;EACH;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AALAC,OAAA,CAAAhD,wBAAA,GAAAA,wBAAA;AAMA,SAAS2B,cAAcA,CAACC,QAAiB,EAAgC;EACvE,MAAMqB,KAAK,GAAGrB,QAAQ,oBAARA,QAAQ,CAAEH,IAAI,CAAC,CAAC,CAACyB,WAAW,CAAC,CAAC;EAC5C,IAAI,CAACD,KAAK,EAAE;IACV,OAAOF,SAAS;EAClB;EACA,OAAQI,0BAAiB,CAAuBC,QAAQ,CAACH,KAAK,CAAC,GAC3D;IAAEzC,IAAI,EAAEyC,KAAK,CAACI,WAAW,CAAC;EAAE,CAAC,GAC7BN,SAAS;AACf","ignoreList":[]}
|
|
@@ -49,13 +49,19 @@ function createSdkRegistry() {
|
|
|
49
49
|
// Collection entities are claimed by their own definition first — it is a
|
|
50
50
|
// strictly narrower match than EntitySectionDefinition, which would
|
|
51
51
|
// otherwise swallow collection, product and article blocks alike.
|
|
52
|
-
.register(new _EntityCollectionSectionDefinition.EntityCollectionSectionDefinition()).register(new _EntitySectionDefinition.EntitySectionDefinition()).register(new _HeroEntitySectionDefinition.HeroEntitySectionDefinition()).register(new _HeroSectionDefinition.HeroSectionDefinition()).register(new _FeatureCardsSectionDefinition.FeatureCardsSectionDefinition()).register(new _listItemsSectionDefinition.ListItemsSectionDefinition()).register(new _FeatureSection9PlusDefinition.FeatureSection9PlusDefinition()).register(new _ComparisonSectionDefinition.ComparisonSectionDefinition())
|
|
52
|
+
.register(new _EntityCollectionSectionDefinition.EntityCollectionSectionDefinition()).register(new _EntitySectionDefinition.EntitySectionDefinition()).register(new _HeroEntitySectionDefinition.HeroEntitySectionDefinition()).register(new _HeroSectionDefinition.HeroSectionDefinition()).register(new _FeatureCardsSectionDefinition.FeatureCardsSectionDefinition()).register(new _listItemsSectionDefinition.ListItemsSectionDefinition()).register(new _FeatureSection9PlusDefinition.FeatureSection9PlusDefinition()).register(new _ComparisonSectionDefinition.ComparisonSectionDefinition())
|
|
53
|
+
// Callout sits above HtmlComment: a callout block opens with its own
|
|
54
|
+
// `<!-- section:callout -->` descriptor, and HtmlComment's bare
|
|
55
|
+
// `html_comment` pattern would match that comment alone. A pattern may
|
|
56
|
+
// match a PREFIX of a block, so HtmlComment would claim the descriptor
|
|
57
|
+
// and strand the prose below it in the fallback, unstyled.
|
|
58
|
+
.register(new _CalloutSectionDefinition.CalloutSectionDefinition()).register(new _HtmlCommentSectionDefinition.HtmlCommentSectionDefinition()).register(new _CtaBannerSectionDefinition.CtaBannerSectionDefinition())
|
|
53
59
|
// textBlock comes after every definition whose block opens `h2 > t`
|
|
54
60
|
// (entity, listItems, featureCards, ctaBanner, comparison, …). Its
|
|
55
61
|
// trailing callout is optional, so its pattern also matches a bare
|
|
56
62
|
// `h2 > t`, and a pattern matches a PREFIX of the block — registered
|
|
57
63
|
// above those it would claim the heading + intro paragraph and strand
|
|
58
64
|
// the list / links / table that follow in a separate section.
|
|
59
|
-
.register(new _TextBlockSectionDefinition.TextBlockSectionDefinition()).register(new
|
|
65
|
+
.register(new _TextBlockSectionDefinition.TextBlockSectionDefinition()).register(new _FallbackSectionDefinition.FallbackSectionDefinition()).register(new _ErrorSectionDefinition.ErrorSectionDefinition());
|
|
60
66
|
}
|
|
61
67
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_ComparisonSectionDefinition","require","exports","ComparisonSectionDefinition","_TextBlockSectionDefinition","TextBlockSectionDefinition","_HeroSectionDefinition","HeroSectionDefinition","_HeroEntitySectionDefinition","HeroEntitySectionDefinition","_KpiSectionDefinition","KpiSectionDefinition","_FeatureCardsSectionDefinition","FeatureCardsSectionDefinition","_EntitySectionDefinition","EntitySectionDefinition","_EntityCollectionSectionDefinition","EntityCollectionSectionDefinition","_CtaBannerSectionDefinition","CtaBannerSectionDefinition","_CalloutSectionDefinition","CalloutSectionDefinition","_NextStepsSectionDefinition","NextStepsSectionDefinition","_FeatureSection9PlusDefinition","FeatureSection9PlusDefinition","_listItemsSectionDefinition","ListItemsSectionDefinition","_SkipNodesSectionDefinition","SkipNodesSectionDefinition","_HtmlCommentSectionDefinition","HtmlCommentSectionDefinition","_SearchSectionDefinition","SearchSectionDefinition","_ErrorSectionDefinition","ErrorSectionDefinition","_FallbackSectionDefinition","FallbackSectionDefinition","_registry","createSdkRegistry","ComponentRegistry","register"],"sources":["../../../../src/component/componentDefinitions/index.ts"],"sourcesContent":["export type { SectionDefinition } from '../section-definition';\nexport { ComparisonSectionDefinition } from './ComparisonSectionDefinition';\nexport { TextBlockSectionDefinition } from './TextBlockSectionDefinition';\nexport { HeroSectionDefinition } from './HeroSectionDefinition';\nexport { HeroEntitySectionDefinition } from './HeroEntitySectionDefinition';\nexport { KpiSectionDefinition } from './KpiSectionDefinition';\nexport { FeatureCardsSectionDefinition } from './FeatureCardsSectionDefinition';\nexport { EntitySectionDefinition } from './EntitySectionDefinition';\nexport { EntityCollectionSectionDefinition } from './EntityCollectionSectionDefinition';\nexport { CtaBannerSectionDefinition } from './CtaBannerSectionDefinition';\nexport { CalloutSectionDefinition } from './CalloutSectionDefinition';\nexport { NextStepsSectionDefinition } from './NextStepsSectionDefinition';\nexport { FeatureSection9PlusDefinition } from './FeatureSection9PlusDefinition';\nexport { ListItemsSectionDefinition } from './listItemsSectionDefinition';\nexport { SkipNodesSectionDefinition } from './SkipNodesSectionDefinition';\nexport { HtmlCommentSectionDefinition } from './HtmlCommentSectionDefinition';\nexport { SearchSectionDefinition } from './SearchSectionDefinition';\nexport { ErrorSectionDefinition } from './ErrorSectionDefinition';\nexport { FallbackSectionDefinition } from './FallbackSectionDefinition';\n\nimport { ComponentRegistry } from '../../registry';\nimport { SkipNodesSectionDefinition } from './SkipNodesSectionDefinition';\nimport { SearchSectionDefinition } from './SearchSectionDefinition';\nimport { KpiSectionDefinition } from './KpiSectionDefinition';\nimport { NextStepsSectionDefinition } from './NextStepsSectionDefinition';\nimport { EntitySectionDefinition } from './EntitySectionDefinition';\nimport { EntityCollectionSectionDefinition } from './EntityCollectionSectionDefinition';\nimport { HeroEntitySectionDefinition } from './HeroEntitySectionDefinition';\nimport { HeroSectionDefinition } from './HeroSectionDefinition';\nimport { FeatureCardsSectionDefinition } from './FeatureCardsSectionDefinition';\nimport { FeatureSection9PlusDefinition } from './FeatureSection9PlusDefinition';\nimport { ListItemsSectionDefinition } from './listItemsSectionDefinition';\nimport { ComparisonSectionDefinition } from './ComparisonSectionDefinition';\nimport { HtmlCommentSectionDefinition } from './HtmlCommentSectionDefinition';\nimport { CtaBannerSectionDefinition } from './CtaBannerSectionDefinition';\nimport { CalloutSectionDefinition } from './CalloutSectionDefinition';\nimport { FallbackSectionDefinition } from './FallbackSectionDefinition';\nimport { ErrorSectionDefinition } from './ErrorSectionDefinition';\nimport { TextBlockSectionDefinition } from './TextBlockSectionDefinition';\n\n/**\n * Creates an SDK registry with all section definitions registered in the\n * same priority order as the app registry (createAppRegistry.ts).\n * Registration order determines evaluation priority — first match wins.\n */\nexport function createSdkRegistry(): ComponentRegistry<null> {\n return (\n new ComponentRegistry<null>(null)\n .register(new SkipNodesSectionDefinition())\n .register(new SearchSectionDefinition())\n .register(new KpiSectionDefinition())\n .register(new NextStepsSectionDefinition())\n // Collection entities are claimed by their own definition first — it is a\n // strictly narrower match than EntitySectionDefinition, which would\n // otherwise swallow collection, product and article blocks alike.\n .register(new EntityCollectionSectionDefinition())\n .register(new EntitySectionDefinition())\n .register(new HeroEntitySectionDefinition())\n .register(new HeroSectionDefinition())\n .register(new FeatureCardsSectionDefinition())\n .register(new ListItemsSectionDefinition())\n .register(new FeatureSection9PlusDefinition())\n .register(new ComparisonSectionDefinition())\n .register(new HtmlCommentSectionDefinition())\n .register(new CtaBannerSectionDefinition())\n // textBlock comes after every definition whose block opens `h2 > t`\n // (entity, listItems, featureCards, ctaBanner, comparison, …). Its\n // trailing callout is optional, so its pattern also matches a bare\n // `h2 > t`, and a pattern matches a PREFIX of the block — registered\n // above those it would claim the heading + intro paragraph and strand\n // the list / links / table that follow in a separate section.\n .register(new TextBlockSectionDefinition())\n .register(new
|
|
1
|
+
{"version":3,"names":["_ComparisonSectionDefinition","require","exports","ComparisonSectionDefinition","_TextBlockSectionDefinition","TextBlockSectionDefinition","_HeroSectionDefinition","HeroSectionDefinition","_HeroEntitySectionDefinition","HeroEntitySectionDefinition","_KpiSectionDefinition","KpiSectionDefinition","_FeatureCardsSectionDefinition","FeatureCardsSectionDefinition","_EntitySectionDefinition","EntitySectionDefinition","_EntityCollectionSectionDefinition","EntityCollectionSectionDefinition","_CtaBannerSectionDefinition","CtaBannerSectionDefinition","_CalloutSectionDefinition","CalloutSectionDefinition","_NextStepsSectionDefinition","NextStepsSectionDefinition","_FeatureSection9PlusDefinition","FeatureSection9PlusDefinition","_listItemsSectionDefinition","ListItemsSectionDefinition","_SkipNodesSectionDefinition","SkipNodesSectionDefinition","_HtmlCommentSectionDefinition","HtmlCommentSectionDefinition","_SearchSectionDefinition","SearchSectionDefinition","_ErrorSectionDefinition","ErrorSectionDefinition","_FallbackSectionDefinition","FallbackSectionDefinition","_registry","createSdkRegistry","ComponentRegistry","register"],"sources":["../../../../src/component/componentDefinitions/index.ts"],"sourcesContent":["export type { SectionDefinition } from '../section-definition';\nexport { ComparisonSectionDefinition } from './ComparisonSectionDefinition';\nexport { TextBlockSectionDefinition } from './TextBlockSectionDefinition';\nexport { HeroSectionDefinition } from './HeroSectionDefinition';\nexport { HeroEntitySectionDefinition } from './HeroEntitySectionDefinition';\nexport { KpiSectionDefinition } from './KpiSectionDefinition';\nexport { FeatureCardsSectionDefinition } from './FeatureCardsSectionDefinition';\nexport { EntitySectionDefinition } from './EntitySectionDefinition';\nexport { EntityCollectionSectionDefinition } from './EntityCollectionSectionDefinition';\nexport { CtaBannerSectionDefinition } from './CtaBannerSectionDefinition';\nexport { CalloutSectionDefinition } from './CalloutSectionDefinition';\nexport { NextStepsSectionDefinition } from './NextStepsSectionDefinition';\nexport { FeatureSection9PlusDefinition } from './FeatureSection9PlusDefinition';\nexport { ListItemsSectionDefinition } from './listItemsSectionDefinition';\nexport { SkipNodesSectionDefinition } from './SkipNodesSectionDefinition';\nexport { HtmlCommentSectionDefinition } from './HtmlCommentSectionDefinition';\nexport { SearchSectionDefinition } from './SearchSectionDefinition';\nexport { ErrorSectionDefinition } from './ErrorSectionDefinition';\nexport { FallbackSectionDefinition } from './FallbackSectionDefinition';\n\nimport { ComponentRegistry } from '../../registry';\nimport { SkipNodesSectionDefinition } from './SkipNodesSectionDefinition';\nimport { SearchSectionDefinition } from './SearchSectionDefinition';\nimport { KpiSectionDefinition } from './KpiSectionDefinition';\nimport { NextStepsSectionDefinition } from './NextStepsSectionDefinition';\nimport { EntitySectionDefinition } from './EntitySectionDefinition';\nimport { EntityCollectionSectionDefinition } from './EntityCollectionSectionDefinition';\nimport { HeroEntitySectionDefinition } from './HeroEntitySectionDefinition';\nimport { HeroSectionDefinition } from './HeroSectionDefinition';\nimport { FeatureCardsSectionDefinition } from './FeatureCardsSectionDefinition';\nimport { FeatureSection9PlusDefinition } from './FeatureSection9PlusDefinition';\nimport { ListItemsSectionDefinition } from './listItemsSectionDefinition';\nimport { ComparisonSectionDefinition } from './ComparisonSectionDefinition';\nimport { HtmlCommentSectionDefinition } from './HtmlCommentSectionDefinition';\nimport { CtaBannerSectionDefinition } from './CtaBannerSectionDefinition';\nimport { CalloutSectionDefinition } from './CalloutSectionDefinition';\nimport { FallbackSectionDefinition } from './FallbackSectionDefinition';\nimport { ErrorSectionDefinition } from './ErrorSectionDefinition';\nimport { TextBlockSectionDefinition } from './TextBlockSectionDefinition';\n\n/**\n * Creates an SDK registry with all section definitions registered in the\n * same priority order as the app registry (createAppRegistry.ts).\n * Registration order determines evaluation priority — first match wins.\n */\nexport function createSdkRegistry(): ComponentRegistry<null> {\n return (\n new ComponentRegistry<null>(null)\n .register(new SkipNodesSectionDefinition())\n .register(new SearchSectionDefinition())\n .register(new KpiSectionDefinition())\n .register(new NextStepsSectionDefinition())\n // Collection entities are claimed by their own definition first — it is a\n // strictly narrower match than EntitySectionDefinition, which would\n // otherwise swallow collection, product and article blocks alike.\n .register(new EntityCollectionSectionDefinition())\n .register(new EntitySectionDefinition())\n .register(new HeroEntitySectionDefinition())\n .register(new HeroSectionDefinition())\n .register(new FeatureCardsSectionDefinition())\n .register(new ListItemsSectionDefinition())\n .register(new FeatureSection9PlusDefinition())\n .register(new ComparisonSectionDefinition())\n // Callout sits above HtmlComment: a callout block opens with its own\n // `<!-- section:callout -->` descriptor, and HtmlComment's bare\n // `html_comment` pattern would match that comment alone. A pattern may\n // match a PREFIX of a block, so HtmlComment would claim the descriptor\n // and strand the prose below it in the fallback, unstyled.\n .register(new CalloutSectionDefinition())\n .register(new HtmlCommentSectionDefinition())\n .register(new CtaBannerSectionDefinition())\n // textBlock comes after every definition whose block opens `h2 > t`\n // (entity, listItems, featureCards, ctaBanner, comparison, …). Its\n // trailing callout is optional, so its pattern also matches a bare\n // `h2 > t`, and a pattern matches a PREFIX of the block — registered\n // above those it would claim the heading + intro paragraph and strand\n // the list / links / table that follow in a separate section.\n .register(new TextBlockSectionDefinition())\n .register(new FallbackSectionDefinition())\n .register(new ErrorSectionDefinition())\n );\n}\n"],"mappings":";;;;AACA,IAAAA,4BAAA,GAAAC,OAAA;AAA4EC,OAAA,CAAAC,2BAAA,GAAAH,4BAAA,CAAAG,2BAAA;AAC5E,IAAAC,2BAAA,GAAAH,OAAA;AAA0EC,OAAA,CAAAG,0BAAA,GAAAD,2BAAA,CAAAC,0BAAA;AAC1E,IAAAC,sBAAA,GAAAL,OAAA;AAAgEC,OAAA,CAAAK,qBAAA,GAAAD,sBAAA,CAAAC,qBAAA;AAChE,I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Q,CAAC,IAAIpC,sDAA0B,CAAC,CAAC,CAAC,CAC1CoC,QAAQ,CAAC,IAAIJ,oDAAyB,CAAC,CAAC,CAAC,CACzCI,QAAQ,CAAC,IAAIN,8CAAsB,CAAC,CAAC,CAAC;AAE7C","ignoreList":[]}
|
|
@@ -243,23 +243,31 @@ function appendInlineToken(current, token) {
|
|
|
243
243
|
}
|
|
244
244
|
|
|
245
245
|
/**
|
|
246
|
-
* Serialize a run of inline parts back to markdown, preserving links
|
|
246
|
+
* Serialize a run of inline parts back to markdown, preserving links and
|
|
247
|
+
* inline emphasis.
|
|
247
248
|
*
|
|
248
249
|
* Concatenating `part.content` alone silently deletes links: a `link` part
|
|
249
250
|
* keeps its label in `content` and its url in `meta.href`, so a filter that
|
|
250
251
|
* reads only text parts turns `Read the [pricing page](/pricing) first` into
|
|
251
252
|
* `Read the first` — url and label both vanish, with nothing in the output to
|
|
252
253
|
* show anything was lost.
|
|
254
|
+
*
|
|
255
|
+
* `content` is also the *plain* text of a text part — `nodesToParts` strips
|
|
256
|
+
* inline formatting and keeps the original in `meta.markdown` whenever the two
|
|
257
|
+
* differ. Reading `content` therefore drops emphasis the same way it used to
|
|
258
|
+
* drop links: `The **4 oz size** is best` becomes `The 4 oz size is best`.
|
|
259
|
+
* Prefer `meta.markdown`, which is exactly the segment's own markdown.
|
|
253
260
|
*/
|
|
254
261
|
function inlinePartsToMarkdown(parts) {
|
|
255
262
|
return parts.reduce((text, part) => {
|
|
263
|
+
var _part$meta;
|
|
256
264
|
if (part.type === 'link') {
|
|
257
265
|
var _meta2, _part$content;
|
|
258
266
|
const href = ((_meta2 = part.meta) == null ? void 0 : _meta2.href) ?? '';
|
|
259
267
|
const label = ((_part$content = part.content) == null ? void 0 : _part$content.trim()) ?? '';
|
|
260
268
|
return appendInlineToken(text, href ? `[${label}](${href})` : label);
|
|
261
269
|
}
|
|
262
|
-
return appendInlineToken(text, part.content ?? '');
|
|
270
|
+
return appendInlineToken(text, ((_part$meta = part.meta) == null ? void 0 : _part$meta.markdown) ?? part.content ?? '');
|
|
263
271
|
}, '');
|
|
264
272
|
}
|
|
265
273
|
function extractListItemText(item) {
|
|
@@ -283,14 +291,14 @@ function extractListItemText(item) {
|
|
|
283
291
|
*/
|
|
284
292
|
function partsToMarkdown(sectionParts) {
|
|
285
293
|
const inline = part => {
|
|
286
|
-
var _part$
|
|
287
|
-
return ((_part$
|
|
294
|
+
var _part$meta2;
|
|
295
|
+
return ((_part$meta2 = part.meta) == null ? void 0 : _part$meta2.markdown) ?? part.content;
|
|
288
296
|
};
|
|
289
297
|
const lines = [];
|
|
290
298
|
for (const part of sectionParts) {
|
|
291
299
|
if (part.type === 'heading') {
|
|
292
|
-
var _part$
|
|
293
|
-
const level = ((_part$
|
|
300
|
+
var _part$meta3;
|
|
301
|
+
const level = ((_part$meta3 = part.meta) == null ? void 0 : _part$meta3.level) ?? 2;
|
|
294
302
|
lines.push(`${'#'.repeat(level)} ${inline(part)}`);
|
|
295
303
|
} else if (part.type === 'text' || part.type === 'richText') {
|
|
296
304
|
lines.push(inline(part));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_parts","require","_entityLinkParser","_linkTypes","str","p","_p$content","content","trim","markdownOrText","_p$meta","meta","markdown","normalizeEntityDescription","description","replace","stripMarkdown","md","headingText","parts","level","heading","getHeading","headingMarkdown","_meta$markdown","bodyText","textParts","getPartsByType","richTextParts","map","filter","Boolean","join","entitySectionBodyText","firstEntityLinkIndex","findIndex","_meta","type","isEntityHref","href","sectionParts","slice","linksToHeroButtons","links","getLinks","length","lists","flatMap","l","_l$meta","items","item","_item$meta","i","_l$content","id","text","variant","onClick","firstImageSrc","_img$meta","images","getImages","img","src","undefined","firstLink","_link$content","link","blockquoteText","bqs","_p$meta2","calloutFromParts","_p$meta3","calloutParts","raw","parsed","parseCalloutTag","kind","listToMarkdown","lines","list","_list$meta","extractListItemText","push","parseEntityUrl","url","trimmedUrl","isWeb5EntityUrl","parseWeb5Url","Web5UrlType","ENTITY","entityType","entityId","parseTableValue","value","normalized","toLowerCase","parseKpiItem","trimmed","boldMatch","match","title","afterBold","indexOf","appendInlineToken","current","token","test","inlinePartsToMarkdown","reduce","part","_meta2","_part$content","label","_item$meta2","partsToMarkdown","inline","_part$meta","_part$meta2","repeat","_list$meta2","_item$meta3","toUpperCase","generatePartId","Math","random","toString","extractNestedListItems","itemParts","nestedLists","features","nested","_list$meta3","extractEntityRefs","entities","_list$meta4","_item$meta4","entityLinks","_meta3","_link$content2","_images$","_p$content2","callout","_calloutParts$0$meta","parsed2","linkText","entityUrl","markdownImageUrl","markdownFeatures","topLinks","_l$meta2","some","e","_link$content3","linkIndex","j","_meta4","_p$content3","_meta5","_p$meta4","parsedCallout","_meta6"],"sources":["../../../../src/component/componentDefinitions/parse-utils.ts"],"sourcesContent":["import type {\n Part,\n ListPart,\n LinkPart,\n ListItemPart,\n ImagePart,\n} from '../../parts/parts';\nimport {\n getPartsByType,\n getHeading,\n getImages,\n getLinks,\n} from '../../parts/parts';\nimport { parseWeb5Url } from '../../utils/entityLinkParser';\nimport { Web5UrlType, isWeb5EntityUrl } from '../../types/link-types';\nimport type { Callout } from '../../types/callout';\nimport type { HeroButton } from '../types';\n\nfunction str(p: Part | undefined): string {\n return p?.content?.trim() ?? '';\n}\n\nfunction markdownOrText(p: Part): string {\n return ((p.meta?.markdown as string)?.trim() || str(p)).trim();\n}\n\nfunction normalizeEntityDescription(description: string): string {\n return description\n .replace(/^[\\s\\u2013\\u2014-]+/, '')\n .replace(/^[:\\s]+/, '')\n .trim();\n}\n\n/** Strip basic markdown formatting to get plain text */\nexport function stripMarkdown(md: string): string {\n return md\n .replace(/\\*\\*(.+?)\\*\\*/g, '$1')\n .replace(/__(.+?)__/g, '$1')\n .replace(/\\*(.+?)\\*/g, '$1')\n .replace(/_(.+?)_/g, '$1')\n .replace(/~~(.+?)~~/g, '$1')\n .replace(/`(.+?)`/g, '$1')\n .replace(/\\[([^\\]]+)\\]\\([^)]+\\)/g, '$1')\n .trim();\n}\n\nexport function headingText(parts: Part[], level?: number): string {\n const heading = getHeading(parts, level);\n return str(heading);\n}\n\n/** Like headingText but preserves inline markdown formatting (bold, italic, etc.) */\nexport function headingMarkdown(parts: Part[], level?: number): string {\n const heading = getHeading(parts, level);\n if (!heading) {\n return '';\n }\n const meta = heading.meta as Record<string, unknown>;\n return (meta?.markdown as string)?.trim() || str(heading);\n}\n\nexport function bodyText(parts: Part[]): string {\n const textParts = getPartsByType<Part>(parts, 'text');\n const richTextParts = getPartsByType<Part>(parts, 'richText');\n return [...textParts, ...richTextParts]\n .map(markdownOrText)\n .filter(Boolean)\n .join('\\n\\n');\n}\n\n/**\n * Entity sections may be authored as one paragraph per entity:\n * `[Product](web5://entity/...) - why it matches`.\n * In that shape, text after the first entity link is item copy rather than\n * section copy, so only keep prose that appears before the first entity link.\n */\nexport function entitySectionBodyText(parts: Part[]): string {\n const firstEntityLinkIndex = parts.findIndex(\n (p) => p.type === 'link' && isEntityHref((p as LinkPart).meta?.href),\n );\n const sectionParts =\n firstEntityLinkIndex >= 0 ? parts.slice(0, firstEntityLinkIndex) : parts;\n\n return sectionParts\n .filter((p) => p.type === 'text' || p.type === 'richText')\n .map(markdownOrText)\n .filter(Boolean)\n .join('\\n\\n');\n}\n\n/** Build HeroButton[] from link parts — aligned to HeroSection1Button shape */\nexport function linksToHeroButtons(parts: Part[]): HeroButton[] {\n let links = getLinks(parts);\n if (!links.length) {\n const lists = getPartsByType<ListPart>(parts, 'list');\n links = lists.flatMap((l) =>\n (l.meta?.items ?? []).flatMap((item) =>\n ((item.meta?.parts ?? []) as Part[]).filter(\n (p): p is LinkPart => p.type === 'link',\n ),\n ),\n );\n }\n return links.map(\n (l, i): HeroButton => ({\n id: `btn-${i}`,\n text: l.content?.trim() || 'Learn more',\n variant: i === 0 ? 'primary' : 'secondary',\n onClick: l.meta.href,\n }),\n );\n}\n\n/** Return just the src URL string of the first image part */\nexport function firstImageSrc(parts: Part[]): string | undefined {\n const images = getImages(parts);\n const img = images[0];\n return img?.meta?.src || undefined;\n}\n\n/** Return the first link as { text, href } */\nexport function firstLink(\n parts: Part[],\n): { text: string; href: string } | undefined {\n const links = getLinks(parts);\n const link = links[0];\n if (!link) {\n return undefined;\n }\n return { text: link.content?.trim() || '', href: link.meta.href };\n}\n\n/** Extract text content from blockquote parts, preserving markdown formatting when available */\nexport function blockquoteText(parts: Part[]): string | undefined {\n const bqs = getPartsByType<Part>(parts, 'blockquote');\n if (bqs.length === 0) {\n return undefined;\n }\n const text = bqs\n .map((p) => (p.meta?.markdown as string)?.trim() || str(p))\n .filter(Boolean)\n .join('\\n');\n return text || undefined;\n}\n\n/** Extract first callout from parts as a Callout object */\nexport function calloutFromParts(parts: Part[]): Callout | undefined {\n const calloutParts = getPartsByType<Part>(parts, 'callout');\n if (calloutParts.length === 0) {\n return undefined;\n }\n const p = calloutParts[0];\n const raw = (p.meta?.markdown as string)?.trim() || str(p);\n const parsed = parseCalloutTag(raw);\n return parsed.text ? { text: parsed.text, kind: parsed.kind } : undefined;\n}\n\n/** Convert list parts to a markdown-like string */\nexport function listToMarkdown(parts: Part[]): string | undefined {\n const lists = getPartsByType<ListPart>(parts, 'list');\n if (lists.length === 0) {\n return undefined;\n }\n const lines: string[] = [];\n for (const list of lists) {\n const items = list.meta?.items ?? [];\n for (const item of items) {\n const text = extractListItemText(item);\n if (text) {\n lines.push(`- ${text}`);\n }\n }\n }\n return lines.length > 0 ? lines.join('\\n') : undefined;\n}\n\n/**\n * Parse a web5://entity/ URL into entityType and entityId.\n * Delegates to the central `parseWeb5Url` parser.\n */\nexport function parseEntityUrl(\n url: string,\n): { entityType: string; entityId: string } | null {\n const trimmedUrl = url?.trim();\n if (!trimmedUrl || !isWeb5EntityUrl(trimmedUrl)) {\n return null;\n }\n const parsed = parseWeb5Url(trimmedUrl);\n if (\n parsed?.type !== Web5UrlType.ENTITY ||\n !parsed.entityType ||\n !parsed.entityId\n ) {\n return null;\n }\n return { entityType: parsed.entityType, entityId: parsed.entityId };\n}\n\n/**\n * Parse a table cell value into boolean or string.\n * Ported from web50-server-ui comparisonSectionParser.tsx.\n */\nexport function parseTableValue(value: string): boolean | string {\n const normalized = value.trim().toLowerCase();\n\n if (\n normalized === 'true' ||\n normalized === 'yes' ||\n normalized === '✓' ||\n normalized === 'check' ||\n normalized === 'y'\n ) {\n return true;\n }\n if (\n normalized === 'false' ||\n normalized === 'no' ||\n normalized === '✗' ||\n normalized === 'x' ||\n normalized === 'n' ||\n normalized === ''\n ) {\n return false;\n }\n\n return value.trim();\n}\n\n/**\n * Parse a KPI item from markdown text.\n * The first **bold** segment becomes the title; everything after it (leading \":\" stripped) is the description.\n */\nexport function parseKpiItem(\n markdown: string,\n): { title: string; description: string } | null {\n const trimmed = markdown.trim();\n if (!trimmed) {\n return null;\n }\n const boldMatch = trimmed.match(/\\*\\*(.+?)\\*\\*/);\n if (!boldMatch) {\n return null;\n }\n const title = boldMatch[1].trim();\n const afterBold = trimmed.slice(\n trimmed.indexOf(boldMatch[0]) + boldMatch[0].length,\n );\n const description = afterBold.replace(/^[:\\s]+/, '').trim();\n return { title, description };\n}\n\n/** Join inline tokens the way prose reads: single spaces, none before punctuation. */\nfunction appendInlineToken(current: string, token: string): string {\n const trimmed = token.trim();\n if (!trimmed) {\n return current;\n }\n if (!current) {\n return trimmed;\n }\n if (/^[,.;:!?)]/.test(trimmed)) {\n return `${current}${trimmed}`;\n }\n return `${current} ${trimmed}`;\n}\n\n/**\n * Serialize a run of inline parts back to markdown, preserving links.\n *\n * Concatenating `part.content` alone silently deletes links: a `link` part\n * keeps its label in `content` and its url in `meta.href`, so a filter that\n * reads only text parts turns `Read the [pricing page](/pricing) first` into\n * `Read the first` — url and label both vanish, with nothing in the output to\n * show anything was lost.\n */\nexport function inlinePartsToMarkdown(parts: Part[]): string {\n return parts.reduce((text, part) => {\n if (part.type === 'link') {\n const href = (part as LinkPart).meta?.href ?? '';\n const label = part.content?.trim() ?? '';\n return appendInlineToken(text, href ? `[${label}](${href})` : label);\n }\n return appendInlineToken(text, part.content ?? '');\n }, '');\n}\n\nexport function extractListItemText(item: ListItemPart): string {\n if (item.content) {\n return item.content;\n }\n if (item.meta?.parts) {\n return (item.meta.parts as Part[])\n .map((p) => p.content)\n .filter(Boolean)\n .join(' ');\n }\n return '';\n}\n\n/**\n * Reconstruct markdown-like content from parts.\n *\n * `part.content` is the *plain* text — `nodesToParts` strips inline\n * formatting and preserves the original markdown (bold, italic, links) in\n * `part.meta.markdown` when they differ. Prefer it so markdown-rendering\n * consumers (e.g. the fallback section's ReactMarkdown) keep `**bold**`.\n */\nexport function partsToMarkdown(sectionParts: Part[]): string {\n const inline = (part: Part): string =>\n (part.meta?.markdown as string | undefined) ?? part.content;\n const lines: string[] = [];\n for (const part of sectionParts) {\n if (part.type === 'heading') {\n const level = (part.meta as { level: number })?.level ?? 2;\n lines.push(`${'#'.repeat(level)} ${inline(part)}`);\n } else if (part.type === 'text' || part.type === 'richText') {\n lines.push(inline(part));\n } else if (part.type === 'list') {\n const list = part as ListPart;\n for (const item of list.meta?.items ?? []) {\n lines.push(\n `- ${(item.meta?.markdown as string | undefined) ?? extractListItemText(item)}`,\n );\n }\n } else if (part.type === 'blockquote' || part.type === 'callout') {\n lines.push(`> ${inline(part)}`);\n }\n }\n return lines.join('\\n\\n');\n}\n\n/**\n * Extract callout kind tag from blockquote text.\n * Handles [!NOTE], [!TIP], [!IMPORTANT], [!WARNING], [!CAUTION] GFM syntax.\n */\nexport function parseCalloutTag(text: string): { text: string; kind?: string } {\n const match = text.match(/^\\[!(\\w+)\\]\\s*(.*)/s);\n if (match) {\n return { kind: match[1].toUpperCase(), text: match[2].trim() };\n }\n return { text: text.trim() };\n}\n\n/** Generate a simple unique ID */\nexport function generatePartId(): string {\n return Math.random().toString(36).slice(2, 10);\n}\n\nfunction isEntityHref(href: string | undefined): boolean {\n return !!href && isWeb5EntityUrl(href);\n}\n\nexport interface EntityRef {\n entityId: string;\n entityType: string;\n linkText: string;\n entityUrl: string;\n description: string;\n markdownImageUrl?: string;\n markdownFeatures?: string[];\n callout?: Callout;\n}\n\n/**\n * Extract text from nested list items within a list item's parts.\n */\nfunction extractNestedListItems(itemParts: Part[]): string[] {\n const nestedLists = itemParts.filter((p): p is ListPart => p.type === 'list');\n const features: string[] = [];\n for (const list of nestedLists) {\n for (const nested of list.meta?.items ?? []) {\n const text = extractListItemText(nested);\n if (text) {\n features.push(text);\n }\n }\n }\n return features;\n}\n\n/**\n * Extract entity references from list items containing web5://entity/ links.\n * Also extracts markdownFeatures from nested list items within each entity item.\n */\nexport function extractEntityRefs(parts: Part[]): EntityRef[] {\n const entities: EntityRef[] = [];\n const lists = getPartsByType<ListPart>(parts, 'list');\n\n for (const list of lists) {\n for (const item of list.meta?.items ?? []) {\n const itemParts = (item.meta?.parts ?? []) as Part[];\n const entityLinks = itemParts.filter(\n (p): p is LinkPart =>\n p.type === 'link' && isEntityHref((p as LinkPart).meta?.href),\n );\n\n for (const link of entityLinks) {\n const parsed = parseEntityUrl(link.meta.href);\n if (parsed) {\n const images = itemParts.filter(\n (p): p is ImagePart => p.type === 'image',\n );\n const textParts = itemParts.filter(\n (p) => p.type === 'text' && p.content?.trim(),\n );\n const description = normalizeEntityDescription(\n textParts.map(markdownOrText).join(' '),\n );\n const features = extractNestedListItems(itemParts);\n const calloutParts = itemParts.filter(\n (p) => p.type === 'callout' || p.type === 'blockquote',\n );\n let callout: Callout | undefined;\n if (calloutParts.length > 0) {\n const raw =\n (calloutParts[0].meta?.markdown as string)?.trim() ||\n str(calloutParts[0]);\n const parsed2 = parseCalloutTag(raw);\n if (parsed2.text) {\n callout = { text: parsed2.text, kind: parsed2.kind };\n }\n }\n entities.push({\n entityId: parsed.entityId,\n entityType: parsed.entityType,\n linkText: link.content?.trim() || '',\n entityUrl: link.meta.href,\n description,\n markdownImageUrl: images[0]?.meta?.src,\n markdownFeatures: features.length > 0 ? features : undefined,\n callout,\n });\n }\n }\n }\n }\n\n // Also check top-level links (with surrounding context for description/image/list)\n const topLinks = getLinks(parts).filter((l) => isEntityHref(l.meta?.href));\n for (const link of topLinks) {\n const parsed = parseEntityUrl(link.meta.href);\n if (parsed && !entities.some((e) => e.entityId === parsed.entityId)) {\n // Look for description text and image after this link in the parts array\n const linkIndex = parts.indexOf(link);\n let description = '';\n let markdownImageUrl: string | undefined;\n let callout: Callout | undefined;\n const features: string[] = [];\n\n if (linkIndex >= 0) {\n // Scan following parts for description, image, callout, and list items\n for (let j = linkIndex + 1; j < parts.length; j++) {\n const p = parts[j];\n // Stop at next entity link\n if (p.type === 'link' && isEntityHref((p as LinkPart).meta?.href)) {\n break;\n }\n if (p.type === 'text' && p.content?.trim()) {\n const text = markdownOrText(p);\n description = description\n ? `${description} ${text}`\n : text;\n } else if (p.type === 'image' && !markdownImageUrl) {\n markdownImageUrl = (p as ImagePart).meta?.src;\n } else if (\n (p.type === 'callout' || p.type === 'blockquote') &&\n !callout\n ) {\n const raw = (p.meta?.markdown as string)?.trim() || str(p);\n const parsedCallout = parseCalloutTag(raw);\n if (parsedCallout.text) {\n callout = { text: parsedCallout.text, kind: parsedCallout.kind };\n }\n } else if (p.type === 'list') {\n for (const item of (p as ListPart).meta?.items ?? []) {\n const text = extractListItemText(item);\n if (text) {\n features.push(text);\n }\n }\n }\n }\n }\n\n entities.push({\n entityId: parsed.entityId,\n entityType: parsed.entityType,\n linkText: link.content?.trim() || '',\n entityUrl: link.meta.href,\n description: normalizeEntityDescription(description),\n markdownImageUrl,\n markdownFeatures: features.length > 0 ? features : undefined,\n callout,\n });\n }\n }\n\n return entities;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAOA,IAAAA,MAAA,GAAAC,OAAA;AAMA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAIA,SAASG,GAAGA,CAACC,CAAmB,EAAU;EAAA,IAAAC,UAAA;EACxC,OAAO,CAAAD,CAAC,aAAAC,UAAA,GAADD,CAAC,CA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M1G,IAAI,GAAG2B,mBAAmB,CAAChC,IAAI,CAAC;cACtC,IAAIK,IAAI,EAAE;gBACR2E,QAAQ,CAAC/C,IAAI,CAAC5B,IAAI,CAAC;cACrB;YACF;UACF;QACF;MACF;MAEA+E,QAAQ,CAACnD,IAAI,CAAC;QACZS,QAAQ,EAAEjB,MAAM,CAACiB,QAAQ;QACzBD,UAAU,EAAEhB,MAAM,CAACgB,UAAU;QAC7BsD,QAAQ,EAAE,EAAAQ,cAAA,GAAAtF,IAAI,CAAC7D,OAAO,qBAAZmJ,cAAA,CAAclJ,IAAI,CAAC,CAAC,KAAI,EAAE;QACpC2I,SAAS,EAAE/E,IAAI,CAACzD,IAAI,CAAC4B,IAAI;QACzBzB,WAAW,EAAED,0BAA0B,CAACC,WAAW,CAAC;QACpDsI,gBAAgB;QAChBC,gBAAgB,EAAElB,QAAQ,CAACtF,MAAM,GAAG,CAAC,GAAGsF,QAAQ,GAAGlE,SAAS;QAC5D8E;MACF,CAAC,CAAC;IACJ;EACF;EAEA,OAAOR,QAAQ;AACjB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_parts","require","_entityLinkParser","_linkTypes","str","p","_p$content","content","trim","markdownOrText","_p$meta","meta","markdown","normalizeEntityDescription","description","replace","stripMarkdown","md","headingText","parts","level","heading","getHeading","headingMarkdown","_meta$markdown","bodyText","textParts","getPartsByType","richTextParts","map","filter","Boolean","join","entitySectionBodyText","firstEntityLinkIndex","findIndex","_meta","type","isEntityHref","href","sectionParts","slice","linksToHeroButtons","links","getLinks","length","lists","flatMap","l","_l$meta","items","item","_item$meta","i","_l$content","id","text","variant","onClick","firstImageSrc","_img$meta","images","getImages","img","src","undefined","firstLink","_link$content","link","blockquoteText","bqs","_p$meta2","calloutFromParts","_p$meta3","calloutParts","raw","parsed","parseCalloutTag","kind","listToMarkdown","lines","list","_list$meta","extractListItemText","push","parseEntityUrl","url","trimmedUrl","isWeb5EntityUrl","parseWeb5Url","Web5UrlType","ENTITY","entityType","entityId","parseTableValue","value","normalized","toLowerCase","parseKpiItem","trimmed","boldMatch","match","title","afterBold","indexOf","appendInlineToken","current","token","test","inlinePartsToMarkdown","reduce","part","_part$meta","_meta2","_part$content","label","_item$meta2","partsToMarkdown","inline","_part$meta2","_part$meta3","repeat","_list$meta2","_item$meta3","toUpperCase","generatePartId","Math","random","toString","extractNestedListItems","itemParts","nestedLists","features","nested","_list$meta3","extractEntityRefs","entities","_list$meta4","_item$meta4","entityLinks","_meta3","_link$content2","_images$","_p$content2","callout","_calloutParts$0$meta","parsed2","linkText","entityUrl","markdownImageUrl","markdownFeatures","topLinks","_l$meta2","some","e","_link$content3","linkIndex","j","_meta4","_p$content3","_meta5","_p$meta4","parsedCallout","_meta6"],"sources":["../../../../src/component/componentDefinitions/parse-utils.ts"],"sourcesContent":["import type {\n Part,\n ListPart,\n LinkPart,\n ListItemPart,\n ImagePart,\n} from '../../parts/parts';\nimport {\n getPartsByType,\n getHeading,\n getImages,\n getLinks,\n} from '../../parts/parts';\nimport { parseWeb5Url } from '../../utils/entityLinkParser';\nimport { Web5UrlType, isWeb5EntityUrl } from '../../types/link-types';\nimport type { Callout } from '../../types/callout';\nimport type { HeroButton } from '../types';\n\nfunction str(p: Part | undefined): string {\n return p?.content?.trim() ?? '';\n}\n\nfunction markdownOrText(p: Part): string {\n return ((p.meta?.markdown as string)?.trim() || str(p)).trim();\n}\n\nfunction normalizeEntityDescription(description: string): string {\n return description\n .replace(/^[\\s\\u2013\\u2014-]+/, '')\n .replace(/^[:\\s]+/, '')\n .trim();\n}\n\n/** Strip basic markdown formatting to get plain text */\nexport function stripMarkdown(md: string): string {\n return md\n .replace(/\\*\\*(.+?)\\*\\*/g, '$1')\n .replace(/__(.+?)__/g, '$1')\n .replace(/\\*(.+?)\\*/g, '$1')\n .replace(/_(.+?)_/g, '$1')\n .replace(/~~(.+?)~~/g, '$1')\n .replace(/`(.+?)`/g, '$1')\n .replace(/\\[([^\\]]+)\\]\\([^)]+\\)/g, '$1')\n .trim();\n}\n\nexport function headingText(parts: Part[], level?: number): string {\n const heading = getHeading(parts, level);\n return str(heading);\n}\n\n/** Like headingText but preserves inline markdown formatting (bold, italic, etc.) */\nexport function headingMarkdown(parts: Part[], level?: number): string {\n const heading = getHeading(parts, level);\n if (!heading) {\n return '';\n }\n const meta = heading.meta as Record<string, unknown>;\n return (meta?.markdown as string)?.trim() || str(heading);\n}\n\nexport function bodyText(parts: Part[]): string {\n const textParts = getPartsByType<Part>(parts, 'text');\n const richTextParts = getPartsByType<Part>(parts, 'richText');\n return [...textParts, ...richTextParts]\n .map(markdownOrText)\n .filter(Boolean)\n .join('\\n\\n');\n}\n\n/**\n * Entity sections may be authored as one paragraph per entity:\n * `[Product](web5://entity/...) - why it matches`.\n * In that shape, text after the first entity link is item copy rather than\n * section copy, so only keep prose that appears before the first entity link.\n */\nexport function entitySectionBodyText(parts: Part[]): string {\n const firstEntityLinkIndex = parts.findIndex(\n (p) => p.type === 'link' && isEntityHref((p as LinkPart).meta?.href),\n );\n const sectionParts =\n firstEntityLinkIndex >= 0 ? parts.slice(0, firstEntityLinkIndex) : parts;\n\n return sectionParts\n .filter((p) => p.type === 'text' || p.type === 'richText')\n .map(markdownOrText)\n .filter(Boolean)\n .join('\\n\\n');\n}\n\n/** Build HeroButton[] from link parts — aligned to HeroSection1Button shape */\nexport function linksToHeroButtons(parts: Part[]): HeroButton[] {\n let links = getLinks(parts);\n if (!links.length) {\n const lists = getPartsByType<ListPart>(parts, 'list');\n links = lists.flatMap((l) =>\n (l.meta?.items ?? []).flatMap((item) =>\n ((item.meta?.parts ?? []) as Part[]).filter(\n (p): p is LinkPart => p.type === 'link',\n ),\n ),\n );\n }\n return links.map(\n (l, i): HeroButton => ({\n id: `btn-${i}`,\n text: l.content?.trim() || 'Learn more',\n variant: i === 0 ? 'primary' : 'secondary',\n onClick: l.meta.href,\n }),\n );\n}\n\n/** Return just the src URL string of the first image part */\nexport function firstImageSrc(parts: Part[]): string | undefined {\n const images = getImages(parts);\n const img = images[0];\n return img?.meta?.src || undefined;\n}\n\n/** Return the first link as { text, href } */\nexport function firstLink(\n parts: Part[],\n): { text: string; href: string } | undefined {\n const links = getLinks(parts);\n const link = links[0];\n if (!link) {\n return undefined;\n }\n return { text: link.content?.trim() || '', href: link.meta.href };\n}\n\n/** Extract text content from blockquote parts, preserving markdown formatting when available */\nexport function blockquoteText(parts: Part[]): string | undefined {\n const bqs = getPartsByType<Part>(parts, 'blockquote');\n if (bqs.length === 0) {\n return undefined;\n }\n const text = bqs\n .map((p) => (p.meta?.markdown as string)?.trim() || str(p))\n .filter(Boolean)\n .join('\\n');\n return text || undefined;\n}\n\n/** Extract first callout from parts as a Callout object */\nexport function calloutFromParts(parts: Part[]): Callout | undefined {\n const calloutParts = getPartsByType<Part>(parts, 'callout');\n if (calloutParts.length === 0) {\n return undefined;\n }\n const p = calloutParts[0];\n const raw = (p.meta?.markdown as string)?.trim() || str(p);\n const parsed = parseCalloutTag(raw);\n return parsed.text ? { text: parsed.text, kind: parsed.kind } : undefined;\n}\n\n/** Convert list parts to a markdown-like string */\nexport function listToMarkdown(parts: Part[]): string | undefined {\n const lists = getPartsByType<ListPart>(parts, 'list');\n if (lists.length === 0) {\n return undefined;\n }\n const lines: string[] = [];\n for (const list of lists) {\n const items = list.meta?.items ?? [];\n for (const item of items) {\n const text = extractListItemText(item);\n if (text) {\n lines.push(`- ${text}`);\n }\n }\n }\n return lines.length > 0 ? lines.join('\\n') : undefined;\n}\n\n/**\n * Parse a web5://entity/ URL into entityType and entityId.\n * Delegates to the central `parseWeb5Url` parser.\n */\nexport function parseEntityUrl(\n url: string,\n): { entityType: string; entityId: string } | null {\n const trimmedUrl = url?.trim();\n if (!trimmedUrl || !isWeb5EntityUrl(trimmedUrl)) {\n return null;\n }\n const parsed = parseWeb5Url(trimmedUrl);\n if (\n parsed?.type !== Web5UrlType.ENTITY ||\n !parsed.entityType ||\n !parsed.entityId\n ) {\n return null;\n }\n return { entityType: parsed.entityType, entityId: parsed.entityId };\n}\n\n/**\n * Parse a table cell value into boolean or string.\n * Ported from web50-server-ui comparisonSectionParser.tsx.\n */\nexport function parseTableValue(value: string): boolean | string {\n const normalized = value.trim().toLowerCase();\n\n if (\n normalized === 'true' ||\n normalized === 'yes' ||\n normalized === '✓' ||\n normalized === 'check' ||\n normalized === 'y'\n ) {\n return true;\n }\n if (\n normalized === 'false' ||\n normalized === 'no' ||\n normalized === '✗' ||\n normalized === 'x' ||\n normalized === 'n' ||\n normalized === ''\n ) {\n return false;\n }\n\n return value.trim();\n}\n\n/**\n * Parse a KPI item from markdown text.\n * The first **bold** segment becomes the title; everything after it (leading \":\" stripped) is the description.\n */\nexport function parseKpiItem(\n markdown: string,\n): { title: string; description: string } | null {\n const trimmed = markdown.trim();\n if (!trimmed) {\n return null;\n }\n const boldMatch = trimmed.match(/\\*\\*(.+?)\\*\\*/);\n if (!boldMatch) {\n return null;\n }\n const title = boldMatch[1].trim();\n const afterBold = trimmed.slice(\n trimmed.indexOf(boldMatch[0]) + boldMatch[0].length,\n );\n const description = afterBold.replace(/^[:\\s]+/, '').trim();\n return { title, description };\n}\n\n/** Join inline tokens the way prose reads: single spaces, none before punctuation. */\nfunction appendInlineToken(current: string, token: string): string {\n const trimmed = token.trim();\n if (!trimmed) {\n return current;\n }\n if (!current) {\n return trimmed;\n }\n if (/^[,.;:!?)]/.test(trimmed)) {\n return `${current}${trimmed}`;\n }\n return `${current} ${trimmed}`;\n}\n\n/**\n * Serialize a run of inline parts back to markdown, preserving links and\n * inline emphasis.\n *\n * Concatenating `part.content` alone silently deletes links: a `link` part\n * keeps its label in `content` and its url in `meta.href`, so a filter that\n * reads only text parts turns `Read the [pricing page](/pricing) first` into\n * `Read the first` — url and label both vanish, with nothing in the output to\n * show anything was lost.\n *\n * `content` is also the *plain* text of a text part — `nodesToParts` strips\n * inline formatting and keeps the original in `meta.markdown` whenever the two\n * differ. Reading `content` therefore drops emphasis the same way it used to\n * drop links: `The **4 oz size** is best` becomes `The 4 oz size is best`.\n * Prefer `meta.markdown`, which is exactly the segment's own markdown.\n */\nexport function inlinePartsToMarkdown(parts: Part[]): string {\n return parts.reduce((text, part) => {\n if (part.type === 'link') {\n const href = (part as LinkPart).meta?.href ?? '';\n const label = part.content?.trim() ?? '';\n return appendInlineToken(text, href ? `[${label}](${href})` : label);\n }\n return appendInlineToken(\n text,\n (part.meta?.markdown as string | undefined) ?? part.content ?? '',\n );\n }, '');\n}\n\nexport function extractListItemText(item: ListItemPart): string {\n if (item.content) {\n return item.content;\n }\n if (item.meta?.parts) {\n return (item.meta.parts as Part[])\n .map((p) => p.content)\n .filter(Boolean)\n .join(' ');\n }\n return '';\n}\n\n/**\n * Reconstruct markdown-like content from parts.\n *\n * `part.content` is the *plain* text — `nodesToParts` strips inline\n * formatting and preserves the original markdown (bold, italic, links) in\n * `part.meta.markdown` when they differ. Prefer it so markdown-rendering\n * consumers (e.g. the fallback section's ReactMarkdown) keep `**bold**`.\n */\nexport function partsToMarkdown(sectionParts: Part[]): string {\n const inline = (part: Part): string =>\n (part.meta?.markdown as string | undefined) ?? part.content;\n const lines: string[] = [];\n for (const part of sectionParts) {\n if (part.type === 'heading') {\n const level = (part.meta as { level: number })?.level ?? 2;\n lines.push(`${'#'.repeat(level)} ${inline(part)}`);\n } else if (part.type === 'text' || part.type === 'richText') {\n lines.push(inline(part));\n } else if (part.type === 'list') {\n const list = part as ListPart;\n for (const item of list.meta?.items ?? []) {\n lines.push(\n `- ${(item.meta?.markdown as string | undefined) ?? extractListItemText(item)}`,\n );\n }\n } else if (part.type === 'blockquote' || part.type === 'callout') {\n lines.push(`> ${inline(part)}`);\n }\n }\n return lines.join('\\n\\n');\n}\n\n/**\n * Extract callout kind tag from blockquote text.\n * Handles [!NOTE], [!TIP], [!IMPORTANT], [!WARNING], [!CAUTION] GFM syntax.\n */\nexport function parseCalloutTag(text: string): { text: string; kind?: string } {\n const match = text.match(/^\\[!(\\w+)\\]\\s*(.*)/s);\n if (match) {\n return { kind: match[1].toUpperCase(), text: match[2].trim() };\n }\n return { text: text.trim() };\n}\n\n/** Generate a simple unique ID */\nexport function generatePartId(): string {\n return Math.random().toString(36).slice(2, 10);\n}\n\nfunction isEntityHref(href: string | undefined): boolean {\n return !!href && isWeb5EntityUrl(href);\n}\n\nexport interface EntityRef {\n entityId: string;\n entityType: string;\n linkText: string;\n entityUrl: string;\n description: string;\n markdownImageUrl?: string;\n markdownFeatures?: string[];\n callout?: Callout;\n}\n\n/**\n * Extract text from nested list items within a list item's parts.\n */\nfunction extractNestedListItems(itemParts: Part[]): string[] {\n const nestedLists = itemParts.filter((p): p is ListPart => p.type === 'list');\n const features: string[] = [];\n for (const list of nestedLists) {\n for (const nested of list.meta?.items ?? []) {\n const text = extractListItemText(nested);\n if (text) {\n features.push(text);\n }\n }\n }\n return features;\n}\n\n/**\n * Extract entity references from list items containing web5://entity/ links.\n * Also extracts markdownFeatures from nested list items within each entity item.\n */\nexport function extractEntityRefs(parts: Part[]): EntityRef[] {\n const entities: EntityRef[] = [];\n const lists = getPartsByType<ListPart>(parts, 'list');\n\n for (const list of lists) {\n for (const item of list.meta?.items ?? []) {\n const itemParts = (item.meta?.parts ?? []) as Part[];\n const entityLinks = itemParts.filter(\n (p): p is LinkPart =>\n p.type === 'link' && isEntityHref((p as LinkPart).meta?.href),\n );\n\n for (const link of entityLinks) {\n const parsed = parseEntityUrl(link.meta.href);\n if (parsed) {\n const images = itemParts.filter(\n (p): p is ImagePart => p.type === 'image',\n );\n const textParts = itemParts.filter(\n (p) => p.type === 'text' && p.content?.trim(),\n );\n const description = normalizeEntityDescription(\n textParts.map(markdownOrText).join(' '),\n );\n const features = extractNestedListItems(itemParts);\n const calloutParts = itemParts.filter(\n (p) => p.type === 'callout' || p.type === 'blockquote',\n );\n let callout: Callout | undefined;\n if (calloutParts.length > 0) {\n const raw =\n (calloutParts[0].meta?.markdown as string)?.trim() ||\n str(calloutParts[0]);\n const parsed2 = parseCalloutTag(raw);\n if (parsed2.text) {\n callout = { text: parsed2.text, kind: parsed2.kind };\n }\n }\n entities.push({\n entityId: parsed.entityId,\n entityType: parsed.entityType,\n linkText: link.content?.trim() || '',\n entityUrl: link.meta.href,\n description,\n markdownImageUrl: images[0]?.meta?.src,\n markdownFeatures: features.length > 0 ? features : undefined,\n callout,\n });\n }\n }\n }\n }\n\n // Also check top-level links (with surrounding context for description/image/list)\n const topLinks = getLinks(parts).filter((l) => isEntityHref(l.meta?.href));\n for (const link of topLinks) {\n const parsed = parseEntityUrl(link.meta.href);\n if (parsed && !entities.some((e) => e.entityId === parsed.entityId)) {\n // Look for description text and image after this link in the parts array\n const linkIndex = parts.indexOf(link);\n let description = '';\n let markdownImageUrl: string | undefined;\n let callout: Callout | undefined;\n const features: string[] = [];\n\n if (linkIndex >= 0) {\n // Scan following parts for description, image, callout, and list items\n for (let j = linkIndex + 1; j < parts.length; j++) {\n const p = parts[j];\n // Stop at next entity link\n if (p.type === 'link' && isEntityHref((p as LinkPart).meta?.href)) {\n break;\n }\n if (p.type === 'text' && p.content?.trim()) {\n const text = markdownOrText(p);\n description = description\n ? `${description} ${text}`\n : text;\n } else if (p.type === 'image' && !markdownImageUrl) {\n markdownImageUrl = (p as ImagePart).meta?.src;\n } else if (\n (p.type === 'callout' || p.type === 'blockquote') &&\n !callout\n ) {\n const raw = (p.meta?.markdown as string)?.trim() || str(p);\n const parsedCallout = parseCalloutTag(raw);\n if (parsedCallout.text) {\n callout = { text: parsedCallout.text, kind: parsedCallout.kind };\n }\n } else if (p.type === 'list') {\n for (const item of (p as ListPart).meta?.items ?? []) {\n const text = extractListItemText(item);\n if (text) {\n features.push(text);\n }\n }\n }\n }\n }\n\n entities.push({\n entityId: parsed.entityId,\n entityType: parsed.entityType,\n linkText: link.content?.trim() || '',\n entityUrl: link.meta.href,\n description: normalizeEntityDescription(description),\n markdownImageUrl,\n markdownFeatures: features.length > 0 ? features : undefined,\n callout,\n });\n }\n }\n\n return entities;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;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,EAAE;cACtBwF,OAAO,GAAG;gBAAExF,IAAI,EAAE0G,aAAa,CAAC1G,IAAI;gBAAEsB,IAAI,EAAEoF,aAAa,CAACpF;cAAK,CAAC;YAClE;UACF,CAAC,MAAM,IAAIzE,CAAC,CAACgC,IAAI,KAAK,MAAM,EAAE;YAC5B,KAAK,MAAMc,IAAI,IAAI,EAAAgH,MAAA,GAAC9J,CAAC,CAAcM,IAAI,qBAApBwJ,MAAA,CAAsBjH,KAAK,KAAI,EAAE,EAAE;cAAA,IAAAiH,MAAA;cACpD,MAAM3G,IAAI,GAAG2B,mBAAmB,CAAChC,IAAI,CAAC;cACtC,IAAIK,IAAI,EAAE;gBACR4E,QAAQ,CAAChD,IAAI,CAAC5B,IAAI,CAAC;cACrB;YACF;UACF;QACF;MACF;MAEAgF,QAAQ,CAACpD,IAAI,CAAC;QACZS,QAAQ,EAAEjB,MAAM,CAACiB,QAAQ;QACzBD,UAAU,EAAEhB,MAAM,CAACgB,UAAU;QAC7BuD,QAAQ,EAAE,EAAAQ,cAAA,GAAAvF,IAAI,CAAC7D,OAAO,qBAAZoJ,cAAA,CAAcnJ,IAAI,CAAC,CAAC,KAAI,EAAE;QACpC4I,SAAS,EAAEhF,IAAI,CAACzD,IAAI,CAAC4B,IAAI;QACzBzB,WAAW,EAAED,0BAA0B,CAACC,WAAW,CAAC;QACpDuI,gBAAgB;QAChBC,gBAAgB,EAAElB,QAAQ,CAACvF,MAAM,GAAG,CAAC,GAAGuF,QAAQ,GAAGnE,SAAS;QAC5D+E;MACF,CAAC,CAAC;IACJ;EACF;EAEA,OAAOR,QAAQ;AACjB","ignoreList":[]}
|
package/dist/cjs/entity/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.formatProductPriceLabel = exports.formatPriceField = exports.formatMoney = exports.fetchEntityListData = exports.enrichEntitiesFromPayload = exports.LIST_ITEMS_ENDPOINT = void 0;
|
|
5
5
|
exports.getEntityExtractor = getEntityExtractor;
|
|
6
|
-
exports.readCurrencyCode = exports.listEntityItems = void 0;
|
|
6
|
+
exports.readCurrencyCode = exports.mergeEntityData = exports.listEntityItems = void 0;
|
|
7
7
|
exports.registerEntityExtractor = registerEntityExtractor;
|
|
8
8
|
exports.transformToSolutionEntityData = exports.transformToGenericEntityData = exports.transformToBlogPostEntityData = exports.toMatchedOptions = void 0;
|
|
9
9
|
var _defaultExtractor = require("./defaultExtractor");
|
|
@@ -13,6 +13,8 @@ exports.transformToBlogPostEntityData = _defaultExtractor.transformToBlogPostEnt
|
|
|
13
13
|
exports.transformToGenericEntityData = _defaultExtractor.transformToGenericEntityData;
|
|
14
14
|
var _enrichEntitiesFromPayload = require("./enrichEntitiesFromPayload");
|
|
15
15
|
exports.enrichEntitiesFromPayload = _enrichEntitiesFromPayload.enrichEntitiesFromPayload;
|
|
16
|
+
var _mergeEntityData = require("./mergeEntityData");
|
|
17
|
+
exports.mergeEntityData = _mergeEntityData.mergeEntityData;
|
|
16
18
|
var _matchedVariant = require("./matchedVariant");
|
|
17
19
|
exports.toMatchedOptions = _matchedVariant.toMatchedOptions;
|
|
18
20
|
exports.formatMoney = _matchedVariant.formatMoney;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_defaultExtractor","require","exports","defaultExtractor","transformToSolutionEntityData","transformToBlogPostEntityData","transformToGenericEntityData","_enrichEntitiesFromPayload","enrichEntitiesFromPayload","_matchedVariant","toMatchedOptions","formatMoney","readCurrencyCode","formatPriceField","formatProductPriceLabel","_fetchEntityListData","fetchEntityListData","_listEntityItems","listEntityItems","LIST_ITEMS_ENDPOINT","extractorRegistry","getEntityExtractor","clientId","registerEntityExtractor","extractor"],"sources":["../../../src/entity/index.ts"],"sourcesContent":["import type { EntityExtractor } from './types';\nimport { defaultExtractor } from './defaultExtractor';\n\nexport {\n defaultExtractor,\n transformToSolutionEntityData,\n transformToBlogPostEntityData,\n transformToGenericEntityData,\n} from './defaultExtractor';\n\nexport { enrichEntitiesFromPayload } from './enrichEntitiesFromPayload';\nexport {\n toMatchedOptions,\n formatMoney,\n readCurrencyCode,\n formatPriceField,\n formatProductPriceLabel,\n type MatchedOption,\n type ProductPriceFields,\n} from './matchedVariant';\nexport {\n fetchEntityListData,\n type FetchEntityListDataOptions,\n} from './fetchEntityListData';\nexport {\n listEntityItems,\n LIST_ITEMS_ENDPOINT,\n type ListEntityItemsOptions,\n} from './listEntityItems';\n\nexport type { EntityExtractor } from './types';\n\n/**\n * Registry of client-specific entity extractors.\n * Only needed if a client requires custom extraction logic beyond the config-driven default.\n */\nconst extractorRegistry: Record<string, EntityExtractor> = {};\n\n/**\n * Get the entity extractor for a specific client.\n * The default extractor is config-driven and works for any client with entityConfig.\n */\nexport function getEntityExtractor(clientId?: string): EntityExtractor {\n if (clientId && extractorRegistry[clientId]) {\n return extractorRegistry[clientId];\n }\n return defaultExtractor;\n}\n\n/**\n * Register a custom entity extractor for a client\n * Useful for runtime registration or testing\n */\nexport function registerEntityExtractor(\n clientId: string,\n extractor: EntityExtractor,\n): void {\n extractorRegistry[clientId] = extractor;\n}\n"],"mappings":";;;;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AAAsDC,OAAA,CAAAC,gBAAA,GAAAH,iBAAA,CAAAG,gBAAA;AAAAD,OAAA,CAAAE,6BAAA,GAAAJ,iBAAA,CAAAI,6BAAA;AAAAF,OAAA,CAAAG,6BAAA,GAAAL,iBAAA,CAAAK,6BAAA;AAAAH,OAAA,CAAAI,4BAAA,GAAAN,iBAAA,CAAAM,4BAAA;AAStD,IAAAC,0BAAA,GAAAN,OAAA;AAAwEC,OAAA,CAAAM,yBAAA,GAAAD,0BAAA,CAAAC,yBAAA;AACxE,IAAAC,
|
|
1
|
+
{"version":3,"names":["_defaultExtractor","require","exports","defaultExtractor","transformToSolutionEntityData","transformToBlogPostEntityData","transformToGenericEntityData","_enrichEntitiesFromPayload","enrichEntitiesFromPayload","_mergeEntityData","mergeEntityData","_matchedVariant","toMatchedOptions","formatMoney","readCurrencyCode","formatPriceField","formatProductPriceLabel","_fetchEntityListData","fetchEntityListData","_listEntityItems","listEntityItems","LIST_ITEMS_ENDPOINT","extractorRegistry","getEntityExtractor","clientId","registerEntityExtractor","extractor"],"sources":["../../../src/entity/index.ts"],"sourcesContent":["import type { EntityExtractor } from './types';\nimport { defaultExtractor } from './defaultExtractor';\n\nexport {\n defaultExtractor,\n transformToSolutionEntityData,\n transformToBlogPostEntityData,\n transformToGenericEntityData,\n} from './defaultExtractor';\n\nexport { enrichEntitiesFromPayload } from './enrichEntitiesFromPayload';\nexport { mergeEntityData } from './mergeEntityData';\nexport {\n toMatchedOptions,\n formatMoney,\n readCurrencyCode,\n formatPriceField,\n formatProductPriceLabel,\n type MatchedOption,\n type ProductPriceFields,\n} from './matchedVariant';\nexport {\n fetchEntityListData,\n type FetchEntityListDataOptions,\n} from './fetchEntityListData';\nexport {\n listEntityItems,\n LIST_ITEMS_ENDPOINT,\n type ListEntityItemsOptions,\n} from './listEntityItems';\n\nexport type { EntityExtractor } from './types';\n\n/**\n * Registry of client-specific entity extractors.\n * Only needed if a client requires custom extraction logic beyond the config-driven default.\n */\nconst extractorRegistry: Record<string, EntityExtractor> = {};\n\n/**\n * Get the entity extractor for a specific client.\n * The default extractor is config-driven and works for any client with entityConfig.\n */\nexport function getEntityExtractor(clientId?: string): EntityExtractor {\n if (clientId && extractorRegistry[clientId]) {\n return extractorRegistry[clientId];\n }\n return defaultExtractor;\n}\n\n/**\n * Register a custom entity extractor for a client\n * Useful for runtime registration or testing\n */\nexport function registerEntityExtractor(\n clientId: string,\n extractor: EntityExtractor,\n): void {\n extractorRegistry[clientId] = extractor;\n}\n"],"mappings":";;;;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AAAsDC,OAAA,CAAAC,gBAAA,GAAAH,iBAAA,CAAAG,gBAAA;AAAAD,OAAA,CAAAE,6BAAA,GAAAJ,iBAAA,CAAAI,6BAAA;AAAAF,OAAA,CAAAG,6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[]}
|
|
@@ -60,30 +60,23 @@ async function listEntityItems(ids, opts) {
|
|
|
60
60
|
if (!id) {
|
|
61
61
|
continue;
|
|
62
62
|
}
|
|
63
|
-
|
|
63
|
+
// Rows travel as-is apart from the `doc_id` → `id` alias both callers key
|
|
64
|
+
// off. Nothing here rewrites a field the backend owns:
|
|
65
|
+
//
|
|
66
|
+
// - `url` used to be rebuilt as `/products/<handle>` for product rows to
|
|
67
|
+
// keep the link same-origin. That threw away the query string, and
|
|
68
|
+
// `?variant=…` is exactly how a resolved variant travels. The client
|
|
69
|
+
// already strips the origin without losing the query —
|
|
70
|
+
// `canonicalizeFeatureProductUrl` (w5-client-feature-com) and
|
|
71
|
+
// `toRelativeUrl` (web50-server-ui/src/utils/linkResolver.ts) both
|
|
72
|
+
// keep `search` and `hash` — so the rewrite was redundant as well as
|
|
73
|
+
// lossy.
|
|
74
|
+
// - the image used to be guessed onto `img` from `thumbnail`/`images[0]`.
|
|
75
|
+
// The backend sends the field the client reads.
|
|
76
|
+
result.set(id, {
|
|
64
77
|
...rec,
|
|
65
78
|
id
|
|
66
|
-
};
|
|
67
|
-
// Product docs carry the Shopify slug in `handle`; the raw `url` is the
|
|
68
|
-
// absolute canonical storefront URL (https://www.feature.com/products/…).
|
|
69
|
-
// Rebuild a host-relative `/products/<handle>` so the link stays same-origin
|
|
70
|
-
// on whatever host serves the page. `handle` is authoritative here
|
|
71
|
-
// (no origin/`www.`/path-parsing, unlike deriving it from `url`).
|
|
72
|
-
if (rec.doc_domain === 'product' && typeof rec.handle === 'string' && rec.handle) {
|
|
73
|
-
normalized.url = `/products/${rec.handle}`;
|
|
74
|
-
}
|
|
75
|
-
// `list-items` carries the image directly (`thumbnail` / `images[]`), but
|
|
76
|
-
// the shared transform (`transformToGenericEntityData`) reads `img`. Alias
|
|
77
|
-
// the image onto `img` so images resolve from the payload itself — no
|
|
78
|
-
// dependence on the SearchSpring catalog, which may not index every product.
|
|
79
|
-
if (normalized.img == null) {
|
|
80
|
-
if (typeof rec.thumbnail === 'string' && rec.thumbnail) {
|
|
81
|
-
normalized.img = rec.thumbnail;
|
|
82
|
-
} else if (Array.isArray(rec.images) && typeof rec.images[0] === 'string' && rec.images[0]) {
|
|
83
|
-
normalized.img = rec.images[0];
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
result.set(id, normalized);
|
|
79
|
+
});
|
|
87
80
|
}
|
|
88
81
|
return result;
|
|
89
82
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LIST_ITEMS_ENDPOINT","exports","listEntityItems","ids","opts","result","Map","length","res","fetchImpl","method","headers","body","JSON","stringify","ok","Error","status","statusText","json","items","item","rec","id","doc_id","
|
|
1
|
+
{"version":3,"names":["LIST_ITEMS_ENDPOINT","exports","listEntityItems","ids","opts","result","Map","length","res","fetchImpl","method","headers","body","JSON","stringify","ok","Error","status","statusText","json","items","item","rec","id","doc_id","set"],"sources":["../../../src/entity/listEntityItems.ts"],"sourcesContent":["import type { ApiPayloadItem } from '../types/entity';\n\n/**\n * Entity resolution via the `list-items` RPC on the ConversationConfiguration\n * service.\n *\n * Entities are resolved through `list-items` (POST `{ ids }`). The response is\n * `{ items: [...] }` where each row is keyed by `doc_id`. We normalize to\n * `ApiPayloadItem` keyed by that id (and alias it onto `id`) so both callers\n * get back the same `Map<id, ApiPayloadItem>` contract.\n *\n * TODO(ambassador): the `@wix/ambassador-enterprise-web-five-v1-configuration`\n * `listItems` builder does NOT yet emit the public URL below — as of 1.0.27 it\n * resolves to the internal `/v1/conversation-configuration/list-items` path,\n * which 405s at the www edge (no public mapping). The gateway mapping was added\n * out-of-band (`/web5/conversation-configuration` → service root), giving the\n * URL below. Once an ambassador version ships with that mapping, replace the\n * hand-built request with the builder + `client.fetchWithAuth`, mirroring\n * `web50-server-ui/src/services/backendConfigService.ts`:\n * const options = listItems({ ids })({ isSSR: false, host: 'www.wixapis.com' });\n * const url = new URL(options.url!, 'https://www.wixapis.com');\n */\n\n/**\n * Public URL for the `list-items` RPC on `www.wixapis.com`. The `/web5/conversation-configuration`\n * gateway prefix is prepended to the proto path, hence the repeated segment.\n */\nexport const LIST_ITEMS_ENDPOINT =\n 'https://www.wixapis.com/web5/conversation-configuration/v1/conversation-configuration/list-items';\n\n/** Minimal fetch shape accepted by both the placement `fetchImpl` and the main app's `client.fetchWithAuth`. */\ntype FetchLike = (\n input: string | URL,\n init?: RequestInit,\n) => Promise<Response>;\n\ninterface ListItemsResponse {\n items?: Record<string, unknown>[] | null;\n}\n\nexport interface ListEntityItemsOptions {\n /** Auth-aware fetch (`client.fetchWithAuth` in the main app, the placement's Wix-auth fetch). */\n fetchImpl: FetchLike;\n}\n\n/**\n * POSTs `{ ids }` to the `list-items` endpoint and returns a Map of\n * `doc_id → ApiPayloadItem`. Throws on network/HTTP error so callers keep their\n * own diagnostics; on success returns only the rows the BE resolved.\n */\nexport async function listEntityItems(\n ids: string[],\n opts: ListEntityItemsOptions,\n): Promise<Map<string, ApiPayloadItem>> {\n const result = new Map<string, ApiPayloadItem>();\n if (!ids.length) return result;\n\n const res = await opts.fetchImpl(LIST_ITEMS_ENDPOINT, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ ids }),\n });\n\n if (!res.ok) {\n throw new Error(`list-items ${res.status} ${res.statusText}`);\n }\n\n const body = (await res.json()) as ListItemsResponse;\n const items = body.items ?? [];\n for (const item of items) {\n const rec = item as Record<string, unknown>;\n const id = rec.doc_id as string | undefined;\n if (!id) {\n continue;\n }\n // Rows travel as-is apart from the `doc_id` → `id` alias both callers key\n // off. Nothing here rewrites a field the backend owns:\n //\n // - `url` used to be rebuilt as `/products/<handle>` for product rows to\n // keep the link same-origin. That threw away the query string, and\n // `?variant=…` is exactly how a resolved variant travels. The client\n // already strips the origin without losing the query —\n // `canonicalizeFeatureProductUrl` (w5-client-feature-com) and\n // `toRelativeUrl` (web50-server-ui/src/utils/linkResolver.ts) both\n // keep `search` and `hash` — so the rewrite was redundant as well as\n // lossy.\n // - the image used to be guessed onto `img` from `thumbnail`/`images[0]`.\n // The backend sends the field the client reads.\n result.set(id, { ...rec, id } as unknown as ApiPayloadItem);\n }\n return result;\n}\n"],"mappings":";;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACO,MAAMA,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAC9B,kGAAkG;;AAEpG;;AAeA;AACA;AACA;AACA;AACA;AACO,eAAeE,eAAeA,CACnCC,GAAa,EACbC,IAA4B,EACU;EACtC,MAAMC,MAAM,GAAG,IAAIC,GAAG,CAAyB,CAAC;EAChD,IAAI,CAACH,GAAG,CAACI,MAAM,EAAE,OAAOF,MAAM;EAE9B,MAAMG,GAAG,GAAG,MAAMJ,IAAI,CAACK,SAAS,CAACT,mBAAmB,EAAE;IACpDU,MAAM,EAAE,MAAM;IACdC,OAAO,EAAE;MAAE,cAAc,EAAE;IAAmB,CAAC;IAC/CC,IAAI,EAAEC,IAAI,CAACC,SAAS,CAAC;MAAEX;IAAI,CAAC;EAC9B,CAAC,CAAC;EAEF,IAAI,CAACK,GAAG,CAACO,EAAE,EAAE;IACX,MAAM,IAAIC,KAAK,CAAC,cAAcR,GAAG,CAACS,MAAM,IAAIT,GAAG,CAACU,UAAU,EAAE,CAAC;EAC/D;EAEA,MAAMN,IAAI,GAAI,MAAMJ,GAAG,CAACW,IAAI,CAAC,CAAuB;EACpD,MAAMC,KAAK,GAAGR,IAAI,CAACQ,KAAK,IAAI,EAAE;EAC9B,KAAK,MAAMC,IAAI,IAAID,KAAK,EAAE;IACxB,MAAME,GAAG,GAAGD,IAA+B;IAC3C,MAAME,EAAE,GAAGD,GAAG,CAACE,MAA4B;IAC3C,IAAI,CAACD,EAAE,EAAE;MACP;IACF;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAC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