Skip to content

Commit e313fb6

Browse files
authored
Webflow v2 migration 2024 12 11 (#14841)
* Re-applying webflow migration * Version updates * pnpm-lock
1 parent 70e534f commit e313fb6

File tree

32 files changed

+372
-642
lines changed

32 files changed

+372
-642
lines changed

components/webflow/actions/create-collection-item/create-collection-item.mjs

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,38 @@
1-
import webflow from "../../webflow.app.mjs";
1+
import app from "../../webflow.app.mjs";
22

33
export default {
44
key: "webflow-create-collection-item",
55
name: "Create Collection Item",
6-
description: "Create new collection item. [See the docs here](https://developers.webflow.com/#create-new-collection-item)",
7-
version: "1.0.1",
6+
description: "Create new collection item. [See the documentation](https://developers.webflow.com/data/reference/cms/collection-items/staged-items/create-item)",
7+
version: "2.0.0",
88
type: "action",
99
props: {
10-
webflow,
10+
app,
1111
siteId: {
1212
propDefinition: [
13-
webflow,
13+
app,
1414
"sites",
1515
],
1616
},
1717
collectionId: {
1818
propDefinition: [
19-
webflow,
19+
app,
2020
"collections",
2121
(c) => ({
2222
siteId: c.siteId,
2323
}),
2424
],
2525
reloadProps: true,
2626
},
27-
live: {
28-
label: "Live",
29-
description: "Indicate if the item should be published to the live site",
30-
type: "boolean",
31-
default: false,
32-
},
3327
},
3428
async additionalProps() {
3529
const props = {};
3630
if (!this.collectionId) {
3731
return props;
3832
}
39-
const { fields } = await this.webflow.getCollection(this.collectionId);
33+
const { fields } = await this.app.getCollection(this.collectionId);
4034
for (const field of fields) {
41-
if (field.editable && field.slug !== "_archived" && field.slug !== "_draft") {
35+
if (field.isEditable && field.slug !== "isArchived" && field.slug !== "isDraft") {
4236
props[field.slug] = {
4337
type: "string",
4438
label: field.name,
@@ -47,37 +41,31 @@ export default {
4741
: field.slug === "slug"
4842
? "URL structure of the Item in your site."
4943
: "See the documentation for additional information about [Field Types & Item Values](https://developers.webflow.com/reference/field-types-item-values).",
50-
optional: !field.required,
44+
optional: !field.isRequired,
5145
};
5246
}
5347
}
5448
return props;
5549
},
5650
async run({ $ }) {
5751
const {
58-
webflow,
52+
app,
5953
// eslint-disable-next-line no-unused-vars
6054
siteId,
61-
// eslint-disable-next-line no-unused-vars
6255
collectionId,
63-
live,
64-
...fields
56+
...fieldData
6557
} = this;
6658

67-
const webflowClient = webflow._createApiClient();
68-
69-
const response = await webflowClient.createItem({
70-
collectionId: this.collectionId,
71-
fields: {
72-
...fields,
73-
_archived: false,
74-
_draft: false,
59+
const response = await app.createCollectionItem(
60+
collectionId,
61+
{
62+
fieldData,
63+
isArchived: false,
64+
isDraft: false,
7565
},
76-
}, {
77-
live,
78-
});
66+
);
7967

80-
$.export("$summary", `Successfully created collection item ${fields.name}`);
68+
$.export("$summary", `Successfully created collection item ${this.name ?? ""}`);
8169

8270
return response;
8371
},

components/webflow/actions/delete-collection-item/delete-collection-item.mjs

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

33
export default {
44
key: "webflow-delete-collection-item",
55
name: "Delete Collection Item",
6-
description: "Delete Item of a Collection. [See the docs here](https://developers.webflow.com/#remove-collection-item)",
7-
version: "1.0.1",
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: "2.0.0",
88
type: "action",
99
props: {
10-
webflow,
10+
app,
1111
siteId: {
1212
propDefinition: [
13-
webflow,
13+
app,
1414
"sites",
1515
],
1616
},
1717
collectionId: {
1818
propDefinition: [
19-
webflow,
19+
app,
2020
"collections",
2121
(c) => ({
2222
siteId: c.siteId,
@@ -25,7 +25,7 @@ export default {
2525
},
2626
itemId: {
2727
propDefinition: [
28-
webflow,
28+
app,
2929
"items",
3030
(c) => ({
3131
collectionId: c.collectionId,
@@ -34,12 +34,10 @@ export default {
3434
},
3535
},
3636
async run({ $ }) {
37-
const webflow = this.webflow._createApiClient();
38-
39-
const response = await webflow.removeItem({
40-
collectionId: this.collectionId,
41-
itemId: this.itemId,
42-
});
37+
const {
38+
collectionId, itemId,
39+
} = this;
40+
const response = await this.app.deleteCollectionItem(collectionId, itemId);
4341

4442
$.export("$summary", "Successfully deleted item");
4543

components/webflow/actions/fulfill-order/fulfill-order.mjs

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

33
export default {
44
key: "webflow-fulfill-order",
55
name: "Fulfill Order",
6-
description: "Fulfill an order. [See the docs here](https://developers.webflow.com/#fulfill-order)",
7-
version: "1.0.1",
6+
description: "Fulfill an order. [See the documentation](https://developers.webflow.com/data/reference/ecommerce/orders/update-fulfill)",
7+
version: "2.0.0",
88
type: "action",
99
props: {
10-
webflow,
10+
app,
1111
siteId: {
1212
propDefinition: [
13-
webflow,
13+
app,
1414
"sites",
1515
],
1616
},
1717
orderId: {
1818
propDefinition: [
19-
webflow,
19+
app,
2020
"orders",
2121
],
2222
},
@@ -28,13 +28,10 @@ export default {
2828
},
2929
},
3030
async run({ $ }) {
31-
const apiClient = this.webflow._createApiClient();
32-
33-
const response = await apiClient.post(`/sites/${this.siteId}/order/${this.orderId}/fulfill`, {
34-
data: {
35-
sendOrderFulfilledEmail: this.sendOrderFulfilledEmail,
36-
},
37-
});
31+
const {
32+
app, siteId, orderId, ...data
33+
} = this;
34+
const response = await app.fulfillOrder(siteId, orderId, data);
3835

3936
$.export("$summary", "Successfully fulfilled order");
4037

components/webflow/actions/get-collection-item/get-collection-item.mjs

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

33
export default {
44
key: "webflow-get-collection-item",
55
name: "Get Collection Item",
6-
description: "Get a Collection Item. [See the docs here](https://developers.webflow.com/#get-single-item)",
7-
version: "1.0.1",
6+
description: "Get a Collection Item. [See the documentation](https://developers.webflow.com/data/reference/cms/collection-items/staged-items/get-item)",
7+
version: "2.0.0",
88
type: "action",
99
props: {
10-
webflow,
10+
app,
1111
siteId: {
1212
propDefinition: [
13-
webflow,
13+
app,
1414
"sites",
1515
],
1616
},
1717
collectionId: {
1818
propDefinition: [
19-
webflow,
19+
app,
2020
"collections",
2121
(c) => ({
2222
siteId: c.siteId,
@@ -25,7 +25,7 @@ export default {
2525
},
2626
itemId: {
2727
propDefinition: [
28-
webflow,
28+
app,
2929
"items",
3030
(c) => ({
3131
collectionId: c.collectionId,
@@ -34,12 +34,7 @@ export default {
3434
},
3535
},
3636
async run({ $ }) {
37-
const webflow = this.webflow._createApiClient();
38-
39-
const response = await webflow.item({
40-
collectionId: this.collectionId,
41-
itemId: this.itemId,
42-
});
37+
const response = await this.app.getCollectionItem(this.collectionId, this.itemId);
4338

4439
$.export("$summary", "Successfully retrieved collection item");
4540

components/webflow/actions/get-collection/get-collection.mjs

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

33
export default {
44
key: "webflow-get-collection",
55
name: "Get Collection",
6-
description: "Get a collection. [See the docs here](https://developers.webflow.com/#get-collection-with-full-schema)",
7-
version: "1.0.1",
6+
description: "Get a collection. [See the documentation](https://developers.webflow.com/data/reference/cms/collections/get)",
7+
version: "2.0.0",
88
type: "action",
99
props: {
10-
webflow,
10+
app,
1111
siteId: {
1212
propDefinition: [
13-
webflow,
13+
app,
1414
"sites",
1515
],
1616
},
1717
collectionId: {
1818
propDefinition: [
19-
webflow,
19+
app,
2020
"collections",
2121
(c) => ({
2222
siteId: c.siteId,
@@ -25,7 +25,7 @@ export default {
2525
},
2626
},
2727
async run({ $ }) {
28-
const response = await this.webflow.getCollection(this.collectionId);
28+
const response = await this.app.getCollection(this.collectionId);
2929

3030
$.export("$summary", "Successfully retrieved collection");
3131

components/webflow/actions/get-item-inventory/get-item-inventory.mjs

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

33
export default {
44
key: "webflow-get-item-inventory",
55
name: "Get Item Inventory",
6-
description: "Get the inventory of a specific item. [See the docs here](https://developers.webflow.com/#item-inventory)",
7-
version: "1.0.1",
6+
description: "Get the inventory of a specific item. [See the documentation](https://developers.webflow.com/data/reference/ecommerce/inventory/list)",
7+
version: "2.0.0",
88
type: "action",
99
props: {
10-
webflow,
10+
app,
1111
siteId: {
1212
propDefinition: [
13-
webflow,
13+
app,
1414
"sites",
1515
],
1616
},
1717
collectionId: {
1818
propDefinition: [
19-
webflow,
19+
app,
2020
"collections",
2121
(c) => ({
2222
siteId: c.siteId,
@@ -25,7 +25,7 @@ export default {
2525
},
2626
itemId: {
2727
propDefinition: [
28-
webflow,
28+
app,
2929
"items",
3030
(c) => ({
3131
collectionId: c.collectionId,
@@ -34,9 +34,7 @@ export default {
3434
},
3535
},
3636
async run({ $ }) {
37-
const apiClient = this.webflow._createApiClient();
38-
39-
const response = await apiClient.apiClient.get(`/collections/${this.collectionId}/items/${this.itemId}/inventory`);
37+
const response = await this.app.getCollectionItemInventory(this.collectionId, this.itemId);
4038

4139
$.export("$summary", "Successfully retrieved item inventory");
4240

components/webflow/actions/get-order/get-order.mjs

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

33
export default {
44
key: "webflow-get-order",
55
name: "Get Order",
6-
description: "Get an order. [See the docs here](https://developers.webflow.com/#get-order)",
7-
version: "1.0.1",
6+
description: "Get info on an order. [See the documentation](https://developers.webflow.com/data/reference/ecommerce/orders/get)",
7+
version: "2.0.0",
88
type: "action",
99
props: {
10-
webflow,
10+
app,
1111
siteId: {
1212
propDefinition: [
13-
webflow,
13+
app,
1414
"sites",
1515
],
1616
},
1717
orderId: {
1818
propDefinition: [
19-
webflow,
19+
app,
2020
"orders",
2121
],
2222
},
2323
},
2424
async run({ $ }) {
25-
const response = await this.webflow.getOrder({
26-
siteId: this.siteId,
27-
orderId: this.orderId,
28-
});
25+
const response = await this.app.getOrder(this.siteId, this.orderId);
2926

3027
$.export("$summary", "Successfully retrieved order");
3128

0 commit comments

Comments
 (0)