mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-15 09:04:07 -08:00
24ce141815
* refactor: Clear unused ESLint directives from nodes-base (no-changelog) * removed unused disable directives --------- Co-authored-by: Marcus <marcus@n8n.io>
54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
import type { IDataObject, ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow';
|
|
import { googleApiRequest } from '../transport';
|
|
|
|
export async function getDatasets(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
|
const projectId = this.getNodeParameter('projectId', undefined, {
|
|
extractValue: true,
|
|
});
|
|
const returnData: INodePropertyOptions[] = [];
|
|
const { datasets } = await googleApiRequest.call(
|
|
this,
|
|
'GET',
|
|
`/v2/projects/${projectId}/datasets`,
|
|
);
|
|
for (const dataset of datasets) {
|
|
returnData.push({
|
|
name: dataset.datasetReference.datasetId as string,
|
|
value: dataset.datasetReference.datasetId,
|
|
});
|
|
}
|
|
return returnData;
|
|
}
|
|
|
|
export async function getSchema(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
|
const projectId = this.getNodeParameter('projectId', undefined, {
|
|
extractValue: true,
|
|
});
|
|
const datasetId = this.getNodeParameter('datasetId', undefined, {
|
|
extractValue: true,
|
|
});
|
|
const tableId = this.getNodeParameter('tableId', undefined, {
|
|
extractValue: true,
|
|
});
|
|
|
|
const returnData: INodePropertyOptions[] = [];
|
|
|
|
const { schema } = await googleApiRequest.call(
|
|
this,
|
|
'GET',
|
|
`/v2/projects/${projectId}/datasets/${datasetId}/tables/${tableId}`,
|
|
{},
|
|
);
|
|
|
|
for (const field of schema.fields as IDataObject[]) {
|
|
returnData.push({
|
|
name: field.name as string,
|
|
value: field.name as string,
|
|
|
|
description:
|
|
`type: ${field.type as string}` + (field.mode ? ` mode: ${field.mode as string}` : ''),
|
|
});
|
|
}
|
|
return returnData;
|
|
}
|