n8n/packages/nodes-base/nodes/Airtable/v2/actions/base/getSchema.operation.ts
Michael Kret b7aea957b8
feat: Do not show errors not processed by n8n (no-changelog) (#9598)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
2024-06-20 08:45:00 +03:00

61 lines
1.5 KiB
TypeScript

import type {
IDataObject,
INodeExecutionData,
INodeProperties,
IExecuteFunctions,
NodeApiError,
} from 'n8n-workflow';
import { updateDisplayOptions, wrapData } from '../../../../../utils/utilities';
import { apiRequest } from '../../transport';
import { baseRLC } from '../common.descriptions';
import { processAirtableError } from '../../helpers/utils';
const properties: INodeProperties[] = [
{
...baseRLC,
description: 'The Airtable Base to retrieve the schema from',
},
];
const displayOptions = {
show: {
resource: ['base'],
operation: ['getSchema'],
},
};
export const description = updateDisplayOptions(displayOptions, properties);
export async function execute(
this: IExecuteFunctions,
items: INodeExecutionData[],
): Promise<INodeExecutionData[]> {
const returnData: INodeExecutionData[] = [];
for (let i = 0; i < items.length; i++) {
try {
const baseId = this.getNodeParameter('base', 0, undefined, {
extractValue: true,
}) as string;
const responseData = await apiRequest.call(this, 'GET', `meta/bases/${baseId}/tables`);
const executionData = this.helpers.constructExecutionMetaData(
wrapData(responseData.tables as IDataObject[]),
{ itemData: { item: i } },
);
returnData.push(...executionData);
} catch (error) {
error = processAirtableError(error as NodeApiError, undefined, i);
if (this.continueOnFail(error)) {
returnData.push({ json: { error: error.message } });
continue;
}
throw error;
}
}
return returnData;
}