File tree Expand file tree Collapse file tree 2 files changed +54
-4
lines changed Expand file tree Collapse file tree 2 files changed +54
-4
lines changed Original file line number Diff line number Diff line change @@ -2,19 +2,39 @@ import shortApp from "../../short.app.mjs";
22import  common  from  "../common/common.mjs" ; 
33import  lodash  from  "lodash" ; 
44
5+ const  { 
6+   props : {  // eslint-disable-next-line no-unused-vars 
7+     domain,  ...props 
8+   } , 
9+ }  =  common ; 
10+ 
511export  default  { 
612  key : "short-create-a-link" , 
713  name : "Create a Short Link" , 
814  description : "Create a Short Link. [See the docs](https://developers.short.io/reference/linkspost)." , 
9-   version : "0.0.1 " , 
15+   version : "0.1.{{ts}} " , 
1016  type : "action" , 
1117  props : { 
1218    shortApp, 
13-     ...common . props , 
19+     domainId : { 
20+       propDefinition : [ 
21+         shortApp , 
22+         "domainId" , 
23+       ] , 
24+     } , 
25+     ...props , 
26+     folderId : { 
27+       propDefinition : [ 
28+         shortApp , 
29+         "folderId" , 
30+         ( {  domainId } )  =>  ( { 
31+           domainId, 
32+         } ) , 
33+       ] , 
34+     } , 
1435  } , 
1536  async  run ( {  $ } )  { 
1637    const  param  =  lodash . pick ( this ,  [ 
17-       "domain" , 
1838      "originalURL" , 
1939      "path" , 
2040      "title" , 
@@ -32,8 +52,13 @@ export default {
3252      "utmContent" , 
3353      "cloaking" , 
3454      "redirectType" , 
55+       "folderId" , 
3556    ] ) ; 
36-     const  link  =  await  this . shortApp . createLink ( $ ,  param ) ; 
57+     const  {  hostname : domain  }  =  await  this . shortApp . getDomainInfo ( this . domainId ) ; 
58+     const  link  =  await  this . shortApp . createLink ( $ ,  { 
59+       domain, 
60+       ...param , 
61+     } ) ; 
3762    $ . export ( "$summary" ,  `Successfully created the link: ${ link . secureShortURL }  ) ; 
3863    return  link ; 
3964  } , 
Original file line number Diff line number Diff line change @@ -20,6 +20,15 @@ export default {
2020        return  this . listDomainsOpts ( true ) ; 
2121      } , 
2222    } , 
23+     folderId : { 
24+       type : "string" , 
25+       label : "Folder ID" , 
26+       description : "The folder to use." , 
27+       optional : true , 
28+       async  options ( {  domainId } )  { 
29+         return  this . listFolderOptions ( domainId ) ; 
30+       } , 
31+     } , 
2332    originalURL : { 
2433      type : "string" , 
2534      label : "Original URL" , 
@@ -325,5 +334,21 @@ export default {
325334      } ) ) ; 
326335      return  response ; 
327336    } , 
337+     async  getDomainInfo ( domainId )  { 
338+       return  axios ( this ,  this . _getRequestParams ( { 
339+         path : `/domains/${ domainId }  , 
340+       } ) ) ; 
341+     } , 
342+     async  listFolderOptions ( domainId )  { 
343+       const  response  =  await  axios ( this ,  this . _getRequestParams ( { 
344+         path : `/links/folders/${ domainId }  , 
345+       } ) ) ; 
346+       return  response . linkFolders ?. map ( ( { 
347+         id,  name, 
348+       } )  =>  ( { 
349+         label : name , 
350+         value : id , 
351+       } ) ) ; 
352+     } , 
328353  } , 
329354} ; 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments