From ac5fd0108844fd5a9ff54dbab57226916bb465f6 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Mon, 13 Oct 2025 13:01:22 -0400 Subject: [PATCH 1/3] new actions --- .../create-purchase-order.mjs | 143 ++++++++ .../create-sales-order/create-sales-order.mjs | 141 ++++++++ .../create-stock-adjustment.mjs | 72 ++++ .../create-stock-transfer.mjs | 64 ++++ .../get-purchase-order/get-purchase-order.mjs | 32 ++ .../get-sales-order/get-sales-order.mjs | 31 ++ .../get-stock-on-hand/get-stock-on-hand.mjs | 34 ++ .../update-purchase-order.mjs | 94 +++++ .../update-sales-order/update-sales-order.mjs | 86 +++++ components/unleashed_software/package.json | 7 +- .../unleashed_software.app.mjs | 322 +++++++++++++++++- 11 files changed, 1020 insertions(+), 6 deletions(-) create mode 100644 components/unleashed_software/actions/create-purchase-order/create-purchase-order.mjs create mode 100644 components/unleashed_software/actions/create-sales-order/create-sales-order.mjs create mode 100644 components/unleashed_software/actions/create-stock-adjustment/create-stock-adjustment.mjs create mode 100644 components/unleashed_software/actions/create-stock-transfer/create-stock-transfer.mjs create mode 100644 components/unleashed_software/actions/get-purchase-order/get-purchase-order.mjs create mode 100644 components/unleashed_software/actions/get-sales-order/get-sales-order.mjs create mode 100644 components/unleashed_software/actions/get-stock-on-hand/get-stock-on-hand.mjs create mode 100644 components/unleashed_software/actions/update-purchase-order/update-purchase-order.mjs create mode 100644 components/unleashed_software/actions/update-sales-order/update-sales-order.mjs diff --git a/components/unleashed_software/actions/create-purchase-order/create-purchase-order.mjs b/components/unleashed_software/actions/create-purchase-order/create-purchase-order.mjs new file mode 100644 index 0000000000000..4f7f70c69f7cd --- /dev/null +++ b/components/unleashed_software/actions/create-purchase-order/create-purchase-order.mjs @@ -0,0 +1,143 @@ +import unleashedSoftware from "../../unleashed_software.app.mjs"; + +export default { + key: "unleashed_software-create-purchase-order", + name: "Create Purchase Order", + description: "Create a purchase order. [See the documentation](https://apidocs.unleashedsoftware.com/Purchases)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: false, + }, + props: { + unleashedSoftware, + orderStatus: { + propDefinition: [ + unleashedSoftware, + "purchaseOrderStatus", + ], + }, + supplierId: { + propDefinition: [ + unleashedSoftware, + "supplierId", + ], + }, + taxCode: { + propDefinition: [ + unleashedSoftware, + "taxCode", + ], + }, + warehouseId: { + propDefinition: [ + unleashedSoftware, + "warehouseId", + ], + optional: true, + }, + exchangeRate: { + propDefinition: [ + unleashedSoftware, + "exchangeRate", + ], + optional: true, + }, + comments: { + propDefinition: [ + unleashedSoftware, + "comments", + ], + }, + numLineItems: { + type: "integer", + label: "Number of Line Items", + description: "The number of line items to enter", + reloadProps: true, + }, + }, + async additionalProps() { + const props = {}; + if (!this.numLineItems) { + return props; + } + for (let i = 1; i <= this.numLineItems; i++) { + props[`line_${i}_productId`] = { + type: "string", + label: `Line Item ${i} - Product ID`, + options: async ({ page }) => { + const { Items: products } = await this.unleashedSoftware.listProducts({ + page: page + 1, + }); + return products?.map(({ + Guid: value, ProductDescription: label, + }) => ({ + value, + label, + })) || []; + }, + }; + props[`line_${i}_quantity`] = { + type: "string", + label: `Line Item ${i} - Quantity`, + }; + props[`line_${i}_unitPrice`] = { + type: "string", + label: `Line Item ${i} - Unit Price`, + }; + } + return props; + }, + async run({ $ }) { + const lineItems = []; + let subtotal = 0, taxTotal = 0; + const taxRate = await this.unleashedSoftware.getTaxRateFromCode({ + $, + taxCode: this.taxCode, + }); + + for (let i = 1; i <= this.numLineItems; i++) { + const lineTotal = +this[`line_${i}_unitPrice`] * +this[`line_${i}_quantity`]; + const lineTax = lineTotal * (taxRate / 100); + lineItems.push({ + Product: { + Guid: this[`line_${i}_productId`], + }, + OrderQuantity: +this[`line_${i}_quantity`], + UnitPrice: +this[`line_${i}_unitPrice`], + LineTotal: lineTotal, + LineTax: lineTax, + LineNumber: i, + }); + subtotal += lineTotal; + taxTotal += lineTax; + } + const response = await this.unleashedSoftware.createPurchaseOrder({ + $, + data: { + Supplier: { + Guid: this.supplierId, + }, + ExchangeRate: +this.exchangeRate, + OrderStatus: this.orderStatus, + Warehouse: { + Guid: this.warehouseId, + }, + Comments: this.comments, + Subtotal: subtotal, + Tax: { + TaxCode: this.taxCode, + }, + TaxRate: taxRate, + TaxTotal: taxTotal, + Total: subtotal + taxTotal, + PurchaseOrderLines: lineItems, + }, + }); + + $.export("$summary", "Successfully created purchase order"); + return response; + }, +}; diff --git a/components/unleashed_software/actions/create-sales-order/create-sales-order.mjs b/components/unleashed_software/actions/create-sales-order/create-sales-order.mjs new file mode 100644 index 0000000000000..8bf449f086d0f --- /dev/null +++ b/components/unleashed_software/actions/create-sales-order/create-sales-order.mjs @@ -0,0 +1,141 @@ +import unleashedSoftware from "../../unleashed_software.app.mjs"; + +export default { + key: "unleashed_software-create-sales-order", + name: "Create Sales Order", + description: "Creates a new sales order. [See the documentation](https://apidocs.unleashedsoftware.com/SalesOrders)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: false, + }, + props: { + unleashedSoftware, + customerId: { + propDefinition: [ + unleashedSoftware, + "customerId", + ], + }, + exchangeRate: { + propDefinition: [ + unleashedSoftware, + "exchangeRate", + ], + }, + orderStatus: { + propDefinition: [ + unleashedSoftware, + "salesOrderStatus", + ], + }, + warehouseId: { + propDefinition: [ + unleashedSoftware, + "warehouseId", + ], + }, + taxCode: { + propDefinition: [ + unleashedSoftware, + "taxCode", + ], + }, + comments: { + propDefinition: [ + unleashedSoftware, + "comments", + ], + }, + numLineItems: { + type: "integer", + label: "Number of Line Items", + description: "The number of line items to enter", + reloadProps: true, + }, + }, + async additionalProps() { + const props = {}; + if (!this.numLineItems) { + return props; + } + for (let i = 1; i <= this.numLineItems; i++) { + props[`line_${i}_productId`] = { + type: "string", + label: `Line Item ${i} - Product ID`, + options: async ({ page }) => { + const { Items: products } = await this.unleashedSoftware.listProducts({ + page: page + 1, + }); + return products?.map(({ + Guid: value, ProductDescription: label, + }) => ({ + value, + label, + })) || []; + }, + }; + props[`line_${i}_quantity`] = { + type: "string", + label: `Line Item ${i} - Quantity`, + }; + props[`line_${i}_unitPrice`] = { + type: "string", + label: `Line Item ${i} - Unit Price`, + }; + } + return props; + }, + async run({ $ }) { + const lineItems = []; + let subtotal = 0, taxTotal = 0; + const taxRate = await this.unleashedSoftware.getTaxRateFromCode({ + $, + taxCode: this.taxCode, + }); + + for (let i = 1; i <= this.numLineItems; i++) { + const lineTotal = +this[`line_${i}_unitPrice`] * +this[`line_${i}_quantity`]; + const lineTax = lineTotal * (taxRate / 100); + lineItems.push({ + Product: { + Guid: this[`line_${i}_productId`], + }, + OrderQuantity: +this[`line_${i}_quantity`], + UnitPrice: +this[`line_${i}_unitPrice`], + LineTotal: lineTotal, + LineTax: lineTax, + LineNumber: i, + }); + subtotal += lineTotal; + taxTotal += lineTax; + } + const response = await this.unleashedSoftware.createSalesOrder({ + $, + data: { + Customer: { + Guid: this.customerId, + }, + ExchangeRate: +this.exchangeRate, + OrderStatus: this.orderStatus, + Warehouse: { + Guid: this.warehouseId, + }, + Comments: this.comments, + Subtotal: subtotal, + Tax: { + TaxCode: this.taxCode, + }, + TaxRate: taxRate, + TaxTotal: taxTotal, + Total: subtotal + taxTotal, + SalesOrderLines: lineItems, + }, + }); + + $.export("$summary", "Successfully created sales order"); + return response; + }, +}; diff --git a/components/unleashed_software/actions/create-stock-adjustment/create-stock-adjustment.mjs b/components/unleashed_software/actions/create-stock-adjustment/create-stock-adjustment.mjs new file mode 100644 index 0000000000000..52e593505f973 --- /dev/null +++ b/components/unleashed_software/actions/create-stock-adjustment/create-stock-adjustment.mjs @@ -0,0 +1,72 @@ +import unleashedSoftware from "../../unleashed_software.app.mjs"; + +export default { + key: "unleashed_software-create-stock-adjustment", + name: "Create Stock Adjustment", + description: "Create a stock adjustment. [See the documentation](https://apidocs.unleashedsoftware.com/StockAdjustments)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: false, + }, + props: { + unleashedSoftware, + adjustmentReason: { + type: "string", + label: "Adjustment Reason", + description: "The reason for the stock adjustment", + options: [ + "End of Season", + "Samples", + "Stolen", + ], + }, + warehouseId: { + propDefinition: [ + unleashedSoftware, + "warehouseId", + ], + }, + productId: { + propDefinition: [ + unleashedSoftware, + "productId", + ], + }, + newQuantity: { + type: "string", + label: "New Quantity", + description: "The new quantity of the product", + }, + newActualValue: { + type: "string", + label: "New Actual Value", + description: "The new actual value of the product", + }, + }, + async run({ $ }) { + const response = await this.unleashedSoftware.createStockAdjustment({ + $, + data: { + AdjustmentReason: this.adjustmentReason, + Warehouse: { + Guid: this.warehouseId, + }, + StockAdjustmentLines: [ + { + Product: { + Guid: this.productId, + }, + NewQuantity: +this.newQuantity, + NewActualValue: +this.newActualValue, + }, + ], + }, + }); + + $.export("$summary", "Successfully created stock adjustment"); + return response; + }, +}; diff --git a/components/unleashed_software/actions/create-stock-transfer/create-stock-transfer.mjs b/components/unleashed_software/actions/create-stock-transfer/create-stock-transfer.mjs new file mode 100644 index 0000000000000..8df7ae448d398 --- /dev/null +++ b/components/unleashed_software/actions/create-stock-transfer/create-stock-transfer.mjs @@ -0,0 +1,64 @@ +import unleashedSoftware from "../../unleashed_software.app.mjs"; + +export default { + key: "unleashed_software-create-stock-transfer", + name: "Create Stock Transfer", + description: "Create a stock transfer. [See the documentation](https://apidocs.unleashedsoftware.com/WarehouseStockTransfers)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: false, + }, + props: { + unleashedSoftware, + sourceWarehouseId: { + propDefinition: [ + unleashedSoftware, + "warehouseId", + ], + }, + destinationWarehouseId: { + propDefinition: [ + unleashedSoftware, + "warehouseId", + ], + }, + productId: { + propDefinition: [ + unleashedSoftware, + "productId", + ], + }, + quantity: { + type: "string", + label: "Quantity", + description: "The quantity of the product to transfer", + }, + }, + async run({ $ }) { + const response = await this.unleashedSoftware.createStockTransfer({ + $, + data: { + SourceWarehouse: { + Guid: this.sourceWarehouseId, + }, + DestinationWarehouse: { + Guid: this.destinationWarehouseId, + }, + TransferDetails: [ + { + Product: { + Guid: this.productId, + }, + TransferQuantity: +this.quantity, + }, + ], + }, + }); + + $.export("$summary", "Successfully created stock transfer"); + return response; + }, +}; diff --git a/components/unleashed_software/actions/get-purchase-order/get-purchase-order.mjs b/components/unleashed_software/actions/get-purchase-order/get-purchase-order.mjs new file mode 100644 index 0000000000000..832a5c944aa1a --- /dev/null +++ b/components/unleashed_software/actions/get-purchase-order/get-purchase-order.mjs @@ -0,0 +1,32 @@ +import unleashedSoftware from "../../unleashed_software.app.mjs"; + +export default { + key: "unleashed_software-get-purchase-order", + name: "Get Purchase Order", + description: "Get a purchase order by ID. [See the documentation](https://apidocs.unleashedsoftware.com/Purchases)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + props: { + unleashedSoftware, + purchaseOrderId: { + propDefinition: [ + unleashedSoftware, + "purchaseOrderId", + ], + }, + }, + async run({ $ }) { + const response = await this.unleashedSoftware.getPurchaseOrder({ + $, + purchaseOrderId: this.purchaseOrderId, + }); + + $.export("$summary", `Successfully retrieved purchase order with ID ${this.purchaseOrderId}`); + return response; + }, +}; diff --git a/components/unleashed_software/actions/get-sales-order/get-sales-order.mjs b/components/unleashed_software/actions/get-sales-order/get-sales-order.mjs new file mode 100644 index 0000000000000..31c06034b176b --- /dev/null +++ b/components/unleashed_software/actions/get-sales-order/get-sales-order.mjs @@ -0,0 +1,31 @@ +import unleashedSoftware from "../../unleashed_software.app.mjs"; + +export default { + key: "unleashed_software-get-sales-order", + name: "Get Sales Order", + description: "Retrieves a sales order by ID. [See the documentation](https://apidocs.unleashedsoftware.com/SalesOrders)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + props: { + unleashedSoftware, + salesOrderId: { + propDefinition: [ + unleashedSoftware, + "salesOrderId", + ], + }, + }, + async run({ $ }) { + const response = await this.unleashedSoftware.getSalesOrder({ + $, + salesOrderId: this.salesOrderId, + }); + $.export("$summary", `Successfully retrieved sales order with ID ${this.salesOrderId}`); + return response; + }, +}; diff --git a/components/unleashed_software/actions/get-stock-on-hand/get-stock-on-hand.mjs b/components/unleashed_software/actions/get-stock-on-hand/get-stock-on-hand.mjs new file mode 100644 index 0000000000000..f36644a45334b --- /dev/null +++ b/components/unleashed_software/actions/get-stock-on-hand/get-stock-on-hand.mjs @@ -0,0 +1,34 @@ +import unleashedSoftware from "../../unleashed_software.app.mjs"; + +export default { + key: "unleashed_software-get-stock-on-hand", + name: "Get Stock On Hand", + description: "Get the stock on hand for a product. [See the documentation](https://apidocs.unleashedsoftware.com/StockOnHand)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + props: { + unleashedSoftware, + productId: { + propDefinition: [ + unleashedSoftware, + "productId", + ], + }, + }, + async run({ $ }) { + const response = await this.unleashedSoftware.getStockOnHand({ + $, + params: { + productId: this.productId, + }, + }); + + $.export("$summary", `Successfully retrieved stock on hand for product ${this.productId}`); + return response; + }, +}; diff --git a/components/unleashed_software/actions/update-purchase-order/update-purchase-order.mjs b/components/unleashed_software/actions/update-purchase-order/update-purchase-order.mjs new file mode 100644 index 0000000000000..38028c75d582c --- /dev/null +++ b/components/unleashed_software/actions/update-purchase-order/update-purchase-order.mjs @@ -0,0 +1,94 @@ +import unleashedSoftware from "../../unleashed_software.app.mjs"; + +export default { + key: "unleashed_software-update-purchase-order", + name: "Update Purchase Order", + description: "Update a purchase order. [See the documentation](https://apidocs.unleashedsoftware.com/Purchases)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: true, + openWorldHint: true, + readOnlyHint: false, + }, + props: { + unleashedSoftware, + purchaseOrderId: { + propDefinition: [ + unleashedSoftware, + "purchaseOrderId", + ], + }, + orderStatus: { + propDefinition: [ + unleashedSoftware, + "purchaseOrderStatus", + ], + options: [ + "Parked", + "Placed", + "Costed", + ], + optional: true, + }, + warehouseId: { + propDefinition: [ + unleashedSoftware, + "warehouseId", + ], + optional: true, + }, + exchangeRate: { + propDefinition: [ + unleashedSoftware, + "exchangeRate", + ], + optional: true, + }, + comments: { + propDefinition: [ + unleashedSoftware, + "comments", + ], + }, + }, + async run({ $ }) { + const purchaseOrder = await this.unleashedSoftware.getPurchaseOrder({ + $, + purchaseOrderId: this.purchaseOrderId, + }); + + const taxRate = await this.unleashedSoftware.getTaxRateFromCode({ + $, + taxCode: purchaseOrder.Tax.TaxCode, + }); + + const response = await this.unleashedSoftware.updatePurchaseOrder({ + $, + purchaseOrderId: this.purchaseOrderId, + data: { + Supplier: { + Guid: purchaseOrder.Supplier.Guid, + }, + ExchangeRate: this.exchangeRate + ? +this.exchangeRate + : purchaseOrder.ExchangeRate, + OrderStatus: this.orderStatus || purchaseOrder.OrderStatus, + Warehouse: { + Guid: this.warehouseId || purchaseOrder.Warehouse.Guid, + }, + Comments: this.comments, + SubTotal: purchaseOrder.SubTotal, + Tax: { + TaxCode: purchaseOrder.Tax.TaxCode, + }, + TaxRate: taxRate, + TaxTotal: purchaseOrder.TaxTotal, + Total: purchaseOrder.Total, + }, + }); + + $.export("$summary", "Successfully updated purchase order"); + return response; + }, +}; diff --git a/components/unleashed_software/actions/update-sales-order/update-sales-order.mjs b/components/unleashed_software/actions/update-sales-order/update-sales-order.mjs new file mode 100644 index 0000000000000..7f3e6f6d87d2e --- /dev/null +++ b/components/unleashed_software/actions/update-sales-order/update-sales-order.mjs @@ -0,0 +1,86 @@ +import unleashedSoftware from "../../unleashed_software.app.mjs"; + +export default { + key: "unleashed_software-update-sales-order", + name: "Update Sales Order", + description: "Updates an existing sales order. [See the documentation](https://apidocs.unleashedsoftware.com/SalesOrders)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: true, + openWorldHint: true, + readOnlyHint: false, + }, + props: { + unleashedSoftware, + salesOrderId: { + propDefinition: [ + unleashedSoftware, + "salesOrderId", + ], + }, + exchangeRate: { + propDefinition: [ + unleashedSoftware, + "exchangeRate", + ], + optional: true, + }, + orderStatus: { + propDefinition: [ + unleashedSoftware, + "salesOrderStatus", + ], + optional: true, + }, + warehouseId: { + propDefinition: [ + unleashedSoftware, + "warehouseId", + ], + optional: true, + }, + comments: { + propDefinition: [ + unleashedSoftware, + "comments", + ], + }, + }, + async run({ $ }) { + const salesOrder = await this.unleashedSoftware.getSalesOrder({ + $, + salesOrderId: this.salesOrderId, + }); + + const taxRate = await this.unleashedSoftware.getTaxRateFromCode({ + $, + taxCode: salesOrder.Tax.TaxCode, + }); + + const response = await this.unleashedSoftware.updateSalesOrder({ + $, + salesOrderId: this.salesOrderId, + data: { + ExchangeRate: this.exchangeRate + ? +this.exchangeRate + : salesOrder.ExchangeRate, + OrderStatus: this.orderStatus || salesOrder.OrderStatus, + Warehouse: { + Guid: this.warehouseId || salesOrder.Warehouse.Guid, + }, + Comments: this.comments, + SubTotal: salesOrder.SubTotal, + Tax: { + TaxCode: salesOrder.Tax.TaxCode, + }, + TaxRate: taxRate, + TaxTotal: salesOrder.TaxTotal, + Total: salesOrder.Total, + }, + }); + + $.export("$summary", "Successfully updated sales order"); + return response; + }, +}; diff --git a/components/unleashed_software/package.json b/components/unleashed_software/package.json index 0c7517c75f29b..ab86790a8be6c 100644 --- a/components/unleashed_software/package.json +++ b/components/unleashed_software/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/unleashed_software", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Unleashed Software Components", "main": "unleashed_software.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.1.0" } -} \ No newline at end of file +} diff --git a/components/unleashed_software/unleashed_software.app.mjs b/components/unleashed_software/unleashed_software.app.mjs index 60b4ed69a6cd2..54bac518d3e99 100644 --- a/components/unleashed_software/unleashed_software.app.mjs +++ b/components/unleashed_software/unleashed_software.app.mjs @@ -1,11 +1,325 @@ +import { axios } from "@pipedream/platform"; +import crypto from "crypto"; + export default { type: "app", app: "unleashed_software", - propDefinitions: {}, + propDefinitions: { + salesOrderId: { + type: "string", + label: "Sales Order ID", + description: "The ID of a sales order", + async options({ page }) { + const { Items: salesOrders } = await this.listSalesOrders({ + page: page + 1, + }); + return salesOrders?.map(({ + Guid: value, OrderNumber: number, + }) => ({ + value, + label: `Sales Order # ${number}`, + })) || []; + }, + }, + purchaseOrderId: { + type: "string", + label: "Purchase Order ID", + description: "The ID of a purchase order", + async options({ page }) { + const { Items: purchaseOrders } = await this.listPurchaseOrders({ + page: page + 1, + }); + return purchaseOrders?.map(({ + Guid: value, OrderNumber: number, + }) => ({ + value, + label: `Purchase Order # ${number}`, + })) || []; + }, + }, + customerId: { + type: "string", + label: "Customer ID", + description: "The ID of a customer", + async options({ page }) { + const { Items: customers } = await this.listCustomers({ + page: page + 1, + }); + return customers?.map(({ + Guid: value, CustomerName: label, + }) => ({ + value, + label, + })) || []; + }, + }, + warehouseId: { + type: "string", + label: "Warehouse ID", + description: "The ID of a warehouse", + async options({ page }) { + const { Items: warehouses } = await this.listWarehouses({ + page: page + 1, + }); + return warehouses?.map(({ + Guid: value, WarehouseName: label, + }) => ({ + value, + label, + })) || []; + }, + }, + productId: { + type: "string", + label: "Product ID", + description: "The ID of a product", + async options({ page }) { + const { Items: products } = await this.listProducts({ + page: page + 1, + }); + return products?.map(({ + Guid: value, ProductDescription: label, + }) => ({ + value, + label, + })) || []; + }, + }, + taxCode: { + type: "string", + label: "Tax Code", + description: "The tax code to use for the order", + async options({ page }) { + const { Items: taxes } = await this.listTaxes({ + page: page + 1, + }); + return taxes?.map(({ + TaxCode: value, Description: label, + }) => ({ + value, + label, + })) || []; + }, + }, + supplierId: { + type: "string", + label: "Supplier ID", + description: "The ID of a supplier", + async options({ page }) { + const { Items: suppliers } = await this.listSuppliers({ + page: page + 1, + }); + return suppliers?.map(({ + Guid: value, SupplierName: label, + }) => ({ + value, + label, + })) || []; + }, + }, + exchangeRate: { + type: "string", + label: "Exchange Rate", + description: "The exchange rate to use for the order", + }, + salesOrderStatus: { + type: "string", + label: "Order Status", + description: "The status of the sales order", + options: [ + "Parked", + "Placed", + "Backordered", + "Completed", + ], + }, + purchaseOrderStatus: { + type: "string", + label: "Order Status", + description: "The status of the purchase order", + options: [ + "Parked", + "Placed", + "Complete", + ], + }, + comments: { + type: "string", + label: "Comments", + description: "The comments to add to the sales order", + optional: true, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://api.unleashedsoftware.com"; + }, + _signature(queryString) { + return crypto + .createHmac("sha256", this.$auth.api_key) + .update(queryString) + .digest("base64"); + }, + _buildQueryString(params) { + const queryString = new URLSearchParams(); + for (const [ + key, + value, + ] of Object.entries(params)) { + queryString.append(key, value); + } + return queryString.toString(); + }, + _makeRequest({ + $ = this, path, params = {}, ...opts + }) { + const queryString = this._buildQueryString(params); + return axios($, { + url: `${this._baseUrl()}/${path}${queryString + ? `?${queryString}` + : ""}`, + headers: { + "api-auth-id": this.$auth.api_id, + "api-auth-signature": this._signature(queryString), + "Accept": "application/json", + "Content-Type": "application/json; charset=utf-8", + }, + ...opts, + }); + }, + async getTaxRateFromCode({ + taxCode, ...opts + }) { + const { Items: taxes } = await this.listTaxes({ + ...opts, + }); + return taxes?.find(({ TaxCode: code }) => code === taxCode)?.TaxRate; + }, + getSalesOrder({ + salesOrderId, ...opts + }) { + return this._makeRequest({ + path: `SalesOrders/${salesOrderId}`, + ...opts, + }); + }, + getPurchaseOrder({ + purchaseOrderId, ...opts + }) { + return this._makeRequest({ + path: `PurchaseOrders/${purchaseOrderId}`, + ...opts, + }); + }, + listSalesOrders({ + page = 1, ...opts + }) { + return this._makeRequest({ + path: `SalesOrders/${page}`, + ...opts, + }); + }, + listPurchaseOrders({ + page = 1, ...opts + }) { + return this._makeRequest({ + path: `PurchaseOrders/${page}`, + ...opts, + }); + }, + listCustomers({ + page = 1, ...opts + }) { + return this._makeRequest({ + path: `Customers/${page}`, + ...opts, + }); + }, + listProducts({ + page = 1, ...opts + }) { + return this._makeRequest({ + path: `Products/${page}`, + ...opts, + }); + }, + listWarehouses({ + page = 1, ...opts + }) { + return this._makeRequest({ + path: `Warehouses/${page}`, + ...opts, + }); + }, + listTaxes({ + page = 1, ...opts + }) { + return this._makeRequest({ + path: `Taxes/${page}`, + ...opts, + }); + }, + listSuppliers({ + page = 1, ...opts + }) { + return this._makeRequest({ + path: `Suppliers/${page}`, + ...opts, + }); + }, + getStockOnHand({ + page = 1, ...opts + }) { + return this._makeRequest({ + path: `StockOnHand/${page}`, + ...opts, + }); + }, + createSalesOrder(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "SalesOrders", + ...opts, + }); + }, + createPurchaseOrder(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "PurchaseOrders", + ...opts, + }); + }, + createStockAdjustment(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "StockAdjustments", + ...opts, + }); + }, + createStockTransfer(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "WarehouseStockTransfers", + ...opts, + }); + }, + updateSalesOrder({ + salesOrderId, ...opts + }) { + return this._makeRequest({ + method: "PUT", + path: `SalesOrders/${salesOrderId}`, + ...opts, + }); + }, + updatePurchaseOrder({ + purchaseOrderId, ...opts + }) { + return this._makeRequest({ + method: "PUT", + path: `PurchaseOrders/${purchaseOrderId}`, + ...opts, + }); }, }, }; From cab1589ba1a5b83ecad26551e538b82b5682567c Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Mon, 13 Oct 2025 13:02:00 -0400 Subject: [PATCH 2/3] pnpm-lock.yaml --- pnpm-lock.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 21f4c92766485..2befda802dd40 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15129,7 +15129,11 @@ importers: specifier: ^3.0.3 version: 3.1.0 - components/unleashed_software: {} + components/unleashed_software: + dependencies: + '@pipedream/platform': + specifier: ^3.1.0 + version: 3.1.0 components/unsplash: dependencies: From 91589674978069ef7adbd2e269942180698daf74 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Mon, 13 Oct 2025 13:07:11 -0400 Subject: [PATCH 3/3] pnpm-lock.yaml --- pnpm-lock.yaml | 105 ++++--------------------------------------------- 1 file changed, 7 insertions(+), 98 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d6e1499ac2aee..4eec3d9ea854b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2044,8 +2044,7 @@ importers: specifier: ^3.0.3 version: 3.0.3 - components/browserflow: - specifiers: {} + components/browserflow: {} components/browserhub: dependencies: @@ -2138,8 +2137,7 @@ importers: specifier: ^1.3.0 version: 1.6.6 - components/bump_sh: - specifiers: {} + components/bump_sh: {} components/bunnycdn: dependencies: @@ -2498,8 +2496,7 @@ importers: specifier: ^3.0.3 version: 3.0.3 - components/chatbase: - specifiers: {} + components/chatbase: {} components/chatbot: dependencies: @@ -4872,8 +4869,7 @@ importers: components/fastfield_mobile_forms: {} - components/fathom: - specifiers: {} + components/fathom: {} components/fatture_in_cloud: {} @@ -5862,8 +5858,7 @@ importers: specifier: ^3.0.3 version: 3.0.3 - components/google_books: - specifiers: {} + components/google_books: {} components/google_calendar: dependencies: @@ -8820,8 +8815,7 @@ importers: specifier: ^3.0.3 version: 3.0.3 - components/microsoft_bookings: - specifiers: {} + components/microsoft_bookings: {} components/microsoft_dataverse: {} @@ -8863,8 +8857,7 @@ importers: components/microsoft_graph_api_daemon_app: {} - components/microsoft_graph_security: - specifiers: {} + components/microsoft_graph_security: {} components/microsoft_onedrive: dependencies: @@ -9271,9 +9264,6 @@ importers: mysql2: specifier: ^3.9.2 version: 3.11.4 - mysql2-promise: - specifier: ^0.1.4 - version: 0.1.4 uuid: specifier: ^8.3.2 version: 8.3.2 @@ -23313,9 +23303,6 @@ packages: engines: {node: '>=8.0.0'} hasBin: true - ansicolors@0.2.1: - resolution: {integrity: sha512-tOIuy1/SK/dr94ZA0ckDohKXNeBNqZ4us6PjMVLs5h1w2GBB6uPtOknp2+VF4F/zcy9LI70W+Z+pE2Soajky1w==} - ansicolors@0.3.2: resolution: {integrity: sha512-QXu7BPrP29VllRxH8GwB7x5iX5qWKAAMLqKQGWTeLWVlNHNOpVMJ91dsxQAIWXpjuW5wqvxu3Jd/nRjrJ+0pqg==} @@ -23758,9 +23745,6 @@ packages: bluebird@3.7.2: resolution: {integrity: sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==} - bn.js@2.0.0: - resolution: {integrity: sha512-NmOLApC80+n+P28y06yHgwGlOCkq/X4jRh5s590959FZXSrM+I/61h0xxuIaYsg0mD44mEAZYG/rnclWuRoz+A==} - bn.js@4.12.1: resolution: {integrity: sha512-k8TVBiPkPJT9uHLdOKfFpqcfprwBFOAAXXozRubr7R7PfIuKvQlzcI4M0pALeqXN09vdaMbUdUj+pass+uULAg==} @@ -23988,10 +23972,6 @@ packages: caniuse-lite@1.0.30001683: resolution: {integrity: sha512-iqmNnThZ0n70mNwvxpEC2nBJ037ZHZUoBI5Gorh1Mw6IlEAZujEoU1tXA628iZfzm7R9FvFzxbfdgml82a3k8Q==} - cardinal@0.4.4: - resolution: {integrity: sha512-3MxV0o9wOpQcobrcSrRpaSxlYkohCcZu0ytOjJUww/Yo/223q4Ecloo7odT+M0SI5kPgb1JhvSaF4EEuVXOLAQ==} - hasBin: true - cardinal@2.1.1: resolution: {integrity: sha512-JSr5eOgoEymtYHBjNWyjrMqet9Am2miJhlfKNdqLp6zoeAh0KN5dRAcxlecj5mAJrmQomgiOBj35xHLrFjqBpw==} hasBin: true @@ -25053,9 +25033,6 @@ packages: resolution: {integrity: sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g==} engines: {node: '>=10'} - double-ended-queue@2.0.0-0: - resolution: {integrity: sha512-t5ouWOpItmHrm0J0+bX/cFrIjBFWnJkk5LbIJq6bbU/M4aLX2c3LrM4QYsBptwvlPe3WzdpQefQ0v1pe/A5wjg==} - dropbox@10.34.0: resolution: {integrity: sha512-5jb5/XzU0fSnq36/hEpwT5/QIep7MgqKuxghEG44xCu7HruOAjPdOb3x0geXv5O/hd0nHpQpWO+r5MjYTpMvJg==} engines: {node: '>=0.10.3'} @@ -25530,11 +25507,6 @@ packages: resolution: {integrity: sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - esprima@1.0.4: - resolution: {integrity: sha512-rp5dMKN8zEs9dfi9g0X1ClLmV//WRyk/R15mppFNICIFRG5P92VP7Z04p8pk++gABo9W2tY+kHyu6P1mEHgmTA==} - engines: {node: '>=0.4.0'} - hasBin: true - esprima@1.2.2: resolution: {integrity: sha512-+JpPZam9w5DuJ3Q67SqsMGtiHKENSMRVoxvArfJZK01/BfLEObtZ6orJa/MtoGNR/rfMgp5837T41PAmTwAv/A==} engines: {node: '>=0.4.0'} @@ -28259,9 +28231,6 @@ packages: resolution: {integrity: sha512-123qHRfJBmo2jXDbo/a5YOQrJoHF/GNQTLzQ5+IdK5pWpceK17yRc6ozlWd25FxvGKQbIUs91fDFkXmDHTKcyA==} engines: {node: 20 || >=22} - lru-cache@2.5.0: - resolution: {integrity: sha512-dVmQmXPBlTgFw77hm60ud//l2bCuDKkqC2on1EBoM7s9Urm9IQDrnujwZ93NFnAq0dVZ0HBXTS7PwEG+YE7+EQ==} - lru-cache@5.1.1: resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} @@ -28840,14 +28809,6 @@ packages: resolution: {integrity: sha512-at/ZndSy3xEGJ8i0ygALh8ru9qy7gWW1cmkaqBN29JmMlIvM//MEO9y1sk/avxuwnPcfhkejkLsuPxH81BrkSg==} engines: {node: '>=0.8.0'} - mysql2-promise@0.1.4: - resolution: {integrity: sha512-/h8ubU/36aIPpbfB6CENw9ZdbzIhZMZOIbstJUHVKp4J9JBRSLScrYImVx+3yZilgag732UhpQMMK5+ktdhLCw==} - engines: {node: '>=0.10.0'} - - mysql2@0.15.8: - resolution: {integrity: sha512-3x5o6C20bfwJYPSoT74MOoad7/chJoq4qXHDL5VAuRBBrIyErovLoj04Dz/5EY9X2kTxWSGNiTegtxpROTd2YQ==} - engines: {node: '>= 0.8'} - mysql2@3.11.4: resolution: {integrity: sha512-Z2o3tY4Z8EvSRDwknaC40MdZ3+m0sKbpnXrShQLdxPrAvcNli7jLrD2Zd2IzsRMw4eK9Yle500FDmlkIqp+krg==} engines: {node: '>= 8.0'} @@ -28855,9 +28816,6 @@ packages: mz@2.7.0: resolution: {integrity: sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==} - named-placeholders@0.1.3: - resolution: {integrity: sha512-Mt79RtxZ6MYTIEemPGv/YDKpbuavcAyGHb0r37xB2mnE5jej3uBzc4+nzOeoZ4nZiii1M32URKt9IjkSTZAmTA==} - named-placeholders@1.1.3: resolution: {integrity: sha512-eLoBxg6wE/rZkJPhU/xRX1WTpkFEwDJEN96oxFrTsqBdbT5ec295Q+CoHrL9IT0DipqKhmGcaZmwOt8OON5x1w==} engines: {node: '>=12.0.0'} @@ -30239,9 +30197,6 @@ packages: resolution: {integrity: sha512-9viLL4/n1BJUCT1NXVTdS1jtm80yDEgR5T4yCelII49Mbj0v1rZdKqj7zCiYdbB0CuCgdrvHcNogAKTFPBocFA==} engines: {node: '>=18'} - readable-stream@1.0.33: - resolution: {integrity: sha512-72KxhcKi8bAvHP/cyyWSP+ODS5ef0DIRs0OzrhGXw31q41f19aoELCbvd42FjhpyEDxQMRiiC5rq9rfE5PzTqg==} - readable-stream@1.1.14: resolution: {integrity: sha512-+MeVjFf4L44XUkhM1eYbD8fyEsxcV81pqMSR5gblfcLCHfZvbrqy4/qYHE+/R5HoBUT11WV5O08Cr1n3YXkWVQ==} @@ -30282,9 +30237,6 @@ packages: recurly@3.30.0: resolution: {integrity: sha512-SVW5pke3MLe+QkIx3Y+NJD8UfR30eBrM90Vkrv6o3FvDPZBvSNpSadTay1SzLo+SmM31rBSeqELyX4zBDTd/Nw==} - redeyed@0.4.4: - resolution: {integrity: sha512-pnk1vsaNLu1UAAClKsImKz9HjBvg9i8cbRqTRzJbiCjGF0fZSMqpdcA5W3juO3c4etFvTrabECkq9wjC45ZyxA==} - redeyed@2.1.1: resolution: {integrity: sha512-FNpGGo1DycYAdnrKFxCMmKYgo/mILAqtRYbkdQD8Ep/Hk2PQ5+aEAEx+IU713RTDmuBaH0c8P5ZozurNu5ObRQ==} @@ -42838,8 +42790,6 @@ snapshots: dependencies: entities: 2.2.0 - ansicolors@0.2.1: {} - ansicolors@0.3.2: {} ansis@4.1.0: {} @@ -43479,8 +43429,6 @@ snapshots: bluebird@3.7.2: {} - bn.js@2.0.0: {} - bn.js@4.12.1: {} bn.js@5.2.1: {} @@ -43752,11 +43700,6 @@ snapshots: caniuse-lite@1.0.30001683: {} - cardinal@0.4.4: - dependencies: - ansicolors: 0.2.1 - redeyed: 0.4.4 - cardinal@2.1.1: dependencies: ansicolors: 0.3.2 @@ -44850,8 +44793,6 @@ snapshots: dotenv@8.6.0: {} - double-ended-queue@2.0.0-0: {} - dropbox@10.34.0(@types/node-fetch@2.6.12): dependencies: '@types/node-fetch': 2.6.12 @@ -45634,8 +45575,6 @@ snapshots: acorn-jsx: 5.3.2(acorn@8.14.0) eslint-visitor-keys: 3.4.3 - esprima@1.0.4: {} - esprima@1.2.2: {} esprima@4.0.1: {} @@ -49246,8 +49185,6 @@ snapshots: lru-cache@11.0.2: {} - lru-cache@2.5.0: {} - lru-cache@5.1.1: dependencies: yallist: 3.1.1 @@ -50056,19 +49993,6 @@ snapshots: rimraf: 2.4.5 optional: true - mysql2-promise@0.1.4: - dependencies: - mysql2: 0.15.8 - q: 1.5.1 - - mysql2@0.15.8: - dependencies: - bn.js: 2.0.0 - cardinal: 0.4.4 - double-ended-queue: 2.0.0-0 - named-placeholders: 0.1.3 - readable-stream: 1.0.33 - mysql2@3.11.4: dependencies: aws-ssl-profiles: 1.1.2 @@ -50087,10 +50011,6 @@ snapshots: object-assign: 4.1.1 thenify-all: 1.6.0 - named-placeholders@0.1.3: - dependencies: - lru-cache: 2.5.0 - named-placeholders@1.1.3: dependencies: lru-cache: 7.18.3 @@ -51991,13 +51911,6 @@ snapshots: type-fest: 4.41.0 unicorn-magic: 0.1.0 - readable-stream@1.0.33: - dependencies: - core-util-is: 1.0.3 - inherits: 2.0.4 - isarray: 0.0.1 - string_decoder: 0.10.31 - readable-stream@1.1.14: dependencies: core-util-is: 1.0.3 @@ -52055,10 +51968,6 @@ snapshots: recurly@3.30.0: {} - redeyed@0.4.4: - dependencies: - esprima: 1.0.4 - redeyed@2.1.1: dependencies: esprima: 4.0.1