@frankframework/doc-library-core 1.0.0 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,17 +1,17 @@
1
- # FF! Doc Library for ESM / TS Applications
2
-
3
- The FF! Doc Library is a powerful and easy-to-use Node.js package designed to extract and process information from the `frankdoc.json`.
4
- This library simplifies working with the data structure and enables seamless integration with [FF! Reference](https://frankdoc.frankframework.org/#/search) and FF! Flow projects.
5
- No matter if you use React, Angular or vanilla JavaScript, FF! Doc Library has you covered.
6
-
7
- ## Usage
8
- ```js
9
- import { FFDoc } from '@frankframework/doc-library-core';
10
- ```
11
-
12
- ## Development
13
- ### Build
14
- Run `pnpm build` to build the library project using Vite. The bundled and type definition files will be stored in the `dist/` directory.
15
-
16
- ### Publishing
17
- Run `pnpm publish` in the this directory in order to publish the library to a package registry.
1
+ # FF! Doc Library for ESM / TS Applications
2
+
3
+ The FF! Doc Library is a powerful and easy-to-use Node.js package designed to extract and process information from the `frankdoc.json`.
4
+ This library simplifies working with the data structure and enables seamless integration with [FF! Reference](https://frankdoc.frankframework.org/#/search) and FF! Flow projects.
5
+ No matter if you use React, Angular or vanilla JavaScript, FF! Doc Library has you covered.
6
+
7
+ ## Usage
8
+ ```js
9
+ import { FFDoc } from '@frankframework/doc-library-core';
10
+ ```
11
+
12
+ ## Development
13
+ ### Build
14
+ Run `pnpm build` to build the library project using Vite. The bundled and type definition files will be stored in the `dist/` directory.
15
+
16
+ ### Publishing
17
+ Run `pnpm publish` in the this directory in order to publish the library to a package registry.
@@ -1,96 +1,96 @@
1
- function d(r, n) {
2
- const e = {};
3
- for (const t of Object.values(r))
4
- if (t.enum) {
5
- const s = n[t.enum];
6
- s && !e[t.enum] && (e[t.enum] = s);
1
+ function h(r, e) {
2
+ const t = {};
3
+ for (const n of Object.values(r))
4
+ if (n.enum) {
5
+ const s = e[n.enum];
6
+ s && !t[n.enum] && (t[n.enum] = s);
7
7
  }
8
- return e;
8
+ return t;
9
9
  }
10
- function h(r) {
10
+ function d(r) {
11
11
  return Object.entries(r).reduce(
12
- (n, [e, t]) => (n[t.mandatory === !0 ? "required" : "optional"][e] = t, n),
12
+ (e, [t, n]) => (e[n.mandatory === !0 ? "required" : "optional"][t] = n, e),
13
13
  { required: {}, optional: {} }
14
14
  );
15
15
  }
16
- function c(r, n, e) {
17
- const t = {
16
+ function c(r, e, t) {
17
+ const n = {
18
18
  attributesRequired: [],
19
19
  attributesOptional: [],
20
20
  forwards: {},
21
21
  enums: {},
22
22
  parentElements: []
23
23
  };
24
- if (!r.parent) return t;
25
- const s = n[r.parent];
26
- if (!s) return t;
27
- const i = c(s, n, e);
24
+ if (!r.parent) return n;
25
+ const s = e[r.parent];
26
+ if (!s) return n;
27
+ const i = c(s, e, t);
28
28
  if (i.parentElements.unshift(s.name), s.attributes) {
29
- const { required: a, optional: l } = h(
29
+ const { required: l, optional: a } = d(
30
30
  s.attributes
31
31
  );
32
- Object.values(a).length > 0 && i.attributesRequired.unshift({
33
- parentElementName: s.name,
34
- properties: a
35
- }), Object.values(l).length > 0 && i.attributesOptional.unshift({
32
+ Object.values(l).length > 0 && i.attributesRequired.unshift({
36
33
  parentElementName: s.name,
37
34
  properties: l
38
- }), i.enums = { ...i.enums, ...d(s.attributes, e) };
35
+ }), Object.values(a).length > 0 && i.attributesOptional.unshift({
36
+ parentElementName: s.name,
37
+ properties: a
38
+ }), i.enums = { ...i.enums, ...h(s.attributes, t) };
39
39
  }
40
40
  return s.forwards && (i.forwards = { ...i.forwards, ...s.forwards }), i;
41
41
  }
42
- function p(r, n, e) {
43
- const t = c(r, n, e);
42
+ function p(r, e, t) {
43
+ const n = c(r, e, t);
44
44
  return {
45
45
  ...r,
46
- parentElements: t.parentElements,
46
+ parentElements: n.parentElements,
47
47
  attributes: {
48
- ...f(t.attributesOptional),
49
- ...f(t.attributesRequired),
48
+ ...f(n.attributesOptional),
49
+ ...f(n.attributesRequired),
50
50
  ...r.attributes
51
51
  },
52
- forwards: { ...t.forwards, ...r.forwards },
53
- enums: t.enums
52
+ forwards: { ...n.forwards, ...r.forwards },
53
+ enums: n.enums
54
54
  };
55
55
  }
56
56
  function f(r) {
57
- let n = {};
58
- for (const e of r)
59
- n = { ...e.properties, ...n };
60
- return n;
57
+ let e = {};
58
+ for (const t of r)
59
+ e = { ...t.properties, ...e };
60
+ return e;
61
61
  }
62
62
  class b {
63
- getFiltersFromLabels(n) {
64
- const e = {};
65
- for (const [t, s] of Object.entries(n)) {
66
- e[t] = {};
63
+ getFiltersFromLabels(e) {
64
+ const t = {};
65
+ for (const [n, s] of Object.entries(e)) {
66
+ t[n] = {};
67
67
  for (const i of s)
68
- e[t][i] = [];
68
+ t[n][i] = [];
69
69
  }
70
- return e;
70
+ return t;
71
71
  }
72
- assignFrankDocElementsToFilters(n, e) {
73
- for (const [t, s] of Object.entries(e))
72
+ assignFrankDocElementsToFilters(e, t) {
73
+ for (const [n, s] of Object.entries(t))
74
74
  for (const i in s.labels) {
75
- const a = s.labels[i];
76
- !n[i] || !n[i][a] || n[i][a].push(t);
75
+ const l = s.labels[i];
76
+ !e[i] || !e[i][l] || e[i][l].push(n);
77
77
  }
78
- return n;
78
+ return e;
79
79
  }
80
- getXMLElements(n) {
81
- const e = {};
82
- for (const [t, s] of Object.entries(n.elementNames)) {
83
- const i = n.elements[s.className];
84
- e[t] = {
85
- ...p(i, n.elements, n.enums),
80
+ getXMLElements(e) {
81
+ const t = {};
82
+ for (const [n, s] of Object.entries(e.elementNames)) {
83
+ const i = e.elements[s.className];
84
+ t[n] = {
85
+ ...p(i, e.elements, e.enums),
86
86
  ...s,
87
- name: t
87
+ name: n
88
88
  };
89
89
  }
90
- return e;
90
+ return t;
91
91
  }
92
92
  }
93
- class k extends b {
93
+ class D extends b {
94
94
  constructor() {
95
95
  super(...arguments), this._ffDoc = null, this._elements = null, this._filters = {};
96
96
  }
@@ -103,72 +103,77 @@ class k extends b {
103
103
  get filters() {
104
104
  return this._filters;
105
105
  }
106
- async initialize(n) {
107
- const e = await this.fetchJson(n);
108
- this._ffDoc = e, this._filters = this.assignFrankDocElementsToFilters(
109
- this.getFiltersFromLabels(e.labels),
110
- e.elementNames
111
- ), this._elements = this.getXMLElements(e);
106
+ async initialize(e) {
107
+ const t = await this.fetchJson(e);
108
+ this._ffDoc = t, this._filters = this.assignFrankDocElementsToFilters(
109
+ this.getFiltersFromLabels(t.labels),
110
+ t.elementNames
111
+ ), this._elements = this.getXMLElements(t);
112
112
  }
113
- async fetchJson(n) {
114
- return await (await fetch(n)).json();
113
+ async fetchJson(e) {
114
+ return await (await fetch(e)).json();
115
115
  }
116
116
  }
117
117
  const m = /\[([^\]]+)]\(([^)]+)\)/g, g = /<[^>]*>?/gm, o = /(?:{@link\s(.*?)})/g;
118
- function D(r, n, e) {
119
- let t = `${r}`;
120
- return t = t.replaceAll(m, '<a target="_blank" href="$2" alt="$1">$1</a>'), e ? (t = t.replaceAll(o, (s, i) => {
121
- const a = u(i, n);
122
- return a.href ? `\\"${JSON.stringify(a)}\\"` : a.text;
123
- }), t.split(String.raw`\"`)) : (t = t.replaceAll(o, (s, i) => {
124
- const a = u(i, n);
125
- return a.href ? O(a) : a.text;
126
- }), t = t.replaceAll(String.raw`\"`, '"'), [t]);
118
+ function F(r, e, t) {
119
+ let n = r.replaceAll(m, '<a target="_blank" href="$2" alt="$1">$1</a>').replaceAll(String.raw`\"`, '"');
120
+ return t ? O(n, e) : (n = n.replaceAll(o, (s, i) => {
121
+ const l = u(i, e);
122
+ return l.href ? x(l) : l.text;
123
+ }), [n]);
127
124
  }
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];
125
+ function P(r, e) {
126
+ return [r.replaceAll(m, "$1($2)").replaceAll(g, "").replaceAll(o, (n, s) => u(s, e).text).replaceAll(String.raw`\"`, '"')];
131
127
  }
132
- function O(r) {
128
+ function x(r) {
133
129
  return `<a href="#/${r.href}">${r.text}</a>`;
134
130
  }
135
- function u(r, n) {
136
- const e = r.indexOf("#"), t = e !== -1, s = t ? r.split("#")[0] : r;
131
+ function u(r, e) {
132
+ const t = r.indexOf("#"), n = t !== -1, s = n ? r.split("#")[0] : r;
137
133
  if (s === "")
138
- return { text: w(r, e) };
139
- const i = s.split(" "), a = x(i, t, r), l = E(n, i[0]);
140
- return l ? { href: l.name, text: a } : { text: a };
134
+ return { text: E(r, t) };
135
+ const i = s.split(" "), l = w(i, n, r), a = k(e, i[0]);
136
+ return a ? { href: a.className, text: l, element: a } : { text: l };
141
137
  }
142
- function w(r, n) {
143
- const e = r.slice(n), t = e.split(" ");
144
- return t.length === 2 ? t[1] : e.slice(1, e.indexOf("("));
138
+ function O(r, e) {
139
+ const t = [];
140
+ let n = 0;
141
+ for (const s of r.matchAll(o)) {
142
+ const [i, l] = s, a = u(l, e);
143
+ t.push(r.slice(n, s.index), a.href ? a : a.text), n = s.index + i.length;
144
+ }
145
+ return n < r.length - 1 && t.push(r.slice(n)), t;
145
146
  }
146
- function x(r, n, e) {
147
- const t = r.at(-1);
148
- if (n) {
149
- const s = e.split("#")[1], i = s.slice(s.indexOf(") ") + 1).trim();
150
- return i.includes(" ") ? s.split(" ")[1] : `${t}.${i}`;
147
+ function E(r, e) {
148
+ const t = r.slice(e), n = t.split(" ");
149
+ return n.length === 2 ? n[1] : t.slice(1, t.indexOf("("));
150
+ }
151
+ function w(r, e, t) {
152
+ const n = r.at(-1);
153
+ if (e) {
154
+ const s = t.split("#")[1], i = s.slice(s.indexOf(") ") + 1).trim();
155
+ return i.includes(" ") ? s.split(" ")[1] : `${n}.${i}`;
151
156
  }
152
- return t;
157
+ return n;
153
158
  }
154
- function E(r, n) {
159
+ function k(r, e) {
155
160
  if (Object.keys(r).length === 0) return null;
156
- const e = r[n];
157
- return e || (console.warn(`could not find element [${n}]`), null);
161
+ const t = r[e] ?? Object.values(r).find((n) => n.className === e);
162
+ return t || (console.warn(`could not find element [${e}]`), null);
158
163
  }
159
164
  export {
160
- k as FFDoc,
165
+ D as FFDoc,
161
166
  b as FFDocBase,
162
167
  p as addInheritedPropertiesToElement,
163
- O as defaultLinkTransformation,
168
+ x as defaultLinkTransformation,
164
169
  f as flattenInheritedParentElementProperties,
165
170
  c as getInheritedProperties,
166
171
  u as getLinkData,
167
- h as groupAttributesByMandatory,
172
+ d as groupAttributesByMandatory,
168
173
  o as linkRegex,
169
174
  m as markdownLinkRegex,
170
175
  g as tagsRegex,
171
- D as transformAsHtml,
172
- F as transformAsText
176
+ F as transformAsHtml,
177
+ P as transformAsText
173
178
  };
174
179
  //# 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 } from './frankdoc.types';\n\nexport type LinkData = { text: string; href?: string };\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, ElementClass>,\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, ElementClass>): 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, ElementClass>): 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.name, text: name };\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, ElementClass>, simpleName: string): ElementClass | 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,OAC3BG,EAAWH,EAAU,cAAc,KAAO,aAAa,UAAU,EAAEI,CAAI,IAAIJ,GACpEG;AAAA,IAET,EAAE,UAAU,IAAI,UAAU,CAAA,EAAC;AAAA,EAAE;AAEjC;AAEO,SAASE,EACdC,GACAC,GACAT,GACqB;AACrB,QAAMU,IAAkD;AAAA,IACtD,oBAAoB,CAAA;AAAA,IACpB,oBAAoB,CAAA;AAAA,IACpB,UAAU,CAAA;AAAA,IACV,OAAO,CAAA;AAAA,IACP,gBAAgB,CAAA;AAAA,EAAC;AAGnB,MAAI,CAACF,E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WAAOE,EAAkB,SAAS,GAAG,IAAIF,EAAO,MAAM,GAAG,EAAE,CAAC,IAAI,GAAG9B,CAAW,IAAIgC,CAAiB;AAAA,EACrG;AACA,SAAOhC;AACT;AAEA,SAAS6B,EAAY7C,GAAwCiD,GAAyC;AACpG,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, 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};\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, ElementsWithInfo>,\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, ElementsWithInfo>): 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, 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\nfunction transformAsCustomHtml(javadoc: string, elements: Record<string, ElementsWithInfo>): 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\nfunction findElement(elements: Record<string, ElementsWithInfo>, name: string): ElementsWithInfo | 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 console.warn(`could not find element [${name}]`);\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","transformed","transformAsCustomHtml","_","captureGroup","linkData","getLinkData","defaultLinkTransformation","transformAsText","hashPosition","isMethod","elementString","getInternalMethodReference","elementParts","parseLinkName","findElement","transformedParts","lastIndex","match","string","method","methodParts","methodNameOrLabel"],"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,OAC3BG,EAAWH,EAAU,cAAc,KAAO,aAAa,UAAU,EAAEI,CAAI,IAAIJ,GACpEG;AAAA,IAET,EAAE,UAAU,IAAI,UAAU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AAShB,EAAa,MAAMK,CAAY,GAC5CY,IAAcD,EAAO,MAAM,GAAG;AAChC,SAAOC,EAAY,WAAW,IAC1BA,EAAY,CAAC,IACbD,EAAO,MAAM,GAAGA,EAAO,QAAQ,GAAG,CAAC;AACzC;AAEA,SAASN,EAAcD,GAAwBH,GAAmBN,GAA8B;AAC9F,QAAMnB,IAAc4B,EAAa,GAAG,EAAE;AACtC,MAAIH,GAAU;AACZ,UAAMU,IAAShB,EAAa,MAAM,GAAG,EAAE,CAAC,GACtCkB,IAAoBF,EAAO,MAAMA,EAAO,QAAQ,IAAI,IAAI,CAAC,EAAE,KAAA;AAC7D,WAAOE,EAAkB,SAAS,GAAG,IAAIF,EAAO,MAAM,GAAG,EAAE,CAAC,IAAI,GAAGnC,CAAW,IAAIqC,CAAiB;AAAA,EACrG;AACA,SAAOrC;AACT;AAEA,SAAS8B,EAAY9C,GAA4CH,GAAuC;AACtG,MAAI,OAAO,KAAKG,CAAQ,EAAE,WAAW,EAAG,QAAO;AAC/C,QAAMD,IAAUC,EAASH,CAAI,KAAK,OAAO,OAAOG,CAAQ,EAAE,KAAK,CAACD,MAAYA,EAAQ,cAAcF,CAAI;AACtG,SAAIE,MAEJ,QAAQ,KAAK,2BAA2BF,CAAI,GAAG,GACxC;AACT;"}
package/dist/javadoc.d.ts CHANGED
@@ -1,13 +1,17 @@
1
- import { ElementClass } from './frankdoc.types';
1
+ import { ElementClass, ElementInfo } from './frankdoc.types';
2
+ export type ElementsWithInfo = ElementClass & ElementInfo;
2
3
  export type LinkData = {
3
4
  text: string;
4
5
  href?: string;
6
+ element?: ElementsWithInfo;
5
7
  };
8
+ type TransformedJavadocPart = string | LinkData;
9
+ export type TransformedJavadoc = TransformedJavadocPart[];
6
10
  export declare const markdownLinkRegex: RegExp;
7
11
  export declare const tagsRegex: RegExp;
8
12
  export declare const linkRegex: RegExp;
9
- export declare function transformAsHtml(javadoc: string, elements: Record<string, ElementClass>, hasCustomLinkTransform: boolean): string[];
10
- export declare function transformAsText(javadoc: string, elements: Record<string, ElementClass>): string[];
13
+ export declare function transformAsHtml(javadoc: string, elements: Record<string, ElementsWithInfo>, hasCustomLinkTransform: boolean): TransformedJavadoc;
14
+ export declare function transformAsText(javadoc: string, elements: Record<string, ElementsWithInfo>): TransformedJavadoc;
11
15
  export declare function defaultLinkTransformation(linkData: LinkData): string;
12
16
  /**
13
17
  * Creates LinkData object from `@link` taglet's data
@@ -15,4 +19,5 @@ export declare function defaultLinkTransformation(linkData: LinkData): string;
15
19
  * e.g. 'PipeLineSession pipeLineSession' for `{@link PipeLineSession pipeLineSession}`
16
20
  * @param elements
17
21
  */
18
- export declare function getLinkData(captureGroup: string, elements: Record<string, ElementClass>): LinkData;
22
+ export declare function getLinkData(captureGroup: string, elements: Record<string, ElementsWithInfo>): LinkData;
23
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frankframework/doc-library-core",
3
- "version": "1.0.0",
3
+ "version": "1.0.3",
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.55.0",
20
+ "@microsoft/api-extractor": "^7.55.2",
21
21
  "unplugin-dts": "1.0.0-beta.6",
22
- "vite": "^7.2.2"
22
+ "vite": "^7.3.1"
23
23
  },
24
24
  "scripts": {
25
25
  "build": "vite build"