@@ -743,18 +743,48 @@ class QueryListComp extends QueryListTmpComp implements BottomResListComp {
743
743
const name = this . genNewName ( editorState ) ;
744
744
const compType = extraInfo ?. compType || "js" ;
745
745
const dataSourceId = extraInfo ?. dataSourceId ;
746
+ const curlData = extraInfo ?. curlData ;
747
+ console . log ( "CURL DATA" , curlData )
748
+
749
+
750
+
751
+ // Build the payload that will be pushed to the list
752
+ let payload : any = {
753
+ id : id ,
754
+ name : name ,
755
+ datasourceId : dataSourceId ,
756
+ compType,
757
+ triggerType : manualTriggerResource . includes ( compType ) ? "manual" : "automatic" ,
758
+ isNewCreate : true ,
759
+ order : Date . now ( ) ,
760
+ } ;
761
+
762
+ // If this is a REST API created from cURL, pre-populate the HTTP query fields
763
+ if ( compType === "restApi" && curlData ) {
764
+ const headersArr = curlData . header
765
+ ? Object . entries ( curlData . header ) . map ( ( [ key , value ] ) => ( { key, value } ) )
766
+ : [ { key : "" , value : "" } ] ;
767
+ const paramsArr = curlData . params
768
+ ? Object . entries ( curlData . params ) . map ( ( [ key , value ] ) => ( { key, value } ) )
769
+ : [ { key : "" , value : "" } ] ;
770
+
771
+ payload = {
772
+ ...payload ,
773
+ comp : {
774
+ httpMethod : curlData . method || "GET" ,
775
+ path : curlData . url || "" ,
776
+ headers : headersArr ,
777
+ params : paramsArr ,
778
+ bodyType : curlData . body ? "application/json" : "none" ,
779
+ body : curlData . body ? JSON . stringify ( curlData . body , null , 2 ) : "" ,
780
+ bodyFormData : [ { key : "" , value : "" , type : "text" } ] ,
781
+ } ,
782
+ } ;
783
+ }
746
784
747
785
this . dispatch (
748
786
wrapActionExtraInfo (
749
- this . pushAction ( {
750
- id : id ,
751
- name : name ,
752
- datasourceId : dataSourceId ,
753
- compType,
754
- triggerType : manualTriggerResource . includes ( compType ) ? "manual" : "automatic" ,
755
- isNewCreate : true ,
756
- order : Date . now ( ) ,
757
- } ) ,
787
+ this . pushAction ( payload ) ,
758
788
{
759
789
compInfos : [
760
790
{
0 commit comments