From f35f351f2e479a810d3f65526e89f25b771410ff Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Tue, 24 Sep 2024 13:49:12 -0400 Subject: [PATCH 1/2] remove async options from update-metafield props --- .../actions/common/metafield-actions.mjs | 2 +- .../create-metafield/create-metafield.mjs | 2 +- .../actions/get-metafields/get-metafields.mjs | 2 +- .../update-metafield/update-metafield.mjs | 60 ++++++++++++++++++- .../actions/update-product/update-product.mjs | 2 +- components/shopify_developer_app/package.json | 2 +- 6 files changed, 64 insertions(+), 6 deletions(-) diff --git a/components/shopify_developer_app/actions/common/metafield-actions.mjs b/components/shopify_developer_app/actions/common/metafield-actions.mjs index 55f8f48ff60a0..2cf5f9acc7794 100644 --- a/components/shopify_developer_app/actions/common/metafield-actions.mjs +++ b/components/shopify_developer_app/actions/common/metafield-actions.mjs @@ -4,7 +4,7 @@ import metafieldActions from "../../../shopify/actions/common/metafield-actions. export default { ...metafieldActions, props: { - ...metafieldActions.props, shopify, + ...metafieldActions.props, }, }; diff --git a/components/shopify_developer_app/actions/create-metafield/create-metafield.mjs b/components/shopify_developer_app/actions/create-metafield/create-metafield.mjs index da165dcad38b0..1a504e5220b41 100644 --- a/components/shopify_developer_app/actions/create-metafield/create-metafield.mjs +++ b/components/shopify_developer_app/actions/create-metafield/create-metafield.mjs @@ -6,7 +6,7 @@ export default { key: "shopify_developer_app-create-metafield", name: "Create Metafield", description: "Creates a metafield belonging to a resource. [See the docs](https://shopify.dev/api/admin-rest/2023-01/resources/metafield#post-blogs-blog-id-metafields)", - version: "0.0.3", + version: "0.0.4", type: "action", props: { ...metafieldActions.props, diff --git a/components/shopify_developer_app/actions/get-metafields/get-metafields.mjs b/components/shopify_developer_app/actions/get-metafields/get-metafields.mjs index 5adcec730fb3a..a42c4a696f9f0 100644 --- a/components/shopify_developer_app/actions/get-metafields/get-metafields.mjs +++ b/components/shopify_developer_app/actions/get-metafields/get-metafields.mjs @@ -6,7 +6,7 @@ export default { key: "shopify_developer_app-get-metafields", name: "Get Metafields", description: "Retrieves a list of metafields that belong to a resource. [See the docs](https://shopify.dev/api/admin-rest/2023-01/resources/metafield#get-metafields?metafield[owner-id]=382285388&metafield[owner-resource]=blog)", - version: "0.0.3", + version: "0.0.4", type: "action", props: { ...metafieldActions.props, diff --git a/components/shopify_developer_app/actions/update-metafield/update-metafield.mjs b/components/shopify_developer_app/actions/update-metafield/update-metafield.mjs index 6e3df5d633558..7ca4f25274e12 100644 --- a/components/shopify_developer_app/actions/update-metafield/update-metafield.mjs +++ b/components/shopify_developer_app/actions/update-metafield/update-metafield.mjs @@ -1,19 +1,77 @@ import metafieldActions from "../common/metafield-actions.mjs"; import common from "../../../shopify/actions/update-metafield/common.mjs"; +import shopify from "../../../shopify/shopify.app.mjs"; export default { ...common, key: "shopify_developer_app-update-metafield", name: "Update Metafield", description: "Updates a metafield belonging to a resource. [See the docs](https://shopify.dev/api/admin-rest/2023-01/resources/metafield#put-blogs-blog-id-metafields-metafield-id)", - version: "0.0.3", + version: "0.0.4", type: "action", props: { ...metafieldActions.props, ...common.props, }, + async additionalProps() { + const props = await this.getOwnerIdProp(this.ownerResource); + + props.metafieldId = { + type: "string", + label: "Metafield ID", + description: "The metafield to update", + }; + props.value = { + type: "string", + label: "Value", + description: "The data to store in the metafield", + }; + + return props; + }, methods: { ...metafieldActions.methods, ...common.methods, + async getOwnerIdProp(ownerResource) { + const resources = { + product: shopify.propDefinitions.productId, + variants: shopify.propDefinitions.productVariantId, + product_image: { + ...shopify.propDefinitions.imageId, + optional: false, + }, + customer: shopify.propDefinitions.customerId, + collection: { + ...shopify.propDefinitions.collectionId, + optional: false, + }, + blog: shopify.propDefinitions.blogId, + article: shopify.propDefinitions.articleId, + page: shopify.propDefinitions.pageId, + order: shopify.propDefinitions.orderId, + draft_order: shopify.propDefinitions.draftOrderId, + }; + + const props = {}; + + if (ownerResource === "variants" || ownerResource === "product_image") { + props.productId = resources.product; + } + if (ownerResource === "article") { + props.blogId = resources.blog; + } + + Object.values(resources).forEach((resource) => { + delete resource.options; + }); + Object.values(props).forEach((prop) => { + delete prop.options; + }); + + return { + ...props, + ownerId: resources[ownerResource], + }; + }, }, }; diff --git a/components/shopify_developer_app/actions/update-product/update-product.mjs b/components/shopify_developer_app/actions/update-product/update-product.mjs index e4bbe5e068153..a39a1c93c3960 100644 --- a/components/shopify_developer_app/actions/update-product/update-product.mjs +++ b/components/shopify_developer_app/actions/update-product/update-product.mjs @@ -8,7 +8,7 @@ export default { key: "shopify_developer_app-update-product", name: "Update Product", description: "Update an existing product. [See the docs](https://shopify.dev/api/admin-rest/2022-01/resources/product#[put]/admin/api/2022-01/products/{product_id}.json)", - version: "0.0.3", + version: "0.0.4", type: "action", props: { shopify, diff --git a/components/shopify_developer_app/package.json b/components/shopify_developer_app/package.json index e11cf2677d101..557297fe78ce2 100644 --- a/components/shopify_developer_app/package.json +++ b/components/shopify_developer_app/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/shopify_developer_app", - "version": "0.4.0", + "version": "0.4.1", "description": "Pipedream Shopify (Developer App) Components", "main": "shopify_developer_app.app.mjs", "keywords": [ From 19f1456d879e8513d8023eef7e890ea7f749d6ae Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Tue, 24 Sep 2024 13:53:05 -0400 Subject: [PATCH 2/2] versions --- .../actions/delete-metafield/delete-metafield.mjs | 2 +- .../actions/update-customer/update-customer.mjs | 2 +- .../actions/update-product-variant/update-product-variant.mjs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/shopify_developer_app/actions/delete-metafield/delete-metafield.mjs b/components/shopify_developer_app/actions/delete-metafield/delete-metafield.mjs index 747f5a9e688ec..1836c3fc95c57 100644 --- a/components/shopify_developer_app/actions/delete-metafield/delete-metafield.mjs +++ b/components/shopify_developer_app/actions/delete-metafield/delete-metafield.mjs @@ -6,7 +6,7 @@ export default { key: "shopify_developer_app-delete-metafield", name: "Delete Metafield", description: "Deletes a metafield belonging to a resource. [See the documentation](https://shopify.dev/docs/api/admin-rest/2023-01/resources/metafield#delete-blogs-blog-id-metafields-metafield-id)", - version: "0.0.3", + version: "0.0.4", type: "action", props: { ...metafieldActions.props, diff --git a/components/shopify_developer_app/actions/update-customer/update-customer.mjs b/components/shopify_developer_app/actions/update-customer/update-customer.mjs index d8f72dcf6e7a6..b036464fe3a06 100644 --- a/components/shopify_developer_app/actions/update-customer/update-customer.mjs +++ b/components/shopify_developer_app/actions/update-customer/update-customer.mjs @@ -8,7 +8,7 @@ export default { key: "shopify_developer_app-update-customer", name: "Update Customer", description: "Update a existing customer. [See the docs](https://shopify.dev/api/admin-rest/2022-01/resources/customer#[put]/admin/api/2022-01/customers/{customer_id}.json)", - version: "0.0.3", + version: "0.0.4", type: "action", props: { shopify, diff --git a/components/shopify_developer_app/actions/update-product-variant/update-product-variant.mjs b/components/shopify_developer_app/actions/update-product-variant/update-product-variant.mjs index af8c120e816c8..345995566ded9 100644 --- a/components/shopify_developer_app/actions/update-product-variant/update-product-variant.mjs +++ b/components/shopify_developer_app/actions/update-product-variant/update-product-variant.mjs @@ -8,7 +8,7 @@ export default { key: "shopify_developer_app-update-product-variant", name: "Update Product Variant", description: "Update an existing product variant. [See the docs](https://shopify.dev/api/admin-rest/2022-01/resources/product-variant#[put]/admin/api/2022-01/variants/{variant_id}.json)", - version: "0.0.4", + version: "0.0.5", type: "action", props: { shopify,