Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions components/webflow/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/webflow",
"version": "1.0.0",
"version": "0.4.6",
"description": "Pipedream Webflow Components",
"main": "webflow.app.mjs",
"keywords": [
Expand All @@ -10,9 +10,10 @@
"homepage": "https://pipedream.com/apps/webflow",
"author": "Pipedream <[email protected]> (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"
}
Expand Down
264 changes: 174 additions & 90 deletions components/webflow/webflow.app.mjs
Original file line number Diff line number Diff line change
@@ -1,71 +1,72 @@
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 "[email protected]";
import constants from "./common/constants.mjs";

export default {
type: "app",
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,
});
Expand All @@ -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;
},
},
};
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Loading
Loading