fix formatting and syntax

This commit is contained in:
shraddha shaligram
2020-06-17 12:49:37 -07:00
parent 717c43b21f
commit c25d62474a
2 changed files with 250 additions and 280 deletions

View File

@@ -8,10 +8,10 @@ import {
ILoadOptionsFunctions, ILoadOptionsFunctions,
INodePropertyOptions INodePropertyOptions
} from 'n8n-workflow'; } from 'n8n-workflow';
import { taskOperations, taskFields } from './TaskDescription';
import { googleApiRequest, googleApiRequestAllItems } from './GenericFunctions'; import { googleApiRequest, googleApiRequestAllItems } from './GenericFunctions';
import { taskOperations, taskFields } from './TaskDescription';
export class GoogleTasks implements INodeType { export class GoogleTasks implements INodeType {
description: INodeTypeDescription = { description: INodeTypeDescription = {
displayName: 'Google Tasks', displayName: 'Google Tasks',
@@ -98,43 +98,40 @@ export class GoogleTasks implements INodeType {
i i
) as IDataObject; ) as IDataObject;
if (additionalFields.parent) if (additionalFields.parent) {
qs.parent = additionalFields.parent as string; qs.parent = additionalFields.parent as string;
if (additionalFields.previous)
qs.previous = additionalFields.previous as string;
if (additionalFields.links) {
body.links = (additionalFields.links as string[]).map(link => {
return { link };
});
} }
if (additionalFields.status) if (additionalFields.previous) {
qs.previous = additionalFields.previous as string;
}
if (additionalFields.status) {
body.status = additionalFields.status as string; body.status = additionalFields.status as string;
}
if (additionalFields.notes) if (additionalFields.notes) {
body.notes = additionalFields.notes as string; body.notes = additionalFields.notes as string;
}
if (additionalFields.title) if (additionalFields.title) {
body.title = additionalFields.title as string; body.title = additionalFields.title as string;
}
if (additionalFields.dueDate) if (additionalFields.dueDate) {
body.dueDate = additionalFields.dueDate as string; body.dueDate = additionalFields.dueDate as string;
}
if (additionalFields.completed) if (additionalFields.completed) {
body.completed = additionalFields.completed as string; body.completed = additionalFields.completed as string;
}
if (additionalFields.deleted) if (additionalFields.deleted) {
body.deleted = additionalFields.deleted as boolean; body.deleted = additionalFields.deleted as boolean;
}
if (additionalFields.hidden) if (additionalFields.selfLink) {
body.hidden = additionalFields.hidden as boolean;
if (additionalFields.position)
body.position = additionalFields.position as string;
if (additionalFields.selfLink)
body.selfLink = additionalFields.selfLink as string; body.selfLink = additionalFields.selfLink as string;
}
responseData = await googleApiRequest.call( responseData = await googleApiRequest.call(
this, this,
@@ -236,38 +233,37 @@ export class GoogleTasks implements INodeType {
i i
) as IDataObject; ) as IDataObject;
if (updateFields.parent) qs.parent = updateFields.parent as string; if (updateFields.previous) {
if (updateFields.previous)
qs.previous = updateFields.previous as string; qs.previous = updateFields.previous as string;
if (updateFields.links) {
body.links = (updateFields.links as string[]).map(link => {
return { link: link };
});
} }
if (updateFields.status) body.status = updateFields.status as string;
if (updateFields.notes) body.notes = updateFields.notes as string; if (updateFields.status) {
body.status = updateFields.status as string;
}
if (updateFields.title) body.title = updateFields.title as string; if (updateFields.notes) {
body.notes = updateFields.notes as string;
}
if (updateFields.dueDate) if (updateFields.title) {
body.title = updateFields.title as string;
}
if (updateFields.dueDate) {
body.dueDate = updateFields.dueDate as string; body.dueDate = updateFields.dueDate as string;
}
if (updateFields.completed) if (updateFields.completed) {
body.completed = updateFields.completed as string; body.completed = updateFields.completed as string;
}
if (updateFields.deleted) if (updateFields.deleted) {
body.deleted = updateFields.deleted as boolean; body.deleted = updateFields.deleted as boolean;
}
if (updateFields.hidden) body.hidden = updateFields.hidden as boolean; if (updateFields.selfLink) {
if (updateFields.position)
body.position = updateFields.position as string;
if (updateFields.selfLink)
body.selfLink = updateFields.selfLink as string; body.selfLink = updateFields.selfLink as string;
}
responseData = await googleApiRequest.call( responseData = await googleApiRequest.call(
this, this,

View File

@@ -7,38 +7,40 @@ export const taskOperations = [
type: 'options', type: 'options',
displayOptions: { displayOptions: {
show: { show: {
resource: ['task'] resource: [
} 'task',
],
},
}, },
options: [ options: [
{ {
name: 'Create', name: 'Create',
value: 'create', value: 'create',
description: 'Add a task to tasklist' description: 'Add a task to tasklist',
}, },
{ {
name: 'Delete', name: 'Delete',
value: 'delete', value: 'delete',
description: 'Delete a task' description: 'Delete a task',
}, },
{ {
name: 'Get', name: 'Get',
value: 'get', value: 'get',
description: 'Retrieve a task' description: 'Retrieve a task',
}, },
{ {
name: 'Get All', name: 'Get All',
value: 'getAll', value: 'getAll',
description: 'Retrieve all tasks from a tasklist' description: 'Retrieve all tasks from a tasklist',
}, },
{ {
name: 'Update', name: 'Update',
value: 'update', value: 'update',
description: 'Update a task' description: 'Update a task',
} }
], ],
default: 'create', default: 'create',
description: 'The operation to perform.' description: 'The operation to perform.',
} }
] as INodeProperties[]; ] as INodeProperties[];
@@ -51,16 +53,20 @@ export const taskFields = [
name: 'task', name: 'task',
type: 'options', type: 'options',
typeOptions: { typeOptions: {
loadOptionsMethod: 'getTasks' loadOptionsMethod: 'getTasks',
}, },
required: true, required: true,
displayOptions: { displayOptions: {
show: { show: {
operation: ['create'], operation: [
resource: ['task'] 'create',
],
resource: [
'task',
],
} }
}, },
default: '' default: '',
}, },
{ {
displayName: 'Additional Fields', displayName: 'Additional Fields',
@@ -70,11 +76,64 @@ export const taskFields = [
default: {}, default: {},
displayOptions: { displayOptions: {
show: { show: {
operation: ['create'], operation: [
resource: ['task'] 'create',
],
resource: [
'task',
],
} }
}, },
options: [ options: [
{
displayName: 'Completion date',
name: 'completed',
type: 'dateTime',
default: '',
description: `Completion date of the task (as a RFC 3339 timestamp). This field is omitted if the task has not been completed.`,
},
{
displayName: 'Deleted status',
name: 'deleted',
type: 'boolean',
default: false,
description: 'Flag indicating whether the task has been deleted.',
},
{
displayName: 'Due Date',
name: 'dueDate',
type: 'dateTime',
default: '',
description: 'Due date of the task.',
},
{
displayName: 'Notes',
name: 'notes',
type: 'string',
default: '',
description: 'Additional Notes.',
},
{
displayName: 'Parent',
name: 'parent',
type: 'string',
default: '',
description: 'Parent task identifier. If the task is created at the top level, this parameter is omitted.',
},
{
displayName: 'Previous',
name: 'previous',
type: 'string',
default: '',
description: 'Previous sibling task identifier. If the task is created at the first position among its siblings, this parameter is omitted.',
},
{
displayName: 'Self Link',
name: 'selfLink',
type: 'string',
default: '',
description: 'URL pointing to this task. Used to retrieve, update, or delete this task.',
},
{ {
displayName: 'Status', displayName: 'Status',
name: 'status', name: 'status',
@@ -82,103 +141,24 @@ export const taskFields = [
options: [ options: [
{ {
name: 'needs Action', name: 'needs Action',
value: 'needsAction' value: 'needsAction',
}, },
{ {
name: 'completed', name: 'completed',
value: 'completed' value: 'completed',
} }
], ],
default: '', default: '',
description: 'Current status of the task.' description: 'Current status of the task.',
},
{
displayName: 'Links',
name: 'links',
type: 'string',
typeOptions: {
multipleValues: true,
multipleValueButtonText: 'Add Link'
},
default: '',
description: 'The links to insert in the task.'
},
{
displayName: 'Notes',
name: 'notes',
type: 'string',
default: '',
description: 'Additional Notes.'
}, },
{ {
displayName: 'Title', displayName: 'Title',
name: 'title', name: 'title',
type: 'string', type: 'string',
default: '', default: '',
description: 'Title of the task.' description: 'Title of the task.',
},
{
displayName: 'Due Date',
name: 'dueDate',
type: 'dateTime',
default: '',
description: 'Due date of the task.'
},
{
displayName: 'Completion date',
name: 'completed',
type: 'dateTime',
default: '',
description: `Completion date of the task (as a RFC 3339 timestamp). This field is omitted if the task has not been completed.`
}, },
{
displayName: 'Deleted status',
name: 'deleted',
type: 'boolean',
default: false,
description: 'Flag indicating whether the task has been deleted.'
},
{
displayName: 'Hidden',
name: 'hidden',
type: 'boolean',
default: false,
description: 'Flag indicating whether the task is hidden.'
},
{
displayName: 'Parent',
name: 'parent',
type: 'string',
default: '',
description:
'Parent task identifier.This field is omitted if it is a top-level task.'
},
{
displayName: 'Position',
name: 'position',
type: 'string',
default: '',
description:
'Parent task identifier.This field is omitted if it is a top-level task.'
},
{
displayName: 'Self Link',
name: 'selfLink',
type: 'string',
default: '',
description:
'URL pointing to this task. Used to retrieve, update, or delete this task.'
},
{
displayName: 'Previous',
name: 'previous',
type: 'string',
default: '',
description:
'Previous sibling task identifier. If the task is created at the first position among its siblings, this parameter is omitted.'
}
] ]
}, },
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
@@ -189,16 +169,20 @@ export const taskFields = [
name: 'task', name: 'task',
type: 'options', type: 'options',
typeOptions: { typeOptions: {
loadOptionsMethod: 'getTasks' loadOptionsMethod: 'getTasks',
}, },
required: true, required: true,
displayOptions: { displayOptions: {
show: { show: {
operation: ['delete'], operation: [
resource: ['task'] 'delete',
],
resource: [
'task',
],
} }
}, },
default: '' default: '',
}, },
{ {
displayName: 'Task ID', displayName: 'Task ID',
@@ -207,11 +191,15 @@ export const taskFields = [
required: true, required: true,
displayOptions: { displayOptions: {
show: { show: {
operation: ['delete'], operation: [
resource: ['task'] 'delete',
],
resource: [
'task',
],
} }
}, },
default: '' default: '',
}, },
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* task:get */ /* task:get */
@@ -221,16 +209,20 @@ export const taskFields = [
name: 'task', name: 'task',
type: 'options', type: 'options',
typeOptions: { typeOptions: {
loadOptionsMethod: 'getTasks' loadOptionsMethod: 'getTasks',
}, },
required: true, required: true,
displayOptions: { displayOptions: {
show: { show: {
operation: ['get'], operation: [
resource: ['task'] 'get',
],
resource: [
'task',
],
} }
}, },
default: '' default: '',
}, },
{ {
displayName: 'Task ID', displayName: 'Task ID',
@@ -239,11 +231,15 @@ export const taskFields = [
required: true, required: true,
displayOptions: { displayOptions: {
show: { show: {
operation: ['get'], operation: [
resource: ['task'] 'get',
],
resource: [
'task',
],
} }
}, },
default: '' default: '',
}, },
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* task:getAll */ /* task:getAll */
@@ -253,16 +249,20 @@ export const taskFields = [
name: 'task', name: 'task',
type: 'options', type: 'options',
typeOptions: { typeOptions: {
loadOptionsMethod: 'getTasks' loadOptionsMethod: 'getTasks',
}, },
required: true, required: true,
displayOptions: { displayOptions: {
show: { show: {
operation: ['getAll'], operation: [
resource: ['task'] 'getAll',
],
resource: [
'task',
],
} }
}, },
default: '' default: '',
}, },
{ {
displayName: 'Return All', displayName: 'Return All',
@@ -270,13 +270,16 @@ export const taskFields = [
type: 'boolean', type: 'boolean',
displayOptions: { displayOptions: {
show: { show: {
operation: ['getAll'], operation: [
resource: ['task'] 'getAll',
],
resource: [
'task',
],
} }
}, },
default: false, default: false,
description: description: 'If all results should be returned or only up to a given limit.',
'If all results should be returned or only up to a given limit.'
}, },
{ {
displayName: 'Limit', displayName: 'Limit',
@@ -284,9 +287,15 @@ export const taskFields = [
type: 'number', type: 'number',
displayOptions: { displayOptions: {
show: { show: {
operation: ['getAll'], operation: [
resource: ['task'], 'getAll',
returnAll: [false] ],
resource: [
'task',
],
returnAll: [
false,
],
} }
}, },
typeOptions: { typeOptions: {
@@ -294,7 +303,7 @@ export const taskFields = [
maxValue: 100 maxValue: 100
}, },
default: 20, default: 20,
description: 'How many results to return.' description: 'How many results to return.',
}, },
{ {
displayName: 'Additional Fields', displayName: 'Additional Fields',
@@ -304,8 +313,12 @@ export const taskFields = [
default: {}, default: {},
displayOptions: { displayOptions: {
show: { show: {
operation: ['getAll'], operation: [
resource: ['task'] 'getAll',
],
resource: [
'task',
],
} }
}, },
@@ -315,40 +328,35 @@ export const taskFields = [
name: 'completedMax', name: 'completedMax',
type: 'dateTime', type: 'dateTime',
default: '', default: '',
description: description: 'Upper bound for a task completion date (as a RFC 3339 timestamp) to filter by.',
'Upper bound for a task completion date (as a RFC 3339 timestamp) to filter by.'
}, },
{ {
displayName: 'Completed Min', displayName: 'Completed Min',
name: 'completedMin', name: 'completedMin',
type: 'dateTime', type: 'dateTime',
default: '', default: '',
description: description: 'Lower bound for a task completion date (as a RFC 3339 timestamp) to filter by.',
'Lower bound for a task completion date (as a RFC 3339 timestamp) to filter by.'
}, },
{ {
displayName: 'Due Min', displayName: 'Due Min',
name: 'dueMin', name: 'dueMin',
type: 'dateTime', type: 'dateTime',
default: '', default: '',
description: description: 'Lower bound for a task due date (as a RFC 3339 timestamp) to filter by.',
'Lower bound for a task due date (as a RFC 3339 timestamp) to filter by.'
}, },
{ {
displayName: 'Due Max', displayName: 'Due Max',
name: 'dueMax', name: 'dueMax',
type: 'dateTime', type: 'dateTime',
default: '', default: '',
description: description: 'Upper bound for a task due date (as a RFC 3339 timestamp) to filter by.',
'Upper bound for a task due date (as a RFC 3339 timestamp) to filter by.'
}, },
{ {
displayName: 'Page Token', displayName: 'Page Token',
name: 'pageToken', name: 'pageToken',
type: 'string', type: 'string',
default: '', default: '',
description: 'Token specifying the result page to return.' description: 'Token specifying the result page to return.',
}, },
{ {
@@ -356,33 +364,29 @@ export const taskFields = [
name: 'showCompleted', name: 'showCompleted',
type: 'boolean', type: 'boolean',
default: true, default: true,
description: description: 'Flag indicating whether completed tasks are returned in the result',
'Flag indicating whether completed tasks are returned in the result'
}, },
{ {
displayName: 'Show Deleted', displayName: 'Show Deleted',
name: 'showDeleted', name: 'showDeleted',
type: 'boolean', type: 'boolean',
default: false, default: false,
description: description: 'Flag indicating whether deleted tasks are returned in the result',
'Flag indicating whether deleted tasks are returned in the result'
}, },
{ {
displayName: 'Show Hidden', displayName: 'Show Hidden',
name: 'showHidden', name: 'showHidden',
type: 'boolean', type: 'boolean',
default: false, default: false,
description: description: 'Flag indicating whether hidden tasks are returned in the result',
'Flag indicating whether hidden tasks are returned in the result'
}, },
{ {
displayName: 'Updated Min', displayName: 'Updated Min',
name: 'updatedMin', name: 'updatedMin',
type: 'string', type: 'string',
default: '',
description: description: 'Lower bound for a task last modification time (as a RFC 3339 timestamp) to filter by.',
'Lower bound for a task last modification time (as a RFC 3339 timestamp) to filter by.' },
}
] ]
}, },
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
@@ -393,16 +397,20 @@ export const taskFields = [
name: 'task', name: 'task',
type: 'options', type: 'options',
typeOptions: { typeOptions: {
loadOptionsMethod: 'getTasks' loadOptionsMethod: 'getTasks',
}, },
required: true, required: true,
displayOptions: { displayOptions: {
show: { show: {
operation: ['update'], operation: [
resource: ['task'] 'update',
],
resource: [
'task',
],
} }
}, },
default: '' default: '',
}, },
{ {
displayName: 'Task ID', displayName: 'Task ID',
@@ -411,11 +419,15 @@ export const taskFields = [
required: true, required: true,
displayOptions: { displayOptions: {
show: { show: {
operation: ['update'], operation: [
resource: ['task'] 'update',
],
resource: [
'task',
],
} }
}, },
default: '' default: '',
}, },
{ {
displayName: 'Update Fields', displayName: 'Update Fields',
@@ -425,67 +437,21 @@ export const taskFields = [
default: {}, default: {},
displayOptions: { displayOptions: {
show: { show: {
operation: ['update'], operation: [
resource: ['task'] 'update',
}
},
options: [
{
displayName: 'Status',
name: 'status',
type: 'options',
options: [
{
name: 'needs Action',
value: 'needsAction'
},
{
name: 'completed',
value: 'completed'
}
], ],
default: '', resource: [
description: 'Current status of the task.' 'task',
}, ],
{ }
displayName: 'Links',
name: 'links',
type: 'string',
typeOptions: {
multipleValues: true,
multipleValueButtonText: 'Add Link'
},
default: '',
description: 'The links to insert in the task.'
},
{
displayName: 'Notes',
name: 'notes',
type: 'string',
default: '',
description: 'Additional Notes.'
},
{
displayName: 'Title',
name: 'title',
type: 'string',
default: '',
description: 'Title of the task.'
},
{
displayName: 'Due Date',
name: 'dueDate',
type: 'dateTime',
default: '',
description: 'Due date of the task.'
}, },
options: [
{ {
displayName: 'Completion date', displayName: 'Completion date',
name: 'completed', name: 'completed',
type: 'dateTime', type: 'dateTime',
default: '', default: '',
description: `Completion date of the task (as a RFC 3339 timestamp). This field is omitted if the task has not been completed.` description: `Completion date of the task (as a RFC 3339 timestamp). This field is omitted if the task has not been completed.`,
}, },
{ {
@@ -493,47 +459,55 @@ export const taskFields = [
name: 'deleted', name: 'deleted',
type: 'boolean', type: 'boolean',
default: false, default: false,
description: 'Flag indicating whether the task has been deleted.' description: 'Flag indicating whether the task has been deleted.',
}, },
{ {
displayName: 'Hidden', displayName: 'Notes',
name: 'hidden', name: 'notes',
type: 'boolean',
default: false,
description: 'Flag indicating whether the task is hidden.'
},
{
displayName: 'Parent',
name: 'parent',
type: 'string', type: 'string',
default: '', default: '',
description: description: 'Additional Notes.',
'Parent task identifier.This field is omitted if it is a top-level task.'
},
{
displayName: 'Position',
name: 'position',
type: 'string',
default: '',
description:
'Parent task identifier.This field is omitted if it is a top-level task.'
},
{
displayName: 'Self Link',
name: 'selfLink',
type: 'string',
default: '',
description:
'URL pointing to this task. Used to retrieve, update, or delete this task.'
}, },
{ {
displayName: 'Previous', displayName: 'Previous',
name: 'previous', name: 'previous',
type: 'string', type: 'string',
default: '', default: '',
description: description: 'Previous sibling task identifier. If the task is created at the first position among its siblings, this parameter is omitted.',
'Previous sibling task identifier. If the task is created at the first position among its siblings, this parameter is omitted.' },
{
displayName: 'Self Link',
name: 'selfLink',
type: 'string',
default: '',
description: 'URL pointing to this task. Used to retrieve, update, or delete this task.',
},
{
displayName: 'Status',
name: 'status',
type: 'options',
options: [
{
name: 'needs Update',
value: 'needsAction',
},
{
name: 'completed',
value: 'completed',
} }
],
default: '',
description: 'Current status of the task.',
},
{
displayName: 'Title',
name: 'title',
type: 'string',
default: '',
description: 'Title of the task.',
},
] ]
} }
] as INodeProperties[]; ] as INodeProperties[];