@postman-enricher/core 1.2.8 → 1.2.9
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/dist/enrichers/preserveIds.js +10 -21
- package/package.json +2 -2
|
@@ -10,13 +10,13 @@ export function preserveIds(collection, existingPath) {
|
|
|
10
10
|
try {
|
|
11
11
|
const existing = JSON.parse(readFileSync(existingPath, 'utf8'));
|
|
12
12
|
const idMap = buildIdMap(existing);
|
|
13
|
-
const
|
|
13
|
+
const responseMap = buildResponseMap(existing);
|
|
14
14
|
const requestBodyMap = buildRequestBodyMap(existing);
|
|
15
15
|
// Restore collection ID
|
|
16
16
|
if (existing.info?._postman_id) {
|
|
17
17
|
collection.info._postman_id = existing.info._postman_id;
|
|
18
18
|
}
|
|
19
|
-
// Restore item IDs, response IDs, and request bodies
|
|
19
|
+
// Restore item IDs, response IDs/bodies, and request bodies
|
|
20
20
|
walkCollection(collection.item, (item) => {
|
|
21
21
|
const key = getItemKey(item);
|
|
22
22
|
const existingId = idMap.get(key);
|
|
@@ -30,14 +30,11 @@ export function preserveIds(collection, existingPath) {
|
|
|
30
30
|
item.request.body.raw = existingBody;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
// Restore
|
|
33
|
+
// Restore responses from existing collection
|
|
34
34
|
if (isRequest(item) && item.response) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (existingResponseId) {
|
|
39
|
-
response.id = existingResponseId;
|
|
40
|
-
}
|
|
35
|
+
const existingResponses = responseMap.get(key);
|
|
36
|
+
if (existingResponses) {
|
|
37
|
+
item.response = existingResponses;
|
|
41
38
|
}
|
|
42
39
|
}
|
|
43
40
|
});
|
|
@@ -57,17 +54,12 @@ function buildIdMap(collection) {
|
|
|
57
54
|
});
|
|
58
55
|
return map;
|
|
59
56
|
}
|
|
60
|
-
function
|
|
57
|
+
function buildResponseMap(collection) {
|
|
61
58
|
const map = new Map();
|
|
62
59
|
walkCollection(collection.item, (item) => {
|
|
63
|
-
if (isRequest(item) && item.response) {
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
if (response.id) {
|
|
67
|
-
const responseKey = getResponseKey(itemKey, response.name, response.code);
|
|
68
|
-
map.set(responseKey, response.id);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
60
|
+
if (isRequest(item) && item.response && item.response.length > 0) {
|
|
61
|
+
const key = getItemKey(item);
|
|
62
|
+
map.set(key, item.response);
|
|
71
63
|
}
|
|
72
64
|
});
|
|
73
65
|
return map;
|
|
@@ -89,6 +81,3 @@ function getItemKey(item) {
|
|
|
89
81
|
}
|
|
90
82
|
return `folder_${item.name}`;
|
|
91
83
|
}
|
|
92
|
-
function getResponseKey(itemKey, responseName, statusCode) {
|
|
93
|
-
return `${itemKey}_${responseName}_${statusCode}`;
|
|
94
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@postman-enricher/core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.9",
|
|
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.
|
|
20
|
+
"@postman-enricher/shared": "^1.2.9"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@anolilab/semantic-release-pnpm": "^3.0.0",
|