Skip to content
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
15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "root",
"private": true,
"devDependencies": {
"@babel/core": "7.29.6",
"@babel/preset-env": "7.29.5",
"@babel/core": "8.0.1",
"@babel/preset-env": "8.0.2",
"@biomejs/biome": "2.4.7",
"@esbuild-plugins/tsconfig-paths": "0.1.2",
"@swc/core": "1.13.5",
Expand All @@ -17,7 +17,7 @@
"husky": "8.0.3",
"jest": "30.0.5",
"kill-port": "1.6.1",
"lerna": "10.0.0",
"lerna": "10.0.1",
"load-tsconfig": "0.2.5",
"prettier": "3.5.3",
"prettier-plugin-svelte": "3.4.0",
Expand Down Expand Up @@ -79,7 +79,7 @@
"env:selfhost:disable": "node scripts/dev/selfhost.js disable",
"mode:self": "yarn env:selfhost:enable && yarn env:multi:disable && yarn env:account:disable",
"mode:cloud": "yarn env:selfhost:disable && yarn env:multi:enable && yarn env:account:disable",
"security:audit": "yarn audit-ci --moderate --config .audit-ci.json",
"security:audit": "yarn audit-ci --high --config .audit-ci.json",
"postinstall": "husky install",
"add-app-migration": "node scripts/add-app-migration.js --title"
},
Expand All @@ -93,22 +93,19 @@
"@supertoolmake/shared-core": "*",
"@supertoolmake/string-templates": "*",
"@supertoolmake/types": "*",
"tough-cookie": "4.1.3",
"node-fetch": "2.6.7",
"semver": "7.5.3",
"http-cache-semantics": "4.1.1",
"msgpackr": "1.10.1",
"axios": "1.18.0",
"xml2js": "0.6.2",
"passport": "0.6.0",
"nodemailer": "9.0.1",
"fast-xml-parser": "5.7.3",
"follow-redirects": "1.16.0",
"form-data": "4.0.6",
"@azure/identity": "4.2.1",
"kind-of": "6.0.3",
"**/nan": "2.22.0",
"globals": "15.13.0",
"esm": "npm:esm-wallaby@3.2.35",
"@types/koa": "3.0.1",
"@smithy/node-http-handler": "4.4.16",
Expand All @@ -122,7 +119,9 @@
"js-yaml": "4.3.1",
"tar": "7.5.21",
"fast-uri": "3.1.5",
"postcss": "8.5.26"
"postcss": "8.5.26",
"browserslist": "4.28.7",
"pacote": "21.5.1"
},
"engines": {
"node": ">=22.22.0 <23.0.0"
Expand Down
9 changes: 1 addition & 8 deletions packages/builder/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,5 @@ module.exports = {
presets: ["@babel/preset-env"],
sourceMaps: "inline",
retainLines: true,
plugins: [
[
"@babel/plugin-transform-runtime",
{
regenerator: true,
},
],
],
plugins: ["@babel/plugin-transform-runtime"],
}
5 changes: 3 additions & 2 deletions packages/builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,16 @@
"yup": "1.7.1"
},
"devDependencies": {
"@babel/plugin-transform-runtime": "7.29.0",
"@babel/preset-env": "7.29.5",
"@babel/plugin-transform-runtime": "8.0.1",
"@babel/preset-env": "8.0.2",
"@rollup/plugin-replace": "6.0.3",
"@roxi/routify": "3.6.4",
"@supertoolmake/client": "*",
"@sveltejs/vite-plugin-svelte": "7.1.2",
"@testing-library/jest-dom": "6.4.2",
"@testing-library/svelte": "5.2.8",
"identity-obj-proxy": "3.0.0",
"jsdom": "30.0.1",
"resize-observer-polyfill": "1.5.1",
"svelte-jester": "1.3.2",
"vite": "8.0.16",
Expand Down
2 changes: 1 addition & 1 deletion packages/server/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const baseConfig: Config = {
"^.+\\.svelte?$": "<rootDir>/scripts/svelteTransformer.js",
},
transformIgnorePatterns: [
"/node_modules/(?!(svelte|esm-env|devalue|archiver|compress-commons|crc32-stream|zip-stream|is-stream)/)",
"/node_modules/(?!(svelte|esm-env|devalue|archiver|compress-commons|crc32-stream|zip-stream|is-stream|curlconverter)/)",
],
moduleNameMapper: {
"@supertoolmake/backend-core/(.*)": "<rootDir>/../backend-core/$1",
Expand Down
9 changes: 4 additions & 5 deletions packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"content-disposition": "0.5.4",
"cookies": "0.8.0",
"csvtojson": "2.0.13",
"curlconverter": "3.21.0",
"curlconverter": "4.12.0",
"dayjs": "1.10.8",
"dotenv": "8.2.0",
"form-data": "4.0.6",
Expand All @@ -76,12 +76,11 @@
"koa-useragent": "4.1.0",
"koa2-ratelimit": "1.1.3",
"lodash": "4.18.1",
"mailparser": "3.9.15",
"memorystream": "0.3.1",
"minio": "8.0.7",
"mongodb": "6.7.0",
"mssql": "12.5.4",
"mysql2": "3.9.8",
"mysql2": "3.22.0",
"nano": "11.0.6",
"node-fetch": "2.6.7",
"openapi-types": "9.3.1",
Expand All @@ -99,8 +98,8 @@
"zod-validation-error": "5.0.0"
},
"devDependencies": {
"@babel/core": "7.29.6",
"@babel/preset-env": "7.29.5",
"@babel/core": "8.0.1",
"@babel/preset-env": "8.0.2",
"@types/formidable": "^3.4.6",
"@types/global-agent": "2.1.1",
"@types/js-yaml": "^4.0.9",
Expand Down
5 changes: 4 additions & 1 deletion packages/server/scripts/svelteTransformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ module.exports = {
css: "injected",
generate: "server",
})
const { code } = transformSync(js.code, { babelrc: true })
const { code } = transformSync(js.code, {
babelrc: true,
presets: [["@babel/preset-env", { targets: { node: "current" }, modules: "commonjs" }]],
})
return { code: code }
},
}
47 changes: 30 additions & 17 deletions packages/server/src/api/controllers/query/import/sources/curl.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
import { URL } from "node:url"
import type { JSONOutput } from "curlconverter"
import type { Query } from "../../../../../definitions/common"
import { type GetQueriesOptions, type ImportInfo, ImportSource } from "./base"

