Skip to content

Commit fe7b4bb

Browse files
Revert "Merging pull request #14818" (#14824)
This reverts commit 73ca9f1.
1 parent 2e50568 commit fe7b4bb

File tree

35 files changed

+481
-189
lines changed

35 files changed

+481
-189
lines changed

components/webflow/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/webflow",
3-
"version": "1.0.0",
3+
"version": "0.4.6",
44
"description": "Pipedream Webflow Components",
55
"main": "webflow.app.mjs",
66
"keywords": [
@@ -10,9 +10,10 @@
1010
"homepage": "https://pipedream.com/apps/webflow",
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"dependencies": {
13-
"@pipedream/platform": "^3.0.3",
14-
"webflow-api": "2.4.2"
13+
"@pipedream/platform": "^1.1.0",
14+
"webflow-api": "1.3.1"
1515
},
16+
"gitHead": "e12480b94cc03bed4808ebc6b13e7fdb3a1ba535",
1617
"publishConfig": {
1718
"access": "public"
1819
}

components/webflow/webflow.app.mjs

Lines changed: 174 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,72 @@
1-
import { WebflowClient } from "webflow-api";
1+
// Webflow version support here: https://www.npmjs.com/package/webflow-api?activeTab=versions
2+
// @note: this is pinned to Webflow 1.3.1
3+
// because the upgrade to version 2 requires a new app
4+
import Webflow from "[email protected]";
25
import constants from "./common/constants.mjs";
36

47
export default {
58
type: "app",
69
app: "webflow",
710
propDefinitions: {
811
domains: {
9-
label: "Custom Domains",
10-
description: "Select one or more custom domains to publish.",
12+
label: "Domain",
13+
description: "The list of domains.",
1114
type: "string[]",
1215
async options({ siteId }) {
13-
const domains = await this.listDomains(siteId);
14-
return domains.map((id, url) => ({
15-
label: url,
16-
id,
17-
}));
16+
const domains = await this.getDomains(siteId);
17+
18+
return domains.map((domain) => domain.name);
1819
},
1920
},
2021
sites: {
2122
label: "Site",
22-
description: "Select a site or provide a custom site ID.",
23+
description: "The list of sites",
2324
type: "string",
2425
async options() {
25-
const sites = await this.listSites();
26+
const sites = await this.getSites();
2627

2728
return sites.map((site) => ({
28-
label: site.displayName || site.shortName,
29-
value: site.id,
29+
label: site.name,
30+
value: site._id,
3031
}));
3132
},
3233
},
3334
collections: {
3435
label: "Collection",
35-
description: "Select a collection or provide a custom collection ID.",
36+
description: "The list of collection of a site",
3637
type: "string",
3738
async options({ siteId }) {
38-
const collections = await this.listCollections(siteId);
39+
const collections = await this.getCollections(siteId);
3940

4041
return collections.map((collection) => ({
41-
label: collection.displayName || collection.slug,
42-
value: collection.id,
42+
label: collection.name,
43+
value: collection._id,
4344
}));
4445
},
4546
},
4647
items: {
4748
label: "Item",
48-
description: "Select an item or provide a custom item ID.",
49+
description: "The list of items of a collection",
4950
type: "string",
5051
async options({
5152
collectionId, page,
5253
}) {
53-
const items = await this.listCollectionItems(page, collectionId);
54+
const items = await this.getItems(page, collectionId);
5455

5556
return items.map((item) => ({
56-
label: item.fieldData?.name || item.fieldData?.slug,
57-
value: item.id,
57+
label: item.name,
58+
value: item._id,
5859
}));
5960
},
6061
},
6162
orders: {
6263
label: "Order",
63-
description: "Select an order, or provide a custom order ID.",
64+
description: "The list of orders of a site",
6465
type: "string",
6566
async options({
6667
siteId, page,
6768
}) {
68-
const items = await this.listOrders({
69+
const items = await this.getOrders({
6970
page,
7071
siteId,
7172
});
@@ -75,96 +76,179 @@ export default {
7576
},
7677
},
7778
methods: {
79+
/**
80+
* Get the auth access token;
81+
*
82+
* @returns {string} The base auth access token.
83+
*/
7884
_authToken() {
7985
return this.$auth.oauth_access_token;
8086
},
81-
webflowClient() {
82-
return new WebflowClient({
83-
accessToken: this._authToken(),
87+
/**
88+
* Create a Webflow API client;
89+
*
90+
* @returns {params} The Webflow API client.
91+
*/
92+
_createApiClient() {
93+
return new Webflow({
94+
token: this._authToken(),
8495
});
8596
},
86-
async createWebhook(siteId, data) {
87-
return this.webflowClient().webhooks.create(siteId, data);
88-
},
89-
async removeWebhook(webhookId) {
90-
return this.webflowClient().webhooks.delete(webhookId);
97+
/**
98+
* Create a Webflow webhook;
99+
*
100+
* @param {siteId} ID of the site to be monitored.
101+
* @param {url} URL to webhook return.
102+
* @param {triggerType} Type of event that will be triggered.
103+
* @param {filter} Filters to be applied in webhook.
104+
*
105+
* @returns {params} The Webflow webhook.
106+
*/
107+
async createWebhook(siteId, url, triggerType, filter = {}) {
108+
const apiClient = this._createApiClient();
109+
110+
return apiClient.createWebhook({
111+
siteId,
112+
triggerType,
113+
url,
114+
filter,
115+
});
91116
},
92-
async getOrder(siteId, orderId) {
93-
return this.webflowClient().orders.get(siteId, orderId);
117+
/**
118+
* Remove a Webflow webhook;
119+
*
120+
* @param {siteId} ID of the site.
121+
* @param {webhookId} ID of the webhook.
122+
*/
123+
async removeWebhook(siteId, webhookId) {
124+
const apiClient = this._createApiClient();
125+
return apiClient.removeWebhook({
126+
siteId,
127+
webhookId,
128+
});
94129
},
95-
async listOrders({
96-
page: offset = 0, siteId, status,
130+
/**
131+
* Get an order;
132+
*
133+
* @param {options} Options to filter the order.
134+
*
135+
* @returns {params} An order.
136+
*/
137+
async getOrder({
138+
siteId, orderId,
139+
}) {
140+
const apiClient = this._createApiClient();
141+
142+
return apiClient.get(`/sites/${siteId}/order/${orderId}`);
143+
},
144+
/**
145+
* Get a list of orders;
146+
*
147+
* @param {options} Options to filter the orders.
148+
*
149+
* @returns {params} A list of orders.
150+
*/
151+
async getOrders({
152+
page, siteId, status,
97153
}) {
98-
const response = await this.webflowClient().orders.list(siteId, {
99-
offset,
100-
status,
154+
const apiClient = this._createApiClient();
155+
156+
return apiClient.get(`/sites/${siteId}/orders`, {
157+
status: status,
158+
offset: page ?? 0,
159+
limit: constants.LIMIT,
101160
});
102-
return response?.orders;
103-
},
104-
async listDomains(siteId) {
105-
const response = await this.webflowClient().sites.getCustomDomain(siteId);
106-
return response?.customDomains;
107161
},
108-
getSite(siteId) {
109-
return this.webflowClient().sites.get(siteId);
162+
/**
163+
* Get a list of domains;
164+
*
165+
* @param {options} Options to filter the domains.
166+
*
167+
* @returns {params} A list of domains.
168+
*/
169+
async getDomains(siteId) {
170+
const webflow = this._createApiClient();
171+
172+
return await webflow.domains({
173+
siteId,
174+
});
110175
},
111-
async listSites() {
112-
const response = await this.webflowClient().sites.list();
113-
return response?.sites;
176+
/**
177+
* Get a site;
178+
*
179+
* @param {options} Options to filter the site.
180+
*
181+
* @returns {params} A site.
182+
*/
183+
async getSite(siteId) {
184+
const webflow = this._createApiClient();
185+
186+
return await webflow.site({
187+
siteId,
188+
});
114189
},
115-
getCollection(collectionId) {
116-
return this.webflowClient().collections.get(collectionId);
190+
/**
191+
* Get a list of sites;
192+
*
193+
* @param {options} Options to filter the sites.
194+
*
195+
* @returns {params} A list of sites.
196+
*/
197+
async getSites() {
198+
const webflow = this._createApiClient();
199+
200+
return await webflow.sites();
201+
},
202+
/**
203+
* Get a collection;
204+
*
205+
* @param {options} Options to filter the collection.
206+
*
207+
* @returns {params} A collection.
208+
*/
209+
async getCollection(collectionId) {
210+
const webflow = this._createApiClient();
211+
212+
return await webflow.collection({
213+
collectionId,
214+
});
117215
},
118-
async listCollections(siteId) {
216+
/**
217+
* Get a list of collections;
218+
*
219+
* @param {options} Options to filter the collections.
220+
*
221+
* @returns {params} A list of collections.
222+
*/
223+
async getCollections(siteId) {
224+
const webflow = this._createApiClient();
225+
119226
if (!siteId) return [];
120227

121-
const response = await this.webflowClient().collections.list(siteId);
122-
return response?.collections;
228+
return await webflow.collections({
229+
siteId: siteId,
230+
});
123231
},
124-
async listCollectionItems(page = 0, collectionId) {
232+
/**
233+
* Get a list of items;
234+
*
235+
* @param {options} Options to filter the items.
236+
*
237+
* @returns {params} A list of items.
238+
*/
239+
async getItems(page = 0, collectionId) {
240+
const webflow = this._createApiClient();
241+
125242
if (!collectionId) return [];
126243

127-
const response = await this.webflowClient().collections.items.listItems(collectionId, {
244+
const response = await webflow.items({
245+
collectionId,
246+
}, {
128247
limit: constants.LIMIT,
129248
offset: page,
130249
});
131250

132-
return response?.items;
133-
},
134-
getCollectionItem(collectionId, itemId) {
135-
return this.webflowClient().collections.items.getItem(collectionId, itemId);
136-
},
137-
deleteCollectionItem(collectionId, itemId) {
138-
return this.webflowClient().collections.items.deleteItem(collectionId, itemId);
139-
},
140-
createCollectionItem(collectionId, data) {
141-
return this.webflowClient().collections.items.createItem(collectionId, data);
142-
},
143-
updateCollectionItem(collectionId, itemId, data) {
144-
return this.webflowClient().collections.items.updateItem(collectionId, itemId, data);
145-
},
146-
getCollectionItemInventory(collectionId, itemId) {
147-
return this.webflowClient().inventory.list(collectionId, itemId);
148-
},
149-
updateCollectionItemInventory(collectionId, itemId, data) {
150-
return this.webflowClient().inventory.update(collectionId, itemId, data);
151-
},
152-
publishSite(siteId, customDomains) {
153-
return this.webflowClient().sites.publish(siteId, {
154-
customDomains,
155-
});
156-
},
157-
fulfillOrder(siteId, orderId, data) {
158-
return this.webflowClient().orders.updateFulfill(siteId, orderId, data);
159-
},
160-
unfulfillOrder(siteId, orderId) {
161-
return this.webflowClient().orders.updateUnfulfill(siteId, orderId);
162-
},
163-
refundOrder(siteId, orderId) {
164-
return this.webflowClient().orders.refund(siteId, orderId);
165-
},
166-
updateOrder(siteId, orderId, data) {
167-
return this.webflowClient().orders.update(siteId, orderId, data);
251+
return response;
168252
},
169253
},
170254
};
File renamed without changes.

components/webflow/actions/create-collection-item/create-collection-item.mjs renamed to components/webflow_v2/actions/create-collection-item/create-collection-item.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import app from "../../webflow.app.mjs";
1+
import app from "../../webflow_v2.app.mjs";
22

33
export default {
4-
key: "webflow-create-collection-item",
4+
key: "webflow_v2-create-collection-item",
55
name: "Create Collection Item",
6-
description: "Create new collection item. [See the documentation](https://developers.webflow.com/data/reference/cms/collection-items/staged-items/create-item)",
7-
version: "1.0.0",
6+
description: "Create new collection item. [See the docs here](https://developers.webflow.com/#create-new-collection-item)",
7+
version: "0.0.1",
88
type: "action",
99
props: {
1010
app,

components/webflow/actions/delete-collection-item/delete-collection-item.mjs renamed to components/webflow_v2/actions/delete-collection-item/delete-collection-item.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import app from "../../webflow.app.mjs";
1+
import app from "../../webflow_v2.app.mjs";
22

33
export default {
4-
key: "webflow-delete-collection-item",
4+
key: "webflow_v2-delete-collection-item",
55
name: "Delete Collection Item",
6-
description: "Delete Item of a Collection. [See the documentation](https://developers.webflow.com/data/reference/cms/collection-items/staged-items/delete-item)",
7-
version: "1.0.0",
6+
description: "Delete Item of a Collection. [See the docs here](https://developers.webflow.com/#remove-collection-item)",
7+
version: "0.0.1",
88
type: "action",
99
props: {
1010
app,

0 commit comments

Comments
 (0)