From 57ab82a6c1548870dffe3f1c1c5722476516a1eb Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Wed, 9 Jul 2025 16:57:45 -0300 Subject: [PATCH 1/2] [FEATURE] Create new action to create Wix draft post #17460 Actions - Publish Draft Post --- .../add-products-to-collection.mjs | 2 +- .../actions/create-contact/create-contact.mjs | 2 +- .../actions/create-product/create-product.mjs | 2 +- .../actions/get-contact/get-contact.mjs | 2 +- .../publish-draft-post/publish-draft-post.mjs | 42 ++++++++++++++++++ components/wix_api_key/package.json | 2 +- .../new-member-registered.mjs | 4 +- .../new-order-created/new-order-created.mjs | 4 +- .../new-product-created.mjs | 4 +- components/wix_api_key/wix_api_key.app.mjs | 43 +++++++++++++++++++ 10 files changed, 96 insertions(+), 11 deletions(-) create mode 100644 components/wix_api_key/actions/publish-draft-post/publish-draft-post.mjs diff --git a/components/wix_api_key/actions/add-products-to-collection/add-products-to-collection.mjs b/components/wix_api_key/actions/add-products-to-collection/add-products-to-collection.mjs index 77008a0867b33..eb56c65b2645b 100644 --- a/components/wix_api_key/actions/add-products-to-collection/add-products-to-collection.mjs +++ b/components/wix_api_key/actions/add-products-to-collection/add-products-to-collection.mjs @@ -4,7 +4,7 @@ export default { key: "wix_api_key-add-products-to-collection", name: "Add Products To Collection", description: "Adds a product or products to a specified collection. [See the documentation](https://dev.wix.com/api/rest/wix-stores/catalog/collections/add-products-to-collection)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { wix, diff --git a/components/wix_api_key/actions/create-contact/create-contact.mjs b/components/wix_api_key/actions/create-contact/create-contact.mjs index c2fa37eb90af7..ad04a11974243 100644 --- a/components/wix_api_key/actions/create-contact/create-contact.mjs +++ b/components/wix_api_key/actions/create-contact/create-contact.mjs @@ -4,7 +4,7 @@ export default { key: "wix_api_key-create-contact", name: "Create Contact", description: "Creates a new contact. [See the documentation](https://dev.wix.com/api/rest/contacts/contacts/contacts-v4/create-contact)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { wix, diff --git a/components/wix_api_key/actions/create-product/create-product.mjs b/components/wix_api_key/actions/create-product/create-product.mjs index c9d82e9889ed1..feb8a23957307 100644 --- a/components/wix_api_key/actions/create-product/create-product.mjs +++ b/components/wix_api_key/actions/create-product/create-product.mjs @@ -4,7 +4,7 @@ export default { key: "wix_api_key-create-product", name: "Create Product", description: "Creates a new product. [See the documentation](https://dev.wix.com/api/rest/wix-stores/catalog/products/create-product)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { wix, diff --git a/components/wix_api_key/actions/get-contact/get-contact.mjs b/components/wix_api_key/actions/get-contact/get-contact.mjs index fe8c26ec74fd6..1405a1b8db925 100644 --- a/components/wix_api_key/actions/get-contact/get-contact.mjs +++ b/components/wix_api_key/actions/get-contact/get-contact.mjs @@ -4,7 +4,7 @@ export default { key: "wix_api_key-get-contact", name: "Get Contact", description: "Retrieves information about a contact. [See the documentation](https://dev.wix.com/api/rest/contacts/contacts/contacts-v4/get-contact)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { wix, diff --git a/components/wix_api_key/actions/publish-draft-post/publish-draft-post.mjs b/components/wix_api_key/actions/publish-draft-post/publish-draft-post.mjs new file mode 100644 index 0000000000000..03054953361d1 --- /dev/null +++ b/components/wix_api_key/actions/publish-draft-post/publish-draft-post.mjs @@ -0,0 +1,42 @@ +import wix from "../../wix_api_key.app.mjs"; + +export default { + key: "wix_api_key-publish-draft-post", + name: "Publish Draft Post", + description: "Publish a draft blog post [See the documentation](https://dev.wix.com/docs/rest/business-solutions/blog/draft-posts/publish-draft-post)", + version: "0.0.1", + type: "action", + props: { + wix, + alert: { + type: "alert", + alertType: "info", + content: "Note: You must have 'Blog' installed in your Wix website or this will return an error.", + }, + site: { + propDefinition: [ + wix, + "site", + ], + }, + draftPostId: { + propDefinition: [ + wix, + "draftPostId", + (c) => ({ + siteId: c.site, + }), + ], + }, + }, + async run({ $ }) { + const response = await this.wix.publishDraftPost({ + $, + siteId: this.site, + postId: this.draftPostId, + }); + + $.export("$summary", `Successfully published draft post ${this.draftPostId}`); + return response; + }, +}; diff --git a/components/wix_api_key/package.json b/components/wix_api_key/package.json index fa88deefd0bf1..68018fc42eafd 100644 --- a/components/wix_api_key/package.json +++ b/components/wix_api_key/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/wix_api_key", - "version": "0.1.0", + "version": "0.2.0", "description": "Pipedream Wix Components", "main": "wix_api_key.app.mjs", "keywords": [ diff --git a/components/wix_api_key/sources/new-member-registered/new-member-registered.mjs b/components/wix_api_key/sources/new-member-registered/new-member-registered.mjs index 8182a2e093a79..8537684bb87f7 100644 --- a/components/wix_api_key/sources/new-member-registered/new-member-registered.mjs +++ b/components/wix_api_key/sources/new-member-registered/new-member-registered.mjs @@ -1,12 +1,12 @@ -import common from "../common/common.mjs"; import constants from "../../common/constants.mjs"; +import common from "../common/common.mjs"; export default { ...common, key: "wix_api_key-new-member-registered", name: "New Member Registered", description: "Emit new event when a new member is registered. [See the documentation](https://dev.wix.com/api/rest/members/members/list-members)", - version: "0.0.1", + version: "0.0.2", type: "source", methods: { ...common.methods, diff --git a/components/wix_api_key/sources/new-order-created/new-order-created.mjs b/components/wix_api_key/sources/new-order-created/new-order-created.mjs index 05329c210a9dc..87713bb86d7ca 100644 --- a/components/wix_api_key/sources/new-order-created/new-order-created.mjs +++ b/components/wix_api_key/sources/new-order-created/new-order-created.mjs @@ -1,12 +1,12 @@ -import common from "../common/common.mjs"; import constants from "../../common/constants.mjs"; +import common from "../common/common.mjs"; export default { ...common, key: "wix_api_key-new-order-created", name: "New Order Created", description: "Emit new event when a new order is created. [See the documentation](https://dev.wix.com/api/rest/wix-stores/orders/query-orders)", - version: "0.0.1", + version: "0.0.2", type: "source", methods: { ...common.methods, diff --git a/components/wix_api_key/sources/new-product-created/new-product-created.mjs b/components/wix_api_key/sources/new-product-created/new-product-created.mjs index 624d0f141f73f..1a2671d4fea5d 100644 --- a/components/wix_api_key/sources/new-product-created/new-product-created.mjs +++ b/components/wix_api_key/sources/new-product-created/new-product-created.mjs @@ -1,12 +1,12 @@ -import common from "../common/common.mjs"; import constants from "../../common/constants.mjs"; +import common from "../common/common.mjs"; export default { ...common, key: "wix_api_key-new-product-created", name: "New Product Created", description: "Emit new event when a new product is created. [See the documentation](https://dev.wix.com/api/rest/wix-stores/catalog/products/query-products)", - version: "0.0.1", + version: "0.0.2", type: "source", methods: { ...common.methods, diff --git a/components/wix_api_key/wix_api_key.app.mjs b/components/wix_api_key/wix_api_key.app.mjs index 696a52dc6ed28..c290ed048f994 100644 --- a/components/wix_api_key/wix_api_key.app.mjs +++ b/components/wix_api_key/wix_api_key.app.mjs @@ -133,6 +133,33 @@ export default { })) || []; }, }, + draftPostId: { + type: "string", + label: "Draft Post ID", + description: "The ID of the draft post to publish", + async options({ + page, siteId, + }) { + const limit = constants.DEFAULT_LIMIT; + const params = { + "paging.limit": limit, + "paging.offset": page * limit, + "status": "UNPUBLISHED", + }; + + const { draftPosts } = await this.listDraftPosts({ + siteId, + params, + }); + + return draftPosts?.map(({ + id: value, title: label, + }) => ({ + label, + value, + })) || []; + }, + }, }, methods: { _baseUrl() { @@ -259,5 +286,21 @@ export default { ...args, }); }, + listDraftPosts(opts = {}) { + return this._makeRequest({ + path: "/blog/v3/draft-posts", + ...opts, + }); + }, + publishDraftPost({ + postId, + ...opts + }) { + return this._makeRequest({ + method: "POST", + path: `/blog/v3/draft-posts/${postId}/publish`, + ...opts, + }); + }, }, }; From 84c4e6f0c4a359cc3abe04807a0756435182b8d5 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Wed, 9 Jul 2025 17:02:19 -0300 Subject: [PATCH 2/2] pnpm update --- pnpm-lock.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1726721f05b06..f70a38b591de3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13305,8 +13305,7 @@ importers: components/switchboard: {} - components/sylius: - specifiers: {} + components/sylius: {} components/symbl_ai: dependencies: