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,6 +1,4 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
import {
|
||||
IDataObject,
|
||||
ILoadOptionsFunctions,
|
||||
@@ -17,19 +15,9 @@ import {
|
||||
woocommerceApiRequest,
|
||||
woocommerceApiRequestAllItems,
|
||||
} from './GenericFunctions';
|
||||
import {
|
||||
productFields,
|
||||
productOperations,
|
||||
} from './ProductDescription';
|
||||
import {
|
||||
orderFields,
|
||||
orderOperations,
|
||||
} from './OrderDescription';
|
||||
import {
|
||||
IDimension,
|
||||
IImage,
|
||||
IProduct,
|
||||
} from './ProductInterface';
|
||||
import { productFields, productOperations } from './ProductDescription';
|
||||
import { orderFields, orderOperations } from './OrderDescription';
|
||||
import { IDimension, IImage, IProduct } from './ProductInterface';
|
||||
import {
|
||||
IAddress,
|
||||
ICouponLine,
|
||||
@@ -39,10 +27,7 @@ import {
|
||||
IShoppingLine,
|
||||
} from './OrderInterface';
|
||||
|
||||
import {
|
||||
customerFields,
|
||||
customerOperations,
|
||||
} from './descriptions';
|
||||
import { customerFields, customerOperations } from './descriptions';
|
||||
|
||||
export class WooCommerce implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -101,7 +86,12 @@ export class WooCommerce implements INodeType {
|
||||
// select them easily
|
||||
async getCategories(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const categories = await woocommerceApiRequestAllItems.call(this, 'GET', '/products/categories', {});
|
||||
const categories = await woocommerceApiRequestAllItems.call(
|
||||
this,
|
||||
'GET',
|
||||
'/products/categories',
|
||||
{},
|
||||
);
|
||||
for (const category of categories) {
|
||||
const categoryName = category.name;
|
||||
const categoryId = category.id;
|
||||
@@ -140,9 +130,7 @@ export class WooCommerce implements INodeType {
|
||||
const operation = this.getNodeParameter('operation', 0) as string;
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
|
||||
if (resource === 'customer') {
|
||||
|
||||
// **********************************************************************
|
||||
// customer
|
||||
// **********************************************************************
|
||||
@@ -150,7 +138,6 @@ export class WooCommerce implements INodeType {
|
||||
// https://woocommerce.github.io/woocommerce-rest-api-docs/?shell#customer-properties
|
||||
|
||||
if (operation === 'create') {
|
||||
|
||||
// ----------------------------------------
|
||||
// customer: create
|
||||
// ----------------------------------------
|
||||
@@ -168,9 +155,7 @@ export class WooCommerce implements INodeType {
|
||||
}
|
||||
|
||||
responseData = await woocommerceApiRequest.call(this, 'POST', '/customers', body);
|
||||
|
||||
} else if (operation === 'delete') {
|
||||
|
||||
// ----------------------------------------
|
||||
// customer: delete
|
||||
// ----------------------------------------
|
||||
@@ -185,9 +170,7 @@ export class WooCommerce implements INodeType {
|
||||
|
||||
const endpoint = `/customers/${customerId}`;
|
||||
responseData = await woocommerceApiRequest.call(this, 'DELETE', endpoint, {}, qs);
|
||||
|
||||
} else if (operation === 'get') {
|
||||
|
||||
// ----------------------------------------
|
||||
// customer: get
|
||||
// ----------------------------------------
|
||||
@@ -198,9 +181,7 @@ export class WooCommerce implements INodeType {
|
||||
|
||||
const endpoint = `/customers/${customerId}`;
|
||||
responseData = await woocommerceApiRequest.call(this, 'GET', endpoint);
|
||||
|
||||
} else if (operation === 'getAll') {
|
||||
|
||||
// ----------------------------------------
|
||||
// customer: getAll
|
||||
// ----------------------------------------
|
||||
@@ -216,14 +197,18 @@ export class WooCommerce implements INodeType {
|
||||
}
|
||||
|
||||
if (returnAll) {
|
||||
responseData = await woocommerceApiRequestAllItems.call(this, 'GET', '/customers', {}, qs);
|
||||
responseData = await woocommerceApiRequestAllItems.call(
|
||||
this,
|
||||
'GET',
|
||||
'/customers',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
qs.per_page = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await woocommerceApiRequest.call(this, 'GET', '/customers', {}, qs);
|
||||
}
|
||||
|
||||
} else if (operation === 'update') {
|
||||
|
||||
// ----------------------------------------
|
||||
// customer: update
|
||||
// ----------------------------------------
|
||||
@@ -241,9 +226,7 @@ export class WooCommerce implements INodeType {
|
||||
|
||||
const endpoint = `/customers/${customerId}`;
|
||||
responseData = await woocommerceApiRequest.call(this, 'PUT', endpoint, body);
|
||||
|
||||
}
|
||||
|
||||
} else if (resource === 'product') {
|
||||
//https://woocommerce.github.io/woocommerce-rest-api-docs/#create-a-product
|
||||
if (operation === 'create') {
|
||||
@@ -256,18 +239,23 @@ export class WooCommerce implements INodeType {
|
||||
setFields(additionalFields, body);
|
||||
|
||||
if (additionalFields.categories) {
|
||||
body.categories = (additionalFields.categories as string[]).map(category => ({ id: parseInt(category, 10) })) as unknown as IDataObject[];
|
||||
body.categories = (additionalFields.categories as string[]).map((category) => ({
|
||||
id: parseInt(category, 10),
|
||||
})) as unknown as IDataObject[];
|
||||
}
|
||||
|
||||
const images = (this.getNodeParameter('imagesUi', i) as IDataObject).imagesValues as IImage[];
|
||||
const images = (this.getNodeParameter('imagesUi', i) as IDataObject)
|
||||
.imagesValues as IImage[];
|
||||
if (images) {
|
||||
body.images = images;
|
||||
}
|
||||
const dimension = (this.getNodeParameter('dimensionsUi', i) as IDataObject).dimensionsValues as IDimension;
|
||||
const dimension = (this.getNodeParameter('dimensionsUi', i) as IDataObject)
|
||||
.dimensionsValues as IDimension;
|
||||
if (dimension) {
|
||||
body.dimensions = dimension;
|
||||
}
|
||||
const metadata = (this.getNodeParameter('metadataUi', i) as IDataObject).metadataValues as IDataObject[];
|
||||
const metadata = (this.getNodeParameter('metadataUi', i) as IDataObject)
|
||||
.metadataValues as IDataObject[];
|
||||
if (metadata) {
|
||||
body.meta_data = metadata;
|
||||
}
|
||||
@@ -281,24 +269,38 @@ export class WooCommerce implements INodeType {
|
||||
|
||||
setFields(updateFields, body);
|
||||
|
||||
const images = (this.getNodeParameter('imagesUi', i) as IDataObject).imagesValues as IImage[];
|
||||
const images = (this.getNodeParameter('imagesUi', i) as IDataObject)
|
||||
.imagesValues as IImage[];
|
||||
if (images) {
|
||||
body.images = images;
|
||||
}
|
||||
const dimension = (this.getNodeParameter('dimensionsUi', i) as IDataObject).dimensionsValues as IDimension;
|
||||
const dimension = (this.getNodeParameter('dimensionsUi', i) as IDataObject)
|
||||
.dimensionsValues as IDimension;
|
||||
if (dimension) {
|
||||
body.dimensions = dimension;
|
||||
}
|
||||
const metadata = (this.getNodeParameter('metadataUi', i) as IDataObject).metadataValues as IDataObject[];
|
||||
const metadata = (this.getNodeParameter('metadataUi', i) as IDataObject)
|
||||
.metadataValues as IDataObject[];
|
||||
if (metadata) {
|
||||
body.meta_data = metadata;
|
||||
}
|
||||
responseData = await woocommerceApiRequest.call(this, 'PUT', `/products/${productId}`, body);
|
||||
responseData = await woocommerceApiRequest.call(
|
||||
this,
|
||||
'PUT',
|
||||
`/products/${productId}`,
|
||||
body,
|
||||
);
|
||||
}
|
||||
//https://woocommerce.github.io/woocommerce-rest-api-docs/#retrieve-a-product
|
||||
if (operation === 'get') {
|
||||
const productId = this.getNodeParameter('productId', i) as string;
|
||||
responseData = await woocommerceApiRequest.call(this, 'GET', `/products/${productId}`, {}, qs);
|
||||
responseData = await woocommerceApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/products/${productId}`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
}
|
||||
//https://woocommerce.github.io/woocommerce-rest-api-docs/#list-all-products
|
||||
if (operation === 'getAll') {
|
||||
@@ -356,7 +358,13 @@ export class WooCommerce implements INodeType {
|
||||
qs.type = options.type as string;
|
||||
}
|
||||
if (returnAll === true) {
|
||||
responseData = await woocommerceApiRequestAllItems.call(this, 'GET', '/products', {}, qs);
|
||||
responseData = await woocommerceApiRequestAllItems.call(
|
||||
this,
|
||||
'GET',
|
||||
'/products',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
qs.per_page = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await woocommerceApiRequest.call(this, 'GET', '/products', {}, qs);
|
||||
@@ -365,7 +373,13 @@ export class WooCommerce implements INodeType {
|
||||
//https://woocommerce.github.io/woocommerce-rest-api-docs/#delete-a-product
|
||||
if (operation === 'delete') {
|
||||
const productId = this.getNodeParameter('productId', i) as string;
|
||||
responseData = await woocommerceApiRequest.call(this, 'DELETE', `/products/${productId}`, {}, { force: true });
|
||||
responseData = await woocommerceApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/products/${productId}`,
|
||||
{},
|
||||
{ force: true },
|
||||
);
|
||||
}
|
||||
}
|
||||
if (resource === 'order') {
|
||||
@@ -376,40 +390,47 @@ export class WooCommerce implements INodeType {
|
||||
|
||||
setFields(additionalFields, body);
|
||||
|
||||
const billing = (this.getNodeParameter('billingUi', i) as IDataObject).billingValues as IAddress;
|
||||
const billing = (this.getNodeParameter('billingUi', i) as IDataObject)
|
||||
.billingValues as IAddress;
|
||||
if (billing !== undefined) {
|
||||
body.billing = billing;
|
||||
toSnakeCase(billing as IDataObject);
|
||||
}
|
||||
const shipping = (this.getNodeParameter('shippingUi', i) as IDataObject).shippingValues as IAddress;
|
||||
const shipping = (this.getNodeParameter('shippingUi', i) as IDataObject)
|
||||
.shippingValues as IAddress;
|
||||
if (shipping !== undefined) {
|
||||
body.shipping = shipping;
|
||||
toSnakeCase(shipping as IDataObject);
|
||||
}
|
||||
const couponLines = (this.getNodeParameter('couponLinesUi', i) as IDataObject).couponLinesValues as ICouponLine[];
|
||||
const couponLines = (this.getNodeParameter('couponLinesUi', i) as IDataObject)
|
||||
.couponLinesValues as ICouponLine[];
|
||||
if (couponLines) {
|
||||
body.coupon_lines = couponLines;
|
||||
setMetadata(couponLines);
|
||||
toSnakeCase(couponLines);
|
||||
}
|
||||
const feeLines = (this.getNodeParameter('feeLinesUi', i) as IDataObject).feeLinesValues as IFeeLine[];
|
||||
const feeLines = (this.getNodeParameter('feeLinesUi', i) as IDataObject)
|
||||
.feeLinesValues as IFeeLine[];
|
||||
if (feeLines) {
|
||||
body.fee_lines = feeLines;
|
||||
setMetadata(feeLines);
|
||||
toSnakeCase(feeLines);
|
||||
}
|
||||
const lineItems = (this.getNodeParameter('lineItemsUi', i) as IDataObject).lineItemsValues as ILineItem[];
|
||||
const lineItems = (this.getNodeParameter('lineItemsUi', i) as IDataObject)
|
||||
.lineItemsValues as ILineItem[];
|
||||
if (lineItems) {
|
||||
body.line_items = lineItems;
|
||||
setMetadata(lineItems);
|
||||
toSnakeCase(lineItems);
|
||||
//@ts-ignore
|
||||
}
|
||||
const metadata = (this.getNodeParameter('metadataUi', i) as IDataObject).metadataValues as IDataObject[];
|
||||
const metadata = (this.getNodeParameter('metadataUi', i) as IDataObject)
|
||||
.metadataValues as IDataObject[];
|
||||
if (metadata) {
|
||||
body.meta_data = metadata;
|
||||
}
|
||||
const shippingLines = (this.getNodeParameter('shippingLinesUi', i) as IDataObject).shippingLinesValues as IShoppingLine[];
|
||||
const shippingLines = (this.getNodeParameter('shippingLinesUi', i) as IDataObject)
|
||||
.shippingLinesValues as IShoppingLine[];
|
||||
if (shippingLines) {
|
||||
body.shipping_lines = shippingLines;
|
||||
setMetadata(shippingLines);
|
||||
@@ -448,39 +469,46 @@ export class WooCommerce implements INodeType {
|
||||
if (updateFields.transactionID) {
|
||||
body.transaction_id = updateFields.transactionID as string;
|
||||
}
|
||||
const billing = (this.getNodeParameter('billingUi', i) as IDataObject).billingValues as IAddress;
|
||||
const billing = (this.getNodeParameter('billingUi', i) as IDataObject)
|
||||
.billingValues as IAddress;
|
||||
if (billing !== undefined) {
|
||||
body.billing = billing;
|
||||
toSnakeCase(billing as IDataObject);
|
||||
}
|
||||
const shipping = (this.getNodeParameter('shippingUi', i) as IDataObject).shippingValues as IAddress;
|
||||
const shipping = (this.getNodeParameter('shippingUi', i) as IDataObject)
|
||||
.shippingValues as IAddress;
|
||||
if (shipping !== undefined) {
|
||||
body.shipping = shipping;
|
||||
toSnakeCase(shipping as IDataObject);
|
||||
}
|
||||
const couponLines = (this.getNodeParameter('couponLinesUi', i) as IDataObject).couponLinesValues as ICouponLine[];
|
||||
const couponLines = (this.getNodeParameter('couponLinesUi', i) as IDataObject)
|
||||
.couponLinesValues as ICouponLine[];
|
||||
if (couponLines) {
|
||||
body.coupon_lines = couponLines;
|
||||
setMetadata(couponLines);
|
||||
toSnakeCase(couponLines);
|
||||
}
|
||||
const feeLines = (this.getNodeParameter('feeLinesUi', i) as IDataObject).feeLinesValues as IFeeLine[];
|
||||
const feeLines = (this.getNodeParameter('feeLinesUi', i) as IDataObject)
|
||||
.feeLinesValues as IFeeLine[];
|
||||
if (feeLines) {
|
||||
body.fee_lines = feeLines;
|
||||
setMetadata(feeLines);
|
||||
toSnakeCase(feeLines);
|
||||
}
|
||||
const lineItems = (this.getNodeParameter('lineItemsUi', i) as IDataObject).lineItemsValues as ILineItem[];
|
||||
const lineItems = (this.getNodeParameter('lineItemsUi', i) as IDataObject)
|
||||
.lineItemsValues as ILineItem[];
|
||||
if (lineItems) {
|
||||
body.line_items = lineItems;
|
||||
setMetadata(lineItems);
|
||||
toSnakeCase(lineItems);
|
||||
}
|
||||
const metadata = (this.getNodeParameter('metadataUi', i) as IDataObject).metadataValues as IDataObject[];
|
||||
const metadata = (this.getNodeParameter('metadataUi', i) as IDataObject)
|
||||
.metadataValues as IDataObject[];
|
||||
if (metadata) {
|
||||
body.meta_data = metadata;
|
||||
}
|
||||
const shippingLines = (this.getNodeParameter('shippingLinesUi', i) as IDataObject).shippingLinesValues as IShoppingLine[];
|
||||
const shippingLines = (this.getNodeParameter('shippingLinesUi', i) as IDataObject)
|
||||
.shippingLinesValues as IShoppingLine[];
|
||||
if (shippingLines) {
|
||||
body.shipping_lines = shippingLines;
|
||||
setMetadata(shippingLines);
|
||||
@@ -492,7 +520,13 @@ export class WooCommerce implements INodeType {
|
||||
//https://woocommerce.github.io/woocommerce-rest-api-docs/#retrieve-an-order
|
||||
if (operation === 'get') {
|
||||
const orderId = this.getNodeParameter('orderId', i) as string;
|
||||
responseData = await woocommerceApiRequest.call(this, 'GET', `/orders/${orderId}`, {}, qs);
|
||||
responseData = await woocommerceApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/orders/${orderId}`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
}
|
||||
//https://woocommerce.github.io/woocommerce-rest-api-docs/#list-all-orders
|
||||
if (operation === 'getAll') {
|
||||
@@ -538,7 +572,13 @@ export class WooCommerce implements INodeType {
|
||||
//https://woocommerce.github.io/woocommerce-rest-api-docs/#delete-an-order
|
||||
if (operation === 'delete') {
|
||||
const orderId = this.getNodeParameter('orderId', i) as string;
|
||||
responseData = await woocommerceApiRequest.call(this, 'DELETE', `/orders/${orderId}`, {}, { force: true });
|
||||
responseData = await woocommerceApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/orders/${orderId}`,
|
||||
{},
|
||||
{ force: true },
|
||||
);
|
||||
}
|
||||
}
|
||||
if (Array.isArray(responseData)) {
|
||||
|
||||
Reference in New Issue
Block a user