diff --git a/components/shopify_developer_app/actions/add-product-to-custom-collection/add-product-to-custom-collection.mjs b/components/shopify_developer_app/actions/add-product-to-custom-collection/add-product-to-custom-collection.mjs index 710f9cbbad39e..e42356ba965ee 100644 --- a/components/shopify_developer_app/actions/add-product-to-custom-collection/add-product-to-custom-collection.mjs +++ b/components/shopify_developer_app/actions/add-product-to-custom-collection/add-product-to-custom-collection.mjs @@ -1,32 +1,22 @@ import shopify from "../../shopify_developer_app.app.mjs"; -import common from "@pipedream/shopify/actions/add-product-to-custom-collection/common.mjs"; +import common from "@pipedream/shopify/actions/add-product-to-custom-collection/add-product-to-custom-collection.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, shopify); export default { - ...common, + ...others, key: "shopify_developer_app-add-product-to-custom-collection", - name: "Add Products to Custom Collections", - description: "Adds a product or products to a custom collection or collections. [See the docs](https://shopify.dev/docs/api/admin-rest/2023-01/resources/collect#post-collects)", - version: "0.0.4", - type: "action", + version: "0.0.5", + name, + description, + type, props: { shopify, - productIds: { - propDefinition: [ - shopify, - "productId", - ], - type: "string[]", - label: "Product IDs", - }, - collectionIds: { - propDefinition: [ - shopify, - "collectionId", - ], - type: "string[]", - label: "Collection IDs", - description: "IDs of the collections that the product will be added to", - optional: false, - }, + ...props, }, }; diff --git a/components/shopify_developer_app/actions/add-tags/add-tags.mjs b/components/shopify_developer_app/actions/add-tags/add-tags.mjs index 62be49b75da50..72208abf278e3 100644 --- a/components/shopify_developer_app/actions/add-tags/add-tags.mjs +++ b/components/shopify_developer_app/actions/add-tags/add-tags.mjs @@ -1,15 +1,22 @@ import shopify from "../../shopify_developer_app.app.mjs"; -import common from "@pipedream/shopify/actions/add-tags/common.mjs"; +import common from "@pipedream/shopify/actions/add-tags/add-tags.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, shopify); export default { - ...common, - name: "Add Tags", - version: "0.0.4", + ...others, key: "shopify_developer_app-add-tags", - description: "Add tags. [See the documentation](https://shopify.dev/api/admin-graphql/2022-07/mutations/tagsadd)", - type: "action", + version: "0.0.5", + name, + description, + type, props: { shopify, - ...common.props, + ...props, }, }; diff --git a/components/shopify_developer_app/actions/common/constants.mjs b/components/shopify_developer_app/actions/common/constants.mjs new file mode 100644 index 0000000000000..3fcae1e594a5e --- /dev/null +++ b/components/shopify_developer_app/actions/common/constants.mjs @@ -0,0 +1,86 @@ +const RESOURCE_TYPES = [ + { + label: "Blog", + value: "blog", + }, + { + label: "Collection", + value: "collection", + }, + { + label: "Customer", + value: "customer", + }, + { + label: "Draft Order", + value: "draftOrder", + }, + { + label: "Page", + value: "page", + }, + { + label: "Product", + value: "product", + }, + { + label: "Product Variant", + value: "variants", + }, + { + label: "Article", + value: "article", + }, + { + label: "Order", + value: "order", + }, +]; + +const METAFIELD_TYPES = { + "boolean": "boolean", + "collection_reference": "string", + "color": "string", + "date": "string", + "date_time": "string", + "dimension": "object", + "file_reference": "string", + "json": "object", + "metaobject_reference": "string", + "mixed_reference": "string", + "money": "object", + "multi_line_text_field": "string", + "number_decimal": "string", + "number_integer": "integer", + "page_reference": "string", + "product_reference": "string", + "rating": "object", + "single_line_text_field": "string", + "url": "string", + "variant_reference": "string", + "volume": "object", + "weight": "object", + "list.collection_reference": "string[]", + "list.color": "string[]", + "list.date": "string[]", + "list.date_time": "string[]", + "list.dimension": "string[]", + "list.file_reference": "string[]", + "list.metaobject_reference": "string[]", + "list.mixed_reference": "string[]", + "list.number_integer": "string[]", + "list.number_decimal": "string[]", + "list.page_reference": "string[]", + "list.product_reference": "string[]", + "list.rating": "string[]", + "list.single_line_text_field": "string[]", + "list.url": "string[]", + "list.variant_reference": "string[]", + "list.volume": "string[]", + "list.weight": "string[]", +}; + +export default { + RESOURCE_TYPES, + METAFIELD_TYPES, +}; diff --git a/components/shopify_developer_app/actions/common/metafield-actions.mjs b/components/shopify_developer_app/actions/common/metafield-actions.mjs index 97b660b61bbf4..058f8ae46e7f1 100644 --- a/components/shopify_developer_app/actions/common/metafield-actions.mjs +++ b/components/shopify_developer_app/actions/common/metafield-actions.mjs @@ -1,10 +1,271 @@ import shopify from "../../shopify_developer_app.app.mjs"; -import metafieldActions from "@pipedream/shopify/actions/common/metafield-actions.mjs"; +import constants from "./constants.mjs"; +import utils from "@pipedream/shopify/common/utils.mjs"; +import { MAX_LIMIT } from "@pipedream/shopify/common/constants.mjs"; export default { - ...metafieldActions, props: { - ...metafieldActions.props, shopify, + ownerResource: { + type: "string", + label: "Resource Type", + description: "Filter by the resource type on which the metafield is attached to", + options: constants.RESOURCE_TYPES, + reloadProps: true, + }, + }, + methods: { + async getOwnerIdProp(ownerResource) { + const resources = { + product: { + ...shopify.propDefinitions.productId, + options: async ({ prevContext }) => { + return this.shopify.getPropOptions({ + resourceFn: this.shopify.listProducts, + resourceKeys: [ + "products", + ], + prevContext, + }); + }, + }, + variants: { + ...shopify.propDefinitions.productVariantId, + options: async ({ prevContext }) => { + return this.shopify.getPropOptions({ + resourceFn: this.shopify.listProductVariants, + resourceKeys: [ + "productVariants", + ], + variables: { + query: `product_id:${this.productId.split("/").pop()}`, + }, + prevContext, + }); + }, + }, + collection: { + ...shopify.propDefinitions.collectionId, + options: async ({ prevContext }) => { + return this.shopify.getPropOptions({ + resourceFn: this.shopify.listCollections, + resourceKeys: [ + "collections", + ], + prevContext, + }); + }, + optional: false, + }, + blog: { + ...shopify.propDefinitions.blogId, + options: async ({ prevContext }) => { + return this.shopify.getPropOptions({ + resourceFn: this.shopify.listBlogs, + resourceKeys: [ + "blogs", + ], + prevContext, + }); + }, + }, + article: { + ...shopify.propDefinitions.articleId, + options: async ({ prevContext }) => { + return this.shopify.getPropOptions({ + resourceFn: this.shopify.listBlogArticles, + resourceKeys: [ + "blog", + "articles", + ], + variables: { + id: this.blogId, + }, + prevContext, + }); + }, + }, + page: { + ...shopify.propDefinitions.pageId, + options: async ({ prevContext }) => { + return this.shopify.getPropOptions({ + resourceFn: this.shopify.listPages, + resourceKeys: [ + "pages", + ], + prevContext, + }); + }, + }, + customer: { + ...shopify.propDefinitions.customerId, + options: async ({ prevContext }) => { + return this.shopify.getPropOptions({ + resourceFn: this.shopify.listCustomers, + resourceKeys: [ + "customers", + ], + labelKey: "displayName", + prevContext, + }); + }, + }, + draftOrder: { + type: "string", + label: "Draft Order ID", + description: "The identifier of a draft order", + options: async ({ prevContext }) => { + return this.shopify.getPropOptions({ + resourceFn: this.shopify.listDraftOrders, + resourceKeys: [ + "draftOrders", + ], + labelKey: "id", + prevContext, + }); + }, + }, + order: { + ...shopify.propDefinitions.orderId, + options: async ({ prevContext }) => { + return this.shopify.getPropOptions({ + resourceFn: this.shopify.listOrders, + resourceKeys: [ + "orders", + ], + labelKey: "id", + prevContext, + }); + }, + }, + }; + + const props = {}; + + if (ownerResource === "variants") { + props.productId = resources.product; + } + + if (ownerResource === "article") { + props.blogId = resources.blog; + } + + return { + ...props, + ownerId: resources[ownerResource], + }; + }, + async getMetafields({ + resourceFn, resourceKeys = [], variables, + }) { + let results = await resourceFn(variables); + for (const key of resourceKeys) { + results = results[key]; + } + return results.metafields.nodes; + }, + async listMetafields(ownerResource, ownerId) { + const variables = { + id: ownerId, + first: MAX_LIMIT, + }; + let resourceFn, resourceKeys; + if (ownerResource === "product") { + resourceFn = this.shopify.getProduct; + resourceKeys = [ + "product", + ]; + } + if (ownerResource === "variants") { + resourceFn = this.shopify.getProductVariant; + resourceKeys = [ + "productVariant", + ]; + } + if (ownerResource === "collection") { + resourceFn = this.shopify.getCollection; + resourceKeys = [ + "collection", + ]; + } + if (ownerResource === "blog") { + resourceFn = this.shopify.getBlog; + resourceKeys = [ + "blog", + ]; + } + if (ownerResource === "article") { + resourceFn = this.shopify.getArticle; + resourceKeys = [ + "article", + ]; + } + if (ownerResource === "page") { + resourceFn = this.shopify.getPage; + resourceKeys = [ + "page", + ]; + } + if (ownerResource === "customer") { + resourceFn = this.shopify.getCustomer; + resourceKeys = [ + "customer", + ]; + } + if (ownerResource === "draftOrder") { + resourceFn = this.shopify.getDraftOrder; + resourceKeys = [ + "draftOrder", + ]; + } + if (ownerResource === "order") { + resourceFn = this.shopify.getOrder; + resourceKeys = [ + "order", + ]; + } + + return this.getMetafields({ + resourceFn, + resourceKeys, + variables, + }); + }, + async getMetafieldIdByKey(key, namespace, ownerId, ownerResource) { + const results = await this.listMetafields(ownerResource, ownerId); + + const metafield = results?.filter( + (field) => field.key === key && field.namespace === namespace, + ); + if (!metafield || metafield.length === 0) { + return false; + } + return metafield[0].id; + }, + async createMetafieldsArray(metafieldsOriginal, ownerId, ownerResource) { + if (!metafieldsOriginal) { + return; + } + const metafields = []; + const metafieldsArray = utils.parseJson(metafieldsOriginal); + for (const meta of metafieldsArray) { + if (meta.id) { + metafields.push(meta); + continue; + } + const metafieldId = await this.getMetafieldIdByKey( + meta.key, meta.namespace, ownerId, ownerResource, + ); + if (!metafieldId) { + metafields.push(meta); + continue; + } + metafields.push({ + id: `${metafieldId}`, + value: meta.value, + }); + } + return metafields; + }, }, }; diff --git a/components/shopify_developer_app/actions/common/metaobjects.mjs b/components/shopify_developer_app/actions/common/metaobjects.mjs deleted file mode 100644 index bcef0bffcfe3a..0000000000000 --- a/components/shopify_developer_app/actions/common/metaobjects.mjs +++ /dev/null @@ -1,21 +0,0 @@ -import metaobjects from "@pipedream/shopify/actions/common/metaobjects.mjs"; -import { axios } from "@pipedream/platform"; - -export default { - ...metaobjects, - methods: { - ...metaobjects.methods, - async makeGraphQLRequest({ - $ = this, ...args - }) { - return axios($, { - url: `https://${this.shopify.getShopId()}.myshopify.com/admin/api/2024-04/graphql.json`, - method: "POST", - headers: { - "X-Shopify-Access-Token": `${this.shopify.$auth.access_token}`, - }, - ...args, - }); - }, - }, -}; diff --git a/components/shopify_developer_app/actions/create-article/create-article.mjs b/components/shopify_developer_app/actions/create-article/create-article.mjs index b9178d6055461..725abb6827790 100644 --- a/components/shopify_developer_app/actions/create-article/create-article.mjs +++ b/components/shopify_developer_app/actions/create-article/create-article.mjs @@ -1,34 +1,22 @@ -import app from "../../common/rest-admin.mjs"; -import common from "@pipedream/shopify/actions/create-article/common.mjs"; +import shopify from "../../shopify_developer_app.app.mjs"; +import common from "@pipedream/shopify/actions/create-article/create-article.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, shopify); export default { - ...common, + ...others, key: "shopify_developer_app-create-article", - name: "Create Article", - description: "Create a new blog article. [See The Documentation](https://shopify.dev/docs/api/admin-rest/2023-04/resources/article#post-blogs-blog-id-articles)", - version: "0.0.6", - type: "action", + version: "0.0.7", + name, + description, + type, props: { - app, - blogId: { - propDefinition: [ - app, - "blogId", - ], - }, - title: { - description: "The title of the article.", - propDefinition: [ - app, - "title", - ], - }, - bodyHtml: { - description: "The text content of the article, complete with HTML markup.", - propDefinition: [ - app, - "bodyHtml", - ], - }, + shopify, + ...props, }, }; diff --git a/components/shopify_developer_app/actions/create-blog/create-blog.mjs b/components/shopify_developer_app/actions/create-blog/create-blog.mjs index b912c5b8aad75..390cf0d35fad7 100644 --- a/components/shopify_developer_app/actions/create-blog/create-blog.mjs +++ b/components/shopify_developer_app/actions/create-blog/create-blog.mjs @@ -1,21 +1,22 @@ -import app from "../../common/rest-admin.mjs"; -import common from "@pipedream/shopify/actions/create-blog/common.mjs"; +import shopify from "../../shopify_developer_app.app.mjs"; +import common from "@pipedream/shopify/actions/create-blog/create-blog.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, shopify); export default { - ...common, + ...others, key: "shopify_developer_app-create-blog", - name: "Create Blog", - description: "Create a new blog. [See The Documentation](https://shopify.dev/docs/api/admin-rest/2023-04/resources/blog#post-blogs)", - version: "0.0.6", - type: "action", + version: "0.0.7", + name, + description, + type, props: { - app, - title: { - description: "The title of the blog.", - propDefinition: [ - app, - "title", - ], - }, + shopify, + ...props, }, }; diff --git a/components/shopify_developer_app/actions/create-custom-collection/create-custom-collection.mjs b/components/shopify_developer_app/actions/create-custom-collection/create-custom-collection.mjs index 3c4c53bc3cbf4..dd7510066c0ab 100644 --- a/components/shopify_developer_app/actions/create-custom-collection/create-custom-collection.mjs +++ b/components/shopify_developer_app/actions/create-custom-collection/create-custom-collection.mjs @@ -1,36 +1,22 @@ import shopify from "../../shopify_developer_app.app.mjs"; -import common from "@pipedream/shopify/actions/create-custom-collection/common.mjs"; +import common from "@pipedream/shopify/actions/create-custom-collection/create-custom-collection.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, shopify); export default { - ...common, + ...others, key: "shopify_developer_app-create-custom-collection", - name: "Create Custom Collection", - description: "Create a new custom collection. [See the documentation](https://shopify.dev/docs/api/admin-rest/2023-01/resources/customcollection#post-custom-collections)", - version: "0.0.4", - type: "action", + version: "0.0.5", + name, + description, + type, props: { shopify, - title: { - propDefinition: [ - shopify, - "title", - ], - description: "The name of the custom collection", - }, - products: { - propDefinition: [ - shopify, - "productId", - ], - type: "string[]", - optional: true, - }, - metafields: { - propDefinition: [ - shopify, - "metafields", - ], - }, - ...common.props, + ...props, }, }; diff --git a/components/shopify_developer_app/actions/create-customer/create-customer.mjs b/components/shopify_developer_app/actions/create-customer/create-customer.mjs index 021f966114327..612032aa57f2c 100644 --- a/components/shopify_developer_app/actions/create-customer/create-customer.mjs +++ b/components/shopify_developer_app/actions/create-customer/create-customer.mjs @@ -1,12 +1,10 @@ import shopify from "../../shopify_developer_app.app.mjs"; -import common from "@pipedream/shopify/actions/create-customer/common.mjs"; export default { - ...common, key: "shopify_developer_app-create-customer", name: "Create Customer", - description: "Create a new customer. [See the documentation](https://shopify.dev/api/admin-rest/2022-01/resources/customer#[post]/admin/api/2022-01/customers.json)", - version: "0.0.4", + description: "Create a new customer. [See the documentation](https://shopify.dev/docs/api/admin-graphql/latest/mutations/customercreate)", + version: "0.0.5", type: "action", props: { shopify, @@ -70,6 +68,27 @@ export default { "zip", ], }, - ...common.props, + }, + async run({ $ }) { + const response = await this.shopify.createCustomer({ + input: { + firstName: this.firstName, + lastName: this.lastName, + email: this.email, + phone: this.phone, + addresses: [ + { + address1: this.address, + company: this.company, + city: this.city, + province: this.province, + country: this.country, + zip: this.zip, + }, + ], + }, + }); + $.export("$summary", `Created new customer with ID \`${response.customerCreate.customer.id}\``); + return response; }, }; 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 70a494aaf55d9..9d8bb5bc4ae5d 100644 --- a/components/shopify_developer_app/actions/create-metafield/create-metafield.mjs +++ b/components/shopify_developer_app/actions/create-metafield/create-metafield.mjs @@ -1,16 +1,58 @@ import metafieldActions from "../common/metafield-actions.mjs"; -import common from "@pipedream/shopify/actions/create-metafield/common.mjs"; +import common from "@pipedream/shopify/actions/create-metafield/create-metafield.mjs"; +import shopify from "../../shopify_developer_app.app.mjs"; +import constants from "../common/constants.mjs"; + +const { + name, description, type, ...others +} = common; export default { - ...common, + ...others, 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.5", - type: "action", + version: "0.0.6", + name, + description, + type, props: { - ...metafieldActions.props, - ...common.props, + shopify, + ownerResource: { + type: "string", + label: "Resource Type", + description: "Filter by the resource type on which the metafield is attached to", + options: constants.RESOURCE_TYPES.map((type) => ({ + ...type, + value: type.value.toUpperCase(), + })), + }, + name: { + type: "string", + label: "Name", + description: "The human-readable name for the metafield definition", + }, + namespace: { + type: "string", + label: "Namespace", + description: "A container for a group of metafields. Grouping metafields within a namespace prevents your metafields from conflicting with other metafields with the same key name. Must have between 3-255 characters.", + }, + key: { + type: "string", + label: "Key", + description: "The key of the metafield. Keys can be up to 64 characters long and can contain alphanumeric characters, hyphens, underscores, and periods.", + }, + type: { + type: "string", + label: "Type", + description: "The type of data that the metafield stores in the `value` field. Refer to the list of [supported types](https://shopify.dev/apps/custom-data/metafields/types).", + options: Object.keys(constants.METAFIELD_TYPES), + }, + pin: { + type: "boolean", + label: "Pin", + description: "Whether to pin the metafield definition", + default: false, + optional: true, + }, }, methods: { ...metafieldActions.methods, diff --git a/components/shopify_developer_app/actions/create-metaobject/create-metaobject.mjs b/components/shopify_developer_app/actions/create-metaobject/create-metaobject.mjs index 87bcae6e58aee..4ef296a05305b 100644 --- a/components/shopify_developer_app/actions/create-metaobject/create-metaobject.mjs +++ b/components/shopify_developer_app/actions/create-metaobject/create-metaobject.mjs @@ -1,27 +1,22 @@ import shopify from "../../shopify_developer_app.app.mjs"; -import metaobjects from "../common/metaobjects.mjs"; -import common from "@pipedream/shopify/actions/create-metaobject/common.mjs"; +import common from "@pipedream/shopify/actions/create-metaobject/create-metaobject.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, shopify); export default { - ...metaobjects, - ...common, + ...others, key: "shopify_developer_app-create-metaobject", - name: "Create Metaobject", - description: "Creates a metaobject. [See the documentation](https://shopify.dev/docs/api/admin-graphql/2023-04/mutations/metaobjectCreate)", - version: "0.0.6", - type: "action", + version: "0.0.7", + name, + description, + type, props: { shopify, - type: { - type: "string", - label: "Type", - description: "The Metaobject Type", - async options() { - const { data: { metaobjectDefinitions: { nodes } } } - = await this.listMetaobjectDefinitions(); - return nodes?.map(({ type }) => type) || []; - }, - reloadProps: true, - }, + ...props, }, }; diff --git a/components/shopify_developer_app/actions/create-order/create-order.mjs b/components/shopify_developer_app/actions/create-order/create-order.mjs index f93f5d0b74a4d..acaecfabad1ed 100644 --- a/components/shopify_developer_app/actions/create-order/create-order.mjs +++ b/components/shopify_developer_app/actions/create-order/create-order.mjs @@ -1,26 +1,160 @@ import shopify from "../../shopify_developer_app.app.mjs"; -import common from "@pipedream/shopify/actions/create-order/common.mjs"; -import { toSingleLineString } from "@pipedream/shopify/actions/common/common.mjs"; +import utils from "@pipedream/shopify/common/utils.mjs"; export default { - ...common, key: "shopify_developer_app-create-order", name: "Create Order", - description: toSingleLineString(`Creates a new order. - For full order object details [see the docs](https://shopify.dev/api/admin-rest/2022-01/resources/order#[post]/admin/api/2022-01/orders.json) - or [see examples](https://shopify.dev/api/admin-rest/2022-01/resources/order#[post]/admin/api/#{api_version}/orders.json_examples) - `), - version: "0.0.4", + description: "Creates a new order. For full order object details [See the documentation](https://shopify.dev/docs/api/admin-graphql/latest/mutations/ordercreate)", + version: "0.0.5", type: "action", props: { shopify, + lineItems: { + type: "string[]", + label: "Line Items", + description: "A list of line item objects, each containing information about an item in the order. Example: `{ \"variantId\": \"gid://shopify/ProductVariant/44572675571992\", \"quantity\": 1, \"title\": \"Title\" }`. More details in [Shopify Order Object](https://shopify.dev/docs/api/admin-graphql/latest/objects/order)", + }, + billingAddress: { + type: "object", + label: "Billing Address", + description: "The mailing address associated with the payment method. More details when searching **billing_address** in [Shopify Order Object](https://shopify.dev/docs/api/admin-graphql/latest/objects/order)", + optional: true, + }, + shippingAddress: { + type: "object", + label: "Shipping Address", + description: "The mailing address to where the order will be shipped. More details when searching **billing_address** in [Shopify Order Object](https://shopify.dev/docs/api/admin-graphql/latest/objects/order)", + optional: true, + }, + financialStatus: { + type: "string", + label: "Financial Status", + description: "The status of payments associated with the order. Can only be set when the order is created", + options: [ + "PENDING", + "AUTHORIZED", + "PARTIALLY_PAID", + "PAID", + "PARTIALLY_REFUNDED", + "REFUNDED", + "VOIDED", + ], + optional: true, + }, + discountCode: { + type: "object", + label: "Discount Code", + description: "A discount applied to the order. Example: `{ \"code\": \"SPRING30\", \"type\": \"fixed_amount\", \"amount\": \"30.00\" }`. More details when searching **discount_codes** in [Shopify Order Object](https://shopify.dev/docs/api/admin-graphql/latest/objects/order)", + optional: true, + }, + fulfillment: { + type: "object", + label: "Fulfillment", + description: "Fulfillment associated with the order. For more information, see the [Fulfillment Object](https://shopify.dev/docs/api/admin-graphql/latest/input-objects/OrderCreateFulfillmentInput)", + optional: true, + }, + fulfillmentStatus: { + type: "string", + label: "Fulfillment Status", + description: "The order's status in terms of fulfilled line items", + options: [ + "FULFILLED", + "NULL", + "PARTIAL", + "RESTOCKED", + ], + optional: true, + }, + sendReceipt: { + type: "boolean", + label: "Send Receipt", + description: "Whether to send an order confirmation to the customer", + optional: true, + }, + sendFulfillmentReceipt: { + type: "boolean", + label: "Send Fulfillment Receipt", + description: "Whether to send a shipping confirmation to the customer", + optional: true, + }, + taxLines: { + type: "string[]", + label: "Tax Lines", + description: "An array of tax line objects, each of which details a tax applicable to the order. Example: `[ { \"rate\": 0.06, \"price\": 11.94, \"title\": \"State Tax\", \"channel_liable\": true } ]`. More details when searching **tax_lines** in [Shopify Order Object](https://shopify.dev/docs/api/admin-graphql/latest/objects/order)", + optional: true, + }, + currency: { + type: "string", + label: "Currency", + description: "The three-letter code ([ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) format) for the shop currency", + optional: true, + }, + note: { + type: "string", + label: "Note", + description: "An optional note that a shop owner can attach to the order", + optional: true, + }, + inventoryBehavior: { + type: "string", + label: "Inventory Behavior", + description: "The behaviour to use when updating inventory", + options: [ + { + value: "BYPASS", + label: "Do not claim inventory", + }, + { + value: "DECREMENT_IGNORING_POLICY", + label: "Ignore the product's inventory policy and claim inventory", + }, + { + value: "DECREMENT_OBEYING_POLICY", + label: "Follow the product's inventory policy and claim inventory, if possible", + }, + ], + optional: true, + }, + shippingLines: { + type: "string[]", + label: "Shipping Lines", + description: "An array of objects, each of which details a shipping method used. More details when searching **shipping_lines** in [Shopify Order Object](https://shopify.dev/docs/api/admin-graphql/latest/objects/order)", + optional: true, + }, customerId: { propDefinition: [ shopify, "customerId", ], - optional: true, }, - ...common.props, + }, + async run({ $ }) { + const response = await this.shopify.createOrder({ + options: { + sendReceipt: this.sendReceipt, + sendFulfillmentReceipt: this.sendFulfillmentReceipt, + inventoryBehaviour: this.inventoryBehavior, + }, + order: { + lineItems: utils.parseJson(this.lineItems), + billingAddress: utils.parseJson(this.billingAddress), + shippingAddress: utils.parseJson(this.shippingAddress), + financialStatus: this.financialStatus, + discountCode: utils.parseJson(this.discountCode), + fulfillment: utils.parseJson(this.fulfillment), + fulfillmentStatus: this.fulfillmentStatus, + taxLines: utils.parseJson(this.taxLines), + currency: this.currency, + customer: { + toAssociate: { + id: this.customerId, + }, + }, + note: this.note, + shippingLines: utils.parseJson(this.shippingLines), + }, + }); + $.export("$summary", `Created new order with ID \`${response.orderCreate.order.id}\``); + return response; }, }; diff --git a/components/shopify_developer_app/actions/create-page/create-page.mjs b/components/shopify_developer_app/actions/create-page/create-page.mjs index 7dfdea7d7c47c..a1139878a7555 100644 --- a/components/shopify_developer_app/actions/create-page/create-page.mjs +++ b/components/shopify_developer_app/actions/create-page/create-page.mjs @@ -1,27 +1,22 @@ -import app from "../../common/rest-admin.mjs"; -import common from "@pipedream/shopify/actions/create-page/common.mjs"; +import shopify from "../../shopify_developer_app.app.mjs"; +import common from "@pipedream/shopify/actions/create-page/create-page.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, shopify); export default { - ...common, + ...others, key: "shopify_developer_app-create-page", - name: "Create Page", - description: "Create a new page. [See The Documentation](https://shopify.dev/docs/api/admin-rest/2023-04/resources/page#post-pages)", - version: "0.0.6", - type: "action", + version: "0.0.7", + name, + description, + type, props: { - app, - title: { - description: "The title of the page.", - propDefinition: [ - app, - "title", - ], - }, - bodyHtml: { - propDefinition: [ - app, - "bodyHtml", - ], - }, + shopify, + ...props, }, }; diff --git a/components/shopify_developer_app/actions/create-product-variant/create-product-variant.mjs b/components/shopify_developer_app/actions/create-product-variant/create-product-variant.mjs index 130724c01f303..82347f3f42ad3 100644 --- a/components/shopify_developer_app/actions/create-product-variant/create-product-variant.mjs +++ b/components/shopify_developer_app/actions/create-product-variant/create-product-variant.mjs @@ -1,56 +1,22 @@ import shopify from "../../shopify_developer_app.app.mjs"; -import common from "@pipedream/shopify/actions/create-product-variant/common.mjs"; +import common from "@pipedream/shopify/actions/create-product-variant/create-product-variant.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, shopify); export default { - ...common, + ...others, key: "shopify_developer_app-create-product-variant", - name: "Create Product Variant", - description: "Create a new product variant. [See the documentation](https://shopify.dev/api/admin-rest/2022-01/resources/product-variant#[post]/admin/api/2022-01/products/{product_id}/variants.json)", - version: "0.0.5", - type: "action", + version: "0.0.6", + name, + description, + type, props: { shopify, - productId: { - propDefinition: [ - shopify, - "productId", - ], - }, - option: { - propDefinition: [ - shopify, - "option", - ], - }, - price: { - propDefinition: [ - shopify, - "price", - ], - description: "The price of the product variant", - }, - imageId: { - propDefinition: [ - shopify, - "imageId", - (c) => ({ - productId: c.productId, - }), - ], - }, - sku: { - propDefinition: [ - shopify, - "sku", - ], - }, - locationId: { - propDefinition: [ - shopify, - "locationId", - ], - optional: true, - }, - ...common.props, + ...props, }, }; diff --git a/components/shopify_developer_app/actions/create-product/create-product.mjs b/components/shopify_developer_app/actions/create-product/create-product.mjs index 5a1bfb8c0d78f..2af9360c29dc0 100644 --- a/components/shopify_developer_app/actions/create-product/create-product.mjs +++ b/components/shopify_developer_app/actions/create-product/create-product.mjs @@ -1,69 +1,22 @@ import shopify from "../../shopify_developer_app.app.mjs"; -import common from "@pipedream/shopify/actions/create-product/common.mjs"; +import common from "@pipedream/shopify/actions/create-product/create-product.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, shopify); export default { - ...common, + ...others, key: "shopify_developer_app-create-product", - name: "Create Product", - description: "Create a new product. [See the documentation](https://shopify.dev/api/admin-rest/2022-01/resources/product#[post]/admin/api/2022-01/products.json)", - version: "0.0.4", - type: "action", + version: "0.0.5", + name, + description, + type, props: { shopify, - title: { - propDefinition: [ - shopify, - "title", - ], - }, - productDescription: { - propDefinition: [ - shopify, - "productDescription", - ], - }, - vendor: { - propDefinition: [ - shopify, - "vendor", - ], - }, - productType: { - propDefinition: [ - shopify, - "productType", - ], - }, - status: { - propDefinition: [ - shopify, - "status", - ], - }, - images: { - propDefinition: [ - shopify, - "images", - ], - }, - options: { - propDefinition: [ - shopify, - "options", - ], - }, - variants: { - propDefinition: [ - shopify, - "variants", - ], - }, - tags: { - propDefinition: [ - shopify, - "tags", - ], - }, - ...common.props, + ...props, }, }; diff --git a/components/shopify_developer_app/actions/create-smart-collection/create-smart-collection.mjs b/components/shopify_developer_app/actions/create-smart-collection/create-smart-collection.mjs index a2a10865eba3e..1b105bdc5db8a 100644 --- a/components/shopify_developer_app/actions/create-smart-collection/create-smart-collection.mjs +++ b/components/shopify_developer_app/actions/create-smart-collection/create-smart-collection.mjs @@ -1,27 +1,22 @@ import shopify from "../../shopify_developer_app.app.mjs"; -import { toSingleLineString } from "@pipedream/shopify/actions/common/common.mjs"; -import common from "@pipedream/shopify/actions/create-smart-collection/common.mjs"; +import common from "@pipedream/shopify/actions/create-smart-collection/create-smart-collection.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, shopify); export default { - ...common, + ...others, key: "shopify_developer_app-create-smart-collection", - name: "Create Smart Collection", - description: toSingleLineString(` - Creates a smart collection. - You can fill in any number of rules by selecting more than one option in each prop. - [See documentation](https://shopify.dev/api/admin-rest/2021-10/resources/smartcollection#post-smart-collections) - `), - version: "0.0.4", - type: "action", + version: "0.0.5", + name, + description, + type, props: { shopify, - title: { - propDefinition: [ - shopify, - "title", - ], - description: "Title of the smart collection", - }, - ...common.props, + ...props, }, }; diff --git a/components/shopify_developer_app/actions/delete-article/delete-article.mjs b/components/shopify_developer_app/actions/delete-article/delete-article.mjs index bba5dd9c0b961..1c09e8de1bdcf 100644 --- a/components/shopify_developer_app/actions/delete-article/delete-article.mjs +++ b/components/shopify_developer_app/actions/delete-article/delete-article.mjs @@ -1,29 +1,22 @@ -import app from "../../common/rest-admin.mjs"; -import common from "@pipedream/shopify/actions/delete-article/common.mjs"; +import shopify from "../../shopify_developer_app.app.mjs"; +import common from "@pipedream/shopify/actions/delete-article/delete-article.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, shopify); export default { - ...common, + ...others, key: "shopify_developer_app-delete-article", - name: "Delete Article", - description: "Delete an existing blog article. [See The Documentation](https://shopify.dev/docs/api/admin-rest/2023-04/resources/article#delete-blogs-blog-id-articles-article-id)", - version: "0.0.6", - type: "action", + version: "0.0.7", + name, + description, + type, props: { - app, - blogId: { - propDefinition: [ - app, - "blogId", - ], - }, - articleId: { - propDefinition: [ - app, - "articleId", - ({ blogId }) => ({ - blogId, - }), - ], - }, + shopify, + ...props, }, }; diff --git a/components/shopify_developer_app/actions/delete-blog/delete-blog.mjs b/components/shopify_developer_app/actions/delete-blog/delete-blog.mjs index d65fe34cab0a1..0b6f4a14f7ed9 100644 --- a/components/shopify_developer_app/actions/delete-blog/delete-blog.mjs +++ b/components/shopify_developer_app/actions/delete-blog/delete-blog.mjs @@ -1,20 +1,22 @@ -import app from "../../common/rest-admin.mjs"; -import common from "@pipedream/shopify/actions/delete-blog/common.mjs"; +import shopify from "../../shopify_developer_app.app.mjs"; +import common from "@pipedream/shopify/actions/delete-blog/delete-blog.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, shopify); export default { - ...common, + ...others, key: "shopify_developer_app-delete-blog", - name: "Delete Blog", - description: "Delete an existing blog. [See The Documentation](https://shopify.dev/docs/api/admin-rest/2023-04/resources/blog#delete-blogs-blog-id)", - version: "0.0.6", - type: "action", + version: "0.0.7", + name, + description, + type, props: { - app, - blogId: { - propDefinition: [ - app, - "blogId", - ], - }, + shopify, + ...props, }, }; 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 3ff2a8ac4e940..51286f4beb7f9 100644 --- a/components/shopify_developer_app/actions/delete-metafield/delete-metafield.mjs +++ b/components/shopify_developer_app/actions/delete-metafield/delete-metafield.mjs @@ -1,19 +1,52 @@ import metafieldActions from "../common/metafield-actions.mjs"; -import common from "@pipedream/shopify/actions/delete-metafield/common.mjs"; +import common from "@pipedream/shopify/actions/delete-metafield/delete-metafield.mjs"; +import shopify from "../../shopify_developer_app.app.mjs"; + +const { + name, description, type, ...others +} = common; export default { - ...common, + ...others, 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.5", - type: "action", + version: "0.0.6", + name, + description, + type, props: { + shopify, ...metafieldActions.props, - ...common.props, }, methods: { ...metafieldActions.methods, - ...common.methods, + }, + async additionalProps() { + const props = await this.getOwnerIdProp(this.ownerResource); console.log(props); + + if (props.ownerId) { + props.ownerId = { + ...props.ownerId, + reloadProps: true, + }; + } + + if (this.ownerResource && this.ownerId) { + props.metafieldId = { + type: "string", + label: "Metafield ID", + description: "The metafield to update", + options: async () => { + const metafields = await this.listMetafields(this.ownerResource, this.ownerId); + return metafields?.map(({ + id: value, key: label, + }) => ({ + value, + label, + })) || []; + }, + }; + } + + return props; }, }; diff --git a/components/shopify_developer_app/actions/delete-page/delete-page.mjs b/components/shopify_developer_app/actions/delete-page/delete-page.mjs index ee75823a58f66..09dd85bbe2001 100644 --- a/components/shopify_developer_app/actions/delete-page/delete-page.mjs +++ b/components/shopify_developer_app/actions/delete-page/delete-page.mjs @@ -1,20 +1,22 @@ -import app from "../../common/rest-admin.mjs"; -import common from "@pipedream/shopify/actions/delete-page/common.mjs"; +import shopify from "../../shopify_developer_app.app.mjs"; +import common from "@pipedream/shopify/actions/delete-page/delete-page.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, shopify); export default { - ...common, + ...others, key: "shopify_developer_app-delete-page", - name: "Delete Page", - description: "Delete an existing page. [See The Documentation](https://shopify.dev/docs/api/admin-rest/2023-04/resources/page#delete-pages-page-id)", - version: "0.0.6", - type: "action", + version: "0.0.7", + name, + description, + type, props: { - app, - pageId: { - propDefinition: [ - app, - "pageId", - ], - }, + shopify, + ...props, }, }; diff --git a/components/shopify_developer_app/actions/get-articles/get-articles.mjs b/components/shopify_developer_app/actions/get-articles/get-articles.mjs index 68e60384242dc..404068091269e 100644 --- a/components/shopify_developer_app/actions/get-articles/get-articles.mjs +++ b/components/shopify_developer_app/actions/get-articles/get-articles.mjs @@ -1,20 +1,22 @@ -import app from "../../common/rest-admin.mjs"; -import common from "@pipedream/shopify/actions/get-articles/common.mjs"; +import shopify from "../../shopify_developer_app.app.mjs"; +import common from "@pipedream/shopify/actions/get-articles/get-articles.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, shopify); export default { - ...common, + ...others, key: "shopify_developer_app-get-articles", - name: "Get Articles", - description: "Retrieve a list of all articles from a blog. [See The Documentation](https://shopify.dev/docs/api/admin-rest/2023-04/resources/article#get-blogs-blog-id-articles)", - version: "0.0.6", - type: "action", + version: "0.0.7", + name, + description, + type, props: { - app, - blogId: { - propDefinition: [ - app, - "blogId", - ], - }, + shopify, + ...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 666d2fd3fd4ad..34d4303ff96b0 100644 --- a/components/shopify_developer_app/actions/get-metafields/get-metafields.mjs +++ b/components/shopify_developer_app/actions/get-metafields/get-metafields.mjs @@ -1,19 +1,51 @@ import metafieldActions from "../common/metafield-actions.mjs"; -import common from "@pipedream/shopify/actions/get-metafields/common.mjs"; +import common from "@pipedream/shopify/actions/get-metafields/get-metafields.mjs"; +import shopify from "../../shopify_developer_app.app.mjs"; + +const { + name, description, type, +} = common; export default { - ...common, 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.5", - type: "action", + version: "0.0.6", + name, + description, + type, props: { + shopify, ...metafieldActions.props, - ...common.props, + namespace: { + type: "string[]", + label: "Namespace", + description: "Filter results by namespace", + optional: true, + }, + key: { + type: "string[]", + label: "Key", + description: "Filter results by key", + optional: true, + }, }, methods: { ...metafieldActions.methods, - ...common.methods, + }, + async additionalProps() { + return this.getOwnerIdProp(this.ownerResource); + }, + async run({ $ }) { + let response = await this.listMetafields(this.ownerResource, this.ownerId); + + if (this.namespace?.length > 0) { + response = response.filter((field) => this.namespace.includes(field.namespace)); + } + + if (this.key?.length > 0) { + response = response.filter((field) => this.key.includes(field.key)); + } + + $.export("$summary", `Found ${response.length} metafield(s) for object with ID ${this.ownerId}`); + return response; }, }; diff --git a/components/shopify_developer_app/actions/get-metaobjects/get-metaobjects.mjs b/components/shopify_developer_app/actions/get-metaobjects/get-metaobjects.mjs index c4f8cd9e79aac..4a8ec3605ef3f 100644 --- a/components/shopify_developer_app/actions/get-metaobjects/get-metaobjects.mjs +++ b/components/shopify_developer_app/actions/get-metaobjects/get-metaobjects.mjs @@ -1,26 +1,22 @@ import shopify from "../../shopify_developer_app.app.mjs"; -import metaobjects from "../common/metaobjects.mjs"; -import common from "@pipedream/shopify/actions/get-metaobjects/common.mjs"; +import common from "@pipedream/shopify/actions/get-metaobjects/get-metaobjects.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, shopify); export default { - ...metaobjects, - ...common, + ...others, key: "shopify_developer_app-get-metaobjects", - name: "Get Metaobjects", - description: "Retrieves a list of metaobjects. [See the documentation](https://shopify.dev/docs/api/admin-graphql/2023-04/queries/metaobjects)", - version: "0.0.5", - type: "action", + version: "0.0.6", + name, + description, + type, props: { shopify, - type: { - type: "string", - label: "Type", - description: "The Metaobject Type", - async options() { - const { data: { metaobjectDefinitions: { nodes } } } - = await this.listMetaobjectDefinitions(); - return nodes?.map(({ type }) => type) || []; - }, - }, + ...props, }, }; diff --git a/components/shopify_developer_app/actions/get-order/get-order.mjs b/components/shopify_developer_app/actions/get-order/get-order.mjs index 989055522d95d..11fb55bac7aec 100644 --- a/components/shopify_developer_app/actions/get-order/get-order.mjs +++ b/components/shopify_developer_app/actions/get-order/get-order.mjs @@ -1,23 +1,25 @@ -import app from "../../common/rest-admin.mjs"; +import shopify from "../../shopify_developer_app.app.mjs"; +import { MAX_LIMIT } from "@pipedream/shopify/common/constants.mjs"; export default { key: "shopify_developer_app-get-order", name: "Get Order", - description: "Retrieve an order by specifying the order ID. [See The Documentation](https://shopify.dev/docs/api/admin-rest/2024-10/resources/order#get-orders)", - version: "0.0.2", + description: "Retrieve an order by specifying the order ID. [See the documentation](https://shopify.dev/docs/api/admin-graphql/latest/queries/order)", + version: "0.0.3", type: "action", props: { - app, + shopify, orderId: { propDefinition: [ - app, + shopify, "orderId", ], }, }, async run({ $ }) { - const response = await this.app.getOrder({ - orderId: this.orderId, + const response = await this.shopify.getOrder({ + id: this.orderId, + first: MAX_LIMIT, }); $.export("$summary", `Successfully retrieved order with ID: ${this.orderId}`); return response; diff --git a/components/shopify_developer_app/actions/get-pages/get-pages.mjs b/components/shopify_developer_app/actions/get-pages/get-pages.mjs index 56d705fa8f120..1d3337ca66d40 100644 --- a/components/shopify_developer_app/actions/get-pages/get-pages.mjs +++ b/components/shopify_developer_app/actions/get-pages/get-pages.mjs @@ -1,14 +1,22 @@ -import app from "../../common/rest-admin.mjs"; -import common from "@pipedream/shopify/actions/get-pages/common.mjs"; +import shopify from "../../shopify_developer_app.app.mjs"; +import common from "@pipedream/shopify/actions/get-pages/get-pages.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, shopify); export default { - ...common, + ...others, key: "shopify_developer_app-get-pages", - name: "Get Pages", - description: "Retrieve a list of all pages. [See The Documentation](https://shopify.dev/docs/api/admin-rest/2023-04/resources/page#get-pages)", - version: "0.0.6", - type: "action", + version: "0.0.7", + name, + description, + type, props: { - app, + shopify, + ...props, }, }; diff --git a/components/shopify_developer_app/actions/search-custom-collection-by-name/search-custom-collection-by-name.mjs b/components/shopify_developer_app/actions/search-custom-collection-by-name/search-custom-collection-by-name.mjs index 71f1c30311a00..88ac8c131f4cb 100644 --- a/components/shopify_developer_app/actions/search-custom-collection-by-name/search-custom-collection-by-name.mjs +++ b/components/shopify_developer_app/actions/search-custom-collection-by-name/search-custom-collection-by-name.mjs @@ -1,22 +1,22 @@ import shopify from "../../shopify_developer_app.app.mjs"; -import common from "@pipedream/shopify/actions/search-custom-collection-by-name/common.mjs"; +import common from "@pipedream/shopify/actions/search-custom-collection-by-name/search-custom-collection-by-name.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, shopify); export default { - ...common, + ...others, key: "shopify_developer_app-search-custom-collection-by-name", - name: "Search Custom Collection by Name", - description: "Search for a custom collection by name/title. [See the documentation](https://shopify.dev/docs/api/admin-rest/2023-01/resources/customcollection#get-custom-collections)", - version: "0.0.4", - type: "action", + version: "0.0.5", + name, + description, + type, props: { shopify, - title: { - propDefinition: [ - shopify, - "title", - ], - description: "The name of the custom collection", - }, - ...common.props, + ...props, }, }; diff --git a/components/shopify_developer_app/actions/search-customers/search-customers.mjs b/components/shopify_developer_app/actions/search-customers/search-customers.mjs index 1d75df419293e..ba5aaa2ac8d37 100644 --- a/components/shopify_developer_app/actions/search-customers/search-customers.mjs +++ b/components/shopify_developer_app/actions/search-customers/search-customers.mjs @@ -1,27 +1,37 @@ import shopify from "../../shopify_developer_app.app.mjs"; -import common from "@pipedream/shopify/actions/search-customers/common.mjs"; export default { - ...common, key: "shopify_developer_app-search-customers", name: "Search for Customers", - description: "Search for a customer or a list of customers. [See the documentation](https://shopify.dev/api/admin-rest/2022-01/resources/customer#[get]/admin/api/2022-01/customers.json)", - version: "0.0.4", + description: "Search for a customer or a list of customers. [See the documentation](https://shopify.dev/docs/api/admin-graphql/latest/queries/customers)", + version: "0.0.5", type: "action", props: { shopify, query: { - propDefinition: [ - shopify, - "query", - ], + type: "string", + label: "Query", + description: "The search query", }, max: { - propDefinition: [ - shopify, - "max", - ], + type: "integer", + label: "Max Records", + description: "Optionally limit the maximum number of records to return. Leave blank to retrieve all records.", + optional: true, }, - ...common.props, + }, + async run({ $ }) { + const response = await this.shopify.getPaginated({ + resourceFn: this.shopify.listCustomers, + resourceKeys: [ + "customers", + ], + variables: { + query: this.query, + }, + max: this.max, + }); + $.export("$summary", `Found ${response.length} customer(s)`); + return response; }, }; diff --git a/components/shopify_developer_app/actions/search-product-variant/search-product-variant.mjs b/components/shopify_developer_app/actions/search-product-variant/search-product-variant.mjs index ca699cdc98304..7abd5ba2716f0 100644 --- a/components/shopify_developer_app/actions/search-product-variant/search-product-variant.mjs +++ b/components/shopify_developer_app/actions/search-product-variant/search-product-variant.mjs @@ -1,38 +1,22 @@ import shopify from "../../shopify_developer_app.app.mjs"; -import common from "@pipedream/shopify/actions/search-product-variant/common.mjs"; +import common from "@pipedream/shopify/actions/search-product-variant/search-product-variant.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, shopify); export default { - ...common, + ...others, key: "shopify_developer_app-search-product-variant", - name: "Search for Product Variant", - description: "Search for product variants or create one if not found. [See the documentation](https://shopify.dev/api/admin-rest/2022-01/resources/product-variant#top)", - version: "0.0.4", - type: "action", + version: "0.0.5", + name, + description, + type, props: { shopify, - productId: { - propDefinition: [ - shopify, - "productId", - ], - }, - productVariantId: { - propDefinition: [ - shopify, - "productVariantId", - (c) => c, - ], - description: "ID of the product variant. Takes precedence over **Title**", - optional: true, - }, - title: { - propDefinition: [ - shopify, - "title", - ], - description: "The name of the product variant", - optional: true, - }, - ...common.props, + ...props, }, }; diff --git a/components/shopify_developer_app/actions/search-products/search-products.mjs b/components/shopify_developer_app/actions/search-products/search-products.mjs index 28b3b091a7ee9..76c3f5175498b 100644 --- a/components/shopify_developer_app/actions/search-products/search-products.mjs +++ b/components/shopify_developer_app/actions/search-products/search-products.mjs @@ -1,48 +1,22 @@ import shopify from "../../shopify_developer_app.app.mjs"; -import common from "@pipedream/shopify/actions/search-products/common.mjs"; +import common from "@pipedream/shopify/actions/search-products/search-products.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, shopify); export default { - ...common, + ...others, key: "shopify_developer_app-search-products", - name: "Search for Products", - description: "Search for products. [See the documentation](https://shopify.dev/api/admin-rest/2022-01/resources/product#[get]/admin/api/2022-01/products.json)", - version: "0.0.4", - type: "action", + version: "0.0.5", + name, + description, + type, props: { shopify, - title: { - propDefinition: [ - shopify, - "title", - ], - optional: true, - }, - productIds: { - propDefinition: [ - shopify, - "productId", - ], - type: "string[]", - optional: true, - }, - collectionId: { - propDefinition: [ - shopify, - "collectionId", - ], - }, - productType: { - propDefinition: [ - shopify, - "productType", - ], - }, - vendor: { - propDefinition: [ - shopify, - "vendor", - ], - }, - ...common.props, + ...props, }, }; diff --git a/components/shopify_developer_app/actions/update-article/update-article.mjs b/components/shopify_developer_app/actions/update-article/update-article.mjs index 5f8789e25251e..3ffb58b9a9ee2 100644 --- a/components/shopify_developer_app/actions/update-article/update-article.mjs +++ b/components/shopify_developer_app/actions/update-article/update-article.mjs @@ -1,43 +1,22 @@ -import app from "../../common/rest-admin.mjs"; -import common from "@pipedream/shopify/actions/update-article/common.mjs"; +import shopify from "../../shopify_developer_app.app.mjs"; +import common from "@pipedream/shopify/actions/update-article/update-article.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, shopify); export default { - ...common, + ...others, key: "shopify_developer_app-update-article", - name: "Update Article", - description: "Update a blog article. [See The Documentation](https://shopify.dev/docs/api/admin-rest/2023-04/resources/article#put-blogs-blog-id-articles-article-id)", - version: "0.0.6", - type: "action", + version: "0.0.7", + name, + description, + type, props: { - app, - blogId: { - propDefinition: [ - app, - "blogId", - ], - }, - articleId: { - propDefinition: [ - app, - "articleId", - ({ blogId }) => ({ - blogId, - }), - ], - }, - title: { - description: "The title of the article.", - propDefinition: [ - app, - "title", - ], - }, - bodyHtml: { - description: "The text content of the article, complete with HTML markup.", - propDefinition: [ - app, - "bodyHtml", - ], - }, + shopify, + ...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 97fba4f7f2862..d31957c23fd48 100644 --- a/components/shopify_developer_app/actions/update-customer/update-customer.mjs +++ b/components/shopify_developer_app/actions/update-customer/update-customer.mjs @@ -1,14 +1,12 @@ import shopify from "../../shopify_developer_app.app.mjs"; -import metafieldActions from "../common/metafield-actions.mjs"; -import common from "@pipedream/shopify/actions/update-customer/common.mjs"; +import common from "../common/metafield-actions.mjs"; export default { - ...metafieldActions, ...common, 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.5", + description: "Update a existing customer. [See the documentation](https://shopify.dev/docs/api/admin-graphql/latest/mutations/customerupdate)", + version: "0.0.6", type: "action", props: { shopify, @@ -86,4 +84,30 @@ export default { ], }, }, + async run({ $ }) { + const metafields = await this.createMetafieldsArray(this.metafields, this.customerId, "customer"); + + const response = await this.shopify.updateCustomer({ + input: { + id: this.customerId, + firstName: this.firstName, + lastName: this.lastName, + email: this.email, + phone: this.phone, + addresses: [ + { + address1: this.address, + company: this.company, + city: this.city, + province: this.province, + country: this.country, + zip: this.zip, + }, + ], + metafields, + }, + }); + $.export("$summary", `Updated customer \`${response.customerUpdate.customer.email || response.customerUpdate.customer.firstName}\` with ID \`${response.customerUpdate.customer.id}\``); + return response; + }, }; diff --git a/components/shopify_developer_app/actions/update-inventory-level/update-inventory-level.mjs b/components/shopify_developer_app/actions/update-inventory-level/update-inventory-level.mjs index de1232e85d10b..0b166b9d1daf7 100644 --- a/components/shopify_developer_app/actions/update-inventory-level/update-inventory-level.mjs +++ b/components/shopify_developer_app/actions/update-inventory-level/update-inventory-level.mjs @@ -1,36 +1,22 @@ import shopify from "../../shopify_developer_app.app.mjs"; -import common from "@pipedream/shopify/actions/update-inventory-level/common.mjs"; +import common from "@pipedream/shopify/actions/update-inventory-level/update-inventory-level.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, shopify); export default { - ...common, + ...others, key: "shopify_developer_app-update-inventory-level", - name: "Update Inventory Level", - description: "Sets the inventory level for an inventory item at a location. [See the documenation](https://shopify.dev/api/admin-rest/2022-01/resources/inventorylevel#[post]/admin/api/2022-01/inventory_levels/set.json)", - version: "0.0.4", - type: "action", + version: "0.0.5", + name, + description, + type, props: { shopify, - locationId: { - propDefinition: [ - shopify, - "locationId", - ], - }, - productId: { - propDefinition: [ - shopify, - "productId", - ], - }, - inventoryItemId: { - propDefinition: [ - shopify, - "inventoryItemId", - (c) => ({ - productId: c.productId, - }), - ], - }, - ...common.props, + ...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 1a67063d2d609..cd3bef96ada3e 100644 --- a/components/shopify_developer_app/actions/update-metafield/update-metafield.mjs +++ b/components/shopify_developer_app/actions/update-metafield/update-metafield.mjs @@ -1,17 +1,21 @@ import metafieldActions from "../common/metafield-actions.mjs"; -import common from "@pipedream/shopify/actions/update-metafield/common.mjs"; -import shopify from "@pipedream/shopify/shopify.app.mjs"; +import common from "@pipedream/shopify/actions/update-metafield/update-metafield.mjs"; +import shopify from "../../shopify_developer_app.app.mjs"; + +const { + name, description, type, ...others +} = common; export default { - ...common, + ...others, 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.5", - type: "action", + version: "0.0.6", + name, + description, + type, props: { + shopify, ...metafieldActions.props, - ...common.props, }, async additionalProps() { const props = await this.getOwnerIdProp(this.ownerResource); @@ -31,15 +35,10 @@ export default { }, 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, @@ -49,12 +48,16 @@ export default { article: shopify.propDefinitions.articleId, page: shopify.propDefinitions.pageId, order: shopify.propDefinitions.orderId, - draft_order: shopify.propDefinitions.draftOrderId, + draftOrder: { + type: "string", + label: "Draft Order ID", + description: "The identifier of a draft order", + }, }; const props = {}; - if (ownerResource === "variants" || ownerResource === "product_image") { + if (ownerResource === "variants") { props.productId = resources.product; } if (ownerResource === "article") { diff --git a/components/shopify_developer_app/actions/update-metaobject/update-metaobject.mjs b/components/shopify_developer_app/actions/update-metaobject/update-metaobject.mjs index b70771409c898..76e713ca984b1 100644 --- a/components/shopify_developer_app/actions/update-metaobject/update-metaobject.mjs +++ b/components/shopify_developer_app/actions/update-metaobject/update-metaobject.mjs @@ -1,32 +1,22 @@ import shopify from "../../shopify_developer_app.app.mjs"; -import metaobjects from "../common/metaobjects.mjs"; -import common from "@pipedream/shopify/actions/update-metaobject/common.mjs"; +import common from "@pipedream/shopify/actions/update-metaobject/update-metaobject.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, shopify); export default { - ...metaobjects, - ...common, + ...others, key: "shopify_developer_app-update-metaobject", - name: "Update Metaobject", - description: "Updates a metaobject. [See the documentation](https://shopify.dev/docs/api/admin-graphql/2023-04/mutations/metaobjectUpdate)", - version: "0.0.7", - type: "action", - methods: { - ...metaobjects.methods, - ...common.methods, - }, + version: "0.0.8", + name, + description, + type, props: { shopify, - type: { - type: "string", - label: "Type", - description: "The Metaobject Type", - async options() { - const { data: { metaobjectDefinitions: { nodes } } } - = await this.listMetaobjectDefinitions(); - return nodes?.map(({ type }) => type) || []; - }, - reloadProps: true, - }, - ...common.props, + ...props, }, }; diff --git a/components/shopify_developer_app/actions/update-page/update-page.mjs b/components/shopify_developer_app/actions/update-page/update-page.mjs index 881e97a343d18..0d2f63b32bd7f 100644 --- a/components/shopify_developer_app/actions/update-page/update-page.mjs +++ b/components/shopify_developer_app/actions/update-page/update-page.mjs @@ -1,33 +1,22 @@ -import app from "../../common/rest-admin.mjs"; -import common from "@pipedream/shopify/actions/update-page/common.mjs"; +import shopify from "../../shopify_developer_app.app.mjs"; +import common from "@pipedream/shopify/actions/update-page/update-page.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, shopify); export default { - ...common, + ...others, key: "shopify_developer_app-update-page", - name: "Update Page", - description: "Update an existing page. [See The Documentation](https://shopify.dev/docs/api/admin-rest/2023-04/resources/page#put-pages-page-id)", - version: "0.0.6", - type: "action", + version: "0.0.7", + name, + description, + type, props: { - app, - pageId: { - propDefinition: [ - app, - "pageId", - ], - }, - title: { - description: "The title of the page.", - propDefinition: [ - app, - "title", - ], - }, - bodyHtml: { - propDefinition: [ - app, - "bodyHtml", - ], - }, + shopify, + ...props, }, }; 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 ac8aa5cab6666..d2d38fda081c9 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 @@ -1,79 +1,22 @@ import shopify from "../../shopify_developer_app.app.mjs"; -import metafieldActions from "../common/metafield-actions.mjs"; -import common from "@pipedream/shopify/actions/update-product-variant/common.mjs"; +import common from "@pipedream/shopify/actions/update-product-variant/update-product-variant.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, shopify); export default { - ...common, - ...metafieldActions, + ...others, 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.6", - type: "action", + version: "0.0.7", + name, + description, + type, props: { shopify, - productId: { - propDefinition: [ - shopify, - "productId", - ], - }, - productVariantId: { - propDefinition: [ - shopify, - "productVariantId", - (c) => c, - ], - description: `${shopify.propDefinitions.productVariantId.description} - Option displayed here as the title of the product variant`, - }, - option: { - propDefinition: [ - shopify, - "option", - ], - optional: true, - }, - price: { - propDefinition: [ - shopify, - "price", - ], - description: "The price of the product variant", - }, - imageId: { - propDefinition: [ - shopify, - "imageId", - (c) => c, - ], - }, - metafields: { - propDefinition: [ - shopify, - "metafields", - ], - }, - sku: { - propDefinition: [ - shopify, - "sku", - ], - }, - countryCodeOfOrigin: { - propDefinition: [ - shopify, - "country", - ], - description: "The country code [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of where the item came from", - }, - locationId: { - propDefinition: [ - shopify, - "locationId", - ], - optional: true, - }, - ...common.props, + ...props, }, }; 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 587299fc43641..fd14f938a1f08 100644 --- a/components/shopify_developer_app/actions/update-product/update-product.mjs +++ b/components/shopify_developer_app/actions/update-product/update-product.mjs @@ -1,14 +1,13 @@ import shopify from "../../shopify_developer_app.app.mjs"; -import metafieldActions from "../common/metafield-actions.mjs"; -import common from "@pipedream/shopify/actions/update-product/common.mjs"; +import common from "../common/metafield-actions.mjs"; +import utils from "@pipedream/shopify/common/utils.mjs"; export default { ...common, - ...metafieldActions, 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.5", + description: "Update an existing product. [See the documentation](https://shopify.dev/docs/api/admin-graphql/latest/mutations/productupdate)", + version: "0.0.6", type: "action", props: { shopify, @@ -19,59 +18,64 @@ export default { ], }, title: { - propDefinition: [ - shopify, - "title", - ], + type: "string", + label: "Title", + description: "Title of the new product", optional: true, }, productDescription: { - propDefinition: [ - shopify, - "productDescription", - ], + type: "string", + label: "Product Description", + description: "A description of the product. Supports HTML formatting. Example: `Good snowboard!`", + optional: true, }, vendor: { - propDefinition: [ - shopify, - "vendor", - ], + type: "string", + label: "Vendor", + description: "The name of the product's vendor", + optional: true, }, productType: { - propDefinition: [ - shopify, - "productType", - ], + type: "string", + label: "Product Type", + description: "A categorization for the product used for filtering and searching products", + optional: true, }, status: { - propDefinition: [ - shopify, - "status", + type: "string", + label: "Status", + description: "The status of the product. `active`: The product is ready to sell and is available to customers on the online store, sales channels, and apps. By default, existing products are set to active. `archived`: The product is no longer being sold and isn't available to customers on sales channels and apps. `draft`: The product isn't ready to sell and is unavailable to customers on sales channels and apps. By default, duplicated and unarchived products are set to draft", + optional: true, + options: [ + "ACTIVE", + "ARCHIVED", + "DRAFT", ], }, images: { - propDefinition: [ - shopify, - "images", - ], + type: "string[]", + label: "Images", + description: "A list of URLs of images to associate with the new product", + optional: true, }, options: { - propDefinition: [ - shopify, - "options", - ], + type: "string[]", + label: "Options", + description: "The custom product properties. For example, Size, Color, and Material. Each product can have up to 3 options and each option value can be up to 255 characters. Product variants are made of up combinations of option values. Options cannot be created without values. To create new options, a variant with an associated option value also needs to be created. Example: `[{\"name\":\"Color\",\"values\":[{\"name\": \"Blue\"},{\"name\": \"Black\"}]},{\"name\":\"Size\",\"values\":[{\"name\": \"155\"},{\"name\": \"159\"}]}]`", + optional: true, }, variants: { - propDefinition: [ - shopify, - "variants", - ], + type: "string[]", + label: "Product Variants", + description: "An array of product variants, each representing a different version of the product. The position property is read-only. The position of variants is indicated by the order in which they are listed. Example: `[{\"option1\":\"First\",\"price\":\"10.00\",\"sku\":\"123\"},{\"option1\":\"Second\",\"price\":\"20.00\",\"sku\":\"123\"}]`", + optional: true, }, tags: { propDefinition: [ shopify, "tags", ], + optional: true, }, metafields: { propDefinition: [ @@ -79,6 +83,61 @@ export default { "metafields", ], }, - ...common.props, + handle: { + type: "string", + label: "Handle", + description: "A unique human-friendly string for the product that serves as the URL handle. Automatically generated from the product's title.", + optional: true, + }, + seoTitle: { + type: "string", + label: "SEO Title", + description: "The product title used for search engine optimization", + optional: true, + }, + seoDescription: { + type: "string", + label: "SEO Description", + description: "The product description used for search engine optimization", + optional: true, + }, + }, + async run({ $ }) { + const metafields = await this.createMetafieldsArray(this.metafields, this.productId, "product"); + + const variants = []; + const variantsArray = this.shopify.parseArrayOfJSONStrings(this.variants); + for (const variant of variantsArray) { + if (variant.metafields) { + const variantMetafields = await this.createMetafieldsArray(variant.metafields, variant.id, "variants"); + variants.push({ + ...variant, + metafields: variantMetafields, + }); + continue; + } + variants.push(variant); + } + + const response = await this.shopify.updateProduct({ + input: { + title: this.title, + descriptionHtml: this.productDescription, + vendor: this.vendor, + productType: this.productType, + status: this.status, + images: utils.parseJson(this.images), + options: utils.parseJson(this.options), + variants, + tags: this.tags, + metafields, + metafields_global_title_tag: this.seoTitle, + metafields_global_description_tag: this.seoDescription, + handle: this.handle, + }, + }); + + $.export("$summary", `Updated product \`${response.title}\` with id \`${response.id}\``); + return response; }, }; diff --git a/components/shopify_developer_app/common/mutations.mjs b/components/shopify_developer_app/common/mutations.mjs new file mode 100644 index 0000000000000..1c675dac8cd6e --- /dev/null +++ b/components/shopify_developer_app/common/mutations.mjs @@ -0,0 +1,124 @@ +const CREATE_ORDER = ` + mutation OrderCreate($order: OrderCreateOrderInput!, $options: OrderCreateOptionsInput) { + orderCreate(order: $order, options: $options) { + userErrors { + field + message + } + order { + id + totalTaxSet { + shopMoney { + amount + currencyCode + } + } + lineItems(first: 5) { + nodes { + variant { + id + } + id + title + quantity + taxLines { + title + rate + priceSet { + shopMoney { + amount + currencyCode + } + } + } + } + } + } + } + } +`; + +const CREATE_CUSTOMER = ` + mutation customerCreate($input: CustomerInput!) { + customerCreate(input: $input) { + userErrors { + field + message + } + customer { + id + email + phone + taxExempt + firstName + lastName + amountSpent { + amount + currencyCode + } + smsMarketingConsent { + marketingState + marketingOptInLevel + consentUpdatedAt + } + } + } + } +`; + +const UPDATE_CUSTOMER = ` + mutation updateCustomerMetafields($input: CustomerInput!) { + customerUpdate(input: $input) { + customer { + id + email + firstName + lastName + metafields(first: 3) { + edges { + node { + id + namespace + key + value + } + } + } + } + userErrors { + message + field + } + } + } +`; + +const UPDATE_PRODUCT = ` + mutation UpdateProductWithNewMedia($input: ProductInput!, $media: [CreateMediaInput!]) { + productUpdate(input: $input, media: $media) { + product { + id + media(first: 10) { + nodes { + alt + mediaContentType + preview { + status + } + } + } + } + userErrors { + field + message + } + } + } +`; + +export default { + CREATE_ORDER, + CREATE_CUSTOMER, + UPDATE_CUSTOMER, + UPDATE_PRODUCT, +}; diff --git a/components/shopify_developer_app/common/queries.mjs b/components/shopify_developer_app/common/queries.mjs new file mode 100644 index 0000000000000..49d66c3382a5e --- /dev/null +++ b/components/shopify_developer_app/common/queries.mjs @@ -0,0 +1,181 @@ +const GET_ORDER = ` + query SuggestedRefund($id: ID!, $refundLineItems: [RefundLineItemInput!], $first: Int, $after: String) { + order(id: $id) { + id + metafields (first: $first, after: $after) { + nodes { + id + key + namespace + value + type + } + pageInfo { + endCursor + } + } + suggestedRefund(refundLineItems: $refundLineItems) { + subtotalSet { + shopMoney { + amount + currencyCode + } + presentmentMoney { + amount + currencyCode + } + } + refundLineItems { + lineItem { + id + } + quantity + } + } + } + } +`; + +const GET_CUSTOMER = ` + query ($id: ID!, $first: Int, $after: String) { + customer(id: $id) { + id + firstName + lastName + email + phone + numberOfOrders + amountSpent { + amount + currencyCode + } + createdAt + updatedAt + note + verifiedEmail + validEmailAddress + tags + lifetimeDuration + defaultAddress { + formattedArea + address1 + } + addresses { + address1 + } + image { + src + } + canDelete + metafields (first: $first, after: $after) { + nodes { + id + key + namespace + value + type + } + pageInfo { + endCursor + } + } + } + } +`; + +const GET_DRAFT_ORDER = ` + query ($id: ID!, $first: Int, $after: String) { + draftOrder(id: $id) { + name + metafields (first: $first, after: $after) { + nodes { + id + key + namespace + value + type + } + pageInfo { + endCursor + } + } + } + } +`; + +const LIST_ORDERS = ` + query ($first: Int, $after: String, $reverse: Boolean){ + orders(first: $first, after: $after, reverse: $reverse) { + nodes { + id + updatedAt + metafields (first: $first, after: $after) { + nodes { + id + key + namespace + value + type + } + } + } + pageInfo { + endCursor + } + } + } +`; + +const LIST_DRAFT_ORDERS = ` + query ($first: Int, $after: String){ + draftOrders(first: $first, after: $after) { + nodes { + id + metafields (first: $first, after: $after) { + nodes { + id + key + namespace + value + type + } + } + } + pageInfo { + endCursor + } + } + } +`; + +const LIST_CUSTOMERS = ` + query ($first: Int, $after: String, $query: String) { + customers(first: $first, after: $after, query: $query) { + nodes { + id + displayName + metafields (first: $first, after: $after) { + nodes { + id + key + namespace + value + type + } + } + } + pageInfo { + endCursor + } + } + } +`; + +export default { + GET_ORDER, + GET_CUSTOMER, + GET_DRAFT_ORDER, + LIST_ORDERS, + LIST_DRAFT_ORDERS, + LIST_CUSTOMERS, +}; diff --git a/components/shopify_developer_app/common/rest-admin.mjs b/components/shopify_developer_app/common/rest-admin.mjs deleted file mode 100644 index cf99e4afc9cb5..0000000000000 --- a/components/shopify_developer_app/common/rest-admin.mjs +++ /dev/null @@ -1,97 +0,0 @@ -import common from "../shopify_developer_app.app.mjs"; -import restAdmin from "../../shopify/common/rest-admin.mjs"; - -export default { - ...common, - propDefinitions: { - ...common.propDefinitions, - bodyHtml: { - type: "string", - label: "Body HTML", - description: "The text content of the page, complete with HTML markup.", - }, - pageId: { - type: "string", - label: "Page ID", - description: "The unique numeric identifier for the page.", - async options() { - const { pages } = await this.listPages(); - return pages.map(({ - id: value, title: label, - }) => ({ - label, - value, - })); - }, - }, - blogId: { - type: "string", - label: "Blog ID", - description: "The unique numeric identifier for the blog.", - async options() { - const { blogs } = await this.listBlogs(); - return blogs.map(({ - id: value, title: label, - }) => ({ - label, - value, - })); - }, - }, - articleId: { - type: "string", - label: "Article ID", - description: "The unique numeric identifier for the article.", - async options({ blogId }) { - const { articles } = await this.listBlogArticles({ - blogId, - }); - return articles.map(({ - id: value, title: label, - }) => ({ - label, - value, - })); - }, - }, - orderId: { - type: "string", - label: "Order ID", - description: "The unique numeric identifier for the order.", - async options() { - const { orders } = await this.listOrders(); - return orders.map(({ - id: value, name: label, - }) => ({ - label, - value, - })); - }, - }, - }, - methods: { - ...common.methods, - ...restAdmin.methods, - getHeaders(headers) { - return { - "Content-Type": "application/json", - "X-Shopify-Access-Token": this.$auth.access_token, - ...headers, - }; - }, - listOrders(args = {}) { - return this.makeRequest({ - path: "/orders", - ...args, - }); - }, - getOrder({ - orderId, ...args - }) { - return this.makeRequest({ - path: `/orders/${orderId}`, - ...args, - }); - }, - }, -}; diff --git a/components/shopify_developer_app/common/utils.mjs b/components/shopify_developer_app/common/utils.mjs new file mode 100644 index 0000000000000..d42df055ddeb0 --- /dev/null +++ b/components/shopify_developer_app/common/utils.mjs @@ -0,0 +1,40 @@ +export function adjustPropDefinitions(props, app) { + return Object.fromEntries( + Object.entries(props).map(([ + key, + prop, + ]) => { + if (typeof prop === "string") return [ + key, + prop, + ]; + const { + propDefinition, ...otherValues + } = prop; + if (propDefinition) { + const [ + , ...otherDefs + ] = propDefinition; + return [ + key, + { + propDefinition: [ + app, + ...otherDefs, + ], + ...otherValues, + }, + ]; + } + return [ + key, + otherValues.type === "app" + ? null + : otherValues, + ]; + }) + .filter(([ + , value, + ]) => value), + ); +} diff --git a/components/shopify_developer_app/package.json b/components/shopify_developer_app/package.json index 8b277a1dce53b..ffd42026eb61e 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.6.4", + "version": "0.7.0", "description": "Pipedream Shopify (Developer App) Components", "main": "shopify_developer_app.app.mjs", "keywords": [ @@ -14,7 +14,7 @@ }, "dependencies": { "@pipedream/platform": "^3.0.3", - "@pipedream/shopify": "^0.6.8", + "@pipedream/shopify": "^0.7.0", "shopify-api-node": "^3.14.2" } } diff --git a/components/shopify_developer_app/shopify_developer_app.app.mjs b/components/shopify_developer_app/shopify_developer_app.app.mjs index 1b89fd0146a89..bf383457409f4 100644 --- a/components/shopify_developer_app/shopify_developer_app.app.mjs +++ b/components/shopify_developer_app/shopify_developer_app.app.mjs @@ -1,10 +1,111 @@ -import commonApp from "@pipedream/shopify/common-app.mjs"; +import commonApp from "@pipedream/shopify"; import Shopify from "shopify-api-node"; +import queries from "./common/queries.mjs"; +import mutations from "./common/mutations.mjs"; +import { API_VERSION } from "@pipedream/shopify/common/constants.mjs"; export default { ...commonApp, type: "app", app: "shopify_developer_app", + propDefinitions: { + ...commonApp.propDefinitions, + orderId: { + type: "string", + label: "Order ID", + description: "The identifier of an order", + async options({ prevContext }) { + return this.getPropOptions({ + resourceFn: this.listOrders, + resourceKeys: [ + "orders", + ], + labelKey: "id", + prevContext, + }); + }, + }, + customerId: { + type: "string", + label: "Customer ID", + description: "The identifier of a customer", + async options({ prevContext }) { + return this.getPropOptions({ + resourceFn: this.listCustomers, + resourceKeys: [ + "customers", + ], + labelKey: "displayName", + prevContext, + }); + }, + }, + firstName: { + type: "string", + label: "First Name", + description: "The customer's first name", + optional: true, + }, + lastName: { + type: "string", + label: "Last Name", + description: "The customer's last name", + optional: true, + }, + email: { + type: "string", + label: "Email", + description: "The unique email address of the customer", + }, + phone: { + type: "string", + label: "Phone Number", + description: "The unique phone number (E.164 format) for this customer. Check out [Shopify Customer API](https://shopify.dev/api/admin-rest/2022-01/resources/customer#[post]/admin/api/#{api_version}/customers.json_examples) for more details on valid formats", + optional: true, + }, + address: { + type: "string", + label: "Street Address", + description: "The customer's mailing address", + optional: true, + }, + company: { + type: "string", + label: "Company", + description: "The customer's company", + optional: true, + }, + city: { + type: "string", + label: "City", + description: "The customer's city, town, or village", + optional: true, + }, + province: { + type: "string", + label: "Province", + description: "The customer's region name. Typically a province, a state, or a prefecture", + optional: true, + }, + country: { + type: "string", + label: "Country", + description: "The customer's country", + optional: true, + }, + zip: { + type: "string", + label: "Zip Code", + description: "The customer's postal code", + optional: true, + }, + metafields: { + type: "string[]", + label: "Metafields", + description: "An array of objects, each one representing a metafield. If adding a new metafield, the object should contain `key`, `value`, `type`, and `namespace`. Example: `{{ [{ \"key\": \"new\", \"value\": \"newvalue\", \"type\": \"single_line_text_field\", \"namespace\": \"global\" }] }}`. To update an existing metafield, use the `id` and `value`. Example: `{{ [{ \"id\": \"28408051400984\", \"value\": \"updatedvalue\" }] }}`", + optional: true, + }, + }, methods: { ...commonApp.methods, getShopifyInstance() { @@ -12,7 +113,35 @@ export default { shopName: this.getShopId(), accessToken: this.$auth.access_token, autoLimit: true, + apiVersion: API_VERSION, }); }, + getOrder(variables) { + return this._makeGraphQlRequest(queries.GET_ORDER, variables); + }, + getDraftOrder(variables) { + return this._makeGraphQlRequest(queries.GET_DRAFT_ORDER, variables); + }, + getCustomer(variables) { + return this._makeGraphQlRequest(queries.GET_CUSTOMER, variables); + }, + listOrders(variables) { + return this._makeGraphQlRequest(queries.LIST_ORDERS, variables); + }, + listDraftOrders(variables) { + return this._makeGraphQlRequest(queries.LIST_DRAFT_ORDERS, variables); + }, + listCustomers(variables) { + return this._makeGraphQlRequest(queries.LIST_CUSTOMERS, variables); + }, + createOrder(variables) { + return this._makeGraphQlRequest(mutations.CREATE_ORDER, variables); + }, + createCustomer(variables) { + return this._makeGraphQlRequest(mutations.CREATE_CUSTOMER, variables); + }, + updateCustomer(variables) { + return this._makeGraphQlRequest(mutations.UPDATE_CUSTOMER, variables); + }, }, }; diff --git a/components/shopify_developer_app/sources/common/webhook.mjs b/components/shopify_developer_app/sources/common/webhook.mjs index 969dfc985199a..4ff2a5cec879e 100644 --- a/components/shopify_developer_app/sources/common/webhook.mjs +++ b/components/shopify_developer_app/sources/common/webhook.mjs @@ -12,17 +12,25 @@ export default { }, hooks: { async activate() { - const { result: webhook } = await this.app.createWebhook({ - address: this.http.endpoint, - topic: this.getTopic(), - metafield_namespaces: this.metafieldNamespaces, - private_metafield_namespaces: this.privateMetafieldNamespaces, - }); - this.setWebhookId(webhook.id); + const { webhookSubscriptionCreate: { webhookSubscription: { id } } } + = await this.app.createWebhook({ + topic: this.getTopic(), + webhookSubscription: { + callbackUrl: this.http.endpoint, + format: "JSON", + metafieldNamespaces: [ + ...(this.metafieldNamespaces || []), + ...(this.privateMetafieldNamespaces || []), + ], + }, + }); + this.setWebhookId(id); }, async deactivate() { const webhookId = this.getWebhookId(); - await this.app.deleteWebhook(webhookId); + if (webhookId) { + await this.app.deleteWebhook(webhookId); + } }, }, methods: { @@ -45,7 +53,7 @@ export default { shopId, ] = domain.split(constants.DOMAIN_SUFFIX); return this.app.getShopId() === shopId - && this.getTopic() === topic; + && constants.EVENT_TOPIC[this.getTopic()] === topic; }, checkMetaFields({ metafields = [], private_metafields: privateMetafields = [], diff --git a/components/shopify_developer_app/sources/new-abandoned-cart/new-abandoned-cart.mjs b/components/shopify_developer_app/sources/new-abandoned-cart/new-abandoned-cart.mjs index 8835ae9ba65e5..4cc767985071a 100644 --- a/components/shopify_developer_app/sources/new-abandoned-cart/new-abandoned-cart.mjs +++ b/components/shopify_developer_app/sources/new-abandoned-cart/new-abandoned-cart.mjs @@ -1,16 +1,22 @@ import shopify from "../../shopify_developer_app.app.mjs"; -import common from "@pipedream/shopify/sources/new-abandoned-cart/common.mjs"; +import common from "@pipedream/shopify/sources/new-abandoned-cart/new-abandoned-cart.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, shopify); export default { - ...common, + ...others, key: "shopify_developer_app-new-abandoned-cart", - name: "New Abandoned Cart", - type: "source", - description: "Emit new event each time a user abandons their cart.", - version: "0.0.5", - dedupe: "unique", + version: "0.0.6", + name, + description, + type, props: { shopify, - ...common.props, + ...props, }, }; diff --git a/components/shopify_developer_app/sources/new-article/new-article.mjs b/components/shopify_developer_app/sources/new-article/new-article.mjs index b1f804b75e44a..f03f4bc514180 100644 --- a/components/shopify_developer_app/sources/new-article/new-article.mjs +++ b/components/shopify_developer_app/sources/new-article/new-article.mjs @@ -1,16 +1,22 @@ import shopify from "../../shopify_developer_app.app.mjs"; -import common from "@pipedream/shopify/sources/new-article/common.mjs"; +import common from "@pipedream/shopify/sources/new-article/new-article.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, shopify); export default { - ...common, + ...others, key: "shopify_developer_app-new-article", - name: "New Article", - type: "source", - description: "Emit new event for each new article in a blog.", - version: "0.0.4", - dedupe: "unique", + version: "0.0.5", + name, + description, + type, props: { - shopify, - ...common.props, + app: shopify, + ...props, }, }; diff --git a/components/shopify_developer_app/sources/new-cancelled-order/new-cancelled-order.mjs b/components/shopify_developer_app/sources/new-cancelled-order/new-cancelled-order.mjs index 5c7eb4b4892ad..330bfe24e2f7f 100644 --- a/components/shopify_developer_app/sources/new-cancelled-order/new-cancelled-order.mjs +++ b/components/shopify_developer_app/sources/new-cancelled-order/new-cancelled-order.mjs @@ -1,4 +1,3 @@ -import constants from "../common/constants.mjs"; import common from "../common/webhook-metafields.mjs"; export default { @@ -7,18 +6,18 @@ export default { name: "New Cancelled Order (Instant)", type: "source", description: "Emit new event each time a new order is cancelled.", - version: "0.0.8", + version: "0.0.9", dedupe: "unique", methods: { ...common.methods, getTopic() { - return constants.EVENT_TOPIC.ORDERS_CANCELLED; + return "ORDERS_CANCELLED"; }, generateMeta(resource) { - const ts = Date.parse(resource.updated_at); + const ts = Date.parse(resource.updatedAt); return { id: ts, - summary: `Order Cancelled ${resource.id}.`, + summary: `Order Cancelled ${resource.id}`, ts, }; }, diff --git a/components/shopify_developer_app/sources/new-customer-created/new-customer-created.mjs b/components/shopify_developer_app/sources/new-customer-created/new-customer-created.mjs index c4a6a19b1420e..5644d2702f61c 100644 --- a/components/shopify_developer_app/sources/new-customer-created/new-customer-created.mjs +++ b/components/shopify_developer_app/sources/new-customer-created/new-customer-created.mjs @@ -1,4 +1,3 @@ -import constants from "../common/constants.mjs"; import common from "../common/webhook-metafields.mjs"; export default { @@ -7,18 +6,18 @@ export default { name: "New Customer Created (Instant)", type: "source", description: "Emit new event for each new customer added to a store.", - version: "0.0.8", + version: "0.0.9", dedupe: "unique", methods: { ...common.methods, getTopic() { - return constants.EVENT_TOPIC.CUSTOMERS_CREATE; + return "CUSTOMERS_CREATE"; }, generateMeta(resource) { - const ts = Date.parse(resource.created_at); + const ts = Date.parse(resource.createdAt); return { id: resource.id, - summary: `New Customer ${resource.id}.`, + summary: `New Customer ${resource.id}`, ts, }; }, diff --git a/components/shopify_developer_app/sources/new-draft-order/new-draft-order.mjs b/components/shopify_developer_app/sources/new-draft-order/new-draft-order.mjs index f1b139b1e5ef3..bf6c1493d2e65 100644 --- a/components/shopify_developer_app/sources/new-draft-order/new-draft-order.mjs +++ b/components/shopify_developer_app/sources/new-draft-order/new-draft-order.mjs @@ -1,4 +1,3 @@ -import constants from "../common/constants.mjs"; import common from "../common/webhook-metafields.mjs"; export default { @@ -7,18 +6,18 @@ export default { name: "New Draft Order (Instant)", type: "source", description: "Emit new event for each new draft order submitted to a store.", - version: "0.0.8", + version: "0.0.9", dedupe: "unique", methods: { ...common.methods, getTopic() { - return constants.EVENT_TOPIC.DRAFT_ORDERS_CREATE; + return "DRAFT_ORDERS_CREATE"; }, generateMeta(resource) { - const ts = Date.parse(resource.created_at); + const ts = Date.parse(resource.createdAt); return { id: resource.id, - summary: `New Draft Order ${resource.id}.`, + summary: `New Draft Order ${resource.id}`, ts, }; }, diff --git a/components/shopify_developer_app/sources/new-event-emitted/new-event-emitted.mjs b/components/shopify_developer_app/sources/new-event-emitted/new-event-emitted.mjs index 27e0951cd5bcc..2410d96540671 100644 --- a/components/shopify_developer_app/sources/new-event-emitted/new-event-emitted.mjs +++ b/components/shopify_developer_app/sources/new-event-emitted/new-event-emitted.mjs @@ -1,5 +1,5 @@ -import constants from "../common/constants.mjs"; import common from "../common/webhook-metafields.mjs"; +import constants from "../common/constants.mjs"; export default { ...common, @@ -7,7 +7,7 @@ export default { name: "New Event Emitted (Instant)", type: "source", description: "Emit new event for each new Shopify event.", - version: "0.0.9", + version: "0.0.10", dedupe: "unique", props: { ...common.props, @@ -15,7 +15,13 @@ export default { type: "string", label: "Event Topic", description: "Event topic that triggers the webhook.", - options: constants.EVENT_TOPICS, + options: Object.entries(constants.EVENT_TOPIC).map(([ + key, + value, + ]) => ({ + value: key, + label: value, + })), }, }, methods: { @@ -27,7 +33,7 @@ export default { const ts = Date.now(); return { id: ts, - summary: `New Event Emitted at ${new Date(ts)}.`, + summary: `New Event Emitted at ${new Date(ts)}`, ts, }; }, diff --git a/components/shopify_developer_app/sources/new-fulfillment-event/new-fulfillment-event.mjs b/components/shopify_developer_app/sources/new-fulfillment-event/new-fulfillment-event.mjs index 1ec78c7b7ca2a..b7c5cebde1740 100644 --- a/components/shopify_developer_app/sources/new-fulfillment-event/new-fulfillment-event.mjs +++ b/components/shopify_developer_app/sources/new-fulfillment-event/new-fulfillment-event.mjs @@ -1,4 +1,3 @@ -import constants from "../common/constants.mjs"; import common from "../common/webhook-metafields.mjs"; export default { @@ -7,18 +6,18 @@ export default { name: "New Fulfillment Event (Instant)", type: "source", description: "Emit new event for each new fulfillment event for a store.", - version: "0.0.6", + version: "0.0.7", dedupe: "unique", methods: { ...common.methods, getTopic() { - return constants.EVENT_TOPIC.FULFILLMENT_EVENTS_CREATE; + return "FULFILLMENT_EVENTS_CREATE"; }, generateMeta(resource) { - const ts = Date.parse(resource.updated_at); + const ts = Date.parse(resource.updatedAt); return { id: ts, - summary: `New Fulfillment Event ${resource.id}.`, + summary: `New Fulfillment Event ${resource.id}`, ts, }; }, diff --git a/components/shopify_developer_app/sources/new-order-created/new-order-created.mjs b/components/shopify_developer_app/sources/new-order-created/new-order-created.mjs index 6f39546a1f5b7..ce6960cab58a0 100644 --- a/components/shopify_developer_app/sources/new-order-created/new-order-created.mjs +++ b/components/shopify_developer_app/sources/new-order-created/new-order-created.mjs @@ -1,4 +1,3 @@ -import constants from "../common/constants.mjs"; import common from "../common/webhook-metafields.mjs"; export default { @@ -7,18 +6,18 @@ export default { name: "New Order Created (Instant)", type: "source", description: "Emit new event for each new order submitted to a store.", - version: "0.0.8", + version: "0.0.9", dedupe: "unique", methods: { ...common.methods, getTopic() { - return constants.EVENT_TOPIC.ORDERS_CREATE; + return "ORDERS_CREATE"; }, generateMeta(resource) { - const ts = Date.parse(resource.created_at); + const ts = Date.parse(resource.createdAt); return { id: resource.id, - summary: `New Order ${resource.id}.`, + summary: `New Order ${resource.id}`, ts, }; }, @@ -26,7 +25,10 @@ export default { hooks: { ...common.hooks, async deploy() { - let results = await this.app.getOrders("any", false, null, null, "any", 5, 1); + const { orders: { nodes: results } } = await this.app.listOrders({ + first: 5, + reverse: true, + }); for (const order of results) { this.$emit(order, this.generateMeta(order)); } diff --git a/components/shopify_developer_app/sources/new-order-fulfilled/new-order-fulfilled.mjs b/components/shopify_developer_app/sources/new-order-fulfilled/new-order-fulfilled.mjs index 7c90a16522718..d6cf6449438a9 100644 --- a/components/shopify_developer_app/sources/new-order-fulfilled/new-order-fulfilled.mjs +++ b/components/shopify_developer_app/sources/new-order-fulfilled/new-order-fulfilled.mjs @@ -1,4 +1,3 @@ -import constants from "../common/constants.mjs"; import common from "../common/webhook-metafields.mjs"; export default { @@ -7,18 +6,18 @@ export default { name: "New Order Fulfilled (Instant)", type: "source", description: "Emit new event whenever an order is fulfilled.", - version: "0.0.5", + version: "0.0.6", dedupe: "unique", methods: { ...common.methods, getTopic() { - return constants.EVENT_TOPIC.ORDERS_FULFILLED; + return "ORDERS_FULFILLED"; }, generateMeta(resource) { - const ts = Date.parse(resource.updated_at); + const ts = Date.parse(resource.updatedAt); return { id: ts, - summary: `New Fulfilled Order ${resource.id}.`, + summary: `New Fulfilled Order ${resource.id}`, ts, }; }, diff --git a/components/shopify_developer_app/sources/new-page/new-page.mjs b/components/shopify_developer_app/sources/new-page/new-page.mjs index e788231c7866d..662fbed08dea7 100644 --- a/components/shopify_developer_app/sources/new-page/new-page.mjs +++ b/components/shopify_developer_app/sources/new-page/new-page.mjs @@ -1,16 +1,22 @@ import shopify from "../../shopify_developer_app.app.mjs"; -import common from "@pipedream/shopify/sources/new-page/common.mjs"; +import common from "@pipedream/shopify/sources/new-page/new-page.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, shopify); export default { - ...common, + ...others, key: "shopify_developer_app-new-page", - name: "New Page", - type: "source", - description: "Emit new event for each new page published.", - version: "0.0.4", - dedupe: "unique", + version: "0.0.5", + name, + description, + type, props: { - shopify, - ...common.props, + app: shopify, + ...props, }, }; diff --git a/components/shopify_developer_app/sources/new-paid-order/new-paid-order.mjs b/components/shopify_developer_app/sources/new-paid-order/new-paid-order.mjs index d7df9dac84b8f..c116ebab4a22f 100644 --- a/components/shopify_developer_app/sources/new-paid-order/new-paid-order.mjs +++ b/components/shopify_developer_app/sources/new-paid-order/new-paid-order.mjs @@ -1,4 +1,3 @@ -import constants from "../common/constants.mjs"; import common from "../common/webhook-metafields.mjs"; export default { @@ -7,18 +6,18 @@ export default { name: "New Paid Order (Instant)", type: "source", description: "Emit new event each time a new order is paid.", - version: "0.0.8", + version: "0.0.9", dedupe: "unique", methods: { ...common.methods, getTopic() { - return constants.EVENT_TOPIC.ORDERS_PAID; + return "ORDERS_PAID"; }, generateMeta(resource) { - const ts = Date.parse(resource.updated_at); + const ts = Date.parse(resource.updatedAt); return { id: ts, - summary: `Order Paid ${resource.id}.`, + summary: `Order Paid ${resource.id}`, ts, }; }, diff --git a/components/shopify_developer_app/sources/new-product-created/new-product-created.mjs b/components/shopify_developer_app/sources/new-product-created/new-product-created.mjs index 87120637111d3..9a3487230c05f 100644 --- a/components/shopify_developer_app/sources/new-product-created/new-product-created.mjs +++ b/components/shopify_developer_app/sources/new-product-created/new-product-created.mjs @@ -1,4 +1,3 @@ -import constants from "../common/constants.mjs"; import common from "../common/webhook-metafields.mjs"; export default { @@ -7,18 +6,18 @@ export default { name: "New Product Created (Instant)", type: "source", description: "Emit new event for each product added to a store.", - version: "0.0.8", + version: "0.0.9", dedupe: "unique", methods: { ...common.methods, getTopic() { - return constants.EVENT_TOPIC.PRODUCTS_CREATE; + return "PRODUCTS_CREATE"; }, generateMeta(resource) { - const ts = Date.parse(resource.created_at); + const ts = Date.parse(resource.createdAt); return { id: resource.id, - summary: `New Product ${resource.id}.`, + summary: `New Product ${resource.id}`, ts, }; }, diff --git a/components/shopify_developer_app/sources/new-product-updated/new-product-updated.mjs b/components/shopify_developer_app/sources/new-product-updated/new-product-updated.mjs index e9f1653a85d5f..50a216e4e4914 100644 --- a/components/shopify_developer_app/sources/new-product-updated/new-product-updated.mjs +++ b/components/shopify_developer_app/sources/new-product-updated/new-product-updated.mjs @@ -1,4 +1,3 @@ -import constants from "../common/constants.mjs"; import common from "../common/webhook-metafields.mjs"; export default { @@ -6,7 +5,7 @@ export default { key: "shopify_developer_app-new-product-updated", name: "New Product Updated (Instant)", description: "Emit new event for each product updated in a store.", - version: "0.0.6", + version: "0.0.7", type: "source", dedupe: "unique", props: { @@ -27,11 +26,11 @@ export default { methods: { ...common.methods, getTopic() { - return constants.EVENT_TOPIC.PRODUCTS_UPDATE; + return "PRODUCTS_UPDATE"; }, isRelevant(resource) { let relevant = true; - if (this.productType && resource.product_type !== this.productType) { + if (this.productType && resource.productType !== this.productType) { relevant = false; } if (this.tags?.length) { @@ -44,7 +43,7 @@ export default { return relevant; }, generateMeta(resource) { - const ts = Date.parse(resource.updated_at); + const ts = Date.parse(resource.updatedAt); return { id: `${resource.id}-${ts}`, summary: `Product Updated ${resource.id}`, diff --git a/components/shopify_developer_app/sources/new-refund-created/new-refund-created.mjs b/components/shopify_developer_app/sources/new-refund-created/new-refund-created.mjs index e1d229189c784..46465f0356d33 100644 --- a/components/shopify_developer_app/sources/new-refund-created/new-refund-created.mjs +++ b/components/shopify_developer_app/sources/new-refund-created/new-refund-created.mjs @@ -1,4 +1,3 @@ -import constants from "../common/constants.mjs"; import common from "../common/webhook.mjs"; export default { @@ -6,16 +5,16 @@ export default { key: "shopify_developer_app-new-refund-created", name: "New Refund Created (Instant)", description: "Emit new event when a new refund is created.", - version: "0.0.5", + version: "0.0.6", type: "source", dedupe: "unique", methods: { ...common.methods, getTopic() { - return constants.EVENT_TOPIC.REFUNDS_CREATE; + return "REFUNDS_CREATE"; }, generateMeta(resource) { - const ts = Date.parse(resource.created_at); + const ts = Date.parse(resource.createdAt); return { id: `${resource.id}-${ts}`, summary: `Refund Created ${resource.id}`, diff --git a/components/shopify_developer_app/sources/new-updated-customer/new-updated-customer.mjs b/components/shopify_developer_app/sources/new-updated-customer/new-updated-customer.mjs index 6240d614fe686..e0f095aa6908e 100644 --- a/components/shopify_developer_app/sources/new-updated-customer/new-updated-customer.mjs +++ b/components/shopify_developer_app/sources/new-updated-customer/new-updated-customer.mjs @@ -1,4 +1,3 @@ -import constants from "../common/constants.mjs"; import common from "../common/webhook-metafields.mjs"; export default { @@ -7,18 +6,18 @@ export default { name: "New Updated Customer (Instant)", type: "source", description: "Emit new event each time a customer's information is updated.", - version: "0.0.8", + version: "0.0.9", dedupe: "unique", methods: { ...common.methods, getTopic() { - return constants.EVENT_TOPIC.CUSTOMERS_UPDATE; + return "CUSTOMERS_UPDATE"; }, generateMeta(resource) { - const ts = Date.parse(resource.updated_at); + const ts = Date.parse(resource.updatedAt); return { id: ts, - summary: `Customer Updated ${resource.id}.`, + summary: `Customer Updated ${resource.id}`, ts, }; }, diff --git a/components/shopify_developer_app/sources/new-updated-order/new-updated-order.mjs b/components/shopify_developer_app/sources/new-updated-order/new-updated-order.mjs index 49611be20fcc3..d8063b5cddca3 100644 --- a/components/shopify_developer_app/sources/new-updated-order/new-updated-order.mjs +++ b/components/shopify_developer_app/sources/new-updated-order/new-updated-order.mjs @@ -1,4 +1,3 @@ -import constants from "../common/constants.mjs"; import common from "../common/webhook-metafields.mjs"; export default { @@ -7,18 +6,18 @@ export default { name: "New Updated Order (Instant)", type: "source", description: "Emit new event each time an order is updated.", - version: "0.0.8", + version: "0.0.9", dedupe: "unique", methods: { ...common.methods, getTopic() { - return constants.EVENT_TOPIC.ORDERS_UPDATED; + return "ORDERS_UPDATED"; }, generateMeta(resource) { - const ts = Date.parse(resource.updated_at); + const ts = Date.parse(resource.updatedAt); return { id: ts, - summary: `Order Updated ${resource.id}.`, + summary: `Order Updated ${resource.id}`, ts, }; }, diff --git a/components/shopify_developer_app/sources/product-added-to-custom-collection/product-added-to-custom-collection.mjs b/components/shopify_developer_app/sources/product-added-to-custom-collection/product-added-to-custom-collection.mjs index 86a0232f08935..71bac3f8dc64d 100644 --- a/components/shopify_developer_app/sources/product-added-to-custom-collection/product-added-to-custom-collection.mjs +++ b/components/shopify_developer_app/sources/product-added-to-custom-collection/product-added-to-custom-collection.mjs @@ -1,16 +1,22 @@ import shopify from "../../shopify_developer_app.app.mjs"; -import common from "@pipedream/shopify/sources/product-added-to-custom-collection/common.mjs"; +import common from "@pipedream/shopify/sources/collection-updated/collection-updated.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, shopify); export default { - ...common, + ...others, key: "shopify_developer_app-product-added-to-custom-collection", - name: "New product added to custom collection", - description: "Emit new event each time a product is added to a custom collection.", - version: "0.0.4", - type: "source", - dedupe: "unique", + version: "0.0.5", + name, + description, + type, props: { shopify, - ...common.props, + ...props, }, }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f247fe651b2bf..626d647fb1a3f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8563,8 +8563,7 @@ importers: components/nusii_proposals: {} - components/nutrient_document_web_services_api: - specifiers: {} + components/nutrient_document_web_services_api: {} components/nutshell: dependencies: @@ -10777,8 +10776,7 @@ importers: components/runpod: {} - components/runsignup: - specifiers: {} + components/runsignup: {} components/runware: dependencies: @@ -11429,8 +11427,8 @@ importers: specifier: ^3.0.3 version: 3.0.3 '@pipedream/shopify': - specifier: ^0.6.8 - version: 0.6.8 + specifier: ^0.7.0 + version: 0.7.0 shopify-api-node: specifier: ^3.14.2 version: 3.14.2 @@ -13653,8 +13651,7 @@ importers: specifier: ^1.6.0 version: 1.6.6 - components/wafrow: - specifiers: {} + components/wafrow: {} components/waitless: {} @@ -17642,8 +17639,8 @@ packages: '@pipedream/sftp@0.4.1': resolution: {integrity: sha512-K+tYweZBO4cAZDXqCsciPeDEG6tJsuCS0+kP+JlWfwjKHH/Z75G/P5NXFO3tGCwmSrhwyB/Ew1Zi89oUsQq8mQ==} - '@pipedream/shopify@0.6.8': - resolution: {integrity: sha512-SKdygl45yUUAMkRpVhIuiAR2EwqKv8rjQWXpu92j6i815K7K7k7iib+EiZ8KIqfQrogck1LcHpF+9wQcCQHRzw==} + '@pipedream/shopify@0.7.0': + resolution: {integrity: sha512-bZoTDxcwBIepWhT8LVXzOxAO3S9NM8U1NEfS5106aDHFizr6L7lg/78+GaPdishK12oce0B/fCFY0ssd5AQxWA==} '@pipedream/snowflake-sdk@1.0.8': resolution: {integrity: sha512-/nLCQNjlSCz71MUnOUZqWmnjZTbEX7mie91mstPspb8uDG/GvaDk/RynLGhhYfgEP5d1KWj+OPaI71hmPSxReg==} @@ -31077,7 +31074,7 @@ snapshots: '@babel/helper-validator-option': 8.0.0-alpha.13 browserslist: 4.24.2 lru-cache: 7.18.3 - semver: 7.6.3 + semver: 7.7.1 '@babel/helper-create-class-features-plugin@7.25.9(@babel/core@7.26.0)': dependencies: @@ -33834,11 +33831,12 @@ snapshots: transitivePeerDependencies: - debug - '@pipedream/shopify@0.6.8': + '@pipedream/shopify@0.7.0': dependencies: '@pipedream/platform': 3.0.3 async-retry: 1.3.3 bottleneck: 2.19.5 + form-data: 4.0.2 lodash.get: 4.4.2 lodash.topath: 4.5.2 shopify-api-node: 3.14.2 @@ -34204,6 +34202,8 @@ snapshots: '@putout/operator-filesystem': 5.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3)) '@putout/operator-json': 2.2.0 putout: 36.13.1(eslint@8.57.1)(typescript@5.6.3) + transitivePeerDependencies: + - supports-color '@putout/operator-regexp@1.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3))': dependencies: @@ -36999,7 +36999,7 @@ snapshots: axios@1.8.2: dependencies: follow-redirects: 1.15.9(debug@3.2.7) - form-data: 4.0.1 + form-data: 4.0.2 proxy-from-env: 1.1.0 transitivePeerDependencies: - debug @@ -41102,7 +41102,7 @@ snapshots: is-bun-module@1.2.1: dependencies: - semver: 7.6.3 + semver: 7.7.1 is-callable@1.2.7: {}