1
1
mirror of https://github.com/n8n-io/n8n.git synced 2024-09-22 10:39:35 +03:00

Refactor reource names to match endpoint

This commit is contained in:
trojanh 2020-01-31 19:13:40 +05:30
parent 9ff78410ef
commit 1759f6ce98
9 changed files with 97 additions and 169 deletions

View File

@ -1,5 +1,7 @@
import { INodeProperties } from "n8n-workflow";
const resource = [ 'clients' ];
export const clientOperations = [
{
displayName: 'Operation',
@ -7,9 +9,7 @@ export const clientOperations = [
type: 'options',
displayOptions: {
show: {
resource: [
'client',
],
resource
},
},
options: [
@ -47,9 +47,7 @@ export const clientFields = [
type: 'boolean',
displayOptions: {
show: {
resource: [
'client',
],
resource
operation: [
'getAll',
],
@ -64,9 +62,7 @@ export const clientFields = [
type: 'number',
displayOptions: {
show: {
resource: [
'client',
],
resource
operation: [
'getAll',
],
@ -90,9 +86,7 @@ export const clientFields = [
default: {},
displayOptions: {
show: {
resource: [
'client',
],
resource
operation: [
'getAll',
],
@ -130,9 +124,7 @@ export const clientFields = [
operation: [
'get',
],
resource: [
'client',
],
resource
},
},
description: 'The ID of the client you are retrieving.',
@ -152,9 +144,7 @@ export const clientFields = [
operation: [
'delete',
],
resource: [
'client',
],
resource
},
},
description: 'The ID of the client you want to delete.',

View File

@ -1,5 +1,7 @@
import { INodeProperties } from "n8n-workflow";
const resource = [ 'companies' ];
export const companyOperations = [
{
displayName: 'Operation',
@ -7,9 +9,7 @@ export const companyOperations = [
type: 'options',
displayOptions: {
show: {
resource: [
'company',
],
resource,
},
},
options: [

View File

@ -1,5 +1,7 @@
import { INodeProperties } from "n8n-workflow";
const resource = [ 'contacts' ];
export const contactOperations = [
{
displayName: 'Operation',
@ -7,9 +9,7 @@ export const contactOperations = [
type: 'options',
displayOptions: {
show: {
resource: [
'contact',
],
resource,
},
},
options: [
@ -47,9 +47,7 @@ export const contactFields = [
type: 'boolean',
displayOptions: {
show: {
resource: [
'contact',
],
resource,
operation: [
'getAll',
],
@ -64,9 +62,7 @@ export const contactFields = [
type: 'number',
displayOptions: {
show: {
resource: [
'contact',
],
resource,
operation: [
'getAll',
],
@ -90,9 +86,7 @@ export const contactFields = [
default: {},
displayOptions: {
show: {
resource: [
'contact',
],
resource,
operation: [
'getAll',
],
@ -130,9 +124,7 @@ export const contactFields = [
operation: [
'get',
],
resource: [
'contact',
],
resource,
},
},
description: 'The ID of the contact you are retrieving.',
@ -152,9 +144,7 @@ export const contactFields = [
operation: [
'delete',
],
resource: [
'contact',
],
resource,
},
},
description: 'The ID of the contact you want to delete.',

View File

@ -1,5 +1,7 @@
import { INodeProperties } from "n8n-workflow";
const resource = [ 'estimates' ];
export const estimateOperations = [
{
displayName: 'Operation',
@ -7,9 +9,7 @@ export const estimateOperations = [
type: 'options',
displayOptions: {
show: {
resource: [
'estimate',
],
resource,
},
},
options: [
@ -47,9 +47,7 @@ export const estimateFields = [
type: 'boolean',
displayOptions: {
show: {
resource: [
'estimate',
],
resource,
operation: [
'getAll',
],
@ -64,9 +62,7 @@ export const estimateFields = [
type: 'number',
displayOptions: {
show: {
resource: [
'estimate',
],
resource,
operation: [
'getAll',
],
@ -90,9 +86,7 @@ export const estimateFields = [
default: {},
displayOptions: {
show: {
resource: [
'estimate',
],
resource,
operation: [
'getAll',
],
@ -161,9 +155,7 @@ export const estimateFields = [
operation: [
'get',
],
resource: [
'estimate',
],
resource,
},
},
description: 'The ID of the estimate you are retrieving.',
@ -183,9 +175,7 @@ export const estimateFields = [
operation: [
'delete',
],
resource: [
'estimate',
],
resource,
},
},
description: 'The ID of the estimate want to delete.',

View File

@ -1,5 +1,7 @@
import { INodeProperties } from "n8n-workflow";
const resource = [ 'invoices' ];
export const expenseOperations = [
{
displayName: 'Operation',
@ -7,9 +9,7 @@ export const expenseOperations = [
type: 'options',
displayOptions: {
show: {
resource: [
'expense',
],
resource,
},
},
options: [
@ -47,9 +47,7 @@ export const expenseFields = [
type: 'boolean',
displayOptions: {
show: {
resource: [
'expense',
],
resource,
operation: [
'getAll',
],
@ -64,9 +62,7 @@ export const expenseFields = [
type: 'number',
displayOptions: {
show: {
resource: [
'expense',
],
resource,
operation: [
'getAll',
],
@ -90,9 +86,7 @@ export const expenseFields = [
default: {},
displayOptions: {
show: {
resource: [
'expense',
],
resource,
operation: [
'getAll',
],
@ -175,9 +169,7 @@ export const expenseFields = [
operation: [
'get',
],
resource: [
'expense',
],
resource,
},
},
description: 'The ID of the expense you are retrieving.',
@ -197,9 +189,7 @@ export const expenseFields = [
operation: [
'delete',
],
resource: [
'expense',
],
resource,
},
},
description: 'The ID of the expense you want to delete.',

View File

@ -75,35 +75,35 @@ export class Harvest implements INodeType {
{
name: 'Client',
value: 'client',
value: 'clients',
},
{
name: 'Company',
value: 'company',
value: 'companies',
},
{
name: 'Contact',
value: 'contact',
value: 'contacts',
},
{
name: 'Estimates',
value: 'estimate',
value: 'estimates',
},
{
name: 'Expense',
value: 'expense',
value: 'expenses',
},
{
name: 'Invoice',
value: 'invoice',
value: 'invoices',
},
{
name: 'Project',
value: 'project',
value: 'projects',
},
{
name: 'Task',
value: 'task',
value: 'tasks',
},
{
name: 'Time Entries',
@ -114,7 +114,7 @@ export class Harvest implements INodeType {
value: 'users',
},
],
default: 'task',
default: 'tasks',
description: 'The resource to operate on.',
},
@ -284,7 +284,7 @@ export class Harvest implements INodeType {
throw new Error(`The operation "${operation}" is not known!`);
}
} else if (resource === 'client') {
} else if (resource === 'clients') {
if (operation === 'get') {
// ----------------------------------
// get
@ -293,7 +293,7 @@ export class Harvest implements INodeType {
requestMethod = 'GET';
const id = this.getNodeParameter('id', i) as string;
endpoint = `clients/${id}`;
endpoint = `${resource}/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData);
@ -303,7 +303,7 @@ export class Harvest implements INodeType {
// getAll
// ----------------------------------
const responseData: IDataObject[] = await getAllResource.call(this, 'clients', i);
const responseData: IDataObject[] = await getAllResource.call(this, resource, i);
returnData.push.apply(returnData, responseData);
} else if (operation === 'delete') {
@ -313,14 +313,14 @@ export class Harvest implements INodeType {
requestMethod = 'DELETE';
const id = this.getNodeParameter('id', i) as string;
endpoint = `clients/${id}`;
endpoint = `${resource}/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData);
} else {
throw new Error(`The resource "${resource}" is not known!`);
}
} else if (resource === 'project') {
} else if (resource === 'projects') {
if (operation === 'get') {
// ----------------------------------
// get
@ -329,7 +329,7 @@ export class Harvest implements INodeType {
requestMethod = 'GET';
const id = this.getNodeParameter('id', i) as string;
endpoint = `projects/${id}`;
endpoint = `${resource}/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData);
@ -339,7 +339,7 @@ export class Harvest implements INodeType {
// getAll
// ----------------------------------
const responseData: IDataObject[] = await getAllResource.call(this, 'projects', i);
const responseData: IDataObject[] = await getAllResource.call(this, resource, i);
returnData.push.apply(returnData, responseData);
} else if (operation === 'delete') {
@ -349,7 +349,7 @@ export class Harvest implements INodeType {
requestMethod = 'DELETE';
const id = this.getNodeParameter('id', i) as string;
endpoint = `projects/${id}`;
endpoint = `${resource}/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData);
@ -430,14 +430,14 @@ export class Harvest implements INodeType {
requestMethod = 'DELETE';
const id = this.getNodeParameter('id', i) as string;
endpoint = `users/${id}`;
endpoint = `${resource}/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData);
} else {
throw new Error(`The resource "${resource}" is not known!`);
}
} else if (resource === 'contact') {
} else if (resource === 'contacts') {
if (operation === 'get') {
// ----------------------------------
// get
@ -446,7 +446,7 @@ export class Harvest implements INodeType {
requestMethod = 'GET';
const id = this.getNodeParameter('id', i) as string;
endpoint = `contacts/${id}`;
endpoint = `${resource}/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData);
@ -456,7 +456,7 @@ export class Harvest implements INodeType {
// getAll
// ----------------------------------
const responseData: IDataObject[] = await getAllResource.call(this, 'contacts', i);
const responseData: IDataObject[] = await getAllResource.call(this, resource, i);
returnData.push.apply(returnData, responseData);
} else if (operation === 'delete') {
@ -466,14 +466,14 @@ export class Harvest implements INodeType {
requestMethod = 'DELETE';
const id = this.getNodeParameter('id', i) as string;
endpoint = `contacts/${id}`;
endpoint = `${resource}/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData);
} else {
throw new Error(`The resource "${resource}" is not known!`);
}
} else if (resource === 'company') {
} else if (resource === 'companies') {
if (operation === 'get') {
// ----------------------------------
// get
@ -488,7 +488,7 @@ export class Harvest implements INodeType {
} else {
throw new Error(`The resource "${resource}" is not known!`);
}
} else if (resource === 'task') {
} else if (resource === 'tasks') {
if (operation === 'get') {
// ----------------------------------
// get
@ -497,7 +497,7 @@ export class Harvest implements INodeType {
requestMethod = 'GET';
const id = this.getNodeParameter('id', i) as string;
endpoint = `tasks/${id}`;
endpoint = `${resource}/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData);
@ -507,7 +507,7 @@ export class Harvest implements INodeType {
// getAll
// ----------------------------------
const responseData: IDataObject[] = await getAllResource.call(this, 'tasks', i);
const responseData: IDataObject[] = await getAllResource.call(this, resource, i);
returnData.push.apply(returnData, responseData);
} else if (operation === 'delete') {
@ -517,14 +517,14 @@ export class Harvest implements INodeType {
requestMethod = 'DELETE';
const id = this.getNodeParameter('id', i) as string;
endpoint = `tasks/${id}`;
endpoint = `${resource}/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData);
} else {
throw new Error(`The resource "${resource}" is not known!`);
}
} else if (resource === 'invoice') {
} else if (resource === 'invoices') {
if (operation === 'get') {
// ----------------------------------
// get
@ -533,7 +533,7 @@ export class Harvest implements INodeType {
requestMethod = 'GET';
const id = this.getNodeParameter('id', i) as string;
endpoint = `invoices/${id}`;
endpoint = `${resource}/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData);
@ -543,7 +543,7 @@ export class Harvest implements INodeType {
// getAll
// ----------------------------------
const responseData: IDataObject[] = await getAllResource.call(this, 'invoices', i);
const responseData: IDataObject[] = await getAllResource.call(this, resource, i);
returnData.push.apply(returnData, responseData);
} else if (operation === 'delete') {
@ -553,14 +553,14 @@ export class Harvest implements INodeType {
requestMethod = 'DELETE';
const id = this.getNodeParameter('id', i) as string;
endpoint = `invoices/${id}`;
endpoint = `${resource}/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData);
} else {
throw new Error(`The resource "${resource}" is not known!`);
}
} else if (resource === 'expense') {
} else if (resource === 'expenses') {
if (operation === 'get') {
// ----------------------------------
// get
@ -569,7 +569,7 @@ export class Harvest implements INodeType {
requestMethod = 'GET';
const id = this.getNodeParameter('id', i) as string;
endpoint = `expenses/${id}`;
endpoint = `${resource}/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData);
@ -579,7 +579,7 @@ export class Harvest implements INodeType {
// getAll
// ----------------------------------
const responseData: IDataObject[] = await getAllResource.call(this, 'expenses', i);
const responseData: IDataObject[] = await getAllResource.call(this, resource, i);
returnData.push.apply(returnData, responseData);
} else if (operation === 'delete') {
@ -589,14 +589,14 @@ export class Harvest implements INodeType {
requestMethod = 'DELETE';
const id = this.getNodeParameter('id', i) as string;
endpoint = `expenses/${id}`;
endpoint = `${resource}/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData);
} else {
throw new Error(`The resource "${resource}" is not known!`);
}
} else if (resource === 'estimate') {
} else if (resource === 'estimates') {
if (operation === 'get') {
// ----------------------------------
// get
@ -605,7 +605,7 @@ export class Harvest implements INodeType {
requestMethod = 'GET';
const id = this.getNodeParameter('id', i) as string;
endpoint = `estimates/${id}`;
endpoint = `${resource}/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData);
@ -615,7 +615,7 @@ export class Harvest implements INodeType {
// getAll
// ----------------------------------
const responseData: IDataObject[] = await getAllResource.call(this, 'estimates', i);
const responseData: IDataObject[] = await getAllResource.call(this, resource, i);
returnData.push.apply(returnData, responseData);
} else if (operation === 'delete') {
@ -625,7 +625,7 @@ export class Harvest implements INodeType {
requestMethod = 'DELETE';
const id = this.getNodeParameter('id', i) as string;
endpoint = `estimates/${id}`;
endpoint = `${resource}/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData);

View File

@ -1,5 +1,7 @@
import { INodeProperties } from "n8n-workflow";
const resource = [ 'invoices' ];
export const invoiceOperations = [
{
displayName: 'Operation',
@ -7,9 +9,7 @@ export const invoiceOperations = [
type: 'options',
displayOptions: {
show: {
resource: [
'invoice',
],
resource,
},
},
options: [
@ -47,9 +47,7 @@ export const invoiceFields = [
type: 'boolean',
displayOptions: {
show: {
resource: [
'invoice',
],
resource,
operation: [
'getAll',
],
@ -64,9 +62,7 @@ export const invoiceFields = [
type: 'number',
displayOptions: {
show: {
resource: [
'invoice',
],
resource,
operation: [
'getAll',
],
@ -90,9 +86,7 @@ export const invoiceFields = [
default: {},
displayOptions: {
show: {
resource: [
'invoice',
],
resource,
operation: [
'getAll',
],
@ -186,9 +180,7 @@ export const invoiceFields = [
operation: [
'get',
],
resource: [
'invoice',
],
resource,
},
},
description: 'The ID of the invoice you are retrieving.',
@ -208,9 +200,7 @@ export const invoiceFields = [
operation: [
'delete',
],
resource: [
'invoice',
],
resource,
},
},
description: 'The ID of the invoice want to delete.',

View File

@ -1,5 +1,7 @@
import { INodeProperties } from "n8n-workflow";
const resource = [ 'projects' ];
export const projectOperations = [
{
displayName: 'Operation',
@ -7,9 +9,7 @@ export const projectOperations = [
type: 'options',
displayOptions: {
show: {
resource: [
'project',
],
resource,
},
},
options: [
@ -47,9 +47,7 @@ export const projectFields = [
type: 'boolean',
displayOptions: {
show: {
resource: [
'project',
],
resource,
operation: [
'getAll',
],
@ -64,9 +62,7 @@ export const projectFields = [
type: 'number',
displayOptions: {
show: {
resource: [
'project',
],
resource,
operation: [
'getAll',
],
@ -90,9 +86,7 @@ export const projectFields = [
default: {},
displayOptions: {
show: {
resource: [
'project',
],
resource,
operation: [
'getAll',
],
@ -148,9 +142,7 @@ export const projectFields = [
operation: [
'get',
],
resource: [
'project',
],
resource,
},
},
description: 'The ID of the project you are retrieving.',
@ -170,9 +162,7 @@ export const projectFields = [
operation: [
'delete',
],
resource: [
'project',
],
resource,
},
},
description: 'The ID of the project want to delete.',

View File

@ -1,5 +1,5 @@
import { INodeProperties } from "n8n-workflow";
const resource = [ 'tasks' ];
export const taskOperations = [
{
displayName: 'Operation',
@ -7,9 +7,7 @@ export const taskOperations = [
type: 'options',
displayOptions: {
show: {
resource: [
'task',
],
resource,
},
},
options: [
@ -47,9 +45,7 @@ export const taskFields = [
type: 'boolean',
displayOptions: {
show: {
resource: [
'task',
],
resource,
operation: [
'getAll',
],
@ -64,9 +60,7 @@ export const taskFields = [
type: 'number',
displayOptions: {
show: {
resource: [
'task',
],
resource,
operation: [
'getAll',
],
@ -90,9 +84,7 @@ export const taskFields = [
default: {},
displayOptions: {
show: {
resource: [
'task',
],
resource,
operation: [
'getAll',
],
@ -140,9 +132,7 @@ export const taskFields = [
operation: [
'get',
],
resource: [
'task',
],
resource,
},
},
description: 'The ID of the task you are retrieving.',
@ -162,9 +152,7 @@ export const taskFields = [
operation: [
'delete',
],
resource: [
'task',
],
resource,
},
},
description: 'The ID of the task you wan to delete.',