mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
n8n-3867-progressively-apply-prettier-to-all (#3873)
* 🔨 formatting nodes with prettier
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
@@ -12,16 +10,9 @@ import {
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
AttributesValuesUi,
|
||||
CommentAnalyzeBody,
|
||||
Language,
|
||||
RequestedAttributes,
|
||||
} from './types';
|
||||
import { AttributesValuesUi, CommentAnalyzeBody, Language, RequestedAttributes } from './types';
|
||||
|
||||
import {
|
||||
googleApiRequest,
|
||||
} from './GenericFunctions';
|
||||
import { googleApiRequest } from './GenericFunctions';
|
||||
|
||||
const ISO6391 = require('iso-639-1');
|
||||
|
||||
@@ -30,21 +21,15 @@ export class GooglePerspective implements INodeType {
|
||||
displayName: 'Google Perspective',
|
||||
name: 'googlePerspective',
|
||||
icon: 'file:perspective.svg',
|
||||
group: [
|
||||
'transform',
|
||||
],
|
||||
group: ['transform'],
|
||||
version: 1,
|
||||
description: 'Consume Google Perspective API',
|
||||
subtitle: '={{$parameter["operation"]}}',
|
||||
defaults: {
|
||||
name: 'Google Perspective',
|
||||
},
|
||||
inputs: [
|
||||
'main',
|
||||
],
|
||||
outputs: [
|
||||
'main',
|
||||
],
|
||||
inputs: ['main'],
|
||||
outputs: ['main'],
|
||||
credentials: [
|
||||
{
|
||||
name: 'googlePerspectiveOAuth2Api',
|
||||
@@ -73,9 +58,7 @@ export class GooglePerspective implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'analyzeComment',
|
||||
],
|
||||
operation: ['analyzeComment'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -91,9 +74,7 @@ export class GooglePerspective implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'analyzeComment',
|
||||
],
|
||||
operation: ['analyzeComment'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -139,7 +120,8 @@ export class GooglePerspective implements INodeType {
|
||||
value: 'toxicity',
|
||||
},
|
||||
],
|
||||
description: 'Attribute to analyze in the text. Details <a href="https://developers.perspectiveapi.com/s/about-the-api-attributes-and-languages">here</a>.',
|
||||
description:
|
||||
'Attribute to analyze in the text. Details <a href="https://developers.perspectiveapi.com/s/about-the-api-attributes-and-languages">here</a>.',
|
||||
default: 'flirtation',
|
||||
},
|
||||
{
|
||||
@@ -151,7 +133,8 @@ export class GooglePerspective implements INodeType {
|
||||
minValue: 0,
|
||||
maxValue: 1,
|
||||
},
|
||||
description: 'Score above which to return results. At zero, all scores are returned.',
|
||||
description:
|
||||
'Score above which to return results. At zero, all scores are returned.',
|
||||
default: 0,
|
||||
},
|
||||
],
|
||||
@@ -164,9 +147,7 @@ export class GooglePerspective implements INodeType {
|
||||
type: 'collection',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'analyzeComment',
|
||||
],
|
||||
operation: ['analyzeComment'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
@@ -180,7 +161,8 @@ export class GooglePerspective implements INodeType {
|
||||
loadOptionsMethod: 'getLanguages',
|
||||
},
|
||||
default: '',
|
||||
description: 'Languages of the text input. If unspecified, the API will auto-detect the comment language. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'Languages of the text input. If unspecified, the API will auto-detect the comment language. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -203,7 +185,9 @@ export class GooglePerspective implements INodeType {
|
||||
'Russian',
|
||||
];
|
||||
|
||||
const languages = ISO6391.getAllNames().filter((language: string) => supportedLanguages.includes(language));
|
||||
const languages = ISO6391.getAllNames().filter((language: string) =>
|
||||
supportedLanguages.includes(language),
|
||||
);
|
||||
for (const language of languages) {
|
||||
const languageName = language;
|
||||
const languageId = ISO6391.getCode(language);
|
||||
@@ -226,22 +210,21 @@ export class GooglePerspective implements INodeType {
|
||||
let responseData;
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
|
||||
try {
|
||||
|
||||
|
||||
if (operation === 'analyzeComment') {
|
||||
|
||||
// https://developers.perspectiveapi.com/s/about-the-api-methods
|
||||
|
||||
const attributes = this.getNodeParameter(
|
||||
'requestedAttributesUi.requestedAttributesValues', i, [],
|
||||
'requestedAttributesUi.requestedAttributesValues',
|
||||
i,
|
||||
[],
|
||||
) as AttributesValuesUi[];
|
||||
|
||||
if (!attributes.length) {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'Please enter at least one attribute to analyze.', { itemIndex: i },
|
||||
'Please enter at least one attribute to analyze.',
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -268,10 +251,13 @@ export class GooglePerspective implements INodeType {
|
||||
body.languages = languages;
|
||||
}
|
||||
|
||||
responseData = await googleApiRequest.call(this, 'POST', '/v1alpha1/comments:analyze', body);
|
||||
responseData = await googleApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
'/v1alpha1/comments:analyze',
|
||||
body,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
returnData.push({ error: error.message });
|
||||
@@ -283,7 +269,6 @@ export class GooglePerspective implements INodeType {
|
||||
Array.isArray(responseData)
|
||||
? returnData.push(...responseData)
|
||||
: returnData.push(responseData);
|
||||
|
||||
}
|
||||
|
||||
return [this.helpers.returnJsonArray(responseData)];
|
||||
|
||||
Reference in New Issue
Block a user