Add Activepieces integration for workflow automation
- Add Activepieces fork with SmoothSchedule custom piece - Create integrations app with Activepieces service layer - Add embed token endpoint for iframe integration - Create Automations page with embedded workflow builder - Add sidebar visibility fix for embed mode - Add list inactive customers endpoint to Public API - Include SmoothSchedule triggers: event created/updated/cancelled - Include SmoothSchedule actions: create/update/cancel events, list resources/services/customers 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"Authorize URL": "Autorisierungs-URL",
|
||||
"Token URL": "Token-URL",
|
||||
"Scopes (whitespace separated)": "Bereiche (Leerzeichen getrennt)",
|
||||
"OAuth2 Authorize URL": "OAuth2 Autorisierungs-URL",
|
||||
"OAuth2 Token URL": "OAuth2 Token URL",
|
||||
"OAuth2 Scopes": "OAuth2 Bereiche",
|
||||
"OAuth2": "OAuth2",
|
||||
"Send an OAuth2 Request": "OAuth2 Anfrage senden",
|
||||
"Sends HTTP request to a specified URL that requires OAuth 2.0 authorization and returns the response.": "Sendet HTTP-Anfrage an eine angegebene URL, die OAuth 2.0 Autorisierung erfordert und gibt die Antwort zurück.",
|
||||
"URL": "URL",
|
||||
"Method": "Methode",
|
||||
"Headers": "Kopfzeilen",
|
||||
"Query Parameters": "Abfrageparameter",
|
||||
"Body Type": "Körpertyp",
|
||||
"Body": "Körper",
|
||||
"Use Proxy": "Proxy verwenden",
|
||||
"Proxy Settings": "Proxy-Einstellungen",
|
||||
"No Error on Failure": "Kein Fehler bei Fehler",
|
||||
"Timeout (in seconds)": "Timeout (in Sekunden)",
|
||||
"Use a proxy for this request": "Proxy für diese Anfrage verwenden",
|
||||
"GET": "ERHALTEN",
|
||||
"POST": "POST",
|
||||
"PUT": "PUT",
|
||||
"PATCH": "PATCH",
|
||||
"DELETE": "LÖSCHEN",
|
||||
"None": "Keine",
|
||||
"Form Data": "Formulardaten",
|
||||
"JSON": "JSON",
|
||||
"Raw": "Rohe"
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"Authorize URL": "Autorizar URL",
|
||||
"Token URL": "URL del token",
|
||||
"Scopes (whitespace separated)": "Ámbitos (espacios en blanco separados)",
|
||||
"OAuth2 Authorize URL": "OAuth2 autorizar URL",
|
||||
"OAuth2 Token URL": "URL de Token de OAuth2",
|
||||
"OAuth2 Scopes": "OAuth2 Scopes",
|
||||
"OAuth2": "OAuth2",
|
||||
"Send an OAuth2 Request": "Enviar una solicitud de OAuth2",
|
||||
"Sends HTTP request to a specified URL that requires OAuth 2.0 authorization and returns the response.": "Envía la solicitud HTTP a una URL especificada que requiere la autorización de OAuth 2.0 y devuelve la respuesta.",
|
||||
"URL": "URL",
|
||||
"Method": "Método",
|
||||
"Headers": "Encabezados",
|
||||
"Query Parameters": "Parámetros de consulta",
|
||||
"Body Type": "Tipo de cuerpo",
|
||||
"Body": "Cuerpo",
|
||||
"Use Proxy": "Usar proxy",
|
||||
"Proxy Settings": "Ajustes del proxy",
|
||||
"No Error on Failure": "No hay ningún error en fallo",
|
||||
"Timeout (in seconds)": "Tiempo de espera (en segundos)",
|
||||
"Use a proxy for this request": "Usar un proxy para esta solicitud",
|
||||
"GET": "RECOGER",
|
||||
"POST": "POST",
|
||||
"PUT": "PUT",
|
||||
"PATCH": "PATCH",
|
||||
"DELETE": "BORRAR",
|
||||
"None": "Ninguna",
|
||||
"Form Data": "Datos de Formulario",
|
||||
"JSON": "JSON",
|
||||
"Raw": "Rápido"
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"Authorize URL": "Autoriser l'URL",
|
||||
"Token URL": "URL du jeton",
|
||||
"Scopes (whitespace separated)": "Portées (séparées par des espaces)",
|
||||
"OAuth2 Authorize URL": "URL d'autorisation OAuth2",
|
||||
"OAuth2 Token URL": "URL du jeton OAuth2",
|
||||
"OAuth2 Scopes": "Portées OAuth2",
|
||||
"OAuth2": "OAuth2",
|
||||
"Send an OAuth2 Request": "Envoyer une requête OAuth2",
|
||||
"Sends HTTP request to a specified URL that requires OAuth 2.0 authorization and returns the response.": "Envoie une requête HTTP à une URL spécifiée qui nécessite une autorisation OAuth 2.0 et renvoie la réponse.",
|
||||
"URL": "URL",
|
||||
"Method": "Méthode",
|
||||
"Headers": "En-têtes",
|
||||
"Query Parameters": "Paramètres de requête",
|
||||
"Body Type": "Type de Corps",
|
||||
"Body": "Corps",
|
||||
"Use Proxy": "Utiliser le proxy",
|
||||
"Proxy Settings": "Paramètres du proxy",
|
||||
"No Error on Failure": "Aucune erreur en cas d'échec",
|
||||
"Timeout (in seconds)": "Délai d'attente (en secondes)",
|
||||
"Use a proxy for this request": "Utiliser un proxy pour cette requête",
|
||||
"GET": "GET",
|
||||
"POST": "POST",
|
||||
"PUT": "PUT",
|
||||
"PATCH": "PATCH",
|
||||
"DELETE": "DELETE",
|
||||
"None": "Aucun",
|
||||
"Form Data": "Données du formulaire",
|
||||
"JSON": "JSON",
|
||||
"Raw": "Brut"
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"Authorize URL": "URL を承認",
|
||||
"Token URL": "トークンURL",
|
||||
"Scopes (whitespace separated)": "スコープ (空白文字で区切る)",
|
||||
"OAuth2 Authorize URL": "OAuth2 認証URL",
|
||||
"OAuth2 Token URL": "OAuth2トークンURL",
|
||||
"OAuth2 Scopes": "OAuth2スコープ",
|
||||
"OAuth2": "OAuth2",
|
||||
"Send an OAuth2 Request": "OAuth2リクエストを送信",
|
||||
"Sends HTTP request to a specified URL that requires OAuth 2.0 authorization and returns the response.": "OAuth 2.0 認可を必要とする指定された URL に HTTP リクエストを送信し、レスポンスを返します。",
|
||||
"URL": "URL",
|
||||
"Method": "方法",
|
||||
"Headers": "ヘッダー",
|
||||
"Query Parameters": "クエリパラメータ",
|
||||
"Body Type": "ボディタイプ",
|
||||
"Body": "本文",
|
||||
"Use Proxy": "プロキシを使用",
|
||||
"Proxy Settings": "プロキシ設定",
|
||||
"No Error on Failure": "失敗時にエラーはありません",
|
||||
"Timeout (in seconds)": "タイムアウト(秒)",
|
||||
"Use a proxy for this request": "このリクエストにプロキシを使用する",
|
||||
"GET": "取得",
|
||||
"POST": "POST",
|
||||
"PUT": "PUT",
|
||||
"PATCH": "PATCH",
|
||||
"DELETE": "削除",
|
||||
"None": "なし",
|
||||
"Form Data": "フォームデータ",
|
||||
"JSON": "JSON",
|
||||
"Raw": "Raw"
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"Authorize URL": "Autoriseer URL",
|
||||
"Token URL": "URL token",
|
||||
"Scopes (whitespace separated)": "Scopes (witruimte gescheiden)",
|
||||
"OAuth2 Authorize URL": "OAuth2 Autorisatie-URL",
|
||||
"OAuth2 Token URL": "URL van de OAuth2 token",
|
||||
"OAuth2 Scopes": "OAuth2 scopes",
|
||||
"OAuth2": "OAuth2",
|
||||
"Send an OAuth2 Request": "Stuur een OAuth2 verzoek",
|
||||
"Sends HTTP request to a specified URL that requires OAuth 2.0 authorization and returns the response.": "Verstuurt het HTTP-verzoek naar een opgegeven URL die OAuth 2.0 autorisatie vereist en geeft het antwoord.",
|
||||
"URL": "URL",
|
||||
"Method": "Methode",
|
||||
"Headers": "Kopteksten",
|
||||
"Query Parameters": "Query parameters",
|
||||
"Body Type": "Type lichaam",
|
||||
"Body": "Lichaam",
|
||||
"Use Proxy": "Gebruik Proxy",
|
||||
"Proxy Settings": "Proxy Instellingen",
|
||||
"No Error on Failure": "Geen fout bij fout",
|
||||
"Timeout (in seconds)": "Time-out (in seconden)",
|
||||
"Use a proxy for this request": "Gebruik een proxy voor dit verzoek",
|
||||
"GET": "KRIJG",
|
||||
"POST": "POSTE",
|
||||
"PUT": "PUT",
|
||||
"PATCH": "BEKIJK",
|
||||
"DELETE": "VERWIJDEREN",
|
||||
"None": "geen",
|
||||
"Form Data": "Formulieren gegevens",
|
||||
"JSON": "JSON",
|
||||
"Raw": "Onbewerkte"
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"Authorize URL": "Autorizar URL",
|
||||
"Token URL": "URL do token",
|
||||
"Scopes (whitespace separated)": "Escopos (espaços em branco separados)",
|
||||
"OAuth2 Authorize URL": "URL de autorização OAuth2",
|
||||
"OAuth2 Token URL": "URL do Token OAuth2",
|
||||
"OAuth2 Scopes": "Escopos OAuth2",
|
||||
"OAuth2": "OAuth2",
|
||||
"Send an OAuth2 Request": "Enviar um pedido OAuth2",
|
||||
"Sends HTTP request to a specified URL that requires OAuth 2.0 authorization and returns the response.": "Envia a solicitação HTTP para uma URL especificada que requer autorização OAuth 2.0 e retorna a resposta.",
|
||||
"URL": "URL:",
|
||||
"Method": "Método",
|
||||
"Headers": "Cabeçalhos",
|
||||
"Query Parameters": "Parâmetros da consulta",
|
||||
"Body Type": "Tipo de Corpo",
|
||||
"Body": "Conteúdo",
|
||||
"Use Proxy": "Usar Proxy",
|
||||
"Proxy Settings": "Configurações do Proxy",
|
||||
"No Error on Failure": "Nenhum erro no Failure",
|
||||
"Timeout (in seconds)": "Tempo limite (em segundos)",
|
||||
"Use a proxy for this request": "Usar um proxy para esta requisição",
|
||||
"GET": "OBTER",
|
||||
"POST": "POSTAR",
|
||||
"PUT": "COLOCAR",
|
||||
"PATCH": "COMPRAR",
|
||||
"DELETE": "EXCLUIR",
|
||||
"None": "Nenhuma",
|
||||
"Form Data": "Dados de Formulário",
|
||||
"JSON": "JSON",
|
||||
"Raw": "RAW"
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"HTTP (OAuth2)": "HTTP (OAuth2)",
|
||||
"Authorize URL": "Авторизовать URL",
|
||||
"Token URL": "URL токена",
|
||||
"Scopes (whitespace separated)": "Области (разделенные пробелами)",
|
||||
"OAuth2 Authorize URL": "OAuth2 URL авторизации",
|
||||
"OAuth2 Token URL": "URL токена OAuth2",
|
||||
"OAuth2 Scopes": "OAuth2 Области",
|
||||
"OAuth2": "OAuth2",
|
||||
"Send an OAuth2 Request": "Отправить OAuth2 запрос",
|
||||
"Sends HTTP request to a specified URL that requires OAuth 2.0 authorization and returns the response.": "Отправляет HTTP запрос на указанный URL-адрес, который требует авторизации OAuth 2.0 и возвращает ответ.",
|
||||
"URL": "URL",
|
||||
"Method": "Метод",
|
||||
"Headers": "Заголовки",
|
||||
"Query Parameters": "Параметры запроса",
|
||||
"Body Type": "Тип тела",
|
||||
"Body": "Тело",
|
||||
"Use Proxy": "Использовать прокси",
|
||||
"Proxy Settings": "Настройки прокси",
|
||||
"No Error on Failure": "Нет ошибок при ошибке",
|
||||
"Timeout (in seconds)": "Таймаут (в секундах)",
|
||||
"Use a proxy for this request": "Использовать прокси для этого запроса",
|
||||
"GET": "ПОЛУЧИТЬ",
|
||||
"POST": "ПОСТ",
|
||||
"PUT": "ПОКУПИТЬ",
|
||||
"PATCH": "ПАТЧ",
|
||||
"DELETE": "УДАЛИТЬ",
|
||||
"None": "Нет",
|
||||
"Form Data": "Данные формы",
|
||||
"JSON": "JSON",
|
||||
"Raw": "Сырье"
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"Authorize URL": "Authorize URL",
|
||||
"Token URL": "Token URL",
|
||||
"Scopes (whitespace separated)": "Scopes (whitespace separated)",
|
||||
"OAuth2 Authorize URL": "OAuth2 Authorize URL",
|
||||
"OAuth2 Token URL": "OAuth2 Token URL",
|
||||
"OAuth2 Scopes": "OAuth2 Scopes",
|
||||
"OAuth2": "OAuth2",
|
||||
"Send an OAuth2 Request": "Send an OAuth2 Request",
|
||||
"Sends HTTP request to a specified URL that requires OAuth 2.0 authorization and returns the response.": "Sends HTTP request to a specified URL that requires OAuth 2.0 authorization and returns the response.",
|
||||
"URL": "URL",
|
||||
"Method": "Method",
|
||||
"Headers": "Headers",
|
||||
"Query Parameters": "Query Parameters",
|
||||
"Body Type": "Body Type",
|
||||
"Body": "Body",
|
||||
"Use Proxy": "Use Proxy",
|
||||
"Proxy Settings": "Proxy Settings",
|
||||
"No Error on Failure": "No Error on Failure",
|
||||
"Timeout (in seconds)": "Timeout (in seconds)",
|
||||
"Use a proxy for this request": "Use a proxy for this request",
|
||||
"GET": "GET",
|
||||
"POST": "POST",
|
||||
"PUT": "PUT",
|
||||
"PATCH": "PATCH",
|
||||
"DELETE": "DELETE",
|
||||
"None": "None",
|
||||
"Form Data": "Form Data",
|
||||
"JSON": "JSON",
|
||||
"Raw": "Raw"
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"HTTP (OAuth2)": "HTTP (OAuth2)",
|
||||
"Authorize URL": "Authorize URL",
|
||||
"Token URL": "Token URL",
|
||||
"Scopes (whitespace separated)": "Scopes (whitespace separated)",
|
||||
"OAuth2 Authorize URL": "OAuth2 Authorize URL",
|
||||
"OAuth2 Token URL": "OAuth2 Token URL",
|
||||
"OAuth2 Scopes": "OAuth2 Scopes",
|
||||
"OAuth2": "OAuth2",
|
||||
"Send an OAuth2 Request": "Send an OAuth2 Request",
|
||||
"Sends HTTP request to a specified URL that requires OAuth 2.0 authorization and returns the response.": "Sends HTTP request to a specified URL that requires OAuth 2.0 authorization and returns the response.",
|
||||
"URL": "URL",
|
||||
"Method": "Method",
|
||||
"Headers": "Headers",
|
||||
"Query Parameters": "Query Parameters",
|
||||
"Body Type": "Body Type",
|
||||
"Body": "Body",
|
||||
"Use Proxy": "Use Proxy",
|
||||
"Proxy Settings": "Proxy Settings",
|
||||
"No Error on Failure": "No Error on Failure",
|
||||
"Timeout (in seconds)": "Timeout (in seconds)",
|
||||
"Use a proxy for this request": "Use a proxy for this request",
|
||||
"GET": "GET",
|
||||
"POST": "POST",
|
||||
"PUT": "PUT",
|
||||
"PATCH": "PATCH",
|
||||
"DELETE": "DELETE",
|
||||
"None": "None",
|
||||
"Form Data": "Form Data",
|
||||
"JSON": "JSON",
|
||||
"Raw": "Raw"
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"Authorize URL": "Authorize URL",
|
||||
"Token URL": "Token URL",
|
||||
"Scopes (whitespace separated)": "Scopes (whitespace separated)",
|
||||
"OAuth2 Authorize URL": "OAuth2 Authorize URL",
|
||||
"OAuth2 Token URL": "OAuth2 Token URL",
|
||||
"OAuth2 Scopes": "OAuth2 Scopes",
|
||||
"OAuth2": "OAuth2",
|
||||
"Send an OAuth2 Request": "Send an OAuth2 Request",
|
||||
"Sends HTTP request to a specified URL that requires OAuth 2.0 authorization and returns the response.": "Sends HTTP request to a specified URL that requires OAuth 2.0 authorization and returns the response.",
|
||||
"URL": "URL",
|
||||
"Method": "方法",
|
||||
"Headers": "信头",
|
||||
"Query Parameters": "查询参数",
|
||||
"Body Type": "Body Type",
|
||||
"Body": "正文内容",
|
||||
"Use Proxy": "Use Proxy",
|
||||
"Proxy Settings": "Proxy Settings",
|
||||
"No Error on Failure": "失败时没有错误",
|
||||
"Timeout (in seconds)": "超时(秒)",
|
||||
"Use a proxy for this request": "Use a proxy for this request",
|
||||
"GET": "获取",
|
||||
"POST": "帖子",
|
||||
"PUT": "弹出",
|
||||
"PATCH": "PATCH",
|
||||
"DELETE": "删除",
|
||||
"None": "无",
|
||||
"Form Data": "表单数据",
|
||||
"JSON": "JSON",
|
||||
"Raw": "原始文件"
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import { createPiece, PieceAuth, Property } from "@activepieces/pieces-framework";
|
||||
import { httpOauth2RequestAction } from "./lib/actions/send-oauth2-http-request";
|
||||
|
||||
export const httpOauth2Auth = PieceAuth.OAuth2({
|
||||
description: 'OAuth2',
|
||||
authUrl: '{authUrl}',
|
||||
tokenUrl: '{tokenUrl}',
|
||||
required: true,
|
||||
scope: '{scopes}'.split(' '),
|
||||
grantType: 'both_client_credentials_and_authorization_code',
|
||||
props: {
|
||||
authUrl: Property.ShortText({
|
||||
displayName: 'Authorize URL',
|
||||
required: true,
|
||||
description: 'OAuth2 Authorize URL',
|
||||
}),
|
||||
tokenUrl: Property.ShortText({
|
||||
displayName: 'Token URL',
|
||||
required: true,
|
||||
description: 'OAuth2 Token URL',
|
||||
}),
|
||||
scopes: Property.ShortText({
|
||||
displayName: 'Scopes (whitespace separated)',
|
||||
required: true,
|
||||
description: 'OAuth2 Scopes',
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
export const httpOauth2ClientCredentials = createPiece({
|
||||
displayName: "HTTP (OAuth2)",
|
||||
auth: httpOauth2Auth,
|
||||
minimumSupportedRelease: '0.56.0',
|
||||
logoUrl: "https://cdn.activepieces.com/pieces/http.png",
|
||||
authors: [
|
||||
'mhshiba'
|
||||
],
|
||||
actions: [
|
||||
httpOauth2RequestAction,
|
||||
],
|
||||
triggers: [],
|
||||
});
|
||||
@@ -0,0 +1,261 @@
|
||||
import {
|
||||
AuthenticationType,
|
||||
httpClient,
|
||||
HttpError,
|
||||
HttpHeaders,
|
||||
HttpMessageBody,
|
||||
HttpMethod,
|
||||
HttpRequest,
|
||||
HttpResponse,
|
||||
QueryParams,
|
||||
} from '@activepieces/pieces-common';
|
||||
import { httpOauth2Auth } from '../..';
|
||||
import {
|
||||
createAction,
|
||||
DynamicPropsValue,
|
||||
Property,
|
||||
} from '@activepieces/pieces-framework';
|
||||
import { assertNotNullOrUndefined } from '@activepieces/shared';
|
||||
import FormData from 'form-data';
|
||||
import { HttpsProxyAgent } from 'https-proxy-agent';
|
||||
import axios from 'axios';
|
||||
|
||||
export const httpOauth2RequestAction = createAction({
|
||||
auth: httpOauth2Auth,
|
||||
name: 'send-oauth2-request',
|
||||
displayName: 'Send an OAuth2 Request',
|
||||
description:
|
||||
'Sends HTTP request to a specified URL that requires OAuth 2.0 authorization and returns the response.',
|
||||
props: {
|
||||
url: Property.ShortText({
|
||||
displayName: 'URL',
|
||||
required: true,
|
||||
}),
|
||||
method: Property.StaticDropdown({
|
||||
displayName: 'Method',
|
||||
required: true,
|
||||
options: {
|
||||
options: [
|
||||
{ value: HttpMethod.GET, label: 'GET' },
|
||||
{ value: HttpMethod.POST, label: 'POST' },
|
||||
{ value: HttpMethod.PUT, label: 'PUT' },
|
||||
{ value: HttpMethod.PATCH, label: 'PATCH' },
|
||||
{ value: HttpMethod.DELETE, label: 'DELETE' },
|
||||
],
|
||||
},
|
||||
}),
|
||||
headers: Property.Object({
|
||||
displayName: 'Headers',
|
||||
required: false,
|
||||
}),
|
||||
queryParams: Property.Object({
|
||||
displayName: 'Query Parameters',
|
||||
required: false,
|
||||
}),
|
||||
body_type: Property.StaticDropdown({
|
||||
displayName: 'Body Type',
|
||||
required: false,
|
||||
defaultValue: 'none',
|
||||
options: {
|
||||
disabled: false,
|
||||
options: [
|
||||
{
|
||||
label: 'None',
|
||||
value: 'none',
|
||||
},
|
||||
{
|
||||
label: 'Form Data',
|
||||
value: 'form_data',
|
||||
},
|
||||
{
|
||||
label: 'JSON',
|
||||
value: 'json',
|
||||
},
|
||||
{
|
||||
label: 'Raw',
|
||||
value: 'raw',
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
body: Property.DynamicProperties({
|
||||
displayName: 'Body',
|
||||
auth: httpOauth2Auth,
|
||||
refreshers: ['body_type'],
|
||||
required: false,
|
||||
props: async ({ body_type }) => {
|
||||
if (!body_type) return {};
|
||||
|
||||
const bodyTypeInput = body_type as unknown as string;
|
||||
|
||||
const fields: DynamicPropsValue = {};
|
||||
|
||||
switch (bodyTypeInput) {
|
||||
case 'none':
|
||||
break;
|
||||
case 'json':
|
||||
fields['data'] = Property.Json({
|
||||
displayName: 'JSON Body',
|
||||
required: true,
|
||||
});
|
||||
break;
|
||||
case 'raw':
|
||||
fields['data'] = Property.LongText({
|
||||
displayName: 'Raw Body',
|
||||
required: true,
|
||||
});
|
||||
break;
|
||||
case 'form_data':
|
||||
fields['data'] = Property.Object({
|
||||
displayName: 'Form Data',
|
||||
required: true,
|
||||
});
|
||||
break;
|
||||
}
|
||||
return fields;
|
||||
},
|
||||
}),
|
||||
use_proxy: Property.Checkbox({
|
||||
displayName: 'Use Proxy',
|
||||
defaultValue: false,
|
||||
description: 'Use a proxy for this request',
|
||||
required: false,
|
||||
}),
|
||||
proxy_settings: Property.DynamicProperties({
|
||||
displayName: 'Proxy Settings',
|
||||
auth: httpOauth2Auth,
|
||||
refreshers: ['use_proxy'],
|
||||
required: false,
|
||||
props: async ({ use_proxy }) => {
|
||||
if (!use_proxy) return {};
|
||||
|
||||
const fields: DynamicPropsValue = {};
|
||||
|
||||
fields['proxy_host'] = Property.ShortText({
|
||||
displayName: 'Proxy Host',
|
||||
required: true,
|
||||
});
|
||||
|
||||
fields['proxy_port'] = Property.Number({
|
||||
displayName: 'Proxy Port',
|
||||
required: true,
|
||||
});
|
||||
|
||||
fields['proxy_username'] = Property.ShortText({
|
||||
displayName: 'Proxy Username',
|
||||
required: false,
|
||||
});
|
||||
|
||||
fields['proxy_password'] = Property.ShortText({
|
||||
displayName: 'Proxy Password',
|
||||
required: false,
|
||||
});
|
||||
|
||||
return fields;
|
||||
},
|
||||
}),
|
||||
failsafe: Property.Checkbox({
|
||||
displayName: 'No Error on Failure',
|
||||
required: false,
|
||||
}),
|
||||
timeout: Property.Number({
|
||||
displayName: 'Timeout (in seconds)',
|
||||
required: false,
|
||||
}),
|
||||
},
|
||||
errorHandlingOptions: {
|
||||
continueOnFailure: { hide: true },
|
||||
retryOnFailure: { defaultValue: true },
|
||||
},
|
||||
async run(context) {
|
||||
const {
|
||||
method,
|
||||
url,
|
||||
headers,
|
||||
queryParams,
|
||||
body,
|
||||
body_type,
|
||||
timeout,
|
||||
failsafe,
|
||||
use_proxy,
|
||||
} = context.propsValue;
|
||||
const { auth } = context;
|
||||
|
||||
assertNotNullOrUndefined(method, 'Method');
|
||||
assertNotNullOrUndefined(url, 'URL');
|
||||
|
||||
const request: HttpRequest = {
|
||||
method,
|
||||
url,
|
||||
headers: headers as HttpHeaders,
|
||||
queryParams: queryParams as QueryParams,
|
||||
timeout: timeout ? timeout * 1000 : 0,
|
||||
authentication: {
|
||||
type: AuthenticationType.BEARER_TOKEN,
|
||||
token: auth.access_token,
|
||||
},
|
||||
};
|
||||
|
||||
if (body) {
|
||||
const bodyInput = body['data'];
|
||||
if (body_type === 'form_data') {
|
||||
const formData = new FormData();
|
||||
for (const key in bodyInput) {
|
||||
formData.append(key, bodyInput[key]);
|
||||
}
|
||||
request.body = formData;
|
||||
request.headers = { ...request.headers, ...formData.getHeaders() };
|
||||
} else {
|
||||
request.body = bodyInput;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (use_proxy) {
|
||||
const proxySettings = context.propsValue.proxy_settings;
|
||||
assertNotNullOrUndefined(proxySettings, 'Proxy Settings');
|
||||
assertNotNullOrUndefined(proxySettings['proxy_host'], 'Proxy Host');
|
||||
assertNotNullOrUndefined(proxySettings['proxy_port'], 'Proxy Port');
|
||||
let proxyUrl;
|
||||
|
||||
if (
|
||||
proxySettings['proxy_username'] &&
|
||||
proxySettings['proxy_password']
|
||||
) {
|
||||
proxyUrl = `http://${proxySettings['proxy_username']}:${proxySettings['proxy_password']}@${proxySettings['proxy_host']}:${proxySettings['proxy_port']}`;
|
||||
} else {
|
||||
proxyUrl = `http://${proxySettings['proxy_host']}:${proxySettings['proxy_port']}`;
|
||||
}
|
||||
|
||||
const httpsAgent = new HttpsProxyAgent(proxyUrl);
|
||||
const axiosClient = axios.create({
|
||||
httpsAgent,
|
||||
});
|
||||
|
||||
const proxied_response = await axiosClient.request(request);
|
||||
return handleResponse(proxied_response.data);
|
||||
}
|
||||
const response = await httpClient.sendRequest(request);
|
||||
return handleResponse(response);
|
||||
} catch (error) {
|
||||
if (failsafe) {
|
||||
return (error as HttpError).errorMessage();
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const handleResponse = (response: HttpResponse<HttpMessageBody>) => {
|
||||
if (
|
||||
response.headers &&
|
||||
response.headers['content-type'] === 'application/octet-stream'
|
||||
) {
|
||||
return {
|
||||
...response,
|
||||
bodyBase64: Buffer.from(response.body, 'binary').toString('base64'),
|
||||
};
|
||||
}
|
||||
return response;
|
||||
};
|
||||
Reference in New Issue
Block a user