From bb85311b99f1ec2d35a0685a25beb54275cfaa95 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Mon, 7 Oct 2024 11:47:18 -0300 Subject: [PATCH 1/4] allocadence init --- .../create-customer-order.mjs | 51 +++++++ .../create-purchase-order.mjs | 54 +++++++ components/allocadence/allocadence.app.mjs | 140 +++++++++++++++++- components/allocadence/package.json | 2 +- .../new-customer-order/new-customer-order.mjs | 113 ++++++++++++++ .../new-purchase-order/new-purchase-order.mjs | 105 +++++++++++++ 6 files changed, 461 insertions(+), 4 deletions(-) create mode 100644 components/allocadence/actions/create-customer-order/create-customer-order.mjs create mode 100644 components/allocadence/actions/create-purchase-order/create-purchase-order.mjs create mode 100644 components/allocadence/sources/new-customer-order/new-customer-order.mjs create mode 100644 components/allocadence/sources/new-purchase-order/new-purchase-order.mjs diff --git a/components/allocadence/actions/create-customer-order/create-customer-order.mjs b/components/allocadence/actions/create-customer-order/create-customer-order.mjs new file mode 100644 index 0000000000000..f97a65ea4a1e4 --- /dev/null +++ b/components/allocadence/actions/create-customer-order/create-customer-order.mjs @@ -0,0 +1,51 @@ +import allocadence from "../../allocadence.app.mjs"; +import { axios } from "@pipedream/platform"; + +export default { + key: "allocadence-create-customer-order", + name: "Create Customer Order", + description: "Creates a new customer order. [See the documentation](https://docs.allocadence.com/)", + version: "0.0.1", + type: "action", + props: { + allocadence, + customerInformation: { + propDefinition: [ + allocadence, + "customerInformation", + ], + }, + productDetails: { + propDefinition: [ + allocadence, + "productDetails", + ], + }, + shippingAddress: { + propDefinition: [ + allocadence, + "shippingAddress", + ], + }, + specialInstructions: { + propDefinition: [ + allocadence, + "specialInstructions", + { + optional: true, + }, + ], + }, + }, + async run({ $ }) { + const response = await this.allocadence.createCustomerOrder({ + customerInformation: this.customerInformation, + productDetails: this.productDetails, + shippingAddress: this.shippingAddress, + specialInstructions: this.specialInstructions, + }); + + $.export("$summary", `Successfully created customer order with ID ${response.id}`); + return response; + }, +}; diff --git a/components/allocadence/actions/create-purchase-order/create-purchase-order.mjs b/components/allocadence/actions/create-purchase-order/create-purchase-order.mjs new file mode 100644 index 0000000000000..964921508ffcd --- /dev/null +++ b/components/allocadence/actions/create-purchase-order/create-purchase-order.mjs @@ -0,0 +1,54 @@ +import allocadence from "../../allocadence.app.mjs"; + +export default { + key: "allocadence-create-purchase-order", + name: "Create Purchase Order", + description: "Generates a new purchase order. [See the documentation](https://docs.allocadence.com/)", + version: "0.0.{{ts}}", + type: "action", + props: { + allocadence, + supplierDetails: { + propDefinition: [ + allocadence, + "supplierDetails", + ], + }, + productDetails: { + propDefinition: [ + allocadence, + "productDetails", + ], + }, + deliveryAddress: { + propDefinition: [ + allocadence, + "deliveryAddress", + ], + }, + orderDeadline: { + propDefinition: [ + allocadence, + "orderDeadline", + ], + }, + additionalInstructions: { + propDefinition: [ + allocadence, + "additionalInstructions", + ], + }, + }, + async run({ $ }) { + const response = await this.allocadence.createPurchaseOrder({ + supplierDetails: this.supplierDetails, + productDetails: this.productDetails, + deliveryAddress: this.deliveryAddress, + orderDeadline: this.orderDeadline, + additionalInstructions: this.additionalInstructions, + }); + + $.export("$summary", `Successfully created purchase order with ID ${response.id}`); + return response; + }, +}; diff --git a/components/allocadence/allocadence.app.mjs b/components/allocadence/allocadence.app.mjs index 7a39d8ca1140b..ce34e0de80df0 100644 --- a/components/allocadence/allocadence.app.mjs +++ b/components/allocadence/allocadence.app.mjs @@ -1,11 +1,145 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "allocadence", - propDefinitions: {}, + propDefinitions: { + customerId: { + type: "string", + label: "Customer ID", + description: "The ID of the customer who placed the order", + }, + productId: { + type: "string", + label: "Product ID", + description: "The ID of the product", + }, + orderDetails: { + type: "string", + label: "Order Details", + description: "Optional details about the customer order", + optional: true, + }, + deliveryMode: { + type: "string", + label: "Delivery Mode", + description: "Optional delivery mode for the order", + optional: true, + }, + supplierId: { + type: "string", + label: "Supplier ID", + description: "The ID of the supplier for purchase orders", + }, + quantity: { + type: "integer", + label: "Quantity", + description: "Optional quantity for the purchase order", + optional: true, + }, + deliveryDate: { + type: "string", + label: "Delivery Date", + description: "Optional delivery date for the purchase order", + optional: true, + }, + customerInformation: { + type: "string", + label: "Customer Information", + description: "Information about the customer", + }, + productDetails: { + type: "string", + label: "Product Details", + description: "Details about the product", + }, + shippingAddress: { + type: "string", + label: "Shipping Address", + description: "Address where the order will be shipped to", + }, + specialInstructions: { + type: "string", + label: "Special Instructions", + description: "Optional special instructions for the order", + optional: true, + }, + supplierDetails: { + type: "string", + label: "Supplier Details", + description: "Details about the supplier", + }, + deliveryAddress: { + type: "string", + label: "Delivery Address", + description: "The address where the purchase order will be delivered", + }, + orderDeadline: { + type: "string", + label: "Order Deadline", + description: "Optional deadline for the order", + optional: true, + }, + additionalInstructions: { + type: "string", + label: "Additional Instructions", + description: "Optional additional instructions for the purchase order", + optional: true, + }, + }, methods: { - // this.$auth contains connected account data + _baseUrl() { + return "https://api.allocadence.com"; + }, + async _makeRequest(opts = {}) { + const { + $ = this, method = "GET", path = "/", headers, ...otherOpts + } = opts; + return axios($, { + ...otherOpts, + method, + url: this._baseUrl() + path, + headers: { + ...headers, + Authorization: `Bearer ${this.$auth.api_token}`, + }, + }); + }, + async createCustomerOrder(opts = {}) { + const { + customerInformation, productDetails, shippingAddress, specialInstructions, ...extraOpts + } = opts; + return this._makeRequest({ + method: "POST", + path: "/customer-orders", + data: { + customerInformation, + productDetails, + shippingAddress, + specialInstructions, + ...extraOpts, + }, + }); + }, + async createPurchaseOrder(opts = {}) { + const { + supplierDetails, productDetails, deliveryAddress, orderDeadline, additionalInstructions, ...extraOpts + } = opts; + return this._makeRequest({ + method: "POST", + path: "/purchase-orders", + data: { + supplierDetails, + productDetails, + deliveryAddress, + orderDeadline, + additionalInstructions, + ...extraOpts, + }, + }); + }, authKeys() { console.log(Object.keys(this.$auth)); }, }, -}; \ No newline at end of file +}; diff --git a/components/allocadence/package.json b/components/allocadence/package.json index 89b605353c8c4..08a195ea5ac12 100644 --- a/components/allocadence/package.json +++ b/components/allocadence/package.json @@ -12,4 +12,4 @@ "publishConfig": { "access": "public" } -} \ No newline at end of file +} diff --git a/components/allocadence/sources/new-customer-order/new-customer-order.mjs b/components/allocadence/sources/new-customer-order/new-customer-order.mjs new file mode 100644 index 0000000000000..94404c972357f --- /dev/null +++ b/components/allocadence/sources/new-customer-order/new-customer-order.mjs @@ -0,0 +1,113 @@ +import allocadence from "../../allocadence.app.mjs"; +import { + axios, DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, +} from "@pipedream/platform"; + +export default { + key: "allocadence-new-customer-order", + name: "New Customer Order Created", + description: "Emit new event when a new customer order is created. [See the documentation](https://docs.allocadence.com/)", + version: "0.0.{{ts}}", + type: "source", + dedupe: "unique", + props: { + allocadence, + db: "$.service.db", + customerId: { + propDefinition: [ + allocadence, + "customerId", + ], + }, + productId: { + propDefinition: [ + allocadence, + "productId", + ], + }, + orderDetails: { + propDefinition: [ + allocadence, + "orderDetails", + ], + optional: true, + }, + deliveryMode: { + propDefinition: [ + allocadence, + "deliveryMode", + ], + optional: true, + }, + timer: { + type: "$.interface.timer", + default: { + intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, + }, + }, + }, + methods: { + _getLastOrderCreatedTime() { + return this.db.get("lastOrderCreatedTime") || 0; + }, + _setLastOrderCreatedTime(time) { + this.db.set("lastOrderCreatedTime", time); + }, + async _getNewCustomerOrders() { + const lastOrderCreatedTime = this._getLastOrderCreatedTime(); + const orders = await this.allocadence.createCustomerOrder({ + customerInformation: this.customerId, + productDetails: this.productId, + specialInstructions: this.orderDetails, + deliveryMode: this.deliveryMode, + }); + + const newOrders = orders.filter((order) => new Date(order.createdDate).getTime() > lastOrderCreatedTime); + return newOrders; + }, + }, + hooks: { + async deploy() { + const newOrders = await this._getNewCustomerOrders(); + + for (const order of newOrders.slice(-50)) { + this.$emit(order, { + id: order.id, + summary: `New Customer Order: ${order.orderNumber}`, + ts: new Date(order.createdDate).getTime(), + }); + } + + if (newOrders.length) { + const latestOrderDate = newOrders[newOrders.length - 1].createdDate; + this._setLastOrderCreatedTime(new Date(latestOrderDate).getTime()); + } + }, + async activate() { + const orders = await this._getNewCustomerOrders(); + if (orders.length) { + const latestOrderDate = orders[orders.length - 1].createdDate; + this._setLastOrderCreatedTime(new Date(latestOrderDate).getTime()); + } + }, + async deactivate() { + this.db.set("lastOrderCreatedTime", null); + }, + }, + async run() { + const newOrders = await this._getNewCustomerOrders(); + + for (const order of newOrders) { + this.$emit(order, { + id: order.id, + summary: `New Customer Order: ${order.orderNumber}`, + ts: new Date(order.createdDate).getTime(), + }); + } + + if (newOrders.length) { + const latestOrderDate = newOrders[newOrders.length - 1].createdDate; + this._setLastOrderCreatedTime(new Date(latestOrderDate).getTime()); + } + }, +}; diff --git a/components/allocadence/sources/new-purchase-order/new-purchase-order.mjs b/components/allocadence/sources/new-purchase-order/new-purchase-order.mjs new file mode 100644 index 0000000000000..0f398243ab135 --- /dev/null +++ b/components/allocadence/sources/new-purchase-order/new-purchase-order.mjs @@ -0,0 +1,105 @@ +import { axios } from "@pipedream/platform"; +import allocadence from "../../allocadence.app.mjs"; + +export default { + key: "allocadence-new-purchase-order", + name: "New Purchase Order Created", + description: "Emit new event when a new purchase order is created. [See the documentation](https://docs.allocadence.com/)", + version: "0.0.{{ts}}", + type: "source", + dedupe: "unique", + props: { + allocadence, + db: "$.service.db", + supplierId: { + propDefinition: [ + allocadence, + "supplierId", + ], + }, + productId: { + propDefinition: [ + allocadence, + "productId", + ], + }, + quantity: { + propDefinition: [ + allocadence, + "quantity", + ], + optional: true, + }, + deliveryDate: { + propDefinition: [ + allocadence, + "deliveryDate", + ], + optional: true, + }, + }, + methods: { + _getLastTimestamp() { + return this.db.get("lastTimestamp") || 0; + }, + _setLastTimestamp(timestamp) { + this.db.set("lastTimestamp", timestamp); + }, + async fetchNewPurchaseOrders(since) { + return this.allocadence._makeRequest({ + path: "/purchase-orders", + params: { + since: since, + }, + }); + }, + async createPurchaseOrder() { + return this.allocadence.createPurchaseOrder({ + supplierId: this.supplierId, + productId: this.productId, + quantity: this.quantity, + deliveryDate: this.deliveryDate, + }); + }, + }, + hooks: { + async deploy() { + const lastTimestamp = this._getLastTimestamp(); + const newOrders = await this.fetchNewPurchaseOrders(lastTimestamp); + + newOrders.slice(0, 50).forEach((order) => { + this.$emit(order, { + id: order.id, + summary: `New Purchase Order: ${order.orderNumber}`, + ts: new Date(order.createdDate).getTime(), + }); + }); + + if (newOrders.length > 0) { + this._setLastTimestamp(new Date(newOrders[0].createdDate).getTime()); + } + }, + async activate() { + // Code to create webhook or other setup tasks + }, + async deactivate() { + // Code to remove webhook or other cleanup tasks + }, + }, + async run() { + const lastTimestamp = this._getLastTimestamp(); + const newOrders = await this.fetchNewPurchaseOrders(lastTimestamp); + + newOrders.forEach((order) => { + this.$emit(order, { + id: order.id, + summary: `New Purchase Order: ${order.orderNumber}`, + ts: new Date(order.createdDate).getTime(), + }); + }); + + if (newOrders.length > 0) { + this._setLastTimestamp(new Date(newOrders[0].createdDate).getTime()); + } + }, +}; From f05e39a5057484ac1db353bc2f47f48f3400bed8 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Tue, 8 Oct 2024 10:47:05 -0300 Subject: [PATCH 2/4] [Components] allocadence #13950 Sources - New Customer Order - New Purchase Order Actions - Create Customer Order - Create Purchase Order --- .../create-customer-order.mjs | 356 ++++++++++++++++-- .../create-purchase-order.mjs | 128 +++++-- components/allocadence/allocadence.app.mjs | 171 +++------ components/allocadence/common/constants.mjs | 5 + components/allocadence/common/utils.mjs | 24 ++ components/allocadence/package.json | 5 +- .../allocadence/sources/common/base.mjs | 69 ++++ .../new-customer-order/new-customer-order.mjs | 129 ++----- .../sources/new-customer-order/test-event.mjs | 109 ++++++ .../new-purchase-order/new-purchase-order.mjs | 112 ++---- .../sources/new-purchase-order/test-event.mjs | 32 ++ 11 files changed, 764 insertions(+), 376 deletions(-) create mode 100644 components/allocadence/common/constants.mjs create mode 100644 components/allocadence/common/utils.mjs create mode 100644 components/allocadence/sources/common/base.mjs create mode 100644 components/allocadence/sources/new-customer-order/test-event.mjs create mode 100644 components/allocadence/sources/new-purchase-order/test-event.mjs diff --git a/components/allocadence/actions/create-customer-order/create-customer-order.mjs b/components/allocadence/actions/create-customer-order/create-customer-order.mjs index f97a65ea4a1e4..8da0e725f2fae 100644 --- a/components/allocadence/actions/create-customer-order/create-customer-order.mjs +++ b/components/allocadence/actions/create-customer-order/create-customer-order.mjs @@ -1,48 +1,340 @@ +import { ConfigurationError } from "@pipedream/platform"; import allocadence from "../../allocadence.app.mjs"; -import { axios } from "@pipedream/platform"; +import { POSTAGE_ACCOUNT_OPTIONS } from "../../common/constants.mjs"; +import { parseObject } from "../../common/utils.mjs"; export default { key: "allocadence-create-customer-order", name: "Create Customer Order", - description: "Creates a new customer order. [See the documentation](https://docs.allocadence.com/)", + description: "Creates a new customer order. [See the documentation](https://docs.allocadence.com/#tag/customer_order/paths/~1customer-orders/post)", version: "0.0.1", type: "action", props: { allocadence, - customerInformation: { - propDefinition: [ - allocadence, - "customerInformation", - ], - }, - productDetails: { - propDefinition: [ - allocadence, - "productDetails", - ], - }, - shippingAddress: { - propDefinition: [ - allocadence, - "shippingAddress", - ], - }, - specialInstructions: { - propDefinition: [ - allocadence, - "specialInstructions", - { - optional: true, - }, - ], + orderNumber: { + type: "string", + label: "Order Number", + description: "Order number for the customer order.", + optional: true, + }, + clientId: { + type: "integer", + label: "Client Id", + description: "Id of the client that the customer order is for.", + optional: true, + }, + clientName: { + type: "string", + label: "Client Name", + description: "Name of the client that the customer order is for. **Ignored if clientId is provided and is nonzero.**", + optional: true, + }, + customerId: { + type: "integer", + label: "Customer Id", + description: "Id of the customer. If none is provided, will attempt to find an existing customer based on the other customer fields and shipping address. Other fields not used if id is provided.", + optional: true, + }, + title: { + type: "string", + label: "Customer Title", + description: "The title of the customer.", + optional: true, + }, + name: { + type: "string", + label: "Customer Name", + description: "A combination of name and surname is required if the customer is new.", + optional: true, + }, + surname: { + type: "string", + label: "Customer Surname", + description: "A combination of name and surname is required if the customer is new.", + optional: true, + }, + email: { + type: "string", + label: "Customer Email", + description: "The email of the customer.", + optional: true, + }, + customerCompany: { + type: "string", + label: "Customer Company", + description: "The company of the customer.", + optional: true, + }, + accountNumber: { + type: "string", + label: "Customer Account Number", + description: "Will only match a customer on this field if provided.", + optional: true, + }, + shippingAddressId: { + type: "integer", + label: "Shipping Address Id", + description: "Id of the shipping address. **Other Shipping fields will not be used if provided.**", + optional: true, + }, + shippingAddressCode: { + type: "string", + label: "Shipping Address Code", + description: "Used to find an existing address. Other fields not used if an address is successfully found.", + optional: true, + }, + shippingAddressCompany: { + type: "string", + label: "Shipping Address Company", + description: "The company of the shipping address.", + optional: true, + }, + shippingAddressName: { + type: "string", + label: "Shipping Address Name", + description: "The name of the shipping address.", + optional: true, + }, + shippingAddressline1: { + type: "string", + label: "Shipping Address Line 1", + description: "The shipping address line 1.", + optional: true, + }, + shippingAddressline2: { + type: "string", + label: "Shipping Address Line 2", + description: "The shipping address line 2.", + optional: true, + }, + shippingAddressline3: { + type: "string", + label: "Shipping Address Line 3", + description: "The shipping address line 3.", + optional: true, + }, + shippingAddressCity: { + type: "string", + label: "Shipping Address City", + description: "The city of the shipping address.", + optional: true, }, + shippingAddressState: { + type: "string", + label: "Shipping Address State", + description: "The state of the shipping address.", + optional: true, + }, + shippingAddressZip: { + type: "string", + label: "Shipping Address Zip", + description: "The zip of the shipping address.", + optional: true, + }, + shippingAddressCountryCode: { + type: "string", + label: "Shipping Address Country Code", + description: "The country code of the shipping address. [See the ISO 3166 codes](https://www.iban.com/country-codes).", + optional: true, + }, + shippingAddressPhone: { + type: "string", + label: "Shipping Address Phone", + description: "The phone of the shipping address.", + optional: true, + }, + sameAsShipping: { + type: "boolean", + label: "Same As Shipping", + description: "True if the billing address is the same as the shipping address.", + reloadProps: true, + optional: true, + }, + shipFromWarehouseId: { + type: "string", + label: "Ship From Warehouse Id", + description: "Id of the warehouse the ordered items will be allocated from. If no warehouse parameters are given, then the user's current warehouse will be used.", + optional: true, + }, + shipFromWarehouseName: { + type: "string", + label: "Ship From Warehouse Name", + description: "Name of the warehouse the ordered items will be allocated from. Ignored if warehouseId is provided.", + optional: true, + }, + shipVia: { + type: "string", + label: "Ship Via", + description: "Code of the carrier or service to use for shipping.", + optional: true, + }, + postageAccount: { + type: "string", + label: "Postage Account", + description: "Who to bill for shipping.", + options: POSTAGE_ACCOUNT_OPTIONS, + optional: true, + }, + items: { + type: "string[]", + label: "Items", + description: "An array of objects of ordered items. **Example: {\"itemId\": \"123\", \"sku\": \"SKU123\", \"quantity\": 1}** [See the documentation](https://docs.allocadence.com/#tag/customer_order/paths/~1customer-orders/post) fro further information.", + optional: true, + }, + }, + async additionalProps() { + const props = {}; + + if (!this.sameAsShipping) { + props.billingAddressId = { + type: "integer", + label: "Billing Address Id", + description: "Id of the billing address. **Other Billing fields will not be used if provided.**", + optional: true, + }; + props.billingAddressCode = { + type: "string", + label: "Billing Address Code", + description: "Used to find an existing address. Other fields not used if an address is successfully found.", + optional: true, + }; + props.billingAddressCompany = { + type: "string", + label: "Billing Address Company", + description: "The company of the billing address.", + optional: true, + }; + props.billingAddressName = { + type: "string", + label: "Billing Address Name", + description: "The name of the billing address.", + optional: true, + }; + props.billingAddressline1 = { + type: "string", + label: "Billing Address Line 1", + description: "The billing address line 1.", + optional: true, + }; + props.billingAddressline2 = { + type: "string", + label: "Billing Address Line 2", + description: "The billing address line 2.", + optional: true, + }; + props.billingAddressline3 = { + type: "string", + label: "Billing Address Line 3", + description: "The billing address line 3.", + optional: true, + }; + props.billingAddressCity = { + type: "string", + label: "Billing Address City", + description: "The city of the billing address.", + optional: true, + }; + props.billingAddressState = { + type: "string", + label: "Billing Address State", + description: "The state of the billing address.", + optional: true, + }; + props.billingAddressZip = { + type: "string", + label: "Billing Address Zip", + description: "The zip of the billing address.", + optional: true, + }; + props.billingAddressCountryCode = { + type: "string", + label: "Billing Address Country Code", + description: "The country code of the billing address. [See the ISO 3166 codes](https://www.iban.com/country-codes).", + optional: true, + }; + props.billingAddressPhone = { + type: "string", + label: "Billing Address Phone", + description: "The phone of the billing address.", + optional: true, + }; + } + return props; }, async run({ $ }) { + if (!this.customerId && + !this.title && + !this.name && + !this.surname && + !this.email && + !this.customerCompany && + !this.accountNumber) { + throw new ConfigurationError("You must provide at least 'Customer Id', 'Customer Title', 'Customer Name', 'Customer Surname', 'Customer Email', 'Customer Company' or 'Customer Account Number'."); + } + + if (!this.shippingAddressId && + !this.shippingAddressline1 && + !this.shippingAddressCountryCode) { + throw new ConfigurationError("You must provide at least 'Shipping Address Id' or 'Shipping Address Line1' and 'Shipping Address Country Code'."); + } + + if (!this.sameAsShipping && + !this.billingAddressId && + !this.billingAddressline1 && + !this.billingAddressCountryCode) { + throw new ConfigurationError("When 'Same As Shipping' is set **False** you must provide at least 'Billing Address Id' or 'Billing Address Line1' and 'Billing Address Country Code'."); + } + const response = await this.allocadence.createCustomerOrder({ - customerInformation: this.customerInformation, - productDetails: this.productDetails, - shippingAddress: this.shippingAddress, - specialInstructions: this.specialInstructions, + $, + data: { + orderNumber: this.orderNumber, + clientId: this.clientId, + clientName: this.clientName, + customer: { + id: this.customerId, + title: this.title, + name: this.name, + surname: this.surname, + email: this.email, + company: this.customerCompany, + accountNumber: this.accountNumber, + }, + shippingAddress: { + id: this.shippingAddressId, + code: this.shippingAddressCode, + company: this.shippingAddressCompany, + name: this.shippingAddressName, + line1: this.shippingAddressline1, + line2: this.shippingAddressline2, + line3: this.shippingAddressline3, + city: this.shippingAddressCity, + state: this.shippingAddressState, + zip: this.shippingAddressZip, + countryCode: this.shippingAddressCountryCode, + phone: this.shippingAddressPhone, + }, + billingAddress: { + sameAsShipping: this.sameAsShipping, + id: this.billingAddressId, + code: this.billingAddressCode, + company: this.billingAddressCompany, + name: this.billingAddressName, + line1: this.billingAddressline1, + line2: this.billingAddressline2, + line3: this.billingAddressline3, + city: this.billingAddressCity, + state: this.billingAddressState, + zip: this.billingAddressZip, + countryCode: this.billingAddressCountryCode, + phone: this.billingAddressPhone, + }, + shipFromWarehouseId: this.shipFromWarehouseId, + shipFromWarehouseName: this.shipFromWarehouseName, + shipVia: this.shipVia, + postageAccount: this.postageAccount, + items: parseObject(this.items), + }, }); $.export("$summary", `Successfully created customer order with ID ${response.id}`); diff --git a/components/allocadence/actions/create-purchase-order/create-purchase-order.mjs b/components/allocadence/actions/create-purchase-order/create-purchase-order.mjs index 964921508ffcd..dd48ccae24cd1 100644 --- a/components/allocadence/actions/create-purchase-order/create-purchase-order.mjs +++ b/components/allocadence/actions/create-purchase-order/create-purchase-order.mjs @@ -1,51 +1,109 @@ +import { ConfigurationError } from "@pipedream/platform"; import allocadence from "../../allocadence.app.mjs"; +import { parseObject } from "../../common/utils.mjs"; export default { key: "allocadence-create-purchase-order", name: "Create Purchase Order", description: "Generates a new purchase order. [See the documentation](https://docs.allocadence.com/)", - version: "0.0.{{ts}}", + version: "0.0.1", type: "action", props: { allocadence, - supplierDetails: { - propDefinition: [ - allocadence, - "supplierDetails", - ], - }, - productDetails: { - propDefinition: [ - allocadence, - "productDetails", - ], - }, - deliveryAddress: { - propDefinition: [ - allocadence, - "deliveryAddress", - ], - }, - orderDeadline: { - propDefinition: [ - allocadence, - "orderDeadline", - ], - }, - additionalInstructions: { - propDefinition: [ - allocadence, - "additionalInstructions", - ], + supplierId: { + type: "integer", + label: "Supplier Id", + description: "Id of the supplier that is being ordered from.", + optional: true, + }, + supplierName: { + type: "string", + label: "Supplier Name", + description: "Name of the supplier that is being ordered from. Ignored if supplierId is provided.", + optional: true, + }, + warehouseId: { + type: "integer", + label: "Warehouse Id", + description: "Id of the warehouse the items will be delivered to. If no warehouse parameters are given, then the user's current warehouse will be used.", + optional: true, + }, + warehouseName: { + type: "string", + label: "Warehouse Name", + description: "Name of the warehouse the items will be delivered to. Ignored if warehouseId is provided.", + optional: true, + }, + clientId: { + type: "integer", + label: "Client Id", + description: "Id of the client that the purchase order is for. Defaults to the user's client id.", + optional: true, + }, + clientName: { + type: "string", + label: "Client Name", + description: "Name of the client that the purchase order is for. Ignored if clientId is provided and is nonzero.", + optional: true, + }, + orderNumber: { + type: "string", + label: "Order Number", + description: "Order number for the purchase order. If blank, one will automatically be generated.", + optional: true, + }, + draft: { + type: "boolean", + label: "Draft", + description: "True if the purchase order should be created as a draft to allow future editing.", + optional: true, + }, + requiredByDate: { + type: "string", + label: "Required By.", + description: "The date of the purchase. **Format: YYYY-MM-DD**", + optional: true, + }, + projectNumber: { + type: "string", + label: "Project Number", + description: "The number of the project.", + optional: true, + }, + notes: { + type: "string", + label: "Notes", + description: "A note of the purchase.", + optional: true, + }, + items: { + type: "string[]", + label: "Items", + description: "A list of object of ordered items. **Example: {\"itemId\": 123, \"sku\": \"SKU123\", \"description\": \"description\", \"quantity\": 1}**. [See the documentation](https://docs.allocadence.com/#tag/purchase_order/paths/~1purchase-orders/post) fro further information.", + optional: true, }, }, async run({ $ }) { + if (!this.supplierId && !this.supplierName) { + throw new ConfigurationError("You must provide at least 'Supplier Id' or 'Supplier Name'."); + } + const response = await this.allocadence.createPurchaseOrder({ - supplierDetails: this.supplierDetails, - productDetails: this.productDetails, - deliveryAddress: this.deliveryAddress, - orderDeadline: this.orderDeadline, - additionalInstructions: this.additionalInstructions, + $, + data: { + supplierId: this.supplierId, + supplierName: this.supplierName, + warehouseId: this.warehouseId, + warehouseName: this.warehouseName, + clientId: this.clientId, + clientName: this.clientName, + orderNumber: this.orderNumber, + draft: this.draft, + requiredByDate: this.requiredByDate, + projectNumber: this.projectNumber, + notes: this.notes, + items: parseObject(this.items), + }, }); $.export("$summary", `Successfully created purchase order with ID ${response.id}`); diff --git a/components/allocadence/allocadence.app.mjs b/components/allocadence/allocadence.app.mjs index ce34e0de80df0..283d20ddb37a9 100644 --- a/components/allocadence/allocadence.app.mjs +++ b/components/allocadence/allocadence.app.mjs @@ -3,143 +3,76 @@ import { axios } from "@pipedream/platform"; export default { type: "app", app: "allocadence", - propDefinitions: { - customerId: { - type: "string", - label: "Customer ID", - description: "The ID of the customer who placed the order", - }, - productId: { - type: "string", - label: "Product ID", - description: "The ID of the product", - }, - orderDetails: { - type: "string", - label: "Order Details", - description: "Optional details about the customer order", - optional: true, - }, - deliveryMode: { - type: "string", - label: "Delivery Mode", - description: "Optional delivery mode for the order", - optional: true, - }, - supplierId: { - type: "string", - label: "Supplier ID", - description: "The ID of the supplier for purchase orders", - }, - quantity: { - type: "integer", - label: "Quantity", - description: "Optional quantity for the purchase order", - optional: true, - }, - deliveryDate: { - type: "string", - label: "Delivery Date", - description: "Optional delivery date for the purchase order", - optional: true, - }, - customerInformation: { - type: "string", - label: "Customer Information", - description: "Information about the customer", - }, - productDetails: { - type: "string", - label: "Product Details", - description: "Details about the product", - }, - shippingAddress: { - type: "string", - label: "Shipping Address", - description: "Address where the order will be shipped to", - }, - specialInstructions: { - type: "string", - label: "Special Instructions", - description: "Optional special instructions for the order", - optional: true, - }, - supplierDetails: { - type: "string", - label: "Supplier Details", - description: "Details about the supplier", - }, - deliveryAddress: { - type: "string", - label: "Delivery Address", - description: "The address where the purchase order will be delivered", - }, - orderDeadline: { - type: "string", - label: "Order Deadline", - description: "Optional deadline for the order", - optional: true, - }, - additionalInstructions: { - type: "string", - label: "Additional Instructions", - description: "Optional additional instructions for the purchase order", - optional: true, - }, - }, methods: { _baseUrl() { - return "https://api.allocadence.com"; + return "https://app.allocadence.com/rest"; + }, + _auth() { + return { + username: `${this.$auth.api_key}`, + password: `${this.$auth.api_secret}`, + }; }, - async _makeRequest(opts = {}) { - const { - $ = this, method = "GET", path = "/", headers, ...otherOpts - } = opts; + _makeRequest({ + $ = this, method = "GET", path, ...opts + }) { return axios($, { - ...otherOpts, method, url: this._baseUrl() + path, - headers: { - ...headers, - Authorization: `Bearer ${this.$auth.api_token}`, - }, + auth: this._auth(), + ...opts, }); }, - async createCustomerOrder(opts = {}) { - const { - customerInformation, productDetails, shippingAddress, specialInstructions, ...extraOpts - } = opts; + createCustomerOrder(opts = {}) { return this._makeRequest({ method: "POST", path: "/customer-orders", - data: { - customerInformation, - productDetails, - shippingAddress, - specialInstructions, - ...extraOpts, - }, + ...opts, }); }, - async createPurchaseOrder(opts = {}) { - const { - supplierDetails, productDetails, deliveryAddress, orderDeadline, additionalInstructions, ...extraOpts - } = opts; + createPurchaseOrder(opts = {}) { return this._makeRequest({ method: "POST", path: "/purchase-orders", - data: { - supplierDetails, - productDetails, - deliveryAddress, - orderDeadline, - additionalInstructions, - ...extraOpts, - }, + ...opts, + }); + }, + listCustomerOrder(opts = {}) { + return this._makeRequest({ + path: "/customer-orders", + ...opts, + }); + }, + listPurchaseOrder(opts = {}) { + return this._makeRequest({ + path: "/purchase-orders", + ...opts, }); }, - authKeys() { - console.log(Object.keys(this.$auth)); + async *paginate({ + fn, params = {}, dataField, maxResults = null, ...opts + }) { + let hasMore = false; + let count = 0; + let page = 0; + + do { + params.page = ++page; + const response = await fn({ + params, + ...opts, + }); + for (const d of response[dataField]) { + yield d; + + if (maxResults && ++count === maxResults) { + return count; + } + } + + hasMore = page < response.meta.totalPages; + + } while (hasMore); }, }, }; diff --git a/components/allocadence/common/constants.mjs b/components/allocadence/common/constants.mjs new file mode 100644 index 0000000000000..a3deffb7fea4d --- /dev/null +++ b/components/allocadence/common/constants.mjs @@ -0,0 +1,5 @@ +export const POSTAGE_ACCOUNT_OPTIONS = [ + "sender", + "client", + "recipient", +]; diff --git a/components/allocadence/common/utils.mjs b/components/allocadence/common/utils.mjs new file mode 100644 index 0000000000000..dcc9cc61f6f41 --- /dev/null +++ b/components/allocadence/common/utils.mjs @@ -0,0 +1,24 @@ +export const parseObject = (obj) => { + if (!obj) return undefined; + + if (Array.isArray(obj)) { + return obj.map((item) => { + if (typeof item === "string") { + try { + return JSON.parse(item); + } catch (e) { + return item; + } + } + return item; + }); + } + if (typeof obj === "string") { + try { + return JSON.parse(obj); + } catch (e) { + return obj; + } + } + return obj; +}; diff --git a/components/allocadence/package.json b/components/allocadence/package.json index 08a195ea5ac12..792f7575ea61a 100644 --- a/components/allocadence/package.json +++ b/components/allocadence/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/allocadence", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Allocadence Components", "main": "allocadence.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } } diff --git a/components/allocadence/sources/common/base.mjs b/components/allocadence/sources/common/base.mjs new file mode 100644 index 0000000000000..1ba07e91f4d2c --- /dev/null +++ b/components/allocadence/sources/common/base.mjs @@ -0,0 +1,69 @@ +import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; +import allocadence from "../../allocadence.app.mjs"; + +export default { + props: { + allocadence, + db: "$.service.db", + timer: { + type: "$.interface.timer", + default: { + intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, + }, + }, + }, + methods: { + _getLastDate() { + return this.db.get("lastDate") || "1970-01-01T00:00:01"; + }, + _setLastDate(lastDate) { + this.db.set("lastDate", lastDate); + }, + prepareData({ + responseArray, fieldDate, + }) { + if (responseArray.length) { + this._setLastDate(responseArray[0][fieldDate]); + } + return responseArray; + }, + async emitEvent(maxResults = false) { + const lastDate = this._getLastDate(); + const fieldDate = this.getFieldDate(); + + const response = this.allocadence.paginate({ + fn: this.getFunction(), + params: this.getParams(lastDate), + dataField: this.getDataField(), + maxResults, + }); + + let responseArray = []; + for await (const item of response) { + responseArray.push(item); + } + + const preparedData = this.prepareData({ + responseArray, + fieldDate, + maxResults, + }); + + for (const item of preparedData.reverse()) { + this.$emit(item, { + id: item.id, + summary: this.getSummary(item), + ts: Date.parse(new Date()), + }); + } + }, + }, + hooks: { + async deploy() { + await this.emitEvent(25); + }, + }, + async run() { + await this.emitEvent(); + }, +}; diff --git a/components/allocadence/sources/new-customer-order/new-customer-order.mjs b/components/allocadence/sources/new-customer-order/new-customer-order.mjs index 94404c972357f..64bfe62c53899 100644 --- a/components/allocadence/sources/new-customer-order/new-customer-order.mjs +++ b/components/allocadence/sources/new-customer-order/new-customer-order.mjs @@ -1,113 +1,46 @@ -import allocadence from "../../allocadence.app.mjs"; -import { - axios, DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, -} from "@pipedream/platform"; +import common from "../common/base.mjs"; +import sampleEmit from "./test-event.mjs"; export default { + ...common, key: "allocadence-new-customer-order", name: "New Customer Order Created", - description: "Emit new event when a new customer order is created. [See the documentation](https://docs.allocadence.com/)", - version: "0.0.{{ts}}", + description: "Emit new event when a new customer order is created.", + version: "0.0.1", type: "source", dedupe: "unique", - props: { - allocadence, - db: "$.service.db", - customerId: { - propDefinition: [ - allocadence, - "customerId", - ], - }, - productId: { - propDefinition: [ - allocadence, - "productId", - ], - }, - orderDetails: { - propDefinition: [ - allocadence, - "orderDetails", - ], - optional: true, - }, - deliveryMode: { - propDefinition: [ - allocadence, - "deliveryMode", - ], - optional: true, - }, - timer: { - type: "$.interface.timer", - default: { - intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, - }, - }, - }, methods: { - _getLastOrderCreatedTime() { - return this.db.get("lastOrderCreatedTime") || 0; + ...common.methods, + prepareData({ + responseArray, fieldDate, maxResults, + }) { + responseArray.reverse(); + if (responseArray.length) { + if (maxResults && responseArray.length > maxResults) { + responseArray.length = maxResults; + } + this._setLastDate(responseArray[0][fieldDate]); + } + return responseArray; }, - _setLastOrderCreatedTime(time) { - this.db.set("lastOrderCreatedTime", time); + getParams(orderedDate) { + return { + orderedDate, + orderedDateConditional: "on_or_after", + }; }, - async _getNewCustomerOrders() { - const lastOrderCreatedTime = this._getLastOrderCreatedTime(); - const orders = await this.allocadence.createCustomerOrder({ - customerInformation: this.customerId, - productDetails: this.productId, - specialInstructions: this.orderDetails, - deliveryMode: this.deliveryMode, - }); - - const newOrders = orders.filter((order) => new Date(order.createdDate).getTime() > lastOrderCreatedTime); - return newOrders; + getFunction() { + return this.allocadence.listCustomerOrder; }, - }, - hooks: { - async deploy() { - const newOrders = await this._getNewCustomerOrders(); - - for (const order of newOrders.slice(-50)) { - this.$emit(order, { - id: order.id, - summary: `New Customer Order: ${order.orderNumber}`, - ts: new Date(order.createdDate).getTime(), - }); - } - - if (newOrders.length) { - const latestOrderDate = newOrders[newOrders.length - 1].createdDate; - this._setLastOrderCreatedTime(new Date(latestOrderDate).getTime()); - } + getDataField() { + return "customerOrders"; }, - async activate() { - const orders = await this._getNewCustomerOrders(); - if (orders.length) { - const latestOrderDate = orders[orders.length - 1].createdDate; - this._setLastOrderCreatedTime(new Date(latestOrderDate).getTime()); - } + getFieldDate() { + return "orderedDate"; }, - async deactivate() { - this.db.set("lastOrderCreatedTime", null); + getSummary(item) { + return `New Customer Order: ${item.orderNumber}`; }, }, - async run() { - const newOrders = await this._getNewCustomerOrders(); - - for (const order of newOrders) { - this.$emit(order, { - id: order.id, - summary: `New Customer Order: ${order.orderNumber}`, - ts: new Date(order.createdDate).getTime(), - }); - } - - if (newOrders.length) { - const latestOrderDate = newOrders[newOrders.length - 1].createdDate; - this._setLastOrderCreatedTime(new Date(latestOrderDate).getTime()); - } - }, + sampleEmit, }; diff --git a/components/allocadence/sources/new-customer-order/test-event.mjs b/components/allocadence/sources/new-customer-order/test-event.mjs new file mode 100644 index 0000000000000..aa1d145c03e70 --- /dev/null +++ b/components/allocadence/sources/new-customer-order/test-event.mjs @@ -0,0 +1,109 @@ +export default { + "id": 103717, + "orderNumber": "Test-Order-001", + "orderReference": "", + "customer": { + "id": 7089, + "title": "", + "name": "Test Customer 1", + "surname": "", + "email": "testcustomer1@testserver.com", + "company": "Test Company", + "accountNumber": "" + }, + "client": null, + "orderedDate": "2021-12-13T00:00:00-07:00", + "createdDate": "2024-09-13T13:02:58-07:00", + "modifiedDate": "2024-09-13T13:02:58-07:00", + "orderPlaced": true, + "createdBy": { + "id": 520, + "name": "Pipedream Support" + }, + "completed": false, + "completedDate": "", + "cancelled": false, + "cancelledDate": "", + "cancelledReason": "", + "cancelledBy": null, + "onHold": false, + "onHoldUntil": "", + "postageAccount": "sender", + "buyerPaidShipping": 0, + "shippingAddress": { + "id": 12517, + "company": "", + "name": "", + "line1": "515 E Grant St", + "line2": "", + "line3": "", + "city": "Phoenix", + "state": "AZ", + "zip": "85004", + "country": "United States", + "countryCode": "US", + "phone": "", + "code": "", + "verifiedStatus": "awaiting", + "verifiedDate": "", + "verifiedMessage": "" + }, + "billingAddress": { + "id": 12518, + "company": "", + "name": "", + "line1": "N/A", + "line2": "", + "line3": "", + "city": "", + "state": "", + "zip": "", + "country": "United States", + "countryCode": "US", + "phone": "", + "code": "", + "verifiedStatus": "awaiting", + "verifiedDate": "", + "verifiedMessage": "" + }, + "shipVia": "Standard", + "shipViaPackaging": "", + "shipViaConfirmation": "", + "dryIceWeight": 0, + "packageSku": "", + "shipFromWarehouse": { + "id": 187, + "name": "Main Warehouse" + }, + "projectNumber": "", + "discountPercentage": 0, + "orderSource": "CSV Import", + "internalNote": "", + "noteFromCustomer": "", + "noteToCustomer": "", + "notificationEmail": "", + "userField1": "", + "userField2": "", + "userField3": "", + "myList1": "", + "myList2": "", + "tags": [], + "items": [ + { + "id": 214405, + "itemId": 12063, + "sku": "TEST-SKU-101", + "description": "Baseball Cap", + "orderQuantity": 1, + "uom": "Each", + "quantity": 1, + "allocatedQuantity": 1, + "pickedQuantity": 0, + "price": 49, + "discountPercentage": 0, + "partOfKit": false, + "componentOf": 0, + "additionalFields": null + } + ] +} \ No newline at end of file diff --git a/components/allocadence/sources/new-purchase-order/new-purchase-order.mjs b/components/allocadence/sources/new-purchase-order/new-purchase-order.mjs index 0f398243ab135..072982dfd2877 100644 --- a/components/allocadence/sources/new-purchase-order/new-purchase-order.mjs +++ b/components/allocadence/sources/new-purchase-order/new-purchase-order.mjs @@ -1,105 +1,35 @@ -import { axios } from "@pipedream/platform"; -import allocadence from "../../allocadence.app.mjs"; +import common from "../common/base.mjs"; +import sampleEmit from "./test-event.mjs"; export default { + ...common, key: "allocadence-new-purchase-order", name: "New Purchase Order Created", - description: "Emit new event when a new purchase order is created. [See the documentation](https://docs.allocadence.com/)", - version: "0.0.{{ts}}", + description: "Emit new event when a new purchase order is created.", + version: "0.0.1", type: "source", dedupe: "unique", - props: { - allocadence, - db: "$.service.db", - supplierId: { - propDefinition: [ - allocadence, - "supplierId", - ], - }, - productId: { - propDefinition: [ - allocadence, - "productId", - ], - }, - quantity: { - propDefinition: [ - allocadence, - "quantity", - ], - optional: true, - }, - deliveryDate: { - propDefinition: [ - allocadence, - "deliveryDate", - ], - optional: true, - }, - }, methods: { - _getLastTimestamp() { - return this.db.get("lastTimestamp") || 0; + ...common.methods, + getParams(lastDate) { + return { + createdFrom: lastDate, + orderBy: "createdDate", + orderDir: "desc", + }; }, - _setLastTimestamp(timestamp) { - this.db.set("lastTimestamp", timestamp); + getFunction() { + return this.allocadence.listPurchaseOrder; }, - async fetchNewPurchaseOrders(since) { - return this.allocadence._makeRequest({ - path: "/purchase-orders", - params: { - since: since, - }, - }); + getDataField() { + return "purchaseOrders"; }, - async createPurchaseOrder() { - return this.allocadence.createPurchaseOrder({ - supplierId: this.supplierId, - productId: this.productId, - quantity: this.quantity, - deliveryDate: this.deliveryDate, - }); + getFieldDate() { + return "createdDate"; }, - }, - hooks: { - async deploy() { - const lastTimestamp = this._getLastTimestamp(); - const newOrders = await this.fetchNewPurchaseOrders(lastTimestamp); - - newOrders.slice(0, 50).forEach((order) => { - this.$emit(order, { - id: order.id, - summary: `New Purchase Order: ${order.orderNumber}`, - ts: new Date(order.createdDate).getTime(), - }); - }); - - if (newOrders.length > 0) { - this._setLastTimestamp(new Date(newOrders[0].createdDate).getTime()); - } - }, - async activate() { - // Code to create webhook or other setup tasks - }, - async deactivate() { - // Code to remove webhook or other cleanup tasks + getSummary(item) { + return `New Purchase Order: ${item.orderNumber}`; }, }, - async run() { - const lastTimestamp = this._getLastTimestamp(); - const newOrders = await this.fetchNewPurchaseOrders(lastTimestamp); - - newOrders.forEach((order) => { - this.$emit(order, { - id: order.id, - summary: `New Purchase Order: ${order.orderNumber}`, - ts: new Date(order.createdDate).getTime(), - }); - }); - - if (newOrders.length > 0) { - this._setLastTimestamp(new Date(newOrders[0].createdDate).getTime()); - } - }, + sampleEmit, }; diff --git a/components/allocadence/sources/new-purchase-order/test-event.mjs b/components/allocadence/sources/new-purchase-order/test-event.mjs new file mode 100644 index 0000000000000..5e0b55e3aed9e --- /dev/null +++ b/components/allocadence/sources/new-purchase-order/test-event.mjs @@ -0,0 +1,32 @@ +export default { + "id": 3858, + "orderNumber": "000000", + "supplier": { + "id": 569, + "name": "Default Supplier" + }, + "warehouse": { + "id": 187, + "name": "Main Warehouse" + }, + "client": null, + "user": { + "id": 123, + "name": "User Name" + }, + "draft": true, + "completed": false, + "deleted": false, + "createdDate": "2024-10-07T11:00:31-07:00", + "preparedDate": "", + "requiredByDate": "2024-10-07", + "completedDate": "", + "projectNumber": "", + "notes": "", + "shipMethod": "", + "terms": "", + "userField1": "", + "userField2": "", + "userField3": "", + "items": [] +} \ No newline at end of file From 9394a7fdbac3639520d5d6ab25f4e414a847f259 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Tue, 8 Oct 2024 10:49:50 -0300 Subject: [PATCH 3/4] pnpm update --- pnpm-lock.yaml | 107 +++++++++++++++++++++++++------------------------ 1 file changed, 55 insertions(+), 52 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0dddf491bc3d6..88288bbaa328e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -486,7 +486,10 @@ importers: '@pipedream/platform': 1.6.0 components/allocadence: - specifiers: {} + specifiers: + '@pipedream/platform': ^3.0.3 + dependencies: + '@pipedream/platform': 3.0.3 components/alpaca: specifiers: @@ -12906,55 +12909,6 @@ packages: - aws-crt dev: false - /@aws-sdk/client-sso-oidc/3.600.0_tdq3komn4zwyd65w7klbptsu34: - resolution: {integrity: sha512-7+I8RWURGfzvChyNQSyj5/tKrqRbzRl7H+BnTOf/4Vsw1nFOi5ROhlhD4X/Y0QCTacxnaoNcIrqnY7uGGvVRzw==} - engines: {node: '>=16.0.0'} - dependencies: - '@aws-crypto/sha256-browser': 5.2.0 - '@aws-crypto/sha256-js': 5.2.0 - '@aws-sdk/client-sts': 3.600.0 - '@aws-sdk/core': 3.598.0 - '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 - '@aws-sdk/middleware-host-header': 3.598.0 - '@aws-sdk/middleware-logger': 3.598.0 - '@aws-sdk/middleware-recursion-detection': 3.598.0 - '@aws-sdk/middleware-user-agent': 3.598.0 - '@aws-sdk/region-config-resolver': 3.598.0 - '@aws-sdk/types': 3.598.0 - '@aws-sdk/util-endpoints': 3.598.0 - '@aws-sdk/util-user-agent-browser': 3.598.0 - '@aws-sdk/util-user-agent-node': 3.598.0 - '@smithy/config-resolver': 3.0.3 - '@smithy/core': 2.2.3 - '@smithy/fetch-http-handler': 3.2.1 - '@smithy/hash-node': 3.0.2 - '@smithy/invalid-dependency': 3.0.2 - '@smithy/middleware-content-length': 3.0.2 - '@smithy/middleware-endpoint': 3.0.4 - '@smithy/middleware-retry': 3.0.6 - '@smithy/middleware-serde': 3.0.3 - '@smithy/middleware-stack': 3.0.3 - '@smithy/node-config-provider': 3.1.3 - '@smithy/node-http-handler': 3.1.2 - '@smithy/protocol-http': 4.0.3 - '@smithy/smithy-client': 3.1.6 - '@smithy/types': 3.3.0 - '@smithy/url-parser': 3.0.3 - '@smithy/util-base64': 3.0.0 - '@smithy/util-body-length-browser': 3.0.0 - '@smithy/util-body-length-node': 3.0.0 - '@smithy/util-defaults-mode-browser': 3.0.6 - '@smithy/util-defaults-mode-node': 3.0.6 - '@smithy/util-endpoints': 2.0.3 - '@smithy/util-middleware': 3.0.3 - '@smithy/util-retry': 3.0.2 - '@smithy/util-utf8': 3.0.0 - tslib: 2.6.3 - transitivePeerDependencies: - - '@aws-sdk/client-sts' - - aws-crt - dev: false - /@aws-sdk/client-sso/3.423.0: resolution: {integrity: sha512-znIufHkwhCIePgaYciIs3x/+BpzR57CZzbCKHR9+oOvGyufEPPpUT5bFLvbwTgfiVkTjuk6sG/ES3U5Bc+xtrA==} engines: {node: '>=14.0.0'} @@ -13190,7 +13144,7 @@ packages: dependencies: '@aws-crypto/sha256-browser': 5.2.0 '@aws-crypto/sha256-js': 5.2.0 - '@aws-sdk/client-sso-oidc': 3.600.0_tdq3komn4zwyd65w7klbptsu34 + '@aws-sdk/client-sso-oidc': 3.600.0 '@aws-sdk/core': 3.598.0 '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 '@aws-sdk/middleware-host-header': 3.598.0 @@ -13232,6 +13186,55 @@ packages: - aws-crt dev: false + /@aws-sdk/client-sts/3.600.0_dseaa2p5u2yk67qiepewcq3hkq: + resolution: {integrity: sha512-KQG97B7LvTtTiGmjlrG1LRAY8wUvCQzrmZVV5bjrJ/1oXAU7DITYwVbSJeX9NWg6hDuSk0VE3MFwIXS2SvfLIA==} + engines: {node: '>=16.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 5.2.0 + '@aws-crypto/sha256-js': 5.2.0 + '@aws-sdk/client-sso-oidc': 3.600.0 + '@aws-sdk/core': 3.598.0 + '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 + '@aws-sdk/middleware-host-header': 3.598.0 + '@aws-sdk/middleware-logger': 3.598.0 + '@aws-sdk/middleware-recursion-detection': 3.598.0 + '@aws-sdk/middleware-user-agent': 3.598.0 + '@aws-sdk/region-config-resolver': 3.598.0 + '@aws-sdk/types': 3.598.0 + '@aws-sdk/util-endpoints': 3.598.0 + '@aws-sdk/util-user-agent-browser': 3.598.0 + '@aws-sdk/util-user-agent-node': 3.598.0 + '@smithy/config-resolver': 3.0.3 + '@smithy/core': 2.2.3 + '@smithy/fetch-http-handler': 3.2.1 + '@smithy/hash-node': 3.0.2 + '@smithy/invalid-dependency': 3.0.2 + '@smithy/middleware-content-length': 3.0.2 + '@smithy/middleware-endpoint': 3.0.4 + '@smithy/middleware-retry': 3.0.6 + '@smithy/middleware-serde': 3.0.3 + '@smithy/middleware-stack': 3.0.3 + '@smithy/node-config-provider': 3.1.3 + '@smithy/node-http-handler': 3.1.2 + '@smithy/protocol-http': 4.0.3 + '@smithy/smithy-client': 3.1.6 + '@smithy/types': 3.3.0 + '@smithy/url-parser': 3.0.3 + '@smithy/util-base64': 3.0.0 + '@smithy/util-body-length-browser': 3.0.0 + '@smithy/util-body-length-node': 3.0.0 + '@smithy/util-defaults-mode-browser': 3.0.6 + '@smithy/util-defaults-mode-node': 3.0.6 + '@smithy/util-endpoints': 2.0.3 + '@smithy/util-middleware': 3.0.3 + '@smithy/util-retry': 3.0.2 + '@smithy/util-utf8': 3.0.0 + tslib: 2.6.3 + transitivePeerDependencies: + - '@aws-sdk/client-sso-oidc' + - aws-crt + dev: false + /@aws-sdk/core/3.556.0: resolution: {integrity: sha512-vJaSaHw2kPQlo11j/Rzuz0gk1tEaKdz+2ser0f0qZ5vwFlANjt08m/frU17ctnVKC1s58bxpctO/1P894fHLrA==} engines: {node: '>=14.0.0'} @@ -17558,7 +17561,7 @@ packages: '@aws-sdk/client-sns': 3.423.0 '@aws-sdk/client-sqs': 3.423.0 '@aws-sdk/client-ssm': 3.423.0 - '@aws-sdk/client-sts': 3.600.0 + '@aws-sdk/client-sts': 3.600.0_dseaa2p5u2yk67qiepewcq3hkq '@aws-sdk/s3-request-presigner': 3.609.0 '@pipedream/helper_functions': 0.3.12 '@pipedream/platform': 1.6.6 From f6741e0123e1ba9059d0883b64fbd581eb97d987 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Wed, 9 Oct 2024 11:47:10 -0300 Subject: [PATCH 4/4] some adjusts --- .../actions/create-purchase-order/create-purchase-order.mjs | 2 +- components/allocadence/allocadence.app.mjs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/allocadence/actions/create-purchase-order/create-purchase-order.mjs b/components/allocadence/actions/create-purchase-order/create-purchase-order.mjs index dd48ccae24cd1..4d4ee3d41601c 100644 --- a/components/allocadence/actions/create-purchase-order/create-purchase-order.mjs +++ b/components/allocadence/actions/create-purchase-order/create-purchase-order.mjs @@ -79,7 +79,7 @@ export default { items: { type: "string[]", label: "Items", - description: "A list of object of ordered items. **Example: {\"itemId\": 123, \"sku\": \"SKU123\", \"description\": \"description\", \"quantity\": 1}**. [See the documentation](https://docs.allocadence.com/#tag/purchase_order/paths/~1purchase-orders/post) fro further information.", + description: "A list of object of ordered items. **Example: {\"itemId\": 123, \"sku\": \"SKU123\", \"description\": \"description\", \"quantity\": 1}**. [See the documentation](https://docs.allocadence.com/#tag/purchase_order/paths/~1purchase-orders/post) for further information.", optional: true, }, }, diff --git a/components/allocadence/allocadence.app.mjs b/components/allocadence/allocadence.app.mjs index 283d20ddb37a9..9648b1b0cb310 100644 --- a/components/allocadence/allocadence.app.mjs +++ b/components/allocadence/allocadence.app.mjs @@ -37,13 +37,13 @@ export default { ...opts, }); }, - listCustomerOrder(opts = {}) { + listCustomerOrders(opts = {}) { return this._makeRequest({ path: "/customer-orders", ...opts, }); }, - listPurchaseOrder(opts = {}) { + listPurchaseOrders(opts = {}) { return this._makeRequest({ path: "/purchase-orders", ...opts,