mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-11 23:24:06 -08:00
58 lines
1.3 KiB
TypeScript
58 lines
1.3 KiB
TypeScript
import type {
|
|
IDataObject,
|
|
INodeExecutionData,
|
|
INodeProperties,
|
|
IExecuteFunctions,
|
|
} from 'n8n-workflow';
|
|
import { updateDisplayOptions, wrapData } from '../../../../../utils/utilities';
|
|
import { apiRequest } from '../../transport';
|
|
import { baseRLC } from '../common.descriptions';
|
|
|
|
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) {
|
|
if (this.continueOnFail()) {
|
|
returnData.push({ json: { error: error.message } });
|
|
continue;
|
|
}
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
return returnData;
|
|
}
|