From 1e34aca8bda1406900137dcc11cec2a574e50166 Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Tue, 12 Oct 2021 22:20:51 -0500 Subject: [PATCH] :zap: Fix build issue --- packages/core/src/NodeExecuteFunctions.ts | 6 +++--- .../nodes-base/nodes/Aws/Comprehend/GenericFunctions.ts | 3 ++- packages/nodes-base/nodes/Aws/DynamoDB/GenericFunctions.ts | 3 ++- packages/nodes-base/nodes/Aws/GenericFunctions.ts | 4 ++-- .../nodes-base/nodes/Aws/Rekognition/GenericFunctions.ts | 3 ++- packages/nodes-base/nodes/Aws/S3/GenericFunctions.ts | 3 ++- packages/nodes-base/nodes/Aws/SES/GenericFunctions.ts | 3 ++- .../nodes-base/nodes/Aws/Transcribe/GenericFunctions.ts | 4 ++-- packages/nodes-base/nodes/S3/GenericFunctions.ts | 3 ++- 9 files changed, 19 insertions(+), 13 deletions(-) diff --git a/packages/core/src/NodeExecuteFunctions.ts b/packages/core/src/NodeExecuteFunctions.ts index 2ce225badf..9e7f1bb747 100644 --- a/packages/core/src/NodeExecuteFunctions.ts +++ b/packages/core/src/NodeExecuteFunctions.ts @@ -236,11 +236,11 @@ async function parseRequestObject(requestObject: IDataObject) { } if (requestObject.uri !== undefined) { - axiosConfig.url = requestObject.uri as string; + axiosConfig.url = requestObject.uri?.toString() as string; } if (requestObject.url !== undefined) { - axiosConfig.url = requestObject.url as string; + axiosConfig.url = requestObject.url?.toString() as string; } if (requestObject.method !== undefined) { @@ -449,7 +449,7 @@ async function proxyRequestToAxios( error.cause = errorData; error.error = error.response?.data || errorData; error.statusCode = error.response?.status; - error.options = config; + error.options = config || {}; // Remove not needed data and so also remove circular references error.request = undefined; diff --git a/packages/nodes-base/nodes/Aws/Comprehend/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/Comprehend/GenericFunctions.ts index 48703ee25b..399c9ea89c 100644 --- a/packages/nodes-base/nodes/Aws/Comprehend/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/Comprehend/GenericFunctions.ts @@ -3,6 +3,7 @@ import { } from 'url'; import { + Request, sign, } from 'aws4'; @@ -47,7 +48,7 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I const endpoint = new URL(getEndpointForService(service, credentials) + path); // Sign AWS API request with the user credentials - const signOpts = { headers: headers || {}, host: endpoint.host, method, path, body }; + const signOpts = { headers: headers || {}, host: endpoint.host, method, path, body } as Request; sign(signOpts, { accessKeyId: `${credentials.accessKeyId}`.trim(), secretAccessKey: `${credentials.secretAccessKey}`.trim() }); diff --git a/packages/nodes-base/nodes/Aws/DynamoDB/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/DynamoDB/GenericFunctions.ts index faa08410da..9e71992875 100644 --- a/packages/nodes-base/nodes/Aws/DynamoDB/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/DynamoDB/GenericFunctions.ts @@ -45,9 +45,10 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I const endpoint = new URL(getEndpointForService(service, credentials) + path); const options = sign({ + // @ts-ignore uri: endpoint, service, - region: credentials.region, + region: credentials.region as string, method, path: '/', headers: { ...headers }, diff --git a/packages/nodes-base/nodes/Aws/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/GenericFunctions.ts index afea4f9e13..49fa4c3208 100644 --- a/packages/nodes-base/nodes/Aws/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/GenericFunctions.ts @@ -1,5 +1,5 @@ import { URL } from 'url'; -import { sign } from 'aws4'; +import { Request, sign } from 'aws4'; import { OptionsWithUri } from 'request'; import { parseString as parseXml } from 'xml2js'; @@ -38,7 +38,7 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I const endpoint = new URL(getEndpointForService(service, credentials) + path); // Sign AWS API request with the user credentials - const signOpts = { headers: headers || {}, host: endpoint.host, method, path, body }; + const signOpts = { headers: headers || {}, host: endpoint.host, method, path, body } as Request; sign(signOpts, { accessKeyId: `${credentials.accessKeyId}`.trim(), secretAccessKey: `${credentials.secretAccessKey}`.trim() }); diff --git a/packages/nodes-base/nodes/Aws/Rekognition/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/Rekognition/GenericFunctions.ts index b19dd1e576..dc2b1b820c 100644 --- a/packages/nodes-base/nodes/Aws/Rekognition/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/Rekognition/GenericFunctions.ts @@ -3,6 +3,7 @@ import { } from 'url'; import { + Request, sign, } from 'aws4'; @@ -44,7 +45,7 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I const endpoint = new URL(((credentials.rekognitionEndpoint as string || '').replace('{region}', credentials.region as string) || `https://${service}.${credentials.region}.amazonaws.com`) + path); // Sign AWS API request with the user credentials - const signOpts = {headers: headers || {}, host: endpoint.host, method, path, body}; + const signOpts = {headers: headers || {}, host: endpoint.host, method, path, body} as Request; sign(signOpts, { accessKeyId: `${credentials.accessKeyId}`.trim(), secretAccessKey: `${credentials.secretAccessKey}`.trim()}); diff --git a/packages/nodes-base/nodes/Aws/S3/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/S3/GenericFunctions.ts index 7d183dadde..1aa593e5c3 100644 --- a/packages/nodes-base/nodes/Aws/S3/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/S3/GenericFunctions.ts @@ -3,6 +3,7 @@ import { } from 'url'; import { + Request, sign, } from 'aws4'; @@ -38,7 +39,7 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I const endpoint = new URL(((credentials.s3Endpoint as string || '').replace('{region}', credentials.region as string) || `https://${service}.${credentials.region}.amazonaws.com`) + path); // Sign AWS API request with the user credentials - const signOpts = {headers: headers || {}, host: endpoint.host, method, path: `${endpoint.pathname}?${queryToString(query).replace(/\+/g, '%2B')}`, body}; + const signOpts = {headers: headers || {}, host: endpoint.host, method, path: `${endpoint.pathname}?${queryToString(query).replace(/\+/g, '%2B')}`, body} as Request; sign(signOpts, { accessKeyId: `${credentials.accessKeyId}`.trim(), secretAccessKey: `${credentials.secretAccessKey}`.trim()}); diff --git a/packages/nodes-base/nodes/Aws/SES/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/SES/GenericFunctions.ts index 20701651d3..09b28b7aa1 100644 --- a/packages/nodes-base/nodes/Aws/SES/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/SES/GenericFunctions.ts @@ -3,6 +3,7 @@ import { } from 'url'; import { + Request, sign, } from 'aws4'; @@ -39,7 +40,7 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I // Sign AWS API request with the user credentials - const signOpts = { headers: headers || {}, host: endpoint.host, method, path, body }; + const signOpts = { headers: headers || {}, host: endpoint.host, method, path, body } as Request; sign(signOpts, { accessKeyId: `${credentials.accessKeyId}`.trim(), secretAccessKey: `${credentials.secretAccessKey}`.trim() }); const options: OptionsWithUri = { diff --git a/packages/nodes-base/nodes/Aws/Transcribe/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/Transcribe/GenericFunctions.ts index f94823c376..ea2abe4dd1 100644 --- a/packages/nodes-base/nodes/Aws/Transcribe/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/Transcribe/GenericFunctions.ts @@ -3,6 +3,7 @@ import { } from 'url'; import { + Request, sign, } from 'aws4'; @@ -50,7 +51,7 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I const endpoint = new URL(getEndpointForService(service, credentials) + path); // Sign AWS API request with the user credentials - const signOpts = { headers: headers || {}, host: endpoint.host, method, path, body }; + const signOpts = { headers: headers || {}, host: endpoint.host, method, path, body } as Request; sign(signOpts, { accessKeyId: `${credentials.accessKeyId}`.trim(), secretAccessKey: `${credentials.secretAccessKey}`.trim() }); @@ -104,4 +105,3 @@ export async function awsApiRequestRESTAllItems(this: IHookFunctions | IExecuteF return returnData; } - diff --git a/packages/nodes-base/nodes/S3/GenericFunctions.ts b/packages/nodes-base/nodes/S3/GenericFunctions.ts index 40d2cc2719..bfdafe0583 100644 --- a/packages/nodes-base/nodes/S3/GenericFunctions.ts +++ b/packages/nodes-base/nodes/S3/GenericFunctions.ts @@ -1,4 +1,5 @@ import { + Request, sign, } from 'aws4'; @@ -62,7 +63,7 @@ export async function s3ApiRequest(this: IHookFunctions | IExecuteFunctions | IL path: `${path}?${queryToString(query).replace(/\+/g, '%2B')}`, service: 's3', body, - }; + } as Request; sign(signOpts, { accessKeyId: `${credentials.accessKeyId}`.trim(), secretAccessKey: `${credentials.secretAccessKey}`.trim() });