@frankframework/doc-library-core 1.0.1 → 1.0.4
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/doc-library-core.js +104 -87
- package/dist/doc-library-core.js.map +1 -1
- package/dist/ff-doc-base.d.ts +2 -1
- package/dist/frankdoc.utilities.d.ts +11 -5
- package/dist/javadoc.d.ts +8 -6
- package/package.json +3 -3
package/dist/doc-library-core.js
CHANGED
|
@@ -1,96 +1,111 @@
|
|
|
1
|
+
function c(r, n) {
|
|
2
|
+
if (Object.keys(r).length === 0) return null;
|
|
3
|
+
const t = r[n] ?? Object.values(r).find((e) => e.className === n);
|
|
4
|
+
return t || null;
|
|
5
|
+
}
|
|
1
6
|
function d(r, n) {
|
|
2
|
-
const
|
|
3
|
-
for (const
|
|
4
|
-
if (
|
|
5
|
-
const s = n[
|
|
6
|
-
s && !e
|
|
7
|
+
const t = {};
|
|
8
|
+
for (const e of Object.values(r))
|
|
9
|
+
if (e.enum) {
|
|
10
|
+
const s = n[e.enum];
|
|
11
|
+
s && !t[e.enum] && (t[e.enum] = s);
|
|
7
12
|
}
|
|
8
|
-
return
|
|
13
|
+
return t;
|
|
9
14
|
}
|
|
10
15
|
function h(r) {
|
|
11
16
|
return Object.entries(r).reduce(
|
|
12
|
-
(n, [
|
|
17
|
+
(n, [t, e]) => (n[e.mandatory === !0 ? "required" : "optional"][t] = e, n),
|
|
13
18
|
{ required: {}, optional: {} }
|
|
14
19
|
);
|
|
15
20
|
}
|
|
16
|
-
function
|
|
17
|
-
const
|
|
21
|
+
function m(r, n, t) {
|
|
22
|
+
const e = {
|
|
18
23
|
attributesRequired: [],
|
|
19
24
|
attributesOptional: [],
|
|
20
25
|
forwards: {},
|
|
21
26
|
enums: {},
|
|
22
27
|
parentElements: []
|
|
23
28
|
};
|
|
24
|
-
if (!r.parent) return
|
|
29
|
+
if (!r.parent) return e;
|
|
25
30
|
const s = n[r.parent];
|
|
26
|
-
if (!s) return
|
|
27
|
-
const i =
|
|
31
|
+
if (!s) return e;
|
|
32
|
+
const i = m(s, n, t);
|
|
28
33
|
if (i.parentElements.unshift(s.name), s.attributes) {
|
|
29
|
-
const { required:
|
|
34
|
+
const { required: l, optional: a } = h(
|
|
30
35
|
s.attributes
|
|
31
36
|
);
|
|
32
|
-
Object.values(
|
|
33
|
-
parentElementName: s.name,
|
|
34
|
-
properties: a
|
|
35
|
-
}), Object.values(l).length > 0 && i.attributesOptional.unshift({
|
|
37
|
+
Object.values(l).length > 0 && i.attributesRequired.unshift({
|
|
36
38
|
parentElementName: s.name,
|
|
37
39
|
properties: l
|
|
38
|
-
}),
|
|
40
|
+
}), Object.values(a).length > 0 && i.attributesOptional.unshift({
|
|
41
|
+
parentElementName: s.name,
|
|
42
|
+
properties: a
|
|
43
|
+
}), i.enums = { ...i.enums, ...d(s.attributes, t) };
|
|
39
44
|
}
|
|
40
45
|
return s.forwards && (i.forwards = { ...i.forwards, ...s.forwards }), i;
|
|
41
46
|
}
|
|
42
|
-
function
|
|
43
|
-
const
|
|
47
|
+
function b(r, n, t) {
|
|
48
|
+
const e = m(r, n, t);
|
|
44
49
|
return {
|
|
45
50
|
...r,
|
|
46
|
-
parentElements:
|
|
51
|
+
parentElements: e.parentElements,
|
|
47
52
|
attributes: {
|
|
48
|
-
...f(
|
|
49
|
-
...f(
|
|
53
|
+
...f(e.attributesOptional),
|
|
54
|
+
...f(e.attributesRequired),
|
|
50
55
|
...r.attributes
|
|
51
56
|
},
|
|
52
|
-
forwards: { ...
|
|
53
|
-
enums:
|
|
57
|
+
forwards: { ...e.forwards, ...r.forwards },
|
|
58
|
+
enums: e.enums
|
|
54
59
|
};
|
|
55
60
|
}
|
|
56
61
|
function f(r) {
|
|
57
62
|
let n = {};
|
|
58
|
-
for (const
|
|
59
|
-
n = { ...
|
|
63
|
+
for (const t of r)
|
|
64
|
+
n = { ...t.properties, ...n };
|
|
60
65
|
return n;
|
|
61
66
|
}
|
|
62
|
-
|
|
67
|
+
function D(r, n, t) {
|
|
68
|
+
const e = n[r.type ?? ""];
|
|
69
|
+
if (!e)
|
|
70
|
+
return { ...r, implementedBy: null };
|
|
71
|
+
const s = e.map((i) => c(t, i)).filter((i) => i !== null);
|
|
72
|
+
return {
|
|
73
|
+
...r,
|
|
74
|
+
implementedBy: s
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
class g {
|
|
63
78
|
getFiltersFromLabels(n) {
|
|
64
|
-
const
|
|
65
|
-
for (const [
|
|
66
|
-
e
|
|
79
|
+
const t = {};
|
|
80
|
+
for (const [e, s] of Object.entries(n)) {
|
|
81
|
+
t[e] = {};
|
|
67
82
|
for (const i of s)
|
|
68
|
-
e
|
|
83
|
+
t[e][i] = [];
|
|
69
84
|
}
|
|
70
|
-
return
|
|
85
|
+
return t;
|
|
71
86
|
}
|
|
72
|
-
assignFrankDocElementsToFilters(n,
|
|
73
|
-
for (const [
|
|
87
|
+
assignFrankDocElementsToFilters(n, t) {
|
|
88
|
+
for (const [e, s] of Object.entries(t))
|
|
74
89
|
for (const i in s.labels) {
|
|
75
|
-
const
|
|
76
|
-
!n[i] || !n[i][
|
|
90
|
+
const l = s.labels[i];
|
|
91
|
+
!n[i] || !n[i][l] || n[i][l].push(e);
|
|
77
92
|
}
|
|
78
93
|
return n;
|
|
79
94
|
}
|
|
80
95
|
getXMLElements(n) {
|
|
81
|
-
const
|
|
82
|
-
for (const [
|
|
96
|
+
const t = {};
|
|
97
|
+
for (const [e, s] of Object.entries(n.elementNames)) {
|
|
83
98
|
const i = n.elements[s.className];
|
|
84
|
-
e
|
|
85
|
-
...
|
|
99
|
+
t[e] = {
|
|
100
|
+
...b(i, n.elements, n.enums),
|
|
86
101
|
...s,
|
|
87
|
-
name:
|
|
102
|
+
name: e
|
|
88
103
|
};
|
|
89
104
|
}
|
|
90
|
-
return
|
|
105
|
+
return t;
|
|
91
106
|
}
|
|
92
107
|
}
|
|
93
|
-
class
|
|
108
|
+
class F extends g {
|
|
94
109
|
constructor() {
|
|
95
110
|
super(...arguments), this._ffDoc = null, this._elements = null, this._filters = {};
|
|
96
111
|
}
|
|
@@ -104,71 +119,73 @@ class k extends b {
|
|
|
104
119
|
return this._filters;
|
|
105
120
|
}
|
|
106
121
|
async initialize(n) {
|
|
107
|
-
const
|
|
108
|
-
this._ffDoc =
|
|
109
|
-
this.getFiltersFromLabels(
|
|
110
|
-
|
|
111
|
-
), this._elements = this.getXMLElements(
|
|
122
|
+
const t = await this.fetchJson(n);
|
|
123
|
+
this._ffDoc = t, this._filters = this.assignFrankDocElementsToFilters(
|
|
124
|
+
this.getFiltersFromLabels(t.labels),
|
|
125
|
+
t.elementNames
|
|
126
|
+
), this._elements = this.getXMLElements(t);
|
|
112
127
|
}
|
|
113
128
|
async fetchJson(n) {
|
|
114
129
|
return await (await fetch(n)).json();
|
|
115
130
|
}
|
|
116
131
|
}
|
|
117
|
-
const
|
|
118
|
-
function
|
|
119
|
-
let
|
|
120
|
-
return t
|
|
121
|
-
const
|
|
122
|
-
return
|
|
123
|
-
}),
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
function F(r, n) {
|
|
129
|
-
let e = `${r}`;
|
|
130
|
-
return e = e.replaceAll(m, "$1($2)"), e = e.replaceAll(g, ""), e = e.replaceAll(o, (t, s) => u(s, n).text), e = e.replaceAll(String.raw`\"`, '"'), [e];
|
|
132
|
+
const p = /\[([^\]]+)]\(([^)]+)\)/g, x = /<[^>]*>?/gm, o = /(?:{@link\s(.*?)})/g;
|
|
133
|
+
function N(r, n, t) {
|
|
134
|
+
let e = r.replaceAll(p, '<a target="_blank" href="$2" alt="$1">$1</a>').replaceAll(String.raw`\"`, '"');
|
|
135
|
+
return t ? E(e, n) : (e = e.replaceAll(o, (s, i) => {
|
|
136
|
+
const l = u(i, n);
|
|
137
|
+
return l.href ? O(l) : l.text;
|
|
138
|
+
}), [e]);
|
|
139
|
+
}
|
|
140
|
+
function P(r, n) {
|
|
141
|
+
return [r.replaceAll(p, "$1($2)").replaceAll(x, "").replaceAll(o, (e, s) => u(s, n).text).replaceAll(String.raw`\"`, '"')];
|
|
131
142
|
}
|
|
132
143
|
function O(r) {
|
|
133
144
|
return `<a href="#/${r.href}">${r.text}</a>`;
|
|
134
145
|
}
|
|
135
146
|
function u(r, n) {
|
|
136
|
-
const
|
|
147
|
+
const t = r.indexOf("#"), e = t !== -1, s = e ? r.split("#")[0] : r;
|
|
137
148
|
if (s === "")
|
|
138
|
-
return { text: w(r,
|
|
139
|
-
const i = s.split(" "),
|
|
140
|
-
return
|
|
149
|
+
return { text: w(r, t) };
|
|
150
|
+
const i = s.split(" "), l = k(i, e, r), a = c(n, i[0]);
|
|
151
|
+
return a ? { href: a.className, text: l, element: a } : (console.warn(`could not find element [${l}]`), { text: l });
|
|
152
|
+
}
|
|
153
|
+
function E(r, n) {
|
|
154
|
+
const t = [];
|
|
155
|
+
let e = 0;
|
|
156
|
+
for (const s of r.matchAll(o)) {
|
|
157
|
+
const [i, l] = s, a = u(l, n);
|
|
158
|
+
t.push(r.slice(e, s.index), a.href ? a : a.text), e = s.index + i.length;
|
|
159
|
+
}
|
|
160
|
+
return e < r.length - 1 && t.push(r.slice(e)), t;
|
|
141
161
|
}
|
|
142
162
|
function w(r, n) {
|
|
143
|
-
const
|
|
144
|
-
return
|
|
163
|
+
const t = r.slice(n), e = t.split(" ");
|
|
164
|
+
return e.length === 2 ? e[1] : t.slice(1, t.indexOf("("));
|
|
145
165
|
}
|
|
146
|
-
function
|
|
147
|
-
const
|
|
166
|
+
function k(r, n, t) {
|
|
167
|
+
const e = r.at(-1);
|
|
148
168
|
if (n) {
|
|
149
|
-
const s =
|
|
150
|
-
return i.includes(" ") ? s.split(" ")[1] : `${
|
|
169
|
+
const s = t.split("#")[1], i = s.slice(s.indexOf(") ") + 1).trim();
|
|
170
|
+
return i.includes(" ") ? s.split(" ")[1] : `${e}.${i}`;
|
|
151
171
|
}
|
|
152
|
-
return
|
|
153
|
-
}
|
|
154
|
-
function E(r, n) {
|
|
155
|
-
if (Object.keys(r).length === 0) return null;
|
|
156
|
-
const e = r[n];
|
|
157
|
-
return e || (console.warn(`could not find element [${n}]`), null);
|
|
172
|
+
return e;
|
|
158
173
|
}
|
|
159
174
|
export {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
175
|
+
F as FFDoc,
|
|
176
|
+
g as FFDocBase,
|
|
177
|
+
b as addInheritedPropertiesToElement,
|
|
163
178
|
O as defaultLinkTransformation,
|
|
179
|
+
c as findElement,
|
|
164
180
|
f as flattenInheritedParentElementProperties,
|
|
165
|
-
|
|
181
|
+
m as getInheritedProperties,
|
|
166
182
|
u as getLinkData,
|
|
167
183
|
h as groupAttributesByMandatory,
|
|
168
184
|
o as linkRegex,
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
185
|
+
p as markdownLinkRegex,
|
|
186
|
+
D as resolveInterfaceChildren,
|
|
187
|
+
x as tagsRegex,
|
|
188
|
+
N as transformAsHtml,
|
|
189
|
+
P as transformAsText
|
|
173
190
|
};
|
|
174
191
|
//# sourceMappingURL=doc-library-core.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doc-library-core.js","sources":["../src/frankdoc.utilities.ts","../src/ff-doc-base.ts","../src/ff-doc.ts","../src/javadoc.ts"],"sourcesContent":["import { Attribute, ElementClass, ElementProperty, EnumValue, FFDocJson } from './frankdoc.types';\n\nexport type InheritedParentElementProperties<T> = {\n parentElementName: string;\n properties: Record<string, T>;\n};\n\ntype InheritedPropertiesExtras = {\n enums: Record<string, EnumValue>;\n parentElements: string[];\n};\n\nexport type InheritedProperties = {\n attributesRequired: InheritedParentElementProperties<Attribute>[];\n attributesOptional: InheritedParentElementProperties<Attribute>[];\n forwards: Record<string, ElementProperty>;\n} & InheritedPropertiesExtras;\n\nexport type ElementClassWithInheritedProperties = ElementClass & InheritedPropertiesExtras;\n\nfunction filterUsedEnums(attributes: Record<string, Attribute>, enums: FFDocJson['enums']): Record<string, EnumValue> {\n const filteredEnums: Record<string, EnumValue> = {};\n for (const attribute of Object.values(attributes)) {\n if (attribute.enum) {\n const enumType = enums[attribute.enum];\n if (enumType && !filteredEnums[attribute.enum]) filteredEnums[attribute.enum] = enumType;\n }\n }\n return filteredEnums;\n}\n\nexport function groupAttributesByMandatory(attributes: Record<string, Attribute>): {\n required: Record<string, Attribute>;\n optional: Record<string, Attribute>;\n} {\n return Object.entries(attributes).reduce<{\n required: Record<string, Attribute>;\n optional: Record<string, Attribute>;\n }>(\n (collection, [name, attribute]) => {\n collection[attribute.mandatory === true ? 'required' : 'optional'][name] = attribute;\n return collection;\n },\n { required: {}, optional: {} },\n );\n}\n\nexport function getInheritedProperties(\n element: ElementClass,\n elements: FFDocJson['elements'],\n enums: FFDocJson['enums'],\n): InheritedProperties {\n const initialInheritedProperties: InheritedProperties = {\n attributesRequired: [],\n attributesOptional: [],\n forwards: {},\n enums: {},\n parentElements: [],\n };\n\n if (!element.parent) return initialInheritedProperties;\n const parentElement = elements[element.parent];\n if (!parentElement) return initialInheritedProperties;\n const inheritedProperties = getInheritedProperties(parentElement, elements, enums);\n inheritedProperties.parentElements.unshift(parentElement.name);\n\n if (parentElement.attributes) {\n // ES2024 has the Object.groupBy function which could make this a lot better\n const { required: attributesRequired, optional: attributesOptional } = groupAttributesByMandatory(\n parentElement.attributes,\n );\n if (Object.values(attributesRequired).length > 0) {\n inheritedProperties.attributesRequired.unshift({\n parentElementName: parentElement.name,\n properties: attributesRequired,\n });\n }\n if (Object.values(attributesOptional).length > 0) {\n inheritedProperties.attributesOptional.unshift({\n parentElementName: parentElement.name,\n properties: attributesOptional,\n });\n }\n inheritedProperties.enums = { ...inheritedProperties.enums, ...filterUsedEnums(parentElement.attributes, enums) };\n }\n\n if (parentElement.forwards)\n inheritedProperties.forwards = { ...inheritedProperties.forwards, ...parentElement.forwards };\n\n return inheritedProperties;\n}\n\nexport function addInheritedPropertiesToElement(\n element: ElementClass,\n elements: FFDocJson['elements'],\n enums: FFDocJson['enums'],\n): ElementClassWithInheritedProperties {\n const inheritedProperties = getInheritedProperties(element, elements, enums);\n return {\n ...element,\n parentElements: inheritedProperties.parentElements,\n attributes: {\n ...flattenInheritedParentElementProperties(inheritedProperties.attributesOptional),\n ...flattenInheritedParentElementProperties(inheritedProperties.attributesRequired),\n ...element.attributes,\n },\n forwards: { ...inheritedProperties.forwards, ...element.forwards },\n enums: inheritedProperties.enums,\n };\n}\n\nexport function flattenInheritedParentElementProperties<T>(\n inheritedProperties: InheritedParentElementProperties<T>[],\n): Record<string, T> {\n let flattenedProperties: Record<string, T> = {};\n for (const inheritedProperty of inheritedProperties) {\n flattenedProperties = { ...inheritedProperty.properties, ...flattenedProperties };\n }\n return flattenedProperties;\n}\n","import { ElementInfo, FFDocJson } from './frankdoc.types';\nimport { addInheritedPropertiesToElement, ElementClassWithInheritedProperties } from './frankdoc.utilities';\n\nexport type Filters = Record<string, FilterLabels>;\nexport type FilterLabels = Record<string, string[]>;\nexport type Elements = Record<string, ElementDetails>;\nexport type ElementDetails = ElementClassWithInheritedProperties & ElementInfo;\n\nexport abstract class FFDocBase {\n protected getFiltersFromLabels(labels: FFDocJson['labels']): Filters {\n const filters: Filters = {};\n for (const [filterGroup, filterLabels] of Object.entries(labels)) {\n filters[filterGroup] = {};\n for (const label of filterLabels) {\n filters[filterGroup][label] = [];\n }\n }\n return filters;\n }\n\n protected assignFrankDocElementsToFilters(filters: Filters, elements: FFDocJson['elementNames']): Filters {\n for (const [elementName, element] of Object.entries(elements)) {\n for (const elementFilterGroup in element.labels) {\n const elementFilterLabel = element.labels[elementFilterGroup];\n if (!filters[elementFilterGroup] || !filters[elementFilterGroup][elementFilterLabel]) continue;\n filters[elementFilterGroup][elementFilterLabel].push(elementName);\n }\n }\n return filters;\n }\n\n protected getXMLElements(json: FFDocJson): Elements {\n const elements: Elements = {};\n\n /* instead of looping over every xml element,\n * maybe parent elements already processed should be used as cache in order to reduce the number of loops\n */\n for (const [elementName, elementValue] of Object.entries(json.elementNames)) {\n const elementClassData = json.elements[elementValue.className];\n elements[elementName] = {\n ...addInheritedPropertiesToElement(elementClassData, json.elements, json.enums),\n ...elementValue,\n name: elementName,\n };\n }\n return elements;\n }\n}\n","import { FFDocJson } from './frankdoc.types';\nimport { Elements, FFDocBase, Filters } from './ff-doc-base';\n\nexport class FFDoc extends FFDocBase {\n private _ffDoc: FFDocJson | null = null;\n private _elements: Elements | null = null;\n private _filters: Filters = {};\n\n get ffDoc(): Readonly<FFDocJson | null> {\n return this._ffDoc;\n }\n\n get elements(): Readonly<Elements | null> {\n return this._elements;\n }\n\n get filters(): Readonly<Filters> {\n return this._filters;\n }\n\n async initialize(jsonUrl: string): Promise<void> {\n const ffDocJson = await this.fetchJson(jsonUrl);\n this._ffDoc = ffDocJson;\n this._filters = this.assignFrankDocElementsToFilters(\n this.getFiltersFromLabels(ffDocJson.labels),\n ffDocJson.elementNames,\n );\n this._elements = this.getXMLElements(ffDocJson);\n }\n\n private async fetchJson(url: string): Promise<FFDocJson> {\n const response = await fetch(url);\n return await response.json();\n }\n}\n","import { ElementClass, ElementInfo } from './frankdoc.types';\n\nexport type ElementsWithInfo = ElementClass & ElementInfo;\nexport type LinkData = {\n text: string;\n href?: string;\n element?: ElementsWithInfo;\n};\n\n// eslint-disable-next-line sonarjs/slow-regex\nexport const markdownLinkRegex = /\\[([^\\]]+)]\\(([^)]+)\\)/g; // old regex: /\\[(.*?)\\]\\((.+?)\\)/g\nexport const tagsRegex = /<[^>]*>?/gm;\nexport const linkRegex = /(?:{@link\\s(.*?)})/g;\n\nexport function transformAsHtml(\n javadoc: string,\n elements: Record<string, ElementsWithInfo>,\n hasCustomLinkTransform: boolean,\n): string[] {\n let value = `${javadoc}`;\n value = value.replaceAll(markdownLinkRegex, '<a target=\"_blank\" href=\"$2\" alt=\"$1\">$1</a>');\n\n if (hasCustomLinkTransform) {\n value = value.replaceAll(linkRegex, (_, captureGroup) => {\n const linkData = getLinkData(captureGroup, elements);\n if (linkData.href) return `\\\\\"${JSON.stringify(linkData)}\\\\\"`;\n return linkData.text;\n });\n return value.split(String.raw`\\\"`);\n }\n value = value.replaceAll(linkRegex, (_, captureGroup) => {\n const linkData = getLinkData(captureGroup, elements);\n if (linkData.href) return defaultLinkTransformation(linkData);\n return linkData.text;\n });\n\n value = value.replaceAll(String.raw`\\\"`, '\"');\n return [value];\n}\n\nexport function transformAsText(javadoc: string, elements: Record<string, ElementsWithInfo>): string[] {\n let value = `${javadoc}`;\n value = value.replaceAll(markdownLinkRegex, '$1($2)');\n value = value.replaceAll(tagsRegex, '');\n value = value.replaceAll(linkRegex, (_: string, captureGroup: string) => {\n const linkData = getLinkData(captureGroup, elements);\n return linkData.text;\n });\n value = value.replaceAll(String.raw`\\\"`, '\"');\n return [value];\n}\n\nexport function defaultLinkTransformation(linkData: LinkData): string {\n return `<a href=\"#/${linkData.href}\">${linkData.text}</a>`;\n}\n\n/**\n * Creates LinkData object from `@link` taglet's data\n * @param captureGroup cature group received from regex matching with the `@link` taglet,\n * e.g. 'PipeLineSession pipeLineSession' for `{@link PipeLineSession pipeLineSession}`\n * @param elements\n */\nexport function getLinkData(captureGroup: string, elements: Record<string, ElementsWithInfo>): LinkData {\n const hashPosition = captureGroup.indexOf('#'),\n isMethod = hashPosition !== -1,\n elementString = isMethod ? captureGroup.split('#')[0] : captureGroup;\n\n if (elementString === '') {\n return { text: getInternalMethodReference(captureGroup, hashPosition) };\n }\n\n const elementParts = elementString.split(' '); //first part is the class name, 2nd part the written name\n const name = parseLinkName(elementParts, isMethod, captureGroup);\n\n const element = findElement(elements, elementParts[0]);\n if (!element) return { text: name };\n return { href: element.className, text: name, element };\n}\n\n/** Handle links to internal class methods */\nfunction getInternalMethodReference(captureGroup: string, hashPosition: number): string {\n const method = captureGroup.slice(hashPosition),\n methodParts = method.split(' ');\n return methodParts.length === 2\n ? methodParts[1] // 'methodName label' -> 'label'\n : method.slice(1, method.indexOf('('));\n}\n\nfunction parseLinkName(elementParts: string[], isMethod: boolean, captureGroup: string): string {\n const elementName = elementParts.at(-1)!; // element name/label\n if (isMethod) {\n const method = captureGroup.split('#')[1],\n methodNameOrLabel = method.slice(method.indexOf(') ') + 1).trim();\n return methodNameOrLabel.includes(' ') ? method.split(' ')[1] : `${elementName}.${methodNameOrLabel}`;\n }\n return elementName;\n}\n\nfunction findElement(elements: Record<string, ElementsWithInfo>, simpleName: string): ElementsWithInfo | null {\n if (Object.keys(elements).length === 0) return null;\n const element = elements[simpleName];\n if (element) return element;\n\n console.warn(`could not find element [${simpleName}]`);\n return null;\n}\n"],"names":["filterUsedEnums","attributes","enums","filteredEnums","attribute","enumType","groupAttributesByMandatory","collection","name","getInheritedProperties","element","elements","initialInheritedProperties","parentElement","inheritedProperties","attributesRequired","attributesOptional","addInheritedPropertiesToElement","flattenInheritedParentElementProperties","flattenedProperties","inheritedProperty","FFDocBase","labels","filters","filterGroup","filterLabels","label","elementName","elementFilterGroup","elementFilterLabel","json","elementValue","elementClassData","FFDoc","jsonUrl","ffDocJson","url","markdownLinkRegex","tagsRegex","linkRegex","transformAsHtml","javadoc","hasCustomLinkTransform","value","_","captureGroup","linkData","getLinkData","defaultLinkTransformation","transformAsText","hashPosition","isMethod","elementString","getInternalMethodReference","elementParts","parseLinkName","findElement","method","methodParts","methodNameOrLabel","simpleName"],"mappings":"AAoBA,SAASA,EAAgBC,GAAuCC,GAAsD;AACpH,QAAMC,IAA2C,CAAA;AACjD,aAAWC,KAAa,OAAO,OAAOH,CAAU;AAC9C,QAAIG,EAAU,MAAM;AAClB,YAAMC,IAAWH,EAAME,EAAU,IAAI;AACrC,MAAIC,KAAY,CAACF,EAAcC,EAAU,IAAI,MAAGD,EAAcC,EAAU,IAAI,IAAIC;AAAA,IAClF;AAEF,SAAOF;AACT;AAEO,SAASG,EAA2BL,GAGzC;AACA,SAAO,OAAO,QAAQA,CAAU,EAAE;AAAA,IAIhC,CAACM,GAAY,CAACC,GAAMJ,CAAS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AC5CQ,IAAcD,EAAO,MAAM,GAAG;AAChC,SAAOC,EAAY,WAAW,IAC1BA,EAAY,CAAC,IACbD,EAAO,MAAM,GAAGA,EAAO,QAAQ,GAAG,CAAC;AACzC;AAEA,SAASF,EAAcD,GAAwBH,GAAmBN,GAA8B;AAC9F,QAAMlB,IAAc2B,EAAa,GAAG,EAAE;AACtC,MAAIH,GAAU;AACZ,UAAMM,IAASZ,EAAa,MAAM,GAAG,EAAE,CAAC,GACtCc,IAAoBF,EAAO,MAAMA,EAAO,QAAQ,IAAI,IAAI,CAAC,EAAE,KAAA;AAC7D,WAAOE,EAAkB,SAAS,GAAG,IAAIF,EAAO,MAAM,GAAG,EAAE,CAAC,IAAI,GAAG9B,CAAW,IAAIgC,CAAiB;AAAA,EACrG;AACA,SAAOhC;AACT;AAEA,SAAS6B,EAAY7C,GAA4CiD,GAA6C;AAC5G,MAAI,OAAO,KAAKjD,CAAQ,EAAE,WAAW,EAAG,QAAO;AAC/C,QAAMD,IAAUC,EAASiD,CAAU;AACnC,SAAIlD,MAEJ,QAAQ,KAAK,2BAA2BkD,CAAU,GAAG,GAC9C;AACT;"}
|
|
1
|
+
{"version":3,"file":"doc-library-core.js","sources":["../src/frankdoc.utilities.ts","../src/ff-doc-base.ts","../src/ff-doc.ts","../src/javadoc.ts"],"sourcesContent":["import { Attribute, Child, ElementClass, ElementProperty, EnumValue, FFDocJson } from './frankdoc.types';\nimport { ElementWithInfo } from './ff-doc-base';\n\ntype InheritedPropertiesExtras = {\n enums: Record<string, EnumValue>;\n parentElements: string[];\n};\n\nexport type InheritedParentElementProperties<T> = {\n parentElementName: string;\n properties: Record<string, T>;\n};\n\nexport type InheritedProperties = {\n attributesRequired: InheritedParentElementProperties<Attribute>[];\n attributesOptional: InheritedParentElementProperties<Attribute>[];\n forwards: Record<string, ElementProperty>;\n} & InheritedPropertiesExtras;\n\nexport type ElementClassWithInheritedProperties = ElementClass & InheritedPropertiesExtras;\n\nexport type ResolvedChild = Child & {\n implementedBy: ElementWithInfo[] | null;\n};\n\nexport function findElement(elements: Record<string, ElementWithInfo>, name: string): ElementWithInfo | null {\n if (Object.keys(elements).length === 0) return null;\n const element = elements[name] ?? Object.values(elements).find((element) => element.className === name);\n if (element) return element;\n\n return null;\n}\n\nfunction filterUsedEnums(attributes: Record<string, Attribute>, enums: FFDocJson['enums']): Record<string, EnumValue> {\n const filteredEnums: Record<string, EnumValue> = {};\n for (const attribute of Object.values(attributes)) {\n if (attribute.enum) {\n const enumType = enums[attribute.enum];\n if (enumType && !filteredEnums[attribute.enum]) filteredEnums[attribute.enum] = enumType;\n }\n }\n return filteredEnums;\n}\n\nexport function groupAttributesByMandatory(attributes: Record<string, Attribute>): {\n required: Record<string, Attribute>;\n optional: Record<string, Attribute>;\n} {\n return Object.entries(attributes).reduce<{\n required: Record<string, Attribute>;\n optional: Record<string, Attribute>;\n }>(\n (collection, [name, attribute]) => {\n collection[attribute.mandatory === true ? 'required' : 'optional'][name] = attribute;\n return collection;\n },\n { required: {}, optional: {} },\n );\n}\n\nexport function getInheritedProperties(\n element: ElementClass,\n elements: FFDocJson['elements'],\n enums: FFDocJson['enums'],\n): InheritedProperties {\n const initialInheritedProperties: InheritedProperties = {\n attributesRequired: [],\n attributesOptional: [],\n forwards: {},\n enums: {},\n parentElements: [],\n };\n\n if (!element.parent) return initialInheritedProperties;\n const parentElement = elements[element.parent];\n if (!parentElement) return initialInheritedProperties;\n const inheritedProperties = getInheritedProperties(parentElement, elements, enums);\n inheritedProperties.parentElements.unshift(parentElement.name);\n\n if (parentElement.attributes) {\n // ES2024 has the Object.groupBy function which could make this a lot better\n const { required: attributesRequired, optional: attributesOptional } = groupAttributesByMandatory(\n parentElement.attributes,\n );\n if (Object.values(attributesRequired).length > 0) {\n inheritedProperties.attributesRequired.unshift({\n parentElementName: parentElement.name,\n properties: attributesRequired,\n });\n }\n if (Object.values(attributesOptional).length > 0) {\n inheritedProperties.attributesOptional.unshift({\n parentElementName: parentElement.name,\n properties: attributesOptional,\n });\n }\n inheritedProperties.enums = { ...inheritedProperties.enums, ...filterUsedEnums(parentElement.attributes, enums) };\n }\n\n if (parentElement.forwards)\n inheritedProperties.forwards = { ...inheritedProperties.forwards, ...parentElement.forwards };\n\n return inheritedProperties;\n}\n\nexport function addInheritedPropertiesToElement(\n element: ElementClass,\n elements: FFDocJson['elements'],\n enums: FFDocJson['enums'],\n): ElementClassWithInheritedProperties {\n const inheritedProperties = getInheritedProperties(element, elements, enums);\n return {\n ...element,\n parentElements: inheritedProperties.parentElements,\n attributes: {\n ...flattenInheritedParentElementProperties(inheritedProperties.attributesOptional),\n ...flattenInheritedParentElementProperties(inheritedProperties.attributesRequired),\n ...element.attributes,\n },\n forwards: { ...inheritedProperties.forwards, ...element.forwards },\n enums: inheritedProperties.enums,\n };\n}\n\nexport function flattenInheritedParentElementProperties<T>(\n inheritedProperties: InheritedParentElementProperties<T>[],\n): Record<string, T> {\n let flattenedProperties: Record<string, T> = {};\n for (const inheritedProperty of inheritedProperties) {\n flattenedProperties = { ...inheritedProperty.properties, ...flattenedProperties };\n }\n return flattenedProperties;\n}\n\nexport function resolveInterfaceChildren(\n child: Child,\n types: FFDocJson['types'],\n elements: Record<string, ElementWithInfo>,\n): ResolvedChild {\n const implementedByClassNames = types[child.type ?? ''];\n if (!implementedByClassNames) {\n return { ...child, implementedBy: null };\n }\n\n const implementedBy = implementedByClassNames\n .map((className) => findElement(elements, className))\n .filter((element): element is ElementWithInfo => element !== null);\n return {\n ...child,\n implementedBy,\n };\n}\n","import { ElementClass, ElementInfo, FFDocJson } from './frankdoc.types';\nimport { addInheritedPropertiesToElement, ElementClassWithInheritedProperties } from './frankdoc.utilities';\n\nexport type Filters = Record<string, FilterLabels>;\nexport type FilterLabels = Record<string, string[]>;\nexport type Elements = Record<string, ElementDetails>;\nexport type ElementDetails = ElementClassWithInheritedProperties & ElementInfo;\nexport type ElementWithInfo = ElementClass & ElementInfo;\n\nexport abstract class FFDocBase {\n protected getFiltersFromLabels(labels: FFDocJson['labels']): Filters {\n const filters: Filters = {};\n for (const [filterGroup, filterLabels] of Object.entries(labels)) {\n filters[filterGroup] = {};\n for (const label of filterLabels) {\n filters[filterGroup][label] = [];\n }\n }\n return filters;\n }\n\n protected assignFrankDocElementsToFilters(filters: Filters, elements: FFDocJson['elementNames']): Filters {\n for (const [elementName, element] of Object.entries(elements)) {\n for (const elementFilterGroup in element.labels) {\n const elementFilterLabel = element.labels[elementFilterGroup];\n if (!filters[elementFilterGroup] || !filters[elementFilterGroup][elementFilterLabel]) continue;\n filters[elementFilterGroup][elementFilterLabel].push(elementName);\n }\n }\n return filters;\n }\n\n protected getXMLElements(json: FFDocJson): Elements {\n const elements: Elements = {};\n\n /* instead of looping over every xml element,\n * maybe parent elements already processed should be used as cache in order to reduce the number of loops\n */\n for (const [elementName, elementValue] of Object.entries(json.elementNames)) {\n const elementClassData = json.elements[elementValue.className];\n elements[elementName] = {\n ...addInheritedPropertiesToElement(elementClassData, json.elements, json.enums),\n ...elementValue,\n name: elementName,\n };\n }\n return elements;\n }\n}\n","import { FFDocJson } from './frankdoc.types';\nimport { Elements, FFDocBase, Filters } from './ff-doc-base';\n\nexport class FFDoc extends FFDocBase {\n private _ffDoc: FFDocJson | null = null;\n private _elements: Elements | null = null;\n private _filters: Filters = {};\n\n get ffDoc(): Readonly<FFDocJson | null> {\n return this._ffDoc;\n }\n\n get elements(): Readonly<Elements | null> {\n return this._elements;\n }\n\n get filters(): Readonly<Filters> {\n return this._filters;\n }\n\n async initialize(jsonUrl: string): Promise<void> {\n const ffDocJson = await this.fetchJson(jsonUrl);\n this._ffDoc = ffDocJson;\n this._filters = this.assignFrankDocElementsToFilters(\n this.getFiltersFromLabels(ffDocJson.labels),\n ffDocJson.elementNames,\n );\n this._elements = this.getXMLElements(ffDocJson);\n }\n\n private async fetchJson(url: string): Promise<FFDocJson> {\n const response = await fetch(url);\n return await response.json();\n }\n}\n","import { findElement } from './frankdoc.utilities';\nimport { ElementWithInfo } from './ff-doc-base';\n\nexport type LinkData = {\n text: string;\n href?: string;\n element?: ElementWithInfo;\n};\ntype TransformedJavadocPart = string | LinkData;\nexport type TransformedJavadoc = TransformedJavadocPart[];\n\n// eslint-disable-next-line sonarjs/slow-regex\nexport const markdownLinkRegex = /\\[([^\\]]+)]\\(([^)]+)\\)/g; // old regex: /\\[(.*?)\\]\\((.+?)\\)/g\nexport const tagsRegex = /<[^>]*>?/gm;\nexport const linkRegex = /(?:{@link\\s(.*?)})/g;\n\nexport function transformAsHtml(\n javadoc: string,\n elements: Record<string, ElementWithInfo>,\n hasCustomLinkTransform: boolean,\n): TransformedJavadoc {\n let transformed = javadoc\n .replaceAll(markdownLinkRegex, '<a target=\"_blank\" href=\"$2\" alt=\"$1\">$1</a>')\n .replaceAll(String.raw`\\\"`, '\"');\n\n if (hasCustomLinkTransform) {\n return transformAsCustomHtml(transformed, elements);\n }\n\n transformed = transformed.replaceAll(linkRegex, (_, captureGroup) => {\n const linkData = getLinkData(captureGroup, elements);\n if (linkData.href) return defaultLinkTransformation(linkData);\n return linkData.text;\n });\n return [transformed];\n}\n\nexport function transformAsText(javadoc: string, elements: Record<string, ElementWithInfo>): TransformedJavadoc {\n const text = javadoc\n .replaceAll(markdownLinkRegex, '$1($2)')\n .replaceAll(tagsRegex, '')\n .replaceAll(linkRegex, (_: string, captureGroup: string) => {\n const linkData = getLinkData(captureGroup, elements);\n return linkData.text;\n })\n .replaceAll(String.raw`\\\"`, '\"');\n return [text];\n}\n\nexport function defaultLinkTransformation(linkData: LinkData): string {\n return `<a href=\"#/${linkData.href}\">${linkData.text}</a>`;\n}\n\n/**\n * Creates LinkData object from `@link` taglet's data\n * @param captureGroup cature group received from regex matching with the `@link` taglet,\n * e.g. 'PipeLineSession pipeLineSession' for `{@link PipeLineSession pipeLineSession}`\n * @param elements\n */\nexport function getLinkData(captureGroup: string, elements: Record<string, ElementWithInfo>): LinkData {\n const hashPosition = captureGroup.indexOf('#'),\n isMethod = hashPosition !== -1,\n elementString = isMethod ? captureGroup.split('#')[0] : captureGroup;\n\n if (elementString === '') {\n return { text: getInternalMethodReference(captureGroup, hashPosition) };\n }\n\n const elementParts = elementString.split(' '); //first part is the class name, 2nd part the written name\n const name = parseLinkName(elementParts, isMethod, captureGroup);\n\n const element = findElement(elements, elementParts[0]);\n if (!element) {\n console.warn(`could not find element [${name}]`);\n return { text: name };\n }\n return { href: element.className, text: name, element };\n}\n\nfunction transformAsCustomHtml(javadoc: string, elements: Record<string, ElementWithInfo>): TransformedJavadoc {\n const transformedParts: TransformedJavadocPart[] = [];\n let lastIndex = 0;\n for (const match of javadoc.matchAll(linkRegex)) {\n const [string, captureGroup] = match;\n const linkData = getLinkData(captureGroup, elements);\n transformedParts.push(javadoc.slice(lastIndex, match.index), linkData.href ? linkData : linkData.text);\n lastIndex = match.index + string.length;\n }\n if (lastIndex < javadoc.length - 1) transformedParts.push(javadoc.slice(lastIndex));\n return transformedParts;\n}\n\n/** Handle links to internal class methods */\nfunction getInternalMethodReference(captureGroup: string, hashPosition: number): string {\n const method = captureGroup.slice(hashPosition),\n methodParts = method.split(' ');\n return methodParts.length === 2\n ? methodParts[1] // 'methodName label' -> 'label'\n : method.slice(1, method.indexOf('('));\n}\n\nfunction parseLinkName(elementParts: string[], isMethod: boolean, captureGroup: string): string {\n const elementName = elementParts.at(-1)!; // element name/label\n if (isMethod) {\n const method = captureGroup.split('#')[1],\n methodNameOrLabel = method.slice(method.indexOf(') ') + 1).trim();\n return methodNameOrLabel.includes(' ') ? method.split(' ')[1] : `${elementName}.${methodNameOrLabel}`;\n }\n return elementName;\n}\n"],"names":["findElement","elements","name","element","filterUsedEnums","attributes","enums","filteredEnums","attribute","enumType","groupAttributesByMandatory","collection","getInheritedProperties","initialInheritedProperties","parentElement","inheritedProperties","attributesRequired","attributesOptional","addInheritedPropertiesToElement","flattenInheritedParentElementProperties","flattenedProperties","inheritedProperty","resolveInterfaceChildren","child","types","implementedByClassNames","implementedBy","className","FFDocBase","labels","filters","filterGroup","filterLabels","label","elementName","elementFilterGroup","elementFilterLabel","json","elementValue","elementClassData","FFDoc","jsonUrl","ffDocJson","url","markdownLinkRegex","tagsRegex","linkRegex","transformAsHtml","javadoc","hasCustomLinkTransform","transformed","transformAsCustomHtml","_","captureGroup","linkData","getLinkData","defaultLinkTransformation","transformAsText","hashPosition","isMethod","elementString","getInternalMethodReference","elementParts","parseLinkName","transformedParts","lastIndex","match","string","method","methodParts","methodNameOrLabel"],"mappings":"AAyBO,SAASA,EAAYC,GAA2CC,GAAsC;AAC3G,MAAI,OAAO,KAAKD,CAAQ,EAAE,WAAW,EAAG,QAAO;AAC/C,QAAME,IAAUF,EAASC,CAAI,KAAK,OAAO,OAAOD,CAAQ,EAAE,KAAK,CAACE,MAAYA,EAAQ,cAAcD,CAAI;AACtG,SAAIC,KAEG;AACT;AAEA,SAASC,EAAgBC,GAAuCC,GAAsD;AACpH,QAAMC,IAA2C,CAAA;AACjD,aAAWC,KAAa,OAAO,OAAOH,CAAU;AAC9C,QAAIG,EAAU,MAAM;AAClB,YAAMC,IAAWH,EAAME,EAAU,IAAI;AACrC,MAAIC,KAAY,CAACF,EAAcC,EAAU,IAAI,MAAGD,EAAcC,EAAU,IAAI,IAAIC;AAAA,IAClF;AAEF,SAAOF;AACT;AAEO,SAASG,EAA2BL,GAGzC;AACA,SAAO,OAAO,QAAQA,CAAU,EAAE;AAAA,IAIhC,CAACM,GAAY,CAACT,GAAMM,CAAS,OAC3BG,EAAWH,EAAU,cAAc,KAAO,aAAa,UAAU,EAAEN,CAAI,IAAIM,GACpEG;AAAA,IAET,EAAE,UAAU,IAAI,UAAU,CAAA,EAAC;AAAA,EAAE;AAEjC;AAEO,SAASC,EACdT,GACAF,GACAK,GACqB;AACrB,QAAMO,IAAkD;AAAA,IACtD,oBAAoB,CAAA;AAAA,IACpB,oBAAoB,CAAA;AAAA,IACpB,UAAU,CAAA;AAAA,IACV,OAAO,CAAA;AAAA,IACP,gBAAgB,CAAA;AAAA,EAAC;AAG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EACnC;AACA,SAAIF,IAAYjB,EAAQ,SAAS,OAAoB,KAAKA,EAAQ,MAAMiB,CAAS,CAAC,GAC3ED;AACT;AAGA,SAASH,EAA2BR,GAAsBK,GAA8B;AACtF,QAAMU,IAASf,EAAa,MAAMK,CAAY,GAC5CW,IAAcD,EAAO,MAAM,GAAG;AAChC,SAAOC,EAAY,WAAW,IAC1BA,EAAY,CAAC,IACbD,EAAO,MAAM,GAAGA,EAAO,QAAQ,GAAG,CAAC;AACzC;AAEA,SAASL,EAAcD,GAAwBH,GAAmBN,GAA8B;AAC9F,QAAMnB,IAAc4B,EAAa,GAAG,EAAE;AACtC,MAAIH,GAAU;AACZ,UAAMS,IAASf,EAAa,MAAM,GAAG,EAAE,CAAC,GACtCiB,IAAoBF,EAAO,MAAMA,EAAO,QAAQ,IAAI,IAAI,CAAC,EAAE,KAAA;AAC7D,WAAOE,EAAkB,SAAS,GAAG,IAAIF,EAAO,MAAM,GAAG,EAAE,CAAC,IAAI,GAAGlC,CAAW,IAAIoC,CAAiB;AAAA,EACrG;AACA,SAAOpC;AACT;"}
|
package/dist/ff-doc-base.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { ElementInfo, FFDocJson } from './frankdoc.types';
|
|
1
|
+
import { ElementClass, ElementInfo, FFDocJson } from './frankdoc.types';
|
|
2
2
|
import { ElementClassWithInheritedProperties } from './frankdoc.utilities';
|
|
3
3
|
export type Filters = Record<string, FilterLabels>;
|
|
4
4
|
export type FilterLabels = Record<string, string[]>;
|
|
5
5
|
export type Elements = Record<string, ElementDetails>;
|
|
6
6
|
export type ElementDetails = ElementClassWithInheritedProperties & ElementInfo;
|
|
7
|
+
export type ElementWithInfo = ElementClass & ElementInfo;
|
|
7
8
|
export declare abstract class FFDocBase {
|
|
8
9
|
protected getFiltersFromLabels(labels: FFDocJson['labels']): Filters;
|
|
9
10
|
protected assignFrankDocElementsToFilters(filters: Filters, elements: FFDocJson['elementNames']): Filters;
|
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
import { Attribute, ElementClass, ElementProperty, EnumValue, FFDocJson } from './frankdoc.types';
|
|
2
|
-
|
|
3
|
-
parentElementName: string;
|
|
4
|
-
properties: Record<string, T>;
|
|
5
|
-
};
|
|
1
|
+
import { Attribute, Child, ElementClass, ElementProperty, EnumValue, FFDocJson } from './frankdoc.types';
|
|
2
|
+
import { ElementWithInfo } from './ff-doc-base';
|
|
6
3
|
type InheritedPropertiesExtras = {
|
|
7
4
|
enums: Record<string, EnumValue>;
|
|
8
5
|
parentElements: string[];
|
|
9
6
|
};
|
|
7
|
+
export type InheritedParentElementProperties<T> = {
|
|
8
|
+
parentElementName: string;
|
|
9
|
+
properties: Record<string, T>;
|
|
10
|
+
};
|
|
10
11
|
export type InheritedProperties = {
|
|
11
12
|
attributesRequired: InheritedParentElementProperties<Attribute>[];
|
|
12
13
|
attributesOptional: InheritedParentElementProperties<Attribute>[];
|
|
13
14
|
forwards: Record<string, ElementProperty>;
|
|
14
15
|
} & InheritedPropertiesExtras;
|
|
15
16
|
export type ElementClassWithInheritedProperties = ElementClass & InheritedPropertiesExtras;
|
|
17
|
+
export type ResolvedChild = Child & {
|
|
18
|
+
implementedBy: ElementWithInfo[] | null;
|
|
19
|
+
};
|
|
20
|
+
export declare function findElement(elements: Record<string, ElementWithInfo>, name: string): ElementWithInfo | null;
|
|
16
21
|
export declare function groupAttributesByMandatory(attributes: Record<string, Attribute>): {
|
|
17
22
|
required: Record<string, Attribute>;
|
|
18
23
|
optional: Record<string, Attribute>;
|
|
@@ -20,4 +25,5 @@ export declare function groupAttributesByMandatory(attributes: Record<string, At
|
|
|
20
25
|
export declare function getInheritedProperties(element: ElementClass, elements: FFDocJson['elements'], enums: FFDocJson['enums']): InheritedProperties;
|
|
21
26
|
export declare function addInheritedPropertiesToElement(element: ElementClass, elements: FFDocJson['elements'], enums: FFDocJson['enums']): ElementClassWithInheritedProperties;
|
|
22
27
|
export declare function flattenInheritedParentElementProperties<T>(inheritedProperties: InheritedParentElementProperties<T>[]): Record<string, T>;
|
|
28
|
+
export declare function resolveInterfaceChildren(child: Child, types: FFDocJson['types'], elements: Record<string, ElementWithInfo>): ResolvedChild;
|
|
23
29
|
export {};
|
package/dist/javadoc.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export type ElementsWithInfo = ElementClass & ElementInfo;
|
|
1
|
+
import { ElementWithInfo } from './ff-doc-base';
|
|
3
2
|
export type LinkData = {
|
|
4
3
|
text: string;
|
|
5
4
|
href?: string;
|
|
6
|
-
element?:
|
|
5
|
+
element?: ElementWithInfo;
|
|
7
6
|
};
|
|
7
|
+
type TransformedJavadocPart = string | LinkData;
|
|
8
|
+
export type TransformedJavadoc = TransformedJavadocPart[];
|
|
8
9
|
export declare const markdownLinkRegex: RegExp;
|
|
9
10
|
export declare const tagsRegex: RegExp;
|
|
10
11
|
export declare const linkRegex: RegExp;
|
|
11
|
-
export declare function transformAsHtml(javadoc: string, elements: Record<string,
|
|
12
|
-
export declare function transformAsText(javadoc: string, elements: Record<string,
|
|
12
|
+
export declare function transformAsHtml(javadoc: string, elements: Record<string, ElementWithInfo>, hasCustomLinkTransform: boolean): TransformedJavadoc;
|
|
13
|
+
export declare function transformAsText(javadoc: string, elements: Record<string, ElementWithInfo>): TransformedJavadoc;
|
|
13
14
|
export declare function defaultLinkTransformation(linkData: LinkData): string;
|
|
14
15
|
/**
|
|
15
16
|
* Creates LinkData object from `@link` taglet's data
|
|
@@ -17,4 +18,5 @@ export declare function defaultLinkTransformation(linkData: LinkData): string;
|
|
|
17
18
|
* e.g. 'PipeLineSession pipeLineSession' for `{@link PipeLineSession pipeLineSession}`
|
|
18
19
|
* @param elements
|
|
19
20
|
*/
|
|
20
|
-
export declare function getLinkData(captureGroup: string, elements: Record<string,
|
|
21
|
+
export declare function getLinkData(captureGroup: string, elements: Record<string, ElementWithInfo>): LinkData;
|
|
22
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frankframework/doc-library-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A powerful and easy-to-use library, designed to extract and process information from the FF! Doc JSON.",
|
|
6
6
|
"module": "dist/doc-library-core.js",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"directory": "packages/core"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@microsoft/api-extractor": "^7.
|
|
20
|
+
"@microsoft/api-extractor": "^7.58.7",
|
|
21
21
|
"unplugin-dts": "1.0.0-beta.6",
|
|
22
|
-
"vite": "^7.3.
|
|
22
|
+
"vite": "^7.3.3"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build": "vite build"
|