mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
n8n-3867-progressively-apply-prettier-to-all (#3873)
* 🔨 formatting nodes with prettier
This commit is contained in:
@@ -1,20 +1,18 @@
|
||||
import {
|
||||
OptionsWithUri
|
||||
} from 'request';
|
||||
import { OptionsWithUri } from 'request';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
INodePropertyOptions,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
import { IDataObject, INodePropertyOptions, NodeApiError, NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
export async function homeAssistantApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: string, body: IDataObject = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}) {
|
||||
export async function homeAssistantApiRequest(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
method: string,
|
||||
resource: string,
|
||||
body: IDataObject = {},
|
||||
qs: IDataObject = {},
|
||||
uri?: string,
|
||||
option: IDataObject = {},
|
||||
) {
|
||||
const credentials = await this.getCredentials('homeAssistantApi');
|
||||
|
||||
let options: OptionsWithUri = {
|
||||
@@ -24,7 +22,11 @@ export async function homeAssistantApiRequest(this: IExecuteFunctions | ILoadOpt
|
||||
method,
|
||||
qs,
|
||||
body,
|
||||
uri: uri ?? `${credentials.ssl === true ? 'https' : 'http'}://${credentials.host}:${credentials.port}/api${resource}`,
|
||||
uri:
|
||||
uri ??
|
||||
`${credentials.ssl === true ? 'https' : 'http'}://${credentials.host}:${
|
||||
credentials.port
|
||||
}/api${resource}`,
|
||||
json: true,
|
||||
};
|
||||
|
||||
@@ -41,13 +43,16 @@ export async function homeAssistantApiRequest(this: IExecuteFunctions | ILoadOpt
|
||||
}
|
||||
}
|
||||
|
||||
export async function getHomeAssistantEntities(this: IExecuteFunctions | ILoadOptionsFunctions, domain = '') {
|
||||
export async function getHomeAssistantEntities(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
domain = '',
|
||||
) {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const entities = await homeAssistantApiRequest.call(this, 'GET', '/states');
|
||||
for (const entity of entities) {
|
||||
const entityId = entity.entity_id as string;
|
||||
if (domain === '' || domain && entityId.startsWith(domain)) {
|
||||
const entityName = entity.attributes.friendly_name as string || entityId;
|
||||
if (domain === '' || (domain && entityId.startsWith(domain))) {
|
||||
const entityName = (entity.attributes.friendly_name as string) || entityId;
|
||||
returnData.push({
|
||||
name: entityName,
|
||||
value: entityId,
|
||||
@@ -57,7 +62,10 @@ export async function getHomeAssistantEntities(this: IExecuteFunctions | ILoadOp
|
||||
return returnData;
|
||||
}
|
||||
|
||||
export async function getHomeAssistantServices(this: IExecuteFunctions | ILoadOptionsFunctions, domain = '') {
|
||||
export async function getHomeAssistantServices(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
domain = '',
|
||||
) {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const services = await homeAssistantApiRequest.call(this, 'GET', '/services');
|
||||
if (domain === '') {
|
||||
|
||||
Reference in New Issue
Block a user