feat(HTTP Request Node): Redesign and add the ability to import cURL commands (#3860)

*  Initial commit

* 👕 Fix linting issue

*  Add import button

*  Remove ligh versioning

*  Improvements

*  Improvements

* 🔥 Remove HttpRequest2 file used for testing

* 🐛 Fix building issue

*  Small improvement

* 👕 Fix linting issue

* 🔥 Remove HttpRequest2 from loader

*  Update package-lock.json

*  Improvements

*  Small change

* 🐛 Fix issue retrieving splitIntoItems

* 🐛 Fix issue retrieving neverError parameter

* 🐛 Fix issue with displayOptions

*  Improvements

*  Improvements

*  Improvements

*  Improvements

*  Move cURL section to its own component

*  Improvements

*  Improvements

*  Add fix for  batching in all versions

*  Add notice to cURL modal

* 🔥 Remove comments

*  Improvements

*  Type curl-to-json endpoint

*  Fix typo

* 🔥 Remove console.logs

*  Fix typo in curl-to-json endpoint

*  Improvements

*  Improvements

*  Update package-lock.json

*  Rename import modal constant

*  Add return types to methods

*  Add CSS modules to ImportParameter component

*  Rename ImportParameter component to use kebab-case

*  Improvements

*  update package-lock.json

*  Fix linting issues

* Fix issue with css reference in ImportParameter component

*  Small improvements

*  Rename redirects to redirect

*  Allow to set multiple parameters on valueChanged

* 👕 Fix linting issue

* 🐛 Add mistakenly removed openExistingCredentials

*  Improve curl regex

*  Keep  headers as defined in the cURL command

*  Account for all protocols supported by cURL

*  Add tests

* 🔥 Remove unnecessary lines

*  Add more testing

*  Add noDataExpression to dependent fields

* 🐛 Fix bug not handling multipart-form data correctly

*  Change error messages

* 🐛 Fix response format string for empty values

* Fix typo
This commit is contained in:
Ricardo Espinoza
2022-09-29 17:28:02 -04:00
committed by GitHub
parent 5526057efc
commit f37d6ba03b
25 changed files with 5816 additions and 1805 deletions

View File

@@ -43,6 +43,7 @@ import { FindManyOptions, getConnectionManager, In } from 'typeorm';
// eslint-disable-next-line import/no-extraneous-dependencies
import axios, { AxiosRequestConfig } from 'axios';
import clientOAuth1, { RequestOptions } from 'oauth-1.0a';
import curlconverter from 'curlconverter';
// IMPORTANT! Do not switch to anther bcrypt library unless really necessary and
// tested with all possible systems like Windows, Alpine on ARM, FreeBSD, ...
import { compare } from 'bcryptjs';
@@ -96,6 +97,7 @@ import { AUTH_COOKIE_NAME, RESPONSE_ERROR_MESSAGES } from './constants';
import { credentialsController } from './credentials/credentials.controller';
import { oauth2CredentialController } from './credentials/oauth2Credential.api';
import type {
CurlHelper,
ExecutionRequest,
NodeListSearchRequest,
NodeParameterOptionsRequest,
@@ -151,6 +153,8 @@ import {
import glob from 'fast-glob';
import { ResponseError } from './ResponseHelper';
import { toHttpNodeParameters } from './CurlConverterHelper';
require('body-parser-xml')(bodyParser);
const exec = promisify(callbackExec);
@@ -1061,6 +1065,27 @@ class App {
}),
);
// ----------------------------------------
// curl-converter
// ----------------------------------------
this.app.post(
`/${this.restEndpoint}/curl-to-json`,
ResponseHelper.send(
async (
req: CurlHelper.ToJson,
res: express.Response,
): Promise<{ [key: string]: string }> => {
const curlCommand = req.body.curlCommand ?? '';
try {
const parameters = toHttpNodeParameters(curlCommand);
return ResponseHelper.flattenObject(parameters, 'parameters');
} catch (e) {
throw new ResponseHelper.ResponseError(`Invalid cURL command`, undefined, 400);
}
},
),
);
// ----------------------------------------
// Credential-Types
// ----------------------------------------