const curlconverter = require("curlconverter")

const parseCurl = (data: string): Promise<any> => {
const curlJson = curlconverter.toJsonString(data)
return JSON.parse(curlJson)
const parseCurl = async (data: string): Promise<JSONOutput> => {
const { toJsonObject } = await import("curlconverter")
return toJsonObject(data)
}

/**
* The curl converter parses the request body into the key field of an object
* e.g. --d '{"key":"val"}' produces an object { "{"key":"val"}" : "" }
* This is not what we want, so we need to parse out the key from the object
*/
const parseBody = (curl: any) => {
const parseBody = (curl: JSONOutput) => {
if (curl.data) {
if (typeof curl.data === "string") {
try {
return JSON.parse(curl.data)
} catch {
return curl.data
}
}
const keys = Object.keys(curl.data)
if (keys.length) {
let key = keys[0]
try {
// filter out the dollar syntax used by curl for shell support
if (key.startsWith("$")) {
key = key.substring(1)
}
Expand All @@ -33,7 +38,7 @@ const parseBody = (curl: any) => {
return
}

const parseCookie = (curl: any) => {
const parseCookie = (curl: JSONOutput) => {
if (curl.cookies) {
return Object.entries(curl.cookies).reduce((acc, entry) => {
const [key, value] = entry
Expand All @@ -49,24 +54,32 @@ const parseCookie = (curl: any) => {
* https://curl.se/docs/manpage.html
*/
export class Curl extends ImportSource {
curl: any
curl: JSONOutput | undefined

private getCurl(): JSONOutput {
if (!this.curl) {
throw new Error("Curl not parsed, call isSupported first")
}
return this.curl
}

isSupported = async (data: string): Promise<boolean> => {
try {
this.curl = parseCurl(data)
this.curl = await parseCurl(data)
} catch {
return false
}
return true
}

getUrl = (): URL => {
return new URL(this.curl.raw_url)
return new URL(this.getCurl().raw_url)
}

getInfo = async (): Promise<ImportInfo> => {
const curl = this.getCurl()
const url = this.getUrl()
const method = this.curl.method
const method = curl.method
const path = url.pathname
return {
name: url.hostname,
Expand All @@ -78,7 +91,6 @@ export class Curl extends ImportSource {
name: path || url.hostname,
method: method?.toUpperCase(),
path,
description: this.curl.description,
queryVerb: this.verbFromMethod(method),
},
],
Expand All @@ -90,21 +102,22 @@ export class Curl extends ImportSource {
}

getQueries = async (datasourceId: string, options?: GetQueriesOptions): Promise<Query[]> => {
const curl = this.getCurl()
const url = this.getUrl()
const name = url.pathname
const path = url.origin + url.pathname
const method = this.curl.method
const method = curl.method
const queryString = url.search
const headers = this.curl.headers
const requestBody = parseBody(this.curl)
const headers = curl.headers ?? {}
const requestBody = parseBody(curl)
const filterIds = options?.filterIds
const endpointId = this.buildEndpointId(method, url.pathname)

if (filterIds && !filterIds.has(endpointId)) {
return []
}

const cookieHeader = parseCookie(this.curl)
const cookieHeader = parseCookie(curl)
if (cookieHeader) {
headers.Cookie = cookieHeader
}
Expand Down
2 changes: 1 addition & 1 deletion packages/worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"nock": "^13.5.4",
"nodemon": "3.1.14",
"rimraf": "3.0.2",
"mailparser": "^3.9.20",
"mailparser": "3.9.20",
"smtp-server": "^3.13.4",
"superagent": "^10.1.1",
"supertest": "7.2.2",
Expand Down
Loading
Loading