mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
refactor: Format nodes-base package (A-F) (#3800)
* 🔨 prettier formated nodes - A * 🔨 prettier formated nodes - B * ⚡ prettier formated nodes - C * ⚡ prettier formated nodes - D * ⚡ prettier formated nodes - E-F * 🎨 Adjust nodes-base formatting command (#3805) * Format additional files in nodes A-F (#3811) * ⚡ fixes * 🎨 Add Mindee to ignored dirs Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
This commit is contained in:
@@ -1,17 +1,8 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
awsApiRequestREST,
|
||||
} from './GenericFunctions';
|
||||
import { awsApiRequestREST } from './GenericFunctions';
|
||||
|
||||
export class AwsComprehend implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -132,13 +123,8 @@ export class AwsComprehend implements INodeType {
|
||||
default: 'en',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'text',
|
||||
],
|
||||
operation: [
|
||||
'detectSentiment',
|
||||
'detectEntities',
|
||||
],
|
||||
resource: ['text'],
|
||||
operation: ['detectSentiment', 'detectEntities'],
|
||||
},
|
||||
},
|
||||
description: 'The language code for text',
|
||||
@@ -153,9 +139,7 @@ export class AwsComprehend implements INodeType {
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'text',
|
||||
],
|
||||
resource: ['text'],
|
||||
},
|
||||
},
|
||||
description: 'The text to send',
|
||||
@@ -166,16 +150,13 @@ export class AwsComprehend implements INodeType {
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'text',
|
||||
],
|
||||
operation: [
|
||||
'detectDominantLanguage',
|
||||
],
|
||||
resource: ['text'],
|
||||
operation: ['detectDominantLanguage'],
|
||||
},
|
||||
},
|
||||
default: true,
|
||||
description: 'Whether to return a simplified version of the response instead of the raw data',
|
||||
description:
|
||||
'Whether to return a simplified version of the response instead of the raw data',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
@@ -184,12 +165,8 @@ export class AwsComprehend implements INodeType {
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'text',
|
||||
],
|
||||
operation: [
|
||||
'detectEntities',
|
||||
],
|
||||
resource: ['text'],
|
||||
operation: ['detectEntities'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
@@ -202,7 +179,8 @@ export class AwsComprehend implements INodeType {
|
||||
alwaysOpenEditWindow: true,
|
||||
},
|
||||
default: '',
|
||||
description: 'The Amazon Resource Name of an endpoint that is associated with a custom entity recognition model',
|
||||
description:
|
||||
'The Amazon Resource Name of an endpoint that is associated with a custom entity recognition model',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -227,13 +205,23 @@ export class AwsComprehend implements INodeType {
|
||||
Text: text,
|
||||
};
|
||||
const action = 'Comprehend_20171127.DetectDominantLanguage';
|
||||
responseData = await awsApiRequestREST.call(this, 'comprehend', 'POST', '', JSON.stringify(body), { 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' });
|
||||
responseData = await awsApiRequestREST.call(
|
||||
this,
|
||||
'comprehend',
|
||||
'POST',
|
||||
'',
|
||||
JSON.stringify(body),
|
||||
{ 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' },
|
||||
);
|
||||
|
||||
if (simple === true) {
|
||||
responseData = responseData.Languages.reduce((accumulator: { [key: string]: number }, currentValue: IDataObject) => {
|
||||
accumulator[currentValue.LanguageCode as string] = currentValue.Score as number;
|
||||
return accumulator;
|
||||
}, {});
|
||||
responseData = responseData.Languages.reduce(
|
||||
(accumulator: { [key: string]: number }, currentValue: IDataObject) => {
|
||||
accumulator[currentValue.LanguageCode as string] = currentValue.Score as number;
|
||||
return accumulator;
|
||||
},
|
||||
{},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,7 +234,14 @@ export class AwsComprehend implements INodeType {
|
||||
Text: text,
|
||||
LanguageCode: languageCode,
|
||||
};
|
||||
responseData = await awsApiRequestREST.call(this, 'comprehend', 'POST', '', JSON.stringify(body), { 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' });
|
||||
responseData = await awsApiRequestREST.call(
|
||||
this,
|
||||
'comprehend',
|
||||
'POST',
|
||||
'',
|
||||
JSON.stringify(body),
|
||||
{ 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' },
|
||||
);
|
||||
}
|
||||
|
||||
//https://docs.aws.amazon.com/comprehend/latest/dg/API_DetectEntities.html
|
||||
@@ -265,7 +260,14 @@ export class AwsComprehend implements INodeType {
|
||||
body.EndpointArn = additionalFields.endpointArn;
|
||||
}
|
||||
|
||||
responseData = await awsApiRequestREST.call(this, 'comprehend', 'POST', '', JSON.stringify(body), { 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' });
|
||||
responseData = await awsApiRequestREST.call(
|
||||
this,
|
||||
'comprehend',
|
||||
'POST',
|
||||
'',
|
||||
JSON.stringify(body),
|
||||
{ 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' },
|
||||
);
|
||||
responseData = responseData.Entities;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user