mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
n8n-3867-progressively-apply-prettier-to-all (#3873)
* 🔨 formatting nodes with prettier
This commit is contained in:
@@ -1,28 +1,30 @@
|
||||
import {
|
||||
OptionsWithUri,
|
||||
} from 'request';
|
||||
import { OptionsWithUri } from 'request';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
IExecuteSingleFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
INodeProperties,
|
||||
INodePropertyOptions,
|
||||
NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
import { IDataObject, INodeProperties, INodePropertyOptions, NodeApiError } from 'n8n-workflow';
|
||||
|
||||
export async function microsoftApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = await this.getCredentials('microsoftDynamicsOAuth2Api') as { subdomain: string, region: string };
|
||||
export async function microsoftApiRequest(
|
||||
this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions,
|
||||
method: string,
|
||||
resource: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
qs: IDataObject = {},
|
||||
uri?: string,
|
||||
option: IDataObject = {},
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const credentials = (await this.getCredentials('microsoftDynamicsOAuth2Api')) as {
|
||||
subdomain: string;
|
||||
region: string;
|
||||
};
|
||||
|
||||
let options: OptionsWithUri = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'accept': 'application/json',
|
||||
'Prefer': 'return=representation',
|
||||
accept: 'application/json',
|
||||
Prefer: 'return=representation',
|
||||
},
|
||||
method,
|
||||
body,
|
||||
@@ -36,14 +38,24 @@ export async function microsoftApiRequest(this: IExecuteFunctions | IExecuteSing
|
||||
options = Object.assign({}, options, option);
|
||||
}
|
||||
//@ts-ignore
|
||||
return await this.helpers.requestOAuth2.call(this, 'microsoftDynamicsOAuth2Api', options, { property: 'id_token' });
|
||||
return await this.helpers.requestOAuth2.call(this, 'microsoftDynamicsOAuth2Api', options, {
|
||||
property: 'id_token',
|
||||
});
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function microsoftApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
export async function microsoftApiRequestAllItems(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
propertyName: string,
|
||||
method: string,
|
||||
endpoint: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
query: IDataObject = {},
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
@@ -54,17 +66,21 @@ export async function microsoftApiRequestAllItems(this: IExecuteFunctions | ILoa
|
||||
responseData = await microsoftApiRequest.call(this, method, endpoint, body, query, uri);
|
||||
uri = responseData['@odata.nextLink'];
|
||||
returnData.push.apply(returnData, responseData[propertyName]);
|
||||
} while (
|
||||
responseData['@odata.nextLink'] !== undefined
|
||||
);
|
||||
} while (responseData['@odata.nextLink'] !== undefined);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
export async function getPicklistOptions(this: ILoadOptionsFunctions, entityName: string, attributeName: string): Promise<INodePropertyOptions[]> {
|
||||
export async function getPicklistOptions(
|
||||
this: ILoadOptionsFunctions,
|
||||
entityName: string,
|
||||
attributeName: string,
|
||||
): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const endpoint = `/EntityDefinitions(LogicalName='${entityName}')/Attributes(LogicalName='${attributeName}')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=OptionSet($select=Options),GlobalOptionSet($select=Options)`;
|
||||
const { OptionSet: { Options: options } } = await microsoftApiRequest.call(this, 'GET', endpoint);
|
||||
const {
|
||||
OptionSet: { Options: options },
|
||||
} = await microsoftApiRequest.call(this, 'GET', endpoint);
|
||||
for (const option of options) {
|
||||
returnData.push({
|
||||
name: option.Label.UserLocalizedLabel.Label,
|
||||
@@ -74,7 +90,10 @@ export async function getPicklistOptions(this: ILoadOptionsFunctions, entityName
|
||||
return returnData;
|
||||
}
|
||||
|
||||
export async function getEntityFields(this: ILoadOptionsFunctions, entityName: string): Promise<IField[]> {
|
||||
export async function getEntityFields(
|
||||
this: ILoadOptionsFunctions,
|
||||
entityName: string,
|
||||
): Promise<IField[]> {
|
||||
const endpoint = `/EntityDefinitions(LogicalName='${entityName}')/Attributes`;
|
||||
const { value } = await microsoftApiRequest.call(this, 'GET', endpoint);
|
||||
return value;
|
||||
@@ -103,13 +122,15 @@ export function getAccountFields(): INodeProperties[] {
|
||||
loadOptionsMethod: 'getAccountCategories',
|
||||
},
|
||||
default: '',
|
||||
description: 'Category to indicate whether the customer account is standard or preferred. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'Category to indicate whether the customer account is standard or preferred. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Account Rating Name or ID',
|
||||
name: 'accountratingcode',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getAccountRatingCodes',
|
||||
},
|
||||
@@ -133,7 +154,8 @@ export function getAccountFields(): INodeProperties[] {
|
||||
displayName: 'Address Type Name or ID',
|
||||
name: 'addresstypecode',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getAddressTypes',
|
||||
},
|
||||
@@ -223,13 +245,15 @@ export function getAccountFields(): INodeProperties[] {
|
||||
loadOptionsMethod: 'getBusinessTypes',
|
||||
},
|
||||
default: '',
|
||||
description: 'The legal designation or other business type of the account for contracts or reporting purposes. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'The legal designation or other business type of the account for contracts or reporting purposes. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Customer Size Name or ID',
|
||||
name: 'customersizecode',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getCustomerSizeCodes',
|
||||
},
|
||||
@@ -239,7 +263,8 @@ export function getAccountFields(): INodeProperties[] {
|
||||
displayName: 'Customer Type Name or ID',
|
||||
name: 'customertypecode',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getCustomerTypeCodes',
|
||||
},
|
||||
@@ -250,7 +275,8 @@ export function getAccountFields(): INodeProperties[] {
|
||||
name: 'description',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Additional information to describe the account, such as an excerpt from the company’s website',
|
||||
description:
|
||||
'Additional information to describe the account, such as an excerpt from the company’s website',
|
||||
},
|
||||
{
|
||||
displayName: 'Email Address 1',
|
||||
@@ -284,7 +310,8 @@ export function getAccountFields(): INodeProperties[] {
|
||||
name: 'ftpsiteurl',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'URL for the account’s FTP site to enable users to access data and share documents',
|
||||
description:
|
||||
'URL for the account’s FTP site to enable users to access data and share documents',
|
||||
},
|
||||
{
|
||||
displayName: 'Industry Name or ID',
|
||||
@@ -294,7 +321,8 @@ export function getAccountFields(): INodeProperties[] {
|
||||
loadOptionsMethod: 'getIndustryCodes',
|
||||
},
|
||||
default: '',
|
||||
description: 'The account’s primary industry for use in marketing segmentation and demographic analysis. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'The account’s primary industry for use in marketing segmentation and demographic analysis. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Name',
|
||||
@@ -303,12 +331,8 @@ export function getAccountFields(): INodeProperties[] {
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
'/resource': [
|
||||
'account',
|
||||
],
|
||||
'/operation': [
|
||||
'update',
|
||||
],
|
||||
'/resource': ['account'],
|
||||
'/operation': ['update'],
|
||||
},
|
||||
},
|
||||
description: 'Company o business name',
|
||||
@@ -318,14 +342,16 @@ export function getAccountFields(): INodeProperties[] {
|
||||
name: 'creditlimit',
|
||||
type: 'number',
|
||||
default: '',
|
||||
description: 'Credit limit of the account. This is a useful reference when you address invoice and accounting issues with the customer.',
|
||||
description:
|
||||
'Credit limit of the account. This is a useful reference when you address invoice and accounting issues with the customer.',
|
||||
},
|
||||
{
|
||||
displayName: 'Number Of Employees',
|
||||
name: 'numberofemployees',
|
||||
type: 'number',
|
||||
default: 0,
|
||||
description: 'Number of employees that work at the account for use in marketing segmentation and demographic analysis',
|
||||
description:
|
||||
'Number of employees that work at the account for use in marketing segmentation and demographic analysis',
|
||||
},
|
||||
{
|
||||
displayName: 'Payment Terms Name or ID',
|
||||
@@ -335,7 +361,8 @@ export function getAccountFields(): INodeProperties[] {
|
||||
loadOptionsMethod: 'getPaymentTermsCodes',
|
||||
},
|
||||
default: '',
|
||||
description: 'The payment terms to indicate when the customer needs to pay the total amount. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'The payment terms to indicate when the customer needs to pay the total amount. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Preferred Appointment Day Name or ID',
|
||||
@@ -345,7 +372,8 @@ export function getAccountFields(): INodeProperties[] {
|
||||
loadOptionsMethod: 'getPreferredAppointmentDayCodes',
|
||||
},
|
||||
default: '',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
},
|
||||
{
|
||||
displayName: 'Preferred Appointment Time Name or ID',
|
||||
@@ -355,7 +383,8 @@ export function getAccountFields(): INodeProperties[] {
|
||||
loadOptionsMethod: 'getPreferredAppointmentTimeCodes',
|
||||
},
|
||||
default: '',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
},
|
||||
{
|
||||
displayName: 'Preferred Contact Method Name or ID',
|
||||
@@ -365,7 +394,8 @@ export function getAccountFields(): INodeProperties[] {
|
||||
loadOptionsMethod: 'getPreferredContactMethodCodes',
|
||||
},
|
||||
default: '',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
},
|
||||
{
|
||||
displayName: 'Primary Satori ID',
|
||||
@@ -384,14 +414,16 @@ export function getAccountFields(): INodeProperties[] {
|
||||
name: 'revenue',
|
||||
type: 'number',
|
||||
default: '',
|
||||
description: 'The annual revenue for the account, used as an indicator in financial performance analysis',
|
||||
description:
|
||||
'The annual revenue for the account, used as an indicator in financial performance analysis',
|
||||
},
|
||||
{
|
||||
displayName: 'Shares Outstanding',
|
||||
name: 'sharesoutstanding',
|
||||
type: 'number',
|
||||
default: '',
|
||||
description: 'The number of shares available to the public for the account. This number is used as an indicator in financial performance analysis.',
|
||||
description:
|
||||
'The number of shares available to the public for the account. This number is used as an indicator in financial performance analysis.',
|
||||
},
|
||||
{
|
||||
displayName: 'Shipping Method Name or ID',
|
||||
@@ -401,14 +433,16 @@ export function getAccountFields(): INodeProperties[] {
|
||||
loadOptionsMethod: 'getShippingMethodCodes',
|
||||
},
|
||||
default: '',
|
||||
description: 'Shipping method for deliveries sent to the account’s address to designate the preferred carrier or other delivery option. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'Shipping method for deliveries sent to the account’s address to designate the preferred carrier or other delivery option. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'SIC',
|
||||
name: 'sic',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The Standard Industrial Classification (SIC) code that indicates the account’s primary industry of business, for use in marketing segmentation and demographic analysis',
|
||||
description:
|
||||
'The Standard Industrial Classification (SIC) code that indicates the account’s primary industry of business, for use in marketing segmentation and demographic analysis',
|
||||
},
|
||||
{
|
||||
displayName: 'Stage ID',
|
||||
@@ -421,7 +455,8 @@ export function getAccountFields(): INodeProperties[] {
|
||||
name: 'stockexchange',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The stock exchange at which the account is listed to track their stock and financial performance of the company',
|
||||
description:
|
||||
'The stock exchange at which the account is listed to track their stock and financial performance of the company',
|
||||
},
|
||||
{
|
||||
displayName: 'Telephone 1',
|
||||
@@ -452,14 +487,16 @@ export function getAccountFields(): INodeProperties[] {
|
||||
loadOptionsMethod: 'getTerritoryCodes',
|
||||
},
|
||||
default: '',
|
||||
description: 'Region or territory for the account for use in segmentation and analysis. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'Region or territory for the account for use in segmentation and analysis. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Ticker Symbol',
|
||||
name: 'tickersymbol',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Type the stock exchange symbol for the account to track financial performance of the company. You can click the code entered in this field to access the latest trading information from MSN Money.',
|
||||
description:
|
||||
'Type the stock exchange symbol for the account to track financial performance of the company. You can click the code entered in this field to access the latest trading information from MSN Money.',
|
||||
},
|
||||
{
|
||||
displayName: 'Website URL',
|
||||
@@ -473,14 +510,19 @@ export function getAccountFields(): INodeProperties[] {
|
||||
name: 'yominame',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The phonetic spelling of the company name, if specified in Japanese, to make sure the name is pronounced correctly in phone calls and other communications',
|
||||
description:
|
||||
'The phonetic spelling of the company name, if specified in Japanese, to make sure the name is pronounced correctly in phone calls and other communications',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
export const sort = (a: { name: string }, b: { name: string }) => {
|
||||
if (a.name < b.name) { return -1; }
|
||||
if (a.name > b.name) { return 1; }
|
||||
if (a.name < b.name) {
|
||||
return -1;
|
||||
}
|
||||
if (a.name > b.name) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
@@ -493,11 +535,11 @@ export interface IField {
|
||||
CanBeSecuredForRead: string;
|
||||
AttributeType: string;
|
||||
IsSortableEnabled: {
|
||||
Value: boolean,
|
||||
Value: boolean;
|
||||
};
|
||||
DisplayName: {
|
||||
UserLocalizedLabel: {
|
||||
Label: string
|
||||
}
|
||||
Label: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
@@ -21,10 +19,7 @@ import {
|
||||
sort,
|
||||
} from './GenericFunctions';
|
||||
|
||||
import {
|
||||
accountFields,
|
||||
accountOperations,
|
||||
} from './descriptions';
|
||||
import { accountFields, accountOperations } from './descriptions';
|
||||
|
||||
export class MicrosoftDynamicsCrm implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -91,13 +86,19 @@ export class MicrosoftDynamicsCrm implements INodeType {
|
||||
async getPaymentTermsCodes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
return await getPicklistOptions.call(this, 'account', 'paymenttermscode');
|
||||
},
|
||||
async getPreferredAppointmentDayCodes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
async getPreferredAppointmentDayCodes(
|
||||
this: ILoadOptionsFunctions,
|
||||
): Promise<INodePropertyOptions[]> {
|
||||
return await getPicklistOptions.call(this, 'account', 'preferredappointmentdaycode');
|
||||
},
|
||||
async getPreferredAppointmentTimeCodes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
async getPreferredAppointmentTimeCodes(
|
||||
this: ILoadOptionsFunctions,
|
||||
): Promise<INodePropertyOptions[]> {
|
||||
return await getPicklistOptions.call(this, 'account', 'preferredappointmenttimecode');
|
||||
},
|
||||
async getPreferredContactMethodCodes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
async getPreferredContactMethodCodes(
|
||||
this: ILoadOptionsFunctions,
|
||||
): Promise<INodePropertyOptions[]> {
|
||||
return await getPicklistOptions.call(this, 'account', 'preferredcontactmethodcode');
|
||||
},
|
||||
async getShippingMethodCodes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
@@ -108,13 +109,37 @@ export class MicrosoftDynamicsCrm implements INodeType {
|
||||
},
|
||||
async getAccountFields(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const fields = await getEntityFields.call(this, 'account');
|
||||
const isSelectable = (field: IField) => (field.IsValidForRead && field.CanBeSecuredForRead && field.IsValidODataAttribute && field.LogicalName !== 'slaid');
|
||||
return fields.filter(isSelectable).filter(field => field.DisplayName.UserLocalizedLabel?.Label).map(field => ({ name: field.DisplayName.UserLocalizedLabel.Label, value: field.LogicalName })).sort(sort);
|
||||
const isSelectable = (field: IField) =>
|
||||
field.IsValidForRead &&
|
||||
field.CanBeSecuredForRead &&
|
||||
field.IsValidODataAttribute &&
|
||||
field.LogicalName !== 'slaid';
|
||||
return fields
|
||||
.filter(isSelectable)
|
||||
.filter((field) => field.DisplayName.UserLocalizedLabel?.Label)
|
||||
.map((field) => ({
|
||||
name: field.DisplayName.UserLocalizedLabel.Label,
|
||||
value: field.LogicalName,
|
||||
}))
|
||||
.sort(sort);
|
||||
},
|
||||
async getExpandableAccountFields(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
async getExpandableAccountFields(
|
||||
this: ILoadOptionsFunctions,
|
||||
): Promise<INodePropertyOptions[]> {
|
||||
const fields = await getEntityFields.call(this, 'account');
|
||||
const isSelectable = (field: IField) => (field.IsValidForRead && field.CanBeSecuredForRead && field.IsValidODataAttribute && field.AttributeType === 'Lookup' && field.LogicalName !== 'slaid');
|
||||
return fields.filter(isSelectable).map(field => ({ name: field.DisplayName.UserLocalizedLabel.Label, value: field.LogicalName })).sort(sort);
|
||||
const isSelectable = (field: IField) =>
|
||||
field.IsValidForRead &&
|
||||
field.CanBeSecuredForRead &&
|
||||
field.IsValidODataAttribute &&
|
||||
field.AttributeType === 'Lookup' &&
|
||||
field.LogicalName !== 'slaid';
|
||||
return fields
|
||||
.filter(isSelectable)
|
||||
.map((field) => ({
|
||||
name: field.DisplayName.UserLocalizedLabel.Label,
|
||||
value: field.LogicalName,
|
||||
}))
|
||||
.sort(sort);
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -134,8 +159,10 @@ export class MicrosoftDynamicsCrm implements INodeType {
|
||||
//https://docs.microsoft.com/en-us/powerapps/developer/data-platform/webapi/create-entity-web-api
|
||||
if (operation === 'create') {
|
||||
const name = this.getNodeParameter('name', i) as string;
|
||||
// tslint:disable-next-line: no-any
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as { addresses: { address: [{ [key: string]: any }] } };
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as {
|
||||
// tslint:disable-next-line: no-any
|
||||
addresses: { address: [{ [key: string]: any }] };
|
||||
};
|
||||
const options = this.getNodeParameter('options', i) as { returnFields: string[] };
|
||||
|
||||
const body = {
|
||||
@@ -176,7 +203,13 @@ export class MicrosoftDynamicsCrm implements INodeType {
|
||||
if (options.expandFields) {
|
||||
qs['$expand'] = (options.expandFields as string[]).join(',');
|
||||
}
|
||||
responseData = await microsoftApiRequest.call(this, 'GET', `/accounts(${accountId})`, {}, qs);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/accounts(${accountId})`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
}
|
||||
|
||||
if (operation === 'getAll') {
|
||||
@@ -194,7 +227,14 @@ export class MicrosoftDynamicsCrm implements INodeType {
|
||||
qs['$filter'] = filters.query as string;
|
||||
}
|
||||
if (returnAll) {
|
||||
responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/accounts`, {}, qs);
|
||||
responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/accounts`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
qs['$top'] = this.getNodeParameter('limit', 0) as number;
|
||||
responseData = await microsoftApiRequest.call(this, 'GET', `/accounts`, {}, qs);
|
||||
@@ -204,8 +244,10 @@ export class MicrosoftDynamicsCrm implements INodeType {
|
||||
|
||||
if (operation === 'update') {
|
||||
const accountId = this.getNodeParameter('accountId', i) as string;
|
||||
// tslint:disable-next-line: no-any
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as { addresses: { address: [{ [key: string]: any }] } };
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as {
|
||||
// tslint:disable-next-line: no-any
|
||||
addresses: { address: [{ [key: string]: any }] };
|
||||
};
|
||||
const options = this.getNodeParameter('options', i) as { returnFields: string[] };
|
||||
|
||||
const body = {
|
||||
@@ -225,7 +267,13 @@ export class MicrosoftDynamicsCrm implements INodeType {
|
||||
qs['$select'] = 'accountid';
|
||||
}
|
||||
|
||||
responseData = await microsoftApiRequest.call(this, 'PATCH', `/accounts(${accountId})`, body, qs);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'PATCH',
|
||||
`/accounts(${accountId})`,
|
||||
body,
|
||||
qs,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
getAccountFields,
|
||||
} from '../GenericFunctions';
|
||||
import { getAccountFields } from '../GenericFunctions';
|
||||
|
||||
export const accountOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -14,9 +10,7 @@ export const accountOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'account',
|
||||
],
|
||||
resource: ['account'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -63,12 +57,8 @@ export const accountFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'account',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: ['account'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -80,17 +70,11 @@ export const accountFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'account',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: ['account'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
...getAccountFields(),
|
||||
],
|
||||
options: [...getAccountFields()],
|
||||
},
|
||||
// ----------------------------------------
|
||||
// account:get
|
||||
@@ -103,14 +87,8 @@ export const accountFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'account',
|
||||
],
|
||||
operation: [
|
||||
'delete',
|
||||
'get',
|
||||
'update',
|
||||
],
|
||||
resource: ['account'],
|
||||
operation: ['delete', 'get', 'update'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -123,12 +101,8 @@ export const accountFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'account',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['account'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -140,15 +114,9 @@ export const accountFields: INodeProperties[] = [
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'account',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
resource: ['account'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
@@ -166,13 +134,8 @@ export const accountFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'account',
|
||||
],
|
||||
operation: [
|
||||
'get',
|
||||
'getAll',
|
||||
],
|
||||
resource: ['account'],
|
||||
operation: ['get', 'getAll'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -180,7 +143,8 @@ export const accountFields: INodeProperties[] = [
|
||||
displayName: 'Return Field Names or IDs',
|
||||
name: 'returnFields',
|
||||
type: 'multiOptions',
|
||||
description: 'Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getAccountFields',
|
||||
},
|
||||
@@ -190,7 +154,8 @@ export const accountFields: INodeProperties[] = [
|
||||
displayName: 'Expand Field Names or IDs',
|
||||
name: 'expandFields',
|
||||
type: 'multiOptions',
|
||||
description: 'Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getExpandableAccountFields',
|
||||
},
|
||||
@@ -206,12 +171,8 @@ export const accountFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'account',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['account'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -220,7 +181,8 @@ export const accountFields: INodeProperties[] = [
|
||||
name: 'query',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Query to filter the results. Check <a href="https://docs.microsoft.com/en-us/powerapps/developer/data-platform/webapi/query-data-web-api#filter-results" target="_blank">filters</a>.',
|
||||
description:
|
||||
'Query to filter the results. Check <a href="https://docs.microsoft.com/en-us/powerapps/developer/data-platform/webapi/query-data-web-api#filter-results" target="_blank">filters</a>.',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -236,17 +198,11 @@ export const accountFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'account',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: ['account'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
...getAccountFields(),
|
||||
],
|
||||
options: [...getAccountFields()],
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
@@ -256,13 +212,8 @@ export const accountFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'account',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
'update',
|
||||
],
|
||||
resource: ['account'],
|
||||
operation: ['create', 'update'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -274,7 +225,8 @@ export const accountFields: INodeProperties[] = [
|
||||
loadOptionsMethod: 'getAccountFields',
|
||||
},
|
||||
default: [],
|
||||
description: 'Fields the response will include. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'Fields the response will include. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -1 +1 @@
|
||||
export * from './AccountDescription';
|
||||
export * from './AccountDescription';
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
import { OptionsWithUri } from 'request';
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
IExecuteSingleFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
import {
|
||||
IDataObject, NodeApiError
|
||||
} from 'n8n-workflow';
|
||||
import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core';
|
||||
import { IDataObject, NodeApiError } from 'n8n-workflow';
|
||||
|
||||
export async function microsoftApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
export async function microsoftApiRequest(
|
||||
this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions,
|
||||
method: string,
|
||||
resource: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
qs: IDataObject = {},
|
||||
uri?: string,
|
||||
headers: IDataObject = {},
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const options: OptionsWithUri = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -30,8 +34,16 @@ export async function microsoftApiRequest(this: IExecuteFunctions | IExecuteSing
|
||||
}
|
||||
}
|
||||
|
||||
export async function microsoftApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string ,method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
export async function microsoftApiRequestAllItems(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
propertyName: string,
|
||||
method: string,
|
||||
endpoint: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
query: IDataObject = {},
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
@@ -42,15 +54,21 @@ export async function microsoftApiRequestAllItems(this: IExecuteFunctions | ILoa
|
||||
responseData = await microsoftApiRequest.call(this, method, endpoint, body, query, uri);
|
||||
uri = responseData['@odata.nextLink'];
|
||||
returnData.push.apply(returnData, responseData[propertyName]);
|
||||
} while (
|
||||
responseData['@odata.nextLink'] !== undefined
|
||||
);
|
||||
} while (responseData['@odata.nextLink'] !== undefined);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
export async function microsoftApiRequestAllItemsSkip(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string ,method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
export async function microsoftApiRequestAllItemsSkip(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
propertyName: string,
|
||||
method: string,
|
||||
endpoint: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
query: IDataObject = {},
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
@@ -61,9 +79,7 @@ export async function microsoftApiRequestAllItemsSkip(this: IExecuteFunctions |
|
||||
responseData = await microsoftApiRequest.call(this, method, endpoint, body, query);
|
||||
query['$skip'] += query['$top'];
|
||||
returnData.push.apply(returnData, responseData[propertyName]);
|
||||
} while (
|
||||
responseData['value'].length !== 0
|
||||
);
|
||||
} while (responseData['value'].length !== 0);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
@@ -19,20 +17,11 @@ import {
|
||||
microsoftApiRequestAllItemsSkip,
|
||||
} from './GenericFunctions';
|
||||
|
||||
import {
|
||||
workbookFields,
|
||||
workbookOperations,
|
||||
} from './WorkbookDescription';
|
||||
import { workbookFields, workbookOperations } from './WorkbookDescription';
|
||||
|
||||
import {
|
||||
worksheetFields,
|
||||
worksheetOperations,
|
||||
} from './WorksheetDescription';
|
||||
import { worksheetFields, worksheetOperations } from './WorksheetDescription';
|
||||
|
||||
import {
|
||||
tableFields,
|
||||
tableOperations,
|
||||
} from './TableDescription';
|
||||
import { tableFields, tableOperations } from './TableDescription';
|
||||
|
||||
export class MicrosoftExcel implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -69,12 +58,14 @@ export class MicrosoftExcel implements INodeType {
|
||||
{
|
||||
name: 'Workbook',
|
||||
value: 'workbook',
|
||||
description: 'Workbook is the top level object which contains related workbook objects such as worksheets, tables, ranges, etc',
|
||||
description:
|
||||
'Workbook is the top level object which contains related workbook objects such as worksheets, tables, ranges, etc',
|
||||
},
|
||||
{
|
||||
name: 'Worksheet',
|
||||
value: 'worksheet',
|
||||
description: 'An Excel worksheet is a grid of cells. It can contain data, tables, charts, etc.',
|
||||
description:
|
||||
'An Excel worksheet is a grid of cells. It can contain data, tables, charts, etc.',
|
||||
},
|
||||
],
|
||||
default: 'workbook',
|
||||
@@ -97,7 +88,14 @@ export class MicrosoftExcel implements INodeType {
|
||||
select: 'id,name',
|
||||
};
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const workbooks = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/drive/root/search(q='.xlsx')`, {}, qs);
|
||||
const workbooks = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/drive/root/search(q='.xlsx')`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
for (const workbook of workbooks) {
|
||||
const workbookName = workbook.name;
|
||||
const workbookId = workbook.id;
|
||||
@@ -116,7 +114,14 @@ export class MicrosoftExcel implements INodeType {
|
||||
select: 'id,name',
|
||||
};
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const worksheets = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/drive/items/${workbookId}/workbook/worksheets`, {}, qs);
|
||||
const worksheets = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/drive/items/${workbookId}/workbook/worksheets`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
for (const worksheet of worksheets) {
|
||||
const worksheetName = worksheet.name;
|
||||
const worksheetId = worksheet.id;
|
||||
@@ -136,7 +141,14 @@ export class MicrosoftExcel implements INodeType {
|
||||
select: 'id,name',
|
||||
};
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const tables = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables`, {}, qs);
|
||||
const tables = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
for (const table of tables) {
|
||||
const tableName = table.name;
|
||||
const tableId = table.id;
|
||||
@@ -177,8 +189,14 @@ export class MicrosoftExcel implements INodeType {
|
||||
}
|
||||
|
||||
// Get table columns to eliminate any columns not needed on the input
|
||||
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));
|
||||
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 rows: any[][] = []; // tslint:disable-line:no-any
|
||||
|
||||
@@ -192,9 +210,30 @@ export class MicrosoftExcel implements INodeType {
|
||||
}
|
||||
|
||||
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 });
|
||||
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[]);
|
||||
@@ -226,17 +265,30 @@ export class MicrosoftExcel implements INodeType {
|
||||
}
|
||||
}
|
||||
if (returnAll === true) {
|
||||
responseData = await microsoftApiRequestAllItemsSkip.call(this, 'value', 'GET', `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/columns`, {}, qs);
|
||||
responseData = await microsoftApiRequestAllItemsSkip.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/columns`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
qs['$top'] = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await microsoftApiRequest.call(this, 'GET', `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/columns`, {}, qs);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/columns`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.value;
|
||||
}
|
||||
if (!rawData) {
|
||||
responseData = responseData.map((column: IDataObject) => ({ name: column.name }));
|
||||
} else {
|
||||
const dataProperty = this.getNodeParameter('dataProperty', i) as string;
|
||||
responseData = { [dataProperty] : responseData };
|
||||
responseData = { [dataProperty]: responseData };
|
||||
}
|
||||
|
||||
if (Array.isArray(responseData)) {
|
||||
@@ -270,20 +322,40 @@ 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);
|
||||
responseData = await microsoftApiRequestAllItemsSkip.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/rows`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
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 = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/rows`,
|
||||
{},
|
||||
rowsQs,
|
||||
);
|
||||
responseData = responseData.value;
|
||||
}
|
||||
if (!rawData) {
|
||||
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);
|
||||
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);
|
||||
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++) {
|
||||
@@ -315,15 +387,31 @@ export class MicrosoftExcel implements INodeType {
|
||||
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`, {}, {});
|
||||
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);
|
||||
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);
|
||||
|
||||
if (!columns.includes(lookupColumn)) {
|
||||
throw new NodeApiError(this.getNode(), responseData, { message: `Column ${lookupColumn} does not exist on the table selected` });
|
||||
throw new NodeApiError(this.getNode(), responseData, {
|
||||
message: `Column ${lookupColumn} does not exist on the table selected`,
|
||||
});
|
||||
}
|
||||
|
||||
result.length = 0;
|
||||
@@ -337,12 +425,12 @@ export class MicrosoftExcel implements INodeType {
|
||||
|
||||
if (options.returnAllMatches) {
|
||||
responseData = result.filter((data: IDataObject) => {
|
||||
return (data[lookupColumn]?.toString() === lookupValue );
|
||||
return data[lookupColumn]?.toString() === lookupValue;
|
||||
});
|
||||
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||
} else {
|
||||
responseData = result.find((data: IDataObject) => {
|
||||
return (data[lookupColumn]?.toString() === lookupValue );
|
||||
return data[lookupColumn]?.toString() === lookupValue;
|
||||
});
|
||||
returnData.push(responseData as IDataObject);
|
||||
}
|
||||
@@ -368,9 +456,30 @@ export class MicrosoftExcel implements INodeType {
|
||||
if (additionalFields.name) {
|
||||
body.name = additionalFields.name;
|
||||
}
|
||||
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/add`, body, {}, '', { 'workbook-session-id': id });
|
||||
await microsoftApiRequest.call(this, 'POST', `/drive/items/${workbookId}/workbook/closeSession`, {}, {}, '', { 'workbook-session-id': id });
|
||||
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/add`,
|
||||
body,
|
||||
{},
|
||||
'',
|
||||
{ 'workbook-session-id': id },
|
||||
);
|
||||
await microsoftApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/drive/items/${workbookId}/workbook/closeSession`,
|
||||
{},
|
||||
{},
|
||||
'',
|
||||
{ 'workbook-session-id': id },
|
||||
);
|
||||
}
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
@@ -379,10 +488,23 @@ export class MicrosoftExcel implements INodeType {
|
||||
qs['$select'] = filters.fields;
|
||||
}
|
||||
if (returnAll === true) {
|
||||
responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/drive/root/search(q='.xlsx')`, {}, qs);
|
||||
responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/drive/root/search(q='.xlsx')`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
qs['$top'] = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await microsoftApiRequest.call(this, 'GET', `/drive/root/search(q='.xlsx')`, {}, qs);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/drive/root/search(q='.xlsx')`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.value;
|
||||
}
|
||||
}
|
||||
@@ -414,10 +536,23 @@ export class MicrosoftExcel implements INodeType {
|
||||
qs['$select'] = filters.fields;
|
||||
}
|
||||
if (returnAll === true) {
|
||||
responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/drive/items/${workbookId}/workbook/worksheets`, {}, qs);
|
||||
responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/drive/items/${workbookId}/workbook/worksheets`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
qs['$top'] = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await microsoftApiRequest.call(this, 'GET', `/drive/items/${workbookId}/workbook/worksheets`, {}, qs);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/drive/items/${workbookId}/workbook/worksheets`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.value;
|
||||
}
|
||||
}
|
||||
@@ -434,13 +569,21 @@ export class MicrosoftExcel implements INodeType {
|
||||
}
|
||||
}
|
||||
|
||||
responseData = await microsoftApiRequest.call(this, 'GET', `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/range(address='${range}')`, {}, qs);
|
||||
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;
|
||||
if (responseData.values === null) {
|
||||
throw new NodeApiError(this.getNode(), responseData, { message: 'Range did not return data' });
|
||||
throw new NodeApiError(this.getNode(), responseData, {
|
||||
message: 'Range did not return data',
|
||||
});
|
||||
}
|
||||
const keyValues = responseData.values[keyRow];
|
||||
for (let i = dataStartRow; i < responseData.values.length; i++) {
|
||||
|
||||
@@ -8,9 +8,7 @@ export const tableOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'table',
|
||||
],
|
||||
resource: ['table'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -44,26 +42,22 @@ export const tableOperations: INodeProperties[] = [
|
||||
];
|
||||
|
||||
export const tableFields: INodeProperties[] = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* table:addRow */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* table:addRow */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Workbook Name or ID',
|
||||
name: 'workbook',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getWorkbooks',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'addRow',
|
||||
],
|
||||
resource: [
|
||||
'table',
|
||||
],
|
||||
operation: ['addRow'],
|
||||
resource: ['table'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -72,22 +66,17 @@ export const tableFields: INodeProperties[] = [
|
||||
displayName: 'Worksheet Name or ID',
|
||||
name: 'worksheet',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
required: true,
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getworksheets',
|
||||
loadOptionsDependsOn: [
|
||||
'workbook',
|
||||
],
|
||||
loadOptionsDependsOn: ['workbook'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'addRow',
|
||||
],
|
||||
resource: [
|
||||
'table',
|
||||
],
|
||||
operation: ['addRow'],
|
||||
resource: ['table'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -96,22 +85,17 @@ export const tableFields: INodeProperties[] = [
|
||||
displayName: 'Table Name or ID',
|
||||
name: 'table',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
required: true,
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getTables',
|
||||
loadOptionsDependsOn: [
|
||||
'worksheet',
|
||||
],
|
||||
loadOptionsDependsOn: ['worksheet'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'addRow',
|
||||
],
|
||||
resource: [
|
||||
'table',
|
||||
],
|
||||
operation: ['addRow'],
|
||||
resource: ['table'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -124,12 +108,8 @@ export const tableFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'addRow',
|
||||
],
|
||||
resource: [
|
||||
'table',
|
||||
],
|
||||
operation: ['addRow'],
|
||||
resource: ['table'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -141,29 +121,27 @@ export const tableFields: INodeProperties[] = [
|
||||
typeOptions: {
|
||||
minValue: 0,
|
||||
},
|
||||
description: 'Specifies the relative position of the new row. If not defined, the addition happens at the end. Any rows below the inserted row are shifted downwards. Zero-indexed',
|
||||
description:
|
||||
'Specifies the relative position of the new row. If not defined, the addition happens at the end. Any rows below the inserted row are shifted downwards. Zero-indexed',
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* table:getRows */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* table:getRows */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Workbook Name or ID',
|
||||
name: 'workbook',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getWorkbooks',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getRows',
|
||||
],
|
||||
resource: [
|
||||
'table',
|
||||
],
|
||||
operation: ['getRows'],
|
||||
resource: ['table'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -172,22 +150,17 @@ export const tableFields: INodeProperties[] = [
|
||||
displayName: 'Worksheet Name or ID',
|
||||
name: 'worksheet',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
required: true,
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getworksheets',
|
||||
loadOptionsDependsOn: [
|
||||
'workbook',
|
||||
],
|
||||
loadOptionsDependsOn: ['workbook'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getRows',
|
||||
],
|
||||
resource: [
|
||||
'table',
|
||||
],
|
||||
operation: ['getRows'],
|
||||
resource: ['table'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -196,22 +169,17 @@ export const tableFields: INodeProperties[] = [
|
||||
displayName: 'Table Name or ID',
|
||||
name: 'table',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
required: true,
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getTables',
|
||||
loadOptionsDependsOn: [
|
||||
'worksheet',
|
||||
],
|
||||
loadOptionsDependsOn: ['worksheet'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getRows',
|
||||
],
|
||||
resource: [
|
||||
'table',
|
||||
],
|
||||
operation: ['getRows'],
|
||||
resource: ['table'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -222,12 +190,8 @@ export const tableFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getRows',
|
||||
],
|
||||
resource: [
|
||||
'table',
|
||||
],
|
||||
operation: ['getRows'],
|
||||
resource: ['table'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -239,15 +203,9 @@ export const tableFields: INodeProperties[] = [
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getRows',
|
||||
],
|
||||
resource: [
|
||||
'table',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
operation: ['getRows'],
|
||||
resource: ['table'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
@@ -263,16 +221,13 @@ export const tableFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getRows',
|
||||
],
|
||||
resource: [
|
||||
'table',
|
||||
],
|
||||
operation: ['getRows'],
|
||||
resource: ['table'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether the data should be returned RAW instead of parsed into keys according to their header',
|
||||
description:
|
||||
'Whether the data should be returned RAW instead of parsed into keys according to their header',
|
||||
},
|
||||
{
|
||||
displayName: 'Data Property',
|
||||
@@ -281,15 +236,9 @@ export const tableFields: INodeProperties[] = [
|
||||
default: 'data',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getRows',
|
||||
],
|
||||
resource: [
|
||||
'table',
|
||||
],
|
||||
rawData: [
|
||||
true,
|
||||
],
|
||||
operation: ['getRows'],
|
||||
resource: ['table'],
|
||||
rawData: [true],
|
||||
},
|
||||
},
|
||||
description: 'The name of the property into which to write the RAW data',
|
||||
@@ -302,15 +251,9 @@ export const tableFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getRows',
|
||||
],
|
||||
resource: [
|
||||
'table',
|
||||
],
|
||||
rawData: [
|
||||
true,
|
||||
],
|
||||
operation: ['getRows'],
|
||||
resource: ['table'],
|
||||
rawData: [true],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -323,25 +266,22 @@ export const tableFields: INodeProperties[] = [
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* table:getColumns */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* table:getColumns */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Workbook Name or ID',
|
||||
name: 'workbook',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getWorkbooks',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getColumns',
|
||||
],
|
||||
resource: [
|
||||
'table',
|
||||
],
|
||||
operation: ['getColumns'],
|
||||
resource: ['table'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -350,22 +290,17 @@ export const tableFields: INodeProperties[] = [
|
||||
displayName: 'Worksheet Name or ID',
|
||||
name: 'worksheet',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
required: true,
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getworksheets',
|
||||
loadOptionsDependsOn: [
|
||||
'workbook',
|
||||
],
|
||||
loadOptionsDependsOn: ['workbook'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getColumns',
|
||||
],
|
||||
resource: [
|
||||
'table',
|
||||
],
|
||||
operation: ['getColumns'],
|
||||
resource: ['table'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -374,22 +309,17 @@ export const tableFields: INodeProperties[] = [
|
||||
displayName: 'Table Name or ID',
|
||||
name: 'table',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
required: true,
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getTables',
|
||||
loadOptionsDependsOn: [
|
||||
'worksheet',
|
||||
],
|
||||
loadOptionsDependsOn: ['worksheet'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getColumns',
|
||||
],
|
||||
resource: [
|
||||
'table',
|
||||
],
|
||||
operation: ['getColumns'],
|
||||
resource: ['table'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -400,12 +330,8 @@ export const tableFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getColumns',
|
||||
],
|
||||
resource: [
|
||||
'table',
|
||||
],
|
||||
operation: ['getColumns'],
|
||||
resource: ['table'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -417,15 +343,9 @@ export const tableFields: INodeProperties[] = [
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getColumns',
|
||||
],
|
||||
resource: [
|
||||
'table',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
operation: ['getColumns'],
|
||||
resource: ['table'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
@@ -441,16 +361,13 @@ export const tableFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getColumns',
|
||||
],
|
||||
resource: [
|
||||
'table',
|
||||
],
|
||||
operation: ['getColumns'],
|
||||
resource: ['table'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether the data should be returned RAW instead of parsed into keys according to their header',
|
||||
description:
|
||||
'Whether the data should be returned RAW instead of parsed into keys according to their header',
|
||||
},
|
||||
{
|
||||
displayName: 'Data Property',
|
||||
@@ -459,15 +376,9 @@ export const tableFields: INodeProperties[] = [
|
||||
default: 'data',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getColumns',
|
||||
],
|
||||
resource: [
|
||||
'table',
|
||||
],
|
||||
rawData: [
|
||||
true,
|
||||
],
|
||||
operation: ['getColumns'],
|
||||
resource: ['table'],
|
||||
rawData: [true],
|
||||
},
|
||||
},
|
||||
description: 'The name of the property into which to write the RAW data',
|
||||
@@ -480,15 +391,9 @@ export const tableFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getColumns',
|
||||
],
|
||||
resource: [
|
||||
'table',
|
||||
],
|
||||
rawData: [
|
||||
true,
|
||||
],
|
||||
operation: ['getColumns'],
|
||||
resource: ['table'],
|
||||
rawData: [true],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -501,26 +406,23 @@ export const tableFields: INodeProperties[] = [
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* table:lookup */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* table:lookup */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Workbook Name or ID',
|
||||
name: 'workbook',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
required: true,
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getWorkbooks',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'lookup',
|
||||
],
|
||||
resource: [
|
||||
'table',
|
||||
],
|
||||
operation: ['lookup'],
|
||||
resource: ['table'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -529,22 +431,17 @@ export const tableFields: INodeProperties[] = [
|
||||
displayName: 'Worksheet Name or ID',
|
||||
name: 'worksheet',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
required: true,
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getworksheets',
|
||||
loadOptionsDependsOn: [
|
||||
'workbook',
|
||||
],
|
||||
loadOptionsDependsOn: ['workbook'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'lookup',
|
||||
],
|
||||
resource: [
|
||||
'table',
|
||||
],
|
||||
operation: ['lookup'],
|
||||
resource: ['table'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -553,22 +450,17 @@ export const tableFields: INodeProperties[] = [
|
||||
displayName: 'Table Name or ID',
|
||||
name: 'table',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
required: true,
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getTables',
|
||||
loadOptionsDependsOn: [
|
||||
'worksheet',
|
||||
],
|
||||
loadOptionsDependsOn: ['worksheet'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'lookup',
|
||||
],
|
||||
resource: [
|
||||
'table',
|
||||
],
|
||||
operation: ['lookup'],
|
||||
resource: ['table'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -582,12 +474,8 @@ export const tableFields: INodeProperties[] = [
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'table',
|
||||
],
|
||||
operation: [
|
||||
'lookup',
|
||||
],
|
||||
resource: ['table'],
|
||||
operation: ['lookup'],
|
||||
},
|
||||
},
|
||||
description: 'The name of the column in which to look for value',
|
||||
@@ -601,12 +489,8 @@ export const tableFields: INodeProperties[] = [
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'table',
|
||||
],
|
||||
operation: [
|
||||
'lookup',
|
||||
],
|
||||
resource: ['table'],
|
||||
operation: ['lookup'],
|
||||
},
|
||||
},
|
||||
description: 'The value to look for in column',
|
||||
@@ -619,12 +503,8 @@ export const tableFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'table',
|
||||
],
|
||||
operation: [
|
||||
'lookup',
|
||||
],
|
||||
resource: ['table'],
|
||||
operation: ['lookup'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -634,7 +514,8 @@ export const tableFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether
|
||||
description: 'By default only the first result gets returned. If options gets set all found matches get returned.',
|
||||
description:
|
||||
'By default only the first result gets returned. If options gets set all found matches get returned.',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -8,9 +8,7 @@ export const workbookOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'workbook',
|
||||
],
|
||||
resource: ['workbook'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -32,27 +30,23 @@ export const workbookOperations: INodeProperties[] = [
|
||||
];
|
||||
|
||||
export const workbookFields: INodeProperties[] = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* workbook:addWorksheet */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* workbook:addWorksheet */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Workbook Name or ID',
|
||||
name: 'workbook',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
required: true,
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getWorkbooks',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'addWorksheet',
|
||||
],
|
||||
resource: [
|
||||
'workbook',
|
||||
],
|
||||
operation: ['addWorksheet'],
|
||||
resource: ['workbook'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -65,12 +59,8 @@ export const workbookFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'addWorksheet',
|
||||
],
|
||||
resource: [
|
||||
'workbook',
|
||||
],
|
||||
operation: ['addWorksheet'],
|
||||
resource: ['workbook'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -79,25 +69,22 @@ export const workbookFields: INodeProperties[] = [
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The name of the worksheet to be added. If specified, name should be unqiue. If not specified, Excel determines the name of the new worksheet.',
|
||||
description:
|
||||
'The name of the worksheet to be added. If specified, name should be unqiue. If not specified, Excel determines the name of the new worksheet.',
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* workbook:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* workbook:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'workbook',
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['workbook'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -109,15 +96,9 @@ export const workbookFields: INodeProperties[] = [
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'workbook',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['workbook'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
@@ -135,12 +116,8 @@ export const workbookFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'workbook',
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['workbook'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
|
||||
@@ -8,9 +8,7 @@ export const worksheetOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'worksheet',
|
||||
],
|
||||
resource: ['worksheet'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -32,26 +30,22 @@ export const worksheetOperations: INodeProperties[] = [
|
||||
];
|
||||
|
||||
export const worksheetFields: INodeProperties[] = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* worksheet:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* worksheet:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Workbook Name or ID',
|
||||
name: 'workbook',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getWorkbooks',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'worksheet',
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['worksheet'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -62,12 +56,8 @@ export const worksheetFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'worksheet',
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['worksheet'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -79,15 +69,9 @@ export const worksheetFields: INodeProperties[] = [
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'worksheet',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['worksheet'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
@@ -105,12 +89,8 @@ export const worksheetFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'worksheet',
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['worksheet'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -123,26 +103,23 @@ export const worksheetFields: INodeProperties[] = [
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* worksheet:getContent */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* worksheet:getContent */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Workbook Name or ID',
|
||||
name: 'workbook',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
required: true,
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getWorkbooks',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getContent',
|
||||
],
|
||||
resource: [
|
||||
'worksheet',
|
||||
],
|
||||
operation: ['getContent'],
|
||||
resource: ['worksheet'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -151,22 +128,17 @@ export const worksheetFields: INodeProperties[] = [
|
||||
displayName: 'Worksheet Name or ID',
|
||||
name: 'worksheet',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
required: true,
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getworksheets',
|
||||
loadOptionsDependsOn: [
|
||||
'workbook',
|
||||
],
|
||||
loadOptionsDependsOn: ['workbook'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getContent',
|
||||
],
|
||||
resource: [
|
||||
'worksheet',
|
||||
],
|
||||
operation: ['getContent'],
|
||||
resource: ['worksheet'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -177,17 +149,14 @@ export const worksheetFields: INodeProperties[] = [
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getContent',
|
||||
],
|
||||
resource: [
|
||||
'worksheet',
|
||||
],
|
||||
operation: ['getContent'],
|
||||
resource: ['worksheet'],
|
||||
},
|
||||
},
|
||||
default: 'A1:C3',
|
||||
required: true,
|
||||
description: 'The address or the name of the range. If not specified, the entire worksheet range is returned.',
|
||||
description:
|
||||
'The address or the name of the range. If not specified, the entire worksheet range is returned.',
|
||||
},
|
||||
{
|
||||
displayName: 'RAW Data',
|
||||
@@ -195,16 +164,13 @@ export const worksheetFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getContent',
|
||||
],
|
||||
resource: [
|
||||
'worksheet',
|
||||
],
|
||||
operation: ['getContent'],
|
||||
resource: ['worksheet'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether the data should be returned RAW instead of parsed into keys according to their header',
|
||||
description:
|
||||
'Whether the data should be returned RAW instead of parsed into keys according to their header',
|
||||
},
|
||||
{
|
||||
displayName: 'Data Property',
|
||||
@@ -213,15 +179,9 @@ export const worksheetFields: INodeProperties[] = [
|
||||
default: 'data',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getContent',
|
||||
],
|
||||
resource: [
|
||||
'worksheet',
|
||||
],
|
||||
rawData: [
|
||||
true,
|
||||
],
|
||||
operation: ['getContent'],
|
||||
resource: ['worksheet'],
|
||||
rawData: [true],
|
||||
},
|
||||
},
|
||||
description: 'The name of the property into which to write the RAW data',
|
||||
@@ -236,20 +196,15 @@ export const worksheetFields: INodeProperties[] = [
|
||||
default: 1,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getContent',
|
||||
],
|
||||
resource: [
|
||||
'worksheet',
|
||||
],
|
||||
operation: ['getContent'],
|
||||
resource: ['worksheet'],
|
||||
},
|
||||
hide: {
|
||||
rawData: [
|
||||
true,
|
||||
],
|
||||
rawData: [true],
|
||||
},
|
||||
},
|
||||
description: 'Index of the first row which contains the actual data and not the keys. Starts with 0.',
|
||||
description:
|
||||
'Index of the first row which contains the actual data and not the keys. Starts with 0.',
|
||||
},
|
||||
{
|
||||
displayName: 'Key Row',
|
||||
@@ -260,21 +215,16 @@ export const worksheetFields: INodeProperties[] = [
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getContent',
|
||||
],
|
||||
resource: [
|
||||
'worksheet',
|
||||
],
|
||||
operation: ['getContent'],
|
||||
resource: ['worksheet'],
|
||||
},
|
||||
hide: {
|
||||
rawData: [
|
||||
true,
|
||||
],
|
||||
rawData: [true],
|
||||
},
|
||||
},
|
||||
default: 0,
|
||||
description: 'Index of the row which contains the keys. Starts at 0. The incoming node data is matched to the keys for assignment. The matching is case sensitve.',
|
||||
description:
|
||||
'Index of the row which contains the keys. Starts at 0. The incoming node data is matched to the keys for assignment. The matching is case sensitve.',
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
@@ -284,15 +234,9 @@ export const worksheetFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getContent',
|
||||
],
|
||||
resource: [
|
||||
'worksheet',
|
||||
],
|
||||
rawData: [
|
||||
true,
|
||||
],
|
||||
operation: ['getContent'],
|
||||
resource: ['worksheet'],
|
||||
rawData: [true],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
|
||||
@@ -1,16 +1,8 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
OptionsWithUri,
|
||||
} from 'request';
|
||||
import { OptionsWithUri } from 'request';
|
||||
|
||||
export async function msGraphSecurityApiRequest(
|
||||
this: IExecuteFunctions,
|
||||
@@ -24,10 +16,10 @@ export async function msGraphSecurityApiRequest(
|
||||
oauthTokenData: {
|
||||
access_token, // tslint:disable-line variable-name
|
||||
},
|
||||
} = await this.getCredentials('microsoftGraphSecurityOAuth2Api') as {
|
||||
} = (await this.getCredentials('microsoftGraphSecurityOAuth2Api')) as {
|
||||
oauthTokenData: {
|
||||
access_token: string;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const options: OptionsWithUri = {
|
||||
@@ -72,7 +64,8 @@ export async function msGraphSecurityApiRequest(
|
||||
}
|
||||
|
||||
if (['Invalid filter clause', 'Invalid ODATA query filter'].includes(nestedMessage)) {
|
||||
error.error.error.message += ' - Please check that your query parameter syntax is correct: https://docs.microsoft.com/en-us/graph/query-parameters#filter-parameter';
|
||||
error.error.error.message +=
|
||||
' - Please check that your query parameter syntax is correct: https://docs.microsoft.com/en-us/graph/query-parameters#filter-parameter';
|
||||
}
|
||||
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
msGraphSecurityApiRequest,
|
||||
@@ -72,23 +65,21 @@ export class MicrosoftGraphSecurity implements INodeType {
|
||||
const items = this.getInputData();
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
const resource = this.getNodeParameter('resource', 0) as 'secureScore'| 'secureScoreControlProfile';
|
||||
const resource = this.getNodeParameter('resource', 0) as
|
||||
| 'secureScore'
|
||||
| 'secureScoreControlProfile';
|
||||
const operation = this.getNodeParameter('operation', 0) as 'get' | 'getAll' | 'update';
|
||||
|
||||
let responseData;
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
|
||||
try {
|
||||
|
||||
if (resource === 'secureScore') {
|
||||
|
||||
// **********************************************************************
|
||||
// secureScore
|
||||
// **********************************************************************
|
||||
|
||||
if (operation === 'get') {
|
||||
|
||||
// ----------------------------------------
|
||||
// secureScore: get
|
||||
// ----------------------------------------
|
||||
@@ -97,11 +88,13 @@ export class MicrosoftGraphSecurity implements INodeType {
|
||||
|
||||
const secureScoreId = this.getNodeParameter('secureScoreId', i);
|
||||
|
||||
responseData = await msGraphSecurityApiRequest.call(this, 'GET', `/secureScores/${secureScoreId}`);
|
||||
responseData = await msGraphSecurityApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/secureScores/${secureScoreId}`,
|
||||
);
|
||||
delete responseData['@odata.context'];
|
||||
|
||||
} else if (operation === 'getAll') {
|
||||
|
||||
// ----------------------------------------
|
||||
// secureScore: getAll
|
||||
// ----------------------------------------
|
||||
@@ -110,10 +103,7 @@ export class MicrosoftGraphSecurity implements INodeType {
|
||||
|
||||
const qs: IDataObject = {};
|
||||
|
||||
const {
|
||||
filter,
|
||||
includeControlScores,
|
||||
} = this.getNodeParameter('filters', i) as {
|
||||
const { filter, includeControlScores } = this.getNodeParameter('filters', i) as {
|
||||
filter?: string;
|
||||
includeControlScores?: boolean;
|
||||
};
|
||||
@@ -129,38 +119,35 @@ export class MicrosoftGraphSecurity implements INodeType {
|
||||
qs.$top = this.getNodeParameter('limit', 0);
|
||||
}
|
||||
|
||||
responseData = await msGraphSecurityApiRequest
|
||||
responseData = (await msGraphSecurityApiRequest
|
||||
.call(this, 'GET', '/secureScores', {}, qs)
|
||||
.then(response => response.value) as Array<{ controlScores: object[] }>;
|
||||
.then((response) => response.value)) as Array<{ controlScores: object[] }>;
|
||||
|
||||
if (!includeControlScores) {
|
||||
responseData = responseData.map(({ controlScores, ...rest }) => rest);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else if (resource === 'secureScoreControlProfile') {
|
||||
|
||||
// **********************************************************************
|
||||
// secureScoreControlProfile
|
||||
// **********************************************************************
|
||||
|
||||
if (operation === 'get') {
|
||||
|
||||
// ----------------------------------------
|
||||
// secureScoreControlProfile: get
|
||||
// ----------------------------------------
|
||||
|
||||
// https://docs.microsoft.com/en-us/graph/api/securescorecontrolprofile-get
|
||||
|
||||
const secureScoreControlProfileId = this.getNodeParameter('secureScoreControlProfileId', i);
|
||||
const secureScoreControlProfileId = this.getNodeParameter(
|
||||
'secureScoreControlProfileId',
|
||||
i,
|
||||
);
|
||||
const endpoint = `/secureScoreControlProfiles/${secureScoreControlProfileId}`;
|
||||
|
||||
responseData = await msGraphSecurityApiRequest.call(this, 'GET', endpoint);
|
||||
delete responseData['@odata.context'];
|
||||
|
||||
} else if (operation === 'getAll') {
|
||||
|
||||
// ----------------------------------------
|
||||
// secureScoreControlProfile: getAll
|
||||
// ----------------------------------------
|
||||
@@ -184,10 +171,8 @@ export class MicrosoftGraphSecurity implements INodeType {
|
||||
|
||||
responseData = await msGraphSecurityApiRequest
|
||||
.call(this, 'GET', '/secureScoreControlProfiles', {}, qs)
|
||||
.then(response => response.value);
|
||||
|
||||
.then((response) => response.value);
|
||||
} else if (operation === 'update') {
|
||||
|
||||
// ----------------------------------------
|
||||
// secureScoreControlProfile: update
|
||||
// ----------------------------------------
|
||||
@@ -215,13 +200,17 @@ export class MicrosoftGraphSecurity implements INodeType {
|
||||
const endpoint = `/secureScoreControlProfiles/${id}`;
|
||||
const headers = { Prefer: 'return=representation' };
|
||||
|
||||
responseData = await msGraphSecurityApiRequest.call(this, 'PATCH', endpoint, body, {}, headers);
|
||||
responseData = await msGraphSecurityApiRequest.call(
|
||||
this,
|
||||
'PATCH',
|
||||
endpoint,
|
||||
body,
|
||||
{},
|
||||
headers,
|
||||
);
|
||||
delete responseData['@odata.context'];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
returnData.push({ error: error.message });
|
||||
@@ -233,7 +222,6 @@ export class MicrosoftGraphSecurity implements INodeType {
|
||||
Array.isArray(responseData)
|
||||
? returnData.push(...responseData)
|
||||
: returnData.push(responseData);
|
||||
|
||||
}
|
||||
|
||||
return [this.helpers.returnJsonArray(returnData)];
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const secureScoreControlProfileOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const secureScoreControlProfileOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'secureScoreControlProfile',
|
||||
],
|
||||
resource: ['secureScoreControlProfile'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -49,12 +45,8 @@ export const secureScoreControlProfileFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'secureScoreControlProfile',
|
||||
],
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
resource: ['secureScoreControlProfile'],
|
||||
operation: ['get'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -70,12 +62,8 @@ export const secureScoreControlProfileFields: INodeProperties[] = [
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'secureScoreControlProfile',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['secureScoreControlProfile'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -91,15 +79,9 @@ export const secureScoreControlProfileFields: INodeProperties[] = [
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'secureScoreControlProfile',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
resource: ['secureScoreControlProfile'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -111,23 +93,20 @@ export const secureScoreControlProfileFields: INodeProperties[] = [
|
||||
placeholder: 'Add Filter',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'secureScoreControlProfile',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['secureScoreControlProfile'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Filter Query Parameter',
|
||||
name: 'filter',
|
||||
description: '<a href="https://docs.microsoft.com/en-us/graph/query-parameters#filter-parameter">Query parameter</a> to filter results by',
|
||||
description:
|
||||
'<a href="https://docs.microsoft.com/en-us/graph/query-parameters#filter-parameter">Query parameter</a> to filter results by',
|
||||
type: 'string',
|
||||
default: '',
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-placeholder-miscased-id
|
||||
placeholder: 'startsWith(id, \'AATP\')',
|
||||
placeholder: "startsWith(id, 'AATP')",
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -144,12 +123,8 @@ export const secureScoreControlProfileFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'secureScoreControlProfile',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: ['secureScoreControlProfile'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -163,12 +138,8 @@ export const secureScoreControlProfileFields: INodeProperties[] = [
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'secureScoreControlProfile',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: ['secureScoreControlProfile'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -182,12 +153,8 @@ export const secureScoreControlProfileFields: INodeProperties[] = [
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'secureScoreControlProfile',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: ['secureScoreControlProfile'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -199,12 +166,8 @@ export const secureScoreControlProfileFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'secureScoreControlProfile',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: ['secureScoreControlProfile'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const secureScoreOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const secureScoreOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'secureScore',
|
||||
],
|
||||
resource: ['secureScore'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -44,12 +40,8 @@ export const secureScoreFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'secureScore',
|
||||
],
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
resource: ['secureScore'],
|
||||
operation: ['get'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -65,12 +57,8 @@ export const secureScoreFields: INodeProperties[] = [
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'secureScore',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['secureScore'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -86,15 +74,9 @@ export const secureScoreFields: INodeProperties[] = [
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'secureScore',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
resource: ['secureScore'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -106,19 +88,16 @@ export const secureScoreFields: INodeProperties[] = [
|
||||
placeholder: 'Add Filter',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'secureScore',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['secureScore'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Filter Query Parameter',
|
||||
name: 'filter',
|
||||
description: '<a href="https://docs.microsoft.com/en-us/graph/query-parameters#filter-parameter">Query parameter</a> to filter results by',
|
||||
description:
|
||||
'<a href="https://docs.microsoft.com/en-us/graph/query-parameters#filter-parameter">Query parameter</a> to filter results by',
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'currentScore eq 13',
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const fileOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const fileOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
resource: ['file'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -70,22 +66,17 @@ export const fileOperations: INodeProperties[] = [
|
||||
];
|
||||
|
||||
export const fileFields: INodeProperties[] = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* file:copy */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* file:copy */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'File ID',
|
||||
name: 'fileId',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'copy',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: ['copy'],
|
||||
resource: ['file'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -97,12 +88,8 @@ export const fileFields: INodeProperties[] = [
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'copy',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: ['copy'],
|
||||
resource: ['file'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
@@ -112,7 +99,8 @@ export const fileFields: INodeProperties[] = [
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The new name for the copy. If this isn\'t provided, the same name will be used as the original.',
|
||||
description:
|
||||
"The new name for the copy. If this isn't provided, the same name will be used as the original.",
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -121,15 +109,12 @@ export const fileFields: INodeProperties[] = [
|
||||
name: 'parentReference',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Parent Reference',
|
||||
description: 'Reference to the parent item the copy will be created in <a href="https://docs.microsoft.com/en-us/onedrive/developer/rest-api/resources/itemreference?view=odsp-graph-online"> Details </a>',
|
||||
description:
|
||||
'Reference to the parent item the copy will be created in <a href="https://docs.microsoft.com/en-us/onedrive/developer/rest-api/resources/itemreference?view=odsp-graph-online"> Details </a>',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'copy',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: ['copy'],
|
||||
resource: ['file'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
@@ -192,41 +177,33 @@ export const fileFields: INodeProperties[] = [
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* file:delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* file:delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'File ID',
|
||||
name: 'fileId',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'delete',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: ['delete'],
|
||||
resource: ['file'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Field ID',
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* file:download */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* file:download */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'File ID',
|
||||
name: 'fileId',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'download',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: ['download'],
|
||||
resource: ['file'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -239,108 +216,85 @@ export const fileFields: INodeProperties[] = [
|
||||
default: 'data',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'download',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: ['download'],
|
||||
resource: ['file'],
|
||||
},
|
||||
},
|
||||
description: 'Name of the binary property to which to write the data of the read file',
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* file:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* file:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'File ID',
|
||||
name: 'fileId',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: ['get'],
|
||||
resource: ['file'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Field ID',
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* file:rename */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Item ID',
|
||||
name: 'itemId',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'rename',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* file:rename */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Item ID',
|
||||
name: 'itemId',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['rename'],
|
||||
resource: ['file'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'ID of the file',
|
||||
},
|
||||
default: '',
|
||||
description: 'ID of the file',
|
||||
},
|
||||
{
|
||||
displayName: 'New Name',
|
||||
name: 'newName',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'rename',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
{
|
||||
displayName: 'New Name',
|
||||
name: 'newName',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['rename'],
|
||||
resource: ['file'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'New name for file',
|
||||
},
|
||||
default: '',
|
||||
description: 'New name for file',
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* file:search */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* file:search */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Query',
|
||||
name: 'query',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'search',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: ['search'],
|
||||
resource: ['file'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The query text used to search for items. Values may be matched across several fields including filename, metadata, and file content.',
|
||||
description:
|
||||
'The query text used to search for items. Values may be matched across several fields including filename, metadata, and file content.',
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* file:share */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* file:share */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'File ID',
|
||||
name: 'fileId',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'share',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: ['share'],
|
||||
resource: ['file'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -365,12 +319,8 @@ export const fileFields: INodeProperties[] = [
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'share',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: ['share'],
|
||||
resource: ['file'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -392,32 +342,24 @@ export const fileFields: INodeProperties[] = [
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'share',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: ['share'],
|
||||
resource: ['file'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The type of sharing link to create',
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* file:upload */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* file:upload */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'File Name',
|
||||
name: 'fileName',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'upload',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: ['upload'],
|
||||
resource: ['file'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -430,12 +372,8 @@ export const fileFields: INodeProperties[] = [
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'upload',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: ['upload'],
|
||||
resource: ['file'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -449,12 +387,8 @@ export const fileFields: INodeProperties[] = [
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'upload',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: ['upload'],
|
||||
resource: ['file'],
|
||||
},
|
||||
},
|
||||
description: 'Whether the data to upload should be taken from binary field',
|
||||
@@ -467,17 +401,10 @@ export const fileFields: INodeProperties[] = [
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
binaryData: [
|
||||
false,
|
||||
],
|
||||
operation: [
|
||||
'upload',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
binaryData: [false],
|
||||
operation: ['upload'],
|
||||
resource: ['file'],
|
||||
},
|
||||
|
||||
},
|
||||
placeholder: '',
|
||||
description: 'The text content of the file',
|
||||
@@ -490,17 +417,10 @@ export const fileFields: INodeProperties[] = [
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
binaryData: [
|
||||
true,
|
||||
],
|
||||
operation: [
|
||||
'upload',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
binaryData: [true],
|
||||
operation: ['upload'],
|
||||
resource: ['file'],
|
||||
},
|
||||
|
||||
},
|
||||
placeholder: '',
|
||||
description: 'Name of the binary property which contains the data for the file',
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const folderOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const folderOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
resource: ['folder'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -58,10 +54,9 @@ export const folderOperations: INodeProperties[] = [
|
||||
];
|
||||
|
||||
export const folderFields: INodeProperties[] = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* folder:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* folder:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
@@ -70,12 +65,8 @@ export const folderFields: INodeProperties[] = [
|
||||
placeholder: '/Pictures/2021',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
operation: ['create'],
|
||||
resource: ['folder'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -87,12 +78,8 @@ export const folderFields: INodeProperties[] = [
|
||||
type: 'collection',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
operation: ['create'],
|
||||
resource: ['folder'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
@@ -107,98 +94,78 @@ export const folderFields: INodeProperties[] = [
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* folder:getChildren/delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* folder:getChildren/delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Folder ID',
|
||||
name: 'folderId',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'delete',
|
||||
'getChildren',
|
||||
],
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
operation: ['delete', 'getChildren'],
|
||||
resource: ['folder'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* folder:rename */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Item ID',
|
||||
name: 'itemId',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'rename',
|
||||
],
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* folder:rename */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Item ID',
|
||||
name: 'itemId',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['rename'],
|
||||
resource: ['folder'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'ID of the folder',
|
||||
},
|
||||
default: '',
|
||||
description: 'ID of the folder',
|
||||
},
|
||||
{
|
||||
displayName: 'New Name',
|
||||
name: 'newName',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'rename',
|
||||
],
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
{
|
||||
displayName: 'New Name',
|
||||
name: 'newName',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['rename'],
|
||||
resource: ['folder'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'New name for folder',
|
||||
},
|
||||
default: '',
|
||||
description: 'New name for folder',
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* folder:search */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* folder:search */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Query',
|
||||
name: 'query',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'search',
|
||||
],
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
operation: ['search'],
|
||||
resource: ['folder'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The query text used to search for items. Values may be matched across several fields including filename, metadata, and file content.',
|
||||
description:
|
||||
'The query text used to search for items. Values may be matched across several fields including filename, metadata, and file content.',
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* folder:share */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* folder:share */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Folder ID',
|
||||
name: 'folderId',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'share',
|
||||
],
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
operation: ['share'],
|
||||
resource: ['folder'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -224,12 +191,8 @@ export const folderFields: INodeProperties[] = [
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'share',
|
||||
],
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
operation: ['share'],
|
||||
resource: ['folder'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -251,12 +214,8 @@ export const folderFields: INodeProperties[] = [
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'share',
|
||||
],
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
operation: ['share'],
|
||||
resource: ['folder'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
import {
|
||||
OptionsWithUri
|
||||
} from 'request';
|
||||
import { OptionsWithUri } from 'request';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
IExecuteSingleFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject, NodeApiError
|
||||
} from 'n8n-workflow';
|
||||
import { IDataObject, NodeApiError } from 'n8n-workflow';
|
||||
|
||||
export async function microsoftApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}, option: IDataObject = { json: true }): Promise<any> { // tslint:disable-line:no-any
|
||||
export async function microsoftApiRequest(
|
||||
this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions,
|
||||
method: string,
|
||||
resource: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
qs: IDataObject = {},
|
||||
uri?: string,
|
||||
headers: IDataObject = {},
|
||||
option: IDataObject = { json: true },
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const options: OptionsWithUri = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -40,8 +43,16 @@ export async function microsoftApiRequest(this: IExecuteFunctions | IExecuteSing
|
||||
}
|
||||
}
|
||||
|
||||
export async function microsoftApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string ,method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
export async function microsoftApiRequestAllItems(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
propertyName: string,
|
||||
method: string,
|
||||
endpoint: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
query: IDataObject = {},
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
@@ -55,15 +66,21 @@ export async function microsoftApiRequestAllItems(this: IExecuteFunctions | ILoa
|
||||
delete query['$top'];
|
||||
}
|
||||
returnData.push.apply(returnData, responseData[propertyName]);
|
||||
} while (
|
||||
responseData['@odata.nextLink'] !== undefined
|
||||
);
|
||||
} while (responseData['@odata.nextLink'] !== undefined);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
export async function microsoftApiRequestAllItemsSkip(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string ,method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
export async function microsoftApiRequestAllItemsSkip(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
propertyName: string,
|
||||
method: string,
|
||||
endpoint: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
query: IDataObject = {},
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
@@ -74,9 +91,7 @@ export async function microsoftApiRequestAllItemsSkip(this: IExecuteFunctions |
|
||||
responseData = await microsoftApiRequest.call(this, method, endpoint, body, query);
|
||||
query['$skip'] += query['$top'];
|
||||
returnData.push.apply(returnData, responseData[propertyName]);
|
||||
} while (
|
||||
responseData['value'].length !== 0
|
||||
);
|
||||
} while (responseData['value'].length !== 0);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IBinaryKeyData,
|
||||
@@ -12,20 +10,11 @@ import {
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
microsoftApiRequest,
|
||||
microsoftApiRequestAllItems,
|
||||
} from './GenericFunctions';
|
||||
import { microsoftApiRequest, microsoftApiRequestAllItems } from './GenericFunctions';
|
||||
|
||||
import {
|
||||
fileFields,
|
||||
fileOperations,
|
||||
} from './FileDescription';
|
||||
import { fileFields, fileOperations } from './FileDescription';
|
||||
|
||||
import {
|
||||
folderFields,
|
||||
folderOperations,
|
||||
} from './FolderDescription';
|
||||
import { folderFields, folderOperations } from './FolderDescription';
|
||||
|
||||
export class MicrosoftOneDrive implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -95,7 +84,16 @@ export class MicrosoftOneDrive implements INodeType {
|
||||
if (additionalFields.name) {
|
||||
body.name = additionalFields.name as string;
|
||||
}
|
||||
responseData = await microsoftApiRequest.call(this, 'POST', `/drive/items/${fileId}/copy`, body, {}, undefined, {}, { json: true, resolveWithFullResponse: true });
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/drive/items/${fileId}/copy`,
|
||||
body,
|
||||
{},
|
||||
undefined,
|
||||
{},
|
||||
{ json: true, resolveWithFullResponse: true },
|
||||
);
|
||||
responseData = { location: responseData.headers.location };
|
||||
returnData.push(responseData as IDataObject);
|
||||
}
|
||||
@@ -109,13 +107,18 @@ export class MicrosoftOneDrive implements INodeType {
|
||||
//https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_list_children?view=odsp-graph-online
|
||||
if (operation === 'download') {
|
||||
const fileId = this.getNodeParameter('fileId', i) as string;
|
||||
const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i) as string;
|
||||
const dataPropertyNameDownload = this.getNodeParameter(
|
||||
'binaryPropertyName',
|
||||
i,
|
||||
) as string;
|
||||
responseData = await microsoftApiRequest.call(this, 'GET', `/drive/items/${fileId}`);
|
||||
|
||||
const fileName = responseData.name;
|
||||
|
||||
if (responseData.file === undefined) {
|
||||
throw new NodeApiError(this.getNode(), responseData, { message: 'The ID you provided does not belong to a file.' });
|
||||
throw new NodeApiError(this.getNode(), responseData, {
|
||||
message: 'The ID you provided does not belong to a file.',
|
||||
});
|
||||
}
|
||||
|
||||
let mimeType: string | undefined;
|
||||
@@ -123,7 +126,16 @@ export class MicrosoftOneDrive implements INodeType {
|
||||
mimeType = responseData.file.mimeType;
|
||||
}
|
||||
|
||||
responseData = await microsoftApiRequest.call(this, 'GET', `/drive/items/${fileId}/content`, {}, {}, undefined, {}, { encoding: null, resolveWithFullResponse: true });
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/drive/items/${fileId}/content`,
|
||||
{},
|
||||
{},
|
||||
undefined,
|
||||
{},
|
||||
{ encoding: null, resolveWithFullResponse: true },
|
||||
);
|
||||
|
||||
const newItem: INodeExecutionData = {
|
||||
json: items[i].json,
|
||||
@@ -145,7 +157,11 @@ export class MicrosoftOneDrive implements INodeType {
|
||||
|
||||
const data = Buffer.from(responseData.body);
|
||||
|
||||
items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(data as unknown as Buffer, fileName, mimeType);
|
||||
items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(
|
||||
data as unknown as Buffer,
|
||||
fileName,
|
||||
mimeType,
|
||||
);
|
||||
}
|
||||
//https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_get?view=odsp-graph-online
|
||||
if (operation === 'get') {
|
||||
@@ -156,7 +172,12 @@ export class MicrosoftOneDrive implements INodeType {
|
||||
//https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_search?view=odsp-graph-online
|
||||
if (operation === 'search') {
|
||||
const query = this.getNodeParameter('query', i) as string;
|
||||
responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/drive/root/search(q='${query}')`);
|
||||
responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/drive/root/search(q='${query}')`,
|
||||
);
|
||||
responseData = responseData.filter((item: IDataObject) => item.file);
|
||||
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||
}
|
||||
@@ -169,7 +190,12 @@ export class MicrosoftOneDrive implements INodeType {
|
||||
type,
|
||||
scope,
|
||||
};
|
||||
responseData = await microsoftApiRequest.call(this, 'POST', `/drive/items/${fileId}/createLink`, body);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/drive/items/${fileId}/createLink`,
|
||||
body,
|
||||
);
|
||||
returnData.push(responseData);
|
||||
}
|
||||
//https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_put_content?view=odsp-graph-online#example-upload-a-new-file
|
||||
@@ -182,18 +208,24 @@ export class MicrosoftOneDrive implements INodeType {
|
||||
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0) as string;
|
||||
|
||||
if (items[i].binary === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i });
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', {
|
||||
itemIndex: i,
|
||||
});
|
||||
}
|
||||
//@ts-ignore
|
||||
if (items[i].binary[binaryPropertyName] === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`No binary data property "${binaryPropertyName}" does not exists on item!`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
|
||||
const binaryData = (items[i].binary as IBinaryKeyData)[binaryPropertyName];
|
||||
const body = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
||||
let encodedFilename;
|
||||
|
||||
if(fileName !== '') {
|
||||
if (fileName !== '') {
|
||||
encodedFilename = encodeURIComponent(fileName);
|
||||
}
|
||||
|
||||
@@ -201,16 +233,35 @@ export class MicrosoftOneDrive implements INodeType {
|
||||
encodedFilename = encodeURIComponent(binaryData.fileName);
|
||||
}
|
||||
|
||||
responseData = await microsoftApiRequest.call(this, 'PUT', `/drive/items/${parentId}:/${encodedFilename}:/content`, body, {}, undefined, { 'Content-Type': binaryData.mimeType, 'Content-length': body.length }, {});
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'PUT',
|
||||
`/drive/items/${parentId}:/${encodedFilename}:/content`,
|
||||
body,
|
||||
{},
|
||||
undefined,
|
||||
{ 'Content-Type': binaryData.mimeType, 'Content-length': body.length },
|
||||
{},
|
||||
);
|
||||
|
||||
returnData.push(JSON.parse(responseData) as IDataObject);
|
||||
} else {
|
||||
const body = this.getNodeParameter('fileContent', i) as string;
|
||||
if (fileName === '') {
|
||||
throw new NodeOperationError(this.getNode(), 'File name must be set!', { itemIndex: i });
|
||||
throw new NodeOperationError(this.getNode(), 'File name must be set!', {
|
||||
itemIndex: i,
|
||||
});
|
||||
}
|
||||
const encodedFilename = encodeURIComponent(fileName);
|
||||
responseData = await microsoftApiRequest.call(this, 'PUT', `/drive/items/${parentId}:/${encodedFilename}:/content`, body, {}, undefined, { 'Content-Type': 'text/plain' });
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'PUT',
|
||||
`/drive/items/${parentId}:/${encodedFilename}:/content`,
|
||||
body,
|
||||
{},
|
||||
undefined,
|
||||
{ 'Content-Type': 'text/plain' },
|
||||
);
|
||||
returnData.push(responseData as IDataObject);
|
||||
}
|
||||
}
|
||||
@@ -218,7 +269,9 @@ export class MicrosoftOneDrive implements INodeType {
|
||||
if (resource === 'folder') {
|
||||
//https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_post_children?view=odsp-graph-online
|
||||
if (operation === 'create') {
|
||||
const names = (this.getNodeParameter('name', i) as string).split('/').filter(s => s.trim() !== '');
|
||||
const names = (this.getNodeParameter('name', i) as string)
|
||||
.split('/')
|
||||
.filter((s) => s.trim() !== '');
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
let parentFolderId = options.parentFolderId ? options.parentFolderId : null;
|
||||
for (const name of names) {
|
||||
@@ -241,20 +294,34 @@ export class MicrosoftOneDrive implements INodeType {
|
||||
//https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_delete?view=odsp-graph-online
|
||||
if (operation === 'delete') {
|
||||
const folderId = this.getNodeParameter('folderId', i) as string;
|
||||
responseData = await microsoftApiRequest.call(this, 'DELETE', `/drive/items/${folderId}`);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/drive/items/${folderId}`,
|
||||
);
|
||||
responseData = { success: true };
|
||||
returnData.push(responseData as IDataObject);
|
||||
}
|
||||
//https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_list_children?view=odsp-graph-online
|
||||
if (operation === 'getChildren') {
|
||||
const folderId = this.getNodeParameter('folderId', i) as string;
|
||||
responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/drive/items/${folderId}/children`);
|
||||
responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/drive/items/${folderId}/children`,
|
||||
);
|
||||
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||
}
|
||||
//https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_search?view=odsp-graph-online
|
||||
if (operation === 'search') {
|
||||
const query = this.getNodeParameter('query', i) as string;
|
||||
responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/drive/root/search(q='${query}')`);
|
||||
responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/drive/root/search(q='${query}')`,
|
||||
);
|
||||
responseData = responseData.filter((item: IDataObject) => item.folder);
|
||||
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||
}
|
||||
@@ -267,7 +334,12 @@ export class MicrosoftOneDrive implements INodeType {
|
||||
type,
|
||||
scope,
|
||||
};
|
||||
responseData = await microsoftApiRequest.call(this, 'POST', `/drive/items/${folderId}/createLink`, body);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/drive/items/${folderId}/createLink`,
|
||||
body,
|
||||
);
|
||||
returnData.push(responseData);
|
||||
}
|
||||
}
|
||||
@@ -275,8 +347,13 @@ export class MicrosoftOneDrive implements INodeType {
|
||||
if (operation === 'rename') {
|
||||
const itemId = this.getNodeParameter('itemId', i) as string;
|
||||
const newName = this.getNodeParameter('newName', i) as string;
|
||||
const body = {name: newName};
|
||||
responseData = await microsoftApiRequest.call(this, 'PATCH', `/drive/items/${itemId}`, body);
|
||||
const body = { name: newName };
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'PATCH',
|
||||
`/drive/items/${itemId}`,
|
||||
body,
|
||||
);
|
||||
returnData.push(responseData as IDataObject);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const draftOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const draftOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'draft',
|
||||
],
|
||||
resource: ['draft'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -60,15 +56,8 @@ export const draftFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'draft',
|
||||
],
|
||||
operation: [
|
||||
'delete',
|
||||
'get',
|
||||
'send',
|
||||
'update',
|
||||
],
|
||||
resource: ['draft'],
|
||||
operation: ['delete', 'get', 'send', 'update'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -80,12 +69,8 @@ export const draftFields: INodeProperties[] = [
|
||||
description: 'The subject of the message',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'draft',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: ['draft'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
type: 'string',
|
||||
@@ -98,12 +83,8 @@ export const draftFields: INodeProperties[] = [
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'draft',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: ['draft'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -116,12 +97,8 @@ export const draftFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'draft',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: ['draft'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -144,12 +121,12 @@ export const draftFields: INodeProperties[] = [
|
||||
name: 'binaryPropertyName',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Name of the binary property containing the data to be added to the email as an attachment',
|
||||
description:
|
||||
'Name of the binary property containing the data to be added to the email as an attachment',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
},
|
||||
{
|
||||
displayName: 'BCC Recipients',
|
||||
@@ -179,7 +156,8 @@ export const draftFields: INodeProperties[] = [
|
||||
displayName: 'Category Names or IDs',
|
||||
name: 'categories',
|
||||
type: 'multiOptions',
|
||||
description: 'Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getCategories',
|
||||
},
|
||||
@@ -227,7 +205,8 @@ export const draftFields: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'From',
|
||||
name: 'from',
|
||||
description: 'The owner of the mailbox which the message is sent. Must correspond to the actual mailbox used.',
|
||||
description:
|
||||
'The owner of the mailbox which the message is sent. Must correspond to the actual mailbox used.',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
@@ -285,12 +264,8 @@ export const draftFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'draft',
|
||||
],
|
||||
operation: [
|
||||
'send',
|
||||
],
|
||||
resource: ['draft'],
|
||||
operation: ['send'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -303,7 +278,4 @@ export const draftFields: INodeProperties[] = [
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
|
||||
|
||||
];
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const draftMessageSharedFields: INodeProperties[] = [
|
||||
|
||||
// Get & Get All operations
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
@@ -13,14 +10,8 @@ export const draftMessageSharedFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'draft',
|
||||
'message',
|
||||
],
|
||||
operation: [
|
||||
'get',
|
||||
'getAll',
|
||||
],
|
||||
resource: ['draft', 'message'],
|
||||
operation: ['get', 'getAll'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -29,7 +20,8 @@ export const draftMessageSharedFields: INodeProperties[] = [
|
||||
name: 'dataPropertyAttachmentsPrefixName',
|
||||
type: 'string',
|
||||
default: 'attachment_',
|
||||
description: 'Prefix for name of the binary property to which to write the attachments. An index starting with 0 will be added. So if name is "attachment_" the first attachment is saved to "attachment_0"',
|
||||
description:
|
||||
'Prefix for name of the binary property to which to write the attachments. An index starting with 0 will be added. So if name is "attachment_" the first attachment is saved to "attachment_0"',
|
||||
},
|
||||
{
|
||||
displayName: 'Fields',
|
||||
@@ -44,7 +36,8 @@ export const draftMessageSharedFields: INodeProperties[] = [
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'isRead eq false',
|
||||
description: 'Microsoft Graph API OData $filter query. Information about the syntax can be found <a href="https://docs.microsoft.com/en-us/graph/query-parameters#filter-parameter">here</a>.',
|
||||
description:
|
||||
'Microsoft Graph API OData $filter query. Information about the syntax can be found <a href="https://docs.microsoft.com/en-us/graph/query-parameters#filter-parameter">here</a>.',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -58,13 +51,8 @@ export const draftMessageSharedFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'draft',
|
||||
'message',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: ['draft', 'message'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -103,7 +91,8 @@ export const draftMessageSharedFields: INodeProperties[] = [
|
||||
displayName: 'Category Names or IDs',
|
||||
name: 'categories',
|
||||
type: 'multiOptions',
|
||||
description: 'Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getCategories',
|
||||
},
|
||||
@@ -151,7 +140,8 @@ export const draftMessageSharedFields: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'From',
|
||||
name: 'from',
|
||||
description: 'The owner of the mailbox which the message is sent. Must correspond to the actual mailbox used.',
|
||||
description:
|
||||
'The owner of the mailbox which the message is sent. Must correspond to the actual mailbox used.',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
@@ -213,5 +203,4 @@ export const draftMessageSharedFields: INodeProperties[] = [
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
];
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const folderOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,16 +8,14 @@ export const folderOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
resource: ['folder'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a new mail folder in the root folder of the user\'s mailbox',
|
||||
description: "Create a new mail folder in the root folder of the user's mailbox",
|
||||
action: 'Create a folder',
|
||||
},
|
||||
{
|
||||
@@ -60,15 +56,8 @@ export const folderFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
operation: [
|
||||
'delete',
|
||||
'get',
|
||||
'getChildren',
|
||||
'update',
|
||||
],
|
||||
resource: ['folder'],
|
||||
operation: ['delete', 'get', 'getChildren', 'update'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -79,13 +68,8 @@ export const folderFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
'getChildren',
|
||||
],
|
||||
resource: ['folder'],
|
||||
operation: ['getAll', 'getChildren'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -97,13 +81,8 @@ export const folderFields: INodeProperties[] = [
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
'getChildren',
|
||||
],
|
||||
resource: ['folder'],
|
||||
operation: ['getAll', 'getChildren'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
@@ -132,12 +111,8 @@ export const folderFields: INodeProperties[] = [
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: ['folder'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: 'folder',
|
||||
@@ -151,12 +126,8 @@ export const folderFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: ['folder'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -168,15 +139,9 @@ export const folderFields: INodeProperties[] = [
|
||||
default: false,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
folderType: [
|
||||
'searchFolder',
|
||||
],
|
||||
resource: ['folder'],
|
||||
operation: ['create'],
|
||||
folderType: ['searchFolder'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -191,15 +156,9 @@ export const folderFields: INodeProperties[] = [
|
||||
default: [],
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
folderType: [
|
||||
'searchFolder',
|
||||
],
|
||||
resource: ['folder'],
|
||||
operation: ['create'],
|
||||
folderType: ['searchFolder'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -212,15 +171,9 @@ export const folderFields: INodeProperties[] = [
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
folderType: [
|
||||
'searchFolder',
|
||||
],
|
||||
resource: ['folder'],
|
||||
operation: ['create'],
|
||||
folderType: ['searchFolder'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -232,14 +185,8 @@ export const folderFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
operation: [
|
||||
'get',
|
||||
'getAll',
|
||||
'getChildren',
|
||||
],
|
||||
resource: ['folder'],
|
||||
operation: ['get', 'getAll', 'getChildren'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -255,7 +202,8 @@ export const folderFields: INodeProperties[] = [
|
||||
name: 'filter',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Microsoft Graph API OData $filter query. Information about the syntax can be found <a href="https://docs.microsoft.com/en-us/graph/query-parameters#filter-parameter">here</a>.',
|
||||
description:
|
||||
'Microsoft Graph API OData $filter query. Information about the syntax can be found <a href="https://docs.microsoft.com/en-us/graph/query-parameters#filter-parameter">here</a>.',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -269,12 +217,8 @@ export const folderFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: ['folder'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -311,5 +255,4 @@ export const folderFields: INodeProperties[] = [
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
];
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const folderMessageOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const folderMessageOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'folderMessage',
|
||||
],
|
||||
resource: ['folderMessage'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -36,12 +32,8 @@ export const folderMessageFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'folderMessage',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['folderMessage'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -51,12 +43,8 @@ export const folderMessageFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'folderMessage',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['folderMessage'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -68,15 +56,9 @@ export const folderMessageFields: INodeProperties[] = [
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'folderMessage',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
resource: ['folderMessage'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
@@ -94,12 +76,8 @@ export const folderMessageFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'folderMessage',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['folderMessage'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -115,7 +93,8 @@ export const folderMessageFields: INodeProperties[] = [
|
||||
name: 'filter',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Microsoft Graph API OData $filter query. Information about the syntax can be found <a href="https://docs.microsoft.com/en-us/graph/query-parameters#filter-parameter">here</a>.',
|
||||
description:
|
||||
'Microsoft Graph API OData $filter query. Information about the syntax can be found <a href="https://docs.microsoft.com/en-us/graph/query-parameters#filter-parameter">here</a>.',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
import {
|
||||
OptionsWithUri,
|
||||
} from 'request';
|
||||
import { OptionsWithUri } from 'request';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
IExecuteSingleFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
INodeExecutionData,
|
||||
NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
import { IDataObject, INodeExecutionData, NodeApiError } from 'n8n-workflow';
|
||||
|
||||
export async function microsoftApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}, option: IDataObject = { json: true }): Promise<any> { // tslint:disable-line:no-any
|
||||
export async function microsoftApiRequest(
|
||||
this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions,
|
||||
method: string,
|
||||
resource: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
qs: IDataObject = {},
|
||||
uri?: string,
|
||||
headers: IDataObject = {},
|
||||
option: IDataObject = { json: true },
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const credentials = await this.getCredentials('microsoftOutlookOAuth2Api');
|
||||
|
||||
let apiUrl = `https://graph.microsoft.com/v1.0/me${resource}`;
|
||||
@@ -50,8 +51,17 @@ export async function microsoftApiRequest(this: IExecuteFunctions | IExecuteSing
|
||||
}
|
||||
}
|
||||
|
||||
export async function microsoftApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}, headers: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
export async function microsoftApiRequestAllItems(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
propertyName: string,
|
||||
method: string,
|
||||
endpoint: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
query: IDataObject = {},
|
||||
headers: IDataObject = {},
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
@@ -59,18 +69,33 @@ export async function microsoftApiRequestAllItems(this: IExecuteFunctions | ILoa
|
||||
query['$top'] = 100;
|
||||
|
||||
do {
|
||||
responseData = await microsoftApiRequest.call(this, method, endpoint, body, query, uri, headers);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
method,
|
||||
endpoint,
|
||||
body,
|
||||
query,
|
||||
uri,
|
||||
headers,
|
||||
);
|
||||
uri = responseData['@odata.nextLink'];
|
||||
returnData.push.apply(returnData, responseData[propertyName]);
|
||||
} while (
|
||||
responseData['@odata.nextLink'] !== undefined
|
||||
);
|
||||
} while (responseData['@odata.nextLink'] !== undefined);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
export async function microsoftApiRequestAllItemsSkip(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}, headers: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
export async function microsoftApiRequestAllItemsSkip(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
propertyName: string,
|
||||
method: string,
|
||||
endpoint: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
query: IDataObject = {},
|
||||
headers: IDataObject = {},
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
@@ -78,12 +103,18 @@ export async function microsoftApiRequestAllItemsSkip(this: IExecuteFunctions |
|
||||
query['$skip'] = 0;
|
||||
|
||||
do {
|
||||
responseData = await microsoftApiRequest.call(this, method, endpoint, body, query, undefined, headers);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
method,
|
||||
endpoint,
|
||||
body,
|
||||
query,
|
||||
undefined,
|
||||
headers,
|
||||
);
|
||||
query['$skip'] += query['$top'];
|
||||
returnData.push.apply(returnData, responseData[propertyName]);
|
||||
} while (
|
||||
responseData['value'].length !== 0
|
||||
);
|
||||
} while (responseData['value'].length !== 0);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
@@ -112,32 +143,40 @@ export function createMessage(fields: IDataObject) {
|
||||
}
|
||||
|
||||
// Handle custom headers
|
||||
if ('internetMessageHeaders' in fields && 'headers' in (fields.internetMessageHeaders as IDataObject)) {
|
||||
if (
|
||||
'internetMessageHeaders' in fields &&
|
||||
'headers' in (fields.internetMessageHeaders as IDataObject)
|
||||
) {
|
||||
fields.internetMessageHeaders = (fields.internetMessageHeaders as IDataObject).headers;
|
||||
}
|
||||
|
||||
// Handle recipient fields
|
||||
['bccRecipients', 'ccRecipients', 'replyTo', 'sender', 'toRecipients'].forEach(key => {
|
||||
['bccRecipients', 'ccRecipients', 'replyTo', 'sender', 'toRecipients'].forEach((key) => {
|
||||
if (Array.isArray(fields[key])) {
|
||||
fields[key] = (fields[key] as string[]).map(email => makeRecipient(email));
|
||||
fields[key] = (fields[key] as string[]).map((email) => makeRecipient(email));
|
||||
} else if (fields[key] !== undefined) {
|
||||
fields[key] = (fields[key] as string).split(',').map((recipient: string) => makeRecipient(recipient));
|
||||
fields[key] = (fields[key] as string)
|
||||
.split(',')
|
||||
.map((recipient: string) => makeRecipient(recipient));
|
||||
}
|
||||
});
|
||||
|
||||
['from', 'sender'].forEach(key => {
|
||||
['from', 'sender'].forEach((key) => {
|
||||
if (fields[key] !== undefined) {
|
||||
fields[key] = makeRecipient(fields[key] as string);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Object.assign(message, fields);
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
export async function downloadAttachments(this: IExecuteFunctions, messages: IDataObject[] | IDataObject, prefix: string) {
|
||||
export async function downloadAttachments(
|
||||
this: IExecuteFunctions,
|
||||
messages: IDataObject[] | IDataObject,
|
||||
prefix: string,
|
||||
) {
|
||||
const elements: INodeExecutionData[] = [];
|
||||
if (!Array.isArray(messages)) {
|
||||
messages = [messages];
|
||||
@@ -168,7 +207,11 @@ export async function downloadAttachments(this: IExecuteFunctions, messages: IDa
|
||||
);
|
||||
|
||||
const data = Buffer.from(response.body as string, 'utf8');
|
||||
element.binary![`${prefix}${index}`] = await this.helpers.prepareBinaryData(data as unknown as Buffer, attachment.name, attachment.contentType);
|
||||
element.binary![`${prefix}${index}`] = await this.helpers.prepareBinaryData(
|
||||
data as unknown as Buffer,
|
||||
attachment.name,
|
||||
attachment.contentType,
|
||||
);
|
||||
}
|
||||
}
|
||||
if (Object.keys(element.binary!).length === 0) {
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const messageAttachmentOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const messageAttachmentOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'messageAttachment',
|
||||
],
|
||||
resource: ['messageAttachment'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -37,7 +33,7 @@ export const messageAttachmentOperations: INodeProperties[] = [
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
description: 'Get all the message\'s attachments',
|
||||
description: "Get all the message's attachments",
|
||||
action: 'Get all message attachments',
|
||||
},
|
||||
],
|
||||
@@ -54,15 +50,8 @@ export const messageAttachmentFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'messageAttachment',
|
||||
],
|
||||
operation: [
|
||||
'add',
|
||||
'download',
|
||||
'get',
|
||||
'getAll',
|
||||
],
|
||||
resource: ['messageAttachment'],
|
||||
operation: ['add', 'download', 'get', 'getAll'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -74,13 +63,8 @@ export const messageAttachmentFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'messageAttachment',
|
||||
],
|
||||
operation: [
|
||||
'download',
|
||||
'get',
|
||||
],
|
||||
resource: ['messageAttachment'],
|
||||
operation: ['download', 'get'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -92,12 +76,8 @@ export const messageAttachmentFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'messageAttachment',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['messageAttachment'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -109,15 +89,9 @@ export const messageAttachmentFields: INodeProperties[] = [
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'messageAttachment',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
resource: ['messageAttachment'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
@@ -128,7 +102,6 @@ export const messageAttachmentFields: INodeProperties[] = [
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
|
||||
|
||||
// messageAttachment:create, messageAttachment:update, messageAttachment:send
|
||||
|
||||
// File operations
|
||||
@@ -141,13 +114,8 @@ export const messageAttachmentFields: INodeProperties[] = [
|
||||
default: 'data',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'messageAttachment',
|
||||
],
|
||||
operation: [
|
||||
'add',
|
||||
'download',
|
||||
],
|
||||
resource: ['messageAttachment'],
|
||||
operation: ['add', 'download'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -161,19 +129,16 @@ export const messageAttachmentFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'messageAttachment',
|
||||
],
|
||||
operation: [
|
||||
'add',
|
||||
],
|
||||
resource: ['messageAttachment'],
|
||||
operation: ['add'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'File Name',
|
||||
name: 'fileName',
|
||||
description: 'Filename of the attachment. If not set will the file-name of the binary property be used, if it exists.',
|
||||
description:
|
||||
'Filename of the attachment. If not set will the file-name of the binary property be used, if it exists.',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
@@ -189,13 +154,8 @@ export const messageAttachmentFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'messageAttachment',
|
||||
],
|
||||
operation: [
|
||||
'get',
|
||||
'getAll',
|
||||
],
|
||||
resource: ['messageAttachment'],
|
||||
operation: ['get', 'getAll'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const messageOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const messageOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'message',
|
||||
],
|
||||
resource: ['message'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -31,7 +27,7 @@ export const messageOperations: INodeProperties[] = [
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
description: 'Get all messages in the signed-in user\'s mailbox',
|
||||
description: "Get all messages in the signed-in user's mailbox",
|
||||
action: 'Get all messages',
|
||||
},
|
||||
{
|
||||
@@ -78,9 +74,7 @@ export const messageFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'message',
|
||||
],
|
||||
resource: ['message'],
|
||||
operation: [
|
||||
'addAttachment',
|
||||
'delete',
|
||||
@@ -114,12 +108,8 @@ export const messageFields: INodeProperties[] = [
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'message',
|
||||
],
|
||||
operation: [
|
||||
'reply',
|
||||
],
|
||||
resource: ['message'],
|
||||
operation: ['reply'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -129,12 +119,8 @@ export const messageFields: INodeProperties[] = [
|
||||
description: 'A comment to include. Can be an empty string.',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'message',
|
||||
],
|
||||
operation: [
|
||||
'reply',
|
||||
],
|
||||
resource: ['message'],
|
||||
operation: ['reply'],
|
||||
},
|
||||
},
|
||||
type: 'string',
|
||||
@@ -143,15 +129,12 @@ export const messageFields: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Send',
|
||||
name: 'send',
|
||||
description: 'Whether to send the reply message directly. If not set, it will be saved as draft.',
|
||||
description:
|
||||
'Whether to send the reply message directly. If not set, it will be saved as draft.',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'message',
|
||||
],
|
||||
operation: [
|
||||
'reply',
|
||||
],
|
||||
resource: ['message'],
|
||||
operation: ['reply'],
|
||||
},
|
||||
},
|
||||
type: 'boolean',
|
||||
@@ -165,15 +148,9 @@ export const messageFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'message',
|
||||
],
|
||||
operation: [
|
||||
'reply',
|
||||
],
|
||||
replyType: [
|
||||
'reply',
|
||||
],
|
||||
resource: ['message'],
|
||||
operation: ['reply'],
|
||||
replyType: ['reply'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -196,12 +173,12 @@ export const messageFields: INodeProperties[] = [
|
||||
name: 'binaryPropertyName',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Name of the binary property containing the data to be added to the email as an attachment',
|
||||
description:
|
||||
'Name of the binary property containing the data to be added to the email as an attachment',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
},
|
||||
{
|
||||
displayName: 'BCC Recipients',
|
||||
@@ -276,7 +253,8 @@ export const messageFields: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'From',
|
||||
name: 'from',
|
||||
description: 'The owner of the mailbox which the message is sent. Must correspond to the actual mailbox used.',
|
||||
description:
|
||||
'The owner of the mailbox which the message is sent. Must correspond to the actual mailbox used.',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
@@ -339,12 +317,8 @@ export const messageFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'message',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['message'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -356,15 +330,9 @@ export const messageFields: INodeProperties[] = [
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'message',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
resource: ['message'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
@@ -382,13 +350,8 @@ export const messageFields: INodeProperties[] = [
|
||||
description: 'The subject of the message',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'message',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
'send',
|
||||
],
|
||||
resource: ['message'],
|
||||
operation: ['create', 'send'],
|
||||
},
|
||||
},
|
||||
type: 'string',
|
||||
@@ -401,13 +364,8 @@ export const messageFields: INodeProperties[] = [
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'message',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
'send',
|
||||
],
|
||||
resource: ['message'],
|
||||
operation: ['create', 'send'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -419,12 +377,8 @@ export const messageFields: INodeProperties[] = [
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'message',
|
||||
],
|
||||
operation: [
|
||||
'send',
|
||||
],
|
||||
resource: ['message'],
|
||||
operation: ['send'],
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
@@ -438,12 +392,8 @@ export const messageFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'message',
|
||||
],
|
||||
operation: [
|
||||
'send',
|
||||
],
|
||||
resource: ['message'],
|
||||
operation: ['send'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -466,12 +416,12 @@ export const messageFields: INodeProperties[] = [
|
||||
name: 'binaryPropertyName',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Name of the binary property containing the data to be added to the email as an attachment',
|
||||
description:
|
||||
'Name of the binary property containing the data to be added to the email as an attachment',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
},
|
||||
{
|
||||
displayName: 'BCC Recipients',
|
||||
@@ -501,7 +451,8 @@ export const messageFields: INodeProperties[] = [
|
||||
displayName: 'Category Names or IDs',
|
||||
name: 'categories',
|
||||
type: 'multiOptions',
|
||||
description: 'Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getCategories',
|
||||
},
|
||||
@@ -549,7 +500,8 @@ export const messageFields: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'From',
|
||||
name: 'from',
|
||||
description: 'The owner of the mailbox which the message is sent. Must correspond to the actual mailbox used.',
|
||||
description:
|
||||
'The owner of the mailbox which the message is sent. Must correspond to the actual mailbox used.',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
@@ -615,12 +567,8 @@ export const messageFields: INodeProperties[] = [
|
||||
default: 'data',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'message',
|
||||
],
|
||||
operation: [
|
||||
'getMime',
|
||||
],
|
||||
resource: ['message'],
|
||||
operation: ['getMime'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -635,12 +583,8 @@ export const messageFields: INodeProperties[] = [
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'message',
|
||||
],
|
||||
operation: [
|
||||
'move',
|
||||
],
|
||||
resource: ['message'],
|
||||
operation: ['move'],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IBinaryKeyData,
|
||||
@@ -19,37 +17,23 @@ import {
|
||||
downloadAttachments,
|
||||
makeRecipient,
|
||||
microsoftApiRequest,
|
||||
microsoftApiRequestAllItems
|
||||
microsoftApiRequestAllItems,
|
||||
} from './GenericFunctions';
|
||||
|
||||
import {
|
||||
draftFields,
|
||||
draftOperations,
|
||||
} from './DraftDescription';
|
||||
import { draftFields, draftOperations } from './DraftDescription';
|
||||
|
||||
import {
|
||||
draftMessageSharedFields,
|
||||
} from './DraftMessageSharedDescription';
|
||||
import { draftMessageSharedFields } from './DraftMessageSharedDescription';
|
||||
|
||||
import {
|
||||
messageFields,
|
||||
messageOperations,
|
||||
} from './MessageDescription';
|
||||
import { messageFields, messageOperations } from './MessageDescription';
|
||||
|
||||
import {
|
||||
messageAttachmentFields,
|
||||
messageAttachmentOperations,
|
||||
} from './MessageAttachmentDescription';
|
||||
|
||||
import {
|
||||
folderFields,
|
||||
folderOperations,
|
||||
} from './FolderDescription';
|
||||
import { folderFields, folderOperations } from './FolderDescription';
|
||||
|
||||
import {
|
||||
folderMessageFields,
|
||||
folderMessageOperations,
|
||||
} from './FolderMessageDecription';
|
||||
import { folderMessageFields, folderMessageOperations } from './FolderMessageDecription';
|
||||
|
||||
export class MicrosoftOutlook implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -128,7 +112,12 @@ export class MicrosoftOutlook implements INodeType {
|
||||
// select them easily
|
||||
async getCategories(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const categories = await microsoftApiRequestAllItems.call(this, 'value', 'GET', '/outlook/masterCategories');
|
||||
const categories = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
'/outlook/masterCategories',
|
||||
);
|
||||
for (const category of categories) {
|
||||
returnData.push({
|
||||
name: category.displayName as string,
|
||||
@@ -155,11 +144,7 @@ export class MicrosoftOutlook implements INodeType {
|
||||
for (let i = 0; i < length; i++) {
|
||||
try {
|
||||
const messageId = this.getNodeParameter('messageId', i) as string;
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/messages/${messageId}`,
|
||||
);
|
||||
responseData = await microsoftApiRequest.call(this, 'DELETE', `/messages/${messageId}`);
|
||||
|
||||
returnData.push({ success: true });
|
||||
} catch (error) {
|
||||
@@ -245,7 +230,6 @@ export class MicrosoftOutlook implements INodeType {
|
||||
}
|
||||
|
||||
if (resource === 'draft') {
|
||||
|
||||
if (operation === 'create') {
|
||||
for (let i = 0; i < length; i++) {
|
||||
try {
|
||||
@@ -263,18 +247,25 @@ export class MicrosoftOutlook implements INodeType {
|
||||
const body: IDataObject = createMessage(additionalFields);
|
||||
|
||||
if (additionalFields.attachments) {
|
||||
const attachments = (additionalFields.attachments as IDataObject).attachments as IDataObject[];
|
||||
const attachments = (additionalFields.attachments as IDataObject)
|
||||
.attachments as IDataObject[];
|
||||
|
||||
// // Handle attachments
|
||||
body['attachments'] = attachments.map(attachment => {
|
||||
body['attachments'] = attachments.map((attachment) => {
|
||||
const binaryPropertyName = attachment.binaryPropertyName as string;
|
||||
|
||||
if (items[i].binary === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i });
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', {
|
||||
itemIndex: i,
|
||||
});
|
||||
}
|
||||
//@ts-ignore
|
||||
if (items[i].binary[binaryPropertyName] === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`No binary data property "${binaryPropertyName}" does not exists on item!`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
|
||||
const binaryData = (items[i].binary as IBinaryKeyData)[binaryPropertyName];
|
||||
@@ -286,13 +277,7 @@ export class MicrosoftOutlook implements INodeType {
|
||||
});
|
||||
}
|
||||
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/messages`,
|
||||
body,
|
||||
{},
|
||||
);
|
||||
responseData = await microsoftApiRequest.call(this, 'POST', `/messages`, body, {});
|
||||
|
||||
returnData.push(responseData);
|
||||
} catch (error) {
|
||||
@@ -309,17 +294,20 @@ export class MicrosoftOutlook implements INodeType {
|
||||
for (let i = 0; i < length; i++) {
|
||||
try {
|
||||
const messageId = this.getNodeParameter('messageId', i);
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i, {}) as IDataObject;
|
||||
const additionalFields = this.getNodeParameter(
|
||||
'additionalFields',
|
||||
i,
|
||||
{},
|
||||
) as IDataObject;
|
||||
|
||||
if (additionalFields && additionalFields.recipients) {
|
||||
const recipients = ((additionalFields.recipients as string).split(',') as string[]).filter(email => !!email);
|
||||
const recipients = (
|
||||
(additionalFields.recipients as string).split(',') as string[]
|
||||
).filter((email) => !!email);
|
||||
if (recipients.length !== 0) {
|
||||
await microsoftApiRequest.call(
|
||||
this,
|
||||
'PATCH',
|
||||
`/messages/${messageId}`,
|
||||
{ toRecipients: recipients.map((recipient: string) => makeRecipient(recipient)) },
|
||||
);
|
||||
await microsoftApiRequest.call(this, 'PATCH', `/messages/${messageId}`, {
|
||||
toRecipients: recipients.map((recipient: string) => makeRecipient(recipient)),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,7 +330,6 @@ export class MicrosoftOutlook implements INodeType {
|
||||
}
|
||||
|
||||
if (resource === 'message') {
|
||||
|
||||
if (operation === 'reply') {
|
||||
for (let i = 0; i < length; i++) {
|
||||
try {
|
||||
@@ -350,7 +337,11 @@ export class MicrosoftOutlook implements INodeType {
|
||||
const replyType = this.getNodeParameter('replyType', i) as string;
|
||||
const comment = this.getNodeParameter('comment', i) as string;
|
||||
const send = this.getNodeParameter('send', i, false) as boolean;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i, {}) as IDataObject;
|
||||
const additionalFields = this.getNodeParameter(
|
||||
'additionalFields',
|
||||
i,
|
||||
{},
|
||||
) as IDataObject;
|
||||
|
||||
const body: IDataObject = {};
|
||||
|
||||
@@ -374,17 +365,24 @@ export class MicrosoftOutlook implements INodeType {
|
||||
);
|
||||
|
||||
if (additionalFields.attachments) {
|
||||
const attachments = (additionalFields.attachments as IDataObject).attachments as IDataObject[];
|
||||
const attachments = (additionalFields.attachments as IDataObject)
|
||||
.attachments as IDataObject[];
|
||||
// // Handle attachments
|
||||
const data = attachments.map(attachment => {
|
||||
const data = attachments.map((attachment) => {
|
||||
const binaryPropertyName = attachment.binaryPropertyName as string;
|
||||
|
||||
if (items[i].binary === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i });
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', {
|
||||
itemIndex: i,
|
||||
});
|
||||
}
|
||||
//@ts-ignore
|
||||
if (items[i].binary[binaryPropertyName] === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`No binary data property "${binaryPropertyName}" does not exists on item!`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
|
||||
const binaryData = (items[i].binary as IBinaryKeyData)[binaryPropertyName];
|
||||
@@ -407,11 +405,7 @@ export class MicrosoftOutlook implements INodeType {
|
||||
}
|
||||
|
||||
if (send === true) {
|
||||
await microsoftApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/messages/${responseData.id}/send`,
|
||||
);
|
||||
await microsoftApiRequest.call(this, 'POST', `/messages/${responseData.id}/send`);
|
||||
}
|
||||
|
||||
returnData.push(responseData);
|
||||
@@ -429,7 +423,10 @@ export class MicrosoftOutlook implements INodeType {
|
||||
for (let i = 0; i < length; i++) {
|
||||
try {
|
||||
const messageId = this.getNodeParameter('messageId', i) as string;
|
||||
const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i) as string;
|
||||
const dataPropertyNameDownload = this.getNodeParameter(
|
||||
'binaryPropertyName',
|
||||
i,
|
||||
) as string;
|
||||
const response = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
@@ -460,10 +457,13 @@ export class MicrosoftOutlook implements INodeType {
|
||||
|
||||
items[i] = newItem;
|
||||
|
||||
|
||||
const fileName = `${messageId}.eml`;
|
||||
const data = Buffer.from(response.body as string, 'utf8');
|
||||
items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(data as unknown as Buffer, fileName, mimeType);
|
||||
items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(
|
||||
data as unknown as Buffer,
|
||||
fileName,
|
||||
mimeType,
|
||||
);
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
items[i].json = { error: error.message };
|
||||
@@ -502,13 +502,7 @@ export class MicrosoftOutlook implements INodeType {
|
||||
);
|
||||
} else {
|
||||
qs['$top'] = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
endpoint,
|
||||
undefined,
|
||||
qs,
|
||||
);
|
||||
responseData = await microsoftApiRequest.call(this, 'GET', endpoint, undefined, qs);
|
||||
responseData = responseData.value;
|
||||
}
|
||||
|
||||
@@ -576,25 +570,35 @@ export class MicrosoftOutlook implements INodeType {
|
||||
|
||||
additionalFields.toRecipients = toRecipients;
|
||||
|
||||
const saveToSentItems = additionalFields.saveToSentItems === undefined ? true : additionalFields.saveToSentItems;
|
||||
const saveToSentItems =
|
||||
additionalFields.saveToSentItems === undefined
|
||||
? true
|
||||
: additionalFields.saveToSentItems;
|
||||
delete additionalFields.saveToSentItems;
|
||||
|
||||
// Create message object from optional fields
|
||||
const message: IDataObject = createMessage(additionalFields);
|
||||
|
||||
if (additionalFields.attachments) {
|
||||
const attachments = (additionalFields.attachments as IDataObject).attachments as IDataObject[];
|
||||
const attachments = (additionalFields.attachments as IDataObject)
|
||||
.attachments as IDataObject[];
|
||||
|
||||
// // Handle attachments
|
||||
message['attachments'] = attachments.map(attachment => {
|
||||
message['attachments'] = attachments.map((attachment) => {
|
||||
const binaryPropertyName = attachment.binaryPropertyName as string;
|
||||
|
||||
if (items[i].binary === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i });
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', {
|
||||
itemIndex: i,
|
||||
});
|
||||
}
|
||||
//@ts-ignore
|
||||
if (items[i].binary[binaryPropertyName] === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`No binary data property "${binaryPropertyName}" does not exists on item!`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
|
||||
const binaryData = (items[i].binary as IBinaryKeyData)[binaryPropertyName];
|
||||
@@ -611,13 +615,7 @@ export class MicrosoftOutlook implements INodeType {
|
||||
saveToSentItems,
|
||||
};
|
||||
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/sendMail`,
|
||||
body,
|
||||
{},
|
||||
);
|
||||
responseData = await microsoftApiRequest.call(this, 'POST', `/sendMail`, body, {});
|
||||
returnData.push({ success: true });
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
@@ -628,7 +626,6 @@ export class MicrosoftOutlook implements INodeType {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (resource === 'messageAttachment') {
|
||||
@@ -644,16 +641,27 @@ export class MicrosoftOutlook implements INodeType {
|
||||
}
|
||||
//@ts-ignore
|
||||
if (items[i].binary[binaryPropertyName] === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`No binary data property "${binaryPropertyName}" does not exists on item!`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
|
||||
const binaryData = (items[i].binary as IBinaryKeyData)[binaryPropertyName];
|
||||
const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
||||
|
||||
const fileName = additionalFields.fileName === undefined ? binaryData.fileName : additionalFields.fileName;
|
||||
const fileName =
|
||||
additionalFields.fileName === undefined
|
||||
? binaryData.fileName
|
||||
: additionalFields.fileName;
|
||||
|
||||
if (!fileName) {
|
||||
throw new NodeOperationError(this.getNode(), 'File name is not set. It has either to be set via "Additional Fields" or has to be set on the binary property!', { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'File name is not set. It has either to be set via "Additional Fields" or has to be set on the binary property!',
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
|
||||
// Check if the file is over 3MB big
|
||||
@@ -678,27 +686,31 @@ export class MicrosoftOutlook implements INodeType {
|
||||
const uploadUrl = responseData.uploadUrl;
|
||||
|
||||
if (uploadUrl === undefined) {
|
||||
throw new NodeApiError(this.getNode(), responseData, { message: 'Failed to get upload session' });
|
||||
throw new NodeApiError(this.getNode(), responseData, {
|
||||
message: 'Failed to get upload session',
|
||||
});
|
||||
}
|
||||
|
||||
for (let bytesUploaded = 0; bytesUploaded < dataBuffer.length; bytesUploaded += chunkSize) {
|
||||
for (
|
||||
let bytesUploaded = 0;
|
||||
bytesUploaded < dataBuffer.length;
|
||||
bytesUploaded += chunkSize
|
||||
) {
|
||||
// Upload the file chunk by chunk
|
||||
const nextChunk = Math.min(bytesUploaded + chunkSize, dataBuffer.length);
|
||||
const contentRange = `bytes ${bytesUploaded}-${nextChunk - 1}/${dataBuffer.length}`;
|
||||
|
||||
const data = dataBuffer.subarray(bytesUploaded, nextChunk);
|
||||
|
||||
responseData = await this.helpers.request(
|
||||
uploadUrl,
|
||||
{
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/octet-stream',
|
||||
'Content-Length': data.length,
|
||||
'Content-Range': contentRange,
|
||||
},
|
||||
body: data,
|
||||
});
|
||||
responseData = await this.helpers.request(uploadUrl, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/octet-stream',
|
||||
'Content-Length': data.length,
|
||||
'Content-Range': contentRange,
|
||||
},
|
||||
body: data,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const body: IDataObject = {
|
||||
@@ -731,7 +743,10 @@ export class MicrosoftOutlook implements INodeType {
|
||||
try {
|
||||
const messageId = this.getNodeParameter('messageId', i) as string;
|
||||
const attachmentId = this.getNodeParameter('attachmentId', i) as string;
|
||||
const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i) as string;
|
||||
const dataPropertyNameDownload = this.getNodeParameter(
|
||||
'binaryPropertyName',
|
||||
i,
|
||||
) as string;
|
||||
|
||||
// Get attachment details first
|
||||
const attachmentDetails = await microsoftApiRequest.call(
|
||||
@@ -739,7 +754,7 @@ export class MicrosoftOutlook implements INodeType {
|
||||
'GET',
|
||||
`/messages/${messageId}/attachments/${attachmentId}`,
|
||||
undefined,
|
||||
{ '$select': 'id,name,contentType' },
|
||||
{ $select: 'id,name,contentType' },
|
||||
);
|
||||
|
||||
let mimeType: string | undefined;
|
||||
@@ -773,7 +788,11 @@ export class MicrosoftOutlook implements INodeType {
|
||||
|
||||
items[i] = newItem;
|
||||
const data = Buffer.from(response.body as string, 'utf8');
|
||||
items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(data as unknown as Buffer, fileName, mimeType);
|
||||
items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(
|
||||
data as unknown as Buffer,
|
||||
fileName,
|
||||
mimeType,
|
||||
);
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
items[i].json = { error: error.message };
|
||||
@@ -844,13 +863,7 @@ export class MicrosoftOutlook implements INodeType {
|
||||
);
|
||||
} else {
|
||||
qs['$top'] = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
endpoint,
|
||||
undefined,
|
||||
qs,
|
||||
);
|
||||
responseData = await microsoftApiRequest.call(this, 'GET', endpoint, undefined, qs);
|
||||
responseData = responseData.value;
|
||||
}
|
||||
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||
@@ -890,12 +903,7 @@ export class MicrosoftOutlook implements INodeType {
|
||||
});
|
||||
}
|
||||
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
endpoint,
|
||||
body,
|
||||
);
|
||||
responseData = await microsoftApiRequest.call(this, 'POST', endpoint, body);
|
||||
returnData.push(responseData);
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
@@ -983,13 +991,7 @@ export class MicrosoftOutlook implements INodeType {
|
||||
);
|
||||
} else {
|
||||
qs['$top'] = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'/mailFolders',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
responseData = await microsoftApiRequest.call(this, 'GET', '/mailFolders', {}, qs);
|
||||
responseData = responseData.value;
|
||||
}
|
||||
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||
@@ -1101,31 +1103,27 @@ export class MicrosoftOutlook implements INodeType {
|
||||
endpoint,
|
||||
qs,
|
||||
);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
qs['$top'] = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
endpoint,
|
||||
undefined,
|
||||
qs,
|
||||
);
|
||||
responseData = await microsoftApiRequest.call(this, 'GET', endpoint, undefined, qs);
|
||||
responseData = responseData.value;
|
||||
}
|
||||
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||
}
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
returnData.push({ error: error.message });
|
||||
continue;
|
||||
}
|
||||
throw error;
|
||||
if (this.continueOnFail()) {
|
||||
returnData.push({ error: error.message });
|
||||
continue;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((resource === 'message' && operation === 'getMime') || (resource === 'messageAttachment' && operation === 'download')) {
|
||||
if (
|
||||
(resource === 'message' && operation === 'getMime') ||
|
||||
(resource === 'messageAttachment' && operation === 'download')
|
||||
) {
|
||||
return this.prepareOutputData(items);
|
||||
} else {
|
||||
return [this.helpers.returnJsonArray(returnData)];
|
||||
|
||||
@@ -9,10 +9,7 @@ import { ITables } from './TableInterface';
|
||||
* @param {string[]} properties The properties it should include
|
||||
* @returns
|
||||
*/
|
||||
export function copyInputItem(
|
||||
item: INodeExecutionData,
|
||||
properties: string[],
|
||||
): IDataObject {
|
||||
export function copyInputItem(item: INodeExecutionData, properties: string[]): IDataObject {
|
||||
// Prepare the data to insert and copy it to be returned
|
||||
const newItem: IDataObject = {};
|
||||
for (const property of properties) {
|
||||
@@ -41,11 +38,9 @@ export function createTableStruct(
|
||||
return items.reduce((tables, item, index) => {
|
||||
const table = getNodeParam('table', index) as string;
|
||||
const columnString = getNodeParam('columns', index) as string;
|
||||
const columns = columnString.split(',').map(column => column.trim());
|
||||
const columns = columnString.split(',').map((column) => column.trim());
|
||||
const itemCopy = copyInputItem(item, columns.concat(additionalProperties));
|
||||
const keyParam = keyName
|
||||
? (getNodeParam(keyName, index) as string)
|
||||
: undefined;
|
||||
const keyParam = keyName ? (getNodeParam(keyName, index) as string) : undefined;
|
||||
if (tables[table] === undefined) {
|
||||
tables[table] = {};
|
||||
}
|
||||
@@ -67,13 +62,11 @@ export function createTableStruct(
|
||||
* @param {function} buildQueryQueue function that builds the queue of promises
|
||||
* @returns {Promise}
|
||||
*/
|
||||
export function executeQueryQueue(
|
||||
tables: ITables,
|
||||
buildQueryQueue: Function,
|
||||
): Promise<any[]> { // tslint:disable-line:no-any
|
||||
// tslint:disable-next-line: no-any
|
||||
export function executeQueryQueue(tables: ITables, buildQueryQueue: Function): Promise<any[]> {
|
||||
return Promise.all(
|
||||
Object.keys(tables).map(table => {
|
||||
const columnsResults = Object.keys(tables[table]).map(columnString => {
|
||||
Object.keys(tables).map((table) => {
|
||||
const columnsResults = Object.keys(tables[table]).map((columnString) => {
|
||||
return Promise.all(
|
||||
buildQueryQueue({
|
||||
table,
|
||||
@@ -95,13 +88,13 @@ export function executeQueryQueue(
|
||||
*/
|
||||
export function extractValues(item: IDataObject): string {
|
||||
return `(${Object.values(item as any) // tslint:disable-line:no-any
|
||||
.map(val => {
|
||||
.map((val) => {
|
||||
//the column cannot be found in the input
|
||||
//so, set it to null in the sql query
|
||||
if (val === null) {
|
||||
return 'NULL';
|
||||
} else if (typeof val === 'string') {
|
||||
return `'${val.replace(/'/g, '\'\'')}'`;
|
||||
return `'${val.replace(/'/g, "''")}'`;
|
||||
} else if (typeof val === 'boolean') {
|
||||
return +!!val;
|
||||
}
|
||||
@@ -120,10 +113,8 @@ export function extractValues(item: IDataObject): string {
|
||||
export function extractUpdateSet(item: IDataObject, columns: string[]): string {
|
||||
return columns
|
||||
.map(
|
||||
column =>
|
||||
`"${column}" = ${
|
||||
typeof item[column] === 'string' ? `'${item[column]}'` : item[column]
|
||||
}`,
|
||||
(column) =>
|
||||
`"${column}" = ${typeof item[column] === 'string' ? `'${item[column]}'` : item[column]}`,
|
||||
)
|
||||
.join(',');
|
||||
}
|
||||
@@ -136,9 +127,7 @@ export function extractUpdateSet(item: IDataObject, columns: string[]): string {
|
||||
* @returns {string} id = '123'
|
||||
*/
|
||||
export function extractUpdateCondition(item: IDataObject, key: string): string {
|
||||
return `${key} = ${
|
||||
typeof item[key] === 'string' ? `'${item[key]}'` : item[key]
|
||||
}`;
|
||||
return `${key} = ${typeof item[key] === 'string' ? `'${item[key]}'` : item[key]}`;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,12 +139,13 @@ export function extractUpdateCondition(item: IDataObject, key: string): string {
|
||||
*/
|
||||
export function extractDeleteValues(items: IDataObject[], key: string): string {
|
||||
return `(${items
|
||||
.map(item => (typeof item[key] === 'string' ? `'${item[key]}'` : item[key]))
|
||||
.map((item) => (typeof item[key] === 'string' ? `'${item[key]}'` : item[key]))
|
||||
.join(',')})`;
|
||||
}
|
||||
|
||||
|
||||
export function formatColumns(columns: string) {
|
||||
return columns.split(',')
|
||||
.map((column) => (`"${column.trim()}"`)).join(',');
|
||||
return columns
|
||||
.split(',')
|
||||
.map((column) => `"${column.trim()}"`)
|
||||
.join(',');
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
@@ -10,16 +8,11 @@ import {
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
chunk,
|
||||
flatten,
|
||||
} from '../../utils/utilities';
|
||||
import { chunk, flatten } from '../../utils/utilities';
|
||||
|
||||
import mssql from 'mssql';
|
||||
|
||||
import {
|
||||
ITables,
|
||||
} from './TableInterface';
|
||||
import { ITables } from './TableInterface';
|
||||
|
||||
import {
|
||||
copyInputItem,
|
||||
@@ -136,7 +129,8 @@ export class MicrosoftSql implements INodeType {
|
||||
default: '',
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-placeholder-miscased-id
|
||||
placeholder: 'id,name,description',
|
||||
description: 'Comma-separated list of the properties which should used as columns for the new rows',
|
||||
description:
|
||||
'Comma-separated list of the properties which should used as columns for the new rows',
|
||||
},
|
||||
|
||||
// ----------------------------------
|
||||
@@ -167,7 +161,8 @@ export class MicrosoftSql implements INodeType {
|
||||
default: 'id',
|
||||
required: true,
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-description-miscased-id
|
||||
description: 'Name of the property which decides which rows in the database should be updated. Normally that would be "id".',
|
||||
description:
|
||||
'Name of the property which decides which rows in the database should be updated. Normally that would be "id".',
|
||||
},
|
||||
{
|
||||
displayName: 'Columns',
|
||||
@@ -180,7 +175,8 @@ export class MicrosoftSql implements INodeType {
|
||||
},
|
||||
default: '',
|
||||
placeholder: 'name,description',
|
||||
description: 'Comma-separated list of the properties which should used as columns for rows to update',
|
||||
description:
|
||||
'Comma-separated list of the properties which should used as columns for rows to update',
|
||||
},
|
||||
|
||||
// ----------------------------------
|
||||
@@ -211,7 +207,8 @@ export class MicrosoftSql implements INodeType {
|
||||
default: 'id',
|
||||
required: true,
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-description-miscased-id
|
||||
description: 'Name of the property which decides which rows in the database should be deleted. Normally that would be "id".',
|
||||
description:
|
||||
'Name of the property which decides which rows in the database should be deleted. Normally that would be "id".',
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -275,15 +272,11 @@ export class MicrosoftSql implements INodeType {
|
||||
columnString: string;
|
||||
items: IDataObject[];
|
||||
}): Array<Promise<object>> => {
|
||||
return chunk(items, 1000).map(insertValues => {
|
||||
const values = insertValues
|
||||
.map((item: IDataObject) => extractValues(item))
|
||||
.join(',');
|
||||
return chunk(items, 1000).map((insertValues) => {
|
||||
const values = insertValues.map((item: IDataObject) => extractValues(item)).join(',');
|
||||
return pool
|
||||
.request()
|
||||
.query(
|
||||
`INSERT INTO ${table}(${formatColumns(columnString)}) VALUES ${values};`,
|
||||
);
|
||||
.query(`INSERT INTO ${table}(${formatColumns(columnString)}) VALUES ${values};`);
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -314,20 +307,13 @@ export class MicrosoftSql implements INodeType {
|
||||
columnString: string;
|
||||
items: IDataObject[];
|
||||
}): Array<Promise<object>> => {
|
||||
return items.map(item => {
|
||||
const columns = columnString
|
||||
.split(',')
|
||||
.map(column => column.trim());
|
||||
return items.map((item) => {
|
||||
const columns = columnString.split(',').map((column) => column.trim());
|
||||
|
||||
const setValues = extractUpdateSet(item, columns);
|
||||
const condition = extractUpdateCondition(
|
||||
item,
|
||||
item.updateKey as string,
|
||||
);
|
||||
const condition = extractUpdateCondition(item, item.updateKey as string);
|
||||
|
||||
return pool
|
||||
.request()
|
||||
.query(`UPDATE ${table} SET ${setValues} WHERE ${condition};`);
|
||||
return pool.request().query(`UPDATE ${table} SET ${setValues} WHERE ${condition};`);
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -352,28 +338,26 @@ export class MicrosoftSql implements INodeType {
|
||||
}, {} as ITables);
|
||||
|
||||
const queriesResults = await Promise.all(
|
||||
Object.keys(tables).map(table => {
|
||||
const deleteKeyResults = Object.keys(tables[table]).map(
|
||||
deleteKey => {
|
||||
const deleteItemsList = chunk(
|
||||
tables[table][deleteKey].map(item =>
|
||||
copyInputItem(item as INodeExecutionData, [deleteKey]),
|
||||
),
|
||||
1000,
|
||||
);
|
||||
const queryQueue = deleteItemsList.map(deleteValues => {
|
||||
return pool
|
||||
.request()
|
||||
.query(
|
||||
`DELETE FROM ${table} WHERE "${deleteKey}" IN ${extractDeleteValues(
|
||||
deleteValues,
|
||||
deleteKey,
|
||||
)};`,
|
||||
);
|
||||
});
|
||||
return Promise.all(queryQueue);
|
||||
},
|
||||
);
|
||||
Object.keys(tables).map((table) => {
|
||||
const deleteKeyResults = Object.keys(tables[table]).map((deleteKey) => {
|
||||
const deleteItemsList = chunk(
|
||||
tables[table][deleteKey].map((item) =>
|
||||
copyInputItem(item as INodeExecutionData, [deleteKey]),
|
||||
),
|
||||
1000,
|
||||
);
|
||||
const queryQueue = deleteItemsList.map((deleteValues) => {
|
||||
return pool
|
||||
.request()
|
||||
.query(
|
||||
`DELETE FROM ${table} WHERE "${deleteKey}" IN ${extractDeleteValues(
|
||||
deleteValues,
|
||||
deleteKey,
|
||||
)};`,
|
||||
);
|
||||
});
|
||||
return Promise.all(queryQueue);
|
||||
});
|
||||
return Promise.all(deleteKeyResults);
|
||||
}),
|
||||
);
|
||||
@@ -389,7 +373,10 @@ export class MicrosoftSql implements INodeType {
|
||||
} as IDataObject);
|
||||
} else {
|
||||
await pool.close();
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not supported!`);
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The operation "${operation}" is not supported!`,
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
if (this.continueOnFail() === true) {
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const channelOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const channelOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'channel',
|
||||
],
|
||||
resource: ['channel'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -52,7 +48,6 @@ export const channelOperations: INodeProperties[] = [
|
||||
];
|
||||
|
||||
export const channelFields: INodeProperties[] = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* channel:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@@ -61,18 +56,15 @@ export const channelFields: INodeProperties[] = [
|
||||
name: 'teamId',
|
||||
required: true,
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getTeams',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'channel',
|
||||
],
|
||||
operation: ['create'],
|
||||
resource: ['channel'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -84,12 +76,8 @@ export const channelFields: INodeProperties[] = [
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'channel',
|
||||
],
|
||||
operation: ['create'],
|
||||
resource: ['channel'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -101,12 +89,8 @@ export const channelFields: INodeProperties[] = [
|
||||
type: 'collection',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'channel',
|
||||
],
|
||||
operation: ['create'],
|
||||
resource: ['channel'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
@@ -120,7 +104,7 @@ export const channelFields: INodeProperties[] = [
|
||||
alwaysOpenEditWindow: true,
|
||||
},
|
||||
default: '',
|
||||
description: 'Channel\'s description',
|
||||
description: "Channel's description",
|
||||
},
|
||||
{
|
||||
displayName: 'Type',
|
||||
@@ -150,18 +134,15 @@ export const channelFields: INodeProperties[] = [
|
||||
name: 'teamId',
|
||||
required: true,
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getTeams',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'delete',
|
||||
],
|
||||
resource: [
|
||||
'channel',
|
||||
],
|
||||
operation: ['delete'],
|
||||
resource: ['channel'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -170,21 +151,16 @@ export const channelFields: INodeProperties[] = [
|
||||
displayName: 'Channel Name or ID',
|
||||
name: 'channelId',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getChannels',
|
||||
loadOptionsDependsOn: [
|
||||
'teamId',
|
||||
],
|
||||
loadOptionsDependsOn: ['teamId'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'delete',
|
||||
],
|
||||
resource: [
|
||||
'channel',
|
||||
],
|
||||
operation: ['delete'],
|
||||
resource: ['channel'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -198,18 +174,15 @@ export const channelFields: INodeProperties[] = [
|
||||
name: 'teamId',
|
||||
required: true,
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getTeams',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
resource: [
|
||||
'channel',
|
||||
],
|
||||
operation: ['get'],
|
||||
resource: ['channel'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -218,21 +191,16 @@ export const channelFields: INodeProperties[] = [
|
||||
displayName: 'Channel Name or ID',
|
||||
name: 'channelId',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getChannels',
|
||||
loadOptionsDependsOn: [
|
||||
'teamId',
|
||||
],
|
||||
loadOptionsDependsOn: ['teamId'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
resource: [
|
||||
'channel',
|
||||
],
|
||||
operation: ['get'],
|
||||
resource: ['channel'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -246,18 +214,15 @@ export const channelFields: INodeProperties[] = [
|
||||
name: 'teamId',
|
||||
required: true,
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getTeams',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'channel',
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['channel'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -268,12 +233,8 @@ export const channelFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'channel',
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['channel'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -285,15 +246,9 @@ export const channelFields: INodeProperties[] = [
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'channel',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['channel'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
@@ -312,18 +267,15 @@ export const channelFields: INodeProperties[] = [
|
||||
name: 'teamId',
|
||||
required: true,
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getTeams',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: [
|
||||
'channel',
|
||||
],
|
||||
operation: ['update'],
|
||||
resource: ['channel'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -332,21 +284,16 @@ export const channelFields: INodeProperties[] = [
|
||||
displayName: 'Channel Name or ID',
|
||||
name: 'channelId',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getChannels',
|
||||
loadOptionsDependsOn: [
|
||||
'teamId',
|
||||
],
|
||||
loadOptionsDependsOn: ['teamId'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: [
|
||||
'channel',
|
||||
],
|
||||
operation: ['update'],
|
||||
resource: ['channel'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -357,12 +304,8 @@ export const channelFields: INodeProperties[] = [
|
||||
type: 'collection',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: [
|
||||
'channel',
|
||||
],
|
||||
operation: ['update'],
|
||||
resource: ['channel'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
@@ -383,7 +326,7 @@ export const channelFields: INodeProperties[] = [
|
||||
alwaysOpenEditWindow: true,
|
||||
},
|
||||
default: '',
|
||||
description: 'Channel\'s description',
|
||||
description: "Channel's description",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const channelMessageOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const channelMessageOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'channelMessage',
|
||||
],
|
||||
resource: ['channelMessage'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -34,7 +30,6 @@ export const channelMessageOperations: INodeProperties[] = [
|
||||
];
|
||||
|
||||
export const channelMessageFields: INodeProperties[] = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* channelMessage:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@@ -43,18 +38,15 @@ export const channelMessageFields: INodeProperties[] = [
|
||||
name: 'teamId',
|
||||
required: true,
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getTeams',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'channelMessage',
|
||||
],
|
||||
operation: ['create'],
|
||||
resource: ['channelMessage'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -63,21 +55,16 @@ export const channelMessageFields: INodeProperties[] = [
|
||||
displayName: 'Channel Name or ID',
|
||||
name: 'channelId',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getChannels',
|
||||
loadOptionsDependsOn: [
|
||||
'teamId',
|
||||
],
|
||||
loadOptionsDependsOn: ['teamId'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'channelMessage',
|
||||
],
|
||||
operation: ['create'],
|
||||
resource: ['channelMessage'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -99,12 +86,8 @@ export const channelMessageFields: INodeProperties[] = [
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'channelMessage',
|
||||
],
|
||||
operation: ['create'],
|
||||
resource: ['channelMessage'],
|
||||
},
|
||||
},
|
||||
default: 'text',
|
||||
@@ -120,12 +103,8 @@ export const channelMessageFields: INodeProperties[] = [
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'channelMessage',
|
||||
],
|
||||
operation: ['create'],
|
||||
resource: ['channelMessage'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -139,12 +118,8 @@ export const channelMessageFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'channelMessage',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: ['channelMessage'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -165,18 +140,15 @@ export const channelMessageFields: INodeProperties[] = [
|
||||
name: 'teamId',
|
||||
required: true,
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getTeams',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'channelMessage',
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['channelMessage'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -185,21 +157,16 @@ export const channelMessageFields: INodeProperties[] = [
|
||||
displayName: 'Channel Name or ID',
|
||||
name: 'channelId',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getChannels',
|
||||
loadOptionsDependsOn: [
|
||||
'teamId',
|
||||
],
|
||||
loadOptionsDependsOn: ['teamId'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'channelMessage',
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['channelMessage'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -210,12 +177,8 @@ export const channelMessageFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'channelMessage',
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['channelMessage'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -227,15 +190,9 @@ export const channelMessageFields: INodeProperties[] = [
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'channelMessage',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['channelMessage'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const chatMessageOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const chatMessageOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'chatMessage',
|
||||
],
|
||||
resource: ['chatMessage'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -40,7 +36,6 @@ export const chatMessageOperations: INodeProperties[] = [
|
||||
];
|
||||
|
||||
export const chatMessageFields: INodeProperties[] = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* chatMessage:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@@ -49,19 +44,15 @@ export const chatMessageFields: INodeProperties[] = [
|
||||
name: 'chatId',
|
||||
required: true,
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getChats',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
'get',
|
||||
],
|
||||
resource: [
|
||||
'chatMessage',
|
||||
],
|
||||
operation: ['create', 'get'],
|
||||
resource: ['chatMessage'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -83,12 +74,8 @@ export const chatMessageFields: INodeProperties[] = [
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'chatMessage',
|
||||
],
|
||||
operation: ['create'],
|
||||
resource: ['chatMessage'],
|
||||
},
|
||||
},
|
||||
default: 'text',
|
||||
@@ -104,12 +91,8 @@ export const chatMessageFields: INodeProperties[] = [
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'chatMessage',
|
||||
],
|
||||
operation: ['create'],
|
||||
resource: ['chatMessage'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -126,12 +109,8 @@ export const chatMessageFields: INodeProperties[] = [
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
resource: [
|
||||
'chatMessage',
|
||||
],
|
||||
operation: ['get'],
|
||||
resource: ['chatMessage'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -144,18 +123,15 @@ export const chatMessageFields: INodeProperties[] = [
|
||||
name: 'chatId',
|
||||
required: true,
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getChats',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'chatMessage',
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['chatMessage'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -166,12 +142,8 @@ export const chatMessageFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'chatMessage',
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['chatMessage'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -183,15 +155,9 @@ export const chatMessageFields: INodeProperties[] = [
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'chatMessage',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['chatMessage'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
import {
|
||||
OptionsWithUri,
|
||||
} from 'request';
|
||||
import { OptionsWithUri } from 'request';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
IExecuteSingleFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject, NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
import { IDataObject, NodeApiError } from 'n8n-workflow';
|
||||
|
||||
export async function microsoftApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
export async function microsoftApiRequest(
|
||||
this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions,
|
||||
method: string,
|
||||
resource: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
qs: IDataObject = {},
|
||||
uri?: string,
|
||||
headers: IDataObject = {},
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const options: OptionsWithUri = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -34,8 +36,16 @@ export async function microsoftApiRequest(this: IExecuteFunctions | IExecuteSing
|
||||
}
|
||||
}
|
||||
|
||||
export async function microsoftApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
export async function microsoftApiRequestAllItems(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
propertyName: string,
|
||||
method: string,
|
||||
endpoint: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
query: IDataObject = {},
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
@@ -48,15 +58,21 @@ export async function microsoftApiRequestAllItems(this: IExecuteFunctions | ILoa
|
||||
if (query.limit && query.limit <= returnData.length) {
|
||||
return returnData;
|
||||
}
|
||||
} while (
|
||||
responseData['@odata.nextLink'] !== undefined
|
||||
);
|
||||
} while (responseData['@odata.nextLink'] !== undefined);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
export async function microsoftApiRequestAllItemsSkip(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
export async function microsoftApiRequestAllItemsSkip(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
propertyName: string,
|
||||
method: string,
|
||||
endpoint: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
query: IDataObject = {},
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
@@ -67,9 +83,7 @@ export async function microsoftApiRequestAllItemsSkip(this: IExecuteFunctions |
|
||||
responseData = await microsoftApiRequest.call(this, method, endpoint, body, query);
|
||||
query['$skip'] += query['$top'];
|
||||
returnData.push.apply(returnData, responseData[propertyName]);
|
||||
} while (
|
||||
responseData['value'].length !== 0
|
||||
);
|
||||
} while (responseData['value'].length !== 0);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
@@ -12,30 +10,15 @@ import {
|
||||
JsonObject,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
microsoftApiRequest,
|
||||
microsoftApiRequestAllItems,
|
||||
} from './GenericFunctions';
|
||||
import { microsoftApiRequest, microsoftApiRequestAllItems } from './GenericFunctions';
|
||||
|
||||
import {
|
||||
channelFields,
|
||||
channelOperations,
|
||||
} from './ChannelDescription';
|
||||
import { channelFields, channelOperations } from './ChannelDescription';
|
||||
|
||||
import {
|
||||
channelMessageFields,
|
||||
channelMessageOperations,
|
||||
} from './ChannelMessageDescription';
|
||||
import { channelMessageFields, channelMessageOperations } from './ChannelMessageDescription';
|
||||
|
||||
import {
|
||||
chatMessageFields,
|
||||
chatMessageOperations,
|
||||
} from './ChatMessageDescription';
|
||||
import { chatMessageFields, chatMessageOperations } from './ChatMessageDescription';
|
||||
|
||||
import {
|
||||
taskFields,
|
||||
taskOperations,
|
||||
} from './TaskDescription';
|
||||
import { taskFields, taskOperations } from './TaskDescription';
|
||||
|
||||
export class MicrosoftTeams implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -104,7 +87,11 @@ export class MicrosoftTeams implements INodeType {
|
||||
async getChannels(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const teamId = this.getCurrentNodeParameter('teamId') as string;
|
||||
const { value } = await microsoftApiRequest.call(this, 'GET', `/v1.0/teams/${teamId}/channels`);
|
||||
const { value } = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/v1.0/teams/${teamId}/channels`,
|
||||
);
|
||||
for (const channel of value) {
|
||||
const channelName = channel.displayName;
|
||||
const channelId = channel.id;
|
||||
@@ -159,7 +146,11 @@ export class MicrosoftTeams implements INodeType {
|
||||
// groupId not found at base, check updateFields for the groupId
|
||||
groupId = this.getCurrentNodeParameter('updateFields.groupId') as string;
|
||||
}
|
||||
const { value } = await microsoftApiRequest.call(this, 'GET', `/v1.0/groups/${groupId}/planner/plans`);
|
||||
const { value } = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/v1.0/groups/${groupId}/planner/plans`,
|
||||
);
|
||||
for (const plan of value) {
|
||||
returnData.push({
|
||||
name: plan.title,
|
||||
@@ -178,7 +169,11 @@ export class MicrosoftTeams implements INodeType {
|
||||
// planId not found at base, check updateFields for the planId
|
||||
planId = this.getCurrentNodeParameter('updateFields.planId') as string;
|
||||
}
|
||||
const { value } = await microsoftApiRequest.call(this, 'GET', `/v1.0/planner/plans/${planId}/buckets`);
|
||||
const { value } = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/v1.0/planner/plans/${planId}/buckets`,
|
||||
);
|
||||
for (const bucket of value) {
|
||||
returnData.push({
|
||||
name: bucket.name,
|
||||
@@ -197,7 +192,11 @@ export class MicrosoftTeams implements INodeType {
|
||||
// groupId not found at base, check updateFields for the groupId
|
||||
groupId = this.getCurrentNodeParameter('updateFields.groupId') as string;
|
||||
}
|
||||
const { value } = await microsoftApiRequest.call(this, 'GET', `/v1.0/groups/${groupId}/members`);
|
||||
const { value } = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/v1.0/groups/${groupId}/members`,
|
||||
);
|
||||
for (const member of value) {
|
||||
returnData.push({
|
||||
name: member.displayName,
|
||||
@@ -217,7 +216,11 @@ export class MicrosoftTeams implements INodeType {
|
||||
// planId not found at base, check updateFields for the planId
|
||||
planId = this.getCurrentNodeParameter('updateFields.planId') as string;
|
||||
}
|
||||
const { categoryDescriptions } = await microsoftApiRequest.call(this, 'GET', `/v1.0/planner/plans/${planId}/details`);
|
||||
const { categoryDescriptions } = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/v1.0/planner/plans/${planId}/details`,
|
||||
);
|
||||
for (const key of Object.keys(categoryDescriptions)) {
|
||||
if (categoryDescriptions[key] !== null) {
|
||||
returnData.push({
|
||||
@@ -239,8 +242,9 @@ export class MicrosoftTeams implements INodeType {
|
||||
for (const chat of value) {
|
||||
if (!chat.topic) {
|
||||
chat.topic = chat.members
|
||||
.filter((member: IDataObject) => member.displayName)
|
||||
.map((member: IDataObject) => member.displayName).join(', ');
|
||||
.filter((member: IDataObject) => member.displayName)
|
||||
.map((member: IDataObject) => member.displayName)
|
||||
.join(', ');
|
||||
}
|
||||
const chatName = `${chat.topic || '(no title) - ' + chat.id} (${chat.chatType})`;
|
||||
const chatId = chat.id;
|
||||
@@ -279,30 +283,54 @@ export class MicrosoftTeams implements INodeType {
|
||||
if (options.type) {
|
||||
body.membershipType = options.type as string;
|
||||
}
|
||||
responseData = await microsoftApiRequest.call(this, 'POST', `/v1.0/teams/${teamId}/channels`, body);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/v1.0/teams/${teamId}/channels`,
|
||||
body,
|
||||
);
|
||||
}
|
||||
//https://docs.microsoft.com/en-us/graph/api/channel-delete?view=graph-rest-beta&tabs=http
|
||||
if (operation === 'delete') {
|
||||
const teamId = this.getNodeParameter('teamId', i) as string;
|
||||
const channelId = this.getNodeParameter('channelId', i) as string;
|
||||
responseData = await microsoftApiRequest.call(this, 'DELETE', `/v1.0/teams/${teamId}/channels/${channelId}`);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/v1.0/teams/${teamId}/channels/${channelId}`,
|
||||
);
|
||||
responseData = { success: true };
|
||||
}
|
||||
//https://docs.microsoft.com/en-us/graph/api/channel-get?view=graph-rest-beta&tabs=http
|
||||
if (operation === 'get') {
|
||||
const teamId = this.getNodeParameter('teamId', i) as string;
|
||||
const channelId = this.getNodeParameter('channelId', i) as string;
|
||||
responseData = await microsoftApiRequest.call(this, 'GET', `/v1.0/teams/${teamId}/channels/${channelId}`);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/v1.0/teams/${teamId}/channels/${channelId}`,
|
||||
);
|
||||
}
|
||||
//https://docs.microsoft.com/en-us/graph/api/channel-list?view=graph-rest-beta&tabs=http
|
||||
if (operation === 'getAll') {
|
||||
const teamId = this.getNodeParameter('teamId', i) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
if (returnAll) {
|
||||
responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/v1.0/teams/${teamId}/channels`);
|
||||
responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/teams/${teamId}/channels`,
|
||||
);
|
||||
} else {
|
||||
qs.limit = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/v1.0/teams/${teamId}/channels`, {});
|
||||
responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/teams/${teamId}/channels`,
|
||||
{},
|
||||
);
|
||||
responseData = responseData.splice(0, qs.limit);
|
||||
}
|
||||
}
|
||||
@@ -318,7 +346,12 @@ export class MicrosoftTeams implements INodeType {
|
||||
if (updateFields.description) {
|
||||
body.description = updateFields.description as string;
|
||||
}
|
||||
responseData = await microsoftApiRequest.call(this, 'PATCH', `/v1.0/teams/${teamId}/channels/${channelId}`, body);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'PATCH',
|
||||
`/v1.0/teams/${teamId}/channels/${channelId}`,
|
||||
body,
|
||||
);
|
||||
responseData = { success: true };
|
||||
}
|
||||
}
|
||||
@@ -341,9 +374,19 @@ export class MicrosoftTeams implements INodeType {
|
||||
|
||||
if (options.makeReply) {
|
||||
const replyToId = options.makeReply as string;
|
||||
responseData = await microsoftApiRequest.call(this, 'POST', `/beta/teams/${teamId}/channels/${channelId}/messages/${replyToId}/replies`, body);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/beta/teams/${teamId}/channels/${channelId}/messages/${replyToId}/replies`,
|
||||
body,
|
||||
);
|
||||
} else {
|
||||
responseData = await microsoftApiRequest.call(this, 'POST', `/beta/teams/${teamId}/channels/${channelId}/messages`, body);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/beta/teams/${teamId}/channels/${channelId}/messages`,
|
||||
body,
|
||||
);
|
||||
}
|
||||
}
|
||||
//https://docs.microsoft.com/en-us/graph/api/channel-list-messages?view=graph-rest-beta&tabs=http
|
||||
@@ -352,10 +395,21 @@ export class MicrosoftTeams implements INodeType {
|
||||
const channelId = this.getNodeParameter('channelId', i) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
if (returnAll) {
|
||||
responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/beta/teams/${teamId}/channels/${channelId}/messages`);
|
||||
responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/beta/teams/${teamId}/channels/${channelId}/messages`,
|
||||
);
|
||||
} else {
|
||||
qs.limit = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/beta/teams/${teamId}/channels/${channelId}/messages`, {});
|
||||
responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/beta/teams/${teamId}/channels/${channelId}/messages`,
|
||||
{},
|
||||
);
|
||||
responseData = responseData.splice(0, qs.limit);
|
||||
}
|
||||
}
|
||||
@@ -372,23 +426,43 @@ export class MicrosoftTeams implements INodeType {
|
||||
content: message,
|
||||
},
|
||||
};
|
||||
responseData = await microsoftApiRequest.call(this, 'POST', `/v1.0/chats/${chatId}/messages`, body);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/v1.0/chats/${chatId}/messages`,
|
||||
body,
|
||||
);
|
||||
}
|
||||
// https://docs.microsoft.com/en-us/graph/api/chat-list-messages?view=graph-rest-1.0&tabs=http
|
||||
if (operation === 'get') {
|
||||
const chatId = this.getNodeParameter('chatId', i) as string;
|
||||
const messageId = this.getNodeParameter('messageId', i) as string;
|
||||
responseData = await microsoftApiRequest.call(this, 'GET', `/v1.0/chats/${chatId}/messages/${messageId}`);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/v1.0/chats/${chatId}/messages/${messageId}`,
|
||||
);
|
||||
}
|
||||
// https://docs.microsoft.com/en-us/graph/api/chat-list-messages?view=graph-rest-1.0&tabs=http
|
||||
if (operation === 'getAll') {
|
||||
const chatId = this.getNodeParameter('chatId', i) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
if (returnAll) {
|
||||
responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/v1.0/chats/${chatId}/messages`);
|
||||
responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/chats/${chatId}/messages`,
|
||||
);
|
||||
} else {
|
||||
qs.limit = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/v1.0/chats/${chatId}/messages`, {});
|
||||
responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/chats/${chatId}/messages`,
|
||||
{},
|
||||
);
|
||||
responseData = responseData.splice(0, qs.limit);
|
||||
}
|
||||
}
|
||||
@@ -411,29 +485,52 @@ export class MicrosoftTeams implements INodeType {
|
||||
body.assignments = {
|
||||
[body.assignedTo as string]: {
|
||||
'@odata.type': 'microsoft.graph.plannerAssignment',
|
||||
'orderHint': ' !',
|
||||
orderHint: ' !',
|
||||
},
|
||||
};
|
||||
delete body.assignedTo;
|
||||
}
|
||||
|
||||
if (Array.isArray(body.labels)) {
|
||||
body.appliedCategories = (body.labels as string[]).map((label) => ({ [label]: true }));
|
||||
body.appliedCategories = (body.labels as string[]).map((label) => ({
|
||||
[label]: true,
|
||||
}));
|
||||
}
|
||||
|
||||
responseData = await microsoftApiRequest.call(this, 'POST', `/v1.0/planner/tasks`, body);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/v1.0/planner/tasks`,
|
||||
body,
|
||||
);
|
||||
}
|
||||
//https://docs.microsoft.com/en-us/graph/api/plannertask-delete?view=graph-rest-1.0&tabs=http
|
||||
if (operation === 'delete') {
|
||||
const taskId = this.getNodeParameter('taskId', i) as string;
|
||||
const task = await microsoftApiRequest.call(this, 'GET', `/v1.0/planner/tasks/${taskId}`);
|
||||
responseData = await microsoftApiRequest.call(this, 'DELETE', `/v1.0/planner/tasks/${taskId}`, {}, {}, undefined, { 'If-Match': task['@odata.etag'] });
|
||||
const task = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/v1.0/planner/tasks/${taskId}`,
|
||||
);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/v1.0/planner/tasks/${taskId}`,
|
||||
{},
|
||||
{},
|
||||
undefined,
|
||||
{ 'If-Match': task['@odata.etag'] },
|
||||
);
|
||||
responseData = { success: true };
|
||||
}
|
||||
//https://docs.microsoft.com/en-us/graph/api/plannertask-get?view=graph-rest-1.0&tabs=http
|
||||
if (operation === 'get') {
|
||||
const taskId = this.getNodeParameter('taskId', i) as string;
|
||||
responseData = await microsoftApiRequest.call(this, 'GET', `/v1.0/planner/tasks/${taskId}`);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/v1.0/planner/tasks/${taskId}`,
|
||||
);
|
||||
}
|
||||
if (operation === 'getAll') {
|
||||
const tasksFor = this.getNodeParameter('tasksFor', i) as string;
|
||||
@@ -442,20 +539,42 @@ export class MicrosoftTeams implements INodeType {
|
||||
//https://docs.microsoft.com/en-us/graph/api/planneruser-list-tasks?view=graph-rest-1.0&tabs=http
|
||||
const memberId = this.getNodeParameter('memberId', i) as string;
|
||||
if (returnAll) {
|
||||
responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/v1.0/users/${memberId}/planner/tasks`);
|
||||
responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/users/${memberId}/planner/tasks`,
|
||||
);
|
||||
} else {
|
||||
qs.limit = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/v1.0/users/${memberId}/planner/tasks`, {});
|
||||
responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/users/${memberId}/planner/tasks`,
|
||||
{},
|
||||
);
|
||||
responseData = responseData.splice(0, qs.limit);
|
||||
}
|
||||
} else {
|
||||
//https://docs.microsoft.com/en-us/graph/api/plannerplan-list-tasks?view=graph-rest-1.0&tabs=http
|
||||
const planId = this.getNodeParameter('planId', i) as string;
|
||||
if (returnAll) {
|
||||
responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/v1.0/planner/plans/${planId}/tasks`);
|
||||
responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/planner/plans/${planId}/tasks`,
|
||||
);
|
||||
} else {
|
||||
qs.limit = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/v1.0/planner/plans/${planId}/tasks`, {});
|
||||
responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/planner/plans/${planId}/tasks`,
|
||||
{},
|
||||
);
|
||||
responseData = responseData.splice(0, qs.limit);
|
||||
}
|
||||
}
|
||||
@@ -471,7 +590,7 @@ export class MicrosoftTeams implements INodeType {
|
||||
body.assignments = {
|
||||
[body.assignedTo as string]: {
|
||||
'@odata.type': 'microsoft.graph.plannerAssignment',
|
||||
'orderHint': ' !',
|
||||
orderHint: ' !',
|
||||
},
|
||||
};
|
||||
delete body.assignedTo;
|
||||
@@ -483,12 +602,26 @@ export class MicrosoftTeams implements INodeType {
|
||||
}
|
||||
|
||||
if (Array.isArray(body.labels)) {
|
||||
body.appliedCategories = (body.labels as string[]).map((label) => ({ [label]: true }));
|
||||
body.appliedCategories = (body.labels as string[]).map((label) => ({
|
||||
[label]: true,
|
||||
}));
|
||||
}
|
||||
|
||||
const task = await microsoftApiRequest.call(this, 'GET', `/v1.0/planner/tasks/${taskId}`);
|
||||
const task = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/v1.0/planner/tasks/${taskId}`,
|
||||
);
|
||||
|
||||
responseData = await microsoftApiRequest.call(this, 'PATCH', `/v1.0/planner/tasks/${taskId}`, body, {}, undefined, { 'If-Match': task['@odata.etag'] });
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'PATCH',
|
||||
`/v1.0/planner/tasks/${taskId}`,
|
||||
body,
|
||||
{},
|
||||
undefined,
|
||||
{ 'If-Match': task['@odata.etag'] },
|
||||
);
|
||||
|
||||
responseData = { success: true };
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const taskOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const taskOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -60,14 +56,8 @@ export const taskFields: INodeProperties[] = [
|
||||
default: 'all',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
'create',
|
||||
'update',
|
||||
],
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: ['getAll', 'create', 'update'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -84,7 +74,6 @@ export const taskFields: INodeProperties[] = [
|
||||
],
|
||||
},
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* task:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@@ -94,21 +83,16 @@ export const taskFields: INodeProperties[] = [
|
||||
name: 'groupId',
|
||||
required: true,
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getGroups',
|
||||
loadOptionsDependsOn: [
|
||||
'groupSource',
|
||||
],
|
||||
loadOptionsDependsOn: ['groupSource'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: ['create'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -120,22 +104,17 @@ export const taskFields: INodeProperties[] = [
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getPlans',
|
||||
loadOptionsDependsOn: [
|
||||
'groupId',
|
||||
],
|
||||
loadOptionsDependsOn: ['groupId'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: ['create'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The plan for the task to belong to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'The plan for the task to belong to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Bucket Name or ID',
|
||||
@@ -144,22 +123,17 @@ export const taskFields: INodeProperties[] = [
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getBuckets',
|
||||
loadOptionsDependsOn: [
|
||||
'planId',
|
||||
],
|
||||
loadOptionsDependsOn: ['planId'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: ['create'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The bucket for the task to belong to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'The bucket for the task to belong to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Title',
|
||||
@@ -168,12 +142,8 @@ export const taskFields: INodeProperties[] = [
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: ['create'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -185,12 +155,8 @@ export const taskFields: INodeProperties[] = [
|
||||
type: 'collection',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: ['create'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
@@ -202,19 +168,19 @@ export const taskFields: INodeProperties[] = [
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getMembers',
|
||||
loadOptionsDependsOn: [
|
||||
'groupId',
|
||||
],
|
||||
loadOptionsDependsOn: ['groupId'],
|
||||
},
|
||||
default: '',
|
||||
description: 'Who the task should be assigned to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'Who the task should be assigned to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Due Date Time',
|
||||
name: 'dueDateTime',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description: 'Date and time at which the task is due. The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time.',
|
||||
description:
|
||||
'Date and time at which the task is due. The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time.',
|
||||
},
|
||||
{
|
||||
displayName: 'Label Names or IDs',
|
||||
@@ -222,12 +188,11 @@ export const taskFields: INodeProperties[] = [
|
||||
type: 'multiOptions',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getLabels',
|
||||
loadOptionsDependsOn: [
|
||||
'planId',
|
||||
],
|
||||
loadOptionsDependsOn: ['planId'],
|
||||
},
|
||||
default: [],
|
||||
description: 'Labels to assign to the task. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'Labels to assign to the task. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Percent Complete',
|
||||
@@ -238,7 +203,8 @@ export const taskFields: INodeProperties[] = [
|
||||
maxValue: 100,
|
||||
},
|
||||
default: 0,
|
||||
description: 'Percentage of task completion. When set to 100, the task is considered completed.',
|
||||
description:
|
||||
'Percentage of task completion. When set to 100, the task is considered completed.',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -253,12 +219,8 @@ export const taskFields: INodeProperties[] = [
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'delete',
|
||||
],
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: ['delete'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -274,12 +236,8 @@ export const taskFields: INodeProperties[] = [
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: ['get'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -297,12 +255,8 @@ export const taskFields: INodeProperties[] = [
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -323,21 +277,16 @@ export const taskFields: INodeProperties[] = [
|
||||
name: 'groupId',
|
||||
required: true,
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getGroups',
|
||||
loadOptionsDependsOn: [
|
||||
'groupSource',
|
||||
],
|
||||
loadOptionsDependsOn: ['groupSource'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -346,24 +295,17 @@ export const taskFields: INodeProperties[] = [
|
||||
displayName: 'Member Name or ID',
|
||||
name: 'memberId',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getMembers',
|
||||
loadOptionsDependsOn: [
|
||||
'groupId',
|
||||
],
|
||||
loadOptionsDependsOn: ['groupId'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
tasksFor: [
|
||||
'member',
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['task'],
|
||||
tasksFor: ['member'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -372,24 +314,17 @@ export const taskFields: INodeProperties[] = [
|
||||
displayName: 'Plan Name or ID',
|
||||
name: 'planId',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getPlans',
|
||||
loadOptionsDependsOn: [
|
||||
'groupId',
|
||||
],
|
||||
loadOptionsDependsOn: ['groupId'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
tasksFor: [
|
||||
'plan',
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['task'],
|
||||
tasksFor: ['plan'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -400,12 +335,8 @@ export const taskFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -417,15 +348,9 @@ export const taskFields: INodeProperties[] = [
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['task'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
@@ -446,12 +371,8 @@ export const taskFields: INodeProperties[] = [
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: ['update'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -463,12 +384,8 @@ export const taskFields: INodeProperties[] = [
|
||||
type: 'collection',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: ['update'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
@@ -480,12 +397,11 @@ export const taskFields: INodeProperties[] = [
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getMembers',
|
||||
loadOptionsDependsOn: [
|
||||
'groupId',
|
||||
],
|
||||
loadOptionsDependsOn: ['groupId'],
|
||||
},
|
||||
default: '',
|
||||
description: 'Who the task should be assigned to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'Who the task should be assigned to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Bucket Name or ID',
|
||||
@@ -493,30 +409,29 @@ export const taskFields: INodeProperties[] = [
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getBuckets',
|
||||
loadOptionsDependsOn: [
|
||||
'updateFields.planId',
|
||||
],
|
||||
loadOptionsDependsOn: ['updateFields.planId'],
|
||||
},
|
||||
default: '',
|
||||
description: 'The bucket for the task to belong to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'The bucket for the task to belong to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Due Date Time',
|
||||
name: 'dueDateTime',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description: 'Date and time at which the task is due. The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time.',
|
||||
description:
|
||||
'Date and time at which the task is due. The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time.',
|
||||
},
|
||||
{
|
||||
displayName: 'Group Name or ID',
|
||||
name: 'groupId',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getGroups',
|
||||
loadOptionsDependsOn: [
|
||||
'groupSource',
|
||||
],
|
||||
loadOptionsDependsOn: ['groupSource'],
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
@@ -526,12 +441,11 @@ export const taskFields: INodeProperties[] = [
|
||||
type: 'multiOptions',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getLabels',
|
||||
loadOptionsDependsOn: [
|
||||
'updateFields.planId',
|
||||
],
|
||||
loadOptionsDependsOn: ['updateFields.planId'],
|
||||
},
|
||||
default: [],
|
||||
description: 'Labels to assign to the task. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'Labels to assign to the task. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Percent Complete',
|
||||
@@ -542,7 +456,8 @@ export const taskFields: INodeProperties[] = [
|
||||
maxValue: 100,
|
||||
},
|
||||
default: 0,
|
||||
description: 'Percentage of task completion. When set to 100, the task is considered completed.',
|
||||
description:
|
||||
'Percentage of task completion. When set to 100, the task is considered completed.',
|
||||
},
|
||||
{
|
||||
displayName: 'Plan Name or ID',
|
||||
@@ -550,12 +465,11 @@ export const taskFields: INodeProperties[] = [
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getPlans',
|
||||
loadOptionsDependsOn: [
|
||||
'groupId',
|
||||
],
|
||||
loadOptionsDependsOn: ['groupId'],
|
||||
},
|
||||
default: '',
|
||||
description: 'The plan for the task to belong to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'The plan for the task to belong to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Title',
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
import {
|
||||
OptionsWithUri
|
||||
} from 'request';
|
||||
import { OptionsWithUri } from 'request';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
ILoadOptionsFunctions,
|
||||
NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
import { IDataObject, ILoadOptionsFunctions, NodeApiError } from 'n8n-workflow';
|
||||
|
||||
export async function microsoftApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: string, body: IDataObject = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}, option: IDataObject = { json: true }) {
|
||||
export async function microsoftApiRequest(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
method: string,
|
||||
resource: string,
|
||||
body: IDataObject = {},
|
||||
qs: IDataObject = {},
|
||||
uri?: string,
|
||||
headers: IDataObject = {},
|
||||
option: IDataObject = { json: true },
|
||||
) {
|
||||
const options: OptionsWithUri = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -37,8 +38,14 @@ export async function microsoftApiRequest(this: IExecuteFunctions | ILoadOptions
|
||||
}
|
||||
}
|
||||
|
||||
export async function microsoftApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: IDataObject = {}, query: IDataObject = {}) {
|
||||
|
||||
export async function microsoftApiRequestAllItems(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
propertyName: string,
|
||||
method: string,
|
||||
endpoint: string,
|
||||
body: IDataObject = {},
|
||||
query: IDataObject = {},
|
||||
) {
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
@@ -49,15 +56,19 @@ export async function microsoftApiRequestAllItems(this: IExecuteFunctions | ILoa
|
||||
responseData = await microsoftApiRequest.call(this, method, endpoint, body, query, uri);
|
||||
uri = responseData['@odata.nextLink'];
|
||||
returnData.push.apply(returnData, responseData[propertyName]);
|
||||
} while (
|
||||
responseData['@odata.nextLink'] !== undefined
|
||||
);
|
||||
} while (responseData['@odata.nextLink'] !== undefined);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
export async function microsoftApiRequestAllItemsSkip(this: IExecuteFunctions, propertyName: string, method: string, endpoint: string, body: IDataObject = {}, query: IDataObject = {}) {
|
||||
|
||||
export async function microsoftApiRequestAllItemsSkip(
|
||||
this: IExecuteFunctions,
|
||||
propertyName: string,
|
||||
method: string,
|
||||
endpoint: string,
|
||||
body: IDataObject = {},
|
||||
query: IDataObject = {},
|
||||
) {
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
@@ -68,9 +79,7 @@ export async function microsoftApiRequestAllItemsSkip(this: IExecuteFunctions, p
|
||||
responseData = await microsoftApiRequest.call(this, method, endpoint, body, query);
|
||||
query['$skip'] += query['$top'];
|
||||
returnData.push.apply(returnData, responseData[propertyName]);
|
||||
} while (
|
||||
responseData['value'].length !== 0
|
||||
);
|
||||
} while (responseData['value'].length !== 0);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const linkedResourceOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const linkedResourceOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'linkedResource',
|
||||
],
|
||||
resource: ['linkedResource'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -54,22 +50,15 @@ export const linkedResourceFields: INodeProperties[] = [
|
||||
displayName: 'Task List Name or ID',
|
||||
name: 'taskListId',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getTaskLists',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
'delete',
|
||||
'get',
|
||||
'getAll',
|
||||
'update',
|
||||
],
|
||||
resource: [
|
||||
'linkedResource',
|
||||
],
|
||||
operation: ['create', 'delete', 'get', 'getAll', 'update'],
|
||||
resource: ['linkedResource'],
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
@@ -81,16 +70,8 @@ export const linkedResourceFields: INodeProperties[] = [
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
'delete',
|
||||
'get',
|
||||
'getAll',
|
||||
'update',
|
||||
],
|
||||
resource: [
|
||||
'linkedResource',
|
||||
],
|
||||
operation: ['create', 'delete', 'get', 'getAll', 'update'],
|
||||
resource: ['linkedResource'],
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
@@ -107,12 +88,8 @@ export const linkedResourceFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'linkedResource',
|
||||
],
|
||||
operation: ['create'],
|
||||
resource: ['linkedResource'],
|
||||
},
|
||||
},
|
||||
description: 'Field indicating title of the linked entity',
|
||||
@@ -123,12 +100,8 @@ export const linkedResourceFields: INodeProperties[] = [
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'linkedResource',
|
||||
],
|
||||
operation: ['create'],
|
||||
resource: ['linkedResource'],
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
@@ -143,12 +116,8 @@ export const linkedResourceFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'linkedResource',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: ['linkedResource'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -157,7 +126,8 @@ export const linkedResourceFields: INodeProperties[] = [
|
||||
name: 'externalId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'ID of the object that is associated with this task on the third-party/partner system',
|
||||
description:
|
||||
'ID of the object that is associated with this task on the third-party/partner system',
|
||||
},
|
||||
{
|
||||
displayName: 'Web URL',
|
||||
@@ -178,14 +148,8 @@ export const linkedResourceFields: INodeProperties[] = [
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'linkedResource',
|
||||
],
|
||||
operation: [
|
||||
'delete',
|
||||
'get',
|
||||
'update',
|
||||
],
|
||||
resource: ['linkedResource'],
|
||||
operation: ['delete', 'get', 'update'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -201,12 +165,8 @@ export const linkedResourceFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'linkedResource',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['linkedResource'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -218,12 +178,8 @@ export const linkedResourceFields: INodeProperties[] = [
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'linkedResource',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['linkedResource'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
@@ -246,12 +202,8 @@ export const linkedResourceFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'linkedResource',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: ['linkedResource'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -274,7 +226,8 @@ export const linkedResourceFields: INodeProperties[] = [
|
||||
name: 'externalId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'ID of the object that is associated with this task on the third-party/partner system',
|
||||
description:
|
||||
'ID of the object that is associated with this task on the third-party/partner system',
|
||||
},
|
||||
{
|
||||
displayName: 'Web URL',
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const listOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const listOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'list',
|
||||
],
|
||||
resource: ['list'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -56,12 +52,8 @@ export const listFields: INodeProperties[] = [
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'list',
|
||||
],
|
||||
operation: ['create'],
|
||||
resource: ['list'],
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
@@ -78,19 +70,13 @@ export const listFields: INodeProperties[] = [
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'delete',
|
||||
'get',
|
||||
'update',
|
||||
],
|
||||
resource: [
|
||||
'list',
|
||||
],
|
||||
operation: ['delete', 'get', 'update'],
|
||||
resource: ['list'],
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
default: '',
|
||||
description: 'The identifier of the list, unique in the user\'s mailbox',
|
||||
description: "The identifier of the list, unique in the user's mailbox",
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@@ -102,12 +88,8 @@ export const listFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'list',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['list'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -119,12 +101,8 @@ export const listFields: INodeProperties[] = [
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'list',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['list'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
@@ -145,12 +123,8 @@ export const listFields: INodeProperties[] = [
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: [
|
||||
'list',
|
||||
],
|
||||
operation: ['update'],
|
||||
resource: ['list'],
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
@@ -12,25 +10,13 @@ import {
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
microsoftApiRequest,
|
||||
microsoftApiRequestAllItems,
|
||||
} from './GenericFunctions';
|
||||
import { microsoftApiRequest, microsoftApiRequestAllItems } from './GenericFunctions';
|
||||
|
||||
import {
|
||||
linkedResourceFields,
|
||||
linkedResourceOperations,
|
||||
} from './LinkedResourceDescription';
|
||||
import { linkedResourceFields, linkedResourceOperations } from './LinkedResourceDescription';
|
||||
|
||||
import {
|
||||
taskFields,
|
||||
taskOperations,
|
||||
} from './TaskDescription';
|
||||
import { taskFields, taskOperations } from './TaskDescription';
|
||||
|
||||
import {
|
||||
listFields,
|
||||
listOperations,
|
||||
} from './ListDescription';
|
||||
import { listFields, listOperations } from './ListDescription';
|
||||
|
||||
import moment from 'moment-timezone';
|
||||
|
||||
@@ -114,81 +100,112 @@ export class MicrosoftToDo implements INodeType {
|
||||
const operation = this.getNodeParameter('operation', 0) as string;
|
||||
for (let i = 0; i < length; i++) {
|
||||
try {
|
||||
|
||||
if (resource === 'linkedResource') {
|
||||
// https://docs.microsoft.com/en-us/graph/api/todotask-post-linkedresources?view=graph-rest-1.0&tabs=http
|
||||
if (operation === 'create') {
|
||||
|
||||
const taskListId = this.getNodeParameter('taskListId', i) as string;
|
||||
const taskId = this.getNodeParameter('taskId', i) as string;
|
||||
const body: IDataObject = {
|
||||
applicationName: this.getNodeParameter('applicationName', i) as string,
|
||||
displayName: this.getNodeParameter('displayName', i) as string,
|
||||
...this.getNodeParameter('additionalFields', i) as IDataObject[],
|
||||
...(this.getNodeParameter('additionalFields', i) as IDataObject[]),
|
||||
};
|
||||
|
||||
responseData = await microsoftApiRequest.call(this, 'POST', `/todo/lists/${taskListId}/tasks/${taskId}/linkedResources`, body, qs);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/todo/lists/${taskListId}/tasks/${taskId}/linkedResources`,
|
||||
body,
|
||||
qs,
|
||||
);
|
||||
|
||||
// https://docs.microsoft.com/en-us/graph/api/linkedresource-delete?view=graph-rest-1.0&tabs=http
|
||||
} else if (operation === 'delete') {
|
||||
|
||||
const taskListId = this.getNodeParameter('taskListId', i) as string;
|
||||
const taskId = this.getNodeParameter('taskId', i) as string;
|
||||
const linkedResourceId = this.getNodeParameter('linkedResourceId', i) as string;
|
||||
|
||||
responseData = await microsoftApiRequest.call(this, 'DELETE', `/todo/lists/${taskListId}/tasks/${taskId}/linkedResources/${linkedResourceId}`, undefined, qs);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/todo/lists/${taskListId}/tasks/${taskId}/linkedResources/${linkedResourceId}`,
|
||||
undefined,
|
||||
qs,
|
||||
);
|
||||
responseData = { success: true };
|
||||
|
||||
// https://docs.microsoft.com/en-us/graph/api/linkedresource-get?view=graph-rest-1.0&tabs=http
|
||||
} else if (operation === 'get') {
|
||||
|
||||
const taskListId = this.getNodeParameter('taskListId', i) as string;
|
||||
const taskId = this.getNodeParameter('taskId', i) as string;
|
||||
const linkedResourceId = this.getNodeParameter('linkedResourceId', i) as string;
|
||||
|
||||
responseData = await microsoftApiRequest.call(this, 'GET', `/todo/lists/${taskListId}/tasks/${taskId}/linkedResources/${linkedResourceId}`, undefined, qs);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/todo/lists/${taskListId}/tasks/${taskId}/linkedResources/${linkedResourceId}`,
|
||||
undefined,
|
||||
qs,
|
||||
);
|
||||
|
||||
// https://docs.microsoft.com/en-us/graph/api/todotask-list-linkedresources?view=graph-rest-1.0&tabs=http
|
||||
} else if (operation === 'getAll') {
|
||||
|
||||
const taskListId = this.getNodeParameter('taskListId', i) as string;
|
||||
const taskId = this.getNodeParameter('taskId', i) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
|
||||
if (returnAll === true) {
|
||||
responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/todo/lists/${taskListId}/tasks/${taskId}/linkedResources`, undefined, qs);
|
||||
responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/todo/lists/${taskListId}/tasks/${taskId}/linkedResources`,
|
||||
undefined,
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
qs['$top'] = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await microsoftApiRequest.call(this, 'GET', `/todo/lists/${taskListId}/tasks/${taskId}/linkedResources`, undefined, qs);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/todo/lists/${taskListId}/tasks/${taskId}/linkedResources`,
|
||||
undefined,
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.value;
|
||||
}
|
||||
|
||||
// https://docs.microsoft.com/en-us/graph/api/linkedresource-update?view=graph-rest-1.0&tabs=http
|
||||
} else if (operation === 'update') {
|
||||
|
||||
const taskListId = this.getNodeParameter('taskListId', i) as string;
|
||||
const taskId = this.getNodeParameter('taskId', i) as string;
|
||||
const linkedResourceId = this.getNodeParameter('linkedResourceId', i) as string;
|
||||
|
||||
const body: IDataObject = {
|
||||
...this.getNodeParameter('updateFields', i) as IDataObject[],
|
||||
...(this.getNodeParameter('updateFields', i) as IDataObject[]),
|
||||
};
|
||||
|
||||
responseData = await microsoftApiRequest.call(this, 'PATCH', `/todo/lists/${taskListId}/tasks/${taskId}/linkedResources/${linkedResourceId}`, body, qs);
|
||||
|
||||
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'PATCH',
|
||||
`/todo/lists/${taskListId}/tasks/${taskId}/linkedResources/${linkedResourceId}`,
|
||||
body,
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not supported!`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The operation "${operation}" is not supported!`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
} else if (resource === 'task') {
|
||||
|
||||
// https://docs.microsoft.com/en-us/graph/api/todotasklist-post-tasks?view=graph-rest-1.0&tabs=http
|
||||
if (operation === 'create') {
|
||||
|
||||
const taskListId = this.getNodeParameter('taskListId', i) as string;
|
||||
const body: IDataObject = {
|
||||
title: this.getNodeParameter('title', i) as string,
|
||||
...this.getNodeParameter('additionalFields', i) as IDataObject[],
|
||||
...(this.getNodeParameter('additionalFields', i) as IDataObject[]),
|
||||
};
|
||||
|
||||
if (body.content) {
|
||||
@@ -205,46 +222,73 @@ export class MicrosoftToDo implements INodeType {
|
||||
};
|
||||
}
|
||||
|
||||
responseData = await microsoftApiRequest.call(this, 'POST', `/todo/lists/${taskListId}/tasks`, body, qs);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/todo/lists/${taskListId}/tasks`,
|
||||
body,
|
||||
qs,
|
||||
);
|
||||
|
||||
// https://docs.microsoft.com/en-us/graph/api/todotask-delete?view=graph-rest-1.0&tabs=http
|
||||
} else if (operation === 'delete') {
|
||||
|
||||
const taskListId = this.getNodeParameter('taskListId', i) as string;
|
||||
const taskId = this.getNodeParameter('taskId', i) as string;
|
||||
|
||||
responseData = await microsoftApiRequest.call(this, 'DELETE', `/todo/lists/${taskListId}/tasks/${taskId}`, undefined, qs);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/todo/lists/${taskListId}/tasks/${taskId}`,
|
||||
undefined,
|
||||
qs,
|
||||
);
|
||||
responseData = { success: true };
|
||||
|
||||
// https://docs.microsoft.com/en-us/graph/api/todotask-get?view=graph-rest-1.0&tabs=http
|
||||
} else if (operation === 'get') {
|
||||
|
||||
const taskListId = this.getNodeParameter('taskListId', i) as string;
|
||||
const taskId = this.getNodeParameter('taskId', i) as string;
|
||||
|
||||
responseData = await microsoftApiRequest.call(this, 'GET', `/todo/lists/${taskListId}/tasks/${taskId}`, undefined, qs);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/todo/lists/${taskListId}/tasks/${taskId}`,
|
||||
undefined,
|
||||
qs,
|
||||
);
|
||||
|
||||
// https://docs.microsoft.com/en-us/graph/api/todotasklist-list-tasks?view=graph-rest-1.0&tabs=http
|
||||
} else if (operation === 'getAll') {
|
||||
|
||||
const taskListId = this.getNodeParameter('taskListId', i) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
|
||||
if (returnAll === true) {
|
||||
responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/todo/lists/${taskListId}/tasks/`, undefined, qs);
|
||||
responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/todo/lists/${taskListId}/tasks/`,
|
||||
undefined,
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
qs['$top'] = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await microsoftApiRequest.call(this, 'GET', `/todo/lists/${taskListId}/tasks/`, undefined, qs);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/todo/lists/${taskListId}/tasks/`,
|
||||
undefined,
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.value;
|
||||
}
|
||||
|
||||
// https://docs.microsoft.com/en-us/graph/api/todotask-update?view=graph-rest-1.0&tabs=http
|
||||
} else if (operation === 'update') {
|
||||
|
||||
const taskListId = this.getNodeParameter('taskListId', i) as string;
|
||||
const taskId = this.getNodeParameter('taskId', i) as string;
|
||||
const body: IDataObject = {
|
||||
...this.getNodeParameter('updateFields', i) as IDataObject[],
|
||||
...(this.getNodeParameter('updateFields', i) as IDataObject[]),
|
||||
};
|
||||
|
||||
if (body.content) {
|
||||
@@ -261,17 +305,23 @@ export class MicrosoftToDo implements INodeType {
|
||||
};
|
||||
}
|
||||
|
||||
responseData = await microsoftApiRequest.call(this, 'PATCH', `/todo/lists/${taskListId}/tasks/${taskId}`, body, qs);
|
||||
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'PATCH',
|
||||
`/todo/lists/${taskListId}/tasks/${taskId}`,
|
||||
body,
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not supported!`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The operation "${operation}" is not supported!`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
|
||||
} else if (resource === 'list') {
|
||||
|
||||
// https://docs.microsoft.com/en-us/graph/api/todo-post-lists?view=graph-rest-1.0&tabs=http
|
||||
if (operation === 'create') {
|
||||
|
||||
const body = {
|
||||
displayName: this.getNodeParameter('displayName', i) as string,
|
||||
};
|
||||
@@ -280,41 +330,71 @@ export class MicrosoftToDo implements INodeType {
|
||||
|
||||
// https://docs.microsoft.com/en-us/graph/api/todotasklist-delete?view=graph-rest-1.0&tabs=http
|
||||
} else if (operation === 'delete') {
|
||||
|
||||
const listId = this.getNodeParameter('listId', i) as string;
|
||||
responseData = await microsoftApiRequest.call(this, 'DELETE', `/todo/lists/${listId}`, undefined, qs);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/todo/lists/${listId}`,
|
||||
undefined,
|
||||
qs,
|
||||
);
|
||||
responseData = { success: true };
|
||||
|
||||
//https://docs.microsoft.com/en-us/graph/api/todotasklist-get?view=graph-rest-1.0&tabs=http
|
||||
} else if (operation === 'get') {
|
||||
|
||||
const listId = this.getNodeParameter('listId', i) as string;
|
||||
responseData = await microsoftApiRequest.call(this, 'GET', `/todo/lists/${listId}`, undefined, qs);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/todo/lists/${listId}`,
|
||||
undefined,
|
||||
qs,
|
||||
);
|
||||
|
||||
// https://docs.microsoft.com/en-us/graph/api/todo-list-lists?view=graph-rest-1.0&tabs=http
|
||||
} else if (operation === 'getAll') {
|
||||
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
if (returnAll === true) {
|
||||
responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', '/todo/lists', undefined, qs);
|
||||
responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
'/todo/lists',
|
||||
undefined,
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
qs['$top'] = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await microsoftApiRequest.call(this, 'GET', '/todo/lists', undefined, qs);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'/todo/lists',
|
||||
undefined,
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.value;
|
||||
}
|
||||
|
||||
// https://docs.microsoft.com/en-us/graph/api/todotasklist-update?view=graph-rest-1.0&tabs=http
|
||||
} else if (operation === 'update') {
|
||||
|
||||
const listId = this.getNodeParameter('listId', i) as string;
|
||||
const body = {
|
||||
displayName: this.getNodeParameter('displayName', i) as string,
|
||||
};
|
||||
|
||||
responseData = await microsoftApiRequest.call(this, 'PATCH', `/todo/lists/${listId}`, body, qs);
|
||||
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'PATCH',
|
||||
`/todo/lists/${listId}`,
|
||||
body,
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not supported!`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The operation "${operation}" is not supported!`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const taskOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const taskOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -59,17 +55,14 @@ export const taskFields: INodeProperties[] = [
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: ['create'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
default: '',
|
||||
description: 'The identifier of the list, unique in the user\'s mailbox. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'The identifier of the list, unique in the user\'s mailbox. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Subject',
|
||||
@@ -77,12 +70,8 @@ export const taskFields: INodeProperties[] = [
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: ['create'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
@@ -97,12 +86,8 @@ export const taskFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: ['task'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -186,20 +171,14 @@ export const taskFields: INodeProperties[] = [
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'delete',
|
||||
'get',
|
||||
'getAll',
|
||||
'update',
|
||||
],
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: ['delete', 'get', 'getAll', 'update'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
default: '',
|
||||
description: 'The identifier of the list, unique in the user\'s mailbox. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'The identifier of the list, unique in the user\'s mailbox. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Task ID',
|
||||
@@ -207,14 +186,8 @@ export const taskFields: INodeProperties[] = [
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'delete',
|
||||
'get',
|
||||
'update',
|
||||
],
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: ['delete', 'get', 'update'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
@@ -230,12 +203,8 @@ export const taskFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['task'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -247,12 +216,8 @@ export const taskFields: INodeProperties[] = [
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['task'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
@@ -275,12 +240,8 @@ export const taskFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: ['task'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
|
||||
Reference in New Issue
Block a user