@judo/codegen 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +277 -0
- package/README.md +106 -0
- package/dist/cli.d.ts +9 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +76 -0
- package/dist/cli.js.map +1 -0
- package/dist/generator.d.ts +25 -0
- package/dist/generator.d.ts.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/model-reader-SXrCZEyZ.js +1811 -0
- package/dist/model-reader-SXrCZEyZ.js.map +1 -0
- package/dist/model-reader.d.ts +137 -0
- package/dist/model-reader.d.ts.map +1 -0
- package/dist/name-utils.d.ts +64 -0
- package/dist/name-utils.d.ts.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,1811 @@
|
|
|
1
|
+
function toActionIdentifier(l) {
|
|
2
|
+
let R = l.split("::").map((l) => l.trim()).filter(Boolean), z = R[R.length - 1] ?? l, B = z.replace(/TabularReferenceTable/g, "").replace(/TabularReferenceFieldLink/g, "").replace(/Action$/g, "").replace(/ActionDefinition$/g, "");
|
|
3
|
+
if (B.startsWith("Operation")) {
|
|
4
|
+
let l = R.length >= 2 ? R[R.length - 2] : "";
|
|
5
|
+
if (l) {
|
|
6
|
+
let R = B.replace(/^Operation/, "").replace(/^Form/, "").replace(/^Unmapped/, "");
|
|
7
|
+
B = R ? `${l}_${R}` : l;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
if (!B || B === "Table" || B === "Form" || B === "View") {
|
|
11
|
+
let l = R.length >= 2 ? R[R.length - 2] : "";
|
|
12
|
+
l && (B = `${l}_${z}`);
|
|
13
|
+
}
|
|
14
|
+
return sanitizeIdentifier(toCamelCase(B));
|
|
15
|
+
}
|
|
16
|
+
function toNavItemIdentifier(l) {
|
|
17
|
+
let R = l.split("::").map((l) => l.trim()).filter(Boolean), z = R.findIndex((l) => l === "NavigationItem");
|
|
18
|
+
return toPascalCase(z > 0 ? R[z - 1] : R[R.length - 1] ?? l);
|
|
19
|
+
}
|
|
20
|
+
function toComponentIdentifier(l) {
|
|
21
|
+
return sanitizeIdentifier(toPascalCase(l));
|
|
22
|
+
}
|
|
23
|
+
function toTransferIdentifier(l) {
|
|
24
|
+
return sanitizeIdentifier(l.split("::").map((l) => l.trim()).filter(Boolean).map((l) => toPascalCase(l)).join(""));
|
|
25
|
+
}
|
|
26
|
+
function toPascalCase(l) {
|
|
27
|
+
return l.replace(/[_\-\s]+(.)?/g, (l, R) => R ? R.toUpperCase() : "").replace(/^./, (l) => l.toUpperCase());
|
|
28
|
+
}
|
|
29
|
+
function toCamelCase(l) {
|
|
30
|
+
let R = toPascalCase(l);
|
|
31
|
+
return R.charAt(0).toLowerCase() + R.slice(1);
|
|
32
|
+
}
|
|
33
|
+
function sanitizeIdentifier(l) {
|
|
34
|
+
let R = l.replace(/^[0-9]+/, "");
|
|
35
|
+
return R = R.replace(/[^a-zA-Z0-9_$]/g, ""), R ||= "_unnamed", R;
|
|
36
|
+
}
|
|
37
|
+
var TYPEAHEAD_ELEMENT_TYPES = new Set(["TextInput"]), TABLE_ELEMENT_TYPES = new Set(["Table"]), ENUM_ELEMENT_TYPES = new Set([
|
|
38
|
+
"EnumerationCombo",
|
|
39
|
+
"EnumerationRadio",
|
|
40
|
+
"EnumerationToggleButtonbar"
|
|
41
|
+
]), DATE_ELEMENT_TYPES = new Set(["DateInput", "DateTimeInput"]), COLUMN_ELEMENT_TYPES = new Set(["Column"]), SECTION_TYPE_FILTERS = [
|
|
42
|
+
["typeaheadProviders", TYPEAHEAD_ELEMENT_TYPES],
|
|
43
|
+
["tableRowHighlighting", TABLE_ELEMENT_TYPES],
|
|
44
|
+
["enumOptionFilter", ENUM_ELEMENT_TYPES],
|
|
45
|
+
["dateValidationProps", DATE_ELEMENT_TYPES],
|
|
46
|
+
["columnCustomizers", COLUMN_ELEMENT_TYPES],
|
|
47
|
+
["itemContainerConfigs", TABLE_ELEMENT_TYPES]
|
|
48
|
+
];
|
|
49
|
+
function computeElementShortKeys(l) {
|
|
50
|
+
let R = /* @__PURE__ */ new Map(), z = [], B = /* @__PURE__ */ new Set();
|
|
51
|
+
for (let R of l) B.has(R.path) || (B.add(R.path), z.push(R));
|
|
52
|
+
let V = /* @__PURE__ */ new Map();
|
|
53
|
+
for (let l of z) {
|
|
54
|
+
let R = V.get(l.name) ?? [];
|
|
55
|
+
R.push(l), V.set(l.name, R);
|
|
56
|
+
}
|
|
57
|
+
for (let [, l] of V) if (l.length === 1) R.set(l[0].path, l[0].name);
|
|
58
|
+
else for (let z of l) {
|
|
59
|
+
let B = z.path.split("."), V = !1;
|
|
60
|
+
for (let H = 2; H <= B.length; H++) {
|
|
61
|
+
let U = B.slice(-H).join(".");
|
|
62
|
+
if (l.every((l) => l.path === z.path || l.path.split(".").slice(-H).join(".") !== U)) {
|
|
63
|
+
R.set(z.path, U), V = !0;
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
V || R.set(z.path, z.path);
|
|
68
|
+
}
|
|
69
|
+
return R;
|
|
70
|
+
}
|
|
71
|
+
function filterElementKeys(l, R) {
|
|
72
|
+
let z = /* @__PURE__ */ new Set(), B = [];
|
|
73
|
+
for (let V of l) R.has(V.elementType) && !z.has(V.path) && (z.add(V.path), B.push(V));
|
|
74
|
+
let V = computeElementShortKeys(B), H = [], U = /* @__PURE__ */ new Map();
|
|
75
|
+
for (let l of B) {
|
|
76
|
+
let R = V.get(l.path) ?? l.name;
|
|
77
|
+
U.has(R) || (H.push(R), U.set(R, l.sourceId));
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
keys: H,
|
|
81
|
+
sourceMap: U
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function buildAnnotationComponentGroups(l, R) {
|
|
85
|
+
let z = /* @__PURE__ */ new Map();
|
|
86
|
+
for (let B of l) if (B.annotations) {
|
|
87
|
+
for (let l of B.annotations) if (l.startsWith(R) && l.length > R.length) {
|
|
88
|
+
let V = l.slice(R.length), H = z.get(V);
|
|
89
|
+
H || (H = [], z.set(V, H)), H.push(B.sourceId);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
let B = [];
|
|
93
|
+
for (let [l, R] of z) B.push({
|
|
94
|
+
name: l,
|
|
95
|
+
sourceIds: R
|
|
96
|
+
});
|
|
97
|
+
return B.toSorted((l, R) => l.name.localeCompare(R.name));
|
|
98
|
+
}
|
|
99
|
+
function generate(l) {
|
|
100
|
+
let { model: R, scaffoldStubs: z = !1, applicationFilter: B, customComponentAnnotationPrefix: V = "use" } = l, H = /* @__PURE__ */ new Map(), U = B ? R.pages.filter((l) => l.applicationName === B) : R.pages, W = new Set(U.map((l) => l.name)), G = R.components.filter((l) => !l.pageName || W.has(l.pageName)), K = buildAnnotationComponentGroups(G, V), q = buildPageIdentifiers(U), J = buildComponentIdentifiers(G);
|
|
101
|
+
H.set("_source-id-map.ts", generateSourceIdMap(U, G, q, J, K));
|
|
102
|
+
for (let l of U) {
|
|
103
|
+
let R = q.get(l.sourceId);
|
|
104
|
+
H.set(`pages/${R}.ts`, generatePageTypes(l, R));
|
|
105
|
+
}
|
|
106
|
+
H.set("pages/index.ts", generatePagesIndex(U, q));
|
|
107
|
+
for (let l of G) {
|
|
108
|
+
let R = J.get(l.sourceId);
|
|
109
|
+
H.set(`components/${R}.ts`, generateComponentTypes(l, R));
|
|
110
|
+
}
|
|
111
|
+
H.set("components/index.ts", generateComponentsIndex(G, J));
|
|
112
|
+
let Y = R.transferTypes ?? [], X = R.dataTypes ?? [];
|
|
113
|
+
if (Y.length > 0) {
|
|
114
|
+
let l = generateTransferFiles(Y, X);
|
|
115
|
+
for (let [R, z] of l) H.set(R, z);
|
|
116
|
+
}
|
|
117
|
+
let Z = R.subThemeNames ?? [];
|
|
118
|
+
if (H.set("customizations.ts", generateCustomizationsFactory(U, G, q, J, Z, K)), H.set("index.ts", generateIndex(Y.length > 0)), z) {
|
|
119
|
+
for (let l of U) {
|
|
120
|
+
let R = q.get(l.sourceId);
|
|
121
|
+
H.set(`stubs/pages/use${R}Actions.ts`, generatePageStub(l, R));
|
|
122
|
+
}
|
|
123
|
+
for (let l of G) {
|
|
124
|
+
let R = J.get(l.sourceId);
|
|
125
|
+
H.set(`stubs/components/${R}.tsx`, generateComponentStub(l, R));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
let $ = R.navigationItems ?? [];
|
|
129
|
+
return H.set("locales/en-US.json", generateTranslationBaseline(U, $, q)), H.set("_translation-key-map.ts", generateTranslationKeyMap(U, $, q)), { files: H };
|
|
130
|
+
}
|
|
131
|
+
function buildPageIdentifiers(l) {
|
|
132
|
+
let R = /* @__PURE__ */ new Map(), z = /* @__PURE__ */ new Map();
|
|
133
|
+
for (let B of l) {
|
|
134
|
+
let l = derivePageIdentifier(B.name), V = z.get(l) ?? 0;
|
|
135
|
+
z.set(l, V + 1), V > 0 && (l = `${l}${V}`), R.set(B.sourceId, l);
|
|
136
|
+
}
|
|
137
|
+
return R;
|
|
138
|
+
}
|
|
139
|
+
function derivePageIdentifier(l) {
|
|
140
|
+
return l.split("::").map((l) => l.trim()).filter(Boolean).map((l) => toPascalCase(l)).join("");
|
|
141
|
+
}
|
|
142
|
+
function buildComponentIdentifiers(l) {
|
|
143
|
+
let R = /* @__PURE__ */ new Map(), B = /* @__PURE__ */ new Map();
|
|
144
|
+
for (let V of l) {
|
|
145
|
+
let l = toComponentIdentifier(V.name), H = B.get(l) ?? 0;
|
|
146
|
+
B.set(l, H + 1), H > 0 && (l = `${l}${H}`), R.set(V.sourceId, l);
|
|
147
|
+
}
|
|
148
|
+
return R;
|
|
149
|
+
}
|
|
150
|
+
function generateSourceIdMap(l, R, z, B, V) {
|
|
151
|
+
let H = [
|
|
152
|
+
"// AUTO-GENERATED — DO NOT EDIT",
|
|
153
|
+
"// This file is internal to the generated code. Do not import directly.",
|
|
154
|
+
"",
|
|
155
|
+
"/** @internal */",
|
|
156
|
+
"export const PAGE_SOURCE_IDS: Record<string, string> = {"
|
|
157
|
+
];
|
|
158
|
+
for (let R of l) {
|
|
159
|
+
let l = z.get(R.sourceId);
|
|
160
|
+
H.push(` ${JSON.stringify(l)}: ${JSON.stringify(R.sourceId)},`);
|
|
161
|
+
}
|
|
162
|
+
H.push("};", ""), H.push("/** @internal */"), H.push("export const ACTION_SOURCE_IDS: Record<string, Record<string, string>> = {");
|
|
163
|
+
for (let R of l) {
|
|
164
|
+
let l = z.get(R.sourceId);
|
|
165
|
+
if (R.actions.length === 0) continue;
|
|
166
|
+
let B = buildActionIdentifiers(R.actions);
|
|
167
|
+
H.push(` ${JSON.stringify(l)}: {`);
|
|
168
|
+
for (let l of R.actions) {
|
|
169
|
+
let R = B.get(l.sourceId);
|
|
170
|
+
H.push(` ${JSON.stringify(R)}: ${JSON.stringify(l.sourceId)},`);
|
|
171
|
+
}
|
|
172
|
+
H.push(" },");
|
|
173
|
+
}
|
|
174
|
+
H.push("};", ""), H.push("/** @internal */"), H.push("export const COMPONENT_SOURCE_IDS: Record<string, string> = {");
|
|
175
|
+
for (let l of R) {
|
|
176
|
+
let R = B.get(l.sourceId);
|
|
177
|
+
H.push(` ${JSON.stringify(R)}: ${JSON.stringify(l.sourceId)},`);
|
|
178
|
+
}
|
|
179
|
+
H.push("};", ""), H.push("/** @internal */"), H.push("export const ELEMENT_SOURCE_IDS: Record<string, Record<string, string>> = {");
|
|
180
|
+
for (let R of l) {
|
|
181
|
+
let l = z.get(R.sourceId);
|
|
182
|
+
if (R.elements.length === 0) continue;
|
|
183
|
+
let B = computeElementShortKeys(R.elements);
|
|
184
|
+
H.push(` ${JSON.stringify(l)}: {`);
|
|
185
|
+
let V = /* @__PURE__ */ new Set();
|
|
186
|
+
for (let l of R.elements) {
|
|
187
|
+
if (V.has(l.path)) continue;
|
|
188
|
+
V.add(l.path);
|
|
189
|
+
let R = B.get(l.path) ?? l.name;
|
|
190
|
+
H.push(` ${JSON.stringify(R)}: ${JSON.stringify(l.sourceId)},`);
|
|
191
|
+
}
|
|
192
|
+
H.push(" },");
|
|
193
|
+
}
|
|
194
|
+
H.push("};"), H.push(""), H.push("/** @internal — section-local element key → sourceId maps */"), H.push("export const SECTION_ELEMENT_SOURCE_IDS: Record<string, Record<string, Record<string, string>>> = {");
|
|
195
|
+
for (let [R, B] of SECTION_TYPE_FILTERS) {
|
|
196
|
+
let V = [];
|
|
197
|
+
for (let R of l) {
|
|
198
|
+
let l = z.get(R.sourceId), { keys: H, sourceMap: U } = filterElementKeys(R.elements, B);
|
|
199
|
+
H.length !== 0 && V.push(` ${JSON.stringify(l)}: {\n${H.map((l) => ` ${JSON.stringify(l)}: ${JSON.stringify(U.get(l))},`).join("\n")}\n },`);
|
|
200
|
+
}
|
|
201
|
+
if (V.length > 0) {
|
|
202
|
+
H.push(` ${JSON.stringify(R)}: {`);
|
|
203
|
+
for (let l of V) H.push(l);
|
|
204
|
+
H.push(" },");
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (H.push("};"), V.length > 0) {
|
|
208
|
+
H.push(""), H.push("/** @internal */"), H.push("export const ANNOTATION_COMPONENT_SOURCE_IDS: Record<string, string[]> = {");
|
|
209
|
+
for (let l of V) {
|
|
210
|
+
let R = l.sourceIds.map((l) => JSON.stringify(l)).join(", ");
|
|
211
|
+
H.push(` ${JSON.stringify(l.name)}: [${R}],`);
|
|
212
|
+
}
|
|
213
|
+
H.push("};");
|
|
214
|
+
}
|
|
215
|
+
return `${H.join("\n")}\n`;
|
|
216
|
+
}
|
|
217
|
+
function buildActionIdentifiers(R) {
|
|
218
|
+
let z = /* @__PURE__ */ new Map(), B = /* @__PURE__ */ new Map();
|
|
219
|
+
for (let V of R) {
|
|
220
|
+
let R = toActionIdentifier(V.name), H = B.get(R) ?? 0;
|
|
221
|
+
B.set(R, H + 1), H > 0 && (R = `${R}${H}`), z.set(V.sourceId, R);
|
|
222
|
+
}
|
|
223
|
+
return z;
|
|
224
|
+
}
|
|
225
|
+
function generatePageTypes(l, R) {
|
|
226
|
+
let z = [
|
|
227
|
+
"// AUTO-GENERATED — DO NOT EDIT",
|
|
228
|
+
"",
|
|
229
|
+
"import type { ActionLifecycle } from \"@judo/model-api\";",
|
|
230
|
+
""
|
|
231
|
+
], B = buildActionIdentifiers(l.actions);
|
|
232
|
+
if (z.push("/**"), z.push(` * Action overrides for ${R}.`), z.push(" * Each property maps to an action on this page by its model name."), z.push(" * All properties and their methods are optional."), z.push(" */"), l.actions.length === 0) z.push(`export type ${R}Actions = Record<string, never>;`);
|
|
233
|
+
else {
|
|
234
|
+
z.push(`export interface ${R}Actions {`);
|
|
235
|
+
for (let R of l.actions) {
|
|
236
|
+
let l = B.get(R.sourceId), V = getLifecycleType(R.actionDefinitionType);
|
|
237
|
+
z.push(` /** ${R.actionDefinitionType} — ${R.name} */`), z.push(` ${l}?: Partial<${V}>;`);
|
|
238
|
+
}
|
|
239
|
+
z.push("}");
|
|
240
|
+
}
|
|
241
|
+
if (z.push("/**"), z.push(` * Hook type for providing ${R} action overrides.`), z.push(" */"), z.push(`export type Use${R}Actions = () => ${R}Actions;`), z.push(""), l.elements.length > 0) {
|
|
242
|
+
z.push("/**"), z.push(` * Named elements on ${R}, for use with visual property overrides.`), z.push(" */");
|
|
243
|
+
let B = computeElementShortKeys(l.elements), V = /* @__PURE__ */ new Set(), H = [];
|
|
244
|
+
for (let R of l.elements) {
|
|
245
|
+
let l = B.get(R.path) ?? R.name;
|
|
246
|
+
V.has(l) || (V.add(l), H.push(`"${l}"`));
|
|
247
|
+
}
|
|
248
|
+
z.push(`export type ${R}Elements = ${H.join(" | ")};`), z.push("");
|
|
249
|
+
}
|
|
250
|
+
return z.join("\n");
|
|
251
|
+
}
|
|
252
|
+
function generatePagesIndex(l, R) {
|
|
253
|
+
let z = ["// AUTO-GENERATED — DO NOT EDIT", ""];
|
|
254
|
+
for (let B of l) {
|
|
255
|
+
let l = R.get(B.sourceId);
|
|
256
|
+
z.push(`export type { ${l}Actions, Use${l}Actions } from "./${l}";`);
|
|
257
|
+
}
|
|
258
|
+
return `${z.join("\n")}\n`;
|
|
259
|
+
}
|
|
260
|
+
function generateComponentTypes(l, R) {
|
|
261
|
+
let z = l.elementType === "Flex" ? "Flex" : "VisualElement";
|
|
262
|
+
return [
|
|
263
|
+
"// AUTO-GENERATED — DO NOT EDIT",
|
|
264
|
+
"",
|
|
265
|
+
"import type { CustomComponentProps } from \"@judo/model-api\";",
|
|
266
|
+
`import type { ${z} } from "@judo/model-api";`,
|
|
267
|
+
"",
|
|
268
|
+
"/**",
|
|
269
|
+
` * Props for the ${R} custom component.`,
|
|
270
|
+
` * The element is typed as ${z} (the VisualElement subtype from the model).`,
|
|
271
|
+
" */",
|
|
272
|
+
`export type ${R}Props = CustomComponentProps<${z}>;`,
|
|
273
|
+
""
|
|
274
|
+
].join("\n");
|
|
275
|
+
}
|
|
276
|
+
function generateComponentsIndex(l, R) {
|
|
277
|
+
let z = ["// AUTO-GENERATED — DO NOT EDIT", ""];
|
|
278
|
+
l.length === 0 && z.push("export {};");
|
|
279
|
+
for (let B of l) {
|
|
280
|
+
let l = R.get(B.sourceId);
|
|
281
|
+
z.push(`export type { ${l}Props } from "./${l}";`);
|
|
282
|
+
}
|
|
283
|
+
return `${z.join("\n")}\n`;
|
|
284
|
+
}
|
|
285
|
+
function generateCustomizationsFactory(l, R, z, B, V, H) {
|
|
286
|
+
let U = V.length > 0, Y = H.length > 0, X = ["// AUTO-GENERATED — DO NOT EDIT", ""];
|
|
287
|
+
U ? X.push("import type { ItemContainerConfig, ColumnCustomizerFn, CustomizationsConfig, ComponentInterceptors, CustomComponent, DateValidationFn, EnumOptionFilterFn, GuestPageProps, HeroComponentProps, NavigationItem, PageActionOverrides, PageCustomization, SubThemeHook, TableRowHighlightConfig, VisualPropertyOverrides } from \"@judo/model-api\";") : X.push("import type { ItemContainerConfig, ColumnCustomizerFn, CustomizationsConfig, ComponentInterceptors, CustomComponent, DateValidationFn, EnumOptionFilterFn, GuestPageProps, HeroComponentProps, NavigationItem, PageActionOverrides, PageCustomization, TableRowHighlightConfig, VisualPropertyOverrides } from \"@judo/model-api\";"), X.push("import type { Flex, VisualElement } from \"@judo/model-api\";"), X.push("import type { ComponentType, ReactElement } from \"react\";");
|
|
288
|
+
for (let R of l) {
|
|
289
|
+
let l = z.get(R.sourceId);
|
|
290
|
+
X.push(`import type { Use${l}Actions } from "./pages/${l}";`);
|
|
291
|
+
}
|
|
292
|
+
X.push(""), X.push("import {"), X.push(" PAGE_SOURCE_IDS,"), X.push(" ACTION_SOURCE_IDS,"), X.push(" COMPONENT_SOURCE_IDS,"), X.push(" ELEMENT_SOURCE_IDS,"), X.push(" SECTION_ELEMENT_SOURCE_IDS,"), Y && X.push(" ANNOTATION_COMPONENT_SOURCE_IDS,"), X.push("} from \"./_source-id-map\";"), X.push(""), X.push("/**"), X.push(" * Typed customization configuration."), X.push(" * All keys are human-readable model `name` attributes — never sourceIds."), X.push(" */"), X.push("export interface TypedCustomizationsInput {"), X.push(" pages?: {");
|
|
293
|
+
for (let R of l) {
|
|
294
|
+
let l = z.get(R.sourceId);
|
|
295
|
+
X.push(` ${JSON.stringify(l)}?: {`), X.push(` actions?: Use${l}Actions;`), X.push(" visualProperties?: () => VisualPropertyOverrides;");
|
|
296
|
+
let B = filterElementKeys(R.elements, TYPEAHEAD_ELEMENT_TYPES);
|
|
297
|
+
if (B.keys.length > 0) {
|
|
298
|
+
X.push(" typeaheadProviders?: {");
|
|
299
|
+
for (let l of B.keys) X.push(` ${JSON.stringify(l)}?: (text: string) => Promise<string[]>;`);
|
|
300
|
+
X.push(" };");
|
|
301
|
+
}
|
|
302
|
+
let V = filterElementKeys(R.elements, TABLE_ELEMENT_TYPES);
|
|
303
|
+
if (V.keys.length > 0) {
|
|
304
|
+
X.push(" tableRowHighlighting?: {");
|
|
305
|
+
for (let l of V.keys) X.push(` ${JSON.stringify(l)}?: TableRowHighlightConfig[];`);
|
|
306
|
+
X.push(" };");
|
|
307
|
+
}
|
|
308
|
+
let H = filterElementKeys(R.elements, ENUM_ELEMENT_TYPES);
|
|
309
|
+
if (H.keys.length > 0) {
|
|
310
|
+
X.push(" enumOptionFilter?: {");
|
|
311
|
+
for (let l of H.keys) X.push(` ${JSON.stringify(l)}?: EnumOptionFilterFn;`);
|
|
312
|
+
X.push(" };");
|
|
313
|
+
}
|
|
314
|
+
let U = filterElementKeys(R.elements, DATE_ELEMENT_TYPES);
|
|
315
|
+
if (U.keys.length > 0) {
|
|
316
|
+
X.push(" dateValidationProps?: {");
|
|
317
|
+
for (let l of U.keys) X.push(` ${JSON.stringify(l)}?: DateValidationFn;`);
|
|
318
|
+
X.push(" };");
|
|
319
|
+
}
|
|
320
|
+
let Y = filterElementKeys(R.elements, COLUMN_ELEMENT_TYPES);
|
|
321
|
+
if (Y.keys.length > 0) {
|
|
322
|
+
X.push(" columnCustomizers?: {");
|
|
323
|
+
for (let l of Y.keys) X.push(` ${JSON.stringify(l)}?: ColumnCustomizerFn;`);
|
|
324
|
+
X.push(" };");
|
|
325
|
+
}
|
|
326
|
+
let Q = filterElementKeys(R.elements, TABLE_ELEMENT_TYPES);
|
|
327
|
+
if (Q.keys.length > 0) {
|
|
328
|
+
X.push(" itemContainerConfigs?: {");
|
|
329
|
+
for (let l of Q.keys) X.push(` ${JSON.stringify(l)}?: ItemContainerConfig;`);
|
|
330
|
+
X.push(" };");
|
|
331
|
+
}
|
|
332
|
+
X.push(" };");
|
|
333
|
+
}
|
|
334
|
+
if (X.push(" };"), R.length > 0) {
|
|
335
|
+
X.push(" components?: {");
|
|
336
|
+
for (let l of R) {
|
|
337
|
+
let R = B.get(l.sourceId), z = l.elementType === "Flex" ? "Flex" : "VisualElement";
|
|
338
|
+
X.push(` ${JSON.stringify(R)}?: CustomComponent<${z}>;`);
|
|
339
|
+
}
|
|
340
|
+
X.push(" };");
|
|
341
|
+
}
|
|
342
|
+
if (Y) {
|
|
343
|
+
X.push(" /**"), X.push(" * Annotation-based component overrides. A single component handles all visual elements"), X.push(" * sharing the same annotation (with the annotation prefix stripped)."), X.push(" * E.g., annotation `useFancyText` → key `\"FancyText\"`."), X.push(" */"), X.push(" annotationComponents?: {");
|
|
344
|
+
for (let l of H) X.push(` ${JSON.stringify(l.name)}?: CustomComponent<VisualElement>;`);
|
|
345
|
+
X.push(" };");
|
|
346
|
+
}
|
|
347
|
+
if (X.push(" componentInterceptors?: ComponentInterceptors;"), U) {
|
|
348
|
+
X.push(" /**"), X.push(" * Sub-theme providers keyed by sub-theme name."), X.push(" * Visual elements with matching subTheme values are wrapped in a scoped MUI ThemeProvider."), X.push(" */"), X.push(" subThemeProviders?: {");
|
|
349
|
+
for (let l of V) X.push(` ${JSON.stringify(l)}?: SubThemeHook;`);
|
|
350
|
+
X.push(" };");
|
|
351
|
+
}
|
|
352
|
+
return X.push(" redirectHandler?: ComponentType;"), X.push(" customRoutes?: Array<{ path: string; element: ReactElement }>;"), X.push(" menuCustomizer?: (items: NavigationItem[]) => NavigationItem[];"), X.push(" footerText?: string | (() => string);"), X.push(" heroComponent?: ComponentType<HeroComponentProps>;"), X.push(" settingsPage?: ComponentType;"), X.push(" guestComponent?: ComponentType<GuestPageProps>;"), X.push("}", ""), X.push("/** @internal — common shape used by factory to handle the union of all per-page types */"), X.push("type _PageBundle = {"), X.push(" actions?: () => Record<string, unknown>;"), X.push(" visualProperties?: () => VisualPropertyOverrides;"), X.push(" typeaheadProviders?: Record<string, (text: string) => Promise<string[]>>;"), X.push(" tableRowHighlighting?: Record<string, TableRowHighlightConfig[]>;"), X.push(" enumOptionFilter?: Record<string, EnumOptionFilterFn>;"), X.push(" dateValidationProps?: Record<string, DateValidationFn>;"), X.push(" columnCustomizers?: Record<string, ColumnCustomizerFn>;"), X.push(" itemContainerConfigs?: Record<string, ItemContainerConfig>;"), X.push("};", ""), X.push("/**"), X.push(" * Creates a CustomizationsConfig with type-safe bindings."), X.push(" * Developers use human-readable names; the factory resolves to sourceIds internally."), X.push(" */"), X.push("export function createCustomizations(input: TypedCustomizationsInput): CustomizationsConfig {"), X.push(" const config: CustomizationsConfig = {};"), X.push(""), X.push(" if (input.pages) {"), X.push(" config.pages = {};"), X.push(" for (const [pageName, bundle] of Object.entries(input.pages)) {"), X.push(" const pageSourceId = PAGE_SOURCE_IDS[pageName];"), X.push(" if (!pageSourceId || !bundle) continue;"), X.push(""), X.push(" // Cast to common shape — per-page types are narrower but factory handles all uniformly"), X.push(" const b = bundle as _PageBundle;"), X.push(" const pageCustomization: PageCustomization = {};"), X.push(""), X.push(" if (b.actions) {"), X.push(" const actionMap = ACTION_SOURCE_IDS[pageName];"), X.push(" const actionsHook = b.actions;"), X.push(" pageCustomization.actions = () => {"), X.push(" const namedOverrides = (actionsHook as () => Record<string, unknown>)();"), X.push(" const resolved: PageActionOverrides = {};"), X.push(" for (const [actionName, lifecycle] of Object.entries(namedOverrides)) {"), X.push(" const actionSourceId = actionMap?.[actionName];"), X.push(" if (actionSourceId && lifecycle) resolved[actionSourceId] = lifecycle as PageActionOverrides[string];"), X.push(" }"), X.push(" return resolved;"), X.push(" };"), X.push(" }"), X.push(""), X.push(" if (b.visualProperties) {"), X.push(" const elementMap = ELEMENT_SOURCE_IDS[pageName];"), X.push(" const visualHook = b.visualProperties;"), X.push(" pageCustomization.visualProperties = () => {"), X.push(" const namedOverrides = (visualHook as () => Record<string, unknown>)();"), X.push(" const resolved: Record<string, unknown> = {};"), X.push(" for (const [elementName, props] of Object.entries(namedOverrides)) {"), X.push(" const elementSourceId = elementMap?.[elementName];"), X.push(" if (elementSourceId && props) resolved[elementSourceId] = props;"), X.push(" }"), X.push(" return resolved as VisualPropertyOverrides;"), X.push(" };"), X.push(" }"), X.push(""), X.push(" if (b.typeaheadProviders) {"), X.push(" const elementMap = SECTION_ELEMENT_SOURCE_IDS.typeaheadProviders?.[pageName];"), X.push(" const resolved: Record<string, (text: string) => Promise<string[]>> = {};"), X.push(" for (const [elementName, provider] of Object.entries(b.typeaheadProviders)) {"), X.push(" const elementSourceId = elementMap?.[elementName];"), X.push(" if (elementSourceId && provider) resolved[elementSourceId] = provider;"), X.push(" }"), X.push(" pageCustomization.typeaheadProviders = resolved;"), X.push(" }"), X.push(""), X.push(" if (b.tableRowHighlighting) {"), X.push(" const elementMap = SECTION_ELEMENT_SOURCE_IDS.tableRowHighlighting?.[pageName];"), X.push(" const resolved: Record<string, TableRowHighlightConfig[]> = {};"), X.push(" for (const [elementName, configs] of Object.entries(b.tableRowHighlighting)) {"), X.push(" const elementSourceId = elementMap?.[elementName];"), X.push(" if (elementSourceId && configs) resolved[elementSourceId] = configs;"), X.push(" }"), X.push(" pageCustomization.tableRowHighlighting = resolved;"), X.push(" }"), X.push(""), X.push(" if (b.enumOptionFilter) {"), X.push(" const elementMap = SECTION_ELEMENT_SOURCE_IDS.enumOptionFilter?.[pageName];"), X.push(" const resolved: Record<string, EnumOptionFilterFn> = {};"), X.push(" for (const [elementName, filterFn] of Object.entries(b.enumOptionFilter)) {"), X.push(" const elementSourceId = elementMap?.[elementName];"), X.push(" if (elementSourceId && filterFn) resolved[elementSourceId] = filterFn;"), X.push(" }"), X.push(" pageCustomization.enumOptionFilter = resolved;"), X.push(" }"), X.push(""), X.push(" if (b.dateValidationProps) {"), X.push(" const elementMap = SECTION_ELEMENT_SOURCE_IDS.dateValidationProps?.[pageName];"), X.push(" const resolved: Record<string, DateValidationFn> = {};"), X.push(" for (const [elementName, validationFn] of Object.entries(b.dateValidationProps)) {"), X.push(" const elementSourceId = elementMap?.[elementName];"), X.push(" if (elementSourceId && validationFn) resolved[elementSourceId] = validationFn;"), X.push(" }"), X.push(" pageCustomization.dateValidationProps = resolved;"), X.push(" }"), X.push(""), X.push(" if (b.columnCustomizers) {"), X.push(" const elementMap = SECTION_ELEMENT_SOURCE_IDS.columnCustomizers?.[pageName];"), X.push(" const resolved: Record<string, ColumnCustomizerFn> = {};"), X.push(" for (const [elementName, customizerFn] of Object.entries(b.columnCustomizers)) {"), X.push(" const elementSourceId = elementMap?.[elementName];"), X.push(" if (elementSourceId && customizerFn) resolved[elementSourceId] = customizerFn;"), X.push(" }"), X.push(" pageCustomization.columnCustomizers = resolved;"), X.push(" }"), X.push(""), X.push(" if (b.itemContainerConfigs) {"), X.push(" const elementMap = SECTION_ELEMENT_SOURCE_IDS.itemContainerConfigs?.[pageName];"), X.push(" const resolved: Record<string, ItemContainerConfig> = {};"), X.push(" for (const [elementName, config] of Object.entries(b.itemContainerConfigs)) {"), X.push(" const elementSourceId = elementMap?.[elementName];"), X.push(" if (elementSourceId && config) resolved[elementSourceId] = config;"), X.push(" }"), X.push(" pageCustomization.itemContainerConfigs = resolved;"), X.push(" }"), X.push(""), X.push(" config.pages[pageSourceId] = pageCustomization;"), X.push(" }"), X.push(" }"), X.push(""), Y && (X.push(" // Annotation-based component overrides (lower priority than individual components)"), X.push(" if (input.annotationComponents) {"), X.push(" if (!config.components) config.components = {};"), X.push(" for (const [name, component] of Object.entries(input.annotationComponents)) {"), X.push(" const sourceIds = ANNOTATION_COMPONENT_SOURCE_IDS[name];"), X.push(" if (sourceIds && component) {"), X.push(" for (const sourceId of sourceIds) {"), X.push(" config.components[sourceId] = component as CustomComponent<VisualElement>;"), X.push(" }"), X.push(" }"), X.push(" }"), X.push(" }"), X.push("")), R.length > 0 && (X.push(" // Individual component overrides (highest priority — overwrites annotation-based)"), X.push(" if (input.components) {"), X.push(" if (!config.components) config.components = {};"), X.push(" for (const [name, component] of Object.entries(input.components)) {"), X.push(" const sourceId = COMPONENT_SOURCE_IDS[name];"), X.push(" if (sourceId && component) config.components[sourceId] = component as CustomComponent<VisualElement>;"), X.push(" }"), X.push(" }"), X.push("")), X.push(" if (input.componentInterceptors) {"), X.push(" config.componentInterceptors = input.componentInterceptors;"), X.push(" }"), U && (X.push(""), X.push(" if (input.subThemeProviders) {"), X.push(" config.subThemeProviders = input.subThemeProviders;"), X.push(" }")), X.push(""), X.push(" if (input.redirectHandler) config.redirectHandler = input.redirectHandler;"), X.push(" if (input.customRoutes) config.customRoutes = input.customRoutes;"), X.push(" if (input.menuCustomizer) config.menuCustomizer = input.menuCustomizer;"), X.push(" if (input.footerText !== undefined) config.footerText = input.footerText;"), X.push(" if (input.heroComponent) config.heroComponent = input.heroComponent;"), X.push(" if (input.settingsPage) config.settingsPage = input.settingsPage;"), X.push(" if (input.guestComponent) config.guestComponent = input.guestComponent;"), X.push(""), X.push(" return config;"), X.push("}"), `${X.join("\n")}\n`;
|
|
353
|
+
}
|
|
354
|
+
function generateIndex(l) {
|
|
355
|
+
let R = [
|
|
356
|
+
"// AUTO-GENERATED — DO NOT EDIT",
|
|
357
|
+
"",
|
|
358
|
+
"export * from \"./pages\";",
|
|
359
|
+
"export * from \"./components\";"
|
|
360
|
+
];
|
|
361
|
+
return l && R.push("export * from \"./transfers\";"), R.push("export { createCustomizations } from \"./customizations\";", "export type { TypedCustomizationsInput } from \"./customizations\";", "export { TRANSLATION_KEY_MAP } from \"./_translation-key-map\";", ""), R.join("\n");
|
|
362
|
+
}
|
|
363
|
+
function generatePageStub(l, R) {
|
|
364
|
+
let z = buildActionIdentifiers(l.actions), B = [
|
|
365
|
+
`import type { Use${R}Actions } from "../../pages/${R}";`,
|
|
366
|
+
"",
|
|
367
|
+
"/**",
|
|
368
|
+
` * Action overrides for ${R}.`,
|
|
369
|
+
" * Implement the methods you want to customize.",
|
|
370
|
+
" * Remove this file or clear the body to use all defaults.",
|
|
371
|
+
" */",
|
|
372
|
+
`export const use${R}Actions: Use${R}Actions = () => ({`
|
|
373
|
+
];
|
|
374
|
+
for (let R of l.actions.slice(0, 3)) {
|
|
375
|
+
let l = z.get(R.sourceId);
|
|
376
|
+
B.push(` // ${l}: {`), B.push(` // before: async (context) => { /* custom pre-${l} logic */ },`), B.push(` // after: async (context, result) => { /* custom post-${l} logic */ },`), B.push(" // },");
|
|
377
|
+
}
|
|
378
|
+
return B.push("});"), B.push(""), B.join("\n");
|
|
379
|
+
}
|
|
380
|
+
function generateComponentStub(l, R) {
|
|
381
|
+
return l.elementType, [
|
|
382
|
+
`import type { ${R}Props } from "../../components/${R}";`,
|
|
383
|
+
"",
|
|
384
|
+
"/**",
|
|
385
|
+
` * Custom implementation for ${R}.`,
|
|
386
|
+
" * This component replaces the default renderer for this element.",
|
|
387
|
+
" */",
|
|
388
|
+
`export const ${R}: React.FC<${R}Props> = ({ element, page }) => {`,
|
|
389
|
+
" return (",
|
|
390
|
+
" <div data-source-id={element[\"xmi:id\"]}>",
|
|
391
|
+
` <p>${R} — custom implementation</p>`,
|
|
392
|
+
" </div>",
|
|
393
|
+
" );",
|
|
394
|
+
"};",
|
|
395
|
+
""
|
|
396
|
+
].join("\n");
|
|
397
|
+
}
|
|
398
|
+
function mapDataTypeToTS(l) {
|
|
399
|
+
switch (l) {
|
|
400
|
+
case "data:StringType": return "string";
|
|
401
|
+
case "data:NumericType": return "number";
|
|
402
|
+
case "data:BooleanType": return "boolean";
|
|
403
|
+
case "data:DateType":
|
|
404
|
+
case "data:TimestampType": return "Date";
|
|
405
|
+
case "data:TimeType": return "string";
|
|
406
|
+
case "data:PasswordType": return "string";
|
|
407
|
+
case "data:BinaryType": return "string";
|
|
408
|
+
case "data:EnumerationType": return "string";
|
|
409
|
+
default: return "unknown";
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
function getTemporalFieldType(l) {
|
|
413
|
+
switch (l) {
|
|
414
|
+
case "data:DateType": return "date";
|
|
415
|
+
case "data:TimestampType": return "timestamp";
|
|
416
|
+
case "data:TimeType": return "time";
|
|
417
|
+
default: return null;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
function isDomainEnum(l) {
|
|
421
|
+
return l.xsiType === "data:EnumerationType" && !l.name.endsWith("Operation") && (l.members?.length ?? 0) > 0;
|
|
422
|
+
}
|
|
423
|
+
function generateTransferFiles(l, R) {
|
|
424
|
+
let z = /* @__PURE__ */ new Map(), V = /* @__PURE__ */ new Map();
|
|
425
|
+
for (let l of R) V.set(l.xmiId, l);
|
|
426
|
+
let H = /* @__PURE__ */ new Map();
|
|
427
|
+
for (let R of l) H.set(R.xmiId, R);
|
|
428
|
+
let U = /* @__PURE__ */ new Set();
|
|
429
|
+
for (let R of l) for (let l of R.attributes) {
|
|
430
|
+
let R = V.get(l.dataTypeRef);
|
|
431
|
+
R && isDomainEnum(R) && U.add(R.xmiId);
|
|
432
|
+
}
|
|
433
|
+
let W = R.filter((l) => U.has(l.xmiId)).toSorted((l, R) => l.name.localeCompare(R.name));
|
|
434
|
+
W.length > 0 && z.set("transfers/_enums.ts", generateEnumTypesFile(W));
|
|
435
|
+
let G = l.filter((l) => !l.isActor).toSorted((l, R) => l.name.localeCompare(R.name)), K = /* @__PURE__ */ new Set();
|
|
436
|
+
for (let l of G) l.attributes.some((l) => {
|
|
437
|
+
let R = V.get(l.dataTypeRef);
|
|
438
|
+
return R != null && getTemporalFieldType(R.xsiType) != null;
|
|
439
|
+
}) && K.add(l.name), z.set(`transfers/${toTransferIdentifier(l.name)}.ts`, generateTransferTypeFile(l, V, H, U));
|
|
440
|
+
return K.size > 0 && z.set("transfers/_registry.ts", generateTemporalRegistry(G, V, K)), z.set("transfers/index.ts", generateTransfersIndex(G, W, K)), z;
|
|
441
|
+
}
|
|
442
|
+
function generateEnumTypesFile(l) {
|
|
443
|
+
let R = ["// AUTO-GENERATED — DO NOT EDIT", ""];
|
|
444
|
+
for (let z of l) {
|
|
445
|
+
let l = toTransferIdentifier(z.name), V = (z.members ?? []).map((l) => JSON.stringify(l)).join(" | ");
|
|
446
|
+
R.push(`/** ${z.name} enumeration values */`), R.push(`export type ${l} = ${V};`), R.push("");
|
|
447
|
+
}
|
|
448
|
+
return R.join("\n");
|
|
449
|
+
}
|
|
450
|
+
function generateTransferTypeFile(l, R, z, V) {
|
|
451
|
+
let H = ["// AUTO-GENERATED — DO NOT EDIT", ""], U = /* @__PURE__ */ new Set();
|
|
452
|
+
for (let R of l.relations) {
|
|
453
|
+
let V = z.get(R.targetRef);
|
|
454
|
+
V && V.name !== l.name && !V.isActor && U.add(toTransferIdentifier(V.name));
|
|
455
|
+
}
|
|
456
|
+
let W = /* @__PURE__ */ new Set();
|
|
457
|
+
for (let z of l.attributes) {
|
|
458
|
+
let l = R.get(z.dataTypeRef);
|
|
459
|
+
l && V.has(l.xmiId) && W.add(toTransferIdentifier(l.name));
|
|
460
|
+
}
|
|
461
|
+
let G = [...U].toSorted();
|
|
462
|
+
for (let l of G) H.push(`import type { ${l} } from "./${l}";`);
|
|
463
|
+
if (W.size > 0) {
|
|
464
|
+
let l = [...W].toSorted();
|
|
465
|
+
H.push(`import type { ${l.join(", ")} } from "./_enums";`);
|
|
466
|
+
}
|
|
467
|
+
(U.size > 0 || W.size > 0) && H.push(""), H.push("/**"), H.push(` * Transfer type interface for ${l.name}.`), H.push(" * Provides strict typing for fields defined in the model."), H.push(" */"), H.push(`export interface ${toTransferIdentifier(l.name)} {`);
|
|
468
|
+
for (let z of l.attributes) {
|
|
469
|
+
let l = R.get(z.dataTypeRef), U;
|
|
470
|
+
U = l && V.has(l.xmiId) ? toTransferIdentifier(l.name) : l ? mapDataTypeToTS(l.xsiType) : "unknown", H.push(` ${z.name}?: ${U};`);
|
|
471
|
+
}
|
|
472
|
+
for (let R of l.relations) {
|
|
473
|
+
let l = z.get(R.targetRef);
|
|
474
|
+
if (l && !l.isActor) {
|
|
475
|
+
let z = toTransferIdentifier(l.name), V = R.isCollection ? `${z}[]` : z;
|
|
476
|
+
H.push(` ${R.name}?: ${V};`);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
H.push("}"), H.push("");
|
|
480
|
+
let K = [];
|
|
481
|
+
for (let z of l.attributes) {
|
|
482
|
+
let l = R.get(z.dataTypeRef);
|
|
483
|
+
if (l) {
|
|
484
|
+
let R = getTemporalFieldType(l.xsiType);
|
|
485
|
+
R != null && K.push({
|
|
486
|
+
name: z.name,
|
|
487
|
+
type: R
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
if (K.length > 0) {
|
|
492
|
+
let R = toTransferIdentifier(l.name);
|
|
493
|
+
H.push(`/** Temporal field metadata for ${R} */`), H.push(`export const ${R}TemporalFields: Record<string, string> = {`);
|
|
494
|
+
for (let l of K) H.push(` ${l.name}: "${l.type}",`);
|
|
495
|
+
H.push("};"), H.push("");
|
|
496
|
+
}
|
|
497
|
+
return H.join("\n");
|
|
498
|
+
}
|
|
499
|
+
function generateTemporalRegistry(l, R, z) {
|
|
500
|
+
let V = ["// AUTO-GENERATED — DO NOT EDIT", ""], H = l.filter((l) => z.has(l.name)).toSorted((l, R) => l.name.localeCompare(R.name));
|
|
501
|
+
for (let l of H) {
|
|
502
|
+
let R = toTransferIdentifier(l.name);
|
|
503
|
+
V.push(`import { ${R}TemporalFields } from "./${R}";`);
|
|
504
|
+
}
|
|
505
|
+
V.push(""), V.push("/**"), V.push(" * Combined temporal field registry for all transfer types."), V.push(" * Keys are entity type FQNs (matching __entityType from API responses)."), V.push(" */"), V.push("export const temporalFieldRegistry: Record<string, Record<string, string>> = {");
|
|
506
|
+
for (let l of H) {
|
|
507
|
+
let R = toTransferIdentifier(l.name);
|
|
508
|
+
V.push(` ${JSON.stringify(l.name)}: ${R}TemporalFields,`);
|
|
509
|
+
}
|
|
510
|
+
return V.push("};"), V.push(""), V.join("\n");
|
|
511
|
+
}
|
|
512
|
+
function generateTransfersIndex(l, R, z) {
|
|
513
|
+
let V = ["// AUTO-GENERATED — DO NOT EDIT", ""];
|
|
514
|
+
R.length > 0 && V.push("export type { " + R.map((l) => toTransferIdentifier(l.name)).join(", ") + " } from \"./_enums\";");
|
|
515
|
+
for (let R of l) {
|
|
516
|
+
let l = toTransferIdentifier(R.name);
|
|
517
|
+
V.push(`export type { ${l} } from "./${l}";`), z.has(R.name) && V.push(`export { ${l}TemporalFields } from "./${l}";`);
|
|
518
|
+
}
|
|
519
|
+
return z.size > 0 && V.push("export { temporalFieldRegistry } from \"./_registry\";"), l.length === 0 && R.length === 0 && V.push("export {};"), V.push(""), V.join("\n");
|
|
520
|
+
}
|
|
521
|
+
function getLifecycleType(l) {
|
|
522
|
+
return "ActionLifecycle";
|
|
523
|
+
}
|
|
524
|
+
function derivePageLabel(l) {
|
|
525
|
+
let R = l.split("::").map((l) => l.trim()).filter(Boolean), z = l.match(/::(\w+)::Input::Form$/);
|
|
526
|
+
if (z) return camelCaseToTitleCase(z[1]);
|
|
527
|
+
let B = l.match(/::(\w+)::Relation::Table::CallSelector$/);
|
|
528
|
+
if (B) return camelCaseToTitleCase(B[1]);
|
|
529
|
+
if (R.length >= 2) {
|
|
530
|
+
let l = R[R.length - 2];
|
|
531
|
+
return camelCaseToTitleCase(l);
|
|
532
|
+
}
|
|
533
|
+
return l;
|
|
534
|
+
}
|
|
535
|
+
function camelCaseToTitleCase(l) {
|
|
536
|
+
return l.replace(/_/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").replace(/\b\w/g, (l) => l.toUpperCase());
|
|
537
|
+
}
|
|
538
|
+
function generateTranslationBaseline(l, z, B) {
|
|
539
|
+
let V = {};
|
|
540
|
+
for (let R of l) {
|
|
541
|
+
let l = B.get(R.sourceId);
|
|
542
|
+
if (l) {
|
|
543
|
+
V[l] = R.label ?? derivePageLabel(R.name);
|
|
544
|
+
for (let z of R.elements) {
|
|
545
|
+
let R = z.label ?? z.name;
|
|
546
|
+
V[`${l}.${z.path}`] = R;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
for (let l of z) {
|
|
551
|
+
let z = toNavItemIdentifier(l.name);
|
|
552
|
+
V[`nav.${z}`] = l.label ?? l.name;
|
|
553
|
+
}
|
|
554
|
+
Object.assign(V, {
|
|
555
|
+
"system.action.save.success": "Saved successfully",
|
|
556
|
+
"system.action.save.error": "Save failed",
|
|
557
|
+
"system.action.delete.success": "Deleted successfully",
|
|
558
|
+
"system.action.delete.error": "Delete failed",
|
|
559
|
+
"system.action.delete.confirm": "Are you sure you want to delete this item?",
|
|
560
|
+
"system.action.create.success": "Created successfully",
|
|
561
|
+
"system.action.create.error": "Create failed",
|
|
562
|
+
"system.action.refresh.error": "Failed to refresh",
|
|
563
|
+
"system.validation.required": "This field is required",
|
|
564
|
+
"system.validation.minLength": "Minimum length is {{min}}",
|
|
565
|
+
"system.validation.maxLength": "Maximum length is {{max}}",
|
|
566
|
+
"system.nav.back": "Back",
|
|
567
|
+
"system.nav.home": "Home",
|
|
568
|
+
"system.session.expired": "Session expired",
|
|
569
|
+
"system.session.timeout": "Session timeout",
|
|
570
|
+
"system.loading.default": "Loading...",
|
|
571
|
+
"system.error.network": "Network error",
|
|
572
|
+
"system.error.unknown": "An unknown error occurred",
|
|
573
|
+
"system.error.notFound": "Not found",
|
|
574
|
+
"system.error.forbidden": "Access denied",
|
|
575
|
+
"system.error.unauthorized": "Unauthorized",
|
|
576
|
+
"system.empty.noData": "No data available",
|
|
577
|
+
"system.empty.noResults": "No results found",
|
|
578
|
+
"system.pagination.rowsPerPage": "Rows per page",
|
|
579
|
+
"system.pagination.of": "of",
|
|
580
|
+
"system.table.noRows": "No rows",
|
|
581
|
+
"system.table.filterPlaceholder": "Filter...",
|
|
582
|
+
"system.dialog.confirm": "Confirm",
|
|
583
|
+
"system.dialog.cancel": "Cancel",
|
|
584
|
+
"system.dialog.ok": "OK",
|
|
585
|
+
"system.dialog.yes": "Yes",
|
|
586
|
+
"system.dialog.no": "No",
|
|
587
|
+
"system.dialog.close": "Close",
|
|
588
|
+
"system.auth.login": "Log in",
|
|
589
|
+
"system.auth.logout": "Log out",
|
|
590
|
+
"system.common.save": "Save",
|
|
591
|
+
"system.common.cancel": "Cancel",
|
|
592
|
+
"system.common.delete": "Delete",
|
|
593
|
+
"system.common.create": "Create",
|
|
594
|
+
"system.common.edit": "Edit",
|
|
595
|
+
"system.common.view": "View",
|
|
596
|
+
"system.common.search": "Search",
|
|
597
|
+
"system.common.filter": "Filter",
|
|
598
|
+
"system.common.refresh": "Refresh",
|
|
599
|
+
"system.common.actions": "Actions"
|
|
600
|
+
});
|
|
601
|
+
let H = Object.fromEntries(Object.entries(V).toSorted(([l], [R]) => l.localeCompare(R)));
|
|
602
|
+
return `${JSON.stringify(H, null, 2)}\n`;
|
|
603
|
+
}
|
|
604
|
+
function generateTranslationKeyMap(l, z, B) {
|
|
605
|
+
let V = [
|
|
606
|
+
"// AUTO-GENERATED — DO NOT EDIT",
|
|
607
|
+
"// Maps element sourceId (xmi:id) to human-readable translation key.",
|
|
608
|
+
"// Used by useModelLabel() at runtime to resolve translation keys.",
|
|
609
|
+
"",
|
|
610
|
+
"/** @internal */",
|
|
611
|
+
"export const TRANSLATION_KEY_MAP: Record<string, string> = {"
|
|
612
|
+
], H = /* @__PURE__ */ new Set();
|
|
613
|
+
for (let R of l) {
|
|
614
|
+
let l = B.get(R.sourceId);
|
|
615
|
+
if (l) {
|
|
616
|
+
H.has(R.sourceId) || (H.add(R.sourceId), V.push(` ${JSON.stringify(R.sourceId)}: ${JSON.stringify(l)},`));
|
|
617
|
+
for (let z of R.elements) {
|
|
618
|
+
if (H.has(z.sourceId)) continue;
|
|
619
|
+
H.add(z.sourceId);
|
|
620
|
+
let R = `${l}.${z.path}`;
|
|
621
|
+
V.push(` ${JSON.stringify(z.sourceId)}: ${JSON.stringify(R)},`);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
for (let l of z) {
|
|
626
|
+
if (H.has(l.sourceId)) continue;
|
|
627
|
+
H.add(l.sourceId);
|
|
628
|
+
let z = toNavItemIdentifier(l.name);
|
|
629
|
+
V.push(` ${JSON.stringify(l.sourceId)}: ${JSON.stringify(`nav.${z}`)},`);
|
|
630
|
+
}
|
|
631
|
+
return V.push("};"), `${V.join("\n")}\n`;
|
|
632
|
+
}
|
|
633
|
+
var nameStartChar = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
|
|
634
|
+
nameStartChar + "";
|
|
635
|
+
const nameRegexp = "[" + nameStartChar + "][:A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*";
|
|
636
|
+
var regexName = /* @__PURE__ */ RegExp("^" + nameRegexp + "$");
|
|
637
|
+
function getAllMatches(l, R) {
|
|
638
|
+
let z = [], B = R.exec(l);
|
|
639
|
+
for (; B;) {
|
|
640
|
+
let V = [];
|
|
641
|
+
V.startIndex = R.lastIndex - B[0].length;
|
|
642
|
+
let H = B.length;
|
|
643
|
+
for (let l = 0; l < H; l++) V.push(B[l]);
|
|
644
|
+
z.push(V), B = R.exec(l);
|
|
645
|
+
}
|
|
646
|
+
return z;
|
|
647
|
+
}
|
|
648
|
+
const isName = function(l) {
|
|
649
|
+
return regexName.exec(l) != null;
|
|
650
|
+
};
|
|
651
|
+
function isExist(l) {
|
|
652
|
+
return l !== void 0;
|
|
653
|
+
}
|
|
654
|
+
var defaultOptions$1 = {
|
|
655
|
+
allowBooleanAttributes: !1,
|
|
656
|
+
unpairedTags: []
|
|
657
|
+
};
|
|
658
|
+
function validate(l, R) {
|
|
659
|
+
R = Object.assign({}, defaultOptions$1, R);
|
|
660
|
+
let z = [], B = !1, V = !1;
|
|
661
|
+
l[0] === "" && (l = l.substr(1));
|
|
662
|
+
for (let H = 0; H < l.length; H++) if (l[H] === "<" && l[H + 1] === "?") {
|
|
663
|
+
if (H += 2, H = readPI(l, H), H.err) return H;
|
|
664
|
+
} else if (l[H] === "<") {
|
|
665
|
+
let U = H;
|
|
666
|
+
if (H++, l[H] === "!") {
|
|
667
|
+
H = readCommentAndCDATA(l, H);
|
|
668
|
+
continue;
|
|
669
|
+
} else {
|
|
670
|
+
let W = !1;
|
|
671
|
+
l[H] === "/" && (W = !0, H++);
|
|
672
|
+
let G = "";
|
|
673
|
+
for (; H < l.length && l[H] !== ">" && l[H] !== " " && l[H] !== " " && l[H] !== "\n" && l[H] !== "\r"; H++) G += l[H];
|
|
674
|
+
if (G = G.trim(), G[G.length - 1] === "/" && (G = G.substring(0, G.length - 1), H--), !validateTagName(G)) {
|
|
675
|
+
let R;
|
|
676
|
+
return R = G.trim().length === 0 ? "Invalid space after '<'." : "Tag '" + G + "' is an invalid name.", getErrorObject("InvalidTag", R, getLineNumberForPosition(l, H));
|
|
677
|
+
}
|
|
678
|
+
let K = readAttributeStr(l, H);
|
|
679
|
+
if (K === !1) return getErrorObject("InvalidAttr", "Attributes for '" + G + "' have open quote.", getLineNumberForPosition(l, H));
|
|
680
|
+
let q = K.value;
|
|
681
|
+
if (H = K.index, q[q.length - 1] === "/") {
|
|
682
|
+
let z = H - q.length;
|
|
683
|
+
q = q.substring(0, q.length - 1);
|
|
684
|
+
let V = validateAttributeString(q, R);
|
|
685
|
+
if (V === !0) B = !0;
|
|
686
|
+
else return getErrorObject(V.err.code, V.err.msg, getLineNumberForPosition(l, z + V.err.line));
|
|
687
|
+
} else if (W) if (K.tagClosed) {
|
|
688
|
+
if (q.trim().length > 0) return getErrorObject("InvalidTag", "Closing tag '" + G + "' can't have attributes or invalid starting.", getLineNumberForPosition(l, U));
|
|
689
|
+
if (z.length === 0) return getErrorObject("InvalidTag", "Closing tag '" + G + "' has not been opened.", getLineNumberForPosition(l, U));
|
|
690
|
+
{
|
|
691
|
+
let R = z.pop();
|
|
692
|
+
if (G !== R.tagName) {
|
|
693
|
+
let z = getLineNumberForPosition(l, R.tagStartPos);
|
|
694
|
+
return getErrorObject("InvalidTag", "Expected closing tag '" + R.tagName + "' (opened in line " + z.line + ", col " + z.col + ") instead of closing tag '" + G + "'.", getLineNumberForPosition(l, U));
|
|
695
|
+
}
|
|
696
|
+
z.length == 0 && (V = !0);
|
|
697
|
+
}
|
|
698
|
+
} else return getErrorObject("InvalidTag", "Closing tag '" + G + "' doesn't have proper closing.", getLineNumberForPosition(l, H));
|
|
699
|
+
else {
|
|
700
|
+
let W = validateAttributeString(q, R);
|
|
701
|
+
if (W !== !0) return getErrorObject(W.err.code, W.err.msg, getLineNumberForPosition(l, H - q.length + W.err.line));
|
|
702
|
+
if (V === !0) return getErrorObject("InvalidXml", "Multiple possible root nodes found.", getLineNumberForPosition(l, H));
|
|
703
|
+
R.unpairedTags.indexOf(G) !== -1 || z.push({
|
|
704
|
+
tagName: G,
|
|
705
|
+
tagStartPos: U
|
|
706
|
+
}), B = !0;
|
|
707
|
+
}
|
|
708
|
+
for (H++; H < l.length; H++) if (l[H] === "<") if (l[H + 1] === "!") {
|
|
709
|
+
H++, H = readCommentAndCDATA(l, H);
|
|
710
|
+
continue;
|
|
711
|
+
} else if (l[H + 1] === "?") {
|
|
712
|
+
if (H = readPI(l, ++H), H.err) return H;
|
|
713
|
+
} else break;
|
|
714
|
+
else if (l[H] === "&") {
|
|
715
|
+
let R = validateAmpersand(l, H);
|
|
716
|
+
if (R == -1) return getErrorObject("InvalidChar", "char '&' is not expected.", getLineNumberForPosition(l, H));
|
|
717
|
+
H = R;
|
|
718
|
+
} else if (V === !0 && !isWhiteSpace(l[H])) return getErrorObject("InvalidXml", "Extra text at the end", getLineNumberForPosition(l, H));
|
|
719
|
+
l[H] === "<" && H--;
|
|
720
|
+
}
|
|
721
|
+
} else {
|
|
722
|
+
if (isWhiteSpace(l[H])) continue;
|
|
723
|
+
return getErrorObject("InvalidChar", "char '" + l[H] + "' is not expected.", getLineNumberForPosition(l, H));
|
|
724
|
+
}
|
|
725
|
+
if (B) {
|
|
726
|
+
if (z.length == 1) return getErrorObject("InvalidTag", "Unclosed tag '" + z[0].tagName + "'.", getLineNumberForPosition(l, z[0].tagStartPos));
|
|
727
|
+
if (z.length > 0) return getErrorObject("InvalidXml", "Invalid '" + JSON.stringify(z.map((l) => l.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", {
|
|
728
|
+
line: 1,
|
|
729
|
+
col: 1
|
|
730
|
+
});
|
|
731
|
+
} else return getErrorObject("InvalidXml", "Start tag expected.", 1);
|
|
732
|
+
return !0;
|
|
733
|
+
}
|
|
734
|
+
function isWhiteSpace(l) {
|
|
735
|
+
return l === " " || l === " " || l === "\n" || l === "\r";
|
|
736
|
+
}
|
|
737
|
+
function readPI(l, R) {
|
|
738
|
+
let z = R;
|
|
739
|
+
for (; R < l.length; R++) if (l[R] == "?" || l[R] == " ") {
|
|
740
|
+
let B = l.substr(z, R - z);
|
|
741
|
+
if (R > 5 && B === "xml") return getErrorObject("InvalidXml", "XML declaration allowed only at the start of the document.", getLineNumberForPosition(l, R));
|
|
742
|
+
if (l[R] == "?" && l[R + 1] == ">") {
|
|
743
|
+
R++;
|
|
744
|
+
break;
|
|
745
|
+
} else continue;
|
|
746
|
+
}
|
|
747
|
+
return R;
|
|
748
|
+
}
|
|
749
|
+
function readCommentAndCDATA(l, R) {
|
|
750
|
+
if (l.length > R + 5 && l[R + 1] === "-" && l[R + 2] === "-") {
|
|
751
|
+
for (R += 3; R < l.length; R++) if (l[R] === "-" && l[R + 1] === "-" && l[R + 2] === ">") {
|
|
752
|
+
R += 2;
|
|
753
|
+
break;
|
|
754
|
+
}
|
|
755
|
+
} else if (l.length > R + 8 && l[R + 1] === "D" && l[R + 2] === "O" && l[R + 3] === "C" && l[R + 4] === "T" && l[R + 5] === "Y" && l[R + 6] === "P" && l[R + 7] === "E") {
|
|
756
|
+
let z = 1;
|
|
757
|
+
for (R += 8; R < l.length; R++) if (l[R] === "<") z++;
|
|
758
|
+
else if (l[R] === ">" && (z--, z === 0)) break;
|
|
759
|
+
} else if (l.length > R + 9 && l[R + 1] === "[" && l[R + 2] === "C" && l[R + 3] === "D" && l[R + 4] === "A" && l[R + 5] === "T" && l[R + 6] === "A" && l[R + 7] === "[") {
|
|
760
|
+
for (R += 8; R < l.length; R++) if (l[R] === "]" && l[R + 1] === "]" && l[R + 2] === ">") {
|
|
761
|
+
R += 2;
|
|
762
|
+
break;
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
return R;
|
|
766
|
+
}
|
|
767
|
+
var doubleQuote = "\"", singleQuote = "'";
|
|
768
|
+
function readAttributeStr(l, R) {
|
|
769
|
+
let z = "", B = "", V = !1;
|
|
770
|
+
for (; R < l.length; R++) {
|
|
771
|
+
if (l[R] === doubleQuote || l[R] === singleQuote) B === "" ? B = l[R] : B !== l[R] || (B = "");
|
|
772
|
+
else if (l[R] === ">" && B === "") {
|
|
773
|
+
V = !0;
|
|
774
|
+
break;
|
|
775
|
+
}
|
|
776
|
+
z += l[R];
|
|
777
|
+
}
|
|
778
|
+
return B === "" ? {
|
|
779
|
+
value: z,
|
|
780
|
+
index: R,
|
|
781
|
+
tagClosed: V
|
|
782
|
+
} : !1;
|
|
783
|
+
}
|
|
784
|
+
var validAttrStrRegxp = RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?", "g");
|
|
785
|
+
function validateAttributeString(l, R) {
|
|
786
|
+
let z = getAllMatches(l, validAttrStrRegxp), B = {};
|
|
787
|
+
for (let l = 0; l < z.length; l++) {
|
|
788
|
+
if (z[l][1].length === 0) return getErrorObject("InvalidAttr", "Attribute '" + z[l][2] + "' has no space in starting.", getPositionFromMatch(z[l]));
|
|
789
|
+
if (z[l][3] !== void 0 && z[l][4] === void 0) return getErrorObject("InvalidAttr", "Attribute '" + z[l][2] + "' is without value.", getPositionFromMatch(z[l]));
|
|
790
|
+
if (z[l][3] === void 0 && !R.allowBooleanAttributes) return getErrorObject("InvalidAttr", "boolean attribute '" + z[l][2] + "' is not allowed.", getPositionFromMatch(z[l]));
|
|
791
|
+
let V = z[l][2];
|
|
792
|
+
if (!validateAttrName(V)) return getErrorObject("InvalidAttr", "Attribute '" + V + "' is an invalid name.", getPositionFromMatch(z[l]));
|
|
793
|
+
if (!B.hasOwnProperty(V)) B[V] = 1;
|
|
794
|
+
else return getErrorObject("InvalidAttr", "Attribute '" + V + "' is repeated.", getPositionFromMatch(z[l]));
|
|
795
|
+
}
|
|
796
|
+
return !0;
|
|
797
|
+
}
|
|
798
|
+
function validateNumberAmpersand(l, R) {
|
|
799
|
+
let z = /\d/;
|
|
800
|
+
for (l[R] === "x" && (R++, z = /[\da-fA-F]/); R < l.length; R++) {
|
|
801
|
+
if (l[R] === ";") return R;
|
|
802
|
+
if (!l[R].match(z)) break;
|
|
803
|
+
}
|
|
804
|
+
return -1;
|
|
805
|
+
}
|
|
806
|
+
function validateAmpersand(l, R) {
|
|
807
|
+
if (R++, l[R] === ";") return -1;
|
|
808
|
+
if (l[R] === "#") return R++, validateNumberAmpersand(l, R);
|
|
809
|
+
let z = 0;
|
|
810
|
+
for (; R < l.length; R++, z++) if (!(l[R].match(/\w/) && z < 20)) {
|
|
811
|
+
if (l[R] === ";") break;
|
|
812
|
+
return -1;
|
|
813
|
+
}
|
|
814
|
+
return R;
|
|
815
|
+
}
|
|
816
|
+
function getErrorObject(l, R, z) {
|
|
817
|
+
return { err: {
|
|
818
|
+
code: l,
|
|
819
|
+
msg: R,
|
|
820
|
+
line: z.line || z,
|
|
821
|
+
col: z.col
|
|
822
|
+
} };
|
|
823
|
+
}
|
|
824
|
+
function validateAttrName(l) {
|
|
825
|
+
return isName(l);
|
|
826
|
+
}
|
|
827
|
+
function validateTagName(l) {
|
|
828
|
+
return isName(l);
|
|
829
|
+
}
|
|
830
|
+
function getLineNumberForPosition(l, R) {
|
|
831
|
+
let z = l.substring(0, R).split(/\r?\n/);
|
|
832
|
+
return {
|
|
833
|
+
line: z.length,
|
|
834
|
+
col: z[z.length - 1].length + 1
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
function getPositionFromMatch(l) {
|
|
838
|
+
return l.startIndex + l[1].length;
|
|
839
|
+
}
|
|
840
|
+
const defaultOptions = {
|
|
841
|
+
preserveOrder: !1,
|
|
842
|
+
attributeNamePrefix: "@_",
|
|
843
|
+
attributesGroupName: !1,
|
|
844
|
+
textNodeName: "#text",
|
|
845
|
+
ignoreAttributes: !0,
|
|
846
|
+
removeNSPrefix: !1,
|
|
847
|
+
allowBooleanAttributes: !1,
|
|
848
|
+
parseTagValue: !0,
|
|
849
|
+
parseAttributeValue: !1,
|
|
850
|
+
trimValues: !0,
|
|
851
|
+
cdataPropName: !1,
|
|
852
|
+
numberParseOptions: {
|
|
853
|
+
hex: !0,
|
|
854
|
+
leadingZeros: !0,
|
|
855
|
+
eNotation: !0
|
|
856
|
+
},
|
|
857
|
+
tagValueProcessor: function(l, R) {
|
|
858
|
+
return R;
|
|
859
|
+
},
|
|
860
|
+
attributeValueProcessor: function(l, R) {
|
|
861
|
+
return R;
|
|
862
|
+
},
|
|
863
|
+
stopNodes: [],
|
|
864
|
+
alwaysCreateTextNode: !1,
|
|
865
|
+
isArray: () => !1,
|
|
866
|
+
commentPropName: !1,
|
|
867
|
+
unpairedTags: [],
|
|
868
|
+
processEntities: !0,
|
|
869
|
+
htmlEntities: !1,
|
|
870
|
+
ignoreDeclaration: !1,
|
|
871
|
+
ignorePiTags: !1,
|
|
872
|
+
transformTagName: !1,
|
|
873
|
+
transformAttributeName: !1,
|
|
874
|
+
updateTag: function(l, R, z) {
|
|
875
|
+
return l;
|
|
876
|
+
},
|
|
877
|
+
captureMetaData: !1
|
|
878
|
+
};
|
|
879
|
+
function normalizeProcessEntities(l) {
|
|
880
|
+
return typeof l == "boolean" ? {
|
|
881
|
+
enabled: l,
|
|
882
|
+
maxEntitySize: 1e4,
|
|
883
|
+
maxExpansionDepth: 10,
|
|
884
|
+
maxTotalExpansions: 1e3,
|
|
885
|
+
maxExpandedLength: 1e5,
|
|
886
|
+
allowedTags: null,
|
|
887
|
+
tagFilter: null
|
|
888
|
+
} : typeof l == "object" && l ? {
|
|
889
|
+
enabled: l.enabled !== !1,
|
|
890
|
+
maxEntitySize: l.maxEntitySize ?? 1e4,
|
|
891
|
+
maxExpansionDepth: l.maxExpansionDepth ?? 10,
|
|
892
|
+
maxTotalExpansions: l.maxTotalExpansions ?? 1e3,
|
|
893
|
+
maxExpandedLength: l.maxExpandedLength ?? 1e5,
|
|
894
|
+
allowedTags: l.allowedTags ?? null,
|
|
895
|
+
tagFilter: l.tagFilter ?? null
|
|
896
|
+
} : normalizeProcessEntities(!0);
|
|
897
|
+
}
|
|
898
|
+
const buildOptions = function(l) {
|
|
899
|
+
let R = Object.assign({}, defaultOptions, l);
|
|
900
|
+
return R.processEntities = normalizeProcessEntities(R.processEntities), R;
|
|
901
|
+
};
|
|
902
|
+
var METADATA_SYMBOL$1 = typeof Symbol == "function" ? Symbol("XML Node Metadata") : "@@xmlMetadata", XmlNode = class {
|
|
903
|
+
constructor(l) {
|
|
904
|
+
this.tagname = l, this.child = [], this[":@"] = {};
|
|
905
|
+
}
|
|
906
|
+
add(l, R) {
|
|
907
|
+
l === "__proto__" && (l = "#__proto__"), this.child.push({ [l]: R });
|
|
908
|
+
}
|
|
909
|
+
addChild(l, R) {
|
|
910
|
+
l.tagname === "__proto__" && (l.tagname = "#__proto__"), l[":@"] && Object.keys(l[":@"]).length > 0 ? this.child.push({
|
|
911
|
+
[l.tagname]: l.child,
|
|
912
|
+
":@": l[":@"]
|
|
913
|
+
}) : this.child.push({ [l.tagname]: l.child }), R !== void 0 && (this.child[this.child.length - 1][METADATA_SYMBOL$1] = { startIndex: R });
|
|
914
|
+
}
|
|
915
|
+
static getMetaDataSymbol() {
|
|
916
|
+
return METADATA_SYMBOL$1;
|
|
917
|
+
}
|
|
918
|
+
}, DocTypeReader = class {
|
|
919
|
+
constructor(l) {
|
|
920
|
+
this.suppressValidationErr = !l, this.options = l;
|
|
921
|
+
}
|
|
922
|
+
readDocType(l, R) {
|
|
923
|
+
let z = {};
|
|
924
|
+
if (l[R + 3] === "O" && l[R + 4] === "C" && l[R + 5] === "T" && l[R + 6] === "Y" && l[R + 7] === "P" && l[R + 8] === "E") {
|
|
925
|
+
R += 9;
|
|
926
|
+
let B = 1, V = !1, H = !1, U = "";
|
|
927
|
+
for (; R < l.length; R++) if (l[R] === "<" && !H) {
|
|
928
|
+
if (V && hasSeq(l, "!ENTITY", R)) {
|
|
929
|
+
R += 7;
|
|
930
|
+
let B, V;
|
|
931
|
+
if ([B, V, R] = this.readEntityExp(l, R + 1, this.suppressValidationErr), V.indexOf("&") === -1) {
|
|
932
|
+
let l = B.replace(/[.\-+*:]/g, "\\.");
|
|
933
|
+
z[B] = {
|
|
934
|
+
regx: RegExp(`&${l};`, "g"),
|
|
935
|
+
val: V
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
} else if (V && hasSeq(l, "!ELEMENT", R)) {
|
|
939
|
+
R += 8;
|
|
940
|
+
let { index: z } = this.readElementExp(l, R + 1);
|
|
941
|
+
R = z;
|
|
942
|
+
} else if (V && hasSeq(l, "!ATTLIST", R)) R += 8;
|
|
943
|
+
else if (V && hasSeq(l, "!NOTATION", R)) {
|
|
944
|
+
R += 9;
|
|
945
|
+
let { index: z } = this.readNotationExp(l, R + 1, this.suppressValidationErr);
|
|
946
|
+
R = z;
|
|
947
|
+
} else if (hasSeq(l, "!--", R)) H = !0;
|
|
948
|
+
else throw Error("Invalid DOCTYPE");
|
|
949
|
+
B++, U = "";
|
|
950
|
+
} else if (l[R] === ">") {
|
|
951
|
+
if (H ? l[R - 1] === "-" && l[R - 2] === "-" && (H = !1, B--) : B--, B === 0) break;
|
|
952
|
+
} else l[R] === "[" ? V = !0 : U += l[R];
|
|
953
|
+
if (B !== 0) throw Error("Unclosed DOCTYPE");
|
|
954
|
+
} else throw Error("Invalid Tag instead of DOCTYPE");
|
|
955
|
+
return {
|
|
956
|
+
entities: z,
|
|
957
|
+
i: R
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
readEntityExp(l, R) {
|
|
961
|
+
R = skipWhitespace(l, R);
|
|
962
|
+
let z = "";
|
|
963
|
+
for (; R < l.length && !/\s/.test(l[R]) && l[R] !== "\"" && l[R] !== "'";) z += l[R], R++;
|
|
964
|
+
if (validateEntityName(z), R = skipWhitespace(l, R), !this.suppressValidationErr) {
|
|
965
|
+
if (l.substring(R, R + 6).toUpperCase() === "SYSTEM") throw Error("External entities are not supported");
|
|
966
|
+
if (l[R] === "%") throw Error("Parameter entities are not supported");
|
|
967
|
+
}
|
|
968
|
+
let B = "";
|
|
969
|
+
if ([R, B] = this.readIdentifierVal(l, R, "entity"), this.options.enabled !== !1 && this.options.maxEntitySize && B.length > this.options.maxEntitySize) throw Error(`Entity "${z}" size (${B.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);
|
|
970
|
+
return R--, [
|
|
971
|
+
z,
|
|
972
|
+
B,
|
|
973
|
+
R
|
|
974
|
+
];
|
|
975
|
+
}
|
|
976
|
+
readNotationExp(l, R) {
|
|
977
|
+
R = skipWhitespace(l, R);
|
|
978
|
+
let z = "";
|
|
979
|
+
for (; R < l.length && !/\s/.test(l[R]);) z += l[R], R++;
|
|
980
|
+
!this.suppressValidationErr && validateEntityName(z), R = skipWhitespace(l, R);
|
|
981
|
+
let B = l.substring(R, R + 6).toUpperCase();
|
|
982
|
+
if (!this.suppressValidationErr && B !== "SYSTEM" && B !== "PUBLIC") throw Error(`Expected SYSTEM or PUBLIC, found "${B}"`);
|
|
983
|
+
R += B.length, R = skipWhitespace(l, R);
|
|
984
|
+
let V = null, H = null;
|
|
985
|
+
if (B === "PUBLIC") [R, V] = this.readIdentifierVal(l, R, "publicIdentifier"), R = skipWhitespace(l, R), (l[R] === "\"" || l[R] === "'") && ([R, H] = this.readIdentifierVal(l, R, "systemIdentifier"));
|
|
986
|
+
else if (B === "SYSTEM" && ([R, H] = this.readIdentifierVal(l, R, "systemIdentifier"), !this.suppressValidationErr && !H)) throw Error("Missing mandatory system identifier for SYSTEM notation");
|
|
987
|
+
return {
|
|
988
|
+
notationName: z,
|
|
989
|
+
publicIdentifier: V,
|
|
990
|
+
systemIdentifier: H,
|
|
991
|
+
index: --R
|
|
992
|
+
};
|
|
993
|
+
}
|
|
994
|
+
readIdentifierVal(l, R, z) {
|
|
995
|
+
let B = "", V = l[R];
|
|
996
|
+
if (V !== "\"" && V !== "'") throw Error(`Expected quoted string, found "${V}"`);
|
|
997
|
+
for (R++; R < l.length && l[R] !== V;) B += l[R], R++;
|
|
998
|
+
if (l[R] !== V) throw Error(`Unterminated ${z} value`);
|
|
999
|
+
return R++, [R, B];
|
|
1000
|
+
}
|
|
1001
|
+
readElementExp(l, R) {
|
|
1002
|
+
R = skipWhitespace(l, R);
|
|
1003
|
+
let z = "";
|
|
1004
|
+
for (; R < l.length && !/\s/.test(l[R]);) z += l[R], R++;
|
|
1005
|
+
if (!this.suppressValidationErr && !isName(z)) throw Error(`Invalid element name: "${z}"`);
|
|
1006
|
+
R = skipWhitespace(l, R);
|
|
1007
|
+
let B = "";
|
|
1008
|
+
if (l[R] === "E" && hasSeq(l, "MPTY", R)) R += 4;
|
|
1009
|
+
else if (l[R] === "A" && hasSeq(l, "NY", R)) R += 2;
|
|
1010
|
+
else if (l[R] === "(") {
|
|
1011
|
+
for (R++; R < l.length && l[R] !== ")";) B += l[R], R++;
|
|
1012
|
+
if (l[R] !== ")") throw Error("Unterminated content model");
|
|
1013
|
+
} else if (!this.suppressValidationErr) throw Error(`Invalid Element Expression, found "${l[R]}"`);
|
|
1014
|
+
return {
|
|
1015
|
+
elementName: z,
|
|
1016
|
+
contentModel: B.trim(),
|
|
1017
|
+
index: R
|
|
1018
|
+
};
|
|
1019
|
+
}
|
|
1020
|
+
readAttlistExp(l, R) {
|
|
1021
|
+
R = skipWhitespace(l, R);
|
|
1022
|
+
let z = "";
|
|
1023
|
+
for (; R < l.length && !/\s/.test(l[R]);) z += l[R], R++;
|
|
1024
|
+
validateEntityName(z), R = skipWhitespace(l, R);
|
|
1025
|
+
let B = "";
|
|
1026
|
+
for (; R < l.length && !/\s/.test(l[R]);) B += l[R], R++;
|
|
1027
|
+
if (!validateEntityName(B)) throw Error(`Invalid attribute name: "${B}"`);
|
|
1028
|
+
R = skipWhitespace(l, R);
|
|
1029
|
+
let V = "";
|
|
1030
|
+
if (l.substring(R, R + 8).toUpperCase() === "NOTATION") {
|
|
1031
|
+
if (V = "NOTATION", R += 8, R = skipWhitespace(l, R), l[R] !== "(") throw Error(`Expected '(', found "${l[R]}"`);
|
|
1032
|
+
R++;
|
|
1033
|
+
let z = [];
|
|
1034
|
+
for (; R < l.length && l[R] !== ")";) {
|
|
1035
|
+
let B = "";
|
|
1036
|
+
for (; R < l.length && l[R] !== "|" && l[R] !== ")";) B += l[R], R++;
|
|
1037
|
+
if (B = B.trim(), !validateEntityName(B)) throw Error(`Invalid notation name: "${B}"`);
|
|
1038
|
+
z.push(B), l[R] === "|" && (R++, R = skipWhitespace(l, R));
|
|
1039
|
+
}
|
|
1040
|
+
if (l[R] !== ")") throw Error("Unterminated list of notations");
|
|
1041
|
+
R++, V += " (" + z.join("|") + ")";
|
|
1042
|
+
} else {
|
|
1043
|
+
for (; R < l.length && !/\s/.test(l[R]);) V += l[R], R++;
|
|
1044
|
+
if (!this.suppressValidationErr && ![
|
|
1045
|
+
"CDATA",
|
|
1046
|
+
"ID",
|
|
1047
|
+
"IDREF",
|
|
1048
|
+
"IDREFS",
|
|
1049
|
+
"ENTITY",
|
|
1050
|
+
"ENTITIES",
|
|
1051
|
+
"NMTOKEN",
|
|
1052
|
+
"NMTOKENS"
|
|
1053
|
+
].includes(V.toUpperCase())) throw Error(`Invalid attribute type: "${V}"`);
|
|
1054
|
+
}
|
|
1055
|
+
R = skipWhitespace(l, R);
|
|
1056
|
+
let H = "";
|
|
1057
|
+
return l.substring(R, R + 8).toUpperCase() === "#REQUIRED" ? (H = "#REQUIRED", R += 8) : l.substring(R, R + 7).toUpperCase() === "#IMPLIED" ? (H = "#IMPLIED", R += 7) : [R, H] = this.readIdentifierVal(l, R, "ATTLIST"), {
|
|
1058
|
+
elementName: z,
|
|
1059
|
+
attributeName: B,
|
|
1060
|
+
attributeType: V,
|
|
1061
|
+
defaultValue: H,
|
|
1062
|
+
index: R
|
|
1063
|
+
};
|
|
1064
|
+
}
|
|
1065
|
+
}, skipWhitespace = (l, R) => {
|
|
1066
|
+
for (; R < l.length && /\s/.test(l[R]);) R++;
|
|
1067
|
+
return R;
|
|
1068
|
+
};
|
|
1069
|
+
function hasSeq(l, R, z) {
|
|
1070
|
+
for (let B = 0; B < R.length; B++) if (R[B] !== l[z + B + 1]) return !1;
|
|
1071
|
+
return !0;
|
|
1072
|
+
}
|
|
1073
|
+
function validateEntityName(l) {
|
|
1074
|
+
if (isName(l)) return l;
|
|
1075
|
+
throw Error(`Invalid entity name ${l}`);
|
|
1076
|
+
}
|
|
1077
|
+
var hexRegex = /^[-+]?0x[a-fA-F0-9]+$/, numRegex = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, consider = {
|
|
1078
|
+
hex: !0,
|
|
1079
|
+
leadingZeros: !0,
|
|
1080
|
+
decimalPoint: ".",
|
|
1081
|
+
eNotation: !0
|
|
1082
|
+
};
|
|
1083
|
+
function toNumber(l, R = {}) {
|
|
1084
|
+
if (R = Object.assign({}, consider, R), !l || typeof l != "string") return l;
|
|
1085
|
+
let z = l.trim();
|
|
1086
|
+
if (R.skipLike !== void 0 && R.skipLike.test(z)) return l;
|
|
1087
|
+
if (l === "0") return 0;
|
|
1088
|
+
if (R.hex && hexRegex.test(z)) return parse_int(z, 16);
|
|
1089
|
+
if (z.includes("e") || z.includes("E")) return resolveEnotation(l, z, R);
|
|
1090
|
+
{
|
|
1091
|
+
let B = numRegex.exec(z);
|
|
1092
|
+
if (B) {
|
|
1093
|
+
let V = B[1] || "", H = B[2], U = trimZeros(B[3]), W = V ? l[H.length + 1] === "." : l[H.length] === ".";
|
|
1094
|
+
if (!R.leadingZeros && (H.length > 1 || H.length === 1 && !W)) return l;
|
|
1095
|
+
{
|
|
1096
|
+
let B = Number(z), W = String(B);
|
|
1097
|
+
if (B === 0) return B;
|
|
1098
|
+
if (W.search(/[eE]/) !== -1) return R.eNotation ? B : l;
|
|
1099
|
+
if (z.indexOf(".") !== -1) return W === "0" || W === U || W === `${V}${U}` ? B : l;
|
|
1100
|
+
let G = H ? U : z;
|
|
1101
|
+
return H ? G === W || V + G === W ? B : l : G === W || G === V + W ? B : l;
|
|
1102
|
+
}
|
|
1103
|
+
} else return l;
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
var eNotationRegx = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;
|
|
1107
|
+
function resolveEnotation(l, R, z) {
|
|
1108
|
+
if (!z.eNotation) return l;
|
|
1109
|
+
let B = R.match(eNotationRegx);
|
|
1110
|
+
if (B) {
|
|
1111
|
+
let V = B[1] || "", H = B[3].indexOf("e") === -1 ? "E" : "e", U = B[2], W = V ? l[U.length + 1] === H : l[U.length] === H;
|
|
1112
|
+
return U.length > 1 && W ? l : U.length === 1 && (B[3].startsWith(`.${H}`) || B[3][0] === H) ? Number(R) : z.leadingZeros && !W ? (R = (B[1] || "") + B[3], Number(R)) : l;
|
|
1113
|
+
} else return l;
|
|
1114
|
+
}
|
|
1115
|
+
function trimZeros(l) {
|
|
1116
|
+
return l && l.indexOf(".") !== -1 ? (l = l.replace(/0+$/, ""), l === "." ? l = "0" : l[0] === "." ? l = "0" + l : l[l.length - 1] === "." && (l = l.substring(0, l.length - 1)), l) : l;
|
|
1117
|
+
}
|
|
1118
|
+
function parse_int(l, R) {
|
|
1119
|
+
if (parseInt) return parseInt(l, R);
|
|
1120
|
+
if (Number.parseInt) return Number.parseInt(l, R);
|
|
1121
|
+
if (window && window.parseInt) return window.parseInt(l, R);
|
|
1122
|
+
throw Error("parseInt, Number.parseInt, window.parseInt are not supported");
|
|
1123
|
+
}
|
|
1124
|
+
function getIgnoreAttributesFn(l) {
|
|
1125
|
+
return typeof l == "function" ? l : Array.isArray(l) ? (R) => {
|
|
1126
|
+
for (let z of l) if (typeof z == "string" && R === z || z instanceof RegExp && z.test(R)) return !0;
|
|
1127
|
+
} : () => !1;
|
|
1128
|
+
}
|
|
1129
|
+
var OrderedObjParser = class {
|
|
1130
|
+
constructor(l) {
|
|
1131
|
+
if (this.options = l, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = {
|
|
1132
|
+
apos: {
|
|
1133
|
+
regex: /&(apos|#39|#x27);/g,
|
|
1134
|
+
val: "'"
|
|
1135
|
+
},
|
|
1136
|
+
gt: {
|
|
1137
|
+
regex: /&(gt|#62|#x3E);/g,
|
|
1138
|
+
val: ">"
|
|
1139
|
+
},
|
|
1140
|
+
lt: {
|
|
1141
|
+
regex: /&(lt|#60|#x3C);/g,
|
|
1142
|
+
val: "<"
|
|
1143
|
+
},
|
|
1144
|
+
quot: {
|
|
1145
|
+
regex: /&(quot|#34|#x22);/g,
|
|
1146
|
+
val: "\""
|
|
1147
|
+
}
|
|
1148
|
+
}, this.ampEntity = {
|
|
1149
|
+
regex: /&(amp|#38|#x26);/g,
|
|
1150
|
+
val: "&"
|
|
1151
|
+
}, this.htmlEntities = {
|
|
1152
|
+
space: {
|
|
1153
|
+
regex: /&(nbsp|#160);/g,
|
|
1154
|
+
val: " "
|
|
1155
|
+
},
|
|
1156
|
+
cent: {
|
|
1157
|
+
regex: /&(cent|#162);/g,
|
|
1158
|
+
val: "¢"
|
|
1159
|
+
},
|
|
1160
|
+
pound: {
|
|
1161
|
+
regex: /&(pound|#163);/g,
|
|
1162
|
+
val: "£"
|
|
1163
|
+
},
|
|
1164
|
+
yen: {
|
|
1165
|
+
regex: /&(yen|#165);/g,
|
|
1166
|
+
val: "¥"
|
|
1167
|
+
},
|
|
1168
|
+
euro: {
|
|
1169
|
+
regex: /&(euro|#8364);/g,
|
|
1170
|
+
val: "€"
|
|
1171
|
+
},
|
|
1172
|
+
copyright: {
|
|
1173
|
+
regex: /&(copy|#169);/g,
|
|
1174
|
+
val: "©"
|
|
1175
|
+
},
|
|
1176
|
+
reg: {
|
|
1177
|
+
regex: /&(reg|#174);/g,
|
|
1178
|
+
val: "®"
|
|
1179
|
+
},
|
|
1180
|
+
inr: {
|
|
1181
|
+
regex: /&(inr|#8377);/g,
|
|
1182
|
+
val: "₹"
|
|
1183
|
+
},
|
|
1184
|
+
num_dec: {
|
|
1185
|
+
regex: /&#([0-9]{1,7});/g,
|
|
1186
|
+
val: (l, R) => fromCodePoint(R, 10, "&#")
|
|
1187
|
+
},
|
|
1188
|
+
num_hex: {
|
|
1189
|
+
regex: /&#x([0-9a-fA-F]{1,6});/g,
|
|
1190
|
+
val: (l, R) => fromCodePoint(R, 16, "&#x")
|
|
1191
|
+
}
|
|
1192
|
+
}, this.addExternalEntities = addExternalEntities, this.parseXml = parseXml, this.parseTextData = parseTextData, this.resolveNameSpace = resolveNameSpace, this.buildAttributesMap = buildAttributesMap, this.isItStopNode = isItStopNode, this.replaceEntitiesValue = replaceEntitiesValue, this.readStopNodeData = readStopNodeData, this.saveTextToParentTag = saveTextToParentTag, this.addChild = addChild, this.ignoreAttributesFn = getIgnoreAttributesFn(this.options.ignoreAttributes), this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.options.stopNodes && this.options.stopNodes.length > 0) {
|
|
1193
|
+
this.stopNodesExact = /* @__PURE__ */ new Set(), this.stopNodesWildcard = /* @__PURE__ */ new Set();
|
|
1194
|
+
for (let l = 0; l < this.options.stopNodes.length; l++) {
|
|
1195
|
+
let R = this.options.stopNodes[l];
|
|
1196
|
+
typeof R == "string" && (R.startsWith("*.") ? this.stopNodesWildcard.add(R.substring(2)) : this.stopNodesExact.add(R));
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
};
|
|
1201
|
+
function addExternalEntities(l) {
|
|
1202
|
+
let R = Object.keys(l);
|
|
1203
|
+
for (let z = 0; z < R.length; z++) {
|
|
1204
|
+
let B = R[z], V = B.replace(/[.\-+*:]/g, "\\.");
|
|
1205
|
+
this.lastEntities[B] = {
|
|
1206
|
+
regex: RegExp("&" + V + ";", "g"),
|
|
1207
|
+
val: l[B]
|
|
1208
|
+
};
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
function parseTextData(l, R, z, B, V, H, U) {
|
|
1212
|
+
if (l !== void 0 && (this.options.trimValues && !B && (l = l.trim()), l.length > 0)) {
|
|
1213
|
+
U || (l = this.replaceEntitiesValue(l, R, z));
|
|
1214
|
+
let B = this.options.tagValueProcessor(R, l, z, V, H);
|
|
1215
|
+
return B == null ? l : typeof B != typeof l || B !== l ? B : this.options.trimValues || l.trim() === l ? parseValue(l, this.options.parseTagValue, this.options.numberParseOptions) : l;
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
function resolveNameSpace(l) {
|
|
1219
|
+
if (this.options.removeNSPrefix) {
|
|
1220
|
+
let R = l.split(":"), z = l.charAt(0) === "/" ? "/" : "";
|
|
1221
|
+
if (R[0] === "xmlns") return "";
|
|
1222
|
+
R.length === 2 && (l = z + R[1]);
|
|
1223
|
+
}
|
|
1224
|
+
return l;
|
|
1225
|
+
}
|
|
1226
|
+
var attrsRegx = RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?", "gm");
|
|
1227
|
+
function buildAttributesMap(l, R, z) {
|
|
1228
|
+
if (this.options.ignoreAttributes !== !0 && typeof l == "string") {
|
|
1229
|
+
let B = getAllMatches(l, attrsRegx), V = B.length, H = {};
|
|
1230
|
+
for (let l = 0; l < V; l++) {
|
|
1231
|
+
let V = this.resolveNameSpace(B[l][1]);
|
|
1232
|
+
if (this.ignoreAttributesFn(V, R)) continue;
|
|
1233
|
+
let U = B[l][4], W = this.options.attributeNamePrefix + V;
|
|
1234
|
+
if (V.length) if (this.options.transformAttributeName && (W = this.options.transformAttributeName(W)), W === "__proto__" && (W = "#__proto__"), U !== void 0) {
|
|
1235
|
+
this.options.trimValues && (U = U.trim()), U = this.replaceEntitiesValue(U, z, R);
|
|
1236
|
+
let l = this.options.attributeValueProcessor(V, U, R);
|
|
1237
|
+
l == null ? H[W] = U : typeof l != typeof U || l !== U ? H[W] = l : H[W] = parseValue(U, this.options.parseAttributeValue, this.options.numberParseOptions);
|
|
1238
|
+
} else this.options.allowBooleanAttributes && (H[W] = !0);
|
|
1239
|
+
}
|
|
1240
|
+
if (!Object.keys(H).length) return;
|
|
1241
|
+
if (this.options.attributesGroupName) {
|
|
1242
|
+
let l = {};
|
|
1243
|
+
return l[this.options.attributesGroupName] = H, l;
|
|
1244
|
+
}
|
|
1245
|
+
return H;
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
var parseXml = function(l) {
|
|
1249
|
+
l = l.replace(/\r\n?/g, "\n");
|
|
1250
|
+
let R = new XmlNode("!xml"), z = R, B = "", V = "";
|
|
1251
|
+
this.entityExpansionCount = 0, this.currentExpandedLength = 0;
|
|
1252
|
+
let H = new DocTypeReader(this.options.processEntities);
|
|
1253
|
+
for (let U = 0; U < l.length; U++) if (l[U] === "<") if (l[U + 1] === "/") {
|
|
1254
|
+
let R = findClosingIndex(l, ">", U, "Closing Tag is not closed."), H = l.substring(U + 2, R).trim();
|
|
1255
|
+
if (this.options.removeNSPrefix) {
|
|
1256
|
+
let l = H.indexOf(":");
|
|
1257
|
+
l !== -1 && (H = H.substr(l + 1));
|
|
1258
|
+
}
|
|
1259
|
+
this.options.transformTagName && (H = this.options.transformTagName(H)), z && (B = this.saveTextToParentTag(B, z, V));
|
|
1260
|
+
let W = V.substring(V.lastIndexOf(".") + 1);
|
|
1261
|
+
if (H && this.options.unpairedTags.indexOf(H) !== -1) throw Error(`Unpaired tag can not be used as closing tag: </${H}>`);
|
|
1262
|
+
let G = 0;
|
|
1263
|
+
W && this.options.unpairedTags.indexOf(W) !== -1 ? (G = V.lastIndexOf(".", V.lastIndexOf(".") - 1), this.tagsNodeStack.pop()) : G = V.lastIndexOf("."), V = V.substring(0, G), z = this.tagsNodeStack.pop(), B = "", U = R;
|
|
1264
|
+
} else if (l[U + 1] === "?") {
|
|
1265
|
+
let R = readTagExp(l, U, !1, "?>");
|
|
1266
|
+
if (!R) throw Error("Pi Tag is not closed.");
|
|
1267
|
+
if (B = this.saveTextToParentTag(B, z, V), !(this.options.ignoreDeclaration && R.tagName === "?xml" || this.options.ignorePiTags)) {
|
|
1268
|
+
let l = new XmlNode(R.tagName);
|
|
1269
|
+
l.add(this.options.textNodeName, ""), R.tagName !== R.tagExp && R.attrExpPresent && (l[":@"] = this.buildAttributesMap(R.tagExp, V, R.tagName)), this.addChild(z, l, V, U);
|
|
1270
|
+
}
|
|
1271
|
+
U = R.closeIndex + 1;
|
|
1272
|
+
} else if (l.substr(U + 1, 3) === "!--") {
|
|
1273
|
+
let R = findClosingIndex(l, "-->", U + 4, "Comment is not closed.");
|
|
1274
|
+
if (this.options.commentPropName) {
|
|
1275
|
+
let H = l.substring(U + 4, R - 2);
|
|
1276
|
+
B = this.saveTextToParentTag(B, z, V), z.add(this.options.commentPropName, [{ [this.options.textNodeName]: H }]);
|
|
1277
|
+
}
|
|
1278
|
+
U = R;
|
|
1279
|
+
} else if (l.substr(U + 1, 2) === "!D") {
|
|
1280
|
+
let R = H.readDocType(l, U);
|
|
1281
|
+
this.docTypeEntities = R.entities, U = R.i;
|
|
1282
|
+
} else if (l.substr(U + 1, 2) === "![") {
|
|
1283
|
+
let R = findClosingIndex(l, "]]>", U, "CDATA is not closed.") - 2, H = l.substring(U + 9, R);
|
|
1284
|
+
B = this.saveTextToParentTag(B, z, V);
|
|
1285
|
+
let W = this.parseTextData(H, z.tagname, V, !0, !1, !0, !0);
|
|
1286
|
+
W ??= "", this.options.cdataPropName ? z.add(this.options.cdataPropName, [{ [this.options.textNodeName]: H }]) : z.add(this.options.textNodeName, W), U = R + 2;
|
|
1287
|
+
} else {
|
|
1288
|
+
let H = readTagExp(l, U, this.options.removeNSPrefix), W = H.tagName, G = H.rawTagName, K = H.tagExp, q = H.attrExpPresent, J = H.closeIndex;
|
|
1289
|
+
if (this.options.transformTagName) {
|
|
1290
|
+
let l = this.options.transformTagName(W);
|
|
1291
|
+
K === W && (K = l), W = l;
|
|
1292
|
+
}
|
|
1293
|
+
z && B && z.tagname !== "!xml" && (B = this.saveTextToParentTag(B, z, V, !1));
|
|
1294
|
+
let Y = z;
|
|
1295
|
+
Y && this.options.unpairedTags.indexOf(Y.tagname) !== -1 && (z = this.tagsNodeStack.pop(), V = V.substring(0, V.lastIndexOf("."))), W !== R.tagname && (V += V ? "." + W : W);
|
|
1296
|
+
let X = U;
|
|
1297
|
+
if (this.isItStopNode(this.stopNodesExact, this.stopNodesWildcard, V, W)) {
|
|
1298
|
+
let R = "";
|
|
1299
|
+
if (K.length > 0 && K.lastIndexOf("/") === K.length - 1) W[W.length - 1] === "/" ? (W = W.substr(0, W.length - 1), V = V.substr(0, V.length - 1), K = W) : K = K.substr(0, K.length - 1), U = H.closeIndex;
|
|
1300
|
+
else if (this.options.unpairedTags.indexOf(W) !== -1) U = H.closeIndex;
|
|
1301
|
+
else {
|
|
1302
|
+
let z = this.readStopNodeData(l, G, J + 1);
|
|
1303
|
+
if (!z) throw Error(`Unexpected end of ${G}`);
|
|
1304
|
+
U = z.i, R = z.tagContent;
|
|
1305
|
+
}
|
|
1306
|
+
let B = new XmlNode(W);
|
|
1307
|
+
W !== K && q && (B[":@"] = this.buildAttributesMap(K, V, W)), R &&= this.parseTextData(R, W, V, !0, q, !0, !0), V = V.substr(0, V.lastIndexOf(".")), B.add(this.options.textNodeName, R), this.addChild(z, B, V, X);
|
|
1308
|
+
} else {
|
|
1309
|
+
if (K.length > 0 && K.lastIndexOf("/") === K.length - 1) {
|
|
1310
|
+
if (W[W.length - 1] === "/" ? (W = W.substr(0, W.length - 1), V = V.substr(0, V.length - 1), K = W) : K = K.substr(0, K.length - 1), this.options.transformTagName) {
|
|
1311
|
+
let l = this.options.transformTagName(W);
|
|
1312
|
+
K === W && (K = l), W = l;
|
|
1313
|
+
}
|
|
1314
|
+
let l = new XmlNode(W);
|
|
1315
|
+
W !== K && q && (l[":@"] = this.buildAttributesMap(K, V, W)), this.addChild(z, l, V, X), V = V.substr(0, V.lastIndexOf("."));
|
|
1316
|
+
} else {
|
|
1317
|
+
let l = new XmlNode(W);
|
|
1318
|
+
this.tagsNodeStack.push(z), W !== K && q && (l[":@"] = this.buildAttributesMap(K, V, W)), this.addChild(z, l, V, X), z = l;
|
|
1319
|
+
}
|
|
1320
|
+
B = "", U = J;
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
else B += l[U];
|
|
1324
|
+
return R.child;
|
|
1325
|
+
};
|
|
1326
|
+
function addChild(l, R, z, B) {
|
|
1327
|
+
this.options.captureMetaData || (B = void 0);
|
|
1328
|
+
let V = this.options.updateTag(R.tagname, z, R[":@"]);
|
|
1329
|
+
V === !1 || (typeof V == "string" && (R.tagname = V), l.addChild(R, B));
|
|
1330
|
+
}
|
|
1331
|
+
var replaceEntitiesValue = function(l, R, z) {
|
|
1332
|
+
if (l.indexOf("&") === -1) return l;
|
|
1333
|
+
let B = this.options.processEntities;
|
|
1334
|
+
if (!B.enabled || B.allowedTags && !B.allowedTags.includes(R) || B.tagFilter && !B.tagFilter(R, z)) return l;
|
|
1335
|
+
for (let R in this.docTypeEntities) {
|
|
1336
|
+
let z = this.docTypeEntities[R], V = l.match(z.regx);
|
|
1337
|
+
if (V) {
|
|
1338
|
+
if (this.entityExpansionCount += V.length, B.maxTotalExpansions && this.entityExpansionCount > B.maxTotalExpansions) throw Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${B.maxTotalExpansions}`);
|
|
1339
|
+
let R = l.length;
|
|
1340
|
+
if (l = l.replace(z.regx, z.val), B.maxExpandedLength && (this.currentExpandedLength += l.length - R, this.currentExpandedLength > B.maxExpandedLength)) throw Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${B.maxExpandedLength}`);
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
if (l.indexOf("&") === -1) return l;
|
|
1344
|
+
for (let R in this.lastEntities) {
|
|
1345
|
+
let z = this.lastEntities[R];
|
|
1346
|
+
l = l.replace(z.regex, z.val);
|
|
1347
|
+
}
|
|
1348
|
+
if (l.indexOf("&") === -1) return l;
|
|
1349
|
+
if (this.options.htmlEntities) for (let R in this.htmlEntities) {
|
|
1350
|
+
let z = this.htmlEntities[R];
|
|
1351
|
+
l = l.replace(z.regex, z.val);
|
|
1352
|
+
}
|
|
1353
|
+
return l = l.replace(this.ampEntity.regex, this.ampEntity.val), l;
|
|
1354
|
+
};
|
|
1355
|
+
function saveTextToParentTag(l, R, z, B) {
|
|
1356
|
+
return l &&= (B === void 0 && (B = R.child.length === 0), l = this.parseTextData(l, R.tagname, z, !1, R[":@"] ? Object.keys(R[":@"]).length !== 0 : !1, B), l !== void 0 && l !== "" && R.add(this.options.textNodeName, l), ""), l;
|
|
1357
|
+
}
|
|
1358
|
+
function isItStopNode(l, R, z, B) {
|
|
1359
|
+
return !!(R && R.has(B) || l && l.has(z));
|
|
1360
|
+
}
|
|
1361
|
+
function tagExpWithClosingIndex(l, R, z = ">") {
|
|
1362
|
+
let B, V = "";
|
|
1363
|
+
for (let H = R; H < l.length; H++) {
|
|
1364
|
+
let R = l[H];
|
|
1365
|
+
if (B) R === B && (B = "");
|
|
1366
|
+
else if (R === "\"" || R === "'") B = R;
|
|
1367
|
+
else if (R === z[0]) if (z[1]) {
|
|
1368
|
+
if (l[H + 1] === z[1]) return {
|
|
1369
|
+
data: V,
|
|
1370
|
+
index: H
|
|
1371
|
+
};
|
|
1372
|
+
} else return {
|
|
1373
|
+
data: V,
|
|
1374
|
+
index: H
|
|
1375
|
+
};
|
|
1376
|
+
else R === " " && (R = " ");
|
|
1377
|
+
V += R;
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
function findClosingIndex(l, R, z, B) {
|
|
1381
|
+
let V = l.indexOf(R, z);
|
|
1382
|
+
if (V === -1) throw Error(B);
|
|
1383
|
+
return V + R.length - 1;
|
|
1384
|
+
}
|
|
1385
|
+
function readTagExp(l, R, z, B = ">") {
|
|
1386
|
+
let V = tagExpWithClosingIndex(l, R + 1, B);
|
|
1387
|
+
if (!V) return;
|
|
1388
|
+
let H = V.data, U = V.index, W = H.search(/\s/), G = H, K = !0;
|
|
1389
|
+
W !== -1 && (G = H.substring(0, W), H = H.substring(W + 1).trimStart());
|
|
1390
|
+
let q = G;
|
|
1391
|
+
if (z) {
|
|
1392
|
+
let l = G.indexOf(":");
|
|
1393
|
+
l !== -1 && (G = G.substr(l + 1), K = G !== V.data.substr(l + 1));
|
|
1394
|
+
}
|
|
1395
|
+
return {
|
|
1396
|
+
tagName: G,
|
|
1397
|
+
tagExp: H,
|
|
1398
|
+
closeIndex: U,
|
|
1399
|
+
attrExpPresent: K,
|
|
1400
|
+
rawTagName: q
|
|
1401
|
+
};
|
|
1402
|
+
}
|
|
1403
|
+
function readStopNodeData(l, R, z) {
|
|
1404
|
+
let B = z, V = 1;
|
|
1405
|
+
for (; z < l.length; z++) if (l[z] === "<") if (l[z + 1] === "/") {
|
|
1406
|
+
let H = findClosingIndex(l, ">", z, `${R} is not closed`);
|
|
1407
|
+
if (l.substring(z + 2, H).trim() === R && (V--, V === 0)) return {
|
|
1408
|
+
tagContent: l.substring(B, z),
|
|
1409
|
+
i: H
|
|
1410
|
+
};
|
|
1411
|
+
z = H;
|
|
1412
|
+
} else if (l[z + 1] === "?") z = findClosingIndex(l, "?>", z + 1, "StopNode is not closed.");
|
|
1413
|
+
else if (l.substr(z + 1, 3) === "!--") z = findClosingIndex(l, "-->", z + 3, "StopNode is not closed.");
|
|
1414
|
+
else if (l.substr(z + 1, 2) === "![") z = findClosingIndex(l, "]]>", z, "StopNode is not closed.") - 2;
|
|
1415
|
+
else {
|
|
1416
|
+
let B = readTagExp(l, z, ">");
|
|
1417
|
+
B && ((B && B.tagName) === R && B.tagExp[B.tagExp.length - 1] !== "/" && V++, z = B.closeIndex);
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
function parseValue(l, R, z) {
|
|
1421
|
+
if (R && typeof l == "string") {
|
|
1422
|
+
let R = l.trim();
|
|
1423
|
+
return R === "true" ? !0 : R === "false" ? !1 : toNumber(l, z);
|
|
1424
|
+
} else if (isExist(l)) return l;
|
|
1425
|
+
else return "";
|
|
1426
|
+
}
|
|
1427
|
+
function fromCodePoint(l, R, z) {
|
|
1428
|
+
let B = Number.parseInt(l, R);
|
|
1429
|
+
return B >= 0 && B <= 1114111 ? String.fromCodePoint(B) : z + l + ";";
|
|
1430
|
+
}
|
|
1431
|
+
var METADATA_SYMBOL = XmlNode.getMetaDataSymbol();
|
|
1432
|
+
function prettify(l, R) {
|
|
1433
|
+
return compress(l, R);
|
|
1434
|
+
}
|
|
1435
|
+
function compress(l, R, z) {
|
|
1436
|
+
let B, V = {};
|
|
1437
|
+
for (let H = 0; H < l.length; H++) {
|
|
1438
|
+
let U = l[H], W = propName(U), G = "";
|
|
1439
|
+
if (G = z === void 0 ? W : z + "." + W, W === R.textNodeName) B === void 0 ? B = U[W] : B += "" + U[W];
|
|
1440
|
+
else if (W === void 0) continue;
|
|
1441
|
+
else if (U[W]) {
|
|
1442
|
+
let l = compress(U[W], R, G), z = isLeafTag(l, R);
|
|
1443
|
+
U[METADATA_SYMBOL] !== void 0 && (l[METADATA_SYMBOL] = U[METADATA_SYMBOL]), U[":@"] ? assignAttributes(l, U[":@"], G, R) : Object.keys(l).length === 1 && l[R.textNodeName] !== void 0 && !R.alwaysCreateTextNode ? l = l[R.textNodeName] : Object.keys(l).length === 0 && (R.alwaysCreateTextNode ? l[R.textNodeName] = "" : l = ""), V[W] !== void 0 && V.hasOwnProperty(W) ? (Array.isArray(V[W]) || (V[W] = [V[W]]), V[W].push(l)) : R.isArray(W, G, z) ? V[W] = [l] : V[W] = l;
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
return typeof B == "string" ? B.length > 0 && (V[R.textNodeName] = B) : B !== void 0 && (V[R.textNodeName] = B), V;
|
|
1447
|
+
}
|
|
1448
|
+
function propName(l) {
|
|
1449
|
+
let R = Object.keys(l);
|
|
1450
|
+
for (let l = 0; l < R.length; l++) {
|
|
1451
|
+
let z = R[l];
|
|
1452
|
+
if (z !== ":@") return z;
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
function assignAttributes(l, R, z, B) {
|
|
1456
|
+
if (R) {
|
|
1457
|
+
let V = Object.keys(R), H = V.length;
|
|
1458
|
+
for (let U = 0; U < H; U++) {
|
|
1459
|
+
let H = V[U];
|
|
1460
|
+
B.isArray(H, z + "." + H, !0, !0) ? l[H] = [R[H]] : l[H] = R[H];
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
function isLeafTag(l, R) {
|
|
1465
|
+
let { textNodeName: z } = R, B = Object.keys(l).length;
|
|
1466
|
+
return !!(B === 0 || B === 1 && (l[z] || typeof l[z] == "boolean" || l[z] === 0));
|
|
1467
|
+
}
|
|
1468
|
+
var XMLParser = class {
|
|
1469
|
+
constructor(l) {
|
|
1470
|
+
this.externalEntities = {}, this.options = buildOptions(l);
|
|
1471
|
+
}
|
|
1472
|
+
parse(l, R) {
|
|
1473
|
+
if (typeof l != "string" && l.toString) l = l.toString();
|
|
1474
|
+
else if (typeof l != "string") throw Error("XML data is accepted in String or Bytes[] form.");
|
|
1475
|
+
if (R) {
|
|
1476
|
+
R === !0 && (R = {});
|
|
1477
|
+
let z = validate(l, R);
|
|
1478
|
+
if (z !== !0) throw Error(`${z.err.msg}:${z.err.line}:${z.err.col}`);
|
|
1479
|
+
}
|
|
1480
|
+
let z = new OrderedObjParser(this.options);
|
|
1481
|
+
z.addExternalEntities(this.externalEntities);
|
|
1482
|
+
let B = z.parseXml(l);
|
|
1483
|
+
return this.options.preserveOrder || B === void 0 ? B : prettify(B, this.options);
|
|
1484
|
+
}
|
|
1485
|
+
addEntity(l, R) {
|
|
1486
|
+
if (R.indexOf("&") !== -1) throw Error("Entity value can't have '&'");
|
|
1487
|
+
if (l.indexOf("&") !== -1 || l.indexOf(";") !== -1) throw Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");
|
|
1488
|
+
if (R === "&") throw Error("An entity with value '&' is not permitted");
|
|
1489
|
+
this.externalEntities[l] = R;
|
|
1490
|
+
}
|
|
1491
|
+
static getMetaDataSymbol() {
|
|
1492
|
+
return XmlNode.getMetaDataSymbol();
|
|
1493
|
+
}
|
|
1494
|
+
};
|
|
1495
|
+
function extractModel(l) {
|
|
1496
|
+
let R = new XMLParser({
|
|
1497
|
+
ignoreAttributes: !1,
|
|
1498
|
+
attributeNamePrefix: "@_",
|
|
1499
|
+
isArray: (l) => [
|
|
1500
|
+
"pages",
|
|
1501
|
+
"actions",
|
|
1502
|
+
"pageContainers",
|
|
1503
|
+
"children",
|
|
1504
|
+
"items",
|
|
1505
|
+
"columns",
|
|
1506
|
+
"buttons",
|
|
1507
|
+
"filters",
|
|
1508
|
+
"actionButtonGroups",
|
|
1509
|
+
"availableAnnotations",
|
|
1510
|
+
"dataElements",
|
|
1511
|
+
"dataTypes",
|
|
1512
|
+
"attributes",
|
|
1513
|
+
"relations",
|
|
1514
|
+
"members"
|
|
1515
|
+
].includes(l)
|
|
1516
|
+
}).parse(l), z = R["xmi:XMI"] ?? R, B = [];
|
|
1517
|
+
if (z["ui:Application"]) {
|
|
1518
|
+
let l = Array.isArray(z["ui:Application"]) ? z["ui:Application"] : [z["ui:Application"]];
|
|
1519
|
+
B.push(...l);
|
|
1520
|
+
}
|
|
1521
|
+
let V = {
|
|
1522
|
+
applications: [],
|
|
1523
|
+
pages: [],
|
|
1524
|
+
components: [],
|
|
1525
|
+
navigationItems: [],
|
|
1526
|
+
subThemeNames: [],
|
|
1527
|
+
dataTypes: [],
|
|
1528
|
+
transferTypes: []
|
|
1529
|
+
}, H = /* @__PURE__ */ new Set(), U = /* @__PURE__ */ new Map(), W = /* @__PURE__ */ new Map();
|
|
1530
|
+
for (let l of B) {
|
|
1531
|
+
let R = ensureArray(l.pageContainers);
|
|
1532
|
+
for (let l of R) {
|
|
1533
|
+
let R = l["@_xmi:id"];
|
|
1534
|
+
R && U.set(R, l);
|
|
1535
|
+
}
|
|
1536
|
+
let z = ensureArray(l.availableAnnotations);
|
|
1537
|
+
for (let l of z) {
|
|
1538
|
+
let R = l["@_xmi:id"], z = l["@_name"];
|
|
1539
|
+
R && z && W.set(R, z);
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
for (let l of B) {
|
|
1543
|
+
let R = l["@_name"] ?? "UnknownApp", z = l["@_xmi:id"] ?? "";
|
|
1544
|
+
V.applications.push({
|
|
1545
|
+
name: R,
|
|
1546
|
+
sourceId: z
|
|
1547
|
+
});
|
|
1548
|
+
let B = ensureArray(l.pages);
|
|
1549
|
+
for (let l of B) {
|
|
1550
|
+
let z = l["@_name"], B = l["@_xmi:id"];
|
|
1551
|
+
if (!z || !B) continue;
|
|
1552
|
+
let G = l["@_container"], K = G ? U.get(G) : void 0, q = K?.["@_type"], J = [], Y = ensureArray(l.actions);
|
|
1553
|
+
for (let l of Y) {
|
|
1554
|
+
let R = l["@_name"], z = l["@_xmi:id"], B = l["@_actionDefinition"];
|
|
1555
|
+
if (!R || !z) continue;
|
|
1556
|
+
let V = resolveActionDefinitionType(B ?? "");
|
|
1557
|
+
J.push({
|
|
1558
|
+
name: R,
|
|
1559
|
+
sourceId: z,
|
|
1560
|
+
actionDefinitionType: V,
|
|
1561
|
+
actionDefinitionSourceId: B ?? ""
|
|
1562
|
+
});
|
|
1563
|
+
}
|
|
1564
|
+
let X = [], Z = [];
|
|
1565
|
+
K && collectElements(K, X, Z, z, "", H, W);
|
|
1566
|
+
for (let l of Z) V.components.push(l);
|
|
1567
|
+
V.pages.push({
|
|
1568
|
+
name: z,
|
|
1569
|
+
sourceId: B,
|
|
1570
|
+
applicationName: R,
|
|
1571
|
+
label: l["@_label"],
|
|
1572
|
+
openInDialog: l["@_openInDialog"] === "true",
|
|
1573
|
+
dashboard: l["@_dashboard"] === "true",
|
|
1574
|
+
containerType: q,
|
|
1575
|
+
actions: J,
|
|
1576
|
+
elements: X
|
|
1577
|
+
});
|
|
1578
|
+
}
|
|
1579
|
+
let G = l.navigationController;
|
|
1580
|
+
if (G) {
|
|
1581
|
+
let l = ensureArray(G.items);
|
|
1582
|
+
for (let R of l) {
|
|
1583
|
+
let l = R["@_name"], z = R["@_xmi:id"], B = R["@_label"];
|
|
1584
|
+
l && z && V.navigationItems.push({
|
|
1585
|
+
name: l,
|
|
1586
|
+
sourceId: z,
|
|
1587
|
+
label: B
|
|
1588
|
+
});
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
let K = ensureArray(l.dataTypes);
|
|
1592
|
+
for (let l of K) {
|
|
1593
|
+
let R = l["@_xmi:id"], z = l["@_xsi:type"], B = l["@_name"];
|
|
1594
|
+
if (!R || !z || !B) continue;
|
|
1595
|
+
let H = {
|
|
1596
|
+
xmiId: R,
|
|
1597
|
+
xsiType: z,
|
|
1598
|
+
name: B
|
|
1599
|
+
};
|
|
1600
|
+
if (z === "data:EnumerationType") {
|
|
1601
|
+
let R = ensureArray(l.members);
|
|
1602
|
+
R.length > 0 && (H.members = R.map((l) => l["@_name"]).filter((l) => typeof l == "string"));
|
|
1603
|
+
}
|
|
1604
|
+
V.dataTypes.push(H);
|
|
1605
|
+
}
|
|
1606
|
+
let q = ensureArray(l.dataElements);
|
|
1607
|
+
for (let l of q) {
|
|
1608
|
+
if (l["@_xsi:type"] !== "data:ClassType") continue;
|
|
1609
|
+
let R = l["@_xmi:id"], z = l["@_name"];
|
|
1610
|
+
if (!R || !z) continue;
|
|
1611
|
+
let B = [], H = ensureArray(l.attributes);
|
|
1612
|
+
for (let l of H) {
|
|
1613
|
+
let R = l["@_name"], z = l["@_dataType"];
|
|
1614
|
+
!R || !z || B.push({
|
|
1615
|
+
name: R,
|
|
1616
|
+
dataTypeRef: z,
|
|
1617
|
+
isReadOnly: l["@_isReadOnly"] === "true",
|
|
1618
|
+
isRequired: l["@_isRequired"] === "true"
|
|
1619
|
+
});
|
|
1620
|
+
}
|
|
1621
|
+
let U = [], W = ensureArray(l.relations);
|
|
1622
|
+
for (let l of W) {
|
|
1623
|
+
let R = l["@_name"], z = l["@_target"];
|
|
1624
|
+
!R || !z || U.push({
|
|
1625
|
+
name: R,
|
|
1626
|
+
targetRef: z,
|
|
1627
|
+
isCollection: l["@_isCollection"] !== "false"
|
|
1628
|
+
});
|
|
1629
|
+
}
|
|
1630
|
+
V.transferTypes.push({
|
|
1631
|
+
name: z,
|
|
1632
|
+
xmiId: R,
|
|
1633
|
+
isActor: l["@_isActor"] === "true",
|
|
1634
|
+
attributes: B,
|
|
1635
|
+
relations: U
|
|
1636
|
+
});
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
return V.subThemeNames = [...H].toSorted(), V;
|
|
1640
|
+
}
|
|
1641
|
+
function collectElements(l, R, z, B, V, H, U) {
|
|
1642
|
+
let W = ensureArray(l.children);
|
|
1643
|
+
for (let l of W) {
|
|
1644
|
+
let W = l["@_name"], G = l["@_xmi:id"], K = l["@_xsi:type"]?.replace("ui:", "") ?? inferType(l), q = W ? V ? `${V}.${W}` : W : V, J = resolveAnnotations(l["@_annotations"], U);
|
|
1645
|
+
W && G && (R.push({
|
|
1646
|
+
name: W,
|
|
1647
|
+
path: q,
|
|
1648
|
+
sourceId: G,
|
|
1649
|
+
elementType: K,
|
|
1650
|
+
label: l["@_label"],
|
|
1651
|
+
...J.length > 0 ? { annotations: J } : {}
|
|
1652
|
+
}), l["@_customImplementation"] === "true" && z.push({
|
|
1653
|
+
name: W,
|
|
1654
|
+
sourceId: G,
|
|
1655
|
+
elementType: K,
|
|
1656
|
+
pageName: B,
|
|
1657
|
+
...J.length > 0 ? { annotations: J } : {}
|
|
1658
|
+
}));
|
|
1659
|
+
let Y = l["@_subTheme"];
|
|
1660
|
+
Y && H && H.add(Y), collectElements(l, R, z, B, q, H, U);
|
|
1661
|
+
}
|
|
1662
|
+
let G = ensureArray(l.columns);
|
|
1663
|
+
for (let l of G) {
|
|
1664
|
+
let z = l["@_name"], B = l["@_xmi:id"];
|
|
1665
|
+
if (z && B) {
|
|
1666
|
+
let H = V ? `${V}.${z}` : z;
|
|
1667
|
+
R.push({
|
|
1668
|
+
name: z,
|
|
1669
|
+
path: H,
|
|
1670
|
+
sourceId: B,
|
|
1671
|
+
elementType: "Column",
|
|
1672
|
+
label: l["@_label"]
|
|
1673
|
+
});
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
let K = ensureArray(l.filters);
|
|
1677
|
+
for (let l of K) {
|
|
1678
|
+
let z = l["@_name"], B = l["@_xmi:id"];
|
|
1679
|
+
if (z && B) {
|
|
1680
|
+
let H = getFilterName(z), U = V ? `${V}.filters.${H}` : `filters.${H}`;
|
|
1681
|
+
R.push({
|
|
1682
|
+
name: H,
|
|
1683
|
+
path: U,
|
|
1684
|
+
sourceId: B,
|
|
1685
|
+
elementType: "Filter",
|
|
1686
|
+
label: l["@_label"]
|
|
1687
|
+
});
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
let q = ensureArray(l.buttons);
|
|
1691
|
+
for (let l of q) {
|
|
1692
|
+
let z = l["@_name"], B = l["@_xmi:id"];
|
|
1693
|
+
if (z && B) {
|
|
1694
|
+
let H = getShortName(z), U = V ? `${V}.${H}` : H;
|
|
1695
|
+
R.push({
|
|
1696
|
+
name: H,
|
|
1697
|
+
path: U,
|
|
1698
|
+
sourceId: B,
|
|
1699
|
+
elementType: "Button",
|
|
1700
|
+
label: l["@_label"]
|
|
1701
|
+
});
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
let J = l.tableActionButtonGroup;
|
|
1705
|
+
if (J) {
|
|
1706
|
+
let l = V ? `${V}.tableActions` : "tableActions", z = ensureArray(J.buttons);
|
|
1707
|
+
for (let B of z) {
|
|
1708
|
+
let z = B["@_name"], V = B["@_xmi:id"];
|
|
1709
|
+
if (z && V) {
|
|
1710
|
+
let H = getShortName(z), U = `${l}.${H}`;
|
|
1711
|
+
R.push({
|
|
1712
|
+
name: H,
|
|
1713
|
+
path: U,
|
|
1714
|
+
sourceId: V,
|
|
1715
|
+
elementType: "Button",
|
|
1716
|
+
label: B["@_label"]
|
|
1717
|
+
});
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
let Y = l.rowActionButtonGroup;
|
|
1722
|
+
if (Y) {
|
|
1723
|
+
let l = V ? `${V}.rowActions` : "rowActions", z = ensureArray(Y.buttons);
|
|
1724
|
+
for (let B of z) {
|
|
1725
|
+
let z = B["@_name"], V = B["@_xmi:id"];
|
|
1726
|
+
if (z && V) {
|
|
1727
|
+
let H = getShortName(z), U = `${l}.${H}`;
|
|
1728
|
+
R.push({
|
|
1729
|
+
name: H,
|
|
1730
|
+
path: U,
|
|
1731
|
+
sourceId: V,
|
|
1732
|
+
elementType: "Button",
|
|
1733
|
+
label: B["@_label"]
|
|
1734
|
+
});
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
let X = ensureArray(l.actionButtonGroups);
|
|
1739
|
+
for (let l of X) {
|
|
1740
|
+
let z = ensureArray(l.buttons);
|
|
1741
|
+
for (let l of z) {
|
|
1742
|
+
let z = l["@_name"], B = l["@_xmi:id"];
|
|
1743
|
+
if (z && B) {
|
|
1744
|
+
let H = getShortName(z), U = V ? `${V}.${H}` : H;
|
|
1745
|
+
R.push({
|
|
1746
|
+
name: H,
|
|
1747
|
+
path: U,
|
|
1748
|
+
sourceId: B,
|
|
1749
|
+
elementType: "Button",
|
|
1750
|
+
label: l["@_label"]
|
|
1751
|
+
});
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
function getShortName(l) {
|
|
1757
|
+
let R = l.split("::");
|
|
1758
|
+
return R[R.length - 1];
|
|
1759
|
+
}
|
|
1760
|
+
function getFilterName(l) {
|
|
1761
|
+
return l.endsWith("::Filter") ? l.slice(0, -8) : getShortName(l);
|
|
1762
|
+
}
|
|
1763
|
+
function inferType(l) {
|
|
1764
|
+
return l.children ? "Flex" : "VisualElement";
|
|
1765
|
+
}
|
|
1766
|
+
function resolveActionDefinitionType(l) {
|
|
1767
|
+
let R = l.split("/"), z = R[R.length - 1];
|
|
1768
|
+
for (let [l, R] of Object.entries({
|
|
1769
|
+
TransferObjectTableBackActionDefinition: "BackActionDefinition",
|
|
1770
|
+
TransferObjectViewBackActionDefinition: "BackActionDefinition",
|
|
1771
|
+
TransferObjectFormBackActionDefinition: "BackActionDefinition",
|
|
1772
|
+
TransferObjectTableTableRefreshActionDefinition: "RefreshActionDefinition",
|
|
1773
|
+
TransferObjectViewRefreshActionDefinition: "RefreshActionDefinition",
|
|
1774
|
+
TransferObjectFormRefreshActionDefinition: "RefreshActionDefinition",
|
|
1775
|
+
TransferObjectTableTableFilterActionDefinition: "FilterActionDefinition",
|
|
1776
|
+
TransferObjectViewDeleteActionDefinition: "DeleteActionDefinition",
|
|
1777
|
+
TransferObjectTableDeleteActionDefinition: "DeleteActionDefinition",
|
|
1778
|
+
TransferObjectViewCancelActionDefinition: "CancelActionDefinition",
|
|
1779
|
+
TransferObjectViewUpdateActionDefinition: "UpdateActionDefinition",
|
|
1780
|
+
TransferObjectFormCreateActionDefinition: "CreateActionDefinition",
|
|
1781
|
+
TransferObjectFormGetTemplateActionDefinition: "GetTemplateActionDefinition",
|
|
1782
|
+
TransferObjectTableRowViewActionDefinition: "OpenPageActionDefinition",
|
|
1783
|
+
TransferObjectTableSetSelectorSetActionDefinition: "SetActionDefinition",
|
|
1784
|
+
TransferObjectTableAddSelectorAddActionDefinition: "AddActionDefinition",
|
|
1785
|
+
TabularReferenceTableBulkDeleteActionDefinition: "BulkDeleteActionDefinition",
|
|
1786
|
+
TabularReferenceTableClearActionDefinition: "ClearActionDefinition",
|
|
1787
|
+
TabularReferenceTableCreateOpenActionDefinition: "OpenCreateFormActionDefinition",
|
|
1788
|
+
TabularReferenceTableFilterActionDefinition: "FilterActionDefinition",
|
|
1789
|
+
TabularReferenceTableRowDeleteActionDefinition: "RowDeleteActionDefinition",
|
|
1790
|
+
TabularReferenceTableRowViewActionDefinition: "OpenPageActionDefinition",
|
|
1791
|
+
TabularReferenceFieldLinkViewActionDefinition: "OpenPageActionDefinition",
|
|
1792
|
+
TabularReferenceFieldLinkSetSelectorOpenPageActionDefinition: "OpenSelectorActionDefinition",
|
|
1793
|
+
TabularReferenceFieldLinkAutocompleteRangeActionDefinition: "AutocompleteRangeActionDefinition",
|
|
1794
|
+
TabularReferenceFieldLinkAutocompleteSetActionDefinition: "AutocompleteSetActionDefinition",
|
|
1795
|
+
TabularReferenceFieldLinkUnsetActionDefinition: "UnsetActionDefinition"
|
|
1796
|
+
})) if (z.includes(l)) return R;
|
|
1797
|
+
return z.includes("OperationFormCallActionDefinition") ? "InputFormCallOperationActionDefinition" : z.includes("OperationFormOpenPageUnmappedInputActionDefinition") ? "OpenOperationInputFormActionDefinition" : z.includes("CallOperationActionDefinition") ? "CallOperationActionDefinition" : z.endsWith("ActionDefinition") ? z : "ActionDefinition";
|
|
1798
|
+
}
|
|
1799
|
+
function ensureArray(l) {
|
|
1800
|
+
return l ? Array.isArray(l) ? l : [l] : [];
|
|
1801
|
+
}
|
|
1802
|
+
function resolveAnnotations(l, R) {
|
|
1803
|
+
if (!l || !R) return [];
|
|
1804
|
+
let z = l.split(/\s+/).filter(Boolean), B = [];
|
|
1805
|
+
for (let l of z) {
|
|
1806
|
+
let z = R.get(l);
|
|
1807
|
+
z && B.push(z);
|
|
1808
|
+
}
|
|
1809
|
+
return B;
|
|
1810
|
+
}
|
|
1811
|
+
export { generate as n, extractModel as t };
|