from sevenbridges.models.file import File


def map_input_output(item, api):
    """
    Maps item to appropriate sevebridges object.
    :param item: Input/Output value.
    :param api: Api instance.
    :return: Mapped object.
    """
    if isinstance(item, list):
        return [map_input_output(it, api) for it in item]

    elif isinstance(item, dict) and 'class' in item:
        if item['class'].lower() in ('file', 'directory'):
            _secondary_files = []
            for _file in item.get('secondaryFiles', []):
                _secondary_files.append({'id': _file['path']})
            data = {
                'id': item['path']
            }
            data.update({k: item[k] for k in item if k != 'path'})
            if _secondary_files:
                data.update({
                    '_secondary_files': _secondary_files,
                    'fetched': True
                })
            return File(api=api, **data)
    else:
        return item

@@ -1,8 +1,61 @@
+from sevenbridges.models.enums import FileApiFormats%0A
 from sev
@@ -88,16 +88,16 @@
 rt File%0A
-
 %0A%0Adef ma
@@ -426,16 +426,137 @@
 n item:%0A
+        file_class_list = %5B%0A            FileApiFormats.FILE.lower(),%0A            FileApiFormats.FOLDER.lower()%0A        %5D%0A
         
@@ -587,29 +587,23 @@
  in 
-('
 file
-', 'directory')
+_class_list
 :%0A  
@@ -824,16 +824,334 @@
       %7D%0A
+            # map class to type%0A            if item%5B'class'%5D.lower() == FileApiFormats.FOLDER.lower():%0A                data%5B'type'%5D = 'folder'%0A            else:%0A                data%5B'type'%5D = 'file'%0A%0A            # map cwl 1 file name%0A            if 'basename' in item:%0A                data%5B'name'%5D = item%5B'basename'%5D%0A%0A
         
@@ -1166,16 +1166,33 @@
 .update(
+%0A                
 %7Bk: item
@@ -1218,18 +1218,49 @@
 f k 
-!= 'path'%7D
+not in %5B'path', 'basename'%5D%7D%0A            
 )%0A  

Add support for cwl1 task outputs so the name is preloaded. Add preloaded file type for task outputs.