mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
n8n-3867-progressively-apply-prettier-to-all (#3873)
* 🔨 formatting nodes with prettier
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
|
||||
import {
|
||||
OptionsWithUrl,
|
||||
} from 'request';
|
||||
import { OptionsWithUrl } from 'request';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
@@ -10,23 +7,28 @@ import {
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject, NodeApiError, NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
createHmac,
|
||||
} from 'crypto';
|
||||
import { createHmac } from 'crypto';
|
||||
|
||||
import qs from 'qs';
|
||||
|
||||
export async function unleashedApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, path: string, body: any = {}, query: IDataObject = {}, pageNumber?: number, headers?: object): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
export async function unleashedApiRequest(
|
||||
this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions,
|
||||
method: string,
|
||||
path: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
query: IDataObject = {},
|
||||
pageNumber?: number,
|
||||
headers?: object,
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const paginatedPath = pageNumber ? `/${path}/${pageNumber}` : `/${path}`;
|
||||
|
||||
const options: OptionsWithUrl = {
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
method,
|
||||
@@ -42,7 +44,7 @@ export async function unleashedApiRequest(this: IHookFunctions | IExecuteFunctio
|
||||
|
||||
const credentials = await this.getCredentials('unleashedSoftwareApi');
|
||||
|
||||
const signature = createHmac('sha256', (credentials.apiKey as string))
|
||||
const signature = createHmac('sha256', credentials.apiKey as string)
|
||||
.update(qs.stringify(query))
|
||||
.digest('base64');
|
||||
|
||||
@@ -58,8 +60,16 @@ export async function unleashedApiRequest(this: IHookFunctions | IExecuteFunctio
|
||||
}
|
||||
}
|
||||
|
||||
export async function unleashedApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
export async function unleashedApiRequestAllItems(
|
||||
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;
|
||||
let pageNumber = 1;
|
||||
@@ -70,9 +80,9 @@ export async function unleashedApiRequestAllItems(this: IExecuteFunctions | ILoa
|
||||
responseData = await unleashedApiRequest.call(this, method, endpoint, body, query, pageNumber);
|
||||
returnData.push.apply(returnData, responseData[propertyName]);
|
||||
pageNumber++;
|
||||
|
||||
} while (
|
||||
(responseData.Pagination.PageNumber as number) < (responseData.Pagination.NumberOfPages as number)
|
||||
(responseData.Pagination.PageNumber as number) <
|
||||
(responseData.Pagination.NumberOfPages as number)
|
||||
);
|
||||
return returnData;
|
||||
}
|
||||
@@ -80,8 +90,9 @@ export async function unleashedApiRequestAllItems(this: IExecuteFunctions | ILoa
|
||||
//.NET code is serializing dates in the following format: "/Date(1586833770780)/"
|
||||
//which is useless on JS side and could not treated as a date for other nodes
|
||||
//so we need to convert all of the fields that has it.
|
||||
export function convertNETDates(item: { [key: string]: any }) { // tslint:disable-line:no-any
|
||||
Object.keys(item).forEach(path => {
|
||||
// tslint:disable-next-line:no-any
|
||||
export function convertNETDates(item: { [key: string]: any }) {
|
||||
Object.keys(item).forEach((path) => {
|
||||
const type = typeof item[path] as string;
|
||||
if (type === 'string') {
|
||||
const value = item[path] as string;
|
||||
@@ -89,7 +100,8 @@ export function convertNETDates(item: { [key: string]: any }) { // tslint:disabl
|
||||
if (a) {
|
||||
item[path] = new Date(+a[1]);
|
||||
}
|
||||
} if (type === 'object' && item[path]) {
|
||||
}
|
||||
if (type === 'object' && item[path]) {
|
||||
convertNETDates(item[path]);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const salesOrderOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const salesOrderOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'salesOrder',
|
||||
],
|
||||
resource: ['salesOrder'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -28,7 +24,6 @@ export const salesOrderOperations: INodeProperties[] = [
|
||||
];
|
||||
|
||||
export const salesOrderFields: INodeProperties[] = [
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* salesOrder:getAll */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@@ -38,12 +33,8 @@ export const salesOrderFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'salesOrder',
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['salesOrder'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -55,15 +46,9 @@ export const salesOrderFields: INodeProperties[] = [
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'salesOrder',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['salesOrder'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
@@ -81,12 +66,8 @@ export const salesOrderFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'salesOrder',
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['salesOrder'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -96,7 +77,8 @@ export const salesOrderFields: INodeProperties[] = [
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
|
||||
description: 'Only returns orders for a specified Customer GUID. The CustomerId can be specified as a list of comma-separated GUIDs.',
|
||||
description:
|
||||
'Only returns orders for a specified Customer GUID. The CustomerId can be specified as a list of comma-separated GUIDs.',
|
||||
},
|
||||
{
|
||||
displayName: 'Customer Code',
|
||||
@@ -124,7 +106,8 @@ export const salesOrderFields: INodeProperties[] = [
|
||||
name: 'orderNumber',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Returns a single order with the specified order number. If set, it overrides all other filters.',
|
||||
description:
|
||||
'Returns a single order with the specified order number. If set, it overrides all other filters.',
|
||||
},
|
||||
{
|
||||
displayName: 'Order Status',
|
||||
@@ -153,7 +136,8 @@ export const salesOrderFields: INodeProperties[] = [
|
||||
},
|
||||
],
|
||||
default: [],
|
||||
description: 'Returns orders with the specified status. If no orderStatus filter is specified, then we exclude "Deleted" by default.',
|
||||
description:
|
||||
'Returns orders with the specified status. If no orderStatus filter is specified, then we exclude "Deleted" by default.',
|
||||
},
|
||||
{
|
||||
displayName: 'Start Date',
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const stockOnHandOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const stockOnHandOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'stockOnHand',
|
||||
],
|
||||
resource: ['stockOnHand'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -34,7 +30,6 @@ export const stockOnHandOperations: INodeProperties[] = [
|
||||
];
|
||||
|
||||
export const stockOnHandFields: INodeProperties[] = [
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* stockOnHand:get */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@@ -44,12 +39,8 @@ export const stockOnHandFields: INodeProperties[] = [
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
resource: [
|
||||
'stockOnHand',
|
||||
],
|
||||
operation: ['get'],
|
||||
resource: ['stockOnHand'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -63,12 +54,8 @@ export const stockOnHandFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'stockOnHand',
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['stockOnHand'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -80,15 +67,9 @@ export const stockOnHandFields: INodeProperties[] = [
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'stockOnHand',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['stockOnHand'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
@@ -106,12 +87,8 @@ export const stockOnHandFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'stockOnHand',
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['stockOnHand'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -127,7 +104,8 @@ export const stockOnHandFields: INodeProperties[] = [
|
||||
name: 'IsAssembled',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether the AvailableQty will also include the quantity that can be assembled',
|
||||
description:
|
||||
'Whether the AvailableQty will also include the quantity that can be assembled',
|
||||
},
|
||||
{
|
||||
displayName: 'Modified Since',
|
||||
@@ -141,14 +119,16 @@ export const stockOnHandFields: INodeProperties[] = [
|
||||
name: 'orderBy',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Orders the list by a specific column, by default the list is ordered by productCode',
|
||||
description:
|
||||
'Orders the list by a specific column, by default the list is ordered by productCode',
|
||||
},
|
||||
{
|
||||
displayName: 'Product ID',
|
||||
name: 'productId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Returns products with the specific Product Guid. You can enter multiple product IDs separated by commas.',
|
||||
description:
|
||||
'Returns products with the specific Product Guid. You can enter multiple product IDs separated by commas.',
|
||||
},
|
||||
{
|
||||
displayName: 'Warehouse Code',
|
||||
|
||||
@@ -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 {
|
||||
convertNETDates,
|
||||
@@ -15,15 +8,9 @@ import {
|
||||
unleashedApiRequestAllItems,
|
||||
} from './GenericFunctions';
|
||||
|
||||
import {
|
||||
salesOrderFields,
|
||||
salesOrderOperations,
|
||||
} from './SalesOrderDescription';
|
||||
import { salesOrderFields, salesOrderOperations } from './SalesOrderDescription';
|
||||
|
||||
import {
|
||||
stockOnHandFields,
|
||||
stockOnHandOperations,
|
||||
} from './StockOnHandDescription';
|
||||
import { stockOnHandFields, stockOnHandOperations } from './StockOnHandDescription';
|
||||
|
||||
import moment from 'moment';
|
||||
|
||||
@@ -75,7 +62,6 @@ export class UnleashedSoftware implements INodeType {
|
||||
};
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
|
||||
const items = this.getInputData();
|
||||
const returnData: IDataObject[] = [];
|
||||
const length = items.length;
|
||||
@@ -83,15 +69,12 @@ export class UnleashedSoftware implements INodeType {
|
||||
let responseData;
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
|
||||
const resource = this.getNodeParameter('resource', 0) as string;
|
||||
const operation = this.getNodeParameter('operation', 0) as string;
|
||||
|
||||
//https://apidocs.unleashedsoftware.com/SalesOrders
|
||||
if (resource === 'salesOrder') {
|
||||
|
||||
if (operation === 'getAll') {
|
||||
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
const filters = this.getNodeParameter('filters', i) as IDataObject;
|
||||
|
||||
@@ -114,7 +97,14 @@ export class UnleashedSoftware implements INodeType {
|
||||
Object.assign(qs, filters);
|
||||
|
||||
if (returnAll) {
|
||||
responseData = await unleashedApiRequestAllItems.call(this, 'Items', 'GET', '/SalesOrders', {}, qs);
|
||||
responseData = await unleashedApiRequestAllItems.call(
|
||||
this,
|
||||
'Items',
|
||||
'GET',
|
||||
'/SalesOrders',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i) as number;
|
||||
qs.pageSize = limit;
|
||||
@@ -128,7 +118,6 @@ export class UnleashedSoftware implements INodeType {
|
||||
|
||||
//https://apidocs.unleashedsoftware.com/StockOnHand
|
||||
if (resource === 'stockOnHand') {
|
||||
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
|
||||
@@ -149,7 +138,14 @@ export class UnleashedSoftware implements INodeType {
|
||||
Object.assign(qs, filters);
|
||||
|
||||
if (returnAll) {
|
||||
responseData = await unleashedApiRequestAllItems.call(this, 'Items', 'GET', '/StockOnHand', {}, qs);
|
||||
responseData = await unleashedApiRequestAllItems.call(
|
||||
this,
|
||||
'Items',
|
||||
'GET',
|
||||
'/StockOnHand',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i) as number;
|
||||
qs.pageSize = limit;
|
||||
|
||||
Reference in New Issue
Block a user