Skip to content

Commit c31961c

Browse files
committed
Migrating more actions
1 parent f122394 commit c31961c

File tree

5 files changed

+73
-76
lines changed

5 files changed

+73
-76
lines changed

components/webflow/actions/publish-site/publish-site.mjs

Lines changed: 0 additions & 39 deletions
This file was deleted.

components/webflow/actions/get-item-inventory/get-item-inventory.mjs renamed to components/webflow_v2/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_v2.app.mjs";
22

33
export default {
4-
key: "webflow-get-item-inventory",
4+
key: "webflow_v2-get-item-inventory",
55
name: "Get Item Inventory",
66
description: "Get the inventory of a specific item. [See the docs here](https://developers.webflow.com/#item-inventory)",
7-
version: "0.0.5",
7+
version: "0.0.{{ts}}",
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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import app from "../../webflow_v2.app.mjs";
2+
3+
export default {
4+
key: "webflow_v2-publish-site",
5+
name: "Publish Site",
6+
description: "Publish a site. [See the docs here](https://developers.webflow.com/#publish-site)",
7+
version: "0.0.{{ts}}",
8+
type: "action",
9+
props: {
10+
app,
11+
siteId: {
12+
propDefinition: [
13+
app,
14+
"sites",
15+
],
16+
},
17+
domains: {
18+
propDefinition: [
19+
app,
20+
"domains",
21+
(c) => ({
22+
siteId: c.siteId,
23+
}),
24+
],
25+
},
26+
},
27+
async run({ $ }) {
28+
const response = await this.app.publishSite(siteId, domains);
29+
30+
$.export("$summary", "Successfully published site");
31+
32+
return response;
33+
},
34+
};

components/webflow/actions/update-item-inventory/update-item-inventory.mjs renamed to components/webflow_v2/actions/update-item-inventory/update-item-inventory.mjs

Lines changed: 15 additions & 22 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_v2.app.mjs";
22

33
export default {
4-
key: "webflow-update-item-inventory",
4+
key: "webflow_v2-update-item-inventory",
55
name: "Update Item Inventory",
66
description: "Update the inventory of a specific item. [See the docs here](https://developers.webflow.com/#update-item-inventory)",
77
version: "0.0.5",
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,
@@ -43,35 +43,28 @@ export default {
4343
},
4444
quantity: {
4545
label: "Quantity",
46-
description: "The quantity will be seted with this value. This just can be used with `finite` option selected and without `updateQuantity` value.",
46+
description: "If specified, sets quantity to this value. Can only be used with the `finite` inventory type, and if `Update Quantity` is not specified.",
4747
type: "integer",
4848
optional: true,
4949
},
5050
updateQuantity: {
5151
label: "Update Quantity",
52-
description: "This value will be added to the quantity. This just can be used with `finite` option selected and without `quantity` value.",
52+
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.",
5353
type: "integer",
5454
optional: true,
5555
},
5656
},
5757
async run({ $ }) {
58-
const apiClient = this.webflow._createApiClient();
59-
6058
const {
61-
inventoryType,
62-
quantity,
63-
updateQuantity,
59+
app,
60+
// eslint-disable-next-line no-unused-vars
61+
siteId,
62+
collectionId,
63+
itemId,
64+
...data
6465
} = this;
6566

66-
const response = await apiClient.patch(`/collections/${this.collectionId}/items/${this.itemId}/inventory`, {
67-
data: {
68-
fields: {
69-
inventoryType,
70-
quantity,
71-
updateQuantity,
72-
},
73-
},
74-
});
67+
const response = await this.app.updateCollectionItemInventory(collectionId, itemId, data);
7568

7669
$.export("$summary", "Successfully updated item inventory");
7770

components/webflow_v2/webflow_v2.app.mjs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
propDefinitions: {
88
domains: {
99
label: "Domain",
10-
description: "The list of domains.",
10+
description: "Select one or more domains, or provide custom domain IDs.",
1111
type: "string[]",
1212
async options({ siteId }) {
1313
const domains = await this.getDomains(siteId);
@@ -17,7 +17,7 @@ export default {
1717
},
1818
sites: {
1919
label: "Site",
20-
description: "The list of sites",
20+
description: "Select a site or provide a custom site ID.",
2121
type: "string",
2222
async options() {
2323
const sites = await this.getSites();
@@ -30,7 +30,7 @@ export default {
3030
},
3131
collections: {
3232
label: "Collection",
33-
description: "The list of collection of a site",
33+
description: "Select a collection or provide a custom collection ID.",
3434
type: "string",
3535
async options({ siteId }) {
3636
const collections = await this.getCollections(siteId);
@@ -43,7 +43,7 @@ export default {
4343
},
4444
items: {
4545
label: "Item",
46-
description: "The list of items of a collection",
46+
description: "Select an item or provide a custom item ID.",
4747
type: "string",
4848
async options({
4949
collectionId, page,
@@ -58,7 +58,7 @@ export default {
5858
},
5959
orders: {
6060
label: "Order",
61-
description: "The list of orders of a site",
61+
description: "Select an order, or provide a custom order ID.",
6262
type: "string",
6363
async options({
6464
siteId, page,
@@ -158,5 +158,16 @@ export default {
158158
updateCollectionItem(collectionId, itemId, data) {
159159
return this.webflowClient().collections.items.updateItem(collectionId, itemId, data);
160160
},
161+
getCollectionItemInventory(collectionId, itemId) {
162+
return this.webflowClient().inventory.list(collectionId, itemId);
163+
},
164+
updateCollectionItemInventory(collectionId, itemId, data) {
165+
return this.webflowClient().inventory.update(collectionId, itemId, data);
166+
},
167+
publishSite(siteId, customDomains) {
168+
return this.webflowClient().sites.publish(siteId, {
169+
customDomains
170+
})
171+
}
161172
},
162173
};

0 commit comments

Comments
 (0)