diff --git a/components/webflow/package.json b/components/webflow/package.json index 3d396544cca56..b044275f45f89 100644 --- a/components/webflow/package.json +++ b/components/webflow/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/webflow", - "version": "1.0.0", + "version": "0.4.6", "description": "Pipedream Webflow Components", "main": "webflow.app.mjs", "keywords": [ @@ -10,9 +10,10 @@ "homepage": "https://pipedream.com/apps/webflow", "author": "Pipedream (https://pipedream.com/)", "dependencies": { - "@pipedream/platform": "^3.0.3", - "webflow-api": "2.4.2" + "@pipedream/platform": "^1.1.0", + "webflow-api": "1.3.1" }, + "gitHead": "e12480b94cc03bed4808ebc6b13e7fdb3a1ba535", "publishConfig": { "access": "public" } diff --git a/components/webflow/webflow.app.mjs b/components/webflow/webflow.app.mjs index e604219812030..74375c31d64f0 100644 --- a/components/webflow/webflow.app.mjs +++ b/components/webflow/webflow.app.mjs @@ -1,4 +1,7 @@ -import { WebflowClient } from "webflow-api"; +// 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 constants from "./common/constants.mjs"; export default { @@ -6,66 +9,64 @@ export default { app: "webflow", propDefinitions: { domains: { - label: "Custom Domains", - description: "Select one or more custom domains to publish.", + label: "Domain", + description: "The list of domains.", type: "string[]", async options({ siteId }) { - const domains = await this.listDomains(siteId); - return domains.map((id, url) => ({ - label: url, - id, - })); + const domains = await this.getDomains(siteId); + + return domains.map((domain) => domain.name); }, }, sites: { label: "Site", - description: "Select a site or provide a custom site ID.", + description: "The list of sites", type: "string", async options() { - const sites = await this.listSites(); + const sites = await this.getSites(); return sites.map((site) => ({ - label: site.displayName || site.shortName, - value: site.id, + label: site.name, + value: site._id, })); }, }, collections: { label: "Collection", - description: "Select a collection or provide a custom collection ID.", + description: "The list of collection of a site", type: "string", async options({ siteId }) { - const collections = await this.listCollections(siteId); + const collections = await this.getCollections(siteId); return collections.map((collection) => ({ - label: collection.displayName || collection.slug, - value: collection.id, + label: collection.name, + value: collection._id, })); }, }, items: { label: "Item", - description: "Select an item or provide a custom item ID.", + description: "The list of items of a collection", type: "string", async options({ collectionId, page, }) { - const items = await this.listCollectionItems(page, collectionId); + const items = await this.getItems(page, collectionId); return items.map((item) => ({ - label: item.fieldData?.name || item.fieldData?.slug, - value: item.id, + label: item.name, + value: item._id, })); }, }, orders: { label: "Order", - description: "Select an order, or provide a custom order ID.", + description: "The list of orders of a site", type: "string", async options({ siteId, page, }) { - const items = await this.listOrders({ + const items = await this.getOrders({ page, siteId, }); @@ -75,96 +76,179 @@ export default { }, }, methods: { + /** + * Get the auth access token; + * + * @returns {string} The base auth access token. + */ _authToken() { return this.$auth.oauth_access_token; }, - webflowClient() { - return new WebflowClient({ - accessToken: this._authToken(), + /** + * Create a Webflow API client; + * + * @returns {params} The Webflow API client. + */ + _createApiClient() { + return new Webflow({ + token: this._authToken(), }); }, - async createWebhook(siteId, data) { - return this.webflowClient().webhooks.create(siteId, data); - }, - async removeWebhook(webhookId) { - return this.webflowClient().webhooks.delete(webhookId); + /** + * 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 getOrder(siteId, orderId) { - return this.webflowClient().orders.get(siteId, orderId); + /** + * 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 listOrders({ - page: offset = 0, siteId, status, + /** + * 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, }) { - const response = await this.webflowClient().orders.list(siteId, { - offset, - status, + const apiClient = this._createApiClient(); + + return apiClient.get(`/sites/${siteId}/orders`, { + status: status, + offset: page ?? 0, + limit: constants.LIMIT, }); - return response?.orders; - }, - async listDomains(siteId) { - const response = await this.webflowClient().sites.getCustomDomain(siteId); - return response?.customDomains; }, - getSite(siteId) { - return this.webflowClient().sites.get(siteId); + /** + * 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 listSites() { - const response = await this.webflowClient().sites.list(); - return response?.sites; + /** + * 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, + }); }, - getCollection(collectionId) { - return this.webflowClient().collections.get(collectionId); + /** + * 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 listCollections(siteId) { + /** + * 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(); + if (!siteId) return []; - const response = await this.webflowClient().collections.list(siteId); - return response?.collections; + return await webflow.collections({ + siteId: siteId, + }); }, - async listCollectionItems(page = 0, collectionId) { + /** + * 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(); + if (!collectionId) return []; - const response = await this.webflowClient().collections.items.listItems(collectionId, { + const response = await webflow.items({ + collectionId, + }, { limit: constants.LIMIT, offset: page, }); - 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); + return response; }, }, }; diff --git a/components/webflow/actions/common/constants.mjs b/components/webflow_v2/actions/common/constants.mjs similarity index 100% rename from components/webflow/actions/common/constants.mjs rename to components/webflow_v2/actions/common/constants.mjs diff --git a/components/webflow/actions/create-collection-item/create-collection-item.mjs b/components/webflow_v2/actions/create-collection-item/create-collection-item.mjs similarity index 85% rename from components/webflow/actions/create-collection-item/create-collection-item.mjs rename to components/webflow_v2/actions/create-collection-item/create-collection-item.mjs index 39e88712aedd2..b9d091eb708e8 100644 --- a/components/webflow/actions/create-collection-item/create-collection-item.mjs +++ b/components/webflow_v2/actions/create-collection-item/create-collection-item.mjs @@ -1,10 +1,10 @@ -import app from "../../webflow.app.mjs"; +import app from "../../webflow_v2.app.mjs"; export default { - key: "webflow-create-collection-item", + key: "webflow_v2-create-collection-item", name: "Create Collection Item", - description: "Create new collection item. [See the documentation](https://developers.webflow.com/data/reference/cms/collection-items/staged-items/create-item)", - version: "1.0.0", + description: "Create new collection item. [See the docs here](https://developers.webflow.com/#create-new-collection-item)", + version: "0.0.1", type: "action", props: { app, diff --git a/components/webflow/actions/delete-collection-item/delete-collection-item.mjs b/components/webflow_v2/actions/delete-collection-item/delete-collection-item.mjs similarity index 73% rename from components/webflow/actions/delete-collection-item/delete-collection-item.mjs rename to components/webflow_v2/actions/delete-collection-item/delete-collection-item.mjs index 63f253fdb7305..be0d12f906afa 100644 --- a/components/webflow/actions/delete-collection-item/delete-collection-item.mjs +++ b/components/webflow_v2/actions/delete-collection-item/delete-collection-item.mjs @@ -1,10 +1,10 @@ -import app from "../../webflow.app.mjs"; +import app from "../../webflow_v2.app.mjs"; export default { - key: "webflow-delete-collection-item", + key: "webflow_v2-delete-collection-item", name: "Delete Collection Item", - description: "Delete Item of a Collection. [See the documentation](https://developers.webflow.com/data/reference/cms/collection-items/staged-items/delete-item)", - version: "1.0.0", + description: "Delete Item of a Collection. [See the docs here](https://developers.webflow.com/#remove-collection-item)", + version: "0.0.1", type: "action", props: { app, diff --git a/components/webflow/actions/fulfill-order/fulfill-order.mjs b/components/webflow_v2/actions/fulfill-order/fulfill-order.mjs similarity index 75% rename from components/webflow/actions/fulfill-order/fulfill-order.mjs rename to components/webflow_v2/actions/fulfill-order/fulfill-order.mjs index 98f5f0fc7b7e8..036cf7e9fde82 100644 --- a/components/webflow/actions/fulfill-order/fulfill-order.mjs +++ b/components/webflow_v2/actions/fulfill-order/fulfill-order.mjs @@ -1,10 +1,10 @@ -import app from "../../webflow.app.mjs"; +import app from "../../webflow_v2.app.mjs"; export default { - key: "webflow-fulfill-order", + key: "webflow_v2-fulfill-order", name: "Fulfill Order", - description: "Fulfill an order. [See the documentation](https://developers.webflow.com/data/reference/ecommerce/orders/update-fulfill)", - version: "1.0.0", + description: "Fulfill an order. [See the docs here](https://developers.webflow.com/#fulfill-order)", + version: "0.0.1", type: "action", props: { app, diff --git a/components/webflow/actions/get-collection-item/get-collection-item.mjs b/components/webflow_v2/actions/get-collection-item/get-collection-item.mjs similarity index 73% rename from components/webflow/actions/get-collection-item/get-collection-item.mjs rename to components/webflow_v2/actions/get-collection-item/get-collection-item.mjs index b490e71b315a0..7d687378800b4 100644 --- a/components/webflow/actions/get-collection-item/get-collection-item.mjs +++ b/components/webflow_v2/actions/get-collection-item/get-collection-item.mjs @@ -1,10 +1,10 @@ -import app from "../../webflow.app.mjs"; +import app from "../../webflow_v2.app.mjs"; export default { - key: "webflow-get-collection-item", + key: "webflow_v2-get-collection-item", name: "Get Collection Item", - description: "Get a Collection Item. [See the documentation](https://developers.webflow.com/data/reference/cms/collection-items/staged-items/get-item)", - version: "1.0.0", + description: "Get a Collection Item. [See the docs here](https://developers.webflow.com/#get-single-item)", + version: "0.0.1", type: "action", props: { app, diff --git a/components/webflow/actions/get-collection/get-collection.mjs b/components/webflow_v2/actions/get-collection/get-collection.mjs similarity index 69% rename from components/webflow/actions/get-collection/get-collection.mjs rename to components/webflow_v2/actions/get-collection/get-collection.mjs index d13e9eb27a44b..ad69e2dc63b75 100644 --- a/components/webflow/actions/get-collection/get-collection.mjs +++ b/components/webflow_v2/actions/get-collection/get-collection.mjs @@ -1,10 +1,10 @@ -import app from "../../webflow.app.mjs"; +import app from "../../webflow_v2.app.mjs"; export default { - key: "webflow-get-collection", + key: "webflow_v2-get-collection", name: "Get Collection", - description: "Get a collection. [See the documentation](https://developers.webflow.com/data/reference/cms/collections/get)", - version: "1.0.0", + description: "Get a collection. [See the docs here](https://developers.webflow.com/#get-collection-with-full-schema)", + version: "0.0.1", type: "action", props: { app, diff --git a/components/webflow/actions/get-item-inventory/get-item-inventory.mjs b/components/webflow_v2/actions/get-item-inventory/get-item-inventory.mjs similarity index 80% rename from components/webflow/actions/get-item-inventory/get-item-inventory.mjs rename to components/webflow_v2/actions/get-item-inventory/get-item-inventory.mjs index a92077ebbc176..85538cbb6b318 100644 --- a/components/webflow/actions/get-item-inventory/get-item-inventory.mjs +++ b/components/webflow_v2/actions/get-item-inventory/get-item-inventory.mjs @@ -1,10 +1,10 @@ -import app from "../../webflow.app.mjs"; +import app from "../../webflow_v2.app.mjs"; export default { - key: "webflow-get-item-inventory", + key: "webflow_v2-get-item-inventory", name: "Get Item Inventory", - description: "Get the inventory of a specific item. [See the documentation](https://developers.webflow.com/data/reference/ecommerce/inventory/list)", - version: "1.0.0", + description: "Get the inventory of a specific item. [See the docs here](https://developers.webflow.com/#item-inventory)", + version: "0.0.1", type: "action", props: { app, diff --git a/components/webflow/actions/get-order/get-order.mjs b/components/webflow_v2/actions/get-order/get-order.mjs similarity index 66% rename from components/webflow/actions/get-order/get-order.mjs rename to components/webflow_v2/actions/get-order/get-order.mjs index be7d9dbc0c326..fa8aa041b7970 100644 --- a/components/webflow/actions/get-order/get-order.mjs +++ b/components/webflow_v2/actions/get-order/get-order.mjs @@ -1,10 +1,10 @@ -import app from "../../webflow.app.mjs"; +import app from "../../webflow_v2.app.mjs"; export default { - key: "webflow-get-order", + key: "webflow_v2-get-order", name: "Get Order", - description: "Get info on an order. [See the documentation](https://developers.webflow.com/data/reference/ecommerce/orders/get)", - version: "1.0.0", + description: "Get info on an order. [See the docs here](https://developers.webflow.com/#get-order)", + version: "0.0.1", type: "action", props: { app, diff --git a/components/webflow/actions/get-site/get-site.mjs b/components/webflow_v2/actions/get-site/get-site.mjs similarity index 62% rename from components/webflow/actions/get-site/get-site.mjs rename to components/webflow_v2/actions/get-site/get-site.mjs index 9821d61fc4dbd..ddcfeaff96918 100644 --- a/components/webflow/actions/get-site/get-site.mjs +++ b/components/webflow_v2/actions/get-site/get-site.mjs @@ -1,10 +1,10 @@ -import app from "../../webflow.app.mjs"; +import app from "../../webflow_v2.app.mjs"; export default { - key: "webflow-get-site", + key: "webflow_v2-get-site", name: "Get Site", - description: "Get a site. [See the documentation](https://developers.webflow.com/data/reference/sites/get)", - version: "1.0.0", + description: "Get a site. [See the docs here](https://developers.webflow.com/#get-specific-site)", + version: "0.0.1", type: "action", props: { app, diff --git a/components/webflow/actions/list-collection-items/list-collection-items.mjs b/components/webflow_v2/actions/list-collection-items/list-collection-items.mjs similarity index 67% rename from components/webflow/actions/list-collection-items/list-collection-items.mjs rename to components/webflow_v2/actions/list-collection-items/list-collection-items.mjs index cfb3a5d5ad0c0..7801319f5dcc9 100644 --- a/components/webflow/actions/list-collection-items/list-collection-items.mjs +++ b/components/webflow_v2/actions/list-collection-items/list-collection-items.mjs @@ -1,10 +1,10 @@ -import app from "../../webflow.app.mjs"; +import app from "../../webflow_v2.app.mjs"; export default { - key: "webflow-list-collection-items", + key: "webflow_v2-list-collection-items", name: "List Collection Items", - description: "List Items of a collection. [See the documentation](https://developers.webflow.com/data/reference/cms/collection-items/bulk-items/list-items)", - version: "1.0.0", + description: "List Items of a collection. [See the docs here](https://developers.webflow.com/#get-all-items-for-a-collection)", + version: "0.0.1", type: "action", props: { app, diff --git a/components/webflow/actions/list-collections/list-collections.mjs b/components/webflow_v2/actions/list-collections/list-collections.mjs similarity index 61% rename from components/webflow/actions/list-collections/list-collections.mjs rename to components/webflow_v2/actions/list-collections/list-collections.mjs index 553356edbb313..3cc625e8fd03d 100644 --- a/components/webflow/actions/list-collections/list-collections.mjs +++ b/components/webflow_v2/actions/list-collections/list-collections.mjs @@ -1,10 +1,10 @@ -import app from "../../webflow.app.mjs"; +import app from "../../webflow_v2.app.mjs"; export default { - key: "webflow-list-collections", + key: "webflow_v2-list-collections", name: "List Collections", - description: "List collections. [See the documentation](https://developers.webflow.com/data/reference/cms/collections/list)", - version: "1.0.0", + description: "List collections. [See the docs here](https://developers.webflow.com/#list-collections)", + version: "0.0.1", type: "action", props: { app, diff --git a/components/webflow/actions/list-orders/list-orders.mjs b/components/webflow_v2/actions/list-orders/list-orders.mjs similarity index 75% rename from components/webflow/actions/list-orders/list-orders.mjs rename to components/webflow_v2/actions/list-orders/list-orders.mjs index 7ea54510b95bc..4768ee641b631 100644 --- a/components/webflow/actions/list-orders/list-orders.mjs +++ b/components/webflow_v2/actions/list-orders/list-orders.mjs @@ -1,11 +1,11 @@ -import app from "../../webflow.app.mjs"; +import app from "../../webflow_v2.app.mjs"; import constants from "../common/constants.mjs"; export default { - key: "webflow-list-orders", + key: "webflow_v2-list-orders", name: "List Orders", - description: "List orders. [See the documentation](https://developers.webflow.com/data/reference/ecommerce/orders/list)", - version: "1.0.0", + description: "List orders. [See the docs here](https://developers.webflow.com/#get-all-orders)", + version: "0.0.1", type: "action", props: { app, diff --git a/components/webflow/actions/list-sites/list-sites.mjs b/components/webflow_v2/actions/list-sites/list-sites.mjs similarity index 54% rename from components/webflow/actions/list-sites/list-sites.mjs rename to components/webflow_v2/actions/list-sites/list-sites.mjs index 2f5dadf3164ac..c14fbb796c54d 100644 --- a/components/webflow/actions/list-sites/list-sites.mjs +++ b/components/webflow_v2/actions/list-sites/list-sites.mjs @@ -1,10 +1,10 @@ -import app from "../../webflow.app.mjs"; +import app from "../../webflow_v2.app.mjs"; export default { - key: "webflow-list-sites", + key: "webflow_v2-list-sites", name: "List Sites", - description: "List sites. [See the documentation](https://developers.webflow.com/data/reference/sites/list)", - version: "1.0.0", + description: "List sites. [See the docs here](https://developers.webflow.com/#list-sites)", + version: "0.0.1", type: "action", props: { app, diff --git a/components/webflow/actions/publish-site/publish-site.mjs b/components/webflow_v2/actions/publish-site/publish-site.mjs similarity index 70% rename from components/webflow/actions/publish-site/publish-site.mjs rename to components/webflow_v2/actions/publish-site/publish-site.mjs index e6b512095fe0e..9b252874b3678 100644 --- a/components/webflow/actions/publish-site/publish-site.mjs +++ b/components/webflow_v2/actions/publish-site/publish-site.mjs @@ -1,10 +1,10 @@ -import app from "../../webflow.app.mjs"; +import app from "../../webflow_v2.app.mjs"; export default { - key: "webflow-publish-site", + key: "webflow_v2-publish-site", name: "Publish Site", - description: "Publish a site. [See the documentation](https://developers.webflow.com/data/reference/sites/publish)", - version: "1.0.0", + description: "Publish a site. [See the docs here](https://developers.webflow.com/#publish-site)", + version: "0.0.1", type: "action", props: { app, diff --git a/components/webflow/actions/refund-order/refund-order.mjs b/components/webflow_v2/actions/refund-order/refund-order.mjs similarity index 66% rename from components/webflow/actions/refund-order/refund-order.mjs rename to components/webflow_v2/actions/refund-order/refund-order.mjs index 9773dfb450acf..4a63293db6cc1 100644 --- a/components/webflow/actions/refund-order/refund-order.mjs +++ b/components/webflow_v2/actions/refund-order/refund-order.mjs @@ -1,10 +1,10 @@ -import app from "../../webflow.app.mjs"; +import app from "../../webflow_v2.app.mjs"; export default { - key: "webflow-refund-order", + key: "webflow_v2-refund-order", name: "Refund Order", - description: "Refund an order. [See the documentation](https://developers.webflow.com/data/reference/ecommerce/orders/refund)", - version: "1.0.0", + description: "Refund an order. [See the docs here](https://developers.webflow.com/#refund-order)", + version: "0.0.1", type: "action", props: { app, diff --git a/components/webflow/actions/unfulfill-order/unfulfill-order.mjs b/components/webflow_v2/actions/unfulfill-order/unfulfill-order.mjs similarity index 65% rename from components/webflow/actions/unfulfill-order/unfulfill-order.mjs rename to components/webflow_v2/actions/unfulfill-order/unfulfill-order.mjs index a2b706ccf194d..e8f649395edd4 100644 --- a/components/webflow/actions/unfulfill-order/unfulfill-order.mjs +++ b/components/webflow_v2/actions/unfulfill-order/unfulfill-order.mjs @@ -1,10 +1,10 @@ -import app from "../../webflow.app.mjs"; +import app from "../../webflow_v2.app.mjs"; export default { - key: "webflow-unfulfill-order", + key: "webflow_v2-unfulfill-order", name: "Unfulfill Order", - description: "Unfulfill an order. [See the documentation](https://developers.webflow.com/data/reference/ecommerce/orders/update-unfulfill)", - version: "1.0.0", + description: "Unfulfill an order. [See the docs here](https://developers.webflow.com/#unfulfill-order)", + version: "0.0.1", type: "action", props: { app, diff --git a/components/webflow/actions/update-collection-item/update-collection-item.mjs b/components/webflow_v2/actions/update-collection-item/update-collection-item.mjs similarity index 92% rename from components/webflow/actions/update-collection-item/update-collection-item.mjs rename to components/webflow_v2/actions/update-collection-item/update-collection-item.mjs index b2ac774fc4a58..bc4d0cbb75575 100644 --- a/components/webflow/actions/update-collection-item/update-collection-item.mjs +++ b/components/webflow_v2/actions/update-collection-item/update-collection-item.mjs @@ -1,11 +1,11 @@ -import app from "../../webflow.app.mjs"; +import app from "../../webflow_v2.app.mjs"; export default { - key: "webflow-update-collection-item", + key: "webflow_v2-update-collection-item", name: "Update Collection Item", description: - "Update collection item. [See the documentation](https://developers.webflow.com/data/reference/cms/collection-items/bulk-items/update-items)", - version: "1.0.0", + "Update collection item. [See the documentation](https://developers.webflow.com/#update-collection-item)", + version: "0.0.1", type: "action", props: { app, diff --git a/components/webflow/actions/update-item-inventory/update-item-inventory.mjs b/components/webflow_v2/actions/update-item-inventory/update-item-inventory.mjs similarity index 90% rename from components/webflow/actions/update-item-inventory/update-item-inventory.mjs rename to components/webflow_v2/actions/update-item-inventory/update-item-inventory.mjs index dff9dfa1a9114..059c39d0e6c19 100644 --- a/components/webflow/actions/update-item-inventory/update-item-inventory.mjs +++ b/components/webflow_v2/actions/update-item-inventory/update-item-inventory.mjs @@ -1,9 +1,9 @@ -import app from "../../webflow.app.mjs"; +import app from "../../webflow_v2.app.mjs"; export default { - key: "webflow-update-item-inventory", + key: "webflow_v2-update-item-inventory", name: "Update Item Inventory", - description: "Update the inventory of a specific item. [See the documentation](https://developers.webflow.com/data/reference/ecommerce/inventory/update)", + description: "Update the inventory of a specific item. [See the docs here](https://developers.webflow.com/#update-item-inventory)", version: "0.0.5", type: "action", props: { diff --git a/components/webflow/actions/update-order/update-order.mjs b/components/webflow_v2/actions/update-order/update-order.mjs similarity index 81% rename from components/webflow/actions/update-order/update-order.mjs rename to components/webflow_v2/actions/update-order/update-order.mjs index 8fee7c34eadfb..ddb3f0d44e350 100644 --- a/components/webflow/actions/update-order/update-order.mjs +++ b/components/webflow_v2/actions/update-order/update-order.mjs @@ -1,10 +1,10 @@ -import app from "../../webflow.app.mjs"; +import app from "../../webflow_v2.app.mjs"; export default { - key: "webflow-update-order", + key: "webflow_v2-update-order", name: "Update Order", - description: "Update an order. [See the documentation](https://developers.webflow.com/data/reference/ecommerce/orders/update)", - version: "1.0.0", + description: "Update an order. [See the docs here](https://developers.webflow.com/#update-order)", + version: "0.0.1", type: "action", props: { app, diff --git a/components/webflow/common/constants.mjs b/components/webflow_v2/common/constants.mjs similarity index 100% rename from components/webflow/common/constants.mjs rename to components/webflow_v2/common/constants.mjs diff --git a/components/webflow_v2/package.json b/components/webflow_v2/package.json new file mode 100644 index 0000000000000..b2808e9dcb729 --- /dev/null +++ b/components/webflow_v2/package.json @@ -0,0 +1,19 @@ +{ + "name": "@pipedream/webflow_v2", + "version": "0.1.0", + "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/)", + "dependencies": { + "@pipedream/platform": "^3.0.3", + "webflow-api": "2.4.2" + }, + "publishConfig": { + "access": "public" + } +} diff --git a/components/webflow/sources/changed-collection-item/changed-collection-item.mjs b/components/webflow_v2/sources/changed-collection-item/changed-collection-item.mjs similarity index 77% rename from components/webflow/sources/changed-collection-item/changed-collection-item.mjs rename to components/webflow_v2/sources/changed-collection-item/changed-collection-item.mjs index af5fb423a689d..1464dce2ba8b6 100644 --- a/components/webflow/sources/changed-collection-item/changed-collection-item.mjs +++ b/components/webflow_v2/sources/changed-collection-item/changed-collection-item.mjs @@ -2,10 +2,10 @@ import common from "../common/common.mjs"; export default { type: "source", - key: "webflow-changed-collection-item", + key: "webflow_v2-changed-collection-item", 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: "1.0.0", + description: "Emit new event when a collection item is changed. [See the docs here](https://developers.webflow.com/#model16)", + version: "0.0.1", ...common, methods: { ...common.methods, diff --git a/components/webflow/sources/changed-ecommerce-inventory/changed-ecommerce-inventory.mjs b/components/webflow_v2/sources/changed-ecommerce-inventory/changed-ecommerce-inventory.mjs similarity index 73% rename from components/webflow/sources/changed-ecommerce-inventory/changed-ecommerce-inventory.mjs rename to components/webflow_v2/sources/changed-ecommerce-inventory/changed-ecommerce-inventory.mjs index 42c59245108b3..155e43314e540 100644 --- a/components/webflow/sources/changed-ecommerce-inventory/changed-ecommerce-inventory.mjs +++ b/components/webflow_v2/sources/changed-ecommerce-inventory/changed-ecommerce-inventory.mjs @@ -2,10 +2,10 @@ import common from "../common/common.mjs"; export default { type: "source", - key: "webflow-changed-ecommerce-inventory", + key: "webflow_v2-changed-ecommerce-inventory", 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: "1.0.0", + description: "Emit new event when an e-commerce inventory level changes. [See the docs here](https://developers.webflow.com/#item-inventory)", + version: "0.0.1", ...common, methods: { ...common.methods, diff --git a/components/webflow/sources/changed-ecommerce-order/changed-ecommerce-order.mjs b/components/webflow_v2/sources/changed-ecommerce-order/changed-ecommerce-order.mjs similarity index 73% rename from components/webflow/sources/changed-ecommerce-order/changed-ecommerce-order.mjs rename to components/webflow_v2/sources/changed-ecommerce-order/changed-ecommerce-order.mjs index 787e0e3fb8a5f..19833b42f3002 100644 --- a/components/webflow/sources/changed-ecommerce-order/changed-ecommerce-order.mjs +++ b/components/webflow_v2/sources/changed-ecommerce-order/changed-ecommerce-order.mjs @@ -2,10 +2,10 @@ import common from "../common/common.mjs"; export default { type: "source", - key: "webflow-changed-ecommerce-order", + key: "webflow_v2-changed-ecommerce-order", 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: "1.0.0", + description: "Emit new event when an e-commerce order is changed. [See the docs here](https://developers.webflow.com/#order-model)", + version: "0.0.1", ...common, methods: { ...common.methods, diff --git a/components/webflow/sources/common/common.mjs b/components/webflow_v2/sources/common/common.mjs similarity index 97% rename from components/webflow/sources/common/common.mjs rename to components/webflow_v2/sources/common/common.mjs index 880a0ea6fadc2..c5d08ccdce861 100644 --- a/components/webflow/sources/common/common.mjs +++ b/components/webflow_v2/sources/common/common.mjs @@ -1,4 +1,4 @@ -import app from "../../webflow.app.mjs"; +import app from "../../webflow_v2.app.mjs"; import { v4 as uuid } from "uuid"; import constants from "../../common/constants.mjs"; diff --git a/components/webflow/sources/new-collection-item/new-collection-item.mjs b/components/webflow_v2/sources/new-collection-item/new-collection-item.mjs similarity index 76% rename from components/webflow/sources/new-collection-item/new-collection-item.mjs rename to components/webflow_v2/sources/new-collection-item/new-collection-item.mjs index 76259c853a34d..463871690e238 100644 --- a/components/webflow/sources/new-collection-item/new-collection-item.mjs +++ b/components/webflow_v2/sources/new-collection-item/new-collection-item.mjs @@ -2,10 +2,10 @@ import common from "../common/common.mjs"; export default { type: "source", - key: "webflow-new-collection-item", + key: "webflow_v2-new-collection-item", 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: "1.0.0", + description: "Emit new event when a collection item is created. [See the docs here](https://developers.webflow.com/#item-model)", + version: "0.0.1", ...common, methods: { ...common.methods, diff --git a/components/webflow/sources/new-deleted-collection-item/new-deleted-collection-item.mjs b/components/webflow_v2/sources/new-deleted-collection-item/new-deleted-collection-item.mjs similarity index 72% rename from components/webflow/sources/new-deleted-collection-item/new-deleted-collection-item.mjs rename to components/webflow_v2/sources/new-deleted-collection-item/new-deleted-collection-item.mjs index ca212b49798d9..4c0463ff7bafe 100644 --- a/components/webflow/sources/new-deleted-collection-item/new-deleted-collection-item.mjs +++ b/components/webflow_v2/sources/new-deleted-collection-item/new-deleted-collection-item.mjs @@ -2,10 +2,10 @@ import common from "../common/common.mjs"; export default { type: "source", - key: "webflow-new-deleted-collection-item", + key: "webflow_v2-new-deleted-collection-item", 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: "1.0.0", + description: "Emit new event when a collection item is deleted. [See the docs here](https://developers.webflow.com/#item-model)", + version: "0.0.1", ...common, methods: { ...common.methods, diff --git a/components/webflow/sources/new-ecommerce-order/new-ecommerce-order.mjs b/components/webflow_v2/sources/new-ecommerce-order/new-ecommerce-order.mjs similarity index 83% rename from components/webflow/sources/new-ecommerce-order/new-ecommerce-order.mjs rename to components/webflow_v2/sources/new-ecommerce-order/new-ecommerce-order.mjs index c744572d87a88..9b1c8adb29ec8 100644 --- a/components/webflow/sources/new-ecommerce-order/new-ecommerce-order.mjs +++ b/components/webflow_v2/sources/new-ecommerce-order/new-ecommerce-order.mjs @@ -2,11 +2,11 @@ import common from "../common/common.mjs"; export default { type: "source", - key: "webflow-new-ecommerce-order", + key: "webflow_v2-new-ecommerce-order", name: "New E-commerce Order", 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: "1.0.0", + "Emit new event when an e-commerce order is created. [See the docs here](https://developers.webflow.com/#order-model)", + version: "0.0.1", ...common, hooks: { ...common.hooks, diff --git a/components/webflow/sources/new-form-submission/new-form-submission.mjs b/components/webflow_v2/sources/new-form-submission/new-form-submission.mjs similarity index 78% rename from components/webflow/sources/new-form-submission/new-form-submission.mjs rename to components/webflow_v2/sources/new-form-submission/new-form-submission.mjs index 62532cde64114..461a0411ad526 100644 --- a/components/webflow/sources/new-form-submission/new-form-submission.mjs +++ b/components/webflow_v2/sources/new-form-submission/new-form-submission.mjs @@ -3,10 +3,10 @@ import sampleEmit from "./test-event.mjs"; export default { type: "source", - key: "webflow-new-form-submission", + key: "webflow_v2-new-form-submission", name: "New Form Submission", - description: "Emit new event when a form is submitted. [See the documentation](https://developers.webflow.com/data/reference/webhooks/events/form-submission)", - version: "1.0.0", + description: "Emit new event when a form is submitted. [See the docs here](https://developers.webflow.com/#trigger-types)", + version: "0.0.1", ...common, methods: { ...common.methods, diff --git a/components/webflow/sources/new-form-submission/test-event.mjs b/components/webflow_v2/sources/new-form-submission/test-event.mjs similarity index 100% rename from components/webflow/sources/new-form-submission/test-event.mjs rename to components/webflow_v2/sources/new-form-submission/test-event.mjs diff --git a/components/webflow/sources/new-site-published/new-site-published.mjs b/components/webflow_v2/sources/new-site-published/new-site-published.mjs similarity index 76% rename from components/webflow/sources/new-site-published/new-site-published.mjs rename to components/webflow_v2/sources/new-site-published/new-site-published.mjs index 82ce8390261ea..a1f1e5aaee9a8 100644 --- a/components/webflow/sources/new-site-published/new-site-published.mjs +++ b/components/webflow_v2/sources/new-site-published/new-site-published.mjs @@ -2,10 +2,10 @@ import common from "../common/common.mjs"; export default { type: "source", - key: "webflow-new-site-published", + key: "webflow_v2-new-site-published", 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: "1.0.0", + description: "Emit new event when a site is published. [See the docs here](https://developers.webflow.com/#trigger-types)", + version: "0.0.1", ...common, methods: { ...common.methods, diff --git a/components/webflow_v2/webflow_v2.app.mjs b/components/webflow_v2/webflow_v2.app.mjs new file mode 100644 index 0000000000000..a0683c658dce7 --- /dev/null +++ b/components/webflow_v2/webflow_v2.app.mjs @@ -0,0 +1,170 @@ +import { WebflowClient } from "webflow-api"; +import constants from "./common/constants.mjs"; + +export default { + type: "app", + app: "webflow_v2", + propDefinitions: { + domains: { + label: "Custom Domains", + description: "Select one or more custom domains to publish.", + type: "string[]", + async options({ siteId }) { + const domains = await this.listDomains(siteId); + return domains.map((id, url) => ({ + label: url, + id, + })); + }, + }, + sites: { + label: "Site", + description: "Select a site or provide a custom site ID.", + type: "string", + async options() { + const sites = await this.listSites(); + + return sites.map((site) => ({ + label: site.displayName || site.shortName, + value: site.id, + })); + }, + }, + collections: { + label: "Collection", + description: "Select a collection or provide a custom collection ID.", + type: "string", + async options({ siteId }) { + const collections = await this.listCollections(siteId); + + return collections.map((collection) => ({ + label: collection.displayName || collection.slug, + value: collection.id, + })); + }, + }, + items: { + label: "Item", + description: "Select an item or provide a custom item ID.", + type: "string", + async options({ + collectionId, page, + }) { + const items = await this.listCollectionItems(page, collectionId); + + return items.map((item) => ({ + label: item.fieldData?.name || item.fieldData?.slug, + value: item.id, + })); + }, + }, + orders: { + label: "Order", + description: "Select an order, or provide a custom order ID.", + type: "string", + async options({ + siteId, page, + }) { + const items = await this.listOrders({ + page, + siteId, + }); + + return items.map((item) => item.orderId); + }, + }, + }, + methods: { + _authToken() { + return this.$auth.oauth_access_token; + }, + webflowClient() { + return new WebflowClient({ + accessToken: this._authToken(), + }); + }, + async createWebhook(siteId, data) { + return this.webflowClient().webhooks.create(siteId, data); + }, + async removeWebhook(webhookId) { + return this.webflowClient().webhooks.delete(webhookId); + }, + async getOrder(siteId, orderId) { + return this.webflowClient().orders.get(siteId, orderId); + }, + async listOrders({ + page: offset = 0, siteId, status, + }) { + const response = await this.webflowClient().orders.list(siteId, { + offset, + status, + }); + return response?.orders; + }, + async listDomains(siteId) { + const response = await this.webflowClient().sites.getCustomDomain(siteId); + return response?.customDomains; + }, + getSite(siteId) { + return this.webflowClient().sites.get(siteId); + }, + async listSites() { + const response = await this.webflowClient().sites.list(); + return response?.sites; + }, + getCollection(collectionId) { + return this.webflowClient().collections.get(collectionId); + }, + async listCollections(siteId) { + if (!siteId) return []; + + const response = await this.webflowClient().collections.list(siteId); + return response?.collections; + }, + async listCollectionItems(page = 0, collectionId) { + if (!collectionId) return []; + + const response = await this.webflowClient().collections.items.listItems(collectionId, { + limit: constants.LIMIT, + offset: page, + }); + + 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/pnpm-lock.yaml b/pnpm-lock.yaml index f59e45263b249..644468cb00f53 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11314,6 +11314,15 @@ importers: components/weaviate: {} components/webflow: + dependencies: + '@pipedream/platform': + specifier: ^1.1.0 + version: 1.6.6 + webflow-api: + specifier: 1.3.1 + version: 1.3.1 + + components/webflow_v2: dependencies: '@pipedream/platform': specifier: ^3.0.3 @@ -23775,6 +23784,9 @@ 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==} @@ -39990,6 +40002,12 @@ snapshots: web-streams-polyfill@3.3.3: {} + webflow-api@1.3.1: + dependencies: + axios: 1.7.7(debug@3.2.7) + transitivePeerDependencies: + - debug + webflow-api@2.4.2: dependencies: form-data: 4.0.1