mirror of
https://github.com/n8n-io/n8n.git
synced 2024-09-20 14:57:31 -07:00
⚡ Fixed some issues with Excel-Node
This commit is contained in:
parent
1b3417390b
commit
bba6a8494d
26
packages/nodes-base/credentials/TestOAuth2Api.credentials.ts
Normal file
26
packages/nodes-base/credentials/TestOAuth2Api.credentials.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
import {
|
||||
ICredentialType,
|
||||
NodePropertyTypes,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
const scopes = [
|
||||
'https://www.googleapis.com/auth/calendar',
|
||||
'https://www.googleapis.com/auth/calendar.events',
|
||||
];
|
||||
|
||||
export class TestOAuth2Api implements ICredentialType {
|
||||
name = 'testOAuth2Api';
|
||||
extends = [
|
||||
'googleOAuth2Api',
|
||||
];
|
||||
displayName = 'Test OAuth2 API';
|
||||
properties = [
|
||||
{
|
||||
displayName: 'Scope',
|
||||
name: 'scope',
|
||||
type: 'string' as NodePropertyTypes,
|
||||
default: '',
|
||||
placeholder: 'asdf',
|
||||
},
|
||||
];
|
||||
}
|
293
packages/nodes-base/nodes/Google/GoogleDriveTrigger.node.ts
Normal file
293
packages/nodes-base/nodes/Google/GoogleDriveTrigger.node.ts
Normal file
|
@ -0,0 +1,293 @@
|
|||
// import { google } from 'googleapis';
|
||||
|
||||
// import {
|
||||
// IHookFunctions,
|
||||
// IWebhookFunctions,
|
||||
// } from 'n8n-core';
|
||||
|
||||
// import {
|
||||
// IDataObject,
|
||||
// INodeTypeDescription,
|
||||
// INodeType,
|
||||
// IWebhookResponseData,
|
||||
// } from 'n8n-workflow';
|
||||
|
||||
// import { getAuthenticationClient } from './GoogleApi';
|
||||
|
||||
|
||||
// export class GoogleDriveTrigger implements INodeType {
|
||||
// description: INodeTypeDescription = {
|
||||
// displayName: 'Google Drive Trigger',
|
||||
// name: 'googleDriveTrigger',
|
||||
// icon: 'file:googleDrive.png',
|
||||
// group: ['trigger'],
|
||||
// version: 1,
|
||||
// subtitle: '={{$parameter["owner"] + "/" + $parameter["repository"] + ": " + $parameter["events"].join(", ")}}',
|
||||
// description: 'Starts the workflow when a file on Google Drive got changed.',
|
||||
// defaults: {
|
||||
// name: 'Google Drive Trigger',
|
||||
// color: '#3f87f2',
|
||||
// },
|
||||
// inputs: [],
|
||||
// outputs: ['main'],
|
||||
// credentials: [
|
||||
// {
|
||||
// name: 'googleApi',
|
||||
// required: true,
|
||||
// }
|
||||
// ],
|
||||
// webhooks: [
|
||||
// {
|
||||
// name: 'default',
|
||||
// httpMethod: 'POST',
|
||||
// responseMode: 'onReceived',
|
||||
// path: 'webhook',
|
||||
// },
|
||||
// ],
|
||||
// properties: [
|
||||
// {
|
||||
// displayName: 'Resource Id',
|
||||
// name: 'resourceId',
|
||||
// type: 'string',
|
||||
// default: '',
|
||||
// required: true,
|
||||
// placeholder: '',
|
||||
// description: 'ID of the resource to watch, for example a file ID.',
|
||||
// },
|
||||
// ],
|
||||
// };
|
||||
|
||||
// // @ts-ignore (because of request)
|
||||
// webhookMethods = {
|
||||
// default: {
|
||||
// async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
// // const webhookData = this.getWorkflowStaticData('node');
|
||||
|
||||
// // if (webhookData.webhookId === undefined) {
|
||||
// // // No webhook id is set so no webhook can exist
|
||||
// // return false;
|
||||
// // }
|
||||
|
||||
// // // Webhook got created before so check if it still exists
|
||||
// // const owner = this.getNodeParameter('owner') as string;
|
||||
// // const repository = this.getNodeParameter('repository') as string;
|
||||
// // const endpoint = `/repos/${owner}/${repository}/hooks/${webhookData.webhookId}`;
|
||||
|
||||
// // try {
|
||||
// // await githubApiRequest.call(this, 'GET', endpoint, {});
|
||||
// // } catch (e) {
|
||||
// // if (e.message.includes('[404]:')) {
|
||||
// // // Webhook does not exist
|
||||
// // delete webhookData.webhookId;
|
||||
// // delete webhookData.webhookEvents;
|
||||
|
||||
// // return false;
|
||||
// // }
|
||||
|
||||
// // // Some error occured
|
||||
// // throw e;
|
||||
// // }
|
||||
|
||||
// // If it did not error then the webhook exists
|
||||
// // return true;
|
||||
// return false;
|
||||
// },
|
||||
// async create(this: IHookFunctions): Promise<boolean> {
|
||||
// const webhookUrl = this.getNodeWebhookUrl('default');
|
||||
|
||||
// const resourceId = this.getNodeParameter('resourceId') as string;
|
||||
|
||||
// const credentials = this.getCredentials('googleApi');
|
||||
|
||||
// if (credentials === undefined) {
|
||||
// throw new Error('No credentials got returned!');
|
||||
// }
|
||||
|
||||
// const scopes = [
|
||||
// 'https://www.googleapis.com/auth/drive',
|
||||
// 'https://www.googleapis.com/auth/drive.appdata',
|
||||
// 'https://www.googleapis.com/auth/drive.photos.readonly',
|
||||
// ];
|
||||
|
||||
// const client = await getAuthenticationClient(credentials.email as string, credentials.privateKey as string, scopes);
|
||||
|
||||
// const drive = google.drive({
|
||||
// version: 'v3',
|
||||
// auth: client,
|
||||
// });
|
||||
|
||||
|
||||
// const accessToken = await client.getAccessToken();
|
||||
// console.log('accessToken: ');
|
||||
// console.log(accessToken);
|
||||
|
||||
// const asdf = await drive.changes.getStartPageToken();
|
||||
// // console.log('asdf: ');
|
||||
// // console.log(asdf);
|
||||
|
||||
|
||||
|
||||
|
||||
// const response = await drive.changes.watch({
|
||||
// //
|
||||
// pageToken: asdf.data.startPageToken,
|
||||
// requestBody: {
|
||||
// id: 'asdf-test-2',
|
||||
// address: webhookUrl,
|
||||
// resourceId,
|
||||
// type: 'web_hook',
|
||||
// // page_token: '',
|
||||
// }
|
||||
// });
|
||||
|
||||
// console.log('...response...CREATE');
|
||||
// console.log(JSON.stringify(response, null, 2));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// // const endpoint = `/repos/${owner}/${repository}/hooks`;
|
||||
|
||||
// // const body = {
|
||||
// // name: 'web',
|
||||
// // config: {
|
||||
// // url: webhookUrl,
|
||||
// // content_type: 'json',
|
||||
// // // secret: '...later...',
|
||||
// // insecure_ssl: '1', // '0' -> not allow inscure ssl | '1' -> allow insercure SSL
|
||||
// // },
|
||||
// // events,
|
||||
// // active: true,
|
||||
// // };
|
||||
|
||||
|
||||
// // let responseData;
|
||||
// // try {
|
||||
// // responseData = await githubApiRequest.call(this, 'POST', endpoint, body);
|
||||
// // } catch (e) {
|
||||
// // if (e.message.includes('[422]:')) {
|
||||
// // throw new Error('A webhook with the identical URL exists already. Please delete it manually on Github!');
|
||||
// // }
|
||||
|
||||
// // throw e;
|
||||
// // }
|
||||
|
||||
// // if (responseData.id === undefined || responseData.active !== true) {
|
||||
// // // Required data is missing so was not successful
|
||||
// // throw new Error('Github webhook creation response did not contain the expected data.');
|
||||
// // }
|
||||
|
||||
// // const webhookData = this.getWorkflowStaticData('node');
|
||||
// // webhookData.webhookId = responseData.id as string;
|
||||
// // webhookData.webhookEvents = responseData.events as string[];
|
||||
|
||||
// return true;
|
||||
// },
|
||||
// async delete(this: IHookFunctions): Promise<boolean> {
|
||||
// const webhookUrl = this.getNodeWebhookUrl('default');
|
||||
|
||||
// const resourceId = this.getNodeParameter('resourceId') as string;
|
||||
|
||||
// const credentials = this.getCredentials('googleApi');
|
||||
|
||||
// if (credentials === undefined) {
|
||||
// throw new Error('No credentials got returned!');
|
||||
// }
|
||||
|
||||
// const scopes = [
|
||||
// 'https://www.googleapis.com/auth/drive',
|
||||
// 'https://www.googleapis.com/auth/drive.appdata',
|
||||
// 'https://www.googleapis.com/auth/drive.photos.readonly',
|
||||
// ];
|
||||
|
||||
// const client = await getAuthenticationClient(credentials.email as string, credentials.privateKey as string, scopes);
|
||||
|
||||
// const drive = google.drive({
|
||||
// version: 'v3',
|
||||
// auth: client,
|
||||
// });
|
||||
|
||||
// // Remove channel
|
||||
// const response = await drive.channels.stop({
|
||||
// requestBody: {
|
||||
// id: 'asdf-test-2',
|
||||
// address: webhookUrl,
|
||||
// resourceId,
|
||||
// type: 'web_hook',
|
||||
// }
|
||||
// });
|
||||
|
||||
|
||||
// console.log('...response...DELETE');
|
||||
// console.log(JSON.stringify(response, null, 2));
|
||||
|
||||
|
||||
|
||||
// // const webhookData = this.getWorkflowStaticData('node');
|
||||
|
||||
// // if (webhookData.webhookId !== undefined) {
|
||||
// // const owner = this.getNodeParameter('owner') as string;
|
||||
// // const repository = this.getNodeParameter('repository') as string;
|
||||
// // const endpoint = `/repos/${owner}/${repository}/hooks/${webhookData.webhookId}`;
|
||||
// // const body = {};
|
||||
|
||||
// // try {
|
||||
// // await githubApiRequest.call(this, 'DELETE', endpoint, body);
|
||||
// // } catch (e) {
|
||||
// // return false;
|
||||
// // }
|
||||
|
||||
// // // Remove from the static workflow data so that it is clear
|
||||
// // // that no webhooks are registred anymore
|
||||
// // delete webhookData.webhookId;
|
||||
// // delete webhookData.webhookEvents;
|
||||
// // }
|
||||
|
||||
// return true;
|
||||
// },
|
||||
// },
|
||||
// };
|
||||
|
||||
|
||||
|
||||
// async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
|
||||
// const bodyData = this.getBodyData();
|
||||
|
||||
// console.log('');
|
||||
// console.log('');
|
||||
// console.log('GOT WEBHOOK CALL');
|
||||
// console.log(JSON.stringify(bodyData, null, 2));
|
||||
|
||||
|
||||
|
||||
// // Check if the webhook is only the ping from Github to confirm if it workshook_id
|
||||
// if (bodyData.hook_id !== undefined && bodyData.action === undefined) {
|
||||
// // Is only the ping and not an actual webhook call. So return 'OK'
|
||||
// // but do not start the workflow.
|
||||
|
||||
// return {
|
||||
// webhookResponse: 'OK'
|
||||
// };
|
||||
// }
|
||||
|
||||
// // Is a regular webhoook call
|
||||
|
||||
// // TODO: Add headers & requestPath
|
||||
// const returnData: IDataObject[] = [];
|
||||
|
||||
// returnData.push(
|
||||
// {
|
||||
// body: bodyData,
|
||||
// headers: this.getHeaderData(),
|
||||
// query: this.getQueryData(),
|
||||
// }
|
||||
// );
|
||||
|
||||
// return {
|
||||
// workflowData: [
|
||||
// this.helpers.returnJsonArray(returnData)
|
||||
// ],
|
||||
// };
|
||||
// }
|
||||
// }
|
|
@ -153,23 +153,23 @@ export class MicrosoftExcel implements INodeType {
|
|||
const items = this.getInputData();
|
||||
const returnData: IDataObject[] = [];
|
||||
const length = items.length as unknown as number;
|
||||
const qs: IDataObject = {};
|
||||
let qs: IDataObject = {};
|
||||
const result: IDataObject[] = [];
|
||||
const object: IDataObject = {};
|
||||
let responseData;
|
||||
const resource = this.getNodeParameter('resource', 0) as string;
|
||||
const operation = this.getNodeParameter('operation', 0) as string;
|
||||
|
||||
if (resource === 'table') {
|
||||
//https://docs.microsoft.com/en-us/graph/api/table-post-rows?view=graph-rest-1.0&tabs=http
|
||||
if (operation === 'addRow') {
|
||||
// TODO: At some point it should be possible to use item dependent parameters.
|
||||
// Is however important to then not make one separate request each.
|
||||
const workbookId = this.getNodeParameter('workbook', 0) as string;
|
||||
const worksheetId = this.getNodeParameter('worksheet', 0) as string;
|
||||
const tableId = this.getNodeParameter('table', 0) as string;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', 0) as IDataObject;
|
||||
const body: IDataObject = {};
|
||||
if (Object.keys(items[0].json).length === 0) {
|
||||
throw new Error('Input cannot be empty');
|
||||
}
|
||||
|
||||
if (additionalFields.index) {
|
||||
body.index = additionalFields.index as number;
|
||||
}
|
||||
|
@ -178,41 +178,35 @@ export class MicrosoftExcel implements INodeType {
|
|||
responseData = await microsoftApiRequest.call(this, 'GET', `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/columns`, {}, qs);
|
||||
const columns = responseData.value.map((column: IDataObject) => (column.name));
|
||||
|
||||
const cleanedItems: IDataObject[] = [];
|
||||
const rows: any[][] = []; // tslint:disable-line:no-any
|
||||
|
||||
// Delete columns the excel table does not have
|
||||
// Bring the items into the correct format
|
||||
for (const item of items) {
|
||||
for (const key of Object.keys(item.json)) {
|
||||
if (!columns.includes(key)) {
|
||||
const property = { ...item.json };
|
||||
delete property[key];
|
||||
cleanedItems.push(property);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Map the keys to the column index
|
||||
const values: any[][] = [];
|
||||
let value = [];
|
||||
for (const item of cleanedItems) {
|
||||
const row = [];
|
||||
for (const column of columns) {
|
||||
value.push(item[column]);
|
||||
row.push(item.json[column]);
|
||||
}
|
||||
values.push(value);
|
||||
value = [];
|
||||
rows.push(row);
|
||||
}
|
||||
|
||||
body.values = values;
|
||||
body.values = rows;
|
||||
const { id } = await microsoftApiRequest.call(this, 'POST', `/drive/items/${workbookId}/workbook/createSession`, { persistChanges: true });
|
||||
responseData = await microsoftApiRequest.call(this, 'POST', `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/rows/add`, body, {}, '', { 'workbook-session-id': id });
|
||||
await microsoftApiRequest.call(this, 'POST', `/drive/items/${workbookId}/workbook/closeSession`, {}, {}, '', { 'workbook-session-id': id });
|
||||
|
||||
if (Array.isArray(responseData)) {
|
||||
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||
} else if (responseData !== undefined) {
|
||||
returnData.push(responseData as IDataObject);
|
||||
}
|
||||
}
|
||||
//https://docs.microsoft.com/en-us/graph/api/table-list-columns?view=graph-rest-1.0&tabs=http
|
||||
if (operation === 'getColumns') {
|
||||
for (let i = 0; i < length; i++) {
|
||||
const workbookId = this.getNodeParameter('workbook', 0) as string;
|
||||
const worksheetId = this.getNodeParameter('worksheet', 0) as string;
|
||||
const tableId = this.getNodeParameter('table', 0) as string;
|
||||
qs = {};
|
||||
const workbookId = this.getNodeParameter('workbook', i) as string;
|
||||
const worksheetId = this.getNodeParameter('worksheet', i) as string;
|
||||
const tableId = this.getNodeParameter('table', i) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
const rawData = this.getNodeParameter('rawData', i) as boolean;
|
||||
if (rawData) {
|
||||
|
@ -234,14 +228,21 @@ export class MicrosoftExcel implements INodeType {
|
|||
const dataProperty = this.getNodeParameter('dataProperty', i) as string;
|
||||
responseData = { [dataProperty] : responseData };
|
||||
}
|
||||
|
||||
if (Array.isArray(responseData)) {
|
||||
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||
} else if (responseData !== undefined) {
|
||||
returnData.push(responseData as IDataObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
//https://docs.microsoft.com/en-us/graph/api/table-list-rows?view=graph-rest-1.0&tabs=http
|
||||
if (operation === 'getRows') {
|
||||
for (let i = 0; i < length; i++) {
|
||||
const workbookId = this.getNodeParameter('workbook', 0) as string;
|
||||
const worksheetId = this.getNodeParameter('worksheet', 0) as string;
|
||||
const tableId = this.getNodeParameter('table', 0) as string;
|
||||
qs = {};
|
||||
const workbookId = this.getNodeParameter('workbook', i) as string;
|
||||
const worksheetId = this.getNodeParameter('worksheet', i) as string;
|
||||
const tableId = this.getNodeParameter('table', i) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
const rawData = this.getNodeParameter('rawData', i) as boolean;
|
||||
if (rawData) {
|
||||
|
@ -253,71 +254,78 @@ export class MicrosoftExcel implements INodeType {
|
|||
if (returnAll === true) {
|
||||
responseData = await microsoftApiRequestAllItemsSkip.call(this, 'value', 'GET', `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/rows`, {}, qs);
|
||||
} else {
|
||||
qs['$top'] = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await microsoftApiRequest.call(this, 'GET', `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/rows`, {}, qs);
|
||||
const rowsQs = { ...qs };
|
||||
rowsQs['$top'] = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await microsoftApiRequest.call(this, 'GET', `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/rows`, {}, rowsQs);
|
||||
responseData = responseData.value;
|
||||
}
|
||||
if (!rawData) {
|
||||
qs['$select'] = 'name';
|
||||
let columns = await microsoftApiRequestAllItemsSkip.call(this, 'value', 'GET', `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/columns`, {}, qs);
|
||||
const columnsQs = { ...qs };
|
||||
columnsQs['$select'] = 'name';
|
||||
// TODO: That should probably be cached in the future
|
||||
let columns = await microsoftApiRequestAllItemsSkip.call(this, 'value', 'GET', `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/columns`, {}, columnsQs);
|
||||
//@ts-ignore
|
||||
columns = columns.map(column => column.name);
|
||||
for (let i = 0; i < responseData.length; i++) {
|
||||
const object: IDataObject = {};
|
||||
for (let y = 0; y < columns.length; y++) {
|
||||
object[columns[y]] = responseData[i].values[0][y];
|
||||
}
|
||||
result.push({ ...object });
|
||||
returnData.push({ ...object });
|
||||
}
|
||||
responseData = result;
|
||||
} else {
|
||||
const dataProperty = this.getNodeParameter('dataProperty', i) as string;
|
||||
responseData = { [dataProperty] : responseData };
|
||||
returnData.push({ [dataProperty]: responseData });
|
||||
}
|
||||
}
|
||||
}
|
||||
if (operation === 'lookup') {
|
||||
for (let i = 0; i < length; i++) {
|
||||
const workbookId = this.getNodeParameter('workbook', 0) as string;
|
||||
const worksheetId = this.getNodeParameter('worksheet', 0) as string;
|
||||
const tableId = this.getNodeParameter('table', 0) as string;
|
||||
const lookupColumn = this.getNodeParameter('lookupColumn', 0) as string;
|
||||
const lookupValue = this.getNodeParameter('lookupValue', 0) as string;
|
||||
const options = this.getNodeParameter('options', 0) as IDataObject;
|
||||
qs = {};
|
||||
const workbookId = this.getNodeParameter('workbook', i) as string;
|
||||
const worksheetId = this.getNodeParameter('worksheet', i) as string;
|
||||
const tableId = this.getNodeParameter('table', i) as string;
|
||||
const lookupColumn = this.getNodeParameter('lookupColumn', i) as string;
|
||||
const lookupValue = this.getNodeParameter('lookupValue', i) as string;
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
|
||||
responseData = await microsoftApiRequestAllItemsSkip.call(this, 'value', 'GET', `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/rows`, {}, qs);
|
||||
responseData = await microsoftApiRequestAllItemsSkip.call(this, 'value', 'GET', `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/rows`, {}, {});
|
||||
|
||||
qs['$select'] = 'name';
|
||||
// TODO: That should probably be cached in the future
|
||||
let columns = await microsoftApiRequestAllItemsSkip.call(this, 'value', 'GET', `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/columns`, {}, qs);
|
||||
columns = columns.map((column: IDataObject) => column.name);
|
||||
for (let i = 0; i < responseData.length; i++) {
|
||||
for (let y = 0; y < columns.length; y++) {
|
||||
object[columns[y]] = responseData[i].values[0][y];
|
||||
}
|
||||
result.push({ ...object });
|
||||
}
|
||||
responseData = result;
|
||||
|
||||
if (!columns.includes(lookupColumn)) {
|
||||
throw new Error(`Column ${lookupColumn} does not exist on the table selected`);
|
||||
}
|
||||
|
||||
result.length = 0;
|
||||
for (let i = 0; i < responseData.length; i++) {
|
||||
const object: IDataObject = {};
|
||||
for (let y = 0; y < columns.length; y++) {
|
||||
object[columns[y]] = responseData[i].values[0][y];
|
||||
}
|
||||
result.push({ ...object });
|
||||
}
|
||||
|
||||
if (options.returnAllMatches) {
|
||||
|
||||
responseData = responseData.filter((data: IDataObject) => {
|
||||
responseData = result.filter((data: IDataObject) => {
|
||||
return (data[lookupColumn]?.toString() === lookupValue );
|
||||
});
|
||||
|
||||
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||
} else {
|
||||
|
||||
responseData = responseData.find((data: IDataObject) => {
|
||||
responseData = result.find((data: IDataObject) => {
|
||||
return (data[lookupColumn]?.toString() === lookupValue );
|
||||
});
|
||||
returnData.push(responseData as IDataObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (resource === 'workbook') {
|
||||
for (let i = 0; i < length; i++) {
|
||||
qs = {};
|
||||
//https://docs.microsoft.com/en-us/graph/api/worksheetcollection-add?view=graph-rest-1.0&tabs=http
|
||||
if (operation === 'addWorksheet') {
|
||||
const workbookId = this.getNodeParameter('workbook', i) as string;
|
||||
|
@ -344,10 +352,17 @@ export class MicrosoftExcel implements INodeType {
|
|||
responseData = responseData.value;
|
||||
}
|
||||
}
|
||||
|
||||
if (Array.isArray(responseData)) {
|
||||
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||
} else if (responseData !== undefined) {
|
||||
returnData.push(responseData as IDataObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (resource === 'worksheet') {
|
||||
for (let i = 0; i < length; i++) {
|
||||
qs = {};
|
||||
//https://docs.microsoft.com/en-us/graph/api/workbook-list-worksheets?view=graph-rest-1.0&tabs=http
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
|
@ -376,7 +391,9 @@ export class MicrosoftExcel implements INodeType {
|
|||
qs['$select'] = filters.fields;
|
||||
}
|
||||
}
|
||||
|
||||
responseData = await microsoftApiRequest.call(this, 'GET', `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/range(address='${range}')`, {}, qs);
|
||||
|
||||
if (!rawData) {
|
||||
const keyRow = this.getNodeParameter('keyRow', i) as number;
|
||||
const dataStartRow = this.getNodeParameter('dataStartRow', i) as number;
|
||||
|
@ -385,24 +402,20 @@ export class MicrosoftExcel implements INodeType {
|
|||
}
|
||||
const keyValues = responseData.values[keyRow];
|
||||
for (let i = dataStartRow; i < responseData.values.length; i++) {
|
||||
const object: IDataObject = {};
|
||||
for (let y = 0; y < keyValues.length; y++) {
|
||||
object[keyValues[y]] = responseData.values[i][y];
|
||||
}
|
||||
result.push({ ...object });
|
||||
returnData.push({ ...object });
|
||||
}
|
||||
responseData = result;
|
||||
} else {
|
||||
const dataProperty = this.getNodeParameter('dataProperty', i) as string;
|
||||
responseData = { [dataProperty] : responseData };
|
||||
returnData.push({ [dataProperty]: responseData });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Array.isArray(responseData)) {
|
||||
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||
} else if (responseData !== undefined) {
|
||||
returnData.push(responseData as IDataObject);
|
||||
}
|
||||
|
||||
return [this.helpers.returnJsonArray(returnData)];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { INodeProperties } from "n8n-workflow";
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const tableOperations = [
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { INodeProperties } from "n8n-workflow";
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const workbookOperations = [
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { INodeProperties } from "n8n-workflow";
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const worksheetOperations = [
|
||||
{
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 1.9 KiB |
|
@ -42,8 +42,8 @@
|
|||
"dist/credentials/GithubApi.credentials.js",
|
||||
"dist/credentials/GithubOAuth2Api.credentials.js",
|
||||
"dist/credentials/GitlabApi.credentials.js",
|
||||
"dist/credentials/GoogleApi.credentials.js",
|
||||
"dist/credentials/GoogleOAuth2Api.credentials.js",
|
||||
"dist/credentials/GoogleApi.credentials.js",
|
||||
"dist/credentials/GoogleOAuth2Api.credentials.js",
|
||||
"dist/credentials/HttpBasicAuth.credentials.js",
|
||||
"dist/credentials/HttpDigestAuth.credentials.js",
|
||||
"dist/credentials/HttpHeaderAuth.credentials.js",
|
||||
|
@ -55,9 +55,9 @@
|
|||
"dist/credentials/MailchimpApi.credentials.js",
|
||||
"dist/credentials/MailgunApi.credentials.js",
|
||||
"dist/credentials/MandrillApi.credentials.js",
|
||||
"dist/credentials/MattermostApi.credentials.js",
|
||||
"dist/credentials/MicrosoftOAuth2Api.credentials.js",
|
||||
"dist/credentials/MicrosoftExcelOAuth2Api.credentials.js",
|
||||
"dist/credentials/MattermostApi.credentials.js",
|
||||
"dist/credentials/MicrosoftExcelOAuth2Api.credentials.js",
|
||||
"dist/credentials/MicrosoftOAuth2Api.credentials.js",
|
||||
"dist/credentials/MongoDb.credentials.js",
|
||||
"dist/credentials/MySql.credentials.js",
|
||||
"dist/credentials/NextCloudApi.credentials.js",
|
||||
|
@ -84,8 +84,8 @@
|
|||
"dist/credentials/TypeformApi.credentials.js",
|
||||
"dist/credentials/TogglApi.credentials.js",
|
||||
"dist/credentials/VeroApi.credentials.js",
|
||||
"dist/credentials/WordpressApi.credentials.js",
|
||||
"dist/credentials/ZohoOAuth2Api.credentials.js"
|
||||
"dist/credentials/WordpressApi.credentials.js",
|
||||
"dist/credentials/ZohoOAuth2Api.credentials.js"
|
||||
],
|
||||
"nodes": [
|
||||
"dist/nodes/ActiveCampaign/ActiveCampaign.node.js",
|
||||
|
@ -119,8 +119,8 @@
|
|||
"dist/nodes/Github/Github.node.js",
|
||||
"dist/nodes/Github/GithubTrigger.node.js",
|
||||
"dist/nodes/Gitlab/Gitlab.node.js",
|
||||
"dist/nodes/Gitlab/GitlabTrigger.node.js",
|
||||
"dist/nodes/Google/GoogleCalendar.node.js",
|
||||
"dist/nodes/Gitlab/GitlabTrigger.node.js",
|
||||
"dist/nodes/Google/GoogleCalendar.node.js",
|
||||
"dist/nodes/Google/GoogleDrive.node.js",
|
||||
"dist/nodes/Google/GoogleSheets.node.js",
|
||||
"dist/nodes/GraphQL/GraphQL.node.js",
|
||||
|
@ -137,8 +137,8 @@
|
|||
"dist/nodes/Mailgun/Mailgun.node.js",
|
||||
"dist/nodes/Mandrill/Mandrill.node.js",
|
||||
"dist/nodes/Mattermost/Mattermost.node.js",
|
||||
"dist/nodes/Merge.node.js",
|
||||
"dist/nodes/Microsoft/Excel/MicrosoftExcel.node.js",
|
||||
"dist/nodes/Merge.node.js",
|
||||
"dist/nodes/Microsoft/Excel/MicrosoftExcel.node.js",
|
||||
"dist/nodes/MoveBinaryData.node.js",
|
||||
"dist/nodes/MongoDb/MongoDb.node.js",
|
||||
"dist/nodes/MySql/MySql.node.js",
|
||||
|
@ -181,8 +181,8 @@
|
|||
"dist/nodes/WriteBinaryFile.node.js",
|
||||
"dist/nodes/Webhook.node.js",
|
||||
"dist/nodes/Wordpress/Wordpress.node.js",
|
||||
"dist/nodes/Xml.node.js",
|
||||
"dist/nodes/Zoho/ZohoCrm.node.js"
|
||||
"dist/nodes/Xml.node.js",
|
||||
"dist/nodes/Zoho/ZohoCrm.node.js"
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
Loading…
Reference in a new issue