feat: add support for importing collection-level variables from PM collections (#3481)

* feat: add support for importing collection-level variables from Postman collections

* fix: add optional chaining for collection variables in Postman importer

* Update postman-collection.js

---------

Co-authored-by: Anoop M D <anoop.md1421@gmail.com>
This commit is contained in:
Sanjai Kumar 2024-12-15 14:53:53 +05:30 committed by GitHub
parent 22ecd0284f
commit a6ac98b709
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -166,6 +166,17 @@ const importScriptsFromEvents = (events, requestObject, options, pushTranslation
});
};
const importCollectionLevelVariables = (variables, requestObject) => {
const vars = variables.map((v) => ({
uid: uuid(),
name: v.key,
value: v.value,
enabled: true
}));
requestObject.vars.req = vars;
};
const importPostmanV2CollectionItem = (brunoParent, item, parentAuth, options) => {
brunoParent.items = brunoParent.items || [];
const folderMap = {};
@ -494,6 +505,10 @@ const importPostmanV2Collection = (collection, options) => {
importScriptsFromEvents(collection.event, brunoCollection.root.request, options, pushTranslationLog);
}
if (collection?.variable){
importCollectionLevelVariables(collection.variable, brunoCollection.root.request);
}
importPostmanV2CollectionItem(brunoCollection, collection.item, collection.auth, options);
return brunoCollection;