mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
🐛 Fix script list parsing on Filemaker Node(#1342)
Scripts in sub folders where not detected
This commit is contained in:
@@ -24,6 +24,12 @@ interface LayoutObject {
|
||||
folderLayoutNames?:LayoutObject[];
|
||||
}
|
||||
|
||||
interface ScriptObject {
|
||||
name: string;
|
||||
isFolder?: boolean;
|
||||
folderScriptNames?:LayoutObject[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Make an API request to ActiveCampaign
|
||||
*
|
||||
@@ -106,7 +112,6 @@ export async function getFields(this: ILoadOptionsFunctions): Promise<any> { //
|
||||
try {
|
||||
const responseData = await this.helpers.request!(options);
|
||||
return responseData.response.fieldMetaData;
|
||||
|
||||
} catch (error) {
|
||||
// If that data does not exist for some reason return the actual error
|
||||
throw error;
|
||||
@@ -177,7 +182,9 @@ export async function getScripts(this: ILoadOptionsFunctions): Promise<any> { //
|
||||
|
||||
try {
|
||||
const responseData = await this.helpers.request!(options);
|
||||
return responseData.response.scripts;
|
||||
const items = parseScriptsList(responseData.response.scripts);
|
||||
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
|
||||
@@ -185,6 +192,21 @@ export async function getScripts(this: ILoadOptionsFunctions): Promise<any> { //
|
||||
}
|
||||
}
|
||||
|
||||
function parseScriptsList(scripts: ScriptObject[]): INodePropertyOptions[] {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
for (const script of scripts) {
|
||||
if (script.isFolder!) {
|
||||
returnData.push(...parseScriptsList(script.folderScriptNames!));
|
||||
} else if (script.name !== '-') {
|
||||
returnData.push({
|
||||
name: script.name,
|
||||
value: script.name,
|
||||
});
|
||||
}
|
||||
}
|
||||
return returnData;
|
||||
}
|
||||
|
||||
export async function getToken(this: ILoadOptionsFunctions | IExecuteFunctions | IExecuteSingleFunctions): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = this.getCredentials('fileMaker');
|
||||
if (credentials === undefined) {
|
||||
|
||||
Reference in New Issue
Block a user