🐛 Fix script list parsing on Filemaker Node(#1342)

Scripts in sub folders where not detected
This commit is contained in:
Romain Dunand 2021-02-06 16:42:07 +01:00 committed by GitHub
parent 58c9a92e38
commit 2d8fe3a4a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -24,6 +24,12 @@ interface LayoutObject {
folderLayoutNames?:LayoutObject[]; folderLayoutNames?:LayoutObject[];
} }
interface ScriptObject {
name: string;
isFolder?: boolean;
folderScriptNames?:LayoutObject[];
}
/** /**
* Make an API request to ActiveCampaign * Make an API request to ActiveCampaign
* *
@ -106,7 +112,6 @@ export async function getFields(this: ILoadOptionsFunctions): Promise<any> { //
try { try {
const responseData = await this.helpers.request!(options); const responseData = await this.helpers.request!(options);
return responseData.response.fieldMetaData; return responseData.response.fieldMetaData;
} catch (error) { } catch (error) {
// If that data does not exist for some reason return the actual error // If that data does not exist for some reason return the actual error
throw error; throw error;
@ -177,7 +182,9 @@ export async function getScripts(this: ILoadOptionsFunctions): Promise<any> { //
try { try {
const responseData = await this.helpers.request!(options); 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) { } catch (error) {
// If that data does not exist for some reason return the actual 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 export async function getToken(this: ILoadOptionsFunctions | IExecuteFunctions | IExecuteSingleFunctions): Promise<any> { // tslint:disable-line:no-any
const credentials = this.getCredentials('fileMaker'); const credentials = this.getCredentials('fileMaker');
if (credentials === undefined) { if (credentials === undefined) {