diff --git a/components/webflow/actions/create-collection-item/create-collection-item.mjs b/components/webflow/actions/create-collection-item/create-collection-item.mjs index 98011b3916bd2..46f983614c632 100644 --- a/components/webflow/actions/create-collection-item/create-collection-item.mjs +++ b/components/webflow/actions/create-collection-item/create-collection-item.mjs @@ -1,22 +1,22 @@ -import webflow from "../../webflow.app.mjs"; +import app from "../../webflow.app.mjs"; export default { key: "webflow-create-collection-item", name: "Create Collection Item", - description: "Create new collection item. [See the docs here](https://developers.webflow.com/#create-new-collection-item)", - version: "1.0.1", + description: "Create new collection item. [See the documentation](https://developers.webflow.com/data/reference/cms/collection-items/staged-items/create-item)", + version: "2.0.0", type: "action", props: { - webflow, + app, siteId: { propDefinition: [ - webflow, + app, "sites", ], }, collectionId: { propDefinition: [ - webflow, + app, "collections", (c) => ({ siteId: c.siteId, @@ -24,21 +24,15 @@ export default { ], reloadProps: true, }, - live: { - label: "Live", - description: "Indicate if the item should be published to the live site", - type: "boolean", - default: false, - }, }, async additionalProps() { const props = {}; if (!this.collectionId) { return props; } - const { fields } = await this.webflow.getCollection(this.collectionId); + const { fields } = await this.app.getCollection(this.collectionId); for (const field of fields) { - if (field.editable && field.slug !== "_archived" && field.slug !== "_draft") { + if (field.isEditable && field.slug !== "isArchived" && field.slug !== "isDraft") { props[field.slug] = { type: "string", label: field.name, @@ -47,7 +41,7 @@ export default { : field.slug === "slug" ? "URL structure of the Item in your site." : "See the documentation for additional information about [Field Types & Item Values](https://developers.webflow.com/reference/field-types-item-values).", - optional: !field.required, + optional: !field.isRequired, }; } } @@ -55,29 +49,23 @@ export default { }, async run({ $ }) { const { - webflow, + app, // eslint-disable-next-line no-unused-vars siteId, - // eslint-disable-next-line no-unused-vars collectionId, - live, - ...fields + ...fieldData } = this; - const webflowClient = webflow._createApiClient(); - - const response = await webflowClient.createItem({ - collectionId: this.collectionId, - fields: { - ...fields, - _archived: false, - _draft: false, + const response = await app.createCollectionItem( + collectionId, + { + fieldData, + isArchived: false, + isDraft: false, }, - }, { - live, - }); + ); - $.export("$summary", `Successfully created collection item ${fields.name}`); + $.export("$summary", `Successfully created collection item ${this.name ?? ""}`); return response; }, diff --git a/components/webflow/actions/delete-collection-item/delete-collection-item.mjs b/components/webflow/actions/delete-collection-item/delete-collection-item.mjs index ed2cc27de4794..63d1deb609e0e 100644 --- a/components/webflow/actions/delete-collection-item/delete-collection-item.mjs +++ b/components/webflow/actions/delete-collection-item/delete-collection-item.mjs @@ -1,22 +1,22 @@ -import webflow from "../../webflow.app.mjs"; +import app from "../../webflow.app.mjs"; export default { key: "webflow-delete-collection-item", name: "Delete Collection Item", - description: "Delete Item of a Collection. [See the docs here](https://developers.webflow.com/#remove-collection-item)", - version: "1.0.1", + description: "Delete Item of a Collection. [See the documentation](https://developers.webflow.com/data/reference/cms/collection-items/staged-items/delete-item)", + version: "2.0.0", type: "action", props: { - webflow, + app, siteId: { propDefinition: [ - webflow, + app, "sites", ], }, collectionId: { propDefinition: [ - webflow, + app, "collections", (c) => ({ siteId: c.siteId, @@ -25,7 +25,7 @@ export default { }, itemId: { propDefinition: [ - webflow, + app, "items", (c) => ({ collectionId: c.collectionId, @@ -34,12 +34,10 @@ export default { }, }, async run({ $ }) { - const webflow = this.webflow._createApiClient(); - - const response = await webflow.removeItem({ - collectionId: this.collectionId, - itemId: this.itemId, - }); + const { + collectionId, itemId, + } = this; + const response = await this.app.deleteCollectionItem(collectionId, itemId); $.export("$summary", "Successfully deleted item"); diff --git a/components/webflow/actions/fulfill-order/fulfill-order.mjs b/components/webflow/actions/fulfill-order/fulfill-order.mjs index 811e3079da281..7d5580f580134 100644 --- a/components/webflow/actions/fulfill-order/fulfill-order.mjs +++ b/components/webflow/actions/fulfill-order/fulfill-order.mjs @@ -1,22 +1,22 @@ -import webflow from "../../webflow.app.mjs"; +import app from "../../webflow.app.mjs"; export default { key: "webflow-fulfill-order", name: "Fulfill Order", - description: "Fulfill an order. [See the docs here](https://developers.webflow.com/#fulfill-order)", - version: "1.0.1", + description: "Fulfill an order. [See the documentation](https://developers.webflow.com/data/reference/ecommerce/orders/update-fulfill)", + version: "2.0.0", type: "action", props: { - webflow, + app, siteId: { propDefinition: [ - webflow, + app, "sites", ], }, orderId: { propDefinition: [ - webflow, + app, "orders", ], }, @@ -28,13 +28,10 @@ export default { }, }, async run({ $ }) { - const apiClient = this.webflow._createApiClient(); - - const response = await apiClient.post(`/sites/${this.siteId}/order/${this.orderId}/fulfill`, { - data: { - sendOrderFulfilledEmail: this.sendOrderFulfilledEmail, - }, - }); + const { + app, siteId, orderId, ...data + } = this; + const response = await app.fulfillOrder(siteId, orderId, data); $.export("$summary", "Successfully fulfilled order"); diff --git a/components/webflow/actions/get-collection-item/get-collection-item.mjs b/components/webflow/actions/get-collection-item/get-collection-item.mjs index d4be37ef4ba7e..c5a279f08fd2b 100644 --- a/components/webflow/actions/get-collection-item/get-collection-item.mjs +++ b/components/webflow/actions/get-collection-item/get-collection-item.mjs @@ -1,22 +1,22 @@ -import webflow from "../../webflow.app.mjs"; +import app from "../../webflow.app.mjs"; export default { key: "webflow-get-collection-item", name: "Get Collection Item", - description: "Get a Collection Item. [See the docs here](https://developers.webflow.com/#get-single-item)", - version: "1.0.1", + description: "Get a Collection Item. [See the documentation](https://developers.webflow.com/data/reference/cms/collection-items/staged-items/get-item)", + version: "2.0.0", type: "action", props: { - webflow, + app, siteId: { propDefinition: [ - webflow, + app, "sites", ], }, collectionId: { propDefinition: [ - webflow, + app, "collections", (c) => ({ siteId: c.siteId, @@ -25,7 +25,7 @@ export default { }, itemId: { propDefinition: [ - webflow, + app, "items", (c) => ({ collectionId: c.collectionId, @@ -34,12 +34,7 @@ export default { }, }, async run({ $ }) { - const webflow = this.webflow._createApiClient(); - - const response = await webflow.item({ - collectionId: this.collectionId, - itemId: this.itemId, - }); + const response = await this.app.getCollectionItem(this.collectionId, this.itemId); $.export("$summary", "Successfully retrieved collection item"); diff --git a/components/webflow/actions/get-collection/get-collection.mjs b/components/webflow/actions/get-collection/get-collection.mjs index d0135eafbe484..0bac66a1a2a8d 100644 --- a/components/webflow/actions/get-collection/get-collection.mjs +++ b/components/webflow/actions/get-collection/get-collection.mjs @@ -1,22 +1,22 @@ -import webflow from "../../webflow.app.mjs"; +import app from "../../webflow.app.mjs"; export default { key: "webflow-get-collection", name: "Get Collection", - description: "Get a collection. [See the docs here](https://developers.webflow.com/#get-collection-with-full-schema)", - version: "1.0.1", + description: "Get a collection. [See the documentation](https://developers.webflow.com/data/reference/cms/collections/get)", + version: "2.0.0", type: "action", props: { - webflow, + app, siteId: { propDefinition: [ - webflow, + app, "sites", ], }, collectionId: { propDefinition: [ - webflow, + app, "collections", (c) => ({ siteId: c.siteId, @@ -25,7 +25,7 @@ export default { }, }, async run({ $ }) { - const response = await this.webflow.getCollection(this.collectionId); + const response = await this.app.getCollection(this.collectionId); $.export("$summary", "Successfully retrieved collection"); diff --git a/components/webflow/actions/get-item-inventory/get-item-inventory.mjs b/components/webflow/actions/get-item-inventory/get-item-inventory.mjs index 78b5e6ff85260..cc5f3469efc76 100644 --- a/components/webflow/actions/get-item-inventory/get-item-inventory.mjs +++ b/components/webflow/actions/get-item-inventory/get-item-inventory.mjs @@ -1,22 +1,22 @@ -import webflow from "../../webflow.app.mjs"; +import app from "../../webflow.app.mjs"; export default { key: "webflow-get-item-inventory", name: "Get Item Inventory", - description: "Get the inventory of a specific item. [See the docs here](https://developers.webflow.com/#item-inventory)", - version: "1.0.1", + description: "Get the inventory of a specific item. [See the documentation](https://developers.webflow.com/data/reference/ecommerce/inventory/list)", + version: "2.0.0", type: "action", props: { - webflow, + app, siteId: { propDefinition: [ - webflow, + app, "sites", ], }, collectionId: { propDefinition: [ - webflow, + app, "collections", (c) => ({ siteId: c.siteId, @@ -25,7 +25,7 @@ export default { }, itemId: { propDefinition: [ - webflow, + app, "items", (c) => ({ collectionId: c.collectionId, @@ -34,9 +34,7 @@ export default { }, }, async run({ $ }) { - const apiClient = this.webflow._createApiClient(); - - const response = await apiClient.apiClient.get(`/collections/${this.collectionId}/items/${this.itemId}/inventory`); + const response = await this.app.getCollectionItemInventory(this.collectionId, this.itemId); $.export("$summary", "Successfully retrieved item inventory"); diff --git a/components/webflow/actions/get-order/get-order.mjs b/components/webflow/actions/get-order/get-order.mjs index 2948ae82f5dae..f33a1a1478f06 100644 --- a/components/webflow/actions/get-order/get-order.mjs +++ b/components/webflow/actions/get-order/get-order.mjs @@ -1,31 +1,28 @@ -import webflow from "../../webflow.app.mjs"; +import app from "../../webflow.app.mjs"; export default { key: "webflow-get-order", name: "Get Order", - description: "Get an order. [See the docs here](https://developers.webflow.com/#get-order)", - version: "1.0.1", + description: "Get info on an order. [See the documentation](https://developers.webflow.com/data/reference/ecommerce/orders/get)", + version: "2.0.0", type: "action", props: { - webflow, + app, siteId: { propDefinition: [ - webflow, + app, "sites", ], }, orderId: { propDefinition: [ - webflow, + app, "orders", ], }, }, async run({ $ }) { - const response = await this.webflow.getOrder({ - siteId: this.siteId, - orderId: this.orderId, - }); + const response = await this.app.getOrder(this.siteId, this.orderId); $.export("$summary", "Successfully retrieved order"); diff --git a/components/webflow/actions/get-site/get-site.mjs b/components/webflow/actions/get-site/get-site.mjs index 4e310708e8c67..0f306c77db22e 100644 --- a/components/webflow/actions/get-site/get-site.mjs +++ b/components/webflow/actions/get-site/get-site.mjs @@ -1,22 +1,22 @@ -import webflow from "../../webflow.app.mjs"; +import app from "../../webflow.app.mjs"; export default { key: "webflow-get-site", name: "Get Site", - description: "Get a site. [See the docs here](https://developers.webflow.com/#get-specific-site)", - version: "1.0.1", + description: "Get a site. [See the documentation](https://developers.webflow.com/data/reference/sites/get)", + version: "2.0.0", type: "action", props: { - webflow, + app, siteId: { propDefinition: [ - webflow, + app, "sites", ], }, }, async run({ $ }) { - const response = await this.webflow.getSite(this.siteId); + const response = await this.app.getSite(this.siteId); $.export("$summary", "Successfully retrieved site"); diff --git a/components/webflow/actions/list-collection-items/list-collection-items.mjs b/components/webflow/actions/list-collection-items/list-collection-items.mjs index 57ec9c5dbd4af..eb1bde0e045c9 100644 --- a/components/webflow/actions/list-collection-items/list-collection-items.mjs +++ b/components/webflow/actions/list-collection-items/list-collection-items.mjs @@ -1,22 +1,22 @@ -import webflow from "../../webflow.app.mjs"; +import app from "../../webflow.app.mjs"; export default { key: "webflow-list-collection-items", name: "List Collection Items", - description: "List Items of a collection. [See the docs here](https://developers.webflow.com/#get-all-items-for-a-collection)", - version: "1.0.1", + description: "List Items of a collection. [See the documentation](https://developers.webflow.com/data/reference/cms/collection-items/bulk-items/list-items)", + version: "2.0.0", type: "action", props: { - webflow, + app, siteId: { propDefinition: [ - webflow, + app, "sites", ], }, collectionId: { propDefinition: [ - webflow, + app, "collections", (c) => ({ siteId: c.siteId, @@ -25,9 +25,9 @@ export default { }, }, async run({ $ }) { - const response = await this.webflow.getItems(0, this.collectionId); + const response = await this.app.listCollectionItems(0, this.collectionId); - $.export("$summary", "Successfully retrieved collections items"); + $.export("$summary", "Successfully retrieved collection's items"); return response; }, diff --git a/components/webflow/actions/list-collections/list-collections.mjs b/components/webflow/actions/list-collections/list-collections.mjs index 0e5fed9287618..3b65a5d6b1caa 100644 --- a/components/webflow/actions/list-collections/list-collections.mjs +++ b/components/webflow/actions/list-collections/list-collections.mjs @@ -1,22 +1,22 @@ -import webflow from "../../webflow.app.mjs"; +import app from "../../webflow.app.mjs"; export default { key: "webflow-list-collections", name: "List Collections", - description: "List collections. [See the docs here](https://developers.webflow.com/#list-collections)", - version: "1.0.1", + description: "List collections. [See the documentation](https://developers.webflow.com/data/reference/cms/collections/list)", + version: "2.0.0", type: "action", props: { - webflow, + app, siteId: { propDefinition: [ - webflow, + app, "sites", ], }, }, async run({ $ }) { - const response = await this.webflow.getCollections(this.siteId); + const response = await this.app.listCollections(this.siteId); $.export("$summary", "Successfully retrieved collections"); diff --git a/components/webflow/actions/list-orders/list-orders.mjs b/components/webflow/actions/list-orders/list-orders.mjs index e2babe945fcb2..bba6e64124f20 100644 --- a/components/webflow/actions/list-orders/list-orders.mjs +++ b/components/webflow/actions/list-orders/list-orders.mjs @@ -1,35 +1,35 @@ -import webflow from "../../webflow.app.mjs"; +import app from "../../webflow.app.mjs"; import constants from "../common/constants.mjs"; export default { key: "webflow-list-orders", name: "List Orders", - description: "List orders. [See the docs here](https://developers.webflow.com/#get-all-orders)", - version: "1.0.1", + description: "List orders. [See the documentation](https://developers.webflow.com/data/reference/ecommerce/orders/list)", + version: "2.0.0", type: "action", props: { - webflow, + app, siteId: { propDefinition: [ - webflow, + app, "sites", ], }, status: { label: "Status", - description: "The status to filter the orders.", + description: "If specified, only orders with this status will be listed.", type: "string", options: constants.ORDER_STATUSES, optional: true, }, }, async run({ $ }) { - const response = await this.webflow.getOrders({ - siteId: this.siteId, - status: this.status, - }); + const { + app, ...data + } = this; + const response = await app.listOrders(data); - $.export("$summary", "Successfully retrieved orders"); + $.export("$summary", `Successfully retrieved ${response?.length} orders`); return response; }, diff --git a/components/webflow/actions/list-sites/list-sites.mjs b/components/webflow/actions/list-sites/list-sites.mjs index e653716bdf409..850fad3e4b9a1 100644 --- a/components/webflow/actions/list-sites/list-sites.mjs +++ b/components/webflow/actions/list-sites/list-sites.mjs @@ -1,16 +1,16 @@ -import webflow from "../../webflow.app.mjs"; +import app from "../../webflow.app.mjs"; export default { key: "webflow-list-sites", name: "List Sites", - description: "List sites. [See the docs here](https://developers.webflow.com/#list-sites)", - version: "1.0.1", + description: "List sites. [See the documentation](https://developers.webflow.com/data/reference/sites/list)", + version: "2.0.0", type: "action", props: { - webflow, + app, }, async run({ $ }) { - const response = await this.webflow.getSites(); + const response = await this.app.listSites(); $.export("$summary", "Successfully retrieved sites"); diff --git a/components/webflow/actions/publish-site/publish-site.mjs b/components/webflow/actions/publish-site/publish-site.mjs index b1f5c49a8afec..3a55cdec20a51 100644 --- a/components/webflow/actions/publish-site/publish-site.mjs +++ b/components/webflow/actions/publish-site/publish-site.mjs @@ -1,22 +1,22 @@ -import webflow from "../../webflow.app.mjs"; +import app from "../../webflow.app.mjs"; export default { key: "webflow-publish-site", name: "Publish Site", - description: "Get a site in a specific domain. [See the docs here](https://developers.webflow.com/#publish-site)", - version: "1.0.1", + description: "Publish a site. [See the documentation](https://developers.webflow.com/data/reference/sites/publish)", + version: "2.0.0", type: "action", props: { - webflow, + app, siteId: { propDefinition: [ - webflow, + app, "sites", ], }, domains: { propDefinition: [ - webflow, + app, "domains", (c) => ({ siteId: c.siteId, @@ -25,12 +25,7 @@ export default { }, }, async run({ $ }) { - const webflow = this.webflow._createApiClient(); - - const response = await webflow.publishSite({ - siteId: this.siteId, - domains: this.domains, - }); + const response = await this.app.publishSite(this.siteId, this.domains); $.export("$summary", "Successfully published site"); diff --git a/components/webflow/actions/refund-order/refund-order.mjs b/components/webflow/actions/refund-order/refund-order.mjs index dbee65a634e93..b35dcd6f9d5d6 100644 --- a/components/webflow/actions/refund-order/refund-order.mjs +++ b/components/webflow/actions/refund-order/refund-order.mjs @@ -1,30 +1,28 @@ -import webflow from "../../webflow.app.mjs"; +import app from "../../webflow.app.mjs"; export default { key: "webflow-refund-order", name: "Refund Order", - description: "Refund an order. [See the docs here](https://developers.webflow.com/#refund-order)", - version: "1.0.1", + description: "Refund an order. [See the documentation](https://developers.webflow.com/data/reference/ecommerce/orders/refund)", + version: "2.0.0", type: "action", props: { - webflow, + app, siteId: { propDefinition: [ - webflow, + app, "sites", ], }, orderId: { propDefinition: [ - webflow, + app, "orders", ], }, }, async run({ $ }) { - const apiClient = this.webflow._createApiClient(); - - const response = apiClient.get(`/sites/${this.siteId}/order/${this.orderId}/refund`); + const response = await this.app.refundOrder(this.siteId, this.orderId); $.export("$summary", "Successfully refunded order"); diff --git a/components/webflow/actions/unfulfill-order/unfulfill-order.mjs b/components/webflow/actions/unfulfill-order/unfulfill-order.mjs index dba68fefee817..af4bbfafe859a 100644 --- a/components/webflow/actions/unfulfill-order/unfulfill-order.mjs +++ b/components/webflow/actions/unfulfill-order/unfulfill-order.mjs @@ -1,30 +1,28 @@ -import webflow from "../../webflow.app.mjs"; +import app from "../../webflow.app.mjs"; export default { key: "webflow-unfulfill-order", name: "Unfulfill Order", - description: "Unfulfill an order. [See the docs here](https://developers.webflow.com/#unfulfill-order)", - version: "1.0.1", + description: "Unfulfill an order. [See the documentation](https://developers.webflow.com/data/reference/ecommerce/orders/update-unfulfill)", + version: "2.0.0", type: "action", props: { - webflow, + app, siteId: { propDefinition: [ - webflow, + app, "sites", ], }, orderId: { propDefinition: [ - webflow, + app, "orders", ], }, }, async run({ $ }) { - const apiClient = this.webflow._createApiClient(); - - const response = apiClient.post(`/sites/${this.siteId}/order/${this.orderId}/unfulfill`); + const response = await this.app.unfulfillOrder(this.siteId, this.orderId); $.export("$summary", "Successfully unfulfilled order"); diff --git a/components/webflow/actions/update-collection-item/update-collection-item.mjs b/components/webflow/actions/update-collection-item/update-collection-item.mjs index 0830552cad05e..e1c980d96c23f 100644 --- a/components/webflow/actions/update-collection-item/update-collection-item.mjs +++ b/components/webflow/actions/update-collection-item/update-collection-item.mjs @@ -1,37 +1,38 @@ -import webflow from "../../webflow.app.mjs"; +import app from "../../webflow.app.mjs"; export default { key: "webflow-update-collection-item", name: "Update Collection Item", - description: "Update collection item. [See the documentation](https://developers.webflow.com/#update-collection-item)", - version: "1.0.1", + description: + "Update collection item. [See the documentation](https://developers.webflow.com/data/reference/cms/collection-items/bulk-items/update-items)", + version: "2.0.0", type: "action", props: { - webflow, + app, siteId: { propDefinition: [ - webflow, + app, "sites", ], }, collectionId: { propDefinition: [ - webflow, + app, "collections", (c) => ({ siteId: c.siteId, }), ], - reloadProps: true, }, itemId: { propDefinition: [ - webflow, + app, "items", (c) => ({ collectionId: c.collectionId, }), ], + reloadProps: true, }, }, async additionalProps() { @@ -39,17 +40,22 @@ export default { if (!this.collectionId) { return props; } - const { fields } = await this.webflow.getCollection(this.collectionId); + const { fields } = await this.app.getCollection(this.collectionId); for (const field of fields) { - if (field.editable && field.slug !== "_archived" && field.slug !== "_draft") { + if ( + field.isEditable && + field.slug !== "isArchived" && + field.slug !== "isDraft" + ) { props[field.slug] = { type: "string", label: field.name, - description: field.slug === "name" - ? "Name given to the Item." - : field.slug === "slug" - ? "URL structure of the Item in your site. Note: Updates to an item slug will break all links referencing the old slug." - : "See the documentation for additional information about [Field Types & Item Values](https://developers.webflow.com/reference/field-types-item-values).", + description: + field.slug === "name" + ? "Name given to the Item." + : field.slug === "slug" + ? "URL structure of the Item in your site. Note: Updates to an item slug will break all links referencing the old slug." + : "See the documentation for additional information about [Field Types & Item Values](https://developers.webflow.com/reference/field-types-item-values).", optional: true, }; } @@ -59,7 +65,7 @@ export default { }, async run({ $ }) { const { - webflow, + app, // eslint-disable-next-line no-unused-vars siteId, collectionId, @@ -69,21 +75,17 @@ export default { ...customFields } = this; - const webflowClient = webflow._createApiClient(); - - const item = await webflowClient.item({ - collectionId, - itemId, - }); + const item = await app.getCollectionItem(collectionId, itemId); - const response = await webflowClient.updateItem({ - collectionId, - itemId, - name: name || item.name, - slug: slug || item.slug, - _archived: false, - _draft: false, - ...customFields, + const response = await app.updateCollectionItem(collectionId, itemId, { + id: itemId, + isArchived: false, + isDraft: false, + fieldData: { + ...customFields, + name: name || item.fieldData.name, + slug: slug || item.fieldData.slug, + }, }); $.export("$summary", "Successfully updated collection item"); diff --git a/components/webflow/actions/update-item-inventory/update-item-inventory.mjs b/components/webflow/actions/update-item-inventory/update-item-inventory.mjs index 2bebbfca35a0c..dff9dfa1a9114 100644 --- a/components/webflow/actions/update-item-inventory/update-item-inventory.mjs +++ b/components/webflow/actions/update-item-inventory/update-item-inventory.mjs @@ -1,22 +1,22 @@ -import webflow from "../../webflow.app.mjs"; +import app from "../../webflow.app.mjs"; export default { key: "webflow-update-item-inventory", name: "Update Item Inventory", - description: "Update the inventory of a specific item. [See the docs here](https://developers.webflow.com/#update-item-inventory)", - version: "1.0.1", + description: "Update the inventory of a specific item. [See the documentation](https://developers.webflow.com/data/reference/ecommerce/inventory/update)", + version: "0.0.5", type: "action", props: { - webflow, + app, siteId: { propDefinition: [ - webflow, + app, "sites", ], }, collectionId: { propDefinition: [ - webflow, + app, "collections", (c) => ({ siteId: c.siteId, @@ -25,7 +25,7 @@ export default { }, itemId: { propDefinition: [ - webflow, + app, "items", (c) => ({ collectionId: c.collectionId, @@ -43,35 +43,28 @@ export default { }, quantity: { label: "Quantity", - description: "The quantity will be seted with this value. This just can be used with `finite` option selected and without `updateQuantity` value.", + description: "If specified, sets quantity to this value. Can only be used with the `finite` inventory type, and if `Update Quantity` is not specified.", type: "integer", optional: true, }, updateQuantity: { label: "Update Quantity", - description: "This value will be added to the quantity. This just can be used with `finite` option selected and without `quantity` value.", + description: "If specified, adds this value to the current quantity. Can only be used with the `finite` inventory type, and if `Quantity` is not specified.", type: "integer", optional: true, }, }, async run({ $ }) { - const apiClient = this.webflow._createApiClient(); - const { - inventoryType, - quantity, - updateQuantity, + app, + // eslint-disable-next-line no-unused-vars + siteId, + collectionId, + itemId, + ...data } = this; - const response = await apiClient.patch(`/collections/${this.collectionId}/items/${this.itemId}/inventory`, { - data: { - fields: { - inventoryType, - quantity, - updateQuantity, - }, - }, - }); + const response = await app.updateCollectionItemInventory(collectionId, itemId, data); $.export("$summary", "Successfully updated item inventory"); diff --git a/components/webflow/actions/update-order/update-order.mjs b/components/webflow/actions/update-order/update-order.mjs index 935465835b200..10bd3c2b2ecc9 100644 --- a/components/webflow/actions/update-order/update-order.mjs +++ b/components/webflow/actions/update-order/update-order.mjs @@ -1,22 +1,22 @@ -import webflow from "../../webflow.app.mjs"; +import app from "../../webflow.app.mjs"; export default { key: "webflow-update-order", name: "Update Order", - description: "Update an order. [See the docs here](https://developers.webflow.com/#update-order)", - version: "1.0.1", + description: "Update an order. [See the documentation](https://developers.webflow.com/data/reference/ecommerce/orders/update)", + version: "2.0.0", type: "action", props: { - webflow, + app, siteId: { propDefinition: [ - webflow, + app, "sites", ], }, orderId: { propDefinition: [ - webflow, + app, "orders", ], }, @@ -40,23 +40,11 @@ export default { }, }, async run({ $ }) { - const apiClient = this.webflow._createApiClient(); - const { - comment, - shippingProvider, - shippingTracking, + app, siteId, orderId, ...data } = this; - const response = await apiClient.post(`/sites/${this.siteId}/order/${this.orderId}`, { - data: { - fields: { - comment, - shippingProvider, - shippingTracking, - }, - }, - }); + const response = await app.updateOrder(siteId, orderId, data); $.export("$summary", "Successfully updated order"); diff --git a/components/webflow/package.json b/components/webflow/package.json index 779c3dfbf19d7..3d396544cca56 100644 --- a/components/webflow/package.json +++ b/components/webflow/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/webflow", - "version": "0.4.7", + "version": "1.0.0", "description": "Pipedream Webflow Components", "main": "webflow.app.mjs", "keywords": [ @@ -10,10 +10,9 @@ "homepage": "https://pipedream.com/apps/webflow", "author": "Pipedream (https://pipedream.com/)", "dependencies": { - "@pipedream/platform": "^1.1.0", - "webflow-api": "1.3.1" + "@pipedream/platform": "^3.0.3", + "webflow-api": "2.4.2" }, - "gitHead": "e12480b94cc03bed4808ebc6b13e7fdb3a1ba535", "publishConfig": { "access": "public" } diff --git a/components/webflow/sources/changed-collection-item/changed-collection-item.mjs b/components/webflow/sources/changed-collection-item/changed-collection-item.mjs index a88658349b030..6506124f24a01 100644 --- a/components/webflow/sources/changed-collection-item/changed-collection-item.mjs +++ b/components/webflow/sources/changed-collection-item/changed-collection-item.mjs @@ -1,11 +1,11 @@ -import common from "../common/collection-common.mjs"; +import common from "../common/common.mjs"; export default { type: "source", key: "webflow-changed-collection-item", - name: "New Changed Collection Item", - description: "Emit new event when a collection item is changed. [See the docs here](https://developers.webflow.com/#model16)", - version: "1.0.1", + name: "Collection Item Updated", + description: "Emit new event when a collection item is changed. [See the documentation](https://developers.webflow.com/data/reference/webhooks/events/collection-item-changed)", + version: "2.0.0", ...common, methods: { ...common.methods, @@ -13,11 +13,14 @@ export default { return "collection_item_changed"; }, generateMeta(data) { - const ts = Date.parse(data["updated-on"]); + const { + id, fieldData, lastUpdated, + } = data; + const ts = Date.parse(lastUpdated); return { - id: `${data._id}-${ts}`, - summary: `Collection ${data.slug} item changed`, + id: `${id}-${ts}`, + summary: `Item updated: ${fieldData?.slug ?? fieldData?.name ?? id}`, ts, }; }, diff --git a/components/webflow/sources/changed-ecommerce-inventory/changed-ecommerce-inventory.mjs b/components/webflow/sources/changed-ecommerce-inventory/changed-ecommerce-inventory.mjs index 8da3bfe3d4ea3..60fc751434fbf 100644 --- a/components/webflow/sources/changed-ecommerce-inventory/changed-ecommerce-inventory.mjs +++ b/components/webflow/sources/changed-ecommerce-inventory/changed-ecommerce-inventory.mjs @@ -3,9 +3,9 @@ import common from "../common/common.mjs"; export default { type: "source", key: "webflow-changed-ecommerce-inventory", - name: "New Changed E-commerce Inventory", - description: "Emit new event when an e-commerce inventory level changes. [See the docs here](https://developers.webflow.com/#item-inventory)", - version: "1.0.1", + name: "E-commerce Inventory Updated", + description: "Emit new event when an e-commerce inventory level changes. [See the documentation](https://developers.webflow.com/data/reference/webhooks/events/ecomm-inventory-changed)", + version: "2.0.0", ...common, methods: { ...common.methods, @@ -13,12 +13,13 @@ export default { return "ecomm_inventory_changed"; }, generateMeta(data) { - const now = Date.now(); + const ts = Date.now(); + const { id } = data; return { - id: `${data._id}-${now}`, - summary: `E-commerce ${data._id} inventory changed`, - ts: now, + id: `${id}-${ts}`, + summary: `E-comm inventory updated: ${id}`, + ts, }; }, }, diff --git a/components/webflow/sources/changed-ecommerce-order/changed-ecommerce-order.mjs b/components/webflow/sources/changed-ecommerce-order/changed-ecommerce-order.mjs index 567a1a50f46bc..c54f17dd383f5 100644 --- a/components/webflow/sources/changed-ecommerce-order/changed-ecommerce-order.mjs +++ b/components/webflow/sources/changed-ecommerce-order/changed-ecommerce-order.mjs @@ -3,22 +3,21 @@ import common from "../common/common.mjs"; export default { type: "source", key: "webflow-changed-ecommerce-order", - name: "New Changed E-commerce Order", - description: "Emit new event when an e-commerce order is changed. [See the docs here](https://developers.webflow.com/#order-model)", - version: "1.0.1", + name: "E-commerce Order Updated", + description: "Emit new event when an e-commerce order is changed. [See the documentation](https://developers.webflow.com/data/reference/webhooks/events/ecomm-order-changed)", + version: "2.0.0", ...common, methods: { ...common.methods, getWebhookTriggerType() { return "ecomm_order_changed"; }, - generateMeta(data) { - const now = Date.now(); - + generateMeta({ orderId }) { + const ts = Date.now(); return { - id: `${data.orderId}-${now}`, - summary: `E-commerce order ${data.orderId} changed`, - ts: now, + id: `${orderId}-${ts}`, + summary: `E-comm order updated: ${orderId}`, + ts, }; }, }, diff --git a/components/webflow/sources/common/common.mjs b/components/webflow/sources/common/common.mjs index 8bbc816812e0f..880a0ea6fadc2 100644 --- a/components/webflow/sources/common/common.mjs +++ b/components/webflow/sources/common/common.mjs @@ -1,15 +1,14 @@ -import webflow from "../../webflow.app.mjs"; +import app from "../../webflow.app.mjs"; import { v4 as uuid } from "uuid"; -import { axios } from "@pipedream/platform"; import constants from "../../common/constants.mjs"; export default { dedupe: "unique", props: { - webflow, + app, siteId: { propDefinition: [ - webflow, + app, "sites", ], }, @@ -17,16 +16,6 @@ export default { http: "$.interface.http", }, methods: { - async _makeRequest(path, params = {}) { - return axios(this, { - url: "https://api.webflow.com" + path, - headers: { - "Authorization": `Bearer ${this.webflow.$auth.oauth_access_token}`, - "Accept-Version": "1.0.0", - }, - params, - }); - }, _getWebhookId() { return this.db.get("webhookId"); }, @@ -36,12 +25,6 @@ export default { getWebhookTriggerType() { throw new Error("getWebhookTriggerType is not implemented"); }, - getWebhookFilter() { - return {}; - }, - isEventRelevant(event) { - if (event) return true; - }, generateMeta(data) { return { id: data.id || uuid(), @@ -50,13 +33,9 @@ export default { }; }, processEvent(event) { - if (!this.isEventRelevant(event)) { - return; - } - - const { body } = event; - const meta = this.generateMeta(body); - this.$emit(body, meta); + const { body: { payload } } = event; + const meta = this.generateMeta(payload); + this.$emit(payload, meta); }, emitHistoricalEvents(events, limit = constants.DEPLOY_OFFSET) { for (const event of events.slice(0, limit)) { @@ -67,18 +46,15 @@ export default { }, hooks: { async activate() { - const { endpoint } = this.http; - const triggerType = this.getWebhookTriggerType(); - const filter = this.getWebhookFilter(); - const webhook = await this.webflow.createWebhook( - this.siteId, endpoint, triggerType, filter, - ); + const webhook = await this.app.createWebhook(this.siteId, { + url: this.http.endpoint, + triggerType: this.getWebhookTriggerType(), + }); - this._setWebhookId(webhook._id); + this._setWebhookId(webhook?.id); }, async deactivate() { - const webhookId = this._getWebhookId(); - await this.webflow.removeWebhook(this.siteId, webhookId); + await this.app.removeWebhook(this._getWebhookId()); }, }, async run(event) { diff --git a/components/webflow/sources/new-collection-item/new-collection-item.mjs b/components/webflow/sources/new-collection-item/new-collection-item.mjs index b5bbb5e50513c..259286fad8250 100644 --- a/components/webflow/sources/new-collection-item/new-collection-item.mjs +++ b/components/webflow/sources/new-collection-item/new-collection-item.mjs @@ -1,56 +1,25 @@ -import constants from "../../common/constants.mjs"; -import common from "../common/collection-common.mjs"; +import common from "../common/common.mjs"; export default { type: "source", key: "webflow-new-collection-item", - name: "New Collection Item", - description: "Emit new event when a collection item is created. [See the docs here](https://developers.webflow.com/#item-model)", - version: "1.0.1", + name: "New Collection Item Created", + description: "Emit new event when a collection item is created. [See the documentation](https://developers.webflow.com/data/reference/webhooks/events/collection-item-created)", + version: "2.0.0", ...common, - hooks: { - ...common.hooks, - async deploy() { - if (this.collectionIds?.length !== 1) { - console.log("Skipping retrieval of historical events for multiple or no Collection ID"); - return; - } - - const path = `/collections/${this.collectionIds[0]}/items`; - console.log("Retrieving historical events..."); - - let { - total, - items: events, - } = await this._makeRequest(path); - - if (total > constants.LIMIT) { - const offset = Math.floor(total / constants.LIMIT); - - events = (await this._makeRequest(path, { - offset, - })).items.reverse(); - - events.push(...(await this._makeRequest(path, { - offset: offset - 1, - })).items.reverse()); - } else { - events.reverse(); - } - - this.emitHistoricalEvents(events); - }, - }, methods: { ...common.methods, getWebhookTriggerType() { return "collection_item_created"; }, generateMeta(data) { + const { + id, fieldData, + } = data; return { - id: data._id, - summary: `New collection item ${data.slug} created`, - ts: Date.parse(data["created-on"]), + id, + summary: `New item: ${fieldData?.slug ?? fieldData?.name ?? id}`, + ts: Date.parse(data["createdOn"]), }; }, }, diff --git a/components/webflow/sources/new-deleted-collection-item/new-deleted-collection-item.mjs b/components/webflow/sources/new-deleted-collection-item/new-deleted-collection-item.mjs index 142eab18ac0a3..529d6cddb94e3 100644 --- a/components/webflow/sources/new-deleted-collection-item/new-deleted-collection-item.mjs +++ b/components/webflow/sources/new-deleted-collection-item/new-deleted-collection-item.mjs @@ -3,9 +3,9 @@ import common from "../common/common.mjs"; export default { type: "source", key: "webflow-new-deleted-collection-item", - name: "New Deleted Collection Item", - description: "Emit new event when a collection item is deleted. [See the docs here](https://developers.webflow.com/#item-model)", - version: "1.0.1", + name: "Collection Item Deleted", + description: "Emit new event when a collection item is deleted. [See the documentation](https://developers.webflow.com/data/reference/webhooks/events/collection-item-deleted)", + version: "2.0.0", ...common, methods: { ...common.methods, @@ -13,10 +13,11 @@ export default { return "collection_item_deleted"; }, generateMeta(data) { + const { id } = data; return { - id: data.itemId, - summary: `Collection item ${data.itemId} deleted.`, - ts: Date.parse(data["created-on"]), + id, + summary: `Item deleted: ${id}`, + ts: Date.now(), }; }, }, diff --git a/components/webflow/sources/new-ecommerce-order/new-ecommerce-order.mjs b/components/webflow/sources/new-ecommerce-order/new-ecommerce-order.mjs index 3ee5a250b4eb7..0fb8a407b33f3 100644 --- a/components/webflow/sources/new-ecommerce-order/new-ecommerce-order.mjs +++ b/components/webflow/sources/new-ecommerce-order/new-ecommerce-order.mjs @@ -4,63 +4,21 @@ export default { type: "source", key: "webflow-new-ecommerce-order", name: "New E-commerce Order", - description: "Emit new event when an e-commerce order is created. [See the docs here](https://developers.webflow.com/#order-model)", - version: "1.0.1", + description: + "Emit new event when an e-commerce order is created. [See the documentation](https://developers.webflow.com/data/reference/webhooks/events/ecomm-new-order)", + version: "2.0.0", ...common, - props: { - ...common.props, - historicalEventsNumber: { - type: "integer", - label: "Number of Historical Events to Emit", - description: "Defaults to `0`. Number of historical events to fetch and emit. Maximum is `100`.", - optional: true, - default: 0, - min: 0, - max: 100, - }, - emitMostRecent: { - type: "boolean", - label: "Emit Most Recent Events", - description: "Defaults to `false`. **Warning**: if `true`, will need to request all orders to extract the most recent ones.", - default: false, - }, - }, hooks: { ...common.hooks, async deploy() { - if (!this.historicalEventsNumber) { - return; - } - - const path = `/sites/${this.siteId}/orders`; + const { siteId } = this; console.log("Retrieving historical events..."); - if (!this.emitMostRecent) { - const events = await this._makeRequest(path, { - limit: this.historicalEventsNumber, - }); - this.emitHistoricalEvents(events); - return; - } - - let toEmit = []; - let events = []; - const params = { - offset: 0, - }; - - do { - events = await this._makeRequest(path, params); - - if (toEmit.push(...events) > 100) { - toEmit = toEmit.slice(toEmit.length - 100, toEmit.length); - } - - params.offset += 1; - } while (events.length > 0); - - toEmit.reverse(); - this.emitHistoricalEvents(toEmit, this.historicalEventsNumber); + const events = await this.app.listOrders({ + siteId, + limit: 10, + }); + this.emitHistoricalEvents(events); }, }, methods: { diff --git a/components/webflow/sources/new-form-submission/new-form-submission.mjs b/components/webflow/sources/new-form-submission/new-form-submission.mjs index ca0aa503b6fb7..2465374dd2f28 100644 --- a/components/webflow/sources/new-form-submission/new-form-submission.mjs +++ b/components/webflow/sources/new-form-submission/new-form-submission.mjs @@ -5,8 +5,8 @@ export default { type: "source", key: "webflow-new-form-submission", name: "New Form Submission", - description: "Emit new event when a new form is submitted. [See the docs here](https://developers.webflow.com/#trigger-types)", - version: "1.0.1", + description: "Emit new event when a form is submitted. [See the documentation](https://developers.webflow.com/data/reference/webhooks/events/form-submission)", + version: "2.0.0", ...common, methods: { ...common.methods, @@ -14,10 +14,13 @@ export default { return "form_submission"; }, generateMeta(data) { + const { + name, id, submittedAt, + } = data; return { - id: data._id, - summary: `New form ${data._id} submission`, - ts: Date.parse(data.date), + id, + summary: `Form submitted: ${name ?? id}`, + ts: Date.parse(submittedAt), }; }, }, diff --git a/components/webflow/sources/new-site-published/new-site-published.mjs b/components/webflow/sources/new-site-published/new-site-published.mjs index 0a50480411979..92ad1006b87ae 100644 --- a/components/webflow/sources/new-site-published/new-site-published.mjs +++ b/components/webflow/sources/new-site-published/new-site-published.mjs @@ -1,44 +1,24 @@ -import constants from "../../common/constants.mjs"; import common from "../common/common.mjs"; export default { type: "source", key: "webflow-new-site-published", - name: "New Site Published", - description: "Emit new event when a site is published. [See the docs here](https://developers.webflow.com/#trigger-types)", - version: "1.0.1", + name: "Site Published", + description: "Emit new event when a site is published. [See the documentation](https://developers.webflow.com/data/reference/webhooks/events/site-publish)", + version: "2.0.0", ...common, - hooks: { - ...common.hooks, - async deploy() { - console.log("Retrieving historical events..."); - - const sites = await this._makeRequest("/sites", { - limit: this.historicalEventsNumber, - }); - - const filtered = sites.filter((site) => site.lastPublished); - const sliced = filtered.slice( - filtered.length - constants.DEPLOY_OFFSET, - constants.DEPLOY_OFFSET, - ); - const sorted = sliced.sort((a, b) => Date.parse(a.lastPublished) > Date.parse(b.lastPublished) - ? -1 - : 1); - - this.emitHistoricalEvents(sorted); - }, - }, methods: { ...common.methods, getWebhookTriggerType() { return "site_publish"; }, - generateMeta(data) { + generateMeta({ + siteId, publishedOn, + }) { return { - id: `${data.site}-${data.publishTime}`, - summary: `The site ${data.site} has been published.`, - ts: data.publishTime, + id: `${siteId}-${publishedOn}`, + summary: `Site published: ${siteId}`, + ts: Date.parse(publishedOn), }; }, }, diff --git a/components/webflow/webflow.app.mjs b/components/webflow/webflow.app.mjs index 74375c31d64f0..e604219812030 100644 --- a/components/webflow/webflow.app.mjs +++ b/components/webflow/webflow.app.mjs @@ -1,7 +1,4 @@ -// Webflow version support here: https://www.npmjs.com/package/webflow-api?activeTab=versions -// @note: this is pinned to Webflow 1.3.1 -// because the upgrade to version 2 requires a new app -import Webflow from "webflow-api@1.3.1"; +import { WebflowClient } from "webflow-api"; import constants from "./common/constants.mjs"; export default { @@ -9,64 +6,66 @@ export default { app: "webflow", propDefinitions: { domains: { - label: "Domain", - description: "The list of domains.", + label: "Custom Domains", + description: "Select one or more custom domains to publish.", type: "string[]", async options({ siteId }) { - const domains = await this.getDomains(siteId); - - return domains.map((domain) => domain.name); + const domains = await this.listDomains(siteId); + return domains.map((id, url) => ({ + label: url, + id, + })); }, }, sites: { label: "Site", - description: "The list of sites", + description: "Select a site or provide a custom site ID.", type: "string", async options() { - const sites = await this.getSites(); + const sites = await this.listSites(); return sites.map((site) => ({ - label: site.name, - value: site._id, + label: site.displayName || site.shortName, + value: site.id, })); }, }, collections: { label: "Collection", - description: "The list of collection of a site", + description: "Select a collection or provide a custom collection ID.", type: "string", async options({ siteId }) { - const collections = await this.getCollections(siteId); + const collections = await this.listCollections(siteId); return collections.map((collection) => ({ - label: collection.name, - value: collection._id, + label: collection.displayName || collection.slug, + value: collection.id, })); }, }, items: { label: "Item", - description: "The list of items of a collection", + description: "Select an item or provide a custom item ID.", type: "string", async options({ collectionId, page, }) { - const items = await this.getItems(page, collectionId); + const items = await this.listCollectionItems(page, collectionId); return items.map((item) => ({ - label: item.name, - value: item._id, + label: item.fieldData?.name || item.fieldData?.slug, + value: item.id, })); }, }, orders: { label: "Order", - description: "The list of orders of a site", + description: "Select an order, or provide a custom order ID.", type: "string", async options({ siteId, page, }) { - const items = await this.getOrders({ + const items = await this.listOrders({ page, siteId, }); @@ -76,179 +75,96 @@ export default { }, }, methods: { - /** - * Get the auth access token; - * - * @returns {string} The base auth access token. - */ _authToken() { return this.$auth.oauth_access_token; }, - /** - * Create a Webflow API client; - * - * @returns {params} The Webflow API client. - */ - _createApiClient() { - return new Webflow({ - token: this._authToken(), + webflowClient() { + return new WebflowClient({ + accessToken: this._authToken(), }); }, - /** - * Create a Webflow webhook; - * - * @param {siteId} ID of the site to be monitored. - * @param {url} URL to webhook return. - * @param {triggerType} Type of event that will be triggered. - * @param {filter} Filters to be applied in webhook. - * - * @returns {params} The Webflow webhook. - */ - async createWebhook(siteId, url, triggerType, filter = {}) { - const apiClient = this._createApiClient(); - - return apiClient.createWebhook({ - siteId, - triggerType, - url, - filter, - }); + async createWebhook(siteId, data) { + return this.webflowClient().webhooks.create(siteId, data); }, - /** - * Remove a Webflow webhook; - * - * @param {siteId} ID of the site. - * @param {webhookId} ID of the webhook. - */ - async removeWebhook(siteId, webhookId) { - const apiClient = this._createApiClient(); - return apiClient.removeWebhook({ - siteId, - webhookId, - }); + async removeWebhook(webhookId) { + return this.webflowClient().webhooks.delete(webhookId); }, - /** - * Get an order; - * - * @param {options} Options to filter the order. - * - * @returns {params} An order. - */ - async getOrder({ - siteId, orderId, - }) { - const apiClient = this._createApiClient(); - - return apiClient.get(`/sites/${siteId}/order/${orderId}`); - }, - /** - * Get a list of orders; - * - * @param {options} Options to filter the orders. - * - * @returns {params} A list of orders. - */ - async getOrders({ - page, siteId, status, + async getOrder(siteId, orderId) { + return this.webflowClient().orders.get(siteId, orderId); + }, + async listOrders({ + page: offset = 0, siteId, status, }) { - const apiClient = this._createApiClient(); - - return apiClient.get(`/sites/${siteId}/orders`, { - status: status, - offset: page ?? 0, - limit: constants.LIMIT, + const response = await this.webflowClient().orders.list(siteId, { + offset, + status, }); + return response?.orders; }, - /** - * Get a list of domains; - * - * @param {options} Options to filter the domains. - * - * @returns {params} A list of domains. - */ - async getDomains(siteId) { - const webflow = this._createApiClient(); - - return await webflow.domains({ - siteId, - }); + async listDomains(siteId) { + const response = await this.webflowClient().sites.getCustomDomain(siteId); + return response?.customDomains; }, - /** - * Get a site; - * - * @param {options} Options to filter the site. - * - * @returns {params} A site. - */ - async getSite(siteId) { - const webflow = this._createApiClient(); - - return await webflow.site({ - siteId, - }); + getSite(siteId) { + return this.webflowClient().sites.get(siteId); }, - /** - * Get a list of sites; - * - * @param {options} Options to filter the sites. - * - * @returns {params} A list of sites. - */ - async getSites() { - const webflow = this._createApiClient(); - - return await webflow.sites(); - }, - /** - * Get a collection; - * - * @param {options} Options to filter the collection. - * - * @returns {params} A collection. - */ - async getCollection(collectionId) { - const webflow = this._createApiClient(); - - return await webflow.collection({ - collectionId, - }); + async listSites() { + const response = await this.webflowClient().sites.list(); + return response?.sites; }, - /** - * Get a list of collections; - * - * @param {options} Options to filter the collections. - * - * @returns {params} A list of collections. - */ - async getCollections(siteId) { - const webflow = this._createApiClient(); - + getCollection(collectionId) { + return this.webflowClient().collections.get(collectionId); + }, + async listCollections(siteId) { if (!siteId) return []; - return await webflow.collections({ - siteId: siteId, - }); + const response = await this.webflowClient().collections.list(siteId); + return response?.collections; }, - /** - * Get a list of items; - * - * @param {options} Options to filter the items. - * - * @returns {params} A list of items. - */ - async getItems(page = 0, collectionId) { - const webflow = this._createApiClient(); - + async listCollectionItems(page = 0, collectionId) { if (!collectionId) return []; - const response = await webflow.items({ - collectionId, - }, { + const response = await this.webflowClient().collections.items.listItems(collectionId, { limit: constants.LIMIT, offset: page, }); - return response; + return response?.items; + }, + getCollectionItem(collectionId, itemId) { + return this.webflowClient().collections.items.getItem(collectionId, itemId); + }, + deleteCollectionItem(collectionId, itemId) { + return this.webflowClient().collections.items.deleteItem(collectionId, itemId); + }, + createCollectionItem(collectionId, data) { + return this.webflowClient().collections.items.createItem(collectionId, data); + }, + updateCollectionItem(collectionId, itemId, data) { + return this.webflowClient().collections.items.updateItem(collectionId, itemId, data); + }, + getCollectionItemInventory(collectionId, itemId) { + return this.webflowClient().inventory.list(collectionId, itemId); + }, + updateCollectionItemInventory(collectionId, itemId, data) { + return this.webflowClient().inventory.update(collectionId, itemId, data); + }, + publishSite(siteId, customDomains) { + return this.webflowClient().sites.publish(siteId, { + customDomains, + }); + }, + fulfillOrder(siteId, orderId, data) { + return this.webflowClient().orders.updateFulfill(siteId, orderId, data); + }, + unfulfillOrder(siteId, orderId) { + return this.webflowClient().orders.updateUnfulfill(siteId, orderId); + }, + refundOrder(siteId, orderId) { + return this.webflowClient().orders.refund(siteId, orderId); + }, + updateOrder(siteId, orderId, data) { + return this.webflowClient().orders.update(siteId, orderId, data); }, }, }; diff --git a/components/webflow_v2/package.json b/components/webflow_v2/package.json deleted file mode 100644 index 9ea5fe8b75feb..0000000000000 --- a/components/webflow_v2/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "@pipedream/webflow_v2", - "version": "0.0.1", - "description": "Pipedream Webflow (v2) Components", - "main": "webflow_v2.app.mjs", - "keywords": [ - "pipedream", - "webflow_v2" - ], - "homepage": "https://pipedream.com/apps/webflow_v2", - "author": "Pipedream (https://pipedream.com/)", - "publishConfig": { - "access": "public" - } -} \ No newline at end of file diff --git a/components/webflow_v2/webflow_v2.app.mjs b/components/webflow_v2/webflow_v2.app.mjs deleted file mode 100644 index 2773a1f8c4584..0000000000000 --- a/components/webflow_v2/webflow_v2.app.mjs +++ /dev/null @@ -1,11 +0,0 @@ -export default { - type: "app", - app: "webflow_v2", - propDefinitions: {}, - methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); - }, - }, -}; \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 641f9a8ec00c3..c65ed8856699b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11315,13 +11315,11 @@ importers: components/webflow: dependencies: '@pipedream/platform': - specifier: ^1.1.0 - version: 1.6.6 + specifier: ^3.0.3 + version: 3.0.3 webflow-api: - specifier: 1.3.1 - version: 1.3.1 - - components/webflow_v2: {} + specifier: 2.4.2 + version: 2.4.2 components/webinarfuel: {} @@ -23776,8 +23774,8 @@ packages: resolution: {integrity: sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==} engines: {node: '>= 8'} - webflow-api@1.3.1: - resolution: {integrity: sha512-ij/Y7t7VqeS2doOhHaCSToKkZeItFwkgCS003mqbG6d51eUmihcJ2ri4SOiR3zTxmUYZO+sg1sF+aAqsY7tgiA==} + webflow-api@2.4.2: + resolution: {integrity: sha512-+znE6V6E6YULwZIGIk8NLFZaimGFH7xVEAjCeivHz4gV13Zcg4FRXyhWxxTHnOYBwKjcjDoaWl8ZK1H9mUA5mQ==} webidl-conversions@3.0.1: resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} @@ -39991,11 +39989,17 @@ snapshots: web-streams-polyfill@3.3.3: {} - webflow-api@1.3.1: + webflow-api@2.4.2: dependencies: - axios: 1.7.7(debug@3.2.7) + form-data: 4.0.1 + formdata-node: 6.0.3 + js-base64: 3.7.2 + node-fetch: 2.7.0 + qs: 6.11.2 + readable-stream: 4.5.2 + url-join: 4.0.1 transitivePeerDependencies: - - debug + - encoding webidl-conversions@3.0.1: {}