@postman-enricher/core 1.2.3 → 1.2.5

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.
@@ -33,6 +33,7 @@ function flattenRequests(items) {
33
33
  }
34
34
  function buildResourceHierarchy(items, excludePathParams, maxDepth) {
35
35
  const folderMap = new Map();
36
+ const topLevelFolders = new Set();
36
37
  items.forEach((item) => {
37
38
  if (!isRequest(item) || !item.request?.url)
38
39
  return;
@@ -51,6 +52,10 @@ function buildResourceHierarchy(items, excludePathParams, maxDepth) {
51
52
  if (parentFolder) {
52
53
  parentFolder.item.push(folder);
53
54
  }
55
+ else {
56
+ // This is a top-level folder
57
+ topLevelFolders.add(folderPath);
58
+ }
54
59
  }
55
60
  parentFolder = folderMap.get(folderPath);
56
61
  // Add item to deepest folder
@@ -60,7 +65,7 @@ function buildResourceHierarchy(items, excludePathParams, maxDepth) {
60
65
  });
61
66
  });
62
67
  // Return only top-level folders
63
- return Array.from(folderMap.values()).filter((folder) => !folder.name.includes('/'));
68
+ return Array.from(topLevelFolders).map((path) => folderMap.get(path));
64
69
  }
65
70
  function extractSegments(path, excludePathParams) {
66
71
  return path
package/dist/index.js CHANGED
@@ -25,10 +25,6 @@ export function enrichCollection(collection, config = {}, existingCollectionPath
25
25
  // Load config from YAML file if string path provided
26
26
  const enrichmentConfig = typeof config === 'string' ? loadConfigFromYaml(config) : config;
27
27
  let enriched = { ...collection };
28
- // 0. Preserve IDs from existing collection (if provided)
29
- if (existingCollectionPath) {
30
- enriched = preserveIds(enriched, existingCollectionPath);
31
- }
32
28
  // 1. Filter endpoints first (reduce what we're working with)
33
29
  if (enrichmentConfig.filter) {
34
30
  enriched = filterEndpoints(enriched, enrichmentConfig.filter);
@@ -57,6 +53,11 @@ export function enrichCollection(collection, config = {}, existingCollectionPath
57
53
  if (enrichmentConfig.tests) {
58
54
  enriched = addTests(enriched, enrichmentConfig.tests);
59
55
  }
56
+ // 8. Preserve IDs from existing collection (if provided) - run LAST
57
+ // This must run after all enrichers so it can match the final folder structure
58
+ if (existingCollectionPath) {
59
+ enriched = preserveIds(enriched, existingCollectionPath);
60
+ }
60
61
  return enriched;
61
62
  }
62
63
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postman-enricher/core",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
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.3"
20
+ "@postman-enricher/shared": "1.2.5"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@anolilab/semantic-release-pnpm": "^3.0.0",