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-draft-post/create-draft-post.mjs b/components/wix_api_key/actions/create-draft-post/create-draft-post.mjs new file mode 100644 index 0000000000000..e0396b97b75e1 --- /dev/null +++ b/components/wix_api_key/actions/create-draft-post/create-draft-post.mjs @@ -0,0 +1,160 @@ +import app from "../../wix_api_key.app.mjs"; + +export default { + key: "wix_api_key-create-draft-post", + name: "Create Draft Post", + description: "Creates a new draft post. [See the documentation](https://dev.wix.com/docs/rest/business-solutions/blog/draft-posts/create-draft-post).", + version: "0.0.1", + type: "action", + props: { + app, + title: { + type: "string", + label: "Title", + description: "Draft post title", + }, + featured: { + type: "boolean", + label: "Featured", + description: "Whether the draft post is marked as featured", + optional: true, + }, + categoryIds: { + type: "string[]", + label: "Category IDs", + description: "Category IDs of the draft post", + propDefinition: [ + app, + "categoryId", + ], + }, + memberId: { + description: "Draft post owner's member ID", + propDefinition: [ + app, + "memberId", + ], + }, + hashtags: { + type: "string[]", + label: "Hashtags", + description: "Hashtags of the draft post", + optional: true, + }, + commentingEnabled: { + type: "boolean", + label: "Commenting Enabled", + description: "Whether commenting is enabled on the draft post", + optional: true, + }, + tagIds: { + type: "string[]", + label: "Tag IDs", + description: "Tag IDs the draft post is tagged with", + propDefinition: [ + app, + "tagId", + ], + }, + relatedPostIds: { + type: "string[]", + label: "Related Post IDs", + description: "IDs of posts related to this draft post", + propDefinition: [ + app, + "postId", + ], + }, + language: { + type: "string", + label: "Language", + description: "Language the draft post is written in. 2-or-4-letter language code in [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. Eg. `en`", + optional: true, + }, + publish: { + type: "boolean", + label: "Publish", + description: "Whether to publish the post after creation", + optional: true, + }, + fieldsets: { + type: "string[]", + label: "Fieldsets", + description: "List of additional draft post fields to include in the response. For example, use the `URL` fieldset to retrieve the url field in the response in addition to the draft post's base fields. Base fields don't include any of the supported fieldset values. By default only the draft post's base fields are returned.", + optional: true, + options: [ + { + label: "If the user has not set excerpt, returns the one autogenerated from content.", + value: "GENERATED_EXCERPT", + }, + { + label: "Includes rich content field.", + value: "RICH_CONTENT", + }, + { + label: "Includes content field.", + value: "CONTENT", + }, + { + label: "Includes internal id field. Reserved for internal use.", + value: "INTERNAL_ID", + }, + { + label: "Includes draft post preview URL.", + value: "URL", + }, + { + label: "Unknown field.", + value: "UNKNOWN", + }, + ], + }, + }, + methods: { + createDraftPost(args = {}) { + return this.app._makeRequest({ + method: "POST", + path: "/blog/v3/draft-posts", + ...args, + }); + }, + }, + async run({ $ }) { + const { + createDraftPost, + title, + featured, + categoryIds, + memberId, + hashtags, + commentingEnabled, + tagIds, + relatedPostIds, + language, + publish, + fieldsets, + } = this; + + const response = await createDraftPost({ + $, + data: { + draftPost: { + title, + featured, + categoryIds, + memberId, + hashtags, + commentingEnabled, + tagIds, + relatedPostIds, + language, + }, + publish, + fieldsets, + }, + }); + + $.export("$summary", `Successfully created draft post with ID \`${response.draftPost.id}\`.`); + return response; + }, +}; 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/package.json b/components/wix_api_key/package.json index fa88deefd0bf1..5ab15f093358e 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": [ @@ -13,6 +13,6 @@ "access": "public" }, "dependencies": { - "@pipedream/platform": "^1.5.1" + "@pipedream/platform": "^3.0.3" } } 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..bd32a6274905a 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 @@ -6,7 +6,7 @@ export default { 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..e63b88ac6d3fa 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 @@ -6,7 +6,7 @@ export default { 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..73caee147f1ed 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 @@ -6,7 +6,7 @@ export default { 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..f20520a68797a 100644 --- a/components/wix_api_key/wix_api_key.app.mjs +++ b/components/wix_api_key/wix_api_key.app.mjs @@ -133,6 +133,107 @@ export default { })) || []; }, }, + categoryId: { + type: "string", + label: "Category ID", + description: "Category ID of the draft post", + optional: true, + async options({ page }) { + const limit = constants.DEFAULT_LIMIT; + const { categories } = await this.listCategories({ + params: { + "paging.limit": limit, + "paging.offset": page * limit, + }, + }); + return categories?.map(({ + id: value, label, + }) => ({ + value, + label, + })); + }, + }, + memberId: { + type: "string", + label: "Member ID", + description: "The identifier of a member", + optional: true, + async options({ page }) { + const limit = constants.DEFAULT_LIMIT; + const { members } = await this.listMembers({ + params: { + "paging.limit": limit, + "paging.offset": page * limit, + }, + }); + return members?.map(({ + id: value, loginEmail: label, + }) => ({ + value, + label, + })); + }, + }, + tagId: { + type: "string", + label: "Tag ID", + description: "Tag ID of the draft post", + optional: true, + async options({ page }) { + const limit = constants.DEFAULT_LIMIT; + const { tags } = await this.queryTags({ + data: { + query: { + paging: { + limit, + offset: page * limit, + }, + }, + }, + }); + return tags?.map(({ + id: value, label, + }) => ({ + value, + label, + })); + }, + }, + postId: { + type: "string", + label: "Post ID", + description: "ID of a post", + optional: true, + useQuery: true, + async options({ + page, query, + filter = { + title: { + "$contains": query, + }, + }, + }) { + const limit = constants.DEFAULT_LIMIT; + const { posts } = await this.queryPosts({ + data: { + query: { + filter, + paging: { + limit, + offset: page * limit, + }, + }, + }, + }); + return posts?.map(({ + id: value, title, + }) => ({ + value, + label: title, + })); + }, + }, }, methods: { _baseUrl() { @@ -146,7 +247,9 @@ export default { }, async getSiteHeaders(siteId) { if (!siteId) { - return {}; + return { + "wix-account-id": this.$auth.account_id, + }; } const accountId = await this.getSiteAccountId(siteId); return { @@ -236,6 +339,26 @@ export default { ...args, }); }, + listCategories(args = {}) { + return this._makeRequest({ + path: "/blog/v3/categories", + ...args, + }); + }, + queryTags(args = {}) { + return this._makeRequest({ + method: "POST", + path: "/blog/v2/tags/query", + ...args, + }); + }, + queryPosts(args = {}) { + return this._makeRequest({ + method: "POST", + path: "/blog/v3/posts/query", + ...args, + }); + }, createContact(args = {}) { return this._makeRequest({ path: "/contacts/v4/contacts", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f732f3bdf4a7f..67b86b94777f9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14014,8 +14014,8 @@ importers: components/wix_api_key: dependencies: '@pipedream/platform': - specifier: ^1.5.1 - version: 1.6.6 + specifier: ^3.0.3 + version: 3.0.3 components/wiza: dependencies: @@ -20390,8 +20390,8 @@ packages: axios@1.7.9: resolution: {integrity: sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==} - axios@1.8.2: - resolution: {integrity: sha512-ls4GYBm5aig9vWx8AWDSGLpnpDQRtWAfrjU+EuytuODrFBkqesN2RkOQCBzrA1RQNHw1SmRMSDDDSwzNAYQ6Rg==} + axios@1.8.3: + resolution: {integrity: sha512-iP4DebzoNlP/YN2dpwCgb8zoCmhtkajzS48JvwmkSkXvPI3DHc7m+XYL5tGnSlJtR6nImXZmdCuN5aP8dh1d8A==} axobject-query@4.1.0: resolution: {integrity: sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==} @@ -22710,6 +22710,10 @@ packages: resolution: {integrity: sha512-GgwY0PS7DbXqajuGf4OYlsrIu3zgxD6Vvql43IBhm6MahqA5SK/7mwhtNj2AdH2z35YR34ujJ7BN+3fFC3jP5Q==} engines: {node: '>= 0.12'} + form-data@2.5.3: + resolution: {integrity: sha512-XHIrMD0NpDrNM/Ckf7XJiBbLl57KEhT3+i3yY+eWm+cqYZJQTZrKo8Y8AWKnuV5GT4scfuUGt9LzNoIx3dU1nQ==} + engines: {node: '>= 0.12'} + form-data@3.0.0: resolution: {integrity: sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==} engines: {node: '>= 6'} @@ -33904,7 +33908,7 @@ snapshots: '@pipedream/platform@3.0.3': dependencies: - axios: 1.7.7(debug@3.2.7) + axios: 1.8.3 fp-ts: 2.16.9 io-ts: 2.2.22(fp-ts@2.16.9) querystring: 0.2.1 @@ -36336,7 +36340,7 @@ snapshots: '@types/caseless': 0.12.5 '@types/node': 20.17.6 '@types/tough-cookie': 4.0.5 - form-data: 2.5.2 + form-data: 2.5.3 '@types/responselike@1.0.3': dependencies: @@ -36998,7 +37002,7 @@ snapshots: dependencies: '@aws-sdk/util-utf8-browser': 3.259.0 '@httptoolkit/websocket-stream': 6.0.1 - axios: 1.8.2 + axios: 1.8.3 buffer: 6.0.3 crypto-js: 4.2.0 mqtt: 4.3.8 @@ -37104,7 +37108,7 @@ snapshots: transitivePeerDependencies: - debug - axios@1.8.2: + axios@1.8.3: dependencies: follow-redirects: 1.15.9(debug@3.2.7) form-data: 4.0.2 @@ -39892,6 +39896,14 @@ snapshots: mime-types: 2.1.35 safe-buffer: 5.2.1 + form-data@2.5.3: + dependencies: + asynckit: 0.4.0 + combined-stream: 1.0.8 + es-set-tostringtag: 2.1.0 + mime-types: 2.1.35 + safe-buffer: 5.2.1 + form-data@3.0.0: dependencies: asynckit: 0.4.0