Skip to content
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

Implement copy as curl #198

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions skyvern-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions skyvern-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"cors": "^2.8.5",
"embla-carousel-react": "^8.0.0",
"express": "^4.19.2",
"fetch-to-curl": "^0.6.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.51.1",
Expand Down
26 changes: 25 additions & 1 deletion skyvern-frontend/src/routes/tasks/create/CreateNewTaskForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import {
} from "@/components/ui/tooltip";
import { ToastAction } from "@radix-ui/react-toast";
import { Link } from "react-router-dom";
import fetchToCurl from "fetch-to-curl";
import { apiBaseUrl, envCredential } from "@/util/env";

const createNewTaskFormSchema = z.object({
url: z.string().url({
Expand All @@ -57,6 +59,7 @@ function createTaskRequestObject(formValues: CreateNewTaskFormValues) {
navigation_goal: formValues.navigationGoal ?? "",
data_extraction_goal: formValues.dataExtractionGoal ?? "",
proxy_location: "NONE",
error_code_mapping: null,
navigation_payload: formValues.navigationPayload ?? "",
extracted_information_schema: formValues.extractedInformationSchema ?? "",
};
Expand Down Expand Up @@ -286,7 +289,28 @@ function CreateNewTaskForm({ initialValues }: Props) {
)}
/>
<div className="flex justify-end gap-3">
<Button variant="outline">Copy cURL</Button>
<Button
type="button"
variant="outline"
onClick={async () => {
const curl = fetchToCurl({
method: "POST",
url: `${apiBaseUrl}/tasks`,
body: createTaskRequestObject(form.getValues()),
headers: {
"Content-Type": "application/json",
"x-api-key": envCredential ?? "",
},
});
await navigator.clipboard.writeText(curl);
toast({
title: "Copied cURL",
description: "cURL copied to clipboard",
});
}}
>
Copy cURL
</Button>
<Button type="submit">Create</Button>
</div>
</form>
Expand Down
Loading