Skip to content

[Feat]: Add Import from cURL in Query Library #1803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 24, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
edits in querycomp
  • Loading branch information
iamfaran committed Jun 23, 2025
commit 850ccdab5bd864a8e4b6716964ffeedda5daade3
48 changes: 39 additions & 9 deletions client/packages/lowcoder/src/comps/queries/queryComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -743,18 +743,48 @@ class QueryListComp extends QueryListTmpComp implements BottomResListComp {
const name = this.genNewName(editorState);
const compType = extraInfo?.compType || "js";
const dataSourceId = extraInfo?.dataSourceId;
const curlData = extraInfo?.curlData;
console.log("CURL DATA", curlData)



// Build the payload that will be pushed to the list
let payload: any = {
id: id,
name: name,
datasourceId: dataSourceId,
compType,
triggerType: manualTriggerResource.includes(compType) ? "manual" : "automatic",
isNewCreate: true,
order: Date.now(),
};

// If this is a REST API created from cURL, pre-populate the HTTP query fields
if (compType === "restApi" && curlData) {
const headersArr = curlData.header
? Object.entries(curlData.header).map(([key, value]) => ({ key, value }))
: [{ key: "", value: "" }];
const paramsArr = curlData.params
? Object.entries(curlData.params).map(([key, value]) => ({ key, value }))
: [{ key: "", value: "" }];

payload = {
...payload,
comp: {
httpMethod: curlData.method || "GET",
path: curlData.url || "",
headers: headersArr,
params: paramsArr,
bodyType: curlData.body ? "application/json" : "none",
body: curlData.body ? JSON.stringify(curlData.body, null, 2) : "",
bodyFormData: [{ key: "", value: "", type: "text" }],
},
};
}

this.dispatch(
wrapActionExtraInfo(
this.pushAction({
id: id,
name: name,
datasourceId: dataSourceId,
compType,
triggerType: manualTriggerResource.includes(compType) ? "manual" : "automatic",
isNewCreate: true,
order: Date.now(),
}),
this.pushAction(payload),
{
compInfos: [
{
Expand Down