@elisra-devops/docgen-data-provider 1.45.0 → 1.46.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/bin/helpers/helper.js +39 -4
- package/bin/helpers/helper.js.map +1 -1
- package/package.json +1 -1
- package/src/helpers/helper.ts +45 -4
package/bin/helpers/helper.js
CHANGED
|
@@ -35,6 +35,8 @@ class Helper {
|
|
|
35
35
|
* @returns Array of suiteData objects representing the hierarchy
|
|
36
36
|
*/
|
|
37
37
|
static findSuitesRecursive(planId, url, project, suits, foundId, recursive, flatTreeByOneLevel = false) {
|
|
38
|
+
console.log(`[findSuitesRecursive] Starting with foundId: ${foundId}, flatTreeByOneLevel: ${flatTreeByOneLevel}`);
|
|
39
|
+
console.log(`[findSuitesRecursive] Total suits provided: ${suits.length}`);
|
|
38
40
|
// Create a map for faster lookups
|
|
39
41
|
const suiteMap = new Map();
|
|
40
42
|
suits.forEach((suite) => suiteMap.set(suite.id.toString(), suite));
|
|
@@ -43,19 +45,36 @@ class Helper {
|
|
|
43
45
|
// Find the starting suite
|
|
44
46
|
const startingSuite = suiteMap.get(foundId);
|
|
45
47
|
if (!startingSuite) {
|
|
48
|
+
console.log(`[findSuitesRecursive] ERROR: Starting suite ${foundId} not found in suite map`);
|
|
46
49
|
return result;
|
|
47
50
|
}
|
|
51
|
+
console.log(`[findSuitesRecursive] Starting suite found: ${startingSuite.title} (ID: ${startingSuite.id}, parentSuiteId: ${startingSuite.parentSuiteId})`);
|
|
48
52
|
// Skip root suites (parentSuiteId = 0) - we don't want them in results
|
|
49
53
|
// Just mark them as visited so we can process their children
|
|
50
54
|
if (startingSuite.parentSuiteId === 0) {
|
|
55
|
+
console.log(`[findSuitesRecursive] Starting suite is root (parentSuiteId = 0), marking as visited`);
|
|
51
56
|
visited.add(foundId);
|
|
52
57
|
}
|
|
53
58
|
// Build the hierarchy
|
|
54
|
-
|
|
59
|
+
const startingLevel = startingSuite.parentSuiteId === 0 ? 1 : 0;
|
|
60
|
+
console.log(`[findSuitesRecursive] Building hierarchy starting at level: ${startingLevel}`);
|
|
61
|
+
this.buildSuiteHierarchy(suiteMap, foundId, planId, url, project, result, visited, startingLevel, recursive);
|
|
62
|
+
console.log(`[findSuitesRecursive] Hierarchy built, result count: ${result.length}`);
|
|
63
|
+
console.log(`[findSuitesRecursive] Result suites:`, result.map(s => `${s.name} (ID: ${s.id}, level: ${s.level}, parent: ${s.parent})`));
|
|
55
64
|
// Apply flattening if conditions are met
|
|
56
|
-
if (flatTreeByOneLevel
|
|
57
|
-
|
|
65
|
+
if (flatTreeByOneLevel) {
|
|
66
|
+
console.log(`[findSuitesRecursive] Checking flattening conditions...`);
|
|
67
|
+
if (this.shouldFlattenHierarchy(result, suiteMap, foundId)) {
|
|
68
|
+
console.log(`[findSuitesRecursive] Flattening conditions met, applying flattening...`);
|
|
69
|
+
const flattened = this.flattenHierarchyByOneLevel(result, foundId);
|
|
70
|
+
console.log(`[findSuitesRecursive] After flattening:`, flattened.map(s => `${s.name} (ID: ${s.id}, level: ${s.level}, parent: ${s.parent})`));
|
|
71
|
+
return flattened;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
console.log(`[findSuitesRecursive] Flattening conditions NOT met`);
|
|
75
|
+
}
|
|
58
76
|
}
|
|
77
|
+
console.log(`[findSuitesRecursive] Returning ${result.length} suites (no flattening applied)`);
|
|
59
78
|
return result;
|
|
60
79
|
}
|
|
61
80
|
/**
|
|
@@ -105,17 +124,26 @@ class Helper {
|
|
|
105
124
|
* - That suite has children (level 2+ suites)
|
|
106
125
|
*/
|
|
107
126
|
static shouldFlattenHierarchy(result, suiteMap, rootId) {
|
|
127
|
+
console.log(`[shouldFlattenHierarchy] Checking flattening conditions for rootId: ${rootId}`);
|
|
128
|
+
console.log(`[shouldFlattenHierarchy] Total result suites: ${result.length}`);
|
|
108
129
|
// Find all level 1 suites (direct children of root) - they have level 1
|
|
109
130
|
const level1Suites = result.filter((suite) => suite.level === 1);
|
|
131
|
+
console.log(`[shouldFlattenHierarchy] Found ${level1Suites.length} level 1 suites:`, level1Suites.map(s => `${s.name} (ID: ${s.id})`));
|
|
110
132
|
// Must have exactly one level 1 suite
|
|
111
133
|
if (level1Suites.length !== 1) {
|
|
134
|
+
console.log(`[shouldFlattenHierarchy] CONDITION FAILED: Not exactly one level 1 suite (found ${level1Suites.length})`);
|
|
112
135
|
return false;
|
|
113
136
|
}
|
|
114
137
|
const singleLevel1Suite = level1Suites[0];
|
|
138
|
+
console.log(`[shouldFlattenHierarchy] Single level 1 suite: ${singleLevel1Suite.name} (ID: ${singleLevel1Suite.id})`);
|
|
115
139
|
// Check if this suite has children by looking for suites with this suite as parent
|
|
116
140
|
const childrenInResult = result.filter((suite) => suite.parent === singleLevel1Suite.id);
|
|
141
|
+
console.log(`[shouldFlattenHierarchy] Found ${childrenInResult.length} children of level 1 suite:`, childrenInResult.map(s => `${s.name} (ID: ${s.id}, level: ${s.level})`));
|
|
117
142
|
// The suite must have children
|
|
118
|
-
|
|
143
|
+
const hasChildren = childrenInResult.length > 0;
|
|
144
|
+
console.log(`[shouldFlattenHierarchy] Suite has children: ${hasChildren}`);
|
|
145
|
+
console.log(`[shouldFlattenHierarchy] FLATTENING CONDITIONS ${hasChildren ? 'MET' : 'NOT MET'}`);
|
|
146
|
+
return hasChildren;
|
|
119
147
|
}
|
|
120
148
|
/**
|
|
121
149
|
* Flattens the hierarchy by one level:
|
|
@@ -124,12 +152,16 @@ class Helper {
|
|
|
124
152
|
* - Updates parentSuiteId of new level 1 suites to point to root
|
|
125
153
|
*/
|
|
126
154
|
static flattenHierarchyByOneLevel(result, rootId) {
|
|
155
|
+
console.log(`[flattenHierarchyByOneLevel] Starting flattening process for rootId: ${rootId}`);
|
|
156
|
+
console.log(`[flattenHierarchyByOneLevel] Input suites:`, result.map(s => `${s.name} (ID: ${s.id}, level: ${s.level}, parent: ${s.parent})`));
|
|
127
157
|
// Find the single level 1 suite to remove (level = 1)
|
|
128
158
|
const level1Suite = result.find((suite) => suite.level === 1);
|
|
129
159
|
if (!level1Suite) {
|
|
160
|
+
console.log(`[flattenHierarchyByOneLevel] ERROR: No level 1 suite found to remove`);
|
|
130
161
|
return result;
|
|
131
162
|
}
|
|
132
163
|
const level1SuiteId = level1Suite.id;
|
|
164
|
+
console.log(`[flattenHierarchyByOneLevel] Removing level 1 suite: ${level1Suite.name} (ID: ${level1SuiteId})`);
|
|
133
165
|
// Filter out the level 1 suite and adjust levels/parents for remaining suites
|
|
134
166
|
const flattenedResult = result
|
|
135
167
|
.filter((suite) => suite.id !== level1SuiteId) // Remove the level 1 suite
|
|
@@ -139,10 +171,13 @@ class Helper {
|
|
|
139
171
|
// If this was a level 2 suite (child of the removed level 1 suite),
|
|
140
172
|
// update its parent to point to the root
|
|
141
173
|
if (suite.parent === level1SuiteId) {
|
|
174
|
+
console.log(`[flattenHierarchyByOneLevel] Updating parent of ${suite.name} from ${level1SuiteId} to ${rootId}`);
|
|
142
175
|
newSuite.parent = rootId;
|
|
143
176
|
}
|
|
177
|
+
console.log(`[flattenHierarchyByOneLevel] Processed suite: ${newSuite.name} (ID: ${newSuite.id}, level: ${suite.level} -> ${newSuite.level}, parent: ${suite.parent} -> ${newSuite.parent})`);
|
|
144
178
|
return newSuite;
|
|
145
179
|
});
|
|
180
|
+
console.log(`[flattenHierarchyByOneLevel] Flattening complete. Result:`, flattenedResult.map(s => `${s.name} (ID: ${s.id}, level: ${s.level}, parent: ${s.parent})`));
|
|
146
181
|
return flattenedResult;
|
|
147
182
|
}
|
|
148
183
|
static LevelBuilder(results, foundId) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../../src/helpers/helper.ts"],"names":[],"mappings":";;;AAEA,MAAa,SAAS;IAMpB,YAAY,IAAY,EAAE,EAAU,EAAE,MAAc,EAAE,KAAa;QACjE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,EAAE,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AAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAClD,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YAEtC,IAAI,QAAQ,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;gBACzB,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC;gBACnB,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;oBACvC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAChC,CAAC;YACH,CAAC;iBAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,OAAO,EAAE,CAAC;gBACjD,QAAQ,CAAC,KAAK,GAAG,YAAY,CAAC;gBAC9B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAE9B,2CAA2C;gBAC3C,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,YAAY,GAAG,CAAC,CAAC,CAAC;YACnF,CAAC;QACH,CAAC;IACH,CAAC;;AAlRH,wBAmRC;AA9Be,gBAAS,GAAoB,IAAI,KAAK,EAAY,CAAC"}
|
package/package.json
CHANGED
package/src/helpers/helper.ts
CHANGED
|
@@ -55,6 +55,9 @@ export class Helper {
|
|
|
55
55
|
recursive: boolean,
|
|
56
56
|
flatTreeByOneLevel: boolean = false
|
|
57
57
|
): Array<suiteData> {
|
|
58
|
+
console.log(`[findSuitesRecursive] Starting with foundId: ${foundId}, flatTreeByOneLevel: ${flatTreeByOneLevel}`);
|
|
59
|
+
console.log(`[findSuitesRecursive] Total suits provided: ${suits.length}`);
|
|
60
|
+
|
|
58
61
|
// Create a map for faster lookups
|
|
59
62
|
const suiteMap = new Map<string, any>();
|
|
60
63
|
suits.forEach((suite) => suiteMap.set(suite.id.toString(), suite));
|
|
@@ -65,16 +68,23 @@ export class Helper {
|
|
|
65
68
|
// Find the starting suite
|
|
66
69
|
const startingSuite = suiteMap.get(foundId);
|
|
67
70
|
if (!startingSuite) {
|
|
71
|
+
console.log(`[findSuitesRecursive] ERROR: Starting suite ${foundId} not found in suite map`);
|
|
68
72
|
return result;
|
|
69
73
|
}
|
|
70
74
|
|
|
75
|
+
console.log(`[findSuitesRecursive] Starting suite found: ${startingSuite.title} (ID: ${startingSuite.id}, parentSuiteId: ${startingSuite.parentSuiteId})`);
|
|
76
|
+
|
|
71
77
|
// Skip root suites (parentSuiteId = 0) - we don't want them in results
|
|
72
78
|
// Just mark them as visited so we can process their children
|
|
73
79
|
if (startingSuite.parentSuiteId === 0) {
|
|
80
|
+
console.log(`[findSuitesRecursive] Starting suite is root (parentSuiteId = 0), marking as visited`);
|
|
74
81
|
visited.add(foundId);
|
|
75
82
|
}
|
|
76
83
|
|
|
77
84
|
// Build the hierarchy
|
|
85
|
+
const startingLevel = startingSuite.parentSuiteId === 0 ? 1 : 0;
|
|
86
|
+
console.log(`[findSuitesRecursive] Building hierarchy starting at level: ${startingLevel}`);
|
|
87
|
+
|
|
78
88
|
this.buildSuiteHierarchy(
|
|
79
89
|
suiteMap,
|
|
80
90
|
foundId,
|
|
@@ -83,15 +93,27 @@ export class Helper {
|
|
|
83
93
|
project,
|
|
84
94
|
result,
|
|
85
95
|
visited,
|
|
86
|
-
|
|
96
|
+
startingLevel,
|
|
87
97
|
recursive
|
|
88
98
|
);
|
|
89
99
|
|
|
100
|
+
console.log(`[findSuitesRecursive] Hierarchy built, result count: ${result.length}`);
|
|
101
|
+
console.log(`[findSuitesRecursive] Result suites:`, result.map(s => `${s.name} (ID: ${s.id}, level: ${s.level}, parent: ${s.parent})`));
|
|
102
|
+
|
|
90
103
|
// Apply flattening if conditions are met
|
|
91
|
-
if (flatTreeByOneLevel
|
|
92
|
-
|
|
104
|
+
if (flatTreeByOneLevel) {
|
|
105
|
+
console.log(`[findSuitesRecursive] Checking flattening conditions...`);
|
|
106
|
+
if (this.shouldFlattenHierarchy(result, suiteMap, foundId)) {
|
|
107
|
+
console.log(`[findSuitesRecursive] Flattening conditions met, applying flattening...`);
|
|
108
|
+
const flattened = this.flattenHierarchyByOneLevel(result, foundId);
|
|
109
|
+
console.log(`[findSuitesRecursive] After flattening:`, flattened.map(s => `${s.name} (ID: ${s.id}, level: ${s.level}, parent: ${s.parent})`));
|
|
110
|
+
return flattened;
|
|
111
|
+
} else {
|
|
112
|
+
console.log(`[findSuitesRecursive] Flattening conditions NOT met`);
|
|
113
|
+
}
|
|
93
114
|
}
|
|
94
115
|
|
|
116
|
+
console.log(`[findSuitesRecursive] Returning ${result.length} suites (no flattening applied)`);
|
|
95
117
|
return result;
|
|
96
118
|
}
|
|
97
119
|
|
|
@@ -187,21 +209,32 @@ export class Helper {
|
|
|
187
209
|
suiteMap: Map<string, any>,
|
|
188
210
|
rootId: string
|
|
189
211
|
): boolean {
|
|
212
|
+
console.log(`[shouldFlattenHierarchy] Checking flattening conditions for rootId: ${rootId}`);
|
|
213
|
+
console.log(`[shouldFlattenHierarchy] Total result suites: ${result.length}`);
|
|
214
|
+
|
|
190
215
|
// Find all level 1 suites (direct children of root) - they have level 1
|
|
191
216
|
const level1Suites = result.filter((suite) => suite.level === 1);
|
|
217
|
+
console.log(`[shouldFlattenHierarchy] Found ${level1Suites.length} level 1 suites:`, level1Suites.map(s => `${s.name} (ID: ${s.id})`));
|
|
192
218
|
|
|
193
219
|
// Must have exactly one level 1 suite
|
|
194
220
|
if (level1Suites.length !== 1) {
|
|
221
|
+
console.log(`[shouldFlattenHierarchy] CONDITION FAILED: Not exactly one level 1 suite (found ${level1Suites.length})`);
|
|
195
222
|
return false;
|
|
196
223
|
}
|
|
197
224
|
|
|
198
225
|
const singleLevel1Suite = level1Suites[0];
|
|
226
|
+
console.log(`[shouldFlattenHierarchy] Single level 1 suite: ${singleLevel1Suite.name} (ID: ${singleLevel1Suite.id})`);
|
|
199
227
|
|
|
200
228
|
// Check if this suite has children by looking for suites with this suite as parent
|
|
201
229
|
const childrenInResult = result.filter((suite) => suite.parent === singleLevel1Suite.id);
|
|
230
|
+
console.log(`[shouldFlattenHierarchy] Found ${childrenInResult.length} children of level 1 suite:`, childrenInResult.map(s => `${s.name} (ID: ${s.id}, level: ${s.level})`));
|
|
202
231
|
|
|
203
232
|
// The suite must have children
|
|
204
|
-
|
|
233
|
+
const hasChildren = childrenInResult.length > 0;
|
|
234
|
+
console.log(`[shouldFlattenHierarchy] Suite has children: ${hasChildren}`);
|
|
235
|
+
console.log(`[shouldFlattenHierarchy] FLATTENING CONDITIONS ${hasChildren ? 'MET' : 'NOT MET'}`);
|
|
236
|
+
|
|
237
|
+
return hasChildren;
|
|
205
238
|
}
|
|
206
239
|
|
|
207
240
|
/**
|
|
@@ -211,13 +244,18 @@ export class Helper {
|
|
|
211
244
|
* - Updates parentSuiteId of new level 1 suites to point to root
|
|
212
245
|
*/
|
|
213
246
|
private static flattenHierarchyByOneLevel(result: Array<suiteData>, rootId: string): Array<suiteData> {
|
|
247
|
+
console.log(`[flattenHierarchyByOneLevel] Starting flattening process for rootId: ${rootId}`);
|
|
248
|
+
console.log(`[flattenHierarchyByOneLevel] Input suites:`, result.map(s => `${s.name} (ID: ${s.id}, level: ${s.level}, parent: ${s.parent})`));
|
|
249
|
+
|
|
214
250
|
// Find the single level 1 suite to remove (level = 1)
|
|
215
251
|
const level1Suite = result.find((suite) => suite.level === 1);
|
|
216
252
|
if (!level1Suite) {
|
|
253
|
+
console.log(`[flattenHierarchyByOneLevel] ERROR: No level 1 suite found to remove`);
|
|
217
254
|
return result;
|
|
218
255
|
}
|
|
219
256
|
|
|
220
257
|
const level1SuiteId = level1Suite.id;
|
|
258
|
+
console.log(`[flattenHierarchyByOneLevel] Removing level 1 suite: ${level1Suite.name} (ID: ${level1SuiteId})`);
|
|
221
259
|
|
|
222
260
|
// Filter out the level 1 suite and adjust levels/parents for remaining suites
|
|
223
261
|
const flattenedResult = result
|
|
@@ -229,12 +267,15 @@ export class Helper {
|
|
|
229
267
|
// If this was a level 2 suite (child of the removed level 1 suite),
|
|
230
268
|
// update its parent to point to the root
|
|
231
269
|
if (suite.parent === level1SuiteId) {
|
|
270
|
+
console.log(`[flattenHierarchyByOneLevel] Updating parent of ${suite.name} from ${level1SuiteId} to ${rootId}`);
|
|
232
271
|
newSuite.parent = rootId;
|
|
233
272
|
}
|
|
234
273
|
|
|
274
|
+
console.log(`[flattenHierarchyByOneLevel] Processed suite: ${newSuite.name} (ID: ${newSuite.id}, level: ${suite.level} -> ${newSuite.level}, parent: ${suite.parent} -> ${newSuite.parent})`);
|
|
235
275
|
return newSuite;
|
|
236
276
|
});
|
|
237
277
|
|
|
278
|
+
console.log(`[flattenHierarchyByOneLevel] Flattening complete. Result:`, flattenedResult.map(s => `${s.name} (ID: ${s.id}, level: ${s.level}, parent: ${s.parent})`));
|
|
238
279
|
return flattenedResult;
|
|
239
280
|
}
|
|
240
281
|
|