@postman-enricher/core 1.2.2 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,14 +8,32 @@ export function organizeByResources(collection, config) {
8
8
  }
9
9
  const excludePathParams = config.excludePathParams ?? true;
10
10
  const maxDepth = config.nestingLevel || Infinity;
11
- const organized = buildResourceHierarchy(collection.item, excludePathParams, maxDepth);
11
+ // First, flatten all requests from existing structure
12
+ const flatRequests = flattenRequests(collection.item);
13
+ const organized = buildResourceHierarchy(flatRequests, excludePathParams, maxDepth);
12
14
  return {
13
15
  ...collection,
14
16
  item: organized.length > 0 ? organized : collection.item,
15
17
  };
16
18
  }
19
+ /**
20
+ * Recursively flatten all requests from a potentially nested structure
21
+ */
22
+ function flattenRequests(items) {
23
+ const requests = [];
24
+ for (const item of items) {
25
+ if (isRequest(item)) {
26
+ requests.push(item);
27
+ }
28
+ else if (item.item) {
29
+ requests.push(...flattenRequests(item.item));
30
+ }
31
+ }
32
+ return requests;
33
+ }
17
34
  function buildResourceHierarchy(items, excludePathParams, maxDepth) {
18
35
  const folderMap = new Map();
36
+ const topLevelFolders = new Set();
19
37
  items.forEach((item) => {
20
38
  if (!isRequest(item) || !item.request?.url)
21
39
  return;
@@ -34,6 +52,10 @@ function buildResourceHierarchy(items, excludePathParams, maxDepth) {
34
52
  if (parentFolder) {
35
53
  parentFolder.item.push(folder);
36
54
  }
55
+ else {
56
+ // This is a top-level folder
57
+ topLevelFolders.add(folderPath);
58
+ }
37
59
  }
38
60
  parentFolder = folderMap.get(folderPath);
39
61
  // Add item to deepest folder
@@ -43,7 +65,7 @@ function buildResourceHierarchy(items, excludePathParams, maxDepth) {
43
65
  });
44
66
  });
45
67
  // Return only top-level folders
46
- return Array.from(folderMap.values()).filter((folder) => !folder.name.includes('/'));
68
+ return Array.from(topLevelFolders).map((path) => folderMap.get(path));
47
69
  }
48
70
  function extractSegments(path, excludePathParams) {
49
71
  return path
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postman-enricher/core",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "Core enrichment logic for Postman Enricher",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -17,7 +17,7 @@
17
17
  "dependencies": {
18
18
  "openapi-to-postmanv2": "^5.5.0",
19
19
  "yaml": "^2.8.1",
20
- "@postman-enricher/shared": "1.2.2"
20
+ "@postman-enricher/shared": "1.2.4"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@anolilab/semantic-release-pnpm": "^3.0.0",