mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +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,15 +1,15 @@
|
||||
/* eslint-disable n8n-nodes-base/node-filename-against-convention */
|
||||
import {IExecuteFunctions} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
import {
|
||||
ILoadOptionsFunctions,
|
||||
INodeExecutionData, INodePropertyOptions,
|
||||
INodeExecutionData,
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
|
||||
import {OptionsWithUri} from 'request';
|
||||
import { OptionsWithUri } from 'request';
|
||||
import {
|
||||
getFields,
|
||||
getPortals,
|
||||
@@ -109,7 +109,8 @@ export class FileMaker implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {},
|
||||
placeholder: 'Layout Name',
|
||||
description: 'FileMaker Layout Name. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'FileMaker Layout Name. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Record ID',
|
||||
@@ -119,12 +120,7 @@ export class FileMaker implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: [
|
||||
'record',
|
||||
'edit',
|
||||
'delete',
|
||||
'duplicate',
|
||||
],
|
||||
action: ['record', 'edit', 'delete', 'duplicate'],
|
||||
},
|
||||
},
|
||||
placeholder: 'Record ID',
|
||||
@@ -139,10 +135,7 @@ export class FileMaker implements INodeType {
|
||||
default: 1,
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: [
|
||||
'find',
|
||||
'records',
|
||||
],
|
||||
action: ['find', 'records'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -158,10 +151,7 @@ export class FileMaker implements INodeType {
|
||||
default: 100,
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: [
|
||||
'find',
|
||||
'records',
|
||||
],
|
||||
action: ['find', 'records'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -173,11 +163,7 @@ export class FileMaker implements INodeType {
|
||||
description: 'Whether to get portal data as well',
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: [
|
||||
'record',
|
||||
'records',
|
||||
'find',
|
||||
],
|
||||
action: ['record', 'records', 'find'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -194,18 +180,13 @@ export class FileMaker implements INodeType {
|
||||
default: [],
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: [
|
||||
'record',
|
||||
'records',
|
||||
'find',
|
||||
],
|
||||
getPortals: [
|
||||
true,
|
||||
],
|
||||
action: ['record', 'records', 'find'],
|
||||
getPortals: [true],
|
||||
},
|
||||
},
|
||||
placeholder: 'Portals',
|
||||
description: 'The portal result set to return. Use the portal object name or portal table name. If this parameter is omitted, the API will return all portal objects and records in the layout. For best performance, pass the portal object name or portal table name. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'The portal result set to return. Use the portal object name or portal table name. If this parameter is omitted, the API will return all portal objects and records in the layout. For best performance, pass the portal object name or portal table name. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
// ----------------------------------
|
||||
// find/records
|
||||
@@ -214,7 +195,8 @@ export class FileMaker implements INodeType {
|
||||
displayName: 'Response Layout Name or ID',
|
||||
name: 'responseLayout',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getResponseLayouts',
|
||||
},
|
||||
@@ -222,9 +204,7 @@ export class FileMaker implements INodeType {
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: [
|
||||
'find',
|
||||
],
|
||||
action: ['find'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -238,9 +218,7 @@ export class FileMaker implements INodeType {
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: [
|
||||
'find',
|
||||
],
|
||||
action: ['find'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
@@ -258,30 +236,32 @@ export class FileMaker implements INodeType {
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
options: [{
|
||||
name: 'field',
|
||||
displayName: 'Field',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Field Name or ID',
|
||||
name: 'name',
|
||||
type: 'options',
|
||||
default: '',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getFields',
|
||||
options: [
|
||||
{
|
||||
name: 'field',
|
||||
displayName: 'Field',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Field Name or ID',
|
||||
name: 'name',
|
||||
type: 'options',
|
||||
default: '',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getFields',
|
||||
},
|
||||
options: [],
|
||||
description:
|
||||
'Search Field. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
options: [],
|
||||
description: 'Search Field. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Value',
|
||||
name: 'value',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Value to search',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Value',
|
||||
name: 'value',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Value to search',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
description: 'Field Name',
|
||||
},
|
||||
@@ -303,11 +283,7 @@ export class FileMaker implements INodeType {
|
||||
description: 'Whether to sort data',
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: [
|
||||
'find',
|
||||
'record',
|
||||
'records',
|
||||
],
|
||||
action: ['find', 'record', 'records'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -321,13 +297,8 @@ export class FileMaker implements INodeType {
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
setSort: [
|
||||
true,
|
||||
],
|
||||
action: [
|
||||
'find',
|
||||
'records',
|
||||
],
|
||||
setSort: [true],
|
||||
action: ['find', 'records'],
|
||||
},
|
||||
},
|
||||
description: 'Sort rules',
|
||||
@@ -346,7 +317,8 @@ export class FileMaker implements INodeType {
|
||||
loadOptionsMethod: 'getFields',
|
||||
},
|
||||
options: [],
|
||||
description: 'Field Name. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'Field Name. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Order',
|
||||
@@ -374,14 +346,11 @@ export class FileMaker implements INodeType {
|
||||
name: 'setScriptBefore',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether to define a script to be run before the action specified by the API call and after the subsequent sort',
|
||||
description:
|
||||
'Whether to define a script to be run before the action specified by the API call and after the subsequent sort',
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: [
|
||||
'find',
|
||||
'record',
|
||||
'records',
|
||||
],
|
||||
action: ['find', 'record', 'records'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -397,18 +366,13 @@ export class FileMaker implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: [
|
||||
'find',
|
||||
'record',
|
||||
'records',
|
||||
],
|
||||
setScriptBefore: [
|
||||
true,
|
||||
],
|
||||
action: ['find', 'record', 'records'],
|
||||
setScriptBefore: [true],
|
||||
},
|
||||
},
|
||||
placeholder: 'Script Name',
|
||||
description: 'The name of the FileMaker script to be run after the action specified by the API call and after the subsequent sort. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'The name of the FileMaker script to be run after the action specified by the API call and after the subsequent sort. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Script Parameter',
|
||||
@@ -417,14 +381,8 @@ export class FileMaker implements INodeType {
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: [
|
||||
'find',
|
||||
'record',
|
||||
'records',
|
||||
],
|
||||
setScriptBefore: [
|
||||
true,
|
||||
],
|
||||
action: ['find', 'record', 'records'],
|
||||
setScriptBefore: [true],
|
||||
},
|
||||
},
|
||||
placeholder: 'Script Parameters',
|
||||
@@ -435,14 +393,11 @@ export class FileMaker implements INodeType {
|
||||
name: 'setScriptSort',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether to define a script to be run after the action specified by the API call but before the subsequent sort',
|
||||
description:
|
||||
'Whether to define a script to be run after the action specified by the API call but before the subsequent sort',
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: [
|
||||
'find',
|
||||
'record',
|
||||
'records',
|
||||
],
|
||||
action: ['find', 'record', 'records'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -458,18 +413,13 @@ export class FileMaker implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: [
|
||||
'find',
|
||||
'record',
|
||||
'records',
|
||||
],
|
||||
setScriptSort: [
|
||||
true,
|
||||
],
|
||||
action: ['find', 'record', 'records'],
|
||||
setScriptSort: [true],
|
||||
},
|
||||
},
|
||||
placeholder: 'Script Name',
|
||||
description: 'The name of the FileMaker script to be run after the action specified by the API call but before the subsequent sort. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'The name of the FileMaker script to be run after the action specified by the API call but before the subsequent sort. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Script Parameter',
|
||||
@@ -478,14 +428,8 @@ export class FileMaker implements INodeType {
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: [
|
||||
'find',
|
||||
'record',
|
||||
'records',
|
||||
],
|
||||
setScriptSort: [
|
||||
true,
|
||||
],
|
||||
action: ['find', 'record', 'records'],
|
||||
setScriptSort: [true],
|
||||
},
|
||||
},
|
||||
placeholder: 'Script Parameters',
|
||||
@@ -496,14 +440,11 @@ export class FileMaker implements INodeType {
|
||||
name: 'setScriptAfter',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether to define a script to be run after the action specified by the API call but before the subsequent sort',
|
||||
description:
|
||||
'Whether to define a script to be run after the action specified by the API call but before the subsequent sort',
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: [
|
||||
'find',
|
||||
'record',
|
||||
'records',
|
||||
],
|
||||
action: ['find', 'record', 'records'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -519,18 +460,13 @@ export class FileMaker implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: [
|
||||
'find',
|
||||
'record',
|
||||
'records',
|
||||
],
|
||||
setScriptAfter: [
|
||||
true,
|
||||
],
|
||||
action: ['find', 'record', 'records'],
|
||||
setScriptAfter: [true],
|
||||
},
|
||||
},
|
||||
placeholder: 'Script Name',
|
||||
description: 'The name of the FileMaker script to be run after the action specified by the API call and after the subsequent sort. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'The name of the FileMaker script to be run after the action specified by the API call and after the subsequent sort. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Script Parameter',
|
||||
@@ -539,14 +475,8 @@ export class FileMaker implements INodeType {
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: [
|
||||
'find',
|
||||
'record',
|
||||
'records',
|
||||
],
|
||||
setScriptAfter: [
|
||||
true,
|
||||
],
|
||||
action: ['find', 'record', 'records'],
|
||||
setScriptAfter: [true],
|
||||
},
|
||||
},
|
||||
placeholder: 'Script Parameters',
|
||||
@@ -574,14 +504,13 @@ export class FileMaker implements INodeType {
|
||||
{
|
||||
displayName: 'Mod ID',
|
||||
name: 'modId',
|
||||
description: 'The last modification ID. When you use modId, a record is edited only when the modId matches.',
|
||||
description:
|
||||
'The last modification ID. When you use modId, a record is edited only when the modId matches.',
|
||||
type: 'number',
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: [
|
||||
'edit',
|
||||
],
|
||||
action: ['edit'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -595,10 +524,7 @@ export class FileMaker implements INodeType {
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: [
|
||||
'create',
|
||||
'edit',
|
||||
],
|
||||
action: ['create', 'edit'],
|
||||
},
|
||||
},
|
||||
description: 'Fields to define',
|
||||
@@ -617,7 +543,8 @@ export class FileMaker implements INodeType {
|
||||
loadOptionsMethod: 'getFields',
|
||||
},
|
||||
options: [],
|
||||
description: 'Field Name. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'Field Name. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Value',
|
||||
@@ -644,13 +571,12 @@ export class FileMaker implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: [
|
||||
'performscript',
|
||||
],
|
||||
action: ['performscript'],
|
||||
},
|
||||
},
|
||||
placeholder: 'Script Name',
|
||||
description: 'The name of the FileMaker script to be run. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'The name of the FileMaker script to be run. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Script Parameter',
|
||||
@@ -659,9 +585,7 @@ export class FileMaker implements INodeType {
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: [
|
||||
'performscript',
|
||||
],
|
||||
action: ['performscript'],
|
||||
},
|
||||
},
|
||||
placeholder: 'Script Parameters',
|
||||
@@ -766,7 +690,6 @@ export class FileMaker implements INodeType {
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
@@ -795,7 +718,7 @@ export class FileMaker implements INodeType {
|
||||
requestOptions = {
|
||||
uri: '',
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`,
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
method: 'GET',
|
||||
json: true,
|
||||
@@ -807,15 +730,15 @@ export class FileMaker implements INodeType {
|
||||
const recid = this.getNodeParameter('recid', i) as string;
|
||||
requestOptions.uri = url + `/databases/${database}/layouts/${layout}/records/${recid}`;
|
||||
requestOptions.qs = {
|
||||
'portal': JSON.stringify(parsePortals.call(this, i)),
|
||||
portal: JSON.stringify(parsePortals.call(this, i)),
|
||||
...parseScripts.call(this, i),
|
||||
};
|
||||
} else if (action === 'records') {
|
||||
requestOptions.uri = url + `/databases/${database}/layouts/${layout}/records`;
|
||||
requestOptions.qs = {
|
||||
'_offset': this.getNodeParameter('offset', i),
|
||||
'_limit': this.getNodeParameter('limit', i),
|
||||
'portal': JSON.stringify(parsePortals.call(this, i)),
|
||||
_offset: this.getNodeParameter('offset', i),
|
||||
_limit: this.getNodeParameter('limit', i),
|
||||
portal: JSON.stringify(parsePortals.call(this, i)),
|
||||
...parseScripts.call(this, i),
|
||||
};
|
||||
const sort = parseSort.call(this, i);
|
||||
@@ -826,9 +749,9 @@ export class FileMaker implements INodeType {
|
||||
requestOptions.uri = url + `/databases/${database}/layouts/${layout}/_find`;
|
||||
requestOptions.method = 'POST';
|
||||
requestOptions.body = {
|
||||
'query': parseQuery.call(this, i),
|
||||
'offset': this.getNodeParameter('offset', i),
|
||||
'limit': this.getNodeParameter('limit', i),
|
||||
query: parseQuery.call(this, i),
|
||||
offset: this.getNodeParameter('offset', i),
|
||||
limit: this.getNodeParameter('limit', i),
|
||||
'layout.response': this.getNodeParameter('responseLayout', i),
|
||||
...parseScripts.call(this, i),
|
||||
};
|
||||
@@ -843,7 +766,7 @@ export class FileMaker implements INodeType {
|
||||
|
||||
//TODO: handle portalData
|
||||
requestOptions.body = {
|
||||
fieldData: {...parseFields.call(this, i)},
|
||||
fieldData: { ...parseFields.call(this, i) },
|
||||
portalData: {},
|
||||
...parseScripts.call(this, i),
|
||||
};
|
||||
@@ -855,13 +778,14 @@ export class FileMaker implements INodeType {
|
||||
|
||||
//TODO: handle portalData
|
||||
requestOptions.body = {
|
||||
fieldData: {...parseFields.call(this, i)},
|
||||
fieldData: { ...parseFields.call(this, i) },
|
||||
portalData: {},
|
||||
...parseScripts.call(this, i),
|
||||
};
|
||||
} else if (action === 'performscript') {
|
||||
const scriptName = this.getNodeParameter('script', i) as string;
|
||||
requestOptions.uri = url + `/databases/${database}/layouts/${layout}/script/${scriptName}`;
|
||||
requestOptions.uri =
|
||||
url + `/databases/${database}/layouts/${layout}/script/${scriptName}`;
|
||||
requestOptions.qs = {
|
||||
'script.param': this.getNodeParameter('scriptParam', i),
|
||||
};
|
||||
@@ -881,7 +805,11 @@ export class FileMaker implements INodeType {
|
||||
...parseScripts.call(this, i),
|
||||
};
|
||||
} else {
|
||||
throw new NodeOperationError(this.getNode(), `The action "${action}" is not implemented yet!`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The action "${action}" is not implemented yet!`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
|
||||
// Now that the options are all set make the actual http request
|
||||
@@ -893,9 +821,13 @@ export class FileMaker implements INodeType {
|
||||
}
|
||||
|
||||
if (typeof response === 'string') {
|
||||
throw new NodeOperationError(this.getNode(), 'Response body is not valid JSON. Change "Response Format" to "String"', { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'Response body is not valid JSON. Change "Response Format" to "String"',
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
returnData.push({json: response});
|
||||
returnData.push({ json: response });
|
||||
}
|
||||
} catch (error) {
|
||||
await logout.call(this, token);
|
||||
@@ -904,7 +836,10 @@ export class FileMaker implements INodeType {
|
||||
throw error;
|
||||
}
|
||||
|
||||
throw new NodeOperationError(this.getNode(), `The action "${error.message}" is not implemented yet!`);
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The action "${error.message}" is not implemented yet!`,
|
||||
);
|
||||
}
|
||||
|
||||
return this.prepareOutputData(returnData);
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
IExecuteSingleFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject, INodePropertyOptions, NodeApiError, NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
import { IDataObject, INodePropertyOptions, NodeApiError, NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
import {OptionsWithUri} from 'request';
|
||||
import { OptionsWithUri } from 'request';
|
||||
|
||||
interface ScriptsOptions {
|
||||
script?: any; //tslint:disable-line:no-any
|
||||
@@ -21,13 +15,13 @@ interface ScriptsOptions {
|
||||
interface LayoutObject {
|
||||
name: string;
|
||||
isFolder?: boolean;
|
||||
folderLayoutNames?:LayoutObject[];
|
||||
folderLayoutNames?: LayoutObject[];
|
||||
}
|
||||
|
||||
interface ScriptObject {
|
||||
name: string;
|
||||
isFolder?: boolean;
|
||||
folderScriptNames?:LayoutObject[];
|
||||
folderScriptNames?: LayoutObject[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,7 +31,10 @@ interface ScriptObject {
|
||||
* @param {string} method
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export async function layoutsApiRequest(this: ILoadOptionsFunctions | IExecuteFunctions | IExecuteSingleFunctions): Promise<INodePropertyOptions[]> { // tslint:disable-line:no-any
|
||||
export async function layoutsApiRequest(
|
||||
this: ILoadOptionsFunctions | IExecuteFunctions | IExecuteSingleFunctions,
|
||||
): Promise<INodePropertyOptions[]> {
|
||||
// tslint:disable-line:no-any
|
||||
const token = await getToken.call(this);
|
||||
const credentials = await this.getCredentials('fileMaker');
|
||||
|
||||
@@ -47,7 +44,7 @@ export async function layoutsApiRequest(this: ILoadOptionsFunctions | IExecuteFu
|
||||
const url = `https://${host}/fmi/data/v1/databases/${db}/layouts`;
|
||||
const options: OptionsWithUri = {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`,
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
method: 'GET',
|
||||
uri: url,
|
||||
@@ -57,7 +54,7 @@ export async function layoutsApiRequest(this: ILoadOptionsFunctions | IExecuteFu
|
||||
try {
|
||||
const responseData = await this.helpers.request!(options);
|
||||
const items = parseLayouts(responseData.response.layouts);
|
||||
items.sort((a, b) => a.name > b.name ? 0 : 1);
|
||||
items.sort((a, b) => (a.name > b.name ? 0 : 1));
|
||||
return items;
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
@@ -67,7 +64,7 @@ export async function layoutsApiRequest(this: ILoadOptionsFunctions | IExecuteFu
|
||||
function parseLayouts(layouts: LayoutObject[]): INodePropertyOptions[] {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
for (const layout of layouts) {
|
||||
if (layout.isFolder!) {
|
||||
if (layout.isFolder!) {
|
||||
returnData.push(...parseLayouts(layout.folderLayoutNames!));
|
||||
} else {
|
||||
returnData.push({
|
||||
@@ -84,7 +81,10 @@ function parseLayouts(layouts: LayoutObject[]): INodePropertyOptions[] {
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export async function getFields(this: ILoadOptionsFunctions): Promise<any> { // tslint:disable-line:no-any
|
||||
export async function getFields(
|
||||
this: ILoadOptionsFunctions,
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const token = await getToken.call(this);
|
||||
const credentials = await this.getCredentials('fileMaker');
|
||||
const layout = this.getCurrentNodeParameter('layout') as string;
|
||||
@@ -95,7 +95,7 @@ export async function getFields(this: ILoadOptionsFunctions): Promise<any> { //
|
||||
const url = `https://${host}/fmi/data/v1/databases/${db}/layouts/${layout}`;
|
||||
const options: OptionsWithUri = {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`,
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
method: 'GET',
|
||||
uri: url,
|
||||
@@ -111,13 +111,15 @@ export async function getFields(this: ILoadOptionsFunctions): Promise<any> { //
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Make an API request to ActiveCampaign
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export async function getPortals(this: ILoadOptionsFunctions): Promise<any> { // tslint:disable-line:no-any
|
||||
export async function getPortals(
|
||||
this: ILoadOptionsFunctions,
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const token = await getToken.call(this);
|
||||
const credentials = await this.getCredentials('fileMaker');
|
||||
const layout = this.getCurrentNodeParameter('layout') as string;
|
||||
@@ -128,7 +130,7 @@ export async function getPortals(this: ILoadOptionsFunctions): Promise<any> { //
|
||||
const url = `https://${host}/fmi/data/v1/databases/${db}/layouts/${layout}`;
|
||||
const options: OptionsWithUri = {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`,
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
method: 'GET',
|
||||
uri: url,
|
||||
@@ -138,7 +140,6 @@ export async function getPortals(this: ILoadOptionsFunctions): Promise<any> { //
|
||||
try {
|
||||
const responseData = await this.helpers.request!(options);
|
||||
return responseData.response.portalMetaData;
|
||||
|
||||
} catch (error) {
|
||||
// If that data does not exist for some reason return the actual error
|
||||
throw error;
|
||||
@@ -150,7 +151,10 @@ export async function getPortals(this: ILoadOptionsFunctions): Promise<any> { //
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export async function getScripts(this: ILoadOptionsFunctions): Promise<any> { // tslint:disable-line:no-any
|
||||
export async function getScripts(
|
||||
this: ILoadOptionsFunctions,
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const token = await getToken.call(this);
|
||||
const credentials = await this.getCredentials('fileMaker');
|
||||
|
||||
@@ -160,7 +164,7 @@ export async function getScripts(this: ILoadOptionsFunctions): Promise<any> { //
|
||||
const url = `https://${host}/fmi/data/v1/databases/${db}/scripts`;
|
||||
const options: OptionsWithUri = {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`,
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
method: 'GET',
|
||||
uri: url,
|
||||
@@ -170,9 +174,8 @@ export async function getScripts(this: ILoadOptionsFunctions): Promise<any> { //
|
||||
try {
|
||||
const responseData = await this.helpers.request!(options);
|
||||
const items = parseScriptsList(responseData.response.scripts);
|
||||
items.sort((a, b) => a.name > b.name ? 0 : 1);
|
||||
items.sort((a, b) => (a.name > b.name ? 0 : 1));
|
||||
return items;
|
||||
|
||||
} catch (error) {
|
||||
// If that data does not exist for some reason return the actual error
|
||||
throw error;
|
||||
@@ -182,7 +185,7 @@ export async function getScripts(this: ILoadOptionsFunctions): Promise<any> { //
|
||||
function parseScriptsList(scripts: ScriptObject[]): INodePropertyOptions[] {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
for (const script of scripts) {
|
||||
if (script.isFolder!) {
|
||||
if (script.isFolder!) {
|
||||
returnData.push(...parseScriptsList(script.folderScriptNames!));
|
||||
} else if (script.name !== '-') {
|
||||
returnData.push({
|
||||
@@ -194,7 +197,10 @@ function parseScriptsList(scripts: ScriptObject[]): INodePropertyOptions[] {
|
||||
return returnData;
|
||||
}
|
||||
|
||||
export async function getToken(this: ILoadOptionsFunctions | IExecuteFunctions | IExecuteSingleFunctions): Promise<any> { // tslint:disable-line:no-any
|
||||
export async function getToken(
|
||||
this: ILoadOptionsFunctions | IExecuteFunctions | IExecuteSingleFunctions,
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const credentials = await this.getCredentials('fileMaker');
|
||||
|
||||
const host = credentials.host as string;
|
||||
@@ -218,11 +224,11 @@ export async function getToken(this: ILoadOptionsFunctions | IExecuteFunctions |
|
||||
pass: password as string,
|
||||
};
|
||||
requestOptions.body = {
|
||||
'fmDataSource': [
|
||||
fmDataSource: [
|
||||
{
|
||||
'database': host,
|
||||
'username': login as string,
|
||||
'password': password as string,
|
||||
database: host,
|
||||
username: login as string,
|
||||
password: password as string,
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -231,7 +237,10 @@ export async function getToken(this: ILoadOptionsFunctions | IExecuteFunctions |
|
||||
const response = await this.helpers.request!(requestOptions);
|
||||
|
||||
if (typeof response === 'string') {
|
||||
throw new NodeOperationError(this.getNode(), 'Response body is not valid JSON. Change "Response Format" to "String"');
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'Response body is not valid JSON. Change "Response Format" to "String"',
|
||||
);
|
||||
}
|
||||
|
||||
return response.response.token;
|
||||
@@ -240,7 +249,11 @@ export async function getToken(this: ILoadOptionsFunctions | IExecuteFunctions |
|
||||
}
|
||||
}
|
||||
|
||||
export async function logout(this: ILoadOptionsFunctions | IExecuteFunctions | IExecuteSingleFunctions, token: string): Promise<any> { // tslint:disable-line:no-any
|
||||
export async function logout(
|
||||
this: ILoadOptionsFunctions | IExecuteFunctions | IExecuteSingleFunctions,
|
||||
token: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const credentials = await this.getCredentials('fileMaker');
|
||||
|
||||
const host = credentials.host as string;
|
||||
@@ -262,12 +275,16 @@ export async function logout(this: ILoadOptionsFunctions | IExecuteFunctions | I
|
||||
const response = await this.helpers.request!(requestOptions);
|
||||
|
||||
if (typeof response === 'string') {
|
||||
throw new NodeOperationError(this.getNode(), 'Response body is not valid JSON. Change "Response Format" to "String"');
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'Response body is not valid JSON. Change "Response Format" to "String"',
|
||||
);
|
||||
}
|
||||
|
||||
return response;
|
||||
} catch (error) {
|
||||
const errorMessage = error.response.body.messages[0].message + '(' + error.response.body.messages[0].message + ')';
|
||||
const errorMessage =
|
||||
error.response.body.messages[0].message + '(' + error.response.body.messages[0].message + ')';
|
||||
|
||||
if (errorMessage !== undefined) {
|
||||
throw errorMessage;
|
||||
@@ -289,8 +306,8 @@ export function parseSort(this: IExecuteFunctions, i: number): object | null {
|
||||
for (const parameterData of sortParametersUi!.rules as IDataObject[]) {
|
||||
// @ts-ignore
|
||||
sort.push({
|
||||
'fieldName': parameterData!.name as string,
|
||||
'sortOrder': parameterData!.value,
|
||||
fieldName: parameterData!.name as string,
|
||||
sortOrder: parameterData!.value,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -298,7 +315,6 @@ export function parseSort(this: IExecuteFunctions, i: number): object | null {
|
||||
return sort;
|
||||
}
|
||||
|
||||
|
||||
export function parseScripts(this: IExecuteFunctions, i: number): object | null {
|
||||
const setScriptAfter = this.getNodeParameter('setScriptAfter', i, false);
|
||||
const setScriptBefore = this.getNodeParameter('setScriptBefore', i, false);
|
||||
@@ -336,7 +352,6 @@ export function parsePortals(this: IExecuteFunctions, i: number): object | null
|
||||
return portals;
|
||||
}
|
||||
|
||||
|
||||
export function parseQuery(this: IExecuteFunctions, i: number): object | null {
|
||||
let queries;
|
||||
const queriesParamUi = this.getNodeParameter('queries', i, {}) as IDataObject;
|
||||
@@ -345,7 +360,7 @@ export function parseQuery(this: IExecuteFunctions, i: number): object | null {
|
||||
queries = [];
|
||||
for (const queryParam of queriesParamUi!.query as IDataObject[]) {
|
||||
const query = {
|
||||
'omit': queryParam.omit ? 'true' : 'false',
|
||||
omit: queryParam.omit ? 'true' : 'false',
|
||||
};
|
||||
// @ts-ignore
|
||||
for (const field of queryParam!.fields!.field as IDataObject[]) {
|
||||
|
||||
Reference in New Issue
Block a user