Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

feat(shopify): let AI agents manage products, collections, inventory and locations (#16088)

Odai Ahmad3edc9e5d7f7c
diff --git a/bun.lock b/bun.lock
index c5a5c7c7f51..33b7576f1e6 100644
--- a/bun.lock
+++ b/bun.lock
@@ -8313,7 +8313,7 @@
},
"packages/pieces/community/shopify": {
"name": "@activepieces/piece-shopify",
- "version": "0.5.0",
+ "version": "0.6.0",
"dependencies": {
"@activepieces/core-piece-types": "workspace:*",
"@activepieces/core-utils": "workspace:*",
diff --git a/packages/pieces/community/shopify/package.json b/packages/pieces/community/shopify/package.json
index e76c8529a5e..7643e7504bc 100644
--- a/packages/pieces/community/shopify/package.json
+++ b/packages/pieces/community/shopify/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-shopify",
- "version": "0.5.0",
+ "version": "0.6.0",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
diff --git a/packages/pieces/community/shopify/src/i18n/translation.json b/packages/pieces/community/shopify/src/i18n/translation.json
index 8b6b98651cd..249b277ee60 100644
--- a/packages/pieces/community/shopify/src/i18n/translation.json
+++ b/packages/pieces/community/shopify/src/i18n/translation.json
@@ -26,6 +26,9 @@
"Update Order": "Update Order",
"Update Product": "Update Product",
"Upload Product Image": "Upload Product Image",
+ "Stock Item at Location": "Stock Item at Location",
+ "Add Product Media": "Add Product Media",
+ "Add Products to Collection": "Add Products to Collection",
"Add Tags": "Add Tags",
"Send Payment Method Update Email": "Send Payment Method Update Email",
"Resolve Requested Order Edit": "Resolve Requested Order Edit",
@@ -33,51 +36,100 @@
"Create Requested Order Edit": "Create Requested Order Edit",
"Calculate Requested Order Edit": "Calculate Requested Order Edit",
"List Requested Order Edits": "List Requested Order Edits",
+ "Adjust Inventory Quantities": "Adjust Inventory Quantities",
"Archive Order": "Archive Order",
+ "Attach Media to Variants": "Attach Media to Variants",
"Calculate Refund": "Calculate Refund",
"Capture Order Payment": "Capture Order Payment",
"Complete Draft Order": "Complete Draft Order",
"Count Abandoned Checkouts": "Count Abandoned Checkouts",
+ "Count Collections": "Count Collections",
"Count Customer Segments": "Count Customer Segments",
"Count Customers": "Count Customers",
"Count Draft Orders": "Count Draft Orders",
+ "Count Locations": "Count Locations",
+ "Count Products": "Count Products",
+ "Create Collection": "Create Collection",
"Create Customer Address": "Create Customer Address",
"Create Order Risk Assessment": "Create Order Risk Assessment",
+ "Create Product Options": "Create Product Options",
+ "Create Product Variants": "Create Product Variants",
"Create Refund": "Create Refund",
+ "Create Smart Collection": "Create Smart Collection",
+ "Stop Stocking Item at Location": "Stop Stocking Item at Location",
+ "Delete Collection": "Delete Collection",
"Delete Customer Address": "Delete Customer Address",
"Delete Customer": "Delete Customer",
"Delete Draft Order": "Delete Draft Order",
"Delete Order": "Delete Order",
+ "Remove Product Media": "Remove Product Media",
+ "Delete Product Options": "Delete Product Options",
+ "Delete Product Variants": "Delete Product Variants",
+ "Delete Product": "Delete Product",
+ "Detach Media from Variants": "Detach Media from Variants",
+ "Duplicate Product": "Duplicate Product",
"Generate Customer Activation URL": "Generate Customer Activation URL",
"Get Abandonment": "Get Abandonment",
"Get Checkout Abandonment": "Get Checkout Abandonment",
+ "Get Collection by Handle": "Get Collection by Handle",
+ "Get Collection": "Get Collection",
"Get Draft Order": "Get Draft Order",
"Get Granted Access Scopes": "Get Granted Access Scopes",
+ "Get Inventory Item": "Get Inventory Item",
"Get Job Status": "Get Job Status",
+ "Get Location": "Get Location",
"Get Order Risk Assessments": "Get Order Risk Assessments",
"Get Order Transaction": "Get Order Transaction",
"Get Order": "Get Order",
+ "Get Product Duplicate Job": "Get Product Duplicate Job",
+ "Get Product Media": "Get Product Media",
+ "Get Publication": "Get Publication",
"Get Refund": "Get Refund",
"Get Shop": "Get Shop",
"List Abandoned Checkouts": "List Abandoned Checkouts",
+ "List Collection Products": "List Collection Products",
"List Customer Addresses": "List Customer Addresses",
"List Customer Orders": "List Customer Orders",
"List Draft Orders": "List Draft Orders",
+ "Search Inventory Items": "Search Inventory Items",
+ "List Inventory Levels": "List Inventory Levels",
+ "List Locations": "List Locations",
"List Order Refunds": "List Order Refunds",
"List Order Transactions": "List Order Transactions",
+ "List Product Media": "List Product Media",
+ "List Product Variants": "List Product Variants",
+ "List Publications": "List Publications",
+ "List Sales Channels": "List Sales Channels",
"List Tender Transactions": "List Tender Transactions",
"Mark Order as Paid": "Mark Order as Paid",
+ "Publish Product or Collection": "Publish Product or Collection",
+ "Remove Products from Collection": "Remove Products from Collection",
"Remove Tags": "Remove Tags",
+ "Start Collection Product Reorder": "Start Collection Product Reorder",
+ "Start Product Media Reorder": "Start Product Media Reorder",
+ "Reorder Product Options": "Reorder Product Options",
+ "Reorder Product Variants": "Reorder Product Variants",
+ "Search Collections": "Search Collections",
"Search Customers": "Search Customers",
"Search Orders": "Search Orders",
+ "Search Product Categories": "Search Product Categories",
+ "Search Products": "Search Products",
"Send Customer Account Invite": "Send Customer Account Invite",
"Send Draft Order Invoice": "Send Draft Order Invoice",
"Set Default Customer Address": "Set Default Customer Address",
+ "Set Inventory Quantities": "Set Inventory Quantities",
+ "Set Product (Full State)": "Set Product (Full State)",
"Start Order Cancellation": "Start Order Cancellation",
"Unarchive Order": "Unarchive Order",
+ "Unpublish Product or Collection": "Unpublish Product or Collection",
+ "Update Collection": "Update Collection",
"Update Customer Address": "Update Customer Address",
"Update Draft Order": "Update Draft Order",
+ "Update Inventory Item": "Update Inventory Item",
"Update Order Details": "Update Order Details",
+ "Update Product Media": "Update Product Media",
+ "Update Product Option": "Update Product Option",
+ "Update Product Variants": "Update Product Variants",
"Void Payment Authorization": "Void Payment Authorization",
"Custom API Call": "Custom API Call",
"Adjust inventory level of an item at a location.": "Adjust inventory level of an item at a location.",
@@ -106,6 +158,9 @@
"Update an existing order.": "Update an existing order.",
"Update an existing product.": "Update an existing product.",
"Upload a new product image.": "Upload a new product image.",
+ "Start tracking an inventory item at a location, optionally with a starting quantity.": "Start tracking an inventory item at a location, optionally with a starting quantity.",
+ "Add images, videos or 3D models to a product from public URLs.": "Add images, videos or 3D models to a product from public URLs.",
+ "Add products to a collection by hand.": "Add products to a collection by hand.",
"Add tags to an order, draft order, customer or product.": "Add tags to an order, draft order, customer or product.",
"Email a customer a secure link to add a new payment method for an order, draft order or subscription contract.": "Email a customer a secure link to add a new payment method for an order, draft order or subscription contract.",
"Mark a buyer request to edit an order as completed.": "Mark a buyer request to edit an order as completed.",
@@ -113,56 +168,109 @@
"Record a buyer request to remove unfulfilled line items from an order.": "Record a buyer request to remove unfulfilled line items from an order.",
"Preview the money effect of removing line items from an order, without changing anything.": "Preview the money effect of removing line items from an order, without changing anything.",
"List the edits a buyer requested on an order, such as removing unfulfilled items.": "List the edits a buyer requested on an order, such as removing unfulfilled items.",
+ "Increase or decrease stock by a relative amount at one or more locations.": "Increase or decrease stock by a relative amount at one or more locations.",
"Close (archive) an order.": "Close (archive) an order.",
+ "Show existing product media on specific variants (for example the red photo on the red variant).": "Show existing product media on specific variants (for example the red photo on the red variant).",
"Preview the refund Shopify suggests for an order, without refunding.": "Preview the refund Shopify suggests for an order, without refunding.",
"Capture money from an authorized payment on an order.": "Capture money from an authorized payment on an order.",
"Turn a draft order into a real order.": "Turn a draft order into a real order.",
"Count abandoned checkouts, optionally filtered.": "Count abandoned checkouts, optionally filtered.",
+ "Count collections, optionally filtered.": "Count collections, optionally filtered.",
"Count the customer segments defined in the store.": "Count the customer segments defined in the store.",
"Count customers, optionally filtered.": "Count customers, optionally filtered.",
"Count draft orders, optionally filtered.": "Count draft orders, optionally filtered.",
+ "Count the store's locations, optionally filtered.": "Count the store's locations, optionally filtered.",
+ "Count products, optionally filtered.": "Count products, optionally filtered.",
+ "Create a manual collection, optionally with an initial list of products.": "Create a manual collection, optionally with an initial list of products.",
"Add a new address to a customer.": "Add a new address to a customer.",
"Create a customer with contact details, tags and optional email marketing consent.": "Create a customer with contact details, tags and optional email marketing consent.",
"Create a draft order with one or more product or custom line items.": "Create a draft order with one or more product or custom line items.",
"Record a fraud risk assessment with supporting facts on an order.": "Record a fraud risk assessment with supporting facts on an order.",
"Create a real order with one or more line items.": "Create a real order with one or more line items.",
+ "Add new options (such as Size or Color) and their values to a product.": "Add new options (such as Size or Color) and their values to a product.",
+ "Create a new product with its title, description, vendor, type, tags and status.": "Create a new product with its title, description, vendor, type, tags and status.",
+ "Add one or more variants to a product.": "Add one or more variants to a product.",
"Refund money and/or line items on an order.": "Refund money and/or line items on an order.",
+ "Create a rule-based collection that automatically includes products matching conditions.": "Create a rule-based collection that automatically includes products matching conditions.",
+ "Stop tracking an inventory item at a location.": "Stop tracking an inventory item at a location.",
+ "Permanently delete a collection. The products in it are not deleted.": "Permanently delete a collection. The products in it are not deleted.",
"Delete a saved address from a customer.": "Delete a saved address from a customer.",
"Permanently delete a customer who has no orders.": "Permanently delete a customer who has no orders.",
"Permanently delete a draft order.": "Permanently delete a draft order.",
"Permanently delete an archived or cancelled order.": "Permanently delete an archived or cancelled order.",
+ "Remove images, videos or 3D models from a product.": "Remove images, videos or 3D models from a product.",
+ "Delete one or more options from a product.": "Delete one or more options from a product.",
+ "Permanently delete one or more variants of a product.": "Permanently delete one or more variants of a product.",
+ "Permanently delete a product with all its variants and media.": "Permanently delete a product with all its variants and media.",
+ "Stop showing specific product media on specific variants.": "Stop showing specific product media on specific variants.",
+ "Create a copy of a product under a new title.": "Create a copy of a product under a new title.",
"Create a one-time account activation link for a customer.": "Create a one-time account activation link for a customer.",
"Get a customer abandonment (browse, cart or checkout) by id.": "Get a customer abandonment (browse, cart or checkout) by id.",
"Get the abandonment record of an abandoned checkout.": "Get the abandonment record of an abandoned checkout.",
+ "Get one collection by its URL handle.": "Get one collection by its URL handle.",
+ "Get one collection with its membership sources and conditions.": "Get one collection with its membership sources and conditions.",
"Get one customer with contact details, marketing state and default address.": "Get one customer with contact details, marketing state and default address.",
"Get one draft order with its line items and totals.": "Get one draft order with its line items and totals.",
"List the Admin API access scopes granted to the connected app.": "List the Admin API access scopes granted to the connected app.",
+ "Get one inventory item with its SKU, cost, tracking and shipping details.": "Get one inventory item with its SKU, cost, tracking and shipping details.",
"Check whether an asynchronous Shopify job has finished.": "Check whether an asynchronous Shopify job has finished.",
+ "Get one store location with its address and capabilities.": "Get one store location with its address and capabilities.",
"Get the fraud risk recommendation and assessments of an order.": "Get the fraud risk recommendation and assessments of an order.",
"Get one payment transaction by id.": "Get one payment transaction by id.",
"Get one order with its totals, addresses and line items.": "Get one order with its totals, addresses and line items.",
+ "Get one product with its options, variants and media.": "Get one product with its options, variants and media.",
+ "Check whether a product duplication job has finished.": "Check whether a product duplication job has finished.",
+ "Get one product image, video or 3D model by id.": "Get one product image, video or 3D model by id.",
+ "Get one product variant with its price, SKU, stock and options.": "Get one product variant with its price, SKU, stock and options.",
+ "Get one publication (sales channel or catalog) by id.": "Get one publication (sales channel or catalog) by id.",
"Get one refund by id.": "Get one refund by id.",
"Get the store name, domain, currency, timezone and plan.": "Get the store name, domain, currency, timezone and plan.",
"List checkouts that customers started but did not complete.": "List checkouts that customers started but did not complete.",
+ "List the products in a collection, one page at a time.": "List the products in a collection, one page at a time.",
"List the saved addresses of one customer.": "List the saved addresses of one customer.",
"List the orders of one customer, one page at a time.": "List the orders of one customer, one page at a time.",
"Search draft orders, one page at a time.": "Search draft orders, one page at a time.",
+ "Search inventory items by SKU or id, one page at a time.": "Search inventory items by SKU or id, one page at a time.",
+ "List stock quantities of one item across locations, or of all items at one location.": "List stock quantities of one item across locations, or of all items at one location.",
+ "List the store's locations (warehouses, shops, fulfillment services), one page at a time.": "List the store's locations (warehouses, shops, fulfillment services), one page at a time.",
"List every refund made on an order.": "List every refund made on an order.",
"List every payment transaction on an order.": "List every payment transaction on an order.",
+ "List the images, videos and 3D models of a product, one page at a time.": "List the images, videos and 3D models of a product, one page at a time.",
+ "List the variants of one product, one page at a time.": "List the variants of one product, one page at a time.",
+ "List the publications (sales channels and catalogs) products can be published to.": "List the publications (sales channels and catalogs) products can be published to.",
+ "List the sales channels installed on the store.": "List the sales channels installed on the store.",
"List money actually received or paid out across all orders.": "List money actually received or paid out across all orders.",
"Record the outstanding balance of an order as paid manually.": "Record the outstanding balance of an order as paid manually.",
+ "Publish a product or collection to one or more sales channels or catalogs.": "Publish a product or collection to one or more sales channels or catalogs.",
+ "Remove hand-picked products from a collection.": "Remove hand-picked products from a collection.",
"Remove tags from an order, draft order, customer or product.": "Remove tags from an order, draft order, customer or product.",
+ "Start moving products to new positions inside a manually sorted collection (runs in the background).": "Start moving products to new positions inside a manually sorted collection (runs in the background).",
+ "Start moving product media to new positions (runs in the background).": "Start moving product media to new positions (runs in the background).",
+ "Set the order of a product's options and, optionally, of their values.": "Set the order of a product's options and, optionally, of their values.",
+ "Move variants of a product to new positions.": "Move variants of a product to new positions.",
+ "Search collections with Shopify search syntax, one page at a time.": "Search collections with Shopify search syntax, one page at a time.",
"Search customers with Shopify search syntax, one page at a time.": "Search customers with Shopify search syntax, one page at a time.",
"Search orders with Shopify search syntax, one page at a time.": "Search orders with Shopify search syntax, one page at a time.",
+ "Search Shopify's standard product taxonomy for category ids.": "Search Shopify's standard product taxonomy for category ids.",
+ "Search products with Shopify search syntax, one page at a time.": "Search products with Shopify search syntax, one page at a time.",
"Email a customer an invitation to create their store account.": "Email a customer an invitation to create their store account.",
"Email the checkout invoice of a draft order to the customer.": "Email the checkout invoice of a draft order to the customer.",
"Make one of a customer's saved addresses the default.": "Make one of a customer's saved addresses the default.",
+ "Set stock to an absolute number at one or more locations.": "Set stock to an absolute number at one or more locations.",
+ "Create or overwrite a whole product, including all its options and variants, in one call.": "Create or overwrite a whole product, including all its options and variants, in one call.",
"Cancel an order asynchronously and get a job to poll.": "Cancel an order asynchronously and get a job to poll.",
"Reopen a closed (archived) order.": "Reopen a closed (archived) order.",
+ "Remove a product or collection from one or more sales channels or catalogs.": "Remove a product or collection from one or more sales channels or catalogs.",
+ "Change a collection's title, description, handle, sort order, image or SEO, and add or remove its rule conditions.": "Change a collection's title, description, handle, sort order, image or SEO, and add or remove its rule conditions.",
"Change fields of a saved customer address.": "Change fields of a saved customer address.",
"Change the name, email, phone, note, tags, locale or tax exemption of a customer.": "Change the name, email, phone, note, tags, locale or tax exemption of a customer.",
"Change the line items, customer, contact, tags or payment terms of a draft order.": "Change the line items, customer, contact, tags or payment terms of a draft order.",
+ "Change the SKU, unit cost, tracking, shipping, weight or customs data of an inventory item.": "Change the SKU, unit cost, tracking, shipping, weight or customs data of an inventory item.",
"Change the email, phone, note, tags or PO number of an order.": "Change the email, phone, note, tags or PO number of an order.",
+ "Change the title, description, vendor, type, status, handle, tags, category, SEO or collections of a product.": "Change the title, description, vendor, type, status, handle, tags, category, SEO or collections of a product.",
+ "Change the alt text, filename or image of an existing media file.": "Change the alt text, filename or image of an existing media file.",
+ "Rename or move a product option and add, rename or delete its values.": "Rename or move a product option and add, rename or delete its values.",
+ "Change the price, SKU, barcode, stock policy or option values of one or more variants of a product.": "Change the price, SKU, barcode, stock policy or option values of one or more variants of a product.",
"Void an uncaptured payment authorization on an order.": "Void an uncaptured payment authorization on an order.",
"Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",
"Inventory Item": "Inventory Item",
@@ -207,6 +315,15 @@
"Note": "Note",
"Image": "Image",
"Position": "Position",
+ "Inventory Item ID": "Inventory Item ID",
+ "Location ID": "Location ID",
+ "Starting Available Quantity": "Starting Available Quantity",
+ "Idempotency Key": "Idempotency Key",
+ "Product ID": "Product ID",
+ "Media": "Media",
+ "Collection ID": "Collection ID",
+ "Product IDs": "Product IDs",
+ "Source ID": "Source ID",
"Resource Type": "Resource Type",
"Resource ID": "Resource ID",
"Sender Email": "Sender Email",
@@ -217,6 +334,11 @@
"Line Items to Remove": "Line Items to Remove",
"Page Size": "Page Size",
"Cursor": "Cursor",
+ "Quantity Name": "Quantity Name",
+ "Reason": "Reason",
+ "Changes": "Changes",
+ "Reference Document URI": "Reference Document URI",
+ "Variant Media": "Variant Media",
"Line Items to Refund": "Line Items to Refund",
"Refund All Shipping": "Refund All Shipping",
"Shipping Amount": "Shipping Amount",
@@ -227,6 +349,14 @@
"Payment Gateway ID": "Payment Gateway ID",
"Source Name": "Source Name",
"Search Query": "Search Query",
+ "Description (HTML)": "Description (HTML)",
+ "Handle": "Handle",
+ "Product Sort Order": "Product Sort Order",
+ "Image URL": "Image URL",
+ "Image Alt Text": "Image Alt Text",
+ "Template Suffix": "Template Suffix",
+ "SEO Title": "SEO Title",
+ "SEO Description": "SEO Description",
"Company": "Company",
"Address Line 1": "Address Line 1",
"Address Line 2": "Address Line 2",
@@ -270,30 +400,80 @@
"Fulfilled From Location ID": "Fulfilled From Location ID",
"Tracking Numbers": "Tracking Numbers",
"Tracking Company": "Tracking Company",
+ "Options": "Options",
+ "Variant Strategy": "Variant Strategy",
+ "Category ID": "Category ID",
+ "Collection IDs": "Collection IDs",
+ "Variants": "Variants",
+ "Default Variant Handling": "Default Variant Handling",
"Refund Transactions": "Refund Transactions",
"Notify Customer": "Notify Customer",
- "Idempotency Key": "Idempotency Key",
+ "Match": "Match",
+ "Conditions": "Conditions",
"Address ID": "Address ID",
+ "Media IDs": "Media IDs",
+ "Option IDs": "Option IDs",
+ "Variant IDs": "Variant IDs",
+ "New Title": "New Title",
+ "Copy Images": "Copy Images",
+ "Copy Translations": "Copy Translations",
"Abandonment ID": "Abandonment ID",
"Abandoned Checkout ID": "Abandoned Checkout ID",
"Job ID": "Job ID",
"Transaction ID": "Transaction ID",
+ "Media ID": "Media ID",
+ "Variant ID": "Variant ID",
+ "Publication ID": "Publication ID",
"Refund ID": "Refund ID",
"Sort By": "Sort By",
"Reverse Order": "Reverse Order",
+ "Include Inactive": "Include Inactive",
+ "Include Legacy": "Include Legacy",
+ "Catalog Type": "Catalog Type",
+ "Publication IDs": "Publication IDs",
+ "Publish Date": "Publish Date",
+ "Moves": "Moves",
+ "Options in Order": "Options in Order",
+ "New Positions": "New Positions",
+ "Search": "Search",
+ "Parent Category ID": "Parent Category ID",
"Subject": "Subject",
"Custom Message": "Custom Message",
"Recipient Email": "Recipient Email",
- "Reason": "Reason",
+ "Quantities": "Quantities",
+ "Product Handle": "Product Handle",
"Restock Items": "Restock Items",
"Refund Method": "Refund Method",
"Store Credit Expiry": "Store Credit Expiry",
"Staff Note": "Staff Note",
+ "Redirect Old Handle": "Redirect Old Handle",
+ "Conditions Source ID": "Conditions Source ID",
+ "Condition IDs to Delete": "Condition IDs to Delete",
"Clear Note": "Clear Note",
"Clear Tags": "Clear Tags",
"Payment Terms Template ID": "Payment Terms Template ID",
"Payment Terms Issued At": "Payment Terms Issued At",
"Payment Due At": "Payment Due At",
+ "SKU": "SKU",
+ "Unit Cost": "Unit Cost",
+ "Track Quantity": "Track Quantity",
+ "Requires Shipping": "Requires Shipping",
+ "Country of Origin": "Country of Origin",
+ "Province of Origin": "Province of Origin",
+ "HS Code": "HS Code",
+ "Weight": "Weight",
+ "Weight Unit": "Weight Unit",
+ "Collections to Join": "Collections to Join",
+ "Collections to Leave": "Collections to Leave",
+ "Alt Text": "Alt Text",
+ "Filename": "Filename",
+ "Replacement Image URL": "Replacement Image URL",
+ "Option ID": "Option ID",
+ "New Name": "New Name",
+ "New Position": "New Position",
+ "Values to Add": "Values to Add",
+ "Values to Rename": "Values to Rename",
+ "Value IDs to Delete": "Value IDs to Delete",
"Method": "Method",
"Headers": "Headers",
"Query Parameters": "Query Parameters",
@@ -326,6 +506,15 @@
"The ID of the product variant.": "The ID of the product variant.",
"The ID of the transaction": "The ID of the transaction",
"1 makes it the main image.": "1 makes it the main image.",
+ "The inventory item id, numeric or \"gid://shopify/InventoryItem/…\" (from get_product_variant_details).": "The inventory item id, numeric or \"gid://shopify/InventoryItem/…\" (from get_product_variant_details).",
+ "The location id, numeric or \"gid://shopify/Location/…\" (from list_locations).": "The location id, numeric or \"gid://shopify/Location/…\" (from list_locations).",
+ "Optional whole-number available quantity to start with, for example 10.": "Optional whole-number available quantity to start with, for example 10.",
+ "A unique key for this operation, for example a UUID such as \"3f1c2a9e-6b1d-4c8e-9a51-2f7d0e4b8c10\". Generate your own key on the first call and pass the same key again when retrying after a timeout or error, so Shopify does not repeat the operation. If left empty a key is generated; it is returned as idempotency_key and included in any error message.": "A unique key for this operation, for example a UUID such as \"3f1c2a9e-6b1d-4c8e-9a51-2f7d0e4b8c10\". Generate your own key on the first call and pass the same key again when retrying after a timeout or error, so Shopify does not repeat the operation. If left empty a key is generated; it is returned as idempotency_key and included in any error message.",
+ "The product id, numeric or \"gid://shopify/Product/…\". Find it with search_products.": "The product id, numeric or \"gid://shopify/Product/…\". Find it with search_products.",
+ "The media to add, one entry per file.": "The media to add, one entry per file.",
+ "The collection id, numeric or \"gid://shopify/Collection/…\". Find it with search_collections.": "The collection id, numeric or \"gid://shopify/Collection/…\". Find it with search_collections.",
+ "Products to add, numeric or \"gid://shopify/Product/…\".": "Products to add, numeric or \"gid://shopify/Product/…\".",
+ "Optional conditions source to add the picks to (from get_collection sources). Must not be a shared source. Defaults to the first non-shared conditions source.": "Optional conditions source to add the picks to (from get_collection sources). Must not be a shared source. Defaults to the first non-shared conditions source.",
"What kind of record the id belongs to. Used to build the full id when a numeric id is given.": "What kind of record the id belongs to. Used to build the full id when a numeric id is given.",
"Numeric id such as \"450789469\" or a full id such as \"gid://shopify/Order/450789469\".": "Numeric id such as \"450789469\" or a full id such as \"gid://shopify/Order/450789469\".",
"Tags to add, for example [\"vip\", \"follow-up\"].": "Tags to add, for example [\"vip\", \"follow-up\"].",
@@ -339,6 +528,12 @@
"The order line items the buyer wants removed and how many units of each. Line item ids come from get_order (line_items[].id). The quantity cannot exceed the unfulfilled quantity of the line item.": "The order line items the buyer wants removed and how many units of each. Line item ids come from get_order (line_items[].id). The quantity cannot exceed the unfulfilled quantity of the line item.",
"How many records to return, 1 to 25. Defaults to 25.": "How many records to return, 1 to 25. Defaults to 25.",
"The end_cursor from the previous page. Leave empty for the first page; pass it only while has_next_page is true.": "The end_cursor from the previous page. Leave empty for the first page; pass it only while has_next_page is true.",
+ "Which quantity to adjust. Anything other than \"available\" needs a ledger document URI on each change.": "Which quantity to adjust. Anything other than \"available\" needs a ledger document URI on each change.",
+ "Why the stock changes; shown in the inventory history.": "Why the stock changes; shown in the inventory history.",
+ "One entry per inventory item and location.": "One entry per inventory item and location.",
+ "Optional URI of the document behind the change, for example \"gid://my-app/PurchaseOrder/PO-1\".": "Optional URI of the document behind the change, for example \"gid://my-app/PurchaseOrder/PO-1\".",
+ "The product id, numeric or \"gid://shopify/Product/…\".": "The product id, numeric or \"gid://shopify/Product/…\".",
+ "Which media to attach to which variant, one entry per pair.": "Which media to attach to which variant, one entry per pair.",
"Line items and quantities to refund. Line item ids come from get_order.": "Line items and quantities to refund. Line item ids come from get_order.",
"Include the full shipping cost in the suggestion. Off by default.": "Include the full shipping cost in the suggestion. Off by default.",
"Refund only this much shipping, for example 4.50. Ignored when refunding all shipping.": "Refund only this much shipping, for example 4.50. Ignored when refunding all shipping.",
@@ -352,8 +547,21 @@
"Optional manual payment gateway to record the payment against, as a full id such as \"gid://shopify/PaymentGateway/1\".": "Optional manual payment gateway to record the payment against, as a full id such as \"gid://shopify/PaymentGateway/1\".",
"Optional channel label stored on the order, for example \"phone\".": "Optional channel label stored on the order, for example \"phone\".",
"Shopify search syntax, for example \"created_at:>=2026-09-01\". Leave empty to count all.": "Shopify search syntax, for example \"created_at:>=2026-09-01\". Leave empty to count all.",
+ "Shopify collection search syntax, for example \"collection_type:custom\". Leave empty to count all.": "Shopify collection search syntax, for example \"collection_type:custom\". Leave empty to count all.",
"Filter by created_at, updated_at or id, for example \"created_at:>2026-01-01\". Leave empty to count all.": "Filter by created_at, updated_at or id, for example \"created_at:>2026-01-01\". Leave empty to count all.",
"Shopify draft order search syntax, for example \"status:open\". Leave empty to count all.": "Shopify draft order search syntax, for example \"status:open\". Leave empty to count all.",
+ "Shopify location search syntax, for example \"name:Warehouse*\". Leave empty to count all.": "Shopify location search syntax, for example \"name:Warehouse*\". Leave empty to count all.",
+ "Shopify product search syntax, for example \"status:active\" or \"tag:sale\". Leave empty to count all.": "Shopify product search syntax, for example \"status:active\" or \"tag:sale\". Leave empty to count all.",
+ "Collection title, for example \"Summer Sale\".": "Collection title, for example \"Summer Sale\".",
+ "Collection description, HTML allowed.": "Collection description, HTML allowed.",
+ "URL handle, for example \"summer-sale\". Generated from the title when empty.": "URL handle, for example \"summer-sale\". Generated from the title when empty.",
+ "Products to put in the collection, numeric or \"gid://shopify/Product/…\".": "Products to put in the collection, numeric or \"gid://shopify/Product/…\".",
+ "How products are ordered inside the collection. Manual is required before reorder_collection_products.": "How products are ordered inside the collection. Manual is required before reorder_collection_products.",
+ "Public URL of the collection image.": "Public URL of the collection image.",
+ "Accessible description of the collection image.": "Accessible description of the collection image.",
+ "Theme template suffix, for example \"sale\" for collection.sale.liquid.": "Theme template suffix, for example \"sale\" for collection.sale.liquid.",
+ "Page title for search engines.": "Page title for search engines.",
+ "Meta description for search engines.": "Meta description for search engines.",
"The customer id, numeric or \"gid://shopify/Customer/…\". Find it with search_customers.": "The customer id, numeric or \"gid://shopify/Customer/…\". Find it with search_customers.",
"First name on the address.": "First name on the address.",
"Last name on the address.": "Last name on the address.",
@@ -420,26 +628,65 @@
"Set only when importing an order that was already shipped: the location id (from list_locations) it shipped from. The order is then created fulfilled for all line items. Leave empty for an unfulfilled order.": "Set only when importing an order that was already shipped: the location id (from list_locations) it shipped from. The order is then created fulfilled for all line items. Leave empty for an unfulfilled order.",
"Tracking numbers of the imported fulfillment, one per package, for example [\"1Z999AA10123456784\", \"1Z999AA10123456785\"]. Needs fulfillment_location_id.": "Tracking numbers of the imported fulfillment, one per package, for example [\"1Z999AA10123456784\", \"1Z999AA10123456785\"]. Needs fulfillment_location_id.",
"Carrier of the tracking numbers, for example \"UPS\", \"USPS\" or \"DHL Express\". Needs fulfillment_location_id.": "Carrier of the tracking numbers, for example \"UPS\", \"USPS\" or \"DHL Express\". Needs fulfillment_location_id.",
+ "The options to add, for example Color with values \"Red, Blue\".": "The options to add, for example Color with values \"Red, Blue\".",
+ "What happens to variants. Defaults to leaving existing variants as they are.": "What happens to variants. Defaults to leaving existing variants as they are.",
+ "Product title, for example \"Organic Cotton T-Shirt\".": "Product title, for example \"Organic Cotton T-Shirt\".",
+ "Product description, HTML allowed, for example \"<p>Soft organic cotton.</p>\".": "Product description, HTML allowed, for example \"<p>Soft organic cotton.</p>\".",
+ "Brand or vendor name, for example \"Acme Apparel\".": "Brand or vendor name, for example \"Acme Apparel\".",
+ "Merchant-defined product type, for example \"T-Shirts\".": "Merchant-defined product type, for example \"T-Shirts\".",
+ "Product status. Defaults to Draft (not visible to customers).": "Product status. Defaults to Draft (not visible to customers).",
+ "URL handle, for example \"organic-cotton-t-shirt\". Generated from the title when empty.": "URL handle, for example \"organic-cotton-t-shirt\". Generated from the title when empty.",
+ "Tags to add, for example [\"summer\", \"cotton\"].": "Tags to add, for example [\"summer\", \"cotton\"].",
+ "Standard product taxonomy category id, for example \"gid://shopify/TaxonomyCategory/aa-1-13-8\". Find it with search_product_taxonomy.": "Standard product taxonomy category id, for example \"gid://shopify/TaxonomyCategory/aa-1-13-8\". Find it with search_product_taxonomy.",
+ "Collections to add the product to, numeric or \"gid://shopify/Collection/…\".": "Collections to add the product to, numeric or \"gid://shopify/Collection/…\".",
+ "The variants to create, one entry per variant. Each needs option values for every product option.": "The variants to create, one entry per variant. Each needs option values for every product option.",
+ "What happens to the placeholder variant of a product without options. Leave empty for the Shopify default.": "What happens to the placeholder variant of a product without options. Leave empty for the Shopify default.",
"The money to return, one entry per original payment. Copy parent_transaction_id, gateway and amount from calculate_refund suggested_transactions; when the order has a presentment currency different from the shop currency, copy presentment_amount instead of amount and set currency. Leave empty to refund items without returning money.": "The money to return, one entry per original payment. Copy parent_transaction_id, gateway and amount from calculate_refund suggested_transactions; when the order has a presentment currency different from the shop currency, copy presentment_amount instead of amount and set currency. Leave empty to refund items without returning money.",
"Refund the full remaining shipping cost. Off by default.": "Refund the full remaining shipping cost. Off by default.",
"Refund only this much shipping, for example 4.50, in the same currency as the transaction amounts. Ignored when refunding all shipping.": "Refund only this much shipping, for example 4.50, in the same currency as the transaction amounts. Ignored when refunding all shipping.",
"Presentment (customer) currency of the refund, for example \"EUR\" (presentment_currency_code from calculate_refund). Required when the presentment currency differs from the shop currency; then every amount given here must be the presentment amount. Leave empty when both currencies are the same.": "Presentment (customer) currency of the refund, for example \"EUR\" (presentment_currency_code from calculate_refund). Required when the presentment currency differs from the shop currency; then every amount given here must be the presentment amount. Leave empty when both currencies are the same.",
"Internal reason for the refund.": "Internal reason for the refund.",
"Email the customer a refund notification. Off by default.": "Email the customer a refund notification. Off by default.",
- "A unique key for this operation, for example a UUID such as \"3f1c2a9e-6b1d-4c8e-9a51-2f7d0e4b8c10\". Generate your own key on the first call and pass the same key again when retrying after a timeout or error, so Shopify does not repeat the operation. If left empty a key is generated; it is returned as idempotency_key and included in any error message.": "A unique key for this operation, for example a UUID such as \"3f1c2a9e-6b1d-4c8e-9a51-2f7d0e4b8c10\". Generate your own key on the first call and pass the same key again when retrying after a timeout or error, so Shopify does not repeat the operation. If left empty a key is generated; it is returned as idempotency_key and included in any error message.",
+ "Collection title, for example \"Summer Items\".": "Collection title, for example \"Summer Items\".",
+ "Whether products must match all conditions or any of them.": "Whether products must match all conditions or any of them.",
+ "The rules products must match, for example field product_tag, relation TAGGED_WITH, value \"summer\".": "The rules products must match, for example field product_tag, relation TAGGED_WITH, value \"summer\".",
+ "Shop currency code for price conditions, for example \"USD\".": "Shop currency code for price conditions, for example \"USD\".",
+ "URL handle, for example \"summer-items\". Generated from the title when empty.": "URL handle, for example \"summer-items\". Generated from the title when empty.",
+ "Theme template suffix, for example \"sale\".": "Theme template suffix, for example \"sale\".",
"The customer id, numeric or \"gid://shopify/Customer/…\".": "The customer id, numeric or \"gid://shopify/Customer/…\".",
"The address id from list_customer_addresses, for example \"gid://shopify/MailingAddress/1053318585?model_name=CustomerAddress\" or its number.": "The address id from list_customer_addresses, for example \"gid://shopify/MailingAddress/1053318585?model_name=CustomerAddress\" or its number.",
+ "The product to remove the media from, numeric or \"gid://shopify/Product/…\".": "The product to remove the media from, numeric or \"gid://shopify/Product/…\".",
+ "Ids of the media to remove, for example [\"gid://shopify/MediaImage/1072273219\"].": "Ids of the media to remove, for example [\"gid://shopify/MediaImage/1072273219\"].",
+ "Ids of the options to delete, for example [\"gid://shopify/ProductOption/1064576516\"].": "Ids of the options to delete, for example [\"gid://shopify/ProductOption/1064576516\"].",
+ "What happens to variants when the options are removed.": "What happens to variants when the options are removed.",
+ "The product the variants belong to, numeric or \"gid://shopify/Product/…\".": "The product the variants belong to, numeric or \"gid://shopify/Product/…\".",
+ "Ids of the variants to delete, numeric or \"gid://shopify/ProductVariant/…\".": "Ids of the variants to delete, numeric or \"gid://shopify/ProductVariant/…\".",
+ "Which media to detach from which variant, one entry per pair.": "Which media to detach from which variant, one entry per pair.",
+ "The product to copy, numeric or \"gid://shopify/Product/…\". Find it with search_products.": "The product to copy, numeric or \"gid://shopify/Product/…\". Find it with search_products.",
+ "Title of the copy, for example \"Organic Cotton T-Shirt (Copy)\".": "Title of the copy, for example \"Organic Cotton T-Shirt (Copy)\".",
+ "Status of the copy. Leave empty to keep the status of the original.": "Status of the copy. Leave empty to keep the status of the original.",
+ "Also copy the product images (runs in the background). Off by default.": "Also copy the product images (runs in the background). Off by default.",
+ "Also copy the product translations. Off by default.": "Also copy the product translations. Off by default.",
"The abandonment id, numeric or \"gid://shopify/Abandonment/…\".": "The abandonment id, numeric or \"gid://shopify/Abandonment/…\".",
"The abandoned checkout id, numeric or \"gid://shopify/AbandonedCheckout/…\". Find it with list_abandoned_checkouts.": "The abandoned checkout id, numeric or \"gid://shopify/AbandonedCheckout/…\". Find it with list_abandoned_checkouts.",
+ "The collection handle, for example \"summer-sale\".": "The collection handle, for example \"summer-sale\".",
"The customer id, numeric such as \"207119551\" or \"gid://shopify/Customer/207119551\". Find it with search_customers.": "The customer id, numeric such as \"207119551\" or \"gid://shopify/Customer/207119551\". Find it with search_customers.",
"The job id returned by the start action, for example \"gid://shopify/Job/dc9b2604-c73b-45c6-8942-e235bac987e8\". A bare UUID such as \"dc9b2604-c73b-45c6-8942-e235bac987e8\" is also accepted.": "The job id returned by the start action, for example \"gid://shopify/Job/dc9b2604-c73b-45c6-8942-e235bac987e8\". A bare UUID such as \"dc9b2604-c73b-45c6-8942-e235bac987e8\" is also accepted.",
+ "The location id, numeric or \"gid://shopify/Location/…\". Find it with list_locations.": "The location id, numeric or \"gid://shopify/Location/…\". Find it with list_locations.",
"The transaction id, numeric such as \"389404469\" or \"gid://shopify/OrderTransaction/389404469\". Find it with list_order_transactions.": "The transaction id, numeric such as \"389404469\" or \"gid://shopify/OrderTransaction/389404469\". Find it with list_order_transactions.",
"The order id: a numeric id such as \"450789469\" or a full id such as \"gid://shopify/Order/450789469\". Find it with search_orders.": "The order id: a numeric id such as \"450789469\" or a full id such as \"gid://shopify/Order/450789469\". Find it with search_orders.",
+ "The product id: a numeric id such as \"632910392\" or a full id such as \"gid://shopify/Product/632910392\". Find it with search_products.": "The product id: a numeric id such as \"632910392\" or a full id such as \"gid://shopify/Product/632910392\". Find it with search_products.",
+ "The product duplicate job id, either the bare id or \"gid://shopify/ProductDuplicateJob/…\".": "The product duplicate job id, either the bare id or \"gid://shopify/ProductDuplicateJob/…\".",
+ "The media id, for example \"gid://shopify/MediaImage/1072273219\". A bare number is treated as an image id. Find it with list_product_media.": "The media id, for example \"gid://shopify/MediaImage/1072273219\". A bare number is treated as an image id. Find it with list_product_media.",
+ "The variant id: numeric such as \"808950810\" or \"gid://shopify/ProductVariant/808950810\". Find it with list_product_variants.": "The variant id: numeric such as \"808950810\" or \"gid://shopify/ProductVariant/808950810\". Find it with list_product_variants.",
+ "The publication id, numeric or \"gid://shopify/Publication/…\". Find it with list_publications.": "The publication id, numeric or \"gid://shopify/Publication/…\". Find it with list_publications.",
"The refund id, numeric or \"gid://shopify/Refund/…\". Find it with list_order_refunds.": "The refund id, numeric or \"gid://shopify/Refund/…\". Find it with list_order_refunds.",
"Shopify search syntax, for example \"created_at:>=2026-09-01\" or \"status:open\". Leave empty for all.": "Shopify search syntax, for example \"created_at:>=2026-09-01\" or \"status:open\". Leave empty for all.",
"Field to sort by. Defaults to the checkout id.": "Field to sort by. Defaults to the checkout id.",
"Return results in reverse sort order (for example newest first).": "Return results in reverse sort order (for example newest first).",
"How many records to return, 1 to 100. Defaults to 50.": "How many records to return, 1 to 100. Defaults to 50.",
+ "Field to sort by. Defaults to the collection's own sort order.": "Field to sort by. Defaults to the collection's own sort order.",
+ "How many records to return, 1 to 80. Defaults to 50.": "How many records to return, 1 to 80. Defaults to 50.",
"How many records to return, 1 to 250. Defaults to 50.": "How many records to return, 1 to 250. Defaults to 50.",
"Optional order search syntax to narrow the list, for example \"financial_status:paid\" or \"created_at:>=2026-01-01\".": "Optional order search syntax to narrow the list, for example \"financial_status:paid\" or \"created_at:>=2026-01-01\".",
"Field to sort by. Defaults to the order id.": "Field to sort by. Defaults to the order id.",
@@ -447,23 +694,79 @@
"Shopify draft order search syntax, for example \"status:open\", \"status:invoice_sent\" or \"tag:quote\". Leave empty for all.": "Shopify draft order search syntax, for example \"status:open\", \"status:invoice_sent\" or \"tag:quote\". Leave empty for all.",
"Field to sort by. Defaults to the draft id.": "Field to sort by. Defaults to the draft id.",
"How many records to return, 1 to 60. Defaults to 50.": "How many records to return, 1 to 60. Defaults to 50.",
+ "Shopify inventory item search syntax, for example \"sku:TSHIRT-RED-L\". Leave empty to list all.": "Shopify inventory item search syntax, for example \"sku:TSHIRT-RED-L\". Leave empty to list all.",
+ "List this item's levels at every location, numeric or \"gid://shopify/InventoryItem/…\". Leave empty when giving a location.": "List this item's levels at every location, numeric or \"gid://shopify/InventoryItem/…\". Leave empty when giving a location.",
+ "List every item stocked at this location, numeric or \"gid://shopify/Location/…\". Leave empty when giving an item.": "List every item stocked at this location, numeric or \"gid://shopify/Location/…\". Leave empty when giving an item.",
+ "Also return levels that were deactivated. Off by default.": "Also return levels that were deactivated. Off by default.",
+ "How many records to return, 1 to 70. Defaults to 50.": "How many records to return, 1 to 70. Defaults to 50.",
+ "Shopify location search syntax, for example \"name:Warehouse*\". Leave empty to list all.": "Shopify location search syntax, for example \"name:Warehouse*\". Leave empty to list all.",
+ "Also return deactivated locations. Off by default.": "Also return deactivated locations. Off by default.",
+ "Also return legacy fulfillment-service locations. Off by default.": "Also return legacy fulfillment-service locations. Off by default.",
+ "Field to sort by. Defaults to the name.": "Field to sort by. Defaults to the name.",
+ "How many records to return, 1 to 50. Defaults to 50.": "How many records to return, 1 to 50. Defaults to 50.",
+ "Field to sort by. Defaults to position.": "Field to sort by. Defaults to position.",
+ "How many records to return, 1 to 130. Defaults to 50.": "How many records to return, 1 to 130. Defaults to 50.",
+ "Only list publications of this catalog type. Leave empty for all.": "Only list publications of this catalog type. Leave empty for all.",
"Shopify search syntax, for example \"processed_at:>=2026-09-01\" or \"test:false\". Leave empty for all.": "Shopify search syntax, for example \"processed_at:>=2026-09-01\" or \"test:false\". Leave empty for all.",
"How many records to return, 1 to 200. Defaults to 50.": "How many records to return, 1 to 200. Defaults to 50.",
+ "Whether the id is a product or a collection.": "Whether the id is a product or a collection.",
+ "The product or collection id, numeric or a full id such as \"gid://shopify/Product/632910392\".": "The product or collection id, numeric or a full id such as \"gid://shopify/Product/632910392\".",
+ "Publications to publish to, for example [\"gid://shopify/Publication/762454635\"].": "Publications to publish to, for example [\"gid://shopify/Publication/762454635\"].",
+ "Optional future date and time to publish at. Leave empty to publish now.": "Optional future date and time to publish at. Leave empty to publish now.",
+ "Products to remove, numeric or \"gid://shopify/Product/…\".": "Products to remove, numeric or \"gid://shopify/Product/…\".",
+ "Optional conditions source to remove the picks from (from get_collection sources). Must not be a shared source. Leave empty to remove from every non-shared conditions source.": "Optional conditions source to remove the picks from (from get_collection sources). Must not be a shared source. Leave empty to remove from every non-shared conditions source.",
"Tags to remove, for example [\"follow-up\"].": "Tags to remove, for example [\"follow-up\"].",
+ "The collection id, numeric or \"gid://shopify/Collection/…\".": "The collection id, numeric or \"gid://shopify/Collection/…\".",
+ "The products to move and their new zero-based positions.": "The products to move and their new zero-based positions.",
+ "The media to move and their new zero-based positions.": "The media to move and their new zero-based positions.",
+ "Every option of the product, first to last.": "Every option of the product, first to last.",
+ "The variants to move and where.": "The variants to move and where.",
+ "Shopify collection search syntax, for example \"title:Summer*\" or \"collection_type:smart\". Leave empty to list all collections.": "Shopify collection search syntax, for example \"title:Summer*\" or \"collection_type:smart\". Leave empty to list all collections.",
+ "Field to sort by. Defaults to the collection id.": "Field to sort by. Defaults to the collection id.",
"Shopify customer search syntax, for example \"email:[email protected]\", \"country:Canada\" or \"orders_count:>5\". Leave empty to list all customers.": "Shopify customer search syntax, for example \"email:[email protected]\", \"country:Canada\" or \"orders_count:>5\". Leave empty to list all customers.",
"Field to sort by. Defaults to the customer id.": "Field to sort by. Defaults to the customer id.",
- "How many records to return, 1 to 130. Defaults to 50.": "How many records to return, 1 to 130. Defaults to 50.",
"Shopify order search syntax, for example \"status:open financial_status:paid\", \"tag:wholesale\" or \"created_at:>=2026-01-01\". Leave empty to list all orders.": "Shopify order search syntax, for example \"status:open financial_status:paid\", \"tag:wholesale\" or \"created_at:>=2026-01-01\". Leave empty to list all orders.",
+ "Words to search for, for example \"t-shirts\".": "Words to search for, for example \"t-shirts\".",
+ "List the direct children of this category, for example \"aa-1\" or \"gid://shopify/TaxonomyCategory/aa-1\".": "List the direct children of this category, for example \"aa-1\" or \"gid://shopify/TaxonomyCategory/aa-1\".",
+ "Shopify product search syntax, for example \"title:*shirt*\", \"sku:TSHIRT-RED-L\", \"vendor:Nike\" or \"status:draft\". Leave empty to list all products.": "Shopify product search syntax, for example \"title:*shirt*\", \"sku:TSHIRT-RED-L\", \"vendor:Nike\" or \"status:draft\". Leave empty to list all products.",
+ "Field to sort by. Defaults to the product id.": "Field to sort by. Defaults to the product id.",
"Email subject. Leave empty for the store default.": "Email subject. Leave empty for the store default.",
"A personal message added to the invitation.": "A personal message added to the invitation.",
"Send to this address instead of the draft email, for example \"[email protected]\".": "Send to this address instead of the draft email, for example \"[email protected]\".",
"A personal message added to the invoice email.": "A personal message added to the invoice email.",
+ "Which quantity to set.": "Which quantity to set.",
+ "Optional URI of the document behind the change, for example \"gid://my-app/CycleCount/CC-1\".": "Optional URI of the document behind the change, for example \"gid://my-app/CycleCount/CC-1\".",
+ "The product to overwrite, numeric or \"gid://shopify/Product/…\". Leave empty (and no handle) to create a new product.": "The product to overwrite, numeric or \"gid://shopify/Product/…\". Leave empty (and no handle) to create a new product.",
+ "Alternative to Product ID: the handle of an existing product to overwrite, for example \"organic-cotton-t-shirt\". If no product has this handle the call fails; it never creates a product.": "Alternative to Product ID: the handle of an existing product to overwrite, for example \"organic-cotton-t-shirt\". If no product has this handle the call fails; it never creates a product.",
+ "Product title. Required when creating a new product.": "Product title. Required when creating a new product.",
+ "Product description, HTML allowed.": "Product description, HTML allowed.",
+ "Brand or vendor name.": "Brand or vendor name.",
+ "Merchant-defined product type.": "Merchant-defined product type.",
+ "Product status. On a new product defaults to Draft; on an existing product leave empty to keep it.": "Product status. On a new product defaults to Draft; on an existing product leave empty to keep it.",
+ "The complete tag list. Replaces every existing tag; leave empty to keep the current tags.": "The complete tag list. Replaces every existing tag; leave empty to keep the current tags.",
+ "Every option the product must have, in order, for example Size with values \"S, M, L\". Options not listed are removed.": "Every option the product must have, in order, for example Size with values \"S, M, L\". Options not listed are removed.",
+ "Every variant the product must have. Variants not listed are deleted.": "Every variant the product must have. Variants not listed are deleted.",
"Why the order is cancelled.": "Why the order is cancelled.",
"Return the line items to inventory. Off by default.": "Return the line items to inventory. Off by default.",
"How to refund captured payments. Leave empty to cancel without refunding captured money (authorized payments are still voided).": "How to refund captured payments. Leave empty to cancel without refunding captured money (authorized payments are still voided).",
"Only for a store credit refund: when the credit expires (ISO 8601). Leave empty for no expiry.": "Only for a store credit refund: when the credit expires (ISO 8601). Leave empty for no expiry.",
"Email the customer about the cancellation. Off by default.": "Email the customer about the cancellation. Off by default.",
"Internal note about the cancellation, not shown to the customer.": "Internal note about the cancellation, not shown to the customer.",
+ "Publications to unpublish from, for example [\"gid://shopify/Publication/762454635\"].": "Publications to unpublish from, for example [\"gid://shopify/Publication/762454635\"].",
+ "New title.": "New title.",
+ "New description, HTML allowed. Replaces the existing description.": "New description, HTML allowed. Replaces the existing description.",
+ "New URL handle.": "New URL handle.",
+ "When changing the handle, create a redirect from the old URL. Leave empty for the Shopify default.": "When changing the handle, create a redirect from the old URL. Leave empty for the Shopify default.",
+ "New theme template suffix.": "New theme template suffix.",
+ "Public URL of a new collection image.": "Public URL of a new collection image.",
+ "Alt text for the new image. Only used together with an image URL.": "Alt text for the new image. Only used together with an image URL.",
+ "New page title for search engines.": "New page title for search engines.",
+ "New meta description for search engines.": "New meta description for search engines.",
+ "The conditions source to edit (from get_collection sources). Required for the condition fields below.": "The conditions source to edit (from get_collection sources). Required for the condition fields below.",
+ "Switch the source between matching all conditions or any of them.": "Switch the source between matching all conditions or any of them.",
+ "New conditions to add to the source. Existing conditions are kept.": "New conditions to add to the source. Existing conditions are kept.",
+ "Ids of conditions to remove (from get_collection sources[].conditions).": "Ids of conditions to remove (from get_collection sources[].conditions).",
+ "Shop currency code for new price conditions, for example \"USD\".": "Shop currency code for new price conditions, for example \"USD\".",
"Yes makes this the customer's default address. Leave empty to leave the default unchanged.": "Yes makes this the customer's default address. Leave empty to leave the default unchanged.",
"New email, for example \"[email protected]\".": "New email, for example \"[email protected]\".",
"New phone in E.164 format, for example \"+16135551111\".": "New phone in E.164 format, for example \"+16135551111\".",
@@ -484,9 +787,39 @@
"Start date for net payment terms (for example net 30), ISO 8601.": "Start date for net payment terms (for example net 30), ISO 8601.",
"Due date for fixed-date payment terms, ISO 8601.": "Due date for fixed-date payment terms, ISO 8601.",
"Hold the stock for this draft until this time (ISO 8601).": "Hold the stock for this draft until this time (ISO 8601).",
+ "New SKU, for example \"TSHIRT-RED-L\".": "New SKU, for example \"TSHIRT-RED-L\".",
+ "New unit cost in the shop currency, for example 7.50.": "New unit cost in the shop currency, for example 7.50.",
+ "Whether Shopify tracks stock for this item. Leave empty to keep the current setting.": "Whether Shopify tracks stock for this item. Leave empty to keep the current setting.",
+ "Whether the item is a physical product that needs shipping. Leave empty to keep the current setting.": "Whether the item is a physical product that needs shipping. Leave empty to keep the current setting.",
+ "Two-letter ISO country code where the item was made, for example \"CN\".": "Two-letter ISO country code where the item was made, for example \"CN\".",
+ "Province or state code of origin, for example \"ON\".": "Province or state code of origin, for example \"ON\".",
+ "Harmonized System code for customs, for example \"6109.10\".": "Harmonized System code for customs, for example \"6109.10\".",
+ "Item weight, for example 0.25. Set together with the weight unit.": "Item weight, for example 0.25. Set together with the weight unit.",
+ "Unit of the weight.": "Unit of the weight.",
"New contact email, for example \"[email protected]\".": "New contact email, for example \"[email protected]\".",
"New contact phone in E.164 format, for example \"+16135551111\".": "New contact phone in E.164 format, for example \"+16135551111\".",
"The complete new tag list, for example [\"wholesale\", \"priority\"]. Replaces every existing tag; leave empty to keep the current tags (use clear_tags to remove all).": "The complete new tag list, for example [\"wholesale\", \"priority\"]. Replaces every existing tag; leave empty to keep the current tags (use clear_tags to remove all).",
+ "New product title.": "New product title.",
+ "New vendor name.": "New vendor name.",
+ "New product type.": "New product type.",
+ "New status. Leave empty to keep the current status.": "New status. Leave empty to keep the current status.",
+ "New URL handle, for example \"organic-cotton-t-shirt\".": "New URL handle, for example \"organic-cotton-t-shirt\".",
+ "The complete new tag list. Replaces every existing tag; leave empty to keep the current tags.": "The complete new tag list. Replaces every existing tag; leave empty to keep the current tags.",
+ "New taxonomy category id, for example \"gid://shopify/TaxonomyCategory/aa-1-13-8\".": "New taxonomy category id, for example \"gid://shopify/TaxonomyCategory/aa-1-13-8\".",
+ "Collection ids to add the product to, numeric or \"gid://shopify/Collection/…\".": "Collection ids to add the product to, numeric or \"gid://shopify/Collection/…\".",
+ "Collection ids to remove the product from.": "Collection ids to remove the product from.",
+ "The media id, for example \"gid://shopify/MediaImage/1072273219\". Find it with list_product_media.": "The media id, for example \"gid://shopify/MediaImage/1072273219\". Find it with list_product_media.",
+ "New accessible description, for example \"Red t-shirt, back view\".": "New accessible description, for example \"Red t-shirt, back view\".",
+ "New filename with the same extension, for example \"red-shirt-back.jpg\".": "New filename with the same extension, for example \"red-shirt-back.jpg\".",
+ "Public URL of a new image that replaces the file content, for example \"https://example.com/new.jpg\". Images only.": "Public URL of a new image that replaces the file content, for example \"https://example.com/new.jpg\". Images only.",
+ "The option id, for example \"gid://shopify/ProductOption/1064576516\". Find it with get_product_details.": "The option id, for example \"gid://shopify/ProductOption/1064576516\". Find it with get_product_details.",
+ "New option name, for example \"Colour\".": "New option name, for example \"Colour\".",
+ "New position of the option, starting at 1.": "New position of the option, starting at 1.",
+ "New values for this option, for example [\"Purple\"].": "New values for this option, for example [\"Purple\"].",
+ "Existing values to rename.": "Existing values to rename.",
+ "Ids of option values to delete.": "Ids of option values to delete.",
+ "How variants follow value changes. Leave empty for the Shopify default (leave variants as they are).": "How variants follow value changes. Leave empty for the Shopify default (leave variants as they are).",
+ "The variants to change, one entry per variant. Fields left empty keep their values.": "The variants to change, one entry per variant. Fields left empty keep their values.",
"The AUTHORIZATION transaction to void, numeric or \"gid://shopify/OrderTransaction/…\". Find it with list_order_transactions.": "The AUTHORIZATION transaction to void, numeric or \"gid://shopify/OrderTransaction/…\". Find it with list_order_transactions.",
"Authorization headers are injected automatically from your connection.": "Authorization headers are injected automatically from your connection.",
"Appended to the URL as ?key=value.": "Appended to the URL as ?key=value.",
@@ -499,8 +832,37 @@
"Archived": "Archived",
"Draft order": "Draft order",
"Subscription contract": "Subscription contract",
+ "Available": "Available",
+ "Damaged": "Damaged",
+ "Quality control": "Quality control",
+ "Reserved": "Reserved",
+ "Safety stock": "Safety stock",
+ "Incoming": "Incoming",
+ "Correction": "Correction",
+ "Cycle count": "Cycle count",
+ "Received": "Received",
+ "Restock": "Restock",
+ "Shrinkage": "Shrinkage",
+ "Promotion": "Promotion",
+ "Movement created": "Movement created",
+ "Movement updated": "Movement updated",
+ "Movement received": "Movement received",
+ "Movement canceled": "Movement canceled",
+ "Reservation created": "Reservation created",
+ "Reservation updated": "Reservation updated",
+ "Reservation deleted": "Reservation deleted",
+ "Other": "Other",
"Yes": "Yes",
"No": "No",
+ "Manual": "Manual",
+ "Best selling": "Best selling",
+ "Alphabetical A-Z": "Alphabetical A-Z",
+ "Alphabetical Z-A": "Alphabetical Z-A",
+ "Price low to high": "Price low to high",
+ "Price high to low": "Price high to low",
+ "Newest first": "Newest first",
+ "Oldest first": "Oldest first",
+ "Most relevant": "Most relevant",
"Subscribed": "Subscribed",
"Not subscribed": "Not subscribed",
"Unsubscribed": "Unsubscribed",
@@ -524,27 +886,52 @@
"Bypass (do not change stock)": "Bypass (do not change stock)",
"Decrement, obey inventory policy": "Decrement, obey inventory policy",
"Decrement, ignore inventory policy": "Decrement, ignore inventory policy",
+ "Leave variants as they are": "Leave variants as they are",
+ "Create variants for every new combination": "Create variants for every new combination",
+ "Unlisted": "Unlisted",
+ "Default": "Default",
+ "Remove the standalone placeholder variant": "Remove the standalone placeholder variant",
+ "Keep the standalone placeholder variant": "Keep the standalone placeholder variant",
+ "All conditions": "All conditions",
+ "Any condition": "Any condition",
+ "Refuse if any variant would be deleted": "Refuse if any variant would be deleted",
+ "Default (only options with a single value)": "Default (only options with a single value)",
+ "Delete duplicate variants, keep the lowest position": "Delete duplicate variants, keep the lowest position",
"Created at": "Created at",
"Checkout id": "Checkout id",
"Customer name": "Customer name",
"Total price": "Total price",
"Relevance (with a query)": "Relevance (with a query)",
"ID": "ID",
+ "Collection default": "Collection default",
+ "Created": "Created",
"Processed at": "Processed at",
"Updated at": "Updated at",
"Order number": "Order number",
"Number": "Number",
"Name": "Name",
+ "Inventory quantity": "Inventory quantity",
+ "App (sales channel)": "App (sales channel)",
+ "Market": "Market",
+ "Company location (B2B)": "Company location (B2B)",
"Financial status": "Financial status",
"Fulfillment status": "Fulfillment status",
+ "Published at": "Published at",
+ "Inventory total": "Inventory total",
+ "Product type": "Product type",
+ "On hand": "On hand",
"Customer changed or cancelled the order": "Customer changed or cancelled the order",
"Payment declined": "Payment declined",
"Fraudulent order": "Fraudulent order",
"Items unavailable": "Items unavailable",
"Staff error": "Staff error",
- "Other": "Other",
"Refund to the original payment methods": "Refund to the original payment methods",
"Refund as store credit": "Refund as store credit",
+ "Kilograms": "Kilograms",
+ "Grams": "Grams",
+ "Pounds": "Pounds",
+ "Ounces": "Ounces",
+ "Manage variants (create and delete as needed)": "Manage variants (create and delete as needed)",
"GET": "GET",
"POST": "POST",
"PATCH": "PATCH",
diff --git a/packages/pieces/community/shopify/src/index.ts b/packages/pieces/community/shopify/src/index.ts
index f091a693f7e..1633fb9e4e4 100644
--- a/packages/pieces/community/shopify/src/index.ts
+++ b/packages/pieces/community/shopify/src/index.ts
@@ -27,6 +27,9 @@ import { updateOrderAction } from './lib/actions/update-order';
import { updateProductAction } from './lib/actions/update-product';
import { uploadProductImageAction } from './lib/actions/upload-product-image';
import { shopifyAuth, shopifyAuthHelpers } from './lib/common/auth';
+import { shopifyAiActivateInventoryAtLocation } from './lib/actions/ai/activate-inventory-at-location';
+import { shopifyAiAddProductMedia } from './lib/actions/ai/add-product-media';
+import { shopifyAiAddProductsToCollection } from './lib/actions/ai/add-products-to-collection';
import { shopifyAiAddTags } from './lib/actions/ai/add-tags';
import { shopifyAiSendPaymentMethodUpdateEmail } from './lib/actions/ai/send-payment-method-update-email';
import { shopifyAiResolveRequestedOrderEdit } from './lib/actions/ai/resolve-requested-order-edit';
@@ -34,56 +37,109 @@ import { shopifyAiDeclineRequestedOrderEdit } from './lib/actions/ai/decline-req
import { shopifyAiCreateRequestedOrderEdit } from './lib/actions/ai/create-requested-order-edit';
import { shopifyAiCalculateRequestedOrderEdit } from './lib/actions/ai/calculate-requested-order-edit';
import { shopifyAiListRequestedOrderEdits } from './lib/actions/ai/list-requested-order-edits';
+import { shopifyAiAdjustInventoryQuantities } from './lib/actions/ai/adjust-inventory-quantities';
import { shopifyAiArchiveOrder } from './lib/actions/ai/archive-order';
+import { shopifyAiAttachVariantMedia } from './lib/actions/ai/attach-variant-media';
import { shopifyAiCalculateRefund } from './lib/actions/ai/calculate-refund';
import { shopifyAiCaptureOrderPayment } from './lib/actions/ai/capture-order-payment';
import { shopifyAiCompleteDraftOrder } from './lib/actions/ai/complete-draft-order';
import { shopifyAiCountAbandonedCheckouts } from './lib/actions/ai/count-abandoned-checkouts';
+import { shopifyAiCountCollections } from './lib/actions/ai/count-collections';
import { shopifyAiCountCustomerSegments } from './lib/actions/ai/count-customer-segments';
import { shopifyAiCountCustomers } from './lib/actions/ai/count-customers';
import { shopifyAiCountDraftOrders } from './lib/actions/ai/count-draft-orders';
+import { shopifyAiCountLocations } from './lib/actions/ai/count-locations';
+import { shopifyAiCountProducts } from './lib/actions/ai/count-products';
+import { shopifyAiCreateCollection } from './lib/actions/ai/create-collection';
import { shopifyAiCreateCustomerAddress } from './lib/actions/ai/create-customer-address';
import { shopifyAiCreateCustomerProfile } from './lib/actions/ai/create-customer-profile';
import { shopifyAiCreateDraftOrderWithLineItems } from './lib/actions/ai/create-draft-order-with-line-items';
import { shopifyAiCreateOrderRiskAssessment } from './lib/actions/ai/create-order-risk-assessment';
import { shopifyAiCreateOrderWithLineItems } from './lib/actions/ai/create-order-with-line-items';
+import { shopifyAiCreateProductOptions } from './lib/actions/ai/create-product-options';
+import { shopifyAiCreateProductRecord } from './lib/actions/ai/create-product-record';
+import { shopifyAiCreateProductVariants } from './lib/actions/ai/create-product-variants';
import { shopifyAiCreateRefund } from './lib/actions/ai/create-refund';
+import { shopifyAiCreateSmartCollection } from './lib/actions/ai/create-smart-collection';
+import { shopifyAiDeactivateInventoryAtLocation } from './lib/actions/ai/deactivate-inventory-at-location';
+import { shopifyAiDeleteCollection } from './lib/actions/ai/delete-collection';
import { shopifyAiDeleteCustomerAddress } from './lib/actions/ai/delete-customer-address';
import { shopifyAiDeleteCustomer } from './lib/actions/ai/delete-customer';
import { shopifyAiDeleteDraftOrder } from './lib/actions/ai/delete-draft-order';
import { shopifyAiDeleteOrder } from './lib/actions/ai/delete-order';
+import { shopifyAiDeleteProductMedia } from './lib/actions/ai/delete-product-media';
+import { shopifyAiDeleteProductOptions } from './lib/actions/ai/delete-product-options';
+import { shopifyAiDeleteProductVariants } from './lib/actions/ai/delete-product-variants';
+import { shopifyAiDeleteProduct } from './lib/actions/ai/delete-product';
+import { shopifyAiDetachVariantMedia } from './lib/actions/ai/detach-variant-media';
+import { shopifyAiDuplicateProduct } from './lib/actions/ai/duplicate-product';
import { shopifyAiGenerateCustomerActivationUrl } from './lib/actions/ai/generate-customer-activation-url';
import { shopifyAiGetAbandonment } from './lib/actions/ai/get-abandonment';
import { shopifyAiGetCheckoutAbandonment } from './lib/actions/ai/get-checkout-abandonment';
+import { shopifyAiGetCollectionByHandle } from './lib/actions/ai/get-collection-by-handle';
+import { shopifyAiGetCollection } from './lib/actions/ai/get-collection';
import { shopifyAiGetCustomerProfile } from './lib/actions/ai/get-customer-profile';
import { shopifyAiGetDraftOrder } from './lib/actions/ai/get-draft-order';
import { shopifyAiGetGrantedAccessScopes } from './lib/actions/ai/get-granted-access-scopes';
+import { shopifyAiGetInventoryItem } from './lib/actions/ai/get-inventory-item';
import { shopifyAiGetJob } from './lib/actions/ai/get-job';
+import { shopifyAiGetLocation } from './lib/actions/ai/get-location';
import { shopifyAiGetOrderRiskAssessments } from './lib/actions/ai/get-order-risk-assessments';
import { shopifyAiGetOrderTransaction } from './lib/actions/ai/get-order-transaction';
import { shopifyAiGetOrder } from './lib/actions/ai/get-order';
+import { shopifyAiGetProductDetails } from './lib/actions/ai/get-product-details';
+import { shopifyAiGetProductDuplicateJob } from './lib/actions/ai/get-product-duplicate-job';
+import { shopifyAiGetProductMedia } from './lib/actions/ai/get-product-media';
+import { shopifyAiGetProductVariantDetails } from './lib/actions/ai/get-product-variant-details';
+import { shopifyAiGetPublication } from './lib/actions/ai/get-publication';
import { shopifyAiGetRefund } from './lib/actions/ai/get-refund';
import { shopifyAiGetShop } from './lib/actions/ai/get-shop';
import { shopifyAiListAbandonedCheckouts } from './lib/actions/ai/list-abandoned-checkouts';
+import { shopifyAiListCollectionProducts } from './lib/actions/ai/list-collection-products';
import { shopifyAiListCustomerAddresses } from './lib/actions/ai/list-customer-addresses';
import { shopifyAiListCustomerOrders } from './lib/actions/ai/list-customer-orders';
import { shopifyAiListDraftOrders } from './lib/actions/ai/list-draft-orders';
+import { shopifyAiListInventoryItems } from './lib/actions/ai/list-inventory-items';
+import { shopifyAiListInventoryLevels } from './lib/actions/ai/list-inventory-levels';
+import { shopifyAiListLocations } from './lib/actions/ai/list-locations';
import { shopifyAiListOrderRefunds } from './lib/actions/ai/list-order-refunds';
import { shopifyAiListOrderTransactions } from './lib/actions/ai/list-order-transactions';
+import { shopifyAiListProductMedia } from './lib/actions/ai/list-product-media';
+import { shopifyAiListProductVariants } from './lib/actions/ai/list-product-variants';
+import { shopifyAiListPublications } from './lib/actions/ai/list-publications';
+import { shopifyAiListSalesChannels } from './lib/actions/ai/list-sales-channels';
import { shopifyAiListTenderTransactions } from './lib/actions/ai/list-tender-transactions';
import { shopifyAiMarkOrderAsPaid } from './lib/actions/ai/mark-order-as-paid';
+import { shopifyAiPublishResource } from './lib/actions/ai/publish-resource';
+import { shopifyAiRemoveProductsFromCollection } from './lib/actions/ai/remove-products-from-collection';
import { shopifyAiRemoveTags } from './lib/actions/ai/remove-tags';
+import { shopifyAiReorderCollectionProducts } from './lib/actions/ai/reorder-collection-products';
+import { shopifyAiReorderProductMedia } from './lib/actions/ai/reorder-product-media';
+import { shopifyAiReorderProductOptions } from './lib/actions/ai/reorder-product-options';
+import { shopifyAiReorderProductVariants } from './lib/actions/ai/reorder-product-variants';
+import { shopifyAiSearchCollections } from './lib/actions/ai/search-collections';
import { shopifyAiSearchCustomers } from './lib/actions/ai/search-customers';
import { shopifyAiSearchOrders } from './lib/actions/ai/search-orders';
+import { shopifyAiSearchProductTaxonomy } from './lib/actions/ai/search-product-taxonomy';
+import { shopifyAiSearchProducts } from './lib/actions/ai/search-products';
import { shopifyAiSendCustomerAccountInvite } from './lib/actions/ai/send-customer-account-invite';
import { shopifyAiSendDraftOrderInvoice } from './lib/actions/ai/send-draft-order-invoice';
import { shopifyAiSetDefaultCustomerAddress } from './lib/actions/ai/set-default-customer-address';
+import { shopifyAiSetInventoryQuantities } from './lib/actions/ai/set-inventory-quantities';
+import { shopifyAiSetProduct } from './lib/actions/ai/set-product';
import { shopifyAiStartOrderCancellation } from './lib/actions/ai/start-order-cancellation';
import { shopifyAiUnarchiveOrder } from './lib/actions/ai/unarchive-order';
+import { shopifyAiUnpublishResource } from './lib/actions/ai/unpublish-resource';
+import { shopifyAiUpdateCollection } from './lib/actions/ai/update-collection';
import { shopifyAiUpdateCustomerAddress } from './lib/actions/ai/update-customer-address';
import { shopifyAiUpdateCustomerProfile } from './lib/actions/ai/update-customer-profile';
import { shopifyAiUpdateDraftOrder } from './lib/actions/ai/update-draft-order';
+import { shopifyAiUpdateInventoryItem } from './lib/actions/ai/update-inventory-item';
import { shopifyAiUpdateOrderDetails } from './lib/actions/ai/update-order-details';
+import { shopifyAiUpdateProductFields } from './lib/actions/ai/update-product-fields';
+import { shopifyAiUpdateProductMedia } from './lib/actions/ai/update-product-media';
+import { shopifyAiUpdateProductOption } from './lib/actions/ai/update-product-option';
+import { shopifyAiUpdateProductVariants } from './lib/actions/ai/update-product-variants';
import { shopifyAiVoidOrderTransaction } from './lib/actions/ai/void-order-transaction';
import { newAbandonedCheckout } from './lib/triggers/new-abandoned-checkout';
import { newCancelledOrder } from './lib/triggers/new-cancelled-order';
@@ -129,6 +185,9 @@ export const shopify = createPiece({
updateOrderAction,
updateProductAction,
uploadProductImageAction,
+ shopifyAiActivateInventoryAtLocation,
+ shopifyAiAddProductMedia,
+ shopifyAiAddProductsToCollection,
shopifyAiAddTags,
shopifyAiSendPaymentMethodUpdateEmail,
shopifyAiResolveRequestedOrderEdit,
@@ -136,56 +195,109 @@ export const shopify = createPiece({
shopifyAiCreateRequestedOrderEdit,
shopifyAiCalculateRequestedOrderEdit,
shopifyAiListRequestedOrderEdits,
+ shopifyAiAdjustInventoryQuantities,
shopifyAiArchiveOrder,
+ shopifyAiAttachVariantMedia,
shopifyAiCalculateRefund,
shopifyAiCaptureOrderPayment,
shopifyAiCompleteDraftOrder,
shopifyAiCountAbandonedCheckouts,
+ shopifyAiCountCollections,
shopifyAiCountCustomerSegments,
shopifyAiCountCustomers,
shopifyAiCountDraftOrders,
+ shopifyAiCountLocations,
+ shopifyAiCountProducts,
+ shopifyAiCreateCollection,
shopifyAiCreateCustomerAddress,
shopifyAiCreateCustomerProfile,
shopifyAiCreateDraftOrderWithLineItems,
shopifyAiCreateOrderRiskAssessment,
shopifyAiCreateOrderWithLineItems,
+ shopifyAiCreateProductOptions,
+ shopifyAiCreateProductRecord,
+ shopifyAiCreateProductVariants,
shopifyAiCreateRefund,
+ shopifyAiCreateSmartCollection,
+ shopifyAiDeactivateInventoryAtLocation,
+ shopifyAiDeleteCollection,
shopifyAiDeleteCustomerAddress,
shopifyAiDeleteCustomer,
shopifyAiDeleteDraftOrder,
shopifyAiDeleteOrder,
+ shopifyAiDeleteProductMedia,
+ shopifyAiDeleteProductOptions,
+ shopifyAiDeleteProductVariants,
+ shopifyAiDeleteProduct,
+ shopifyAiDetachVariantMedia,
+ shopifyAiDuplicateProduct,
shopifyAiGenerateCustomerActivationUrl,
shopifyAiGetAbandonment,
shopifyAiGetCheckoutAbandonment,
+ shopifyAiGetCollectionByHandle,
+ shopifyAiGetCollection,
shopifyAiGetCustomerProfile,
shopifyAiGetDraftOrder,
shopifyAiGetGrantedAccessScopes,
+ shopifyAiGetInventoryItem,
shopifyAiGetJob,
+ shopifyAiGetLocation,
shopifyAiGetOrderRiskAssessments,
shopifyAiGetOrderTransaction,
shopifyAiGetOrder,
+ shopifyAiGetProductDetails,
+ shopifyAiGetProductDuplicateJob,
+ shopifyAiGetProductMedia,
+ shopifyAiGetProductVariantDetails,
+ shopifyAiGetPublication,
shopifyAiGetRefund,
shopifyAiGetShop,
shopifyAiListAbandonedCheckouts,
+ shopifyAiListCollectionProducts,
shopifyAiListCustomerAddresses,
shopifyAiListCustomerOrders,
shopifyAiListDraftOrders,
+ shopifyAiListInventoryItems,
+ shopifyAiListInventoryLevels,
+ shopifyAiListLocations,
shopifyAiListOrderRefunds,
shopifyAiListOrderTransactions,
+ shopifyAiListProductMedia,
+ shopifyAiListProductVariants,
+ shopifyAiListPublications,
+ shopifyAiListSalesChannels,
shopifyAiListTenderTransactions,
shopifyAiMarkOrderAsPaid,
+ shopifyAiPublishResource,
+ shopifyAiRemoveProductsFromCollection,
shopifyAiRemoveTags,
+ shopifyAiReorderCollectionProducts,
+ shopifyAiReorderProductMedia,
+ shopifyAiReorderProductOptions,
+ shopifyAiReorderProductVariants,
+ shopifyAiSearchCollections,
shopifyAiSearchCustomers,
shopifyAiSearchOrders,
+ shopifyAiSearchProductTaxonomy,
+ shopifyAiSearchProducts,
shopifyAiSendCustomerAccountInvite,
shopifyAiSendDraftOrderInvoice,
shopifyAiSetDefaultCustomerAddress,
+ shopifyAiSetInventoryQuantities,
+ shopifyAiSetProduct,
shopifyAiStartOrderCancellation,
shopifyAiUnarchiveOrder,
+ shopifyAiUnpublishResource,
+ shopifyAiUpdateCollection,
shopifyAiUpdateCustomerAddress,
shopifyAiUpdateCustomerProfile,
shopifyAiUpdateDraftOrder,
+ shopifyAiUpdateInventoryItem,
shopifyAiUpdateOrderDetails,
+ shopifyAiUpdateProductFields,
+ shopifyAiUpdateProductMedia,
+ shopifyAiUpdateProductOption,
+ shopifyAiUpdateProductVariants,
shopifyAiVoidOrderTransaction,
createCustomApiCallAction({
baseUrl: (auth) => {
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/activate-inventory-at-location.ts b/packages/pieces/community/shopify/src/lib/actions/ai/activate-inventory-at-location.ts
new file mode 100644
index 00000000000..80a253adfe5
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/activate-inventory-at-location.ts
@@ -0,0 +1,72 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlInventoryLevel,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { activateInventoryAtLocationOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiActivateInventoryAtLocation = createAction({
+ auth: shopifyAuth,
+ name: 'activate_inventory_at_location',
+ classification: 'WRITE',
+ displayName: 'Stock Item at Location',
+ description: 'Start tracking an inventory item at a location, optionally with a starting quantity.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Starts stocking one inventory item at one location (creates its inventory level there), optionally with a starting available quantity. Activating an item that is already stocked there leaves it stocked. Generate your own idempotency_key (for example a UUID) on the first call and pass the same key on every retry; the key used is returned and is included in any error message. Undo with deactivate_inventory_at_location.',
+ idempotent: true,
+ },
+ outputSchema: activateInventoryAtLocationOutputSchema,
+ props: {
+ inventory_item_id: Property.ShortText({
+ displayName: 'Inventory Item ID',
+ description: 'The inventory item id, numeric or "gid://shopify/InventoryItem/…" (from get_product_variant_details).',
+ required: true,
+ }),
+ location_id: Property.ShortText({
+ displayName: 'Location ID',
+ description: 'The location id, numeric or "gid://shopify/Location/…" (from list_locations).',
+ required: true,
+ }),
+ available: Property.Number({
+ displayName: 'Starting Available Quantity',
+ description: 'Optional whole-number available quantity to start with, for example 10.',
+ required: false,
+ }),
+ idempotency_key: shopifyProps.idempotencyKey(),
+ },
+ async run({ auth, propsValue }) {
+ const available = shopifyValues.readNumber(propsValue.available);
+ if (available !== undefined && !Number.isInteger(available)) {
+ throw new Error('available must be a whole number.');
+ }
+ const idempotencyKey = shopifyGraphqlClient.resolveIdempotencyKey(propsValue.idempotency_key);
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ inventoryActivate: { inventoryLevel: GqlInventoryLevel | null } | null;
+ }>({
+ auth,
+ query: `mutation ActivateInventoryAtLocation($inventoryItemId: ID!, $locationId: ID!, $available: Int, $idempotencyKey: String!) { inventoryActivate(inventoryItemId: $inventoryItemId, locationId: $locationId, available: $available) @idempotent(key: $idempotencyKey) { inventoryLevel { ${shopifyFields.INVENTORY_LEVEL_FIELDS} } userErrors { field message } } }`,
+ variables: {
+ inventoryItemId: shopifyGraphqlClient.toGid({ type: 'InventoryItem', id: propsValue.inventory_item_id }),
+ locationId: shopifyGraphqlClient.toGid({ type: 'Location', id: propsValue.location_id }),
+ available,
+ },
+ idempotencyKey,
+ });
+ const level = data.inventoryActivate?.inventoryLevel;
+ if (!level) {
+ throw new Error('Shopify did not return the inventory level.');
+ }
+ return {
+ ...shopifyMappers.mapInventoryLevel(level),
+ idempotency_key: idempotencyKey,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/add-product-media.ts b/packages/pieces/community/shopify/src/lib/actions/ai/add-product-media.ts
new file mode 100644
index 00000000000..872121e998e
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/add-product-media.ts
@@ -0,0 +1,107 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlConnection,
+ GqlMedia,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyValues,
+} from '../../common/graphql';
+import { addProductMediaOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiAddProductMedia = createAction({
+ auth: shopifyAuth,
+ name: 'add_product_media',
+ classification: 'WRITE',
+ displayName: 'Add Product Media',
+ description: 'Add images, videos or 3D models to a product from public URLs.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Adds media to a product from publicly reachable URLs (images, videos, YouTube or Vimeo links, 3D models). New media is appended after the existing media and is processed in the background: status starts as UPLOADED or PROCESSING and becomes READY later (check with list_product_media). Returns the newly added media items (the last ones by position, one per URL sent) with their new ids, however many media the product already had. Each call adds new copies, so retries create duplicates.',
+ idempotent: false,
+ },
+ outputSchema: addProductMediaOutputSchema,
+ props: {
+ product_id: Property.ShortText({
+ displayName: 'Product ID',
+ description: 'The product id, numeric or "gid://shopify/Product/…". Find it with search_products.',
+ required: true,
+ }),
+ media: Property.Array({
+ displayName: 'Media',
+ description: 'The media to add, one entry per file.',
+ required: true,
+ properties: {
+ url: Property.ShortText({
+ displayName: 'URL',
+ description: 'Public URL of the file, for example "https://example.com/shirt-front.jpg" or a YouTube link.',
+ required: true,
+ }),
+ alt: Property.ShortText({
+ displayName: 'Alt Text',
+ description: 'Accessible description, for example "Red t-shirt, front view".',
+ required: false,
+ }),
+ media_type: Property.StaticDropdown({
+ displayName: 'Media Type',
+ description: 'Kind of file. Defaults to image.',
+ required: false,
+ options: {
+ options: [
+ { label: 'Image', value: 'IMAGE' },
+ { label: 'Video file', value: 'VIDEO' },
+ { label: 'External video (YouTube, Vimeo)', value: 'EXTERNAL_VIDEO' },
+ { label: '3D model', value: 'MODEL_3D' },
+ ],
+ },
+ }),
+ },
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'Product', id: propsValue.product_id });
+ const media = shopifyValues.readRecords(propsValue.media).map((item) => {
+ const url = shopifyValues.readText(item['url']);
+ if (!url) {
+ throw new Error('Every media entry needs a url.');
+ }
+ return shopifyValues.compact({
+ originalSource: url,
+ alt: shopifyValues.readText(item['alt']),
+ mediaContentType: shopifyValues.readText(item['media_type']) ?? 'IMAGE',
+ });
+ });
+ if (media.length === 0) {
+ throw new Error('Provide at least one media URL.');
+ }
+ const before = await shopifyGraphqlClient.request<{
+ product: { media: { nodes: { id: string }[] } } | null;
+ }>({
+ auth,
+ query: `query ReadProductMediaIds($id: ID!) { product(id: $id) { media(first: 250) { nodes { id } } } }`,
+ variables: { id },
+ });
+ if (!before.data.product) {
+ throw new Error(`Product ${id} was not found. Nothing was added.`);
+ }
+ const existingIds = new Set(before.data.product.media.nodes.map((node) => node.id));
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ productUpdate: { product: { id: string; media: GqlConnection<GqlMedia> } | null } | null;
+ }>({
+ auth,
+ query: `mutation AddProductMedia($product: ProductUpdateInput!, $media: [CreateMediaInput!]) { productUpdate(product: $product, media: $media) { product { id media(first: 250, sortKey: POSITION) { nodes { ${shopifyFields.MEDIA_FIELDS} } } } userErrors { field message } } }`,
+ variables: { product: { id }, media },
+ });
+ const items = (data.productUpdate?.product?.media?.nodes ?? [])
+ .filter((node) => node.id !== undefined && node.id !== null && !existingIds.has(node.id))
+ .map(shopifyMappers.mapMedia);
+ return {
+ product_id: data.productUpdate?.product?.id ?? id,
+ media: items,
+ count: items.length,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/add-products-to-collection.ts b/packages/pieces/community/shopify/src/lib/actions/ai/add-products-to-collection.ts
new file mode 100644
index 00000000000..1b254873c1b
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/add-products-to-collection.ts
@@ -0,0 +1,95 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlCollection,
+ GqlJob,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyValues,
+} from '../../common/graphql';
+import { addProductsToCollectionOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiAddProductsToCollection = createAction({
+ auth: shopifyAuth,
+ name: 'add_products_to_collection',
+ classification: 'WRITE',
+ displayName: 'Add Products to Collection',
+ description: 'Add products to a collection by hand.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Adds products to one collection as manual picks. Reads the collection\'s sources first, then adds the products to its first non-shared conditions source (or to source_id when given); a collection without one gets a new manual-selection source. Shared conditions sources (shareable=true in get_collection, reused by other collections) are never changed: they are skipped when choosing the default, and a shared source_id is refused. Works on manual and rule-based collections alike. Large changes may finish in the background (job_id, poll get_job). Adding a product that is already picked leaves it in the collection. Not available on Starter or Retail plans.',
+ idempotent: true,
+ },
+ outputSchema: addProductsToCollectionOutputSchema,
+ props: {
+ collection_id: Property.ShortText({
+ displayName: 'Collection ID',
+ description: 'The collection id, numeric or "gid://shopify/Collection/…". Find it with search_collections.',
+ required: true,
+ }),
+ product_ids: Property.Array({
+ displayName: 'Product IDs',
+ description: 'Products to add, numeric or "gid://shopify/Product/…".',
+ required: true,
+ }),
+ source_id: Property.ShortText({
+ displayName: 'Source ID',
+ description: 'Optional conditions source to add the picks to (from get_collection sources). Must not be a shared source. Defaults to the first non-shared conditions source.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'Collection', id: propsValue.collection_id });
+ const productIds = shopifyValues.toGidList({ type: 'Product', value: propsValue.product_ids });
+ if (!productIds) {
+ throw new Error('Provide at least one product id to add.');
+ }
+ const lookup = await shopifyGraphqlClient.request<{ collection: GqlCollection | null }>({
+ auth,
+ query: `query AddProductsToCollectionSources($id: ID!) { collection(id: $id) { ${shopifyFields.COLLECTION_SOURCE_LOOKUP_FIELDS} } }`,
+ variables: { id },
+ });
+ if (!lookup.data.collection) {
+ throw new Error(`Collection ${id} was not found.`);
+ }
+ const source = shopifyValues.findConditionsSource({
+ collection: lookup.data.collection,
+ sourceId: shopifyValues.nonEmpty(propsValue.source_id),
+ });
+ const selections = productIds.map((productId) => ({ productId }));
+ const change = source
+ ? { sourcesToUpdate: [{ condition: { id: source.id, inclusion: { selectionsToAdd: selections } } }] }
+ : {
+ sourcesToCreate: [
+ {
+ source: {
+ title: shopifyFields.MANUAL_SELECTION_SOURCE_TITLE,
+ inclusion: { selections },
+ },
+ },
+ ],
+ };
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ collectionUpdate: { collection: GqlCollection | null; job: GqlJob | null } | null;
+ }>({
+ auth,
+ query: `mutation AddProductsToCollection($collection: CollectionUpdateInput!) { collectionUpdate(collection: $collection) { collection { ${shopifyFields.COLLECTION_FIELDS} } job { id done } userErrors { field message } } }`,
+ variables: { collection: { id, ...change } },
+ });
+ const collection = data.collectionUpdate?.collection;
+ if (!collection) {
+ throw new Error(`Collection ${id} was not returned by Shopify.`);
+ }
+ return {
+ ...shopifyMappers.mapCollection(collection),
+ added_product_ids: productIds,
+ source_id_used: source?.id ?? null,
+ created_source: source === undefined,
+ job_id: data.collectionUpdate?.job?.id ?? null,
+ job_done: data.collectionUpdate?.job?.done ?? null,
+ redacted_fields: [...lookup.redactedFields, ...redactedFields],
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/adjust-inventory-quantities.ts b/packages/pieces/community/shopify/src/lib/actions/ai/adjust-inventory-quantities.ts
new file mode 100644
index 00000000000..79293204470
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/adjust-inventory-quantities.ts
@@ -0,0 +1,160 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlInventoryAdjustmentGroup,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { inventoryChangeOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiAdjustInventoryQuantities = createAction({
+ auth: shopifyAuth,
+ name: 'adjust_inventory_quantities',
+ classification: 'WRITE',
+ displayName: 'Adjust Inventory Quantities',
+ description: 'Increase or decrease stock by a relative amount at one or more locations.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Changes stock relatively: adds or subtracts a delta (for example -2 or +10) for inventory items at locations, all in one batch under one reason. Every item must already be stocked at its location (see list_inventory_levels); otherwise nothing is changed and you should call activate_inventory_at_location first. Use set_inventory_quantities to set an absolute number instead. Optional expected_quantity per change is a safety check: if the current quantity differs, the whole call fails with CHANGE_FROM_QUANTITY_STALE. Adjusting any quantity name other than "available" needs a ledger_document_uri on every change (a non-Shopify URI such as "gid://my-app/StockMovement/SM-1"). Generate your own idempotency_key (for example a UUID) on the first call and pass the same key on every retry so the delta is not applied twice; the key used is returned and is included in any error message. Inventory item ids come from get_product_variant_details or list_inventory_items, location ids from list_locations.',
+ idempotent: false,
+ },
+ outputSchema: inventoryChangeOutputSchema,
+ props: {
+ name: Property.StaticDropdown({
+ displayName: 'Quantity Name',
+ description: 'Which quantity to adjust. Anything other than "available" needs a ledger document URI on each change.',
+ required: true,
+ options: {
+ options: [
+ { label: 'Available', value: 'available' },
+ { label: 'Damaged', value: 'damaged' },
+ { label: 'Quality control', value: 'quality_control' },
+ { label: 'Reserved', value: 'reserved' },
+ { label: 'Safety stock', value: 'safety_stock' },
+ { label: 'Incoming', value: 'incoming' },
+ ],
+ },
+ }),
+ reason: Property.StaticDropdown({
+ displayName: 'Reason',
+ description: 'Why the stock changes; shown in the inventory history.',
+ required: true,
+ options: {
+ options: [
+ { label: 'Correction', value: 'correction' },
+ { label: 'Cycle count', value: 'cycle_count_available' },
+ { label: 'Damaged', value: 'damaged' },
+ { label: 'Received', value: 'received' },
+ { label: 'Restock', value: 'restock' },
+ { label: 'Shrinkage', value: 'shrinkage' },
+ { label: 'Promotion', value: 'promotion' },
+ { label: 'Quality control', value: 'quality_control' },
+ { label: 'Safety stock', value: 'safety_stock' },
+ { label: 'Movement created', value: 'movement_created' },
+ { label: 'Movement updated', value: 'movement_updated' },
+ { label: 'Movement received', value: 'movement_received' },
+ { label: 'Movement canceled', value: 'movement_canceled' },
+ { label: 'Reservation created', value: 'reservation_created' },
+ { label: 'Reservation updated', value: 'reservation_updated' },
+ { label: 'Reservation deleted', value: 'reservation_deleted' },
+ { label: 'Other', value: 'other' },
+ ],
+ },
+ }),
+ changes: Property.Array({
+ displayName: 'Changes',
+ description: 'One entry per inventory item and location.',
+ required: true,
+ properties: {
+ inventory_item_id: Property.ShortText({
+ displayName: 'Inventory Item ID',
+ description: 'The inventory item id, numeric or "gid://shopify/InventoryItem/…" (from get_product_variant_details).',
+ required: true,
+ }),
+ location_id: Property.ShortText({
+ displayName: 'Location ID',
+ description: 'The location id, numeric or "gid://shopify/Location/…" (from list_locations).',
+ required: true,
+ }),
+ delta: Property.Number({
+ displayName: 'Delta',
+ description: 'Whole number to add (positive) or subtract (negative), for example -2.',
+ required: true,
+ }),
+ expected_quantity: Property.Number({
+ displayName: 'Expected Current Quantity',
+ description: 'Optional safety check: the quantity you expect right now. The call fails if stock moved in the meantime.',
+ required: false,
+ }),
+ ledger_document_uri: Property.ShortText({
+ displayName: 'Ledger Document URI',
+ description: 'Required for quantity names other than "available": a non-Shopify URI, for example "gid://my-app/StockMovement/SM-1".',
+ required: false,
+ }),
+ },
+ }),
+ reference_document_uri: Property.ShortText({
+ displayName: 'Reference Document URI',
+ description: 'Optional URI of the document behind the change, for example "gid://my-app/PurchaseOrder/PO-1".',
+ required: false,
+ }),
+ idempotency_key: shopifyProps.idempotencyKey(),
+ },
+ async run({ auth, propsValue }) {
+ const name = propsValue.name;
+ const changes = shopifyValues.readRecords(propsValue.changes).map((change) => {
+ const inventoryItemId = shopifyValues.readText(change['inventory_item_id']);
+ const locationId = shopifyValues.readText(change['location_id']);
+ const delta = shopifyValues.readNumber(change['delta']);
+ if (!inventoryItemId || !locationId || delta === undefined || !Number.isInteger(delta)) {
+ throw new Error('Every change needs an inventory_item_id, a location_id and a whole-number delta.');
+ }
+ const expected = shopifyValues.readNumber(change['expected_quantity']);
+ if (expected !== undefined && !Number.isInteger(expected)) {
+ throw new Error('expected_quantity must be a whole number.');
+ }
+ const ledgerDocumentUri = shopifyValues.readText(change['ledger_document_uri']);
+ if (name !== 'available' && !ledgerDocumentUri) {
+ throw new Error(`Adjusting "${name}" needs a ledger_document_uri on every change, for example "gid://my-app/StockMovement/SM-1".`);
+ }
+ if (ledgerDocumentUri && ledgerDocumentUri.startsWith('gid://shopify/')) {
+ throw new Error('ledger_document_uri must not be a Shopify id (gid://shopify/…); use your own system\'s URI.');
+ }
+ return {
+ inventoryItemId: shopifyGraphqlClient.toGid({ type: 'InventoryItem', id: inventoryItemId }),
+ locationId: shopifyGraphqlClient.toGid({ type: 'Location', id: locationId }),
+ delta,
+ changeFromQuantity: expected ?? null,
+ ...(ledgerDocumentUri ? { ledgerDocumentUri } : {}),
+ };
+ });
+ if (changes.length === 0) {
+ throw new Error('Provide at least one change.');
+ }
+ await shopifyGraphqlClient.assertStockedAtLocations({ auth, pairs: changes });
+ const idempotencyKey = shopifyGraphqlClient.resolveIdempotencyKey(propsValue.idempotency_key);
+ const input = shopifyValues.compact({
+ name,
+ reason: propsValue.reason,
+ referenceDocumentUri: shopifyValues.nonEmpty(propsValue.reference_document_uri),
+ changes,
+ });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ inventoryAdjustQuantities: { inventoryAdjustmentGroup: GqlInventoryAdjustmentGroup | null } | null;
+ }>({
+ auth,
+ query: `mutation AdjustInventoryQuantities($input: InventoryAdjustQuantitiesInput!, $idempotencyKey: String!) { inventoryAdjustQuantities(input: $input) @idempotent(key: $idempotencyKey) { inventoryAdjustmentGroup { ${shopifyFields.INVENTORY_ADJUSTMENT_GROUP_FIELDS} } userErrors { field message code } } }`,
+ variables: { input },
+ idempotencyKey,
+ });
+ return {
+ ...shopifyMappers.mapAdjustmentGroup(data.inventoryAdjustQuantities?.inventoryAdjustmentGroup),
+ idempotency_key: idempotencyKey,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/attach-variant-media.ts b/packages/pieces/community/shopify/src/lib/actions/ai/attach-variant-media.ts
new file mode 100644
index 00000000000..7cbdec57c73
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/attach-variant-media.ts
@@ -0,0 +1,63 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import { GqlVariant, shopifyGraphqlClient, shopifyValues } from '../../common/graphql';
+import { variantMediaOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiAttachVariantMedia = createAction({
+ auth: shopifyAuth,
+ name: 'attach_variant_media',
+ classification: 'WRITE',
+ displayName: 'Attach Media to Variants',
+ description: 'Show existing product media on specific variants (for example the red photo on the red variant).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Attaches media that already belongs to the product to one or more of its variants, so the storefront shows it when that variant is chosen. The media must first be added to the product (add_product_media) and be READY. Media ids come from list_product_media, variant ids from list_product_variants. Attaching the same media again leaves it attached.',
+ idempotent: true,
+ },
+ outputSchema: variantMediaOutputSchema,
+ props: {
+ product_id: Property.ShortText({
+ displayName: 'Product ID',
+ description: 'The product id, numeric or "gid://shopify/Product/…".',
+ required: true,
+ }),
+ variant_media: Property.Array({
+ displayName: 'Variant Media',
+ description: 'Which media to attach to which variant, one entry per pair.',
+ required: true,
+ properties: {
+ variant_id: Property.ShortText({
+ displayName: 'Variant ID',
+ description: 'The variant id, numeric or "gid://shopify/ProductVariant/…".',
+ required: true,
+ }),
+ media_id: Property.ShortText({
+ displayName: 'Media ID',
+ description: 'The media id, for example "gid://shopify/MediaImage/1072273219".',
+ required: true,
+ }),
+ },
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const productId = shopifyGraphqlClient.toGid({ type: 'Product', id: propsValue.product_id });
+ const variantMedia = shopifyValues.groupVariantMedia(propsValue.variant_media);
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ productVariantAppendMedia: { productVariants: GqlVariant[] | null } | null;
+ }>({
+ auth,
+ query: `mutation AttachVariantMedia($productId: ID!, $variantMedia: [ProductVariantAppendMediaInput!]!) { productVariantAppendMedia(productId: $productId, variantMedia: $variantMedia) { productVariants { id title media(first: 10) { nodes { id } } } userErrors { field message code } } }`,
+ variables: { productId, variantMedia },
+ });
+ return {
+ product_id: productId,
+ variants: (data.productVariantAppendMedia?.productVariants ?? []).map((variant) => ({
+ id: variant.id,
+ title: variant.title ?? null,
+ media_ids: (variant.media?.nodes ?? []).map((media) => media.id ?? null),
+ })),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/count-collections.ts b/packages/pieces/community/shopify/src/lib/actions/ai/count-collections.ts
new file mode 100644
index 00000000000..804e5b8a7aa
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/count-collections.ts
@@ -0,0 +1,43 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlCount,
+ shopifyGraphqlClient,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { collectionCountOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiCountCollections = createAction({
+ auth: shopifyAuth,
+ name: 'count_collections',
+ classification: 'READ',
+ displayName: 'Count Collections',
+ description: 'Count collections, optionally filtered.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Counts collections, optionally filtered with search syntax such as "collection_type:smart" or "title:Summer*". precision is AT_LEAST when Shopify stopped counting at its limit. Use search_collections to see them. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: collectionCountOutputSchema,
+ props: {
+ query: shopifyProps.searchQuery(
+ 'Shopify collection search syntax, for example "collection_type:custom". Leave empty to count all.'
+ ),
+ },
+ async run({ auth, propsValue }) {
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ collectionsCount: GqlCount | null;
+ }>({
+ auth,
+ query: `query CountCollections($query: String) { collectionsCount(query: $query) { count precision } }`,
+ variables: { query: shopifyValues.nonEmpty(propsValue.query) },
+ });
+ return {
+ count: data.collectionsCount?.count ?? 0,
+ precision: data.collectionsCount?.precision ?? null,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/count-locations.ts b/packages/pieces/community/shopify/src/lib/actions/ai/count-locations.ts
new file mode 100644
index 00000000000..9f90469143a
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/count-locations.ts
@@ -0,0 +1,43 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlCount,
+ shopifyGraphqlClient,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { locationCountOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiCountLocations = createAction({
+ auth: shopifyAuth,
+ name: 'count_locations',
+ classification: 'READ',
+ displayName: 'Count Locations',
+ description: 'Count the store\'s locations, optionally filtered.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Counts the store\'s locations, optionally filtered with search syntax such as "name:Warehouse*". precision is AT_LEAST when Shopify stopped counting at its limit. Use list_locations to see them. Needs the read_locations access scope. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: locationCountOutputSchema,
+ props: {
+ query: shopifyProps.searchQuery(
+ 'Shopify location search syntax, for example "name:Warehouse*". Leave empty to count all.'
+ ),
+ },
+ async run({ auth, propsValue }) {
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ locationsCount: GqlCount | null;
+ }>({
+ auth,
+ query: `query CountLocations($query: String) { locationsCount(query: $query) { count precision } }`,
+ variables: { query: shopifyValues.nonEmpty(propsValue.query) },
+ });
+ return {
+ count: data.locationsCount?.count ?? 0,
+ precision: data.locationsCount?.precision ?? null,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/count-products.ts b/packages/pieces/community/shopify/src/lib/actions/ai/count-products.ts
new file mode 100644
index 00000000000..3698e7baa68
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/count-products.ts
@@ -0,0 +1,43 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlCount,
+ shopifyGraphqlClient,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { productCountOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiCountProducts = createAction({
+ auth: shopifyAuth,
+ name: 'count_products',
+ classification: 'READ',
+ displayName: 'Count Products',
+ description: 'Count products, optionally filtered.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Counts products, optionally filtered with search syntax such as "status:active" or "vendor:Nike". precision is AT_LEAST when Shopify stopped counting at its limit. Use search_products to see them. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: productCountOutputSchema,
+ props: {
+ query: shopifyProps.searchQuery(
+ 'Shopify product search syntax, for example "status:active" or "tag:sale". Leave empty to count all.'
+ ),
+ },
+ async run({ auth, propsValue }) {
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ productsCount: GqlCount | null;
+ }>({
+ auth,
+ query: `query CountProducts($query: String) { productsCount(query: $query) { count precision } }`,
+ variables: { query: shopifyValues.nonEmpty(propsValue.query) },
+ });
+ return {
+ count: data.productsCount?.count ?? 0,
+ precision: data.productsCount?.precision ?? null,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/create-collection.ts b/packages/pieces/community/shopify/src/lib/actions/ai/create-collection.ts
new file mode 100644
index 00000000000..c287795c96f
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/create-collection.ts
@@ -0,0 +1,114 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlCollection,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { collectionOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiCreateCollection = createAction({
+ auth: shopifyAuth,
+ name: 'create_collection',
+ classification: 'WRITE',
+ displayName: 'Create Collection',
+ description: 'Create a manual collection, optionally with an initial list of products.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Creates one collection whose products are picked by hand (the equivalent of a custom collection), optionally with the given products already in it. Use create_smart_collection for a rule-based collection, add_products_to_collection to add more products later, and publish_resource to make it visible on a sales channel. Not available on Starter or Retail plans. Each call creates another collection, so retries create duplicates.',
+ idempotent: false,
+ },
+ outputSchema: collectionOutputSchema,
+ props: {
+ title: Property.ShortText({
+ displayName: 'Title',
+ description: 'Collection title, for example "Summer Sale".',
+ required: true,
+ }),
+ description_html: Property.LongText({
+ displayName: 'Description (HTML)',
+ description: 'Collection description, HTML allowed.',
+ required: false,
+ }),
+ handle: Property.ShortText({
+ displayName: 'Handle',
+ description: 'URL handle, for example "summer-sale". Generated from the title when empty.',
+ required: false,
+ }),
+ product_ids: Property.Array({
+ displayName: 'Product IDs',
+ description: 'Products to put in the collection, numeric or "gid://shopify/Product/…".',
+ required: false,
+ }),
+ sort_order: shopifyProps.collectionSortOrder(),
+ image_url: Property.ShortText({
+ displayName: 'Image URL',
+ description: 'Public URL of the collection image.',
+ required: false,
+ }),
+ image_alt: Property.ShortText({
+ displayName: 'Image Alt Text',
+ description: 'Accessible description of the collection image.',
+ required: false,
+ }),
+ template_suffix: Property.ShortText({
+ displayName: 'Template Suffix',
+ description: 'Theme template suffix, for example "sale" for collection.sale.liquid.',
+ required: false,
+ }),
+ seo_title: Property.ShortText({
+ displayName: 'SEO Title',
+ description: 'Page title for search engines.',
+ required: false,
+ }),
+ seo_description: Property.LongText({
+ displayName: 'SEO Description',
+ description: 'Meta description for search engines.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const productIds = shopifyValues.toGidList({ type: 'Product', value: propsValue.product_ids });
+ const imageUrl = shopifyValues.nonEmpty(propsValue.image_url);
+ const collection = shopifyValues.compact({
+ title: propsValue.title,
+ descriptionHtml: shopifyValues.nonEmpty(propsValue.description_html),
+ handle: shopifyValues.nonEmpty(propsValue.handle),
+ sortOrder: propsValue.sort_order,
+ templateSuffix: shopifyValues.nonEmpty(propsValue.template_suffix),
+ image: imageUrl
+ ? shopifyValues.compact({ src: imageUrl, altText: shopifyValues.nonEmpty(propsValue.image_alt) })
+ : undefined,
+ seo: shopifyValues.toSeo({ title: propsValue.seo_title, description: propsValue.seo_description }),
+ sources: productIds
+ ? [
+ {
+ source: {
+ title: shopifyFields.MANUAL_SELECTION_SOURCE_TITLE,
+ inclusion: { selections: productIds.map((productId) => ({ productId })) },
+ },
+ },
+ ]
+ : undefined,
+ });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ collectionCreate: { collection: GqlCollection | null } | null;
+ }>({
+ auth,
+ query: `mutation CreateCollection($collection: CollectionCreateInput!) { collectionCreate(collection: $collection) { collection { ${shopifyFields.COLLECTION_FIELDS} } userErrors { field message } } }`,
+ variables: { collection },
+ });
+ const created = data.collectionCreate?.collection;
+ if (!created) {
+ throw new Error('Shopify did not return the new collection.');
+ }
+ return {
+ ...shopifyMappers.mapCollection(created),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/create-product-options.ts b/packages/pieces/community/shopify/src/lib/actions/ai/create-product-options.ts
new file mode 100644
index 00000000000..9926ca16493
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/create-product-options.ts
@@ -0,0 +1,102 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlProduct,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyValues,
+} from '../../common/graphql';
+import { productDetailOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiCreateProductOptions = createAction({
+ auth: shopifyAuth,
+ name: 'create_product_options',
+ classification: 'WRITE',
+ displayName: 'Create Product Options',
+ description: 'Add new options (such as Size or Color) and their values to a product.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Adds one or more options with their values to a product (a product can have up to 3 options). With variant_strategy LEAVE_AS_IS (the default) existing variants get the first value of each new option and no variants are added; CREATE also creates a variant for every new value combination. Returns the product with its options and variants. Adding an option that already exists fails, so do not blindly retry.',
+ idempotent: false,
+ },
+ outputSchema: productDetailOutputSchema,
+ props: {
+ product_id: Property.ShortText({
+ displayName: 'Product ID',
+ description: 'The product id, numeric or "gid://shopify/Product/…". Find it with search_products.',
+ required: true,
+ }),
+ options: Property.Array({
+ displayName: 'Options',
+ description: 'The options to add, for example Color with values "Red, Blue".',
+ required: true,
+ properties: {
+ name: Property.ShortText({
+ displayName: 'Option Name',
+ description: 'Option name, for example "Color".',
+ required: true,
+ }),
+ values: Property.ShortText({
+ displayName: 'Values',
+ description: 'Comma-separated values, for example "Red, Blue, Green". Write \\, for a comma inside a value, for example "Cotton\\, Linen".',
+ required: true,
+ }),
+ position: Property.Number({
+ displayName: 'Position',
+ description: 'Optional position of the option, starting at 1.',
+ required: false,
+ }),
+ },
+ }),
+ variant_strategy: Property.StaticDropdown({
+ displayName: 'Variant Strategy',
+ description: 'What happens to variants. Defaults to leaving existing variants as they are.',
+ required: false,
+ options: {
+ options: [
+ { label: 'Leave variants as they are', value: 'LEAVE_AS_IS' },
+ { label: 'Create variants for every new combination', value: 'CREATE' },
+ ],
+ },
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const productId = shopifyGraphqlClient.toGid({ type: 'Product', id: propsValue.product_id });
+ const options = shopifyValues.readRecords(propsValue.options).map((option) => {
+ const name = shopifyValues.readText(option['name']);
+ const values = shopifyValues.splitList(option['values']);
+ if (!name || values.length === 0) {
+ throw new Error('Every option needs a name and at least one value.');
+ }
+ return shopifyValues.compact({
+ name,
+ position: shopifyValues.readNumber(option['position']),
+ values: values.map((value) => ({ name: value })),
+ });
+ });
+ if (options.length === 0) {
+ throw new Error('Provide at least one option to create.');
+ }
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ productOptionsCreate: { product: GqlProduct | null } | null;
+ }>({
+ auth,
+ query: `mutation CreateProductOptions($productId: ID!, $options: [OptionCreateInput!]!, $variantStrategy: ProductOptionCreateVariantStrategy) { productOptionsCreate(productId: $productId, options: $options, variantStrategy: $variantStrategy) { product { ${shopifyFields.PRODUCT_DETAIL_FIELDS} } userErrors { field message code } } }`,
+ variables: {
+ productId,
+ options,
+ variantStrategy: propsValue.variant_strategy ?? 'LEAVE_AS_IS',
+ },
+ });
+ const product = data.productOptionsCreate?.product;
+ if (!product) {
+ throw new Error(`Product ${productId} was not returned by Shopify.`);
+ }
+ return {
+ ...shopifyMappers.mapProductDetail(product),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/create-product-record.ts b/packages/pieces/community/shopify/src/lib/actions/ai/create-product-record.ts
new file mode 100644
index 00000000000..9a0404cb133
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/create-product-record.ts
@@ -0,0 +1,111 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlProduct,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { productDetailOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiCreateProductRecord = createAction({
+ auth: shopifyAuth,
+ name: 'create_product_record',
+ classification: 'WRITE',
+ displayName: 'Create Product',
+ description: 'Create a new product with its title, description, vendor, type, tags and status.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Creates one new product with a single default variant. The status defaults to DRAFT so nothing goes live by accident; pass ACTIVE to sell it. Add options and more variants afterwards with create_product_options and create_product_variants, images with add_product_media, and stock with the inventory actions; set_product builds a whole product with options and variants in one call. Each call creates another product, so retries create duplicates.',
+ idempotent: false,
+ },
+ outputSchema: productDetailOutputSchema,
+ props: {
+ title: Property.ShortText({
+ displayName: 'Title',
+ description: 'Product title, for example "Organic Cotton T-Shirt".',
+ required: true,
+ }),
+ description_html: Property.LongText({
+ displayName: 'Description (HTML)',
+ description: 'Product description, HTML allowed, for example "<p>Soft organic cotton.</p>".',
+ required: false,
+ }),
+ vendor: Property.ShortText({
+ displayName: 'Vendor',
+ description: 'Brand or vendor name, for example "Acme Apparel".',
+ required: false,
+ }),
+ product_type: Property.ShortText({
+ displayName: 'Product Type',
+ description: 'Merchant-defined product type, for example "T-Shirts".',
+ required: false,
+ }),
+ status: shopifyProps.productStatus({
+ description: 'Product status. Defaults to Draft (not visible to customers).',
+ }),
+ handle: Property.ShortText({
+ displayName: 'Handle',
+ description: 'URL handle, for example "organic-cotton-t-shirt". Generated from the title when empty.',
+ required: false,
+ }),
+ tags: Property.Array({
+ displayName: 'Tags',
+ description: 'Tags to add, for example ["summer", "cotton"].',
+ required: false,
+ }),
+ category_id: Property.ShortText({
+ displayName: 'Category ID',
+ description: 'Standard product taxonomy category id, for example "gid://shopify/TaxonomyCategory/aa-1-13-8". Find it with search_product_taxonomy.',
+ required: false,
+ }),
+ collection_ids: Property.Array({
+ displayName: 'Collection IDs',
+ description: 'Collections to add the product to, numeric or "gid://shopify/Collection/…".',
+ required: false,
+ }),
+ seo_title: Property.ShortText({
+ displayName: 'SEO Title',
+ description: 'Page title for search engines.',
+ required: false,
+ }),
+ seo_description: Property.LongText({
+ displayName: 'SEO Description',
+ description: 'Meta description for search engines.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const tags = shopifyValues.readStringList(propsValue.tags);
+ const product = shopifyValues.compact({
+ title: propsValue.title,
+ descriptionHtml: shopifyValues.nonEmpty(propsValue.description_html),
+ vendor: shopifyValues.nonEmpty(propsValue.vendor),
+ productType: shopifyValues.nonEmpty(propsValue.product_type),
+ status: propsValue.status ?? 'DRAFT',
+ handle: shopifyValues.nonEmpty(propsValue.handle),
+ tags: tags && tags.length > 0 ? tags : undefined,
+ category: shopifyValues.toCategoryGid(propsValue.category_id),
+ collectionsToJoin: shopifyValues.toGidList({ type: 'Collection', value: propsValue.collection_ids }),
+ seo: shopifyValues.toSeo({ title: propsValue.seo_title, description: propsValue.seo_description }),
+ });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ productCreate: { product: GqlProduct | null } | null;
+ }>({
+ auth,
+ query: `mutation CreateProductRecord($product: ProductCreateInput!) { productCreate(product: $product) { product { ${shopifyFields.PRODUCT_DETAIL_FIELDS} } userErrors { field message } } }`,
+ variables: { product },
+ });
+ const created = data.productCreate?.product;
+ if (!created) {
+ throw new Error('Shopify did not return the new product.');
+ }
+ return {
+ ...shopifyMappers.mapProductDetail(created),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/create-product-variants.ts b/packages/pieces/community/shopify/src/lib/actions/ai/create-product-variants.ts
new file mode 100644
index 00000000000..c6ab9844857
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/create-product-variants.ts
@@ -0,0 +1,67 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlVariant,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { variantListOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiCreateProductVariants = createAction({
+ auth: shopifyAuth,
+ name: 'create_product_variants',
+ classification: 'WRITE',
+ displayName: 'Create Product Variants',
+ description: 'Add one or more variants to a product.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Adds variants to an existing product in one call. Each variant needs a value for every product option (for example "Color=Red, Size=Large"); new values are added to the options automatically. Optionally stock each new variant at one location. With strategy REMOVE_STANDALONE_VARIANT the placeholder "Default Title" variant is removed. All-or-nothing: if one variant is invalid none is created. Each call creates new variants, so retries create duplicates or fail on existing option combinations.',
+ idempotent: false,
+ },
+ outputSchema: variantListOutputSchema,
+ props: {
+ product_id: Property.ShortText({
+ displayName: 'Product ID',
+ description: 'The product id, numeric or "gid://shopify/Product/…". Find it with search_products.',
+ required: true,
+ }),
+ variants: shopifyProps.variants({ mode: 'create' }),
+ strategy: Property.StaticDropdown({
+ displayName: 'Default Variant Handling',
+ description: 'What happens to the placeholder variant of a product without options. Leave empty for the Shopify default.',
+ required: false,
+ options: {
+ options: [
+ { label: 'Default', value: 'DEFAULT' },
+ { label: 'Remove the standalone placeholder variant', value: 'REMOVE_STANDALONE_VARIANT' },
+ { label: 'Keep the standalone placeholder variant', value: 'PRESERVE_STANDALONE_VARIANT' },
+ ],
+ },
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const productId = shopifyGraphqlClient.toGid({ type: 'Product', id: propsValue.product_id });
+ const variants = shopifyValues.buildVariantInputs({ value: propsValue.variants, mode: 'create' });
+ if (variants.length === 0) {
+ throw new Error('Provide at least one variant to create.');
+ }
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ productVariantsBulkCreate: { productVariants: GqlVariant[] | null; product: { id: string } | null } | null;
+ }>({
+ auth,
+ query: `mutation CreateProductVariants($productId: ID!, $variants: [ProductVariantsBulkInput!]!, $strategy: ProductVariantsBulkCreateStrategy) { productVariantsBulkCreate(productId: $productId, variants: $variants, strategy: $strategy) { product { id } productVariants { ${shopifyFields.VARIANT_FIELDS} } userErrors { field message code } } }`,
+ variables: { productId, variants, strategy: propsValue.strategy },
+ });
+ const items = (data.productVariantsBulkCreate?.productVariants ?? []).map(shopifyMappers.mapVariant);
+ return {
+ product_id: data.productVariantsBulkCreate?.product?.id ?? productId,
+ variants: items,
+ count: items.length,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/create-smart-collection.ts b/packages/pieces/community/shopify/src/lib/actions/ai/create-smart-collection.ts
new file mode 100644
index 00000000000..c9d17a19c09
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/create-smart-collection.ts
@@ -0,0 +1,119 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlCollection,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { collectionOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiCreateSmartCollection = createAction({
+ auth: shopifyAuth,
+ name: 'create_smart_collection',
+ classification: 'WRITE',
+ displayName: 'Create Smart Collection',
+ description: 'Create a rule-based collection that automatically includes products matching conditions.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Creates one collection whose products are chosen automatically by conditions, for example product tag TAGGED_WITH "summer" or variant price LESS_THAN 25. match_type ALL requires every condition, ANY requires at least one. Price conditions need currency. Membership is computed by Shopify and may take a moment. Not available on Starter or Retail plans. Each call creates another collection, so retries create duplicates.',
+ idempotent: false,
+ },
+ outputSchema: collectionOutputSchema,
+ props: {
+ title: Property.ShortText({
+ displayName: 'Title',
+ description: 'Collection title, for example "Summer Items".',
+ required: true,
+ }),
+ match_type: Property.StaticDropdown({
+ displayName: 'Match',
+ description: 'Whether products must match all conditions or any of them.',
+ required: true,
+ options: {
+ options: [
+ { label: 'All conditions', value: 'ALL' },
+ { label: 'Any condition', value: 'ANY' },
+ ],
+ },
+ }),
+ conditions: shopifyProps.conditions({
+ required: true,
+ description: 'The rules products must match, for example field product_tag, relation TAGGED_WITH, value "summer".',
+ }),
+ currency: Property.ShortText({
+ displayName: 'Currency',
+ description: 'Shop currency code for price conditions, for example "USD".',
+ required: false,
+ }),
+ description_html: Property.LongText({
+ displayName: 'Description (HTML)',
+ description: 'Collection description, HTML allowed.',
+ required: false,
+ }),
+ handle: Property.ShortText({
+ displayName: 'Handle',
+ description: 'URL handle, for example "summer-items". Generated from the title when empty.',
+ required: false,
+ }),
+ sort_order: shopifyProps.collectionSortOrder(),
+ template_suffix: Property.ShortText({
+ displayName: 'Template Suffix',
+ description: 'Theme template suffix, for example "sale".',
+ required: false,
+ }),
+ seo_title: Property.ShortText({
+ displayName: 'SEO Title',
+ description: 'Page title for search engines.',
+ required: false,
+ }),
+ seo_description: Property.LongText({
+ displayName: 'SEO Description',
+ description: 'Meta description for search engines.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const conditions = shopifyValues.buildConditions({
+ value: propsValue.conditions,
+ currency: shopifyValues.nonEmpty(propsValue.currency)?.toUpperCase(),
+ });
+ if (conditions.length === 0) {
+ throw new Error('Provide at least one condition.');
+ }
+ const collection = shopifyValues.compact({
+ title: propsValue.title,
+ descriptionHtml: shopifyValues.nonEmpty(propsValue.description_html),
+ handle: shopifyValues.nonEmpty(propsValue.handle),
+ sortOrder: propsValue.sort_order,
+ templateSuffix: shopifyValues.nonEmpty(propsValue.template_suffix),
+ seo: shopifyValues.toSeo({ title: propsValue.seo_title, description: propsValue.seo_description }),
+ sources: [
+ {
+ source: {
+ title: shopifyFields.CONDITIONS_SOURCE_TITLE,
+ inclusion: { matchType: propsValue.match_type, conditions },
+ },
+ },
+ ],
+ });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ collectionCreate: { collection: GqlCollection | null } | null;
+ }>({
+ auth,
+ query: `mutation CreateSmartCollection($collection: CollectionCreateInput!) { collectionCreate(collection: $collection) { collection { ${shopifyFields.COLLECTION_FIELDS} } userErrors { field message } } }`,
+ variables: { collection },
+ });
+ const created = data.collectionCreate?.collection;
+ if (!created) {
+ throw new Error('Shopify did not return the new collection.');
+ }
+ return {
+ ...shopifyMappers.mapCollection(created),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/deactivate-inventory-at-location.ts b/packages/pieces/community/shopify/src/lib/actions/ai/deactivate-inventory-at-location.ts
new file mode 100644
index 00000000000..f7b7ecd2709
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/deactivate-inventory-at-location.ts
@@ -0,0 +1,71 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import { shopifyGraphqlClient } from '../../common/graphql';
+import { deactivateInventoryAtLocationOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiDeactivateInventoryAtLocation = createAction({
+ auth: shopifyAuth,
+ name: 'deactivate_inventory_at_location',
+ classification: 'DESTRUCTIVE',
+ displayName: 'Stop Stocking Item at Location',
+ description: 'Stop tracking an inventory item at a location.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Stops stocking one inventory item at one location: looks up the item\'s inventory level at that location, then removes it, discarding the quantities recorded there. An item must stay stocked at one location at least, and Shopify can refuse for other reasons, for example stock still committed to orders; the refusal reason is returned and nothing is changed. Re-stock with activate_inventory_at_location. A repeat call fails because the level is gone.',
+ idempotent: false,
+ },
+ outputSchema: deactivateInventoryAtLocationOutputSchema,
+ props: {
+ inventory_item_id: Property.ShortText({
+ displayName: 'Inventory Item ID',
+ description: 'The inventory item id, numeric or "gid://shopify/InventoryItem/…" (from get_product_variant_details).',
+ required: true,
+ }),
+ location_id: Property.ShortText({
+ displayName: 'Location ID',
+ description: 'The location id, numeric or "gid://shopify/Location/…" (from list_locations).',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const inventoryItemId = shopifyGraphqlClient.toGid({ type: 'InventoryItem', id: propsValue.inventory_item_id });
+ const locationId = shopifyGraphqlClient.toGid({ type: 'Location', id: propsValue.location_id });
+ const lookup = await shopifyGraphqlClient.request<{
+ inventoryItem: {
+ id: string;
+ inventoryLevel: { id: string; canDeactivate?: boolean | null; deactivationAlert?: string | null } | null;
+ } | null;
+ }>({
+ auth,
+ query: `query DeactivateInventoryLevelLookup($id: ID!, $locationId: ID!) { inventoryItem(id: $id) { id inventoryLevel(locationId: $locationId) { id canDeactivate deactivationAlert } } }`,
+ variables: { id: inventoryItemId, locationId },
+ });
+ if (!lookup.data.inventoryItem) {
+ throw new Error(`Inventory item ${inventoryItemId} was not found.`);
+ }
+ const level = lookup.data.inventoryItem.inventoryLevel;
+ if (!level) {
+ throw new Error(`Inventory item ${inventoryItemId} is not stocked at location ${locationId}.`);
+ }
+ if (level.canDeactivate === false) {
+ throw new Error(
+ `Shopify will not stop stocking this item at ${locationId}: ${level.deactivationAlert ?? 'the level cannot be deactivated'}.`
+ );
+ }
+ const { redactedFields } = await shopifyGraphqlClient.request<{
+ inventoryDeactivate: { userErrors: { field?: string[] | null; message: string }[] } | null;
+ }>({
+ auth,
+ query: `mutation DeactivateInventoryAtLocation($inventoryLevelId: ID!) { inventoryDeactivate(inventoryLevelId: $inventoryLevelId) { userErrors { field message } } }`,
+ variables: { inventoryLevelId: level.id },
+ });
+ return {
+ deactivated: true,
+ inventory_level_id: level.id,
+ inventory_item_id: inventoryItemId,
+ location_id: locationId,
+ redacted_fields: [...lookup.redactedFields, ...redactedFields],
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/delete-collection.ts b/packages/pieces/community/shopify/src/lib/actions/ai/delete-collection.ts
new file mode 100644
index 00000000000..7a4f90bf062
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/delete-collection.ts
@@ -0,0 +1,40 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import { shopifyGraphqlClient } from '../../common/graphql';
+import { deleteCollectionOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiDeleteCollection = createAction({
+ auth: shopifyAuth,
+ name: 'delete_collection',
+ classification: 'DESTRUCTIVE',
+ displayName: 'Delete Collection',
+ description: 'Permanently delete a collection. The products in it are not deleted.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Permanently deletes one collection (manual or rule-based) and its membership rules. The products themselves are kept. Cannot be undone; a repeat call fails because the collection is gone.',
+ idempotent: false,
+ },
+ outputSchema: deleteCollectionOutputSchema,
+ props: {
+ collection_id: Property.ShortText({
+ displayName: 'Collection ID',
+ description: 'The collection id, numeric or "gid://shopify/Collection/…". Find it with search_collections.',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'Collection', id: propsValue.collection_id });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ collectionDelete: { deletedCollectionId?: string | null } | null;
+ }>({
+ auth,
+ query: `mutation DeleteCollection($input: CollectionDeleteInput!) { collectionDelete(input: $input) { deletedCollectionId userErrors { field message } } }`,
+ variables: { input: { id } },
+ });
+ return {
+ deleted_collection_id: data.collectionDelete?.deletedCollectionId ?? id,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/delete-product-media.ts b/packages/pieces/community/shopify/src/lib/actions/ai/delete-product-media.ts
new file mode 100644
index 00000000000..5343fd79962
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/delete-product-media.ts
@@ -0,0 +1,88 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import { shopifyGraphqlClient, shopifyValues } from '../../common/graphql';
+import { deleteProductMediaOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiDeleteProductMedia = createAction({
+ auth: shopifyAuth,
+ name: 'delete_product_media',
+ classification: 'DESTRUCTIVE',
+ displayName: 'Remove Product Media',
+ description: 'Remove images, videos or 3D models from a product.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Detaches media from a product: it disappears from the product gallery and from any variant that used it. The file itself stays in the store\'s Files library (it is not deleted there), except for media whose upload FAILED: Shopify cannot detach those, so they are deleted. Needs the write_files (or write_themes) access scope. Media ids come from list_product_media. A repeat call is not guaranteed to succeed once the media is detached.',
+ idempotent: false,
+ },
+ outputSchema: deleteProductMediaOutputSchema,
+ props: {
+ product_id: Property.ShortText({
+ displayName: 'Product ID',
+ description: 'The product to remove the media from, numeric or "gid://shopify/Product/…".',
+ required: true,
+ }),
+ media_ids: Property.Array({
+ displayName: 'Media IDs',
+ description: 'Ids of the media to remove, for example ["gid://shopify/MediaImage/1072273219"].',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const productId = shopifyGraphqlClient.toGid({ type: 'Product', id: propsValue.product_id });
+ const mediaIds = shopifyValues.toGidList({ type: 'MediaImage', value: propsValue.media_ids });
+ if (!mediaIds) {
+ throw new Error('Provide at least one media id to remove.');
+ }
+ const { data: productData } = await shopifyGraphqlClient.request<{
+ product: { media: { nodes: { id: string; status?: string | null }[] } } | null;
+ }>({
+ auth,
+ query: `query ReadProductMediaStatus($id: ID!) { product(id: $id) { media(first: 250) { nodes { id status } } } }`,
+ variables: { id: productId },
+ });
+ if (!productData.product) {
+ throw new Error(`Product ${productId} was not found. Nothing was removed.`);
+ }
+ const productMedia = new Map(productData.product.media.nodes.map((node) => [node.id, node.status ?? null]));
+ const foreignIds = mediaIds.filter((id) => !productMedia.has(id));
+ if (foreignIds.length > 0) {
+ throw new Error(
+ `${foreignIds.join(', ')} ${foreignIds.length === 1 ? 'is' : 'are'} not media of product ${productId}. Check the ids with list_product_media. Nothing was removed.`
+ );
+ }
+ const failedIds = new Set(mediaIds.filter((id) => productMedia.get(id) === 'FAILED'));
+ const readyIds = mediaIds.filter((id) => !failedIds.has(id));
+ const removedIds: (string | null)[] = [];
+ const redacted: string[] = [];
+ if (readyIds.length > 0) {
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ fileUpdate: { files: { id?: string | null }[] | null } | null;
+ }>({
+ auth,
+ query: `mutation DeleteProductMedia($files: [FileUpdateInput!]!) { fileUpdate(files: $files) { files { id } userErrors { field message code } } }`,
+ variables: {
+ files: readyIds.map((id) => ({ id, referencesToRemove: [productId] })),
+ },
+ });
+ removedIds.push(...(data.fileUpdate?.files ?? []).map((file) => file.id ?? null));
+ redacted.push(...redactedFields);
+ }
+ if (failedIds.size > 0) {
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ fileDelete: { deletedFileIds: string[] | null } | null;
+ }>({
+ auth,
+ query: `mutation DeleteFailedProductMedia($fileIds: [ID!]!) { fileDelete(fileIds: $fileIds) { deletedFileIds userErrors { field message code } } }`,
+ variables: { fileIds: [...failedIds] },
+ });
+ removedIds.push(...(data.fileDelete?.deletedFileIds ?? []));
+ redacted.push(...redactedFields);
+ }
+ return {
+ product_id: productId,
+ removed_media_ids: removedIds,
+ redacted_fields: redacted,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/delete-product-options.ts b/packages/pieces/community/shopify/src/lib/actions/ai/delete-product-options.ts
new file mode 100644
index 00000000000..4878ed84f35
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/delete-product-options.ts
@@ -0,0 +1,72 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlProduct,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyValues,
+} from '../../common/graphql';
+import { deleteProductOptionsOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiDeleteProductOptions = createAction({
+ auth: shopifyAuth,
+ name: 'delete_product_options',
+ classification: 'DESTRUCTIVE',
+ displayName: 'Delete Product Options',
+ description: 'Delete one or more options from a product.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Deletes options from a product. The strategy is required because it decides what happens to variants: NON_DESTRUCTIVE deletes only when no variant has to be deleted, DEFAULT deletes only options that have a single value, POSITION also deletes options with several values and removes the variants that become duplicates, keeping the one with the lowest position. Option ids come from get_product_details. Cannot be undone; a repeat call fails because the options are gone.',
+ idempotent: false,
+ },
+ outputSchema: deleteProductOptionsOutputSchema,
+ props: {
+ product_id: Property.ShortText({
+ displayName: 'Product ID',
+ description: 'The product id, numeric or "gid://shopify/Product/…".',
+ required: true,
+ }),
+ option_ids: Property.Array({
+ displayName: 'Option IDs',
+ description: 'Ids of the options to delete, for example ["gid://shopify/ProductOption/1064576516"].',
+ required: true,
+ }),
+ strategy: Property.StaticDropdown({
+ displayName: 'Variant Strategy',
+ description: 'What happens to variants when the options are removed.',
+ required: true,
+ options: {
+ options: [
+ { label: 'Refuse if any variant would be deleted', value: 'NON_DESTRUCTIVE' },
+ { label: 'Default (only options with a single value)', value: 'DEFAULT' },
+ { label: 'Delete duplicate variants, keep the lowest position', value: 'POSITION' },
+ ],
+ },
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const productId = shopifyGraphqlClient.toGid({ type: 'Product', id: propsValue.product_id });
+ const options = shopifyValues.toGidList({ type: 'ProductOption', value: propsValue.option_ids });
+ if (!options) {
+ throw new Error('Provide at least one option id to delete.');
+ }
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ productOptionsDelete: { deletedOptionsIds?: string[] | null; product: GqlProduct | null } | null;
+ }>({
+ auth,
+ query: `mutation DeleteProductOptions($productId: ID!, $options: [ID!]!, $strategy: ProductOptionDeleteStrategy) { productOptionsDelete(productId: $productId, options: $options, strategy: $strategy) { deletedOptionsIds product { ${shopifyFields.PRODUCT_DETAIL_FIELDS} } userErrors { field message code } } }`,
+ variables: { productId, options, strategy: propsValue.strategy },
+ });
+ const product = data.productOptionsDelete?.product;
+ if (!product) {
+ throw new Error(`Product ${productId} was not returned by Shopify.`);
+ }
+ return {
+ deleted_option_ids: data.productOptionsDelete?.deletedOptionsIds ?? [],
+ ...shopifyMappers.mapProductDetail(product),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/delete-product-variants.ts b/packages/pieces/community/shopify/src/lib/actions/ai/delete-product-variants.ts
new file mode 100644
index 00000000000..f0550c6c672
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/delete-product-variants.ts
@@ -0,0 +1,50 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import { shopifyGraphqlClient, shopifyValues } from '../../common/graphql';
+import { deleteProductVariantsOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiDeleteProductVariants = createAction({
+ auth: shopifyAuth,
+ name: 'delete_product_variants',
+ classification: 'DESTRUCTIVE',
+ displayName: 'Delete Product Variants',
+ description: 'Permanently delete one or more variants of a product.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Permanently deletes variants of one product, together with their inventory items and stock. A product always keeps at least one variant. Cannot be undone; a repeat call fails because the variants are gone. Variant ids come from list_product_variants.',
+ idempotent: false,
+ },
+ outputSchema: deleteProductVariantsOutputSchema,
+ props: {
+ product_id: Property.ShortText({
+ displayName: 'Product ID',
+ description: 'The product the variants belong to, numeric or "gid://shopify/Product/…".',
+ required: true,
+ }),
+ variant_ids: Property.Array({
+ displayName: 'Variant IDs',
+ description: 'Ids of the variants to delete, numeric or "gid://shopify/ProductVariant/…".',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const productId = shopifyGraphqlClient.toGid({ type: 'Product', id: propsValue.product_id });
+ const variantsIds = shopifyValues.toGidList({ type: 'ProductVariant', value: propsValue.variant_ids });
+ if (!variantsIds) {
+ throw new Error('Provide at least one variant id to delete.');
+ }
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ productVariantsBulkDelete: { product: { id: string } | null } | null;
+ }>({
+ auth,
+ query: `mutation DeleteProductVariants($productId: ID!, $variantsIds: [ID!]!) { productVariantsBulkDelete(productId: $productId, variantsIds: $variantsIds) { product { id } userErrors { field message code } } }`,
+ variables: { productId, variantsIds },
+ });
+ return {
+ product_id: data.productVariantsBulkDelete?.product?.id ?? productId,
+ deleted_variant_ids: variantsIds,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/delete-product.ts b/packages/pieces/community/shopify/src/lib/actions/ai/delete-product.ts
new file mode 100644
index 00000000000..2c8070d2b69
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/delete-product.ts
@@ -0,0 +1,40 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import { shopifyGraphqlClient } from '../../common/graphql';
+import { deleteProductOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiDeleteProduct = createAction({
+ auth: shopifyAuth,
+ name: 'delete_product',
+ classification: 'DESTRUCTIVE',
+ displayName: 'Delete Product',
+ description: 'Permanently delete a product with all its variants and media.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Permanently deletes one product together with all its variants and inventory items. Its media files are deleted too, unless another product also uses them. Cannot be undone; to hide a product instead, set its status to ARCHIVED or DRAFT with update_product_fields. A repeat call fails because the product is gone.',
+ idempotent: false,
+ },
+ outputSchema: deleteProductOutputSchema,
+ props: {
+ product_id: Property.ShortText({
+ displayName: 'Product ID',
+ description: 'The product id, numeric or "gid://shopify/Product/…". Find it with search_products.',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'Product', id: propsValue.product_id });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ productDelete: { deletedProductId?: string | null } | null;
+ }>({
+ auth,
+ query: `mutation DeleteProduct($input: ProductDeleteInput!) { productDelete(input: $input, synchronous: true) { deletedProductId userErrors { field message } } }`,
+ variables: { input: { id } },
+ });
+ return {
+ deleted_product_id: data.productDelete?.deletedProductId ?? id,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/detach-variant-media.ts b/packages/pieces/community/shopify/src/lib/actions/ai/detach-variant-media.ts
new file mode 100644
index 00000000000..2c359836dbe
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/detach-variant-media.ts
@@ -0,0 +1,63 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import { GqlVariant, shopifyGraphqlClient, shopifyValues } from '../../common/graphql';
+import { variantMediaOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiDetachVariantMedia = createAction({
+ auth: shopifyAuth,
+ name: 'detach_variant_media',
+ classification: 'WRITE',
+ displayName: 'Detach Media from Variants',
+ description: 'Stop showing specific product media on specific variants.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Detaches media from one or more variants of a product. The media stays on the product itself; to remove it from the product use delete_product_media. Media ids come from list_product_media, variant ids from list_product_variants. Detaching again leaves it detached.',
+ idempotent: true,
+ },
+ outputSchema: variantMediaOutputSchema,
+ props: {
+ product_id: Property.ShortText({
+ displayName: 'Product ID',
+ description: 'The product id, numeric or "gid://shopify/Product/…".',
+ required: true,
+ }),
+ variant_media: Property.Array({
+ displayName: 'Variant Media',
+ description: 'Which media to detach from which variant, one entry per pair.',
+ required: true,
+ properties: {
+ variant_id: Property.ShortText({
+ displayName: 'Variant ID',
+ description: 'The variant id, numeric or "gid://shopify/ProductVariant/…".',
+ required: true,
+ }),
+ media_id: Property.ShortText({
+ displayName: 'Media ID',
+ description: 'The media id, for example "gid://shopify/MediaImage/1072273219".',
+ required: true,
+ }),
+ },
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const productId = shopifyGraphqlClient.toGid({ type: 'Product', id: propsValue.product_id });
+ const variantMedia = shopifyValues.groupVariantMedia(propsValue.variant_media);
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ productVariantDetachMedia: { productVariants: GqlVariant[] | null } | null;
+ }>({
+ auth,
+ query: `mutation DetachVariantMedia($productId: ID!, $variantMedia: [ProductVariantDetachMediaInput!]!) { productVariantDetachMedia(productId: $productId, variantMedia: $variantMedia) { productVariants { id title media(first: 10) { nodes { id } } } userErrors { field message code } } }`,
+ variables: { productId, variantMedia },
+ });
+ return {
+ product_id: productId,
+ variants: (data.productVariantDetachMedia?.productVariants ?? []).map((variant) => ({
+ id: variant.id,
+ title: variant.title ?? null,
+ media_ids: (variant.media?.nodes ?? []).map((media) => media.id ?? null),
+ })),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/duplicate-product.ts b/packages/pieces/community/shopify/src/lib/actions/ai/duplicate-product.ts
new file mode 100644
index 00000000000..e05b4e87525
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/duplicate-product.ts
@@ -0,0 +1,80 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlJob,
+ GqlProduct,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+} from '../../common/graphql';
+import { duplicateProductOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiDuplicateProduct = createAction({
+ auth: shopifyAuth,
+ name: 'duplicate_product',
+ classification: 'WRITE',
+ displayName: 'Duplicate Product',
+ description: 'Create a copy of a product under a new title.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Copies one product (options, variants, prices, tags) into a new product with the given title and returns the new product. Images are copied only when include_images is on; that copy runs in the background and its image_job_id is polled with get_job. The copy keeps the original status unless new_status is set. Very large products may time out. Each call creates another copy, so retries create duplicates.',
+ idempotent: false,
+ },
+ outputSchema: duplicateProductOutputSchema,
+ props: {
+ product_id: Property.ShortText({
+ displayName: 'Product ID',
+ description: 'The product to copy, numeric or "gid://shopify/Product/…". Find it with search_products.',
+ required: true,
+ }),
+ new_title: Property.ShortText({
+ displayName: 'New Title',
+ description: 'Title of the copy, for example "Organic Cotton T-Shirt (Copy)".',
+ required: true,
+ }),
+ new_status: shopifyProps.productStatus({
+ description: 'Status of the copy. Leave empty to keep the status of the original.',
+ }),
+ include_images: Property.Checkbox({
+ displayName: 'Copy Images',
+ description: 'Also copy the product images (runs in the background). Off by default.',
+ required: false,
+ defaultValue: false,
+ }),
+ include_translations: Property.Checkbox({
+ displayName: 'Copy Translations',
+ description: 'Also copy the product translations. Off by default.',
+ required: false,
+ defaultValue: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const productId = shopifyGraphqlClient.toGid({ type: 'Product', id: propsValue.product_id });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ productDuplicate: { newProduct: GqlProduct | null; imageJob: GqlJob | null } | null;
+ }>({
+ auth,
+ query: `mutation DuplicateProduct($productId: ID!, $newTitle: String!, $newStatus: ProductStatus, $includeImages: Boolean, $includeTranslations: Boolean) { productDuplicate(productId: $productId, newTitle: $newTitle, newStatus: $newStatus, includeImages: $includeImages, includeTranslations: $includeTranslations, synchronous: true) { newProduct { ${shopifyFields.PRODUCT_DETAIL_FIELDS} } imageJob { id done } userErrors { field message } } }`,
+ variables: {
+ productId,
+ newTitle: propsValue.new_title,
+ newStatus: propsValue.new_status,
+ includeImages: propsValue.include_images ?? false,
+ includeTranslations: propsValue.include_translations ?? false,
+ },
+ });
+ const newProduct = data.productDuplicate?.newProduct;
+ if (!newProduct) {
+ throw new Error('Shopify did not return the duplicated product.');
+ }
+ return {
+ ...shopifyMappers.mapProductDetail(newProduct),
+ source_product_id: productId,
+ image_job_id: data.productDuplicate?.imageJob?.id ?? null,
+ image_job_done: data.productDuplicate?.imageJob?.done ?? null,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/get-collection-by-handle.ts b/packages/pieces/community/shopify/src/lib/actions/ai/get-collection-by-handle.ts
new file mode 100644
index 00000000000..192927469cb
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/get-collection-by-handle.ts
@@ -0,0 +1,48 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlCollection,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+} from '../../common/graphql';
+import { collectionOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiGetCollectionByHandle = createAction({
+ auth: shopifyAuth,
+ name: 'get_collection_by_handle',
+ classification: 'READ',
+ displayName: 'Get Collection by Handle',
+ description: 'Get one collection by its URL handle.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Returns one collection by its URL handle (the last part of /collections/<handle>), with the same fields as get_collection. Fails when no collection has that handle. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: collectionOutputSchema,
+ props: {
+ handle: Property.ShortText({
+ displayName: 'Handle',
+ description: 'The collection handle, for example "summer-sale".',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const handle = propsValue.handle.trim();
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ collectionByIdentifier: GqlCollection | null;
+ }>({
+ auth,
+ query: `query GetCollectionByHandle($identifier: CollectionIdentifierInput!) { collectionByIdentifier(identifier: $identifier) { ${shopifyFields.COLLECTION_FIELDS} } }`,
+ variables: { identifier: { handle } },
+ });
+ if (!data.collectionByIdentifier) {
+ throw new Error(`No collection has the handle "${handle}".`);
+ }
+ return {
+ ...shopifyMappers.mapCollection(data.collectionByIdentifier),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/get-collection.ts b/packages/pieces/community/shopify/src/lib/actions/ai/get-collection.ts
new file mode 100644
index 00000000000..f62b5b1820d
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/get-collection.ts
@@ -0,0 +1,48 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlCollection,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+} from '../../common/graphql';
+import { collectionOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiGetCollection = createAction({
+ auth: shopifyAuth,
+ name: 'get_collection',
+ classification: 'READ',
+ displayName: 'Get Collection',
+ description: 'Get one collection with its membership sources and conditions.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Returns one collection by id: title, handle, description, product sort order, product count, image, SEO and its membership sources. A conditions source holds the rule conditions (each with id, kind, relation, values and, for prices, currency_code) and the manually selected products (the first 25, with selected_products_truncated=true when there are more; list_collection_products lists every member). A source with shareable=true is reused by other collections and is never changed by add_products_to_collection or remove_products_from_collection. The source id and condition ids are what update_collection, add_products_to_collection and remove_products_from_collection work with. Use search_collections to find a collection first. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: collectionOutputSchema,
+ props: {
+ collection_id: Property.ShortText({
+ displayName: 'Collection ID',
+ description: 'The collection id, numeric or "gid://shopify/Collection/…". Find it with search_collections.',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'Collection', id: propsValue.collection_id });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ collection: GqlCollection | null;
+ }>({
+ auth,
+ query: `query GetCollection($id: ID!) { collection(id: $id) { ${shopifyFields.COLLECTION_FIELDS} } }`,
+ variables: { id },
+ });
+ if (!data.collection) {
+ throw new Error(`Collection ${id} was not found.`);
+ }
+ return {
+ ...shopifyMappers.mapCollection(data.collection),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/get-inventory-item.ts b/packages/pieces/community/shopify/src/lib/actions/ai/get-inventory-item.ts
new file mode 100644
index 00000000000..38c2f85683e
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/get-inventory-item.ts
@@ -0,0 +1,48 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlInventoryItem,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+} from '../../common/graphql';
+import { inventoryItemOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiGetInventoryItem = createAction({
+ auth: shopifyAuth,
+ name: 'get_inventory_item',
+ classification: 'READ',
+ displayName: 'Get Inventory Item',
+ description: 'Get one inventory item with its SKU, cost, tracking and shipping details.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Returns one inventory item (the stock-keeping record behind a variant): SKU, whether stock is tracked, unit cost, weight, customs data (country of origin, HS code), how many locations stock it, and its variant and product. For quantities per location use list_inventory_levels. Needs the read_inventory access scope. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: inventoryItemOutputSchema,
+ props: {
+ inventory_item_id: Property.ShortText({
+ displayName: 'Inventory Item ID',
+ description: 'The inventory item id, numeric or "gid://shopify/InventoryItem/…" (from get_product_variant_details).',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'InventoryItem', id: propsValue.inventory_item_id });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ inventoryItem: GqlInventoryItem | null;
+ }>({
+ auth,
+ query: `query GetInventoryItem($id: ID!) { inventoryItem(id: $id) { ${shopifyFields.INVENTORY_ITEM_FIELDS} } }`,
+ variables: { id },
+ });
+ if (!data.inventoryItem) {
+ throw new Error(`Inventory item ${id} was not found.`);
+ }
+ return {
+ ...shopifyMappers.mapInventoryItem(data.inventoryItem),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/get-location.ts b/packages/pieces/community/shopify/src/lib/actions/ai/get-location.ts
new file mode 100644
index 00000000000..abda9bd8abb
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/get-location.ts
@@ -0,0 +1,48 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlLocation,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+} from '../../common/graphql';
+import { locationOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiGetLocation = createAction({
+ auth: shopifyAuth,
+ name: 'get_location',
+ classification: 'READ',
+ displayName: 'Get Location',
+ description: 'Get one store location with its address and capabilities.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Returns one location by id: name, address, whether it is active, fulfills online orders, ships inventory, has stock or unfulfilled orders, and whether it can be deactivated or deleted. Use list_locations to find location ids. Needs the read_locations access scope. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: locationOutputSchema,
+ props: {
+ location_id: Property.ShortText({
+ displayName: 'Location ID',
+ description: 'The location id, numeric or "gid://shopify/Location/…". Find it with list_locations.',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'Location', id: propsValue.location_id });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ location: GqlLocation | null;
+ }>({
+ auth,
+ query: `query GetLocation($id: ID!) { location(id: $id) { ${shopifyFields.LOCATION_FIELDS} } }`,
+ variables: { id },
+ });
+ if (!data.location) {
+ throw new Error(`Location ${id} was not found.`);
+ }
+ return {
+ ...shopifyMappers.mapLocation(data.location),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/get-product-details.ts b/packages/pieces/community/shopify/src/lib/actions/ai/get-product-details.ts
new file mode 100644
index 00000000000..67869a4930a
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/get-product-details.ts
@@ -0,0 +1,49 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlProduct,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+} from '../../common/graphql';
+import { productDetailOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiGetProductDetails = createAction({
+ auth: shopifyAuth,
+ name: 'get_product_details',
+ classification: 'READ',
+ displayName: 'Get Product',
+ description: 'Get one product with its options, variants and media.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Returns one product by id: title, status, vendor, type, tags, price range, SEO, its options with their values, the first 100 variants (price, SKU, stock, option values, inventory item id) and the first 50 media items. Use search_products to find a product by title, SKU, vendor or tag first. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: productDetailOutputSchema,
+ props: {
+ product_id: Property.ShortText({
+ displayName: 'Product ID',
+ description:
+ 'The product id: a numeric id such as "632910392" or a full id such as "gid://shopify/Product/632910392". Find it with search_products.',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'Product', id: propsValue.product_id });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ product: GqlProduct | null;
+ }>({
+ auth,
+ query: `query GetProductDetails($id: ID!) { product(id: $id) { ${shopifyFields.PRODUCT_DETAIL_FIELDS} } }`,
+ variables: { id },
+ });
+ if (!data.product) {
+ throw new Error(`Product ${id} was not found.`);
+ }
+ return {
+ ...shopifyMappers.mapProductDetail(data.product),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/get-product-duplicate-job.ts b/packages/pieces/community/shopify/src/lib/actions/ai/get-product-duplicate-job.ts
new file mode 100644
index 00000000000..6f7ed3428d0
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/get-product-duplicate-job.ts
@@ -0,0 +1,41 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import { GqlJob, shopifyGraphqlClient } from '../../common/graphql';
+import { getProductDuplicateJobOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiGetProductDuplicateJob = createAction({
+ auth: shopifyAuth,
+ name: 'get_product_duplicate_job',
+ classification: 'READ',
+ displayName: 'Get Product Duplicate Job',
+ description: 'Check whether a product duplication job has finished.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Reads the status of a product duplication job by its id, for duplication jobs started elsewhere (for example in the Shopify admin or by another app). duplicate_product does not need it: it waits and returns the copy directly, and its image copy (image_job_id) is polled with get_job. Returns done=true once Shopify has finished; call it again later while done is false. Shopify also reports done=true for a job id it does not know, so done=true alone does not prove the id was right. One status read, it never waits.',
+ idempotent: true,
+ },
+ outputSchema: getProductDuplicateJobOutputSchema,
+ props: {
+ job_id: Property.ShortText({
+ displayName: 'Job ID',
+ description: 'The product duplicate job id, either the bare id or "gid://shopify/ProductDuplicateJob/…".',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toOpaqueGid({ type: 'ProductDuplicateJob', id: propsValue.job_id });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ productDuplicateJob: GqlJob | null;
+ }>({
+ auth,
+ query: `query GetProductDuplicateJob($id: ID!) { productDuplicateJob(id: $id) { id done } }`,
+ variables: { id },
+ });
+ return {
+ id: data.productDuplicateJob?.id ?? id,
+ done: data.productDuplicateJob?.done ?? false,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/get-product-media.ts b/packages/pieces/community/shopify/src/lib/actions/ai/get-product-media.ts
new file mode 100644
index 00000000000..137420ea710
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/get-product-media.ts
@@ -0,0 +1,49 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlMedia,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+} from '../../common/graphql';
+import { productMediaOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiGetProductMedia = createAction({
+ auth: shopifyAuth,
+ name: 'get_product_media',
+ classification: 'READ',
+ displayName: 'Get Product Media',
+ description: 'Get one product image, video or 3D model by id.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Returns one media item by id: type, processing status, alt text, URL, size and any processing errors. Use list_product_media to find media ids. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: productMediaOutputSchema,
+ props: {
+ media_id: Property.ShortText({
+ displayName: 'Media ID',
+ description:
+ 'The media id, for example "gid://shopify/MediaImage/1072273219". A bare number is treated as an image id. Find it with list_product_media.',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'MediaImage', id: propsValue.media_id });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ node: GqlMedia | null;
+ }>({
+ auth,
+ query: `query GetProductMedia($id: ID!) { node(id: $id) { ... on Media { ${shopifyFields.MEDIA_FIELDS} } } }`,
+ variables: { id },
+ });
+ if (!data.node || !data.node.id) {
+ throw new Error(`Media ${id} was not found.`);
+ }
+ return {
+ ...shopifyMappers.mapMedia(data.node),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/get-product-variant-details.ts b/packages/pieces/community/shopify/src/lib/actions/ai/get-product-variant-details.ts
new file mode 100644
index 00000000000..433fb6cfd15
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/get-product-variant-details.ts
@@ -0,0 +1,49 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlVariant,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+} from '../../common/graphql';
+import { productVariantOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiGetProductVariantDetails = createAction({
+ auth: shopifyAuth,
+ name: 'get_product_variant_details',
+ classification: 'READ',
+ displayName: 'Get Product Variant',
+ description: 'Get one product variant with its price, SKU, stock and options.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Returns one product variant by id: title, SKU, barcode, price, compare-at price, stock quantity, out-of-stock policy, option values, its inventory item id (needed by the inventory actions) and its product. Use list_product_variants to find variant ids. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: productVariantOutputSchema,
+ props: {
+ variant_id: Property.ShortText({
+ displayName: 'Variant ID',
+ description:
+ 'The variant id: numeric such as "808950810" or "gid://shopify/ProductVariant/808950810". Find it with list_product_variants.',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'ProductVariant', id: propsValue.variant_id });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ productVariant: GqlVariant | null;
+ }>({
+ auth,
+ query: `query GetProductVariantDetails($id: ID!) { productVariant(id: $id) { ${shopifyFields.VARIANT_FIELDS} } }`,
+ variables: { id },
+ });
+ if (!data.productVariant) {
+ throw new Error(`Product variant ${id} was not found.`);
+ }
+ return {
+ ...shopifyMappers.mapVariant(data.productVariant),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/get-publication.ts b/packages/pieces/community/shopify/src/lib/actions/ai/get-publication.ts
new file mode 100644
index 00000000000..acca7bd7f7f
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/get-publication.ts
@@ -0,0 +1,48 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlPublication,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+} from '../../common/graphql';
+import { publicationOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiGetPublication = createAction({
+ auth: shopifyAuth,
+ name: 'get_publication',
+ classification: 'READ',
+ displayName: 'Get Publication',
+ description: 'Get one publication (sales channel or catalog) by id.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Returns one publication by id: its title, catalog and whether new products are published to it automatically. Use list_publications to find publication ids. Needs the read_publications access scope. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: publicationOutputSchema,
+ props: {
+ publication_id: Property.ShortText({
+ displayName: 'Publication ID',
+ description: 'The publication id, numeric or "gid://shopify/Publication/…". Find it with list_publications.',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'Publication', id: propsValue.publication_id });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ publication: GqlPublication | null;
+ }>({
+ auth,
+ query: `query GetPublication($id: ID!) { publication(id: $id) { ${shopifyFields.PUBLICATION_FIELDS} } }`,
+ variables: { id },
+ });
+ if (!data.publication) {
+ throw new Error(`Publication ${id} was not found.`);
+ }
+ return {
+ ...shopifyMappers.mapPublication(data.publication),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/list-collection-products.ts b/packages/pieces/community/shopify/src/lib/actions/ai/list-collection-products.ts
new file mode 100644
index 00000000000..e2d7d9e597c
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/list-collection-products.ts
@@ -0,0 +1,80 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlConnection,
+ GqlProduct,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { listCollectionProductsOutputSchema } from '../../output-schemas/products';
+
+const MAX_PAGE_SIZE = 80;
+
+export const shopifyAiListCollectionProducts = createAction({
+ auth: shopifyAuth,
+ name: 'list_collection_products',
+ classification: 'SEARCH',
+ displayName: 'List Collection Products',
+ description: 'List the products in a collection, one page at a time.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists the products currently in one collection (manual picks and products matching its conditions) as product summaries. With the default sort the collection\'s own sort order is used. Paged: pass end_cursor back as the cursor while has_next_page is true. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: listCollectionProductsOutputSchema,
+ props: {
+ collection_id: Property.ShortText({
+ displayName: 'Collection ID',
+ description: 'The collection id, numeric or "gid://shopify/Collection/…". Find it with search_collections.',
+ required: true,
+ }),
+ sort_key: Property.StaticDropdown({
+ displayName: 'Sort By',
+ description: 'Field to sort by. Defaults to the collection\'s own sort order.',
+ required: false,
+ options: {
+ options: [
+ { label: 'Collection default', value: 'COLLECTION_DEFAULT' },
+ { label: 'Manual', value: 'MANUAL' },
+ { label: 'Best selling', value: 'BEST_SELLING' },
+ { label: 'Title', value: 'TITLE' },
+ { label: 'Price', value: 'PRICE' },
+ { label: 'Created', value: 'CREATED' },
+ { label: 'ID', value: 'ID' },
+ ],
+ },
+ }),
+ reverse: shopifyProps.reverse(),
+ first: shopifyProps.first({ max: MAX_PAGE_SIZE }),
+ after: shopifyProps.after(),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'Collection', id: propsValue.collection_id });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ collection: { id: string; products: GqlConnection<GqlProduct> } | null;
+ }>({
+ auth,
+ query: `query ListCollectionProducts($id: ID!, $first: Int!, $after: String, $sortKey: ProductCollectionSortKeys, $reverse: Boolean) { collection(id: $id) { id products(first: $first, after: $after, sortKey: $sortKey, reverse: $reverse) { nodes { ${shopifyFields.PRODUCT_SUMMARY_FIELDS} } ${shopifyFields.PAGE_INFO_FIELDS} } } }`,
+ variables: {
+ id,
+ first: shopifyValues.readFirst({ value: propsValue.first, max: MAX_PAGE_SIZE }),
+ after: shopifyValues.nonEmpty(propsValue.after),
+ sortKey: propsValue.sort_key,
+ reverse: propsValue.reverse ?? false,
+ },
+ primaryPaths: ['collection.products'],
+ });
+ if (!data.collection) {
+ throw new Error(`Collection ${id} was not found.`);
+ }
+ return shopifyMappers.toPage({
+ connection: data.collection.products,
+ map: shopifyMappers.mapProductSummary,
+ redactedFields,
+ });
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/list-inventory-items.ts b/packages/pieces/community/shopify/src/lib/actions/ai/list-inventory-items.ts
new file mode 100644
index 00000000000..b9f1ccd7dcb
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/list-inventory-items.ts
@@ -0,0 +1,56 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlConnection,
+ GqlInventoryItem,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { listInventoryItemsOutputSchema } from '../../output-schemas/products';
+
+const MAX_PAGE_SIZE = 100;
+
+export const shopifyAiListInventoryItems = createAction({
+ auth: shopifyAuth,
+ name: 'list_inventory_items',
+ classification: 'SEARCH',
+ displayName: 'Search Inventory Items',
+ description: 'Search inventory items by SKU or id, one page at a time.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Searches inventory items with Shopify search syntax (for example "sku:TSHIRT-RED-L", "sku:TSHIRT*" or "id:>=30322695") and returns one page with SKU, tracking, cost and the linked variant and product. Use it to turn a SKU into the inventory item id the inventory actions need. Paged: pass end_cursor back as the cursor while has_next_page is true. Needs the read_inventory access scope. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: listInventoryItemsOutputSchema,
+ props: {
+ query: shopifyProps.searchQuery(
+ 'Shopify inventory item search syntax, for example "sku:TSHIRT-RED-L". Leave empty to list all.'
+ ),
+ reverse: shopifyProps.reverse(),
+ first: shopifyProps.first({ max: MAX_PAGE_SIZE }),
+ after: shopifyProps.after(),
+ },
+ async run({ auth, propsValue }) {
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ inventoryItems: GqlConnection<GqlInventoryItem>;
+ }>({
+ auth,
+ query: `query ListInventoryItems($first: Int!, $after: String, $query: String, $reverse: Boolean) { inventoryItems(first: $first, after: $after, query: $query, reverse: $reverse) { nodes { ${shopifyFields.INVENTORY_ITEM_FIELDS} } ${shopifyFields.PAGE_INFO_FIELDS} } }`,
+ variables: {
+ first: shopifyValues.readFirst({ value: propsValue.first, max: MAX_PAGE_SIZE }),
+ after: shopifyValues.nonEmpty(propsValue.after),
+ query: shopifyValues.nonEmpty(propsValue.query),
+ reverse: propsValue.reverse ?? false,
+ },
+ });
+ return shopifyMappers.toPage({
+ connection: data.inventoryItems,
+ map: shopifyMappers.mapInventoryItem,
+ redactedFields,
+ });
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/list-inventory-levels.ts b/packages/pieces/community/shopify/src/lib/actions/ai/list-inventory-levels.ts
new file mode 100644
index 00000000000..a938c0add73
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/list-inventory-levels.ts
@@ -0,0 +1,97 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlConnection,
+ GqlInventoryLevel,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { listInventoryLevelsOutputSchema } from '../../output-schemas/products';
+
+const MAX_PAGE_SIZE = 70;
+
+export const shopifyAiListInventoryLevels = createAction({
+ auth: shopifyAuth,
+ name: 'list_inventory_levels',
+ classification: 'SEARCH',
+ displayName: 'List Inventory Levels',
+ description: 'List stock quantities of one item across locations, or of all items at one location.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists inventory levels with their quantities (available, on hand, committed, incoming, reserved, damaged, safety stock, quality control). Give exactly one of inventory_item_id (where is this item stocked, and how much) or location_id (what is stocked at this location). Paged: pass end_cursor back as the cursor while has_next_page is true. Needs the read_inventory access scope. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: listInventoryLevelsOutputSchema,
+ props: {
+ inventory_item_id: Property.ShortText({
+ displayName: 'Inventory Item ID',
+ description: 'List this item\'s levels at every location, numeric or "gid://shopify/InventoryItem/…". Leave empty when giving a location.',
+ required: false,
+ }),
+ location_id: Property.ShortText({
+ displayName: 'Location ID',
+ description: 'List every item stocked at this location, numeric or "gid://shopify/Location/…". Leave empty when giving an item.',
+ required: false,
+ }),
+ include_inactive: Property.Checkbox({
+ displayName: 'Include Inactive',
+ description: 'Also return levels that were deactivated. Off by default.',
+ required: false,
+ defaultValue: false,
+ }),
+ first: shopifyProps.first({ max: MAX_PAGE_SIZE }),
+ after: shopifyProps.after(),
+ },
+ async run({ auth, propsValue }) {
+ const itemId = shopifyValues.nonEmpty(propsValue.inventory_item_id);
+ const locationId = shopifyValues.nonEmpty(propsValue.location_id);
+ if ((itemId === undefined) === (locationId === undefined)) {
+ throw new Error('Give exactly one of inventory_item_id or location_id.');
+ }
+ const paging = {
+ first: shopifyValues.readFirst({ value: propsValue.first, max: MAX_PAGE_SIZE }),
+ after: shopifyValues.nonEmpty(propsValue.after),
+ includeInactive: propsValue.include_inactive ?? false,
+ };
+ if (itemId !== undefined) {
+ const id = shopifyGraphqlClient.toGid({ type: 'InventoryItem', id: itemId });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ inventoryItem: { id: string; inventoryLevels: GqlConnection<GqlInventoryLevel> } | null;
+ }>({
+ auth,
+ query: `query ListInventoryLevelsByItem($id: ID!, $first: Int!, $after: String, $includeInactive: Boolean) { inventoryItem(id: $id) { id inventoryLevels(first: $first, after: $after, includeInactive: $includeInactive) { nodes { ${shopifyFields.INVENTORY_LEVEL_FIELDS} } ${shopifyFields.PAGE_INFO_FIELDS} } } }`,
+ variables: { id, ...paging },
+ primaryPaths: ['inventoryItem.inventoryLevels'],
+ });
+ if (!data.inventoryItem) {
+ throw new Error(`Inventory item ${id} was not found.`);
+ }
+ return shopifyMappers.toPage({
+ connection: data.inventoryItem.inventoryLevels,
+ map: shopifyMappers.mapInventoryLevel,
+ redactedFields,
+ });
+ }
+ const id = shopifyGraphqlClient.toGid({ type: 'Location', id: locationId ?? '' });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ location: { id: string; inventoryLevels: GqlConnection<GqlInventoryLevel> } | null;
+ }>({
+ auth,
+ query: `query ListInventoryLevelsByLocation($id: ID!, $first: Int!, $after: String, $includeInactive: Boolean) { location(id: $id) { id inventoryLevels(first: $first, after: $after, includeInactive: $includeInactive) { nodes { ${shopifyFields.INVENTORY_LEVEL_FIELDS} } ${shopifyFields.PAGE_INFO_FIELDS} } } }`,
+ variables: { id, ...paging },
+ primaryPaths: ['location.inventoryLevels'],
+ });
+ if (!data.location) {
+ throw new Error(`Location ${id} was not found.`);
+ }
+ return shopifyMappers.toPage({
+ connection: data.location.inventoryLevels,
+ map: shopifyMappers.mapInventoryLevel,
+ redactedFields,
+ });
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/list-locations.ts b/packages/pieces/community/shopify/src/lib/actions/ai/list-locations.ts
new file mode 100644
index 00000000000..20f81f0450e
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/list-locations.ts
@@ -0,0 +1,83 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlConnection,
+ GqlLocation,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { listLocationsOutputSchema } from '../../output-schemas/products';
+
+const MAX_PAGE_SIZE = 250;
+
+export const shopifyAiListLocations = createAction({
+ auth: shopifyAuth,
+ name: 'list_locations',
+ classification: 'SEARCH',
+ displayName: 'List Locations',
+ description: 'List the store\'s locations (warehouses, shops, fulfillment services), one page at a time.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists the store\'s locations with name, address, whether they are active, fulfill online orders or ship inventory, and whether they belong to a fulfillment service. The ids are needed by the inventory actions. Optionally filter with search syntax such as "name:Warehouse*". Inactive and legacy (fulfillment service) locations are left out unless asked for. Paged: pass end_cursor back as the cursor while has_next_page is true. Needs the read_locations access scope. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: listLocationsOutputSchema,
+ props: {
+ query: shopifyProps.searchQuery(
+ 'Shopify location search syntax, for example "name:Warehouse*". Leave empty to list all.'
+ ),
+ include_inactive: Property.Checkbox({
+ displayName: 'Include Inactive',
+ description: 'Also return deactivated locations. Off by default.',
+ required: false,
+ defaultValue: false,
+ }),
+ include_legacy: Property.Checkbox({
+ displayName: 'Include Legacy',
+ description: 'Also return legacy fulfillment-service locations. Off by default.',
+ required: false,
+ defaultValue: false,
+ }),
+ sort_key: Property.StaticDropdown({
+ displayName: 'Sort By',
+ description: 'Field to sort by. Defaults to the name.',
+ required: false,
+ options: {
+ options: [
+ { label: 'Name', value: 'NAME' },
+ { label: 'ID', value: 'ID' },
+ { label: 'Relevance (with a query)', value: 'RELEVANCE' },
+ ],
+ },
+ }),
+ reverse: shopifyProps.reverse(),
+ first: shopifyProps.first({ max: MAX_PAGE_SIZE }),
+ after: shopifyProps.after(),
+ },
+ async run({ auth, propsValue }) {
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ locations: GqlConnection<GqlLocation>;
+ }>({
+ auth,
+ query: `query ListLocations($first: Int!, $after: String, $query: String, $includeInactive: Boolean, $includeLegacy: Boolean, $sortKey: LocationSortKeys, $reverse: Boolean) { locations(first: $first, after: $after, query: $query, includeInactive: $includeInactive, includeLegacy: $includeLegacy, sortKey: $sortKey, reverse: $reverse) { nodes { ${shopifyFields.LOCATION_FIELDS} } ${shopifyFields.PAGE_INFO_FIELDS} } }`,
+ variables: {
+ first: shopifyValues.readFirst({ value: propsValue.first, max: MAX_PAGE_SIZE }),
+ after: shopifyValues.nonEmpty(propsValue.after),
+ query: shopifyValues.nonEmpty(propsValue.query),
+ includeInactive: propsValue.include_inactive ?? false,
+ includeLegacy: propsValue.include_legacy ?? false,
+ sortKey: propsValue.sort_key,
+ reverse: propsValue.reverse ?? false,
+ },
+ });
+ return shopifyMappers.toPage({
+ connection: data.locations,
+ map: shopifyMappers.mapLocation,
+ redactedFields,
+ });
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/list-product-media.ts b/packages/pieces/community/shopify/src/lib/actions/ai/list-product-media.ts
new file mode 100644
index 00000000000..c7a780fa1f8
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/list-product-media.ts
@@ -0,0 +1,63 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlConnection,
+ GqlMedia,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { listProductMediaOutputSchema } from '../../output-schemas/products';
+
+const MAX_PAGE_SIZE = 50;
+
+export const shopifyAiListProductMedia = createAction({
+ auth: shopifyAuth,
+ name: 'list_product_media',
+ classification: 'SEARCH',
+ displayName: 'List Product Media',
+ description: 'List the images, videos and 3D models of a product, one page at a time.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists the media of one product in display order: id, type, processing status, alt text and URL. The ids are needed by update_product_media, delete_product_media, reorder_product_media and attach_variant_media. Paged: pass end_cursor back as the cursor while has_next_page is true. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: listProductMediaOutputSchema,
+ props: {
+ product_id: Property.ShortText({
+ displayName: 'Product ID',
+ description: 'The product id, numeric or "gid://shopify/Product/…". Find it with search_products.',
+ required: true,
+ }),
+ reverse: shopifyProps.reverse(),
+ first: shopifyProps.first({ max: MAX_PAGE_SIZE }),
+ after: shopifyProps.after(),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'Product', id: propsValue.product_id });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ product: { id: string; media: GqlConnection<GqlMedia> } | null;
+ }>({
+ auth,
+ query: `query ListProductMedia($id: ID!, $first: Int!, $after: String, $reverse: Boolean) { product(id: $id) { id media(first: $first, after: $after, reverse: $reverse, sortKey: POSITION) { nodes { ${shopifyFields.MEDIA_FIELDS} } ${shopifyFields.PAGE_INFO_FIELDS} } } }`,
+ variables: {
+ id,
+ first: shopifyValues.readFirst({ value: propsValue.first, max: MAX_PAGE_SIZE }),
+ after: shopifyValues.nonEmpty(propsValue.after),
+ reverse: propsValue.reverse ?? false,
+ },
+ primaryPaths: ['product.media'],
+ });
+ if (!data.product) {
+ throw new Error(`Product ${id} was not found.`);
+ }
+ return shopifyMappers.toPage({
+ connection: data.product.media,
+ map: shopifyMappers.mapMedia,
+ redactedFields,
+ });
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/list-product-variants.ts b/packages/pieces/community/shopify/src/lib/actions/ai/list-product-variants.ts
new file mode 100644
index 00000000000..65726457ea8
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/list-product-variants.ts
@@ -0,0 +1,78 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlConnection,
+ GqlVariant,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { listProductVariantsOutputSchema } from '../../output-schemas/products';
+
+const MAX_PAGE_SIZE = 130;
+
+export const shopifyAiListProductVariants = createAction({
+ auth: shopifyAuth,
+ name: 'list_product_variants',
+ classification: 'SEARCH',
+ displayName: 'List Product Variants',
+ description: 'List the variants of one product, one page at a time.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists the variants of one product with price, SKU, stock, option values and inventory item id. Paged: pass end_cursor back as the cursor while has_next_page is true. Use get_product_variant_details for a single variant. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: listProductVariantsOutputSchema,
+ props: {
+ product_id: Property.ShortText({
+ displayName: 'Product ID',
+ description: 'The product id, numeric or "gid://shopify/Product/…". Find it with search_products.',
+ required: true,
+ }),
+ sort_key: Property.StaticDropdown({
+ displayName: 'Sort By',
+ description: 'Field to sort by. Defaults to position.',
+ required: false,
+ options: {
+ options: [
+ { label: 'Position', value: 'POSITION' },
+ { label: 'Title', value: 'TITLE' },
+ { label: 'SKU', value: 'SKU' },
+ { label: 'Inventory quantity', value: 'INVENTORY_QUANTITY' },
+ { label: 'ID', value: 'ID' },
+ ],
+ },
+ }),
+ reverse: shopifyProps.reverse(),
+ first: shopifyProps.first({ max: MAX_PAGE_SIZE }),
+ after: shopifyProps.after(),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'Product', id: propsValue.product_id });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ product: { id: string; variants: GqlConnection<GqlVariant> } | null;
+ }>({
+ auth,
+ query: `query ListProductVariants($id: ID!, $first: Int!, $after: String, $sortKey: ProductVariantSortKeys, $reverse: Boolean) { product(id: $id) { id variants(first: $first, after: $after, sortKey: $sortKey, reverse: $reverse) { nodes { ${shopifyFields.VARIANT_FIELDS} } ${shopifyFields.PAGE_INFO_FIELDS} } } }`,
+ variables: {
+ id,
+ first: shopifyValues.readFirst({ value: propsValue.first, max: MAX_PAGE_SIZE }),
+ after: shopifyValues.nonEmpty(propsValue.after),
+ sortKey: propsValue.sort_key,
+ reverse: propsValue.reverse ?? false,
+ },
+ primaryPaths: ['product.variants'],
+ });
+ if (!data.product) {
+ throw new Error(`Product ${id} was not found.`);
+ }
+ return shopifyMappers.toPage({
+ connection: data.product.variants,
+ map: shopifyMappers.mapVariant,
+ redactedFields,
+ });
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/list-publications.ts b/packages/pieces/community/shopify/src/lib/actions/ai/list-publications.ts
new file mode 100644
index 00000000000..c0da3bd1c22
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/list-publications.ts
@@ -0,0 +1,66 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlConnection,
+ GqlPublication,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { listPublicationsOutputSchema } from '../../output-schemas/products';
+
+const MAX_PAGE_SIZE = 250;
+
+export const shopifyAiListPublications = createAction({
+ auth: shopifyAuth,
+ name: 'list_publications',
+ classification: 'SEARCH',
+ displayName: 'List Publications',
+ description: 'List the publications (sales channels and catalogs) products can be published to.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists the store\'s publications, the targets that publish_resource and unpublish_resource take (for example the Online Store, Point of Sale or a market catalog), with their title and whether new products are published automatically. Paged: pass end_cursor back as the cursor while has_next_page is true. Needs the read_publications access scope. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: listPublicationsOutputSchema,
+ props: {
+ catalog_type: Property.StaticDropdown({
+ displayName: 'Catalog Type',
+ description: 'Only list publications of this catalog type. Leave empty for all.',
+ required: false,
+ options: {
+ options: [
+ { label: 'App (sales channel)', value: 'APP' },
+ { label: 'Market', value: 'MARKET' },
+ { label: 'Company location (B2B)', value: 'COMPANY_LOCATION' },
+ { label: 'None', value: 'NONE' },
+ ],
+ },
+ }),
+ reverse: shopifyProps.reverse(),
+ first: shopifyProps.first({ max: MAX_PAGE_SIZE }),
+ after: shopifyProps.after(),
+ },
+ async run({ auth, propsValue }) {
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ publications: GqlConnection<GqlPublication>;
+ }>({
+ auth,
+ query: `query ListPublications($first: Int!, $after: String, $catalogType: CatalogType, $reverse: Boolean) { publications(first: $first, after: $after, catalogType: $catalogType, reverse: $reverse) { nodes { ${shopifyFields.PUBLICATION_FIELDS} } ${shopifyFields.PAGE_INFO_FIELDS} } }`,
+ variables: {
+ first: shopifyValues.readFirst({ value: propsValue.first, max: MAX_PAGE_SIZE }),
+ after: shopifyValues.nonEmpty(propsValue.after),
+ catalogType: propsValue.catalog_type,
+ reverse: propsValue.reverse ?? false,
+ },
+ });
+ return shopifyMappers.toPage({
+ connection: data.publications,
+ map: shopifyMappers.mapPublication,
+ redactedFields,
+ });
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/list-sales-channels.ts b/packages/pieces/community/shopify/src/lib/actions/ai/list-sales-channels.ts
new file mode 100644
index 00000000000..6dc0f5fcc0e
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/list-sales-channels.ts
@@ -0,0 +1,52 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlChannelPublication,
+ GqlConnection,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { listSalesChannelsOutputSchema } from '../../output-schemas/products';
+
+const MAX_PAGE_SIZE = 250;
+
+export const shopifyAiListSalesChannels = createAction({
+ auth: shopifyAuth,
+ name: 'list_sales_channels',
+ classification: 'SEARCH',
+ displayName: 'List Sales Channels',
+ description: 'List the sales channels installed on the store.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists the sales channels of the store (for example Online Store, Point of Sale, Shop), built from the store\'s app publications: each item has the channel name and handle (from the channel app) and its publication_id. Put publication_id in publication_ids of publish_resource or unpublish_resource to show or hide products and collections on that channel. Markets and B2B catalogs are not channels and are listed by list_publications. Paged: pass end_cursor back as the cursor while has_next_page is true. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: listSalesChannelsOutputSchema,
+ props: {
+ reverse: shopifyProps.reverse(),
+ first: shopifyProps.first({ max: MAX_PAGE_SIZE }),
+ after: shopifyProps.after(),
+ },
+ async run({ auth, propsValue }) {
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ publications: GqlConnection<GqlChannelPublication>;
+ }>({
+ auth,
+ query: `query ListSalesChannels($first: Int!, $after: String, $reverse: Boolean) { publications(first: $first, after: $after, catalogType: APP, reverse: $reverse) { nodes { ${shopifyFields.CHANNEL_FIELDS} } ${shopifyFields.PAGE_INFO_FIELDS} } }`,
+ variables: {
+ first: shopifyValues.readFirst({ value: propsValue.first, max: MAX_PAGE_SIZE }),
+ after: shopifyValues.nonEmpty(propsValue.after),
+ reverse: propsValue.reverse ?? false,
+ },
+ });
+ return shopifyMappers.toPage({
+ connection: data.publications,
+ map: shopifyMappers.mapChannel,
+ redactedFields,
+ });
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/publish-resource.ts b/packages/pieces/community/shopify/src/lib/actions/ai/publish-resource.ts
new file mode 100644
index 00000000000..c5251b89afc
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/publish-resource.ts
@@ -0,0 +1,77 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import { shopifyGraphqlClient, shopifyValues } from '../../common/graphql';
+import { publishResourceOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiPublishResource = createAction({
+ auth: shopifyAuth,
+ name: 'publish_resource',
+ classification: 'WRITE',
+ displayName: 'Publish Product or Collection',
+ description: 'Publish a product or collection to one or more sales channels or catalogs.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Publishes one product or collection to the given publications (find them with list_publications), making it visible on those channels, optionally from a future date. A product is only visible to customers when its status is ACTIVE. Publishing to a publication it is already on leaves it published. Needs the write_publications access scope.',
+ idempotent: true,
+ },
+ outputSchema: publishResourceOutputSchema,
+ props: {
+ resource_type: Property.StaticDropdown({
+ displayName: 'Resource Type',
+ description: 'Whether the id is a product or a collection.',
+ required: true,
+ options: {
+ options: [
+ { label: 'Product', value: 'Product' },
+ { label: 'Collection', value: 'Collection' },
+ ],
+ },
+ }),
+ resource_id: Property.ShortText({
+ displayName: 'Resource ID',
+ description: 'The product or collection id, numeric or a full id such as "gid://shopify/Product/632910392".',
+ required: true,
+ }),
+ publication_ids: Property.Array({
+ displayName: 'Publication IDs',
+ description: 'Publications to publish to, for example ["gid://shopify/Publication/762454635"].',
+ required: true,
+ }),
+ publish_date: Property.DateTime({
+ displayName: 'Publish Date',
+ description: 'Optional future date and time to publish at. Leave empty to publish now.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: propsValue.resource_type, id: propsValue.resource_id });
+ const publicationIds = shopifyValues.toGidList({ type: 'Publication', value: propsValue.publication_ids });
+ if (!publicationIds) {
+ throw new Error('Provide at least one publication id. Find them with list_publications.');
+ }
+ const publishDate = shopifyValues.nonEmpty(propsValue.publish_date);
+ const input = publicationIds.map((publicationId) => shopifyValues.compact({ publicationId, publishDate }));
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ publishablePublish: {
+ publishable: {
+ id?: string | null;
+ title?: string | null;
+ resourcePublicationsCount?: { count?: number | null } | null;
+ } | null;
+ } | null;
+ }>({
+ auth,
+ query: `mutation PublishResource($id: ID!, $input: [PublicationInput!]!) { publishablePublish(id: $id, input: $input) { publishable { resourcePublicationsCount(onlyPublished: true) { count } ... on Product { id title } ... on Collection { id title } } userErrors { field message } } }`,
+ variables: { id, input },
+ });
+ const publishable = data.publishablePublish?.publishable;
+ return {
+ id: publishable?.id ?? id,
+ title: publishable?.title ?? null,
+ published_publications_count: publishable?.resourcePublicationsCount?.count ?? null,
+ publication_ids: publicationIds,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/remove-products-from-collection.ts b/packages/pieces/community/shopify/src/lib/actions/ai/remove-products-from-collection.ts
new file mode 100644
index 00000000000..2ce0b8bf85b
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/remove-products-from-collection.ts
@@ -0,0 +1,102 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlCollection,
+ GqlCollectionSource,
+ GqlJob,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyValues,
+} from '../../common/graphql';
+import { removeProductsFromCollectionOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiRemoveProductsFromCollection = createAction({
+ auth: shopifyAuth,
+ name: 'remove_products_from_collection',
+ classification: 'WRITE',
+ displayName: 'Remove Products from Collection',
+ description: 'Remove hand-picked products from a collection.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Removes manual picks from one collection. Reads the collection\'s sources first, then removes the products from every non-shared conditions source in one update (or only from source_id when given). Shared conditions sources (shareable=true in get_collection, reused by other collections) are never changed: a shared source_id is refused, and a collection whose only conditions sources are shared is refused with their ids. Only manual selections are removed: a product that still matches one of the collection\'s conditions stays in the collection; change the conditions with update_collection for that. The products themselves are not deleted. Large changes may finish in the background (job_id, poll get_job). Removing a product that is not picked leaves it unpicked.',
+ idempotent: true,
+ },
+ outputSchema: removeProductsFromCollectionOutputSchema,
+ props: {
+ collection_id: Property.ShortText({
+ displayName: 'Collection ID',
+ description: 'The collection id, numeric or "gid://shopify/Collection/…". Find it with search_collections.',
+ required: true,
+ }),
+ product_ids: Property.Array({
+ displayName: 'Product IDs',
+ description: 'Products to remove, numeric or "gid://shopify/Product/…".',
+ required: true,
+ }),
+ source_id: Property.ShortText({
+ displayName: 'Source ID',
+ description: 'Optional conditions source to remove the picks from (from get_collection sources). Must not be a shared source. Leave empty to remove from every non-shared conditions source.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'Collection', id: propsValue.collection_id });
+ const productIds = shopifyValues.toGidList({ type: 'Product', value: propsValue.product_ids });
+ if (!productIds) {
+ throw new Error('Provide at least one product id to remove.');
+ }
+ const lookup = await shopifyGraphqlClient.request<{ collection: GqlCollection | null }>({
+ auth,
+ query: `query RemoveProductsFromCollectionSources($id: ID!) { collection(id: $id) { ${shopifyFields.COLLECTION_SOURCE_LOOKUP_FIELDS} } }`,
+ variables: { id },
+ });
+ const lookedUp = lookup.data.collection;
+ if (!lookedUp) {
+ throw new Error(`Collection ${id} was not found.`);
+ }
+ const sourceId = shopifyValues.nonEmpty(propsValue.source_id);
+ const sources = sourceId
+ ? [shopifyValues.findExplicitConditionsSource({ collection: lookedUp, sourceId })]
+ : shopifyValues.editableConditionsSources(lookedUp);
+ if (sources.length === 0) {
+ throw new Error(noEditableSourceMessage({ id, shared: shopifyValues.sharedConditionsSources(lookedUp) }));
+ }
+ const selectionsToRemove = productIds.map((productId) => ({ productId }));
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ collectionUpdate: { collection: GqlCollection | null; job: GqlJob | null } | null;
+ }>({
+ auth,
+ query: `mutation RemoveProductsFromCollection($collection: CollectionUpdateInput!) { collectionUpdate(collection: $collection) { collection { ${shopifyFields.COLLECTION_FIELDS} } job { id done } userErrors { field message } } }`,
+ variables: {
+ collection: {
+ id,
+ sourcesToUpdate: sources.map((source) => ({
+ condition: { id: source.id, inclusion: { selectionsToRemove } },
+ })),
+ },
+ },
+ });
+ const collection = data.collectionUpdate?.collection;
+ if (!collection) {
+ throw new Error(`Collection ${id} was not returned by Shopify.`);
+ }
+ return {
+ ...shopifyMappers.mapCollection(collection),
+ removed_product_ids: productIds,
+ source_ids_used: sources.map((source) => source.id),
+ job_id: data.collectionUpdate?.job?.id ?? null,
+ job_done: data.collectionUpdate?.job?.done ?? null,
+ redacted_fields: [...lookup.redactedFields, ...redactedFields],
+ };
+ },
+});
+
+function noEditableSourceMessage({ id, shared }: { id: string; shared: GqlCollectionSource[] }): string {
+ if (shared.length === 0) {
+ return `Collection ${id} has no hand-picked products to remove (it has no conditions source).`;
+ }
+ const names = shared.map((source) => `${source.id} ("${source.title ?? ''}")`).join(', ');
+ return `Collection ${id} has only shared conditions sources (${names}); they are reused by other collections, so removing picks there would change those collections too. Nothing was removed.`;
+}
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/reorder-collection-products.ts b/packages/pieces/community/shopify/src/lib/actions/ai/reorder-collection-products.ts
new file mode 100644
index 00000000000..1a6559d502b
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/reorder-collection-products.ts
@@ -0,0 +1,70 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import { GqlJob, shopifyGraphqlClient, shopifyValues } from '../../common/graphql';
+import { reorderCollectionProductsOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiReorderCollectionProducts = createAction({
+ auth: shopifyAuth,
+ name: 'reorder_collection_products',
+ classification: 'WRITE',
+ displayName: 'Start Collection Product Reorder',
+ description: 'Start moving products to new positions inside a manually sorted collection (runs in the background).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Starts moving products to new zero-based positions inside one collection. The collection\'s sort order must be MANUAL (set it with update_collection first). Shopify does the move in the background and returns only a job: poll get_job with job_id until done is true, then read the order with list_collection_products. Starts a new job on every call.',
+ idempotent: false,
+ },
+ outputSchema: reorderCollectionProductsOutputSchema,
+ props: {
+ collection_id: Property.ShortText({
+ displayName: 'Collection ID',
+ description: 'The collection id, numeric or "gid://shopify/Collection/…".',
+ required: true,
+ }),
+ moves: Property.Array({
+ displayName: 'Moves',
+ description: 'The products to move and their new zero-based positions.',
+ required: true,
+ properties: {
+ product_id: Property.ShortText({
+ displayName: 'Product ID',
+ description: 'The product id, numeric or "gid://shopify/Product/…".',
+ required: true,
+ }),
+ new_position: Property.Number({
+ displayName: 'New Position',
+ description: 'Zero-based position inside the collection, 0 is first.',
+ required: true,
+ }),
+ },
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'Collection', id: propsValue.collection_id });
+ const moves = shopifyValues.readRecords(propsValue.moves).map((move) => {
+ const productId = shopifyValues.readText(move['product_id']);
+ const position = shopifyValues.readNumber(move['new_position']);
+ if (!productId || position === undefined || !Number.isInteger(position) || position < 0) {
+ throw new Error('Every move needs a product_id and a whole-number new_position of 0 or more.');
+ }
+ return { id: shopifyGraphqlClient.toGid({ type: 'Product', id: productId }), newPosition: String(position) };
+ });
+ if (moves.length === 0) {
+ throw new Error('Provide at least one move.');
+ }
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ collectionReorderProducts: { job: GqlJob | null } | null;
+ }>({
+ auth,
+ query: `mutation ReorderCollectionProducts($id: ID!, $moves: [MoveInput!]!) { collectionReorderProducts(id: $id, moves: $moves) { job { id done } userErrors { field message code } } }`,
+ variables: { id, moves },
+ });
+ return {
+ collection_id: id,
+ job_id: data.collectionReorderProducts?.job?.id ?? null,
+ done: data.collectionReorderProducts?.job?.done ?? false,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/reorder-product-media.ts b/packages/pieces/community/shopify/src/lib/actions/ai/reorder-product-media.ts
new file mode 100644
index 00000000000..8473743eac0
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/reorder-product-media.ts
@@ -0,0 +1,70 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import { GqlJob, shopifyGraphqlClient, shopifyValues } from '../../common/graphql';
+import { reorderProductMediaOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiReorderProductMedia = createAction({
+ auth: shopifyAuth,
+ name: 'reorder_product_media',
+ classification: 'WRITE',
+ displayName: 'Start Product Media Reorder',
+ description: 'Start moving product media to new positions (runs in the background).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Starts moving media of one product to new positions (0 is first). Shopify does the move in the background and returns only a job: poll get_job with job_id until done is true, then read the order with list_product_media. Starts a new job on every call.',
+ idempotent: false,
+ },
+ outputSchema: reorderProductMediaOutputSchema,
+ props: {
+ product_id: Property.ShortText({
+ displayName: 'Product ID',
+ description: 'The product id, numeric or "gid://shopify/Product/…".',
+ required: true,
+ }),
+ moves: Property.Array({
+ displayName: 'Moves',
+ description: 'The media to move and their new zero-based positions.',
+ required: true,
+ properties: {
+ media_id: Property.ShortText({
+ displayName: 'Media ID',
+ description: 'The media id, for example "gid://shopify/MediaImage/1072273219".',
+ required: true,
+ }),
+ new_position: Property.Number({
+ displayName: 'New Position',
+ description: 'Zero-based position, 0 is the first (featured) media.',
+ required: true,
+ }),
+ },
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'Product', id: propsValue.product_id });
+ const moves = shopifyValues.readRecords(propsValue.moves).map((move) => {
+ const mediaId = shopifyValues.readText(move['media_id']);
+ const position = shopifyValues.readNumber(move['new_position']);
+ if (!mediaId || position === undefined || !Number.isInteger(position) || position < 0) {
+ throw new Error('Every move needs a media_id and a whole-number new_position of 0 or more.');
+ }
+ return { id: shopifyGraphqlClient.toGid({ type: 'MediaImage', id: mediaId }), newPosition: String(position) };
+ });
+ if (moves.length === 0) {
+ throw new Error('Provide at least one move.');
+ }
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ productReorderMedia: { job: GqlJob | null } | null;
+ }>({
+ auth,
+ query: `mutation ReorderProductMedia($id: ID!, $moves: [MoveInput!]!) { productReorderMedia(id: $id, moves: $moves) { job { id done } mediaUserErrors { field message code } } }`,
+ variables: { id, moves },
+ });
+ return {
+ product_id: id,
+ job_id: data.productReorderMedia?.job?.id ?? null,
+ done: data.productReorderMedia?.job?.done ?? false,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/reorder-product-options.ts b/packages/pieces/community/shopify/src/lib/actions/ai/reorder-product-options.ts
new file mode 100644
index 00000000000..448825c05d1
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/reorder-product-options.ts
@@ -0,0 +1,93 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlProduct,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyValues,
+} from '../../common/graphql';
+import { productDetailOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiReorderProductOptions = createAction({
+ auth: shopifyAuth,
+ name: 'reorder_product_options',
+ classification: 'WRITE',
+ displayName: 'Reorder Product Options',
+ description: 'Set the order of a product\'s options and, optionally, of their values.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Sets the absolute order of a product\'s options (and optionally the order of each option\'s values). List every option in the order you want; for each option you can list its value names in order. Variant order follows the new option order. Sending the same order again is safe.',
+ idempotent: true,
+ },
+ outputSchema: productDetailOutputSchema,
+ props: {
+ product_id: Property.ShortText({
+ displayName: 'Product ID',
+ description: 'The product id, numeric or "gid://shopify/Product/…".',
+ required: true,
+ }),
+ options: Property.Array({
+ displayName: 'Options in Order',
+ description: 'Every option of the product, first to last.',
+ required: true,
+ properties: {
+ option_id: Property.ShortText({
+ displayName: 'Option ID',
+ description: 'The option id, for example "gid://shopify/ProductOption/1064576516". Use option_id for every option or name for every option; do not mix.',
+ required: false,
+ }),
+ name: Property.ShortText({
+ displayName: 'Option Name',
+ description: 'The option name, for example "Size". Use it for every option when no option ids are given.',
+ required: false,
+ }),
+ values: Property.ShortText({
+ displayName: 'Values in Order',
+ description: 'Optional comma-separated value names in the new order, for example "S, M, L". Write \\, for a comma inside a value, for example "Cotton\\, Linen".',
+ required: false,
+ }),
+ },
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const productId = shopifyGraphqlClient.toGid({ type: 'Product', id: propsValue.product_id });
+ const options = shopifyValues.readRecords(propsValue.options).map((option) => {
+ const optionId = shopifyValues.readText(option['option_id']);
+ const name = shopifyValues.readText(option['name']);
+ if (!optionId && !name) {
+ throw new Error('Every option needs an option_id or a name.');
+ }
+ const values = shopifyValues.splitList(option['values']).map((value) => ({ name: value }));
+ return shopifyValues.compact({
+ id: optionId ? shopifyGraphqlClient.toGid({ type: 'ProductOption', id: optionId }) : undefined,
+ name: optionId ? undefined : name,
+ values: values.length > 0 ? values : undefined,
+ });
+ });
+ if (options.length === 0) {
+ throw new Error('Provide the options in their new order.');
+ }
+ const usesIds = options.some((option) => option['id'] !== undefined);
+ const usesNames = options.some((option) => option['name'] !== undefined);
+ if (usesIds && usesNames) {
+ throw new Error('Identify every option the same way: all by option_id or all by name.');
+ }
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ productOptionsReorder: { product: GqlProduct | null } | null;
+ }>({
+ auth,
+ query: `mutation ReorderProductOptions($productId: ID!, $options: [OptionReorderInput!]!) { productOptionsReorder(productId: $productId, options: $options) { product { ${shopifyFields.PRODUCT_DETAIL_FIELDS} } userErrors { field message code } } }`,
+ variables: { productId, options },
+ });
+ const product = data.productOptionsReorder?.product;
+ if (!product) {
+ throw new Error(`Product ${productId} was not returned by Shopify.`);
+ }
+ return {
+ ...shopifyMappers.mapProductDetail(product),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/reorder-product-variants.ts b/packages/pieces/community/shopify/src/lib/actions/ai/reorder-product-variants.ts
new file mode 100644
index 00000000000..8b8d9cc8f03
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/reorder-product-variants.ts
@@ -0,0 +1,78 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlConnection,
+ GqlVariant,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyValues,
+} from '../../common/graphql';
+import { variantListOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiReorderProductVariants = createAction({
+ auth: shopifyAuth,
+ name: 'reorder_product_variants',
+ classification: 'WRITE',
+ displayName: 'Reorder Product Variants',
+ description: 'Move variants of a product to new positions.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Moves variants of one product to absolute positions (1 is first). Variants not listed shift around the moved ones. Returns the product\'s first 100 variants in their new order. Sending the same positions again is safe.',
+ idempotent: true,
+ },
+ outputSchema: variantListOutputSchema,
+ props: {
+ product_id: Property.ShortText({
+ displayName: 'Product ID',
+ description: 'The product id, numeric or "gid://shopify/Product/…".',
+ required: true,
+ }),
+ positions: Property.Array({
+ displayName: 'New Positions',
+ description: 'The variants to move and where.',
+ required: true,
+ properties: {
+ variant_id: Property.ShortText({
+ displayName: 'Variant ID',
+ description: 'The variant id, numeric or "gid://shopify/ProductVariant/…".',
+ required: true,
+ }),
+ position: Property.Number({
+ displayName: 'Position',
+ description: 'New position, starting at 1.',
+ required: true,
+ }),
+ },
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const productId = shopifyGraphqlClient.toGid({ type: 'Product', id: propsValue.product_id });
+ const positions = shopifyValues.readRecords(propsValue.positions).map((item) => {
+ const variantId = shopifyValues.readText(item['variant_id']);
+ const position = shopifyValues.readNumber(item['position']);
+ if (!variantId || position === undefined || !Number.isInteger(position) || position < 1) {
+ throw new Error('Every entry needs a variant_id and a whole-number position of at least 1.');
+ }
+ return { id: shopifyGraphqlClient.toGid({ type: 'ProductVariant', id: variantId }), position };
+ });
+ if (positions.length === 0) {
+ throw new Error('Provide at least one variant position.');
+ }
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ productVariantsBulkReorder: { product: { id: string; variants: GqlConnection<GqlVariant> } | null } | null;
+ }>({
+ auth,
+ query: `mutation ReorderProductVariants($productId: ID!, $positions: [ProductVariantPositionInput!]!) { productVariantsBulkReorder(productId: $productId, positions: $positions) { product { id variants(first: 100, sortKey: POSITION) { nodes { ${shopifyFields.VARIANT_FIELDS} } } } userErrors { field message code } } }`,
+ variables: { productId, positions },
+ });
+ const items = (data.productVariantsBulkReorder?.product?.variants?.nodes ?? []).map(shopifyMappers.mapVariant);
+ return {
+ product_id: data.productVariantsBulkReorder?.product?.id ?? productId,
+ variants: items,
+ count: items.length,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/search-collections.ts b/packages/pieces/community/shopify/src/lib/actions/ai/search-collections.ts
new file mode 100644
index 00000000000..e0cd1674ff7
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/search-collections.ts
@@ -0,0 +1,70 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlCollection,
+ GqlConnection,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { searchCollectionsOutputSchema } from '../../output-schemas/products';
+
+const MAX_PAGE_SIZE = 250;
+
+export const shopifyAiSearchCollections = createAction({
+ auth: shopifyAuth,
+ name: 'search_collections',
+ classification: 'SEARCH',
+ displayName: 'Search Collections',
+ description: 'Search collections with Shopify search syntax, one page at a time.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Searches collections with Shopify search syntax (for example "title:Summer*", "handle:summer-sale", "collection_type:custom" for manual collections or "collection_type:smart" for rule-based ones) and returns one page of collection summaries with product counts. Use get_collection for sources and conditions. Paged: pass end_cursor back as the cursor while has_next_page is true. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: searchCollectionsOutputSchema,
+ props: {
+ query: shopifyProps.searchQuery(
+ 'Shopify collection search syntax, for example "title:Summer*" or "collection_type:smart". Leave empty to list all collections.'
+ ),
+ sort_key: Property.StaticDropdown({
+ displayName: 'Sort By',
+ description: 'Field to sort by. Defaults to the collection id.',
+ required: false,
+ options: {
+ options: [
+ { label: 'Title', value: 'TITLE' },
+ { label: 'Updated at', value: 'UPDATED_AT' },
+ { label: 'Relevance (with a query)', value: 'RELEVANCE' },
+ { label: 'ID', value: 'ID' },
+ ],
+ },
+ }),
+ reverse: shopifyProps.reverse(),
+ first: shopifyProps.first({ max: MAX_PAGE_SIZE }),
+ after: shopifyProps.after(),
+ },
+ async run({ auth, propsValue }) {
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ collections: GqlConnection<GqlCollection>;
+ }>({
+ auth,
+ query: `query SearchCollections($first: Int!, $after: String, $query: String, $sortKey: CollectionSortKeys, $reverse: Boolean) { collections(first: $first, after: $after, query: $query, sortKey: $sortKey, reverse: $reverse) { nodes { ${shopifyFields.COLLECTION_SUMMARY_FIELDS} } ${shopifyFields.PAGE_INFO_FIELDS} } }`,
+ variables: {
+ first: shopifyValues.readFirst({ value: propsValue.first, max: MAX_PAGE_SIZE }),
+ after: shopifyValues.nonEmpty(propsValue.after),
+ query: shopifyValues.nonEmpty(propsValue.query),
+ sortKey: propsValue.sort_key,
+ reverse: propsValue.reverse ?? false,
+ },
+ });
+ return shopifyMappers.toPage({
+ connection: data.collections,
+ map: shopifyMappers.mapCollectionSummary,
+ redactedFields,
+ });
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/search-product-taxonomy.ts b/packages/pieces/community/shopify/src/lib/actions/ai/search-product-taxonomy.ts
new file mode 100644
index 00000000000..8589fba85ac
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/search-product-taxonomy.ts
@@ -0,0 +1,63 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlConnection,
+ GqlTaxonomyCategory,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { searchProductTaxonomyOutputSchema } from '../../output-schemas/products';
+
+const MAX_PAGE_SIZE = 250;
+
+export const shopifyAiSearchProductTaxonomy = createAction({
+ auth: shopifyAuth,
+ name: 'search_product_taxonomy',
+ classification: 'SEARCH',
+ displayName: 'Search Product Categories',
+ description: 'Search Shopify\'s standard product taxonomy for category ids.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Searches Shopify\'s standard product taxonomy (for example "t-shirts" or "running shoes") and returns categories with their full path, level and id. Pass the id as category_id to create_product_record or update_product_fields. Leave the search empty and give parent_category_id to browse one level down; with neither, the top-level categories are listed. Paged: pass end_cursor back as the cursor while has_next_page is true. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: searchProductTaxonomyOutputSchema,
+ props: {
+ search: Property.ShortText({
+ displayName: 'Search',
+ description: 'Words to search for, for example "t-shirts".',
+ required: false,
+ }),
+ parent_category_id: Property.ShortText({
+ displayName: 'Parent Category ID',
+ description: 'List the direct children of this category, for example "aa-1" or "gid://shopify/TaxonomyCategory/aa-1".',
+ required: false,
+ }),
+ first: shopifyProps.first({ max: MAX_PAGE_SIZE }),
+ after: shopifyProps.after(),
+ },
+ async run({ auth, propsValue }) {
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ taxonomy: { categories: GqlConnection<GqlTaxonomyCategory> } | null;
+ }>({
+ auth,
+ query: `query SearchProductTaxonomy($first: Int!, $after: String, $search: String, $childrenOf: ID) { taxonomy { categories(first: $first, after: $after, search: $search, childrenOf: $childrenOf) { nodes { ${shopifyFields.TAXONOMY_CATEGORY_FIELDS} } ${shopifyFields.PAGE_INFO_FIELDS} } } }`,
+ variables: {
+ first: shopifyValues.readFirst({ value: propsValue.first, max: MAX_PAGE_SIZE }),
+ after: shopifyValues.nonEmpty(propsValue.after),
+ search: shopifyValues.nonEmpty(propsValue.search),
+ childrenOf: shopifyValues.toCategoryGid(propsValue.parent_category_id),
+ },
+ primaryPaths: ['taxonomy.categories'],
+ });
+ return shopifyMappers.toPage({
+ connection: data.taxonomy?.categories,
+ map: shopifyMappers.mapTaxonomyCategory,
+ redactedFields,
+ });
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/search-products.ts b/packages/pieces/community/shopify/src/lib/actions/ai/search-products.ts
new file mode 100644
index 00000000000..4a27e31acbc
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/search-products.ts
@@ -0,0 +1,75 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlConnection,
+ GqlProduct,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { searchProductsOutputSchema } from '../../output-schemas/products';
+
+const MAX_PAGE_SIZE = 80;
+
+export const shopifyAiSearchProducts = createAction({
+ auth: shopifyAuth,
+ name: 'search_products',
+ classification: 'SEARCH',
+ displayName: 'Search Products',
+ description: 'Search products with Shopify search syntax, one page at a time.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Searches products with Shopify search syntax (for example "title:*shirt*", "sku:TSHIRT-RED-L", "vendor:Nike", "tag:sale", "status:active" or "product_type:Shoes") and returns one page of product summaries with price range, inventory total and variant count. Use get_product_details for options, variants and media. Paged: pass end_cursor back as the cursor while has_next_page is true. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: searchProductsOutputSchema,
+ props: {
+ query: shopifyProps.searchQuery(
+ 'Shopify product search syntax, for example "title:*shirt*", "sku:TSHIRT-RED-L", "vendor:Nike" or "status:draft". Leave empty to list all products.'
+ ),
+ sort_key: Property.StaticDropdown({
+ displayName: 'Sort By',
+ description: 'Field to sort by. Defaults to the product id.',
+ required: false,
+ options: {
+ options: [
+ { label: 'Title', value: 'TITLE' },
+ { label: 'Created at', value: 'CREATED_AT' },
+ { label: 'Updated at', value: 'UPDATED_AT' },
+ { label: 'Published at', value: 'PUBLISHED_AT' },
+ { label: 'Inventory total', value: 'INVENTORY_TOTAL' },
+ { label: 'Product type', value: 'PRODUCT_TYPE' },
+ { label: 'Vendor', value: 'VENDOR' },
+ { label: 'Relevance (with a query)', value: 'RELEVANCE' },
+ { label: 'ID', value: 'ID' },
+ ],
+ },
+ }),
+ reverse: shopifyProps.reverse(),
+ first: shopifyProps.first({ max: MAX_PAGE_SIZE }),
+ after: shopifyProps.after(),
+ },
+ async run({ auth, propsValue }) {
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ products: GqlConnection<GqlProduct>;
+ }>({
+ auth,
+ query: `query SearchProducts($first: Int!, $after: String, $query: String, $sortKey: ProductSortKeys, $reverse: Boolean) { products(first: $first, after: $after, query: $query, sortKey: $sortKey, reverse: $reverse) { nodes { ${shopifyFields.PRODUCT_SUMMARY_FIELDS} } ${shopifyFields.PAGE_INFO_FIELDS} } }`,
+ variables: {
+ first: shopifyValues.readFirst({ value: propsValue.first, max: MAX_PAGE_SIZE }),
+ after: shopifyValues.nonEmpty(propsValue.after),
+ query: shopifyValues.nonEmpty(propsValue.query),
+ sortKey: propsValue.sort_key,
+ reverse: propsValue.reverse ?? false,
+ },
+ });
+ return shopifyMappers.toPage({
+ connection: data.products,
+ map: shopifyMappers.mapProductSummary,
+ redactedFields,
+ });
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/set-inventory-quantities.ts b/packages/pieces/community/shopify/src/lib/actions/ai/set-inventory-quantities.ts
new file mode 100644
index 00000000000..dc257b3f402
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/set-inventory-quantities.ts
@@ -0,0 +1,135 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlInventoryAdjustmentGroup,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { inventoryChangeOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiSetInventoryQuantities = createAction({
+ auth: shopifyAuth,
+ name: 'set_inventory_quantities',
+ classification: 'WRITE',
+ displayName: 'Set Inventory Quantities',
+ description: 'Set stock to an absolute number at one or more locations.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Sets the available or on-hand quantity of inventory items at locations to an absolute number (for example 25), all in one batch under one reason. Every item must already be stocked at its location (see list_inventory_levels); otherwise nothing is changed and you should call activate_inventory_at_location first. Use adjust_inventory_quantities to add or subtract instead. Optional expected_quantity per entry is a safety check: if the current quantity differs, the whole call fails with CHANGE_FROM_QUANTITY_STALE, and a blind retry after a successful call also fails that way. Generate your own idempotency_key (for example a UUID) on the first call and pass the same key on every retry so a retry is safe; the key used is returned and is included in any error message. Inventory item ids come from get_product_variant_details or list_inventory_items, location ids from list_locations.',
+ idempotent: true,
+ },
+ outputSchema: inventoryChangeOutputSchema,
+ props: {
+ name: Property.StaticDropdown({
+ displayName: 'Quantity Name',
+ description: 'Which quantity to set.',
+ required: true,
+ options: {
+ options: [
+ { label: 'Available', value: 'available' },
+ { label: 'On hand', value: 'on_hand' },
+ ],
+ },
+ }),
+ reason: Property.StaticDropdown({
+ displayName: 'Reason',
+ description: 'Why the stock changes; shown in the inventory history.',
+ required: true,
+ options: {
+ options: [
+ { label: 'Correction', value: 'correction' },
+ { label: 'Cycle count', value: 'cycle_count_available' },
+ { label: 'Damaged', value: 'damaged' },
+ { label: 'Received', value: 'received' },
+ { label: 'Restock', value: 'restock' },
+ { label: 'Shrinkage', value: 'shrinkage' },
+ { label: 'Promotion', value: 'promotion' },
+ { label: 'Quality control', value: 'quality_control' },
+ { label: 'Safety stock', value: 'safety_stock' },
+ { label: 'Other', value: 'other' },
+ ],
+ },
+ }),
+ quantities: Property.Array({
+ displayName: 'Quantities',
+ description: 'One entry per inventory item and location.',
+ required: true,
+ properties: {
+ inventory_item_id: Property.ShortText({
+ displayName: 'Inventory Item ID',
+ description: 'The inventory item id, numeric or "gid://shopify/InventoryItem/…" (from get_product_variant_details).',
+ required: true,
+ }),
+ location_id: Property.ShortText({
+ displayName: 'Location ID',
+ description: 'The location id, numeric or "gid://shopify/Location/…" (from list_locations).',
+ required: true,
+ }),
+ quantity: Property.Number({
+ displayName: 'Quantity',
+ description: 'The new absolute quantity, a whole number such as 25.',
+ required: true,
+ }),
+ expected_quantity: Property.Number({
+ displayName: 'Expected Current Quantity',
+ description: 'Optional safety check: the quantity you expect right now. The call fails if stock moved in the meantime.',
+ required: false,
+ }),
+ },
+ }),
+ reference_document_uri: Property.ShortText({
+ displayName: 'Reference Document URI',
+ description: 'Optional URI of the document behind the change, for example "gid://my-app/CycleCount/CC-1".',
+ required: false,
+ }),
+ idempotency_key: shopifyProps.idempotencyKey(),
+ },
+ async run({ auth, propsValue }) {
+ const quantities = shopifyValues.readRecords(propsValue.quantities).map((entry) => {
+ const inventoryItemId = shopifyValues.readText(entry['inventory_item_id']);
+ const locationId = shopifyValues.readText(entry['location_id']);
+ const quantity = shopifyValues.readNumber(entry['quantity']);
+ if (!inventoryItemId || !locationId || quantity === undefined || !Number.isInteger(quantity)) {
+ throw new Error('Every entry needs an inventory_item_id, a location_id and a whole-number quantity.');
+ }
+ const expected = shopifyValues.readNumber(entry['expected_quantity']);
+ if (expected !== undefined && !Number.isInteger(expected)) {
+ throw new Error('expected_quantity must be a whole number.');
+ }
+ return {
+ inventoryItemId: shopifyGraphqlClient.toGid({ type: 'InventoryItem', id: inventoryItemId }),
+ locationId: shopifyGraphqlClient.toGid({ type: 'Location', id: locationId }),
+ quantity,
+ changeFromQuantity: expected ?? null,
+ };
+ });
+ if (quantities.length === 0) {
+ throw new Error('Provide at least one quantity to set.');
+ }
+ await shopifyGraphqlClient.assertStockedAtLocations({ auth, pairs: quantities });
+ const idempotencyKey = shopifyGraphqlClient.resolveIdempotencyKey(propsValue.idempotency_key);
+ const input = shopifyValues.compact({
+ name: propsValue.name,
+ reason: propsValue.reason,
+ referenceDocumentUri: shopifyValues.nonEmpty(propsValue.reference_document_uri),
+ quantities,
+ });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ inventorySetQuantities: { inventoryAdjustmentGroup: GqlInventoryAdjustmentGroup | null } | null;
+ }>({
+ auth,
+ query: `mutation SetInventoryQuantities($input: InventorySetQuantitiesInput!, $idempotencyKey: String!) { inventorySetQuantities(input: $input) @idempotent(key: $idempotencyKey) { inventoryAdjustmentGroup { ${shopifyFields.INVENTORY_ADJUSTMENT_GROUP_FIELDS} } userErrors { field message code } } }`,
+ variables: { input },
+ idempotencyKey,
+ });
+ return {
+ ...shopifyMappers.mapAdjustmentGroup(data.inventorySetQuantities?.inventoryAdjustmentGroup),
+ idempotency_key: idempotencyKey,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/set-product.ts b/packages/pieces/community/shopify/src/lib/actions/ai/set-product.ts
new file mode 100644
index 00000000000..1d1b6e23821
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/set-product.ts
@@ -0,0 +1,224 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlProduct,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import type { ShopifyAuth } from '../../common/types';
+import { setProductOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiSetProduct = createAction({
+ auth: shopifyAuth,
+ name: 'set_product',
+ classification: 'DESTRUCTIVE',
+ displayName: 'Set Product (Full State)',
+ description: 'Create or overwrite a whole product, including all its options and variants, in one call.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Declarative create-or-update of a complete product: sends the full list of options and variants you want the product to have. WARNING: on an existing product every variant and every option value not included here is DELETED, together with its stock and sales history links. Use update_product_fields to change single fields, and the variant and option actions for targeted changes. With product_id or product_handle an existing product is overwritten; a handle is looked up first and, if no product has it, the call is refused and nothing is created. Only with neither product_id nor product_handle is a new product created (status defaults to DRAFT); the output field created tells which happened. Tags, when sent, replace all tags. Collections and metafields are not sent by this action, so they are left unchanged. Sending the same full state again to the same product gives the same result; repeating a create (no id or handle) makes another product.',
+ idempotent: false,
+ },
+ outputSchema: setProductOutputSchema,
+ props: {
+ product_id: Property.ShortText({
+ displayName: 'Product ID',
+ description: 'The product to overwrite, numeric or "gid://shopify/Product/…". Leave empty (and no handle) to create a new product.',
+ required: false,
+ }),
+ product_handle: Property.ShortText({
+ displayName: 'Product Handle',
+ description: 'Alternative to Product ID: the handle of an existing product to overwrite, for example "organic-cotton-t-shirt". If no product has this handle the call fails; it never creates a product.',
+ required: false,
+ }),
+ title: Property.ShortText({
+ displayName: 'Title',
+ description: 'Product title. Required when creating a new product.',
+ required: false,
+ }),
+ description_html: Property.LongText({
+ displayName: 'Description (HTML)',
+ description: 'Product description, HTML allowed.',
+ required: false,
+ }),
+ vendor: Property.ShortText({
+ displayName: 'Vendor',
+ description: 'Brand or vendor name.',
+ required: false,
+ }),
+ product_type: Property.ShortText({
+ displayName: 'Product Type',
+ description: 'Merchant-defined product type.',
+ required: false,
+ }),
+ status: shopifyProps.productStatus({
+ description: 'Product status. On a new product defaults to Draft; on an existing product leave empty to keep it.',
+ }),
+ tags: Property.Array({
+ displayName: 'Tags',
+ description: 'The complete tag list. Replaces every existing tag; leave empty to keep the current tags.',
+ required: false,
+ }),
+ product_options: Property.Array({
+ displayName: 'Options',
+ description: 'Every option the product must have, in order, for example Size with values "S, M, L". Options not listed are removed.',
+ required: true,
+ properties: {
+ name: Property.ShortText({
+ displayName: 'Option Name',
+ description: 'Option name, for example "Size".',
+ required: true,
+ }),
+ values: Property.ShortText({
+ displayName: 'Values',
+ description: 'Comma-separated option values, for example "S, M, L". Write \\, for a comma inside a value, for example "Cotton\\, Linen".',
+ required: true,
+ }),
+ },
+ }),
+ variants: Property.Array({
+ displayName: 'Variants',
+ description: 'Every variant the product must have. Variants not listed are deleted.',
+ required: true,
+ properties: {
+ option_values: Property.ShortText({
+ displayName: 'Option Values',
+ description: 'One value per option, for example "Size=M, Color=Red". Write \\, for a comma inside a value, for example "Cotton\\, Linen".',
+ required: true,
+ }),
+ price: Property.Number({
+ displayName: 'Price',
+ description: 'Price in the shop currency, for example 19.99.',
+ required: false,
+ }),
+ compare_at_price: Property.Number({
+ displayName: 'Compare-at Price',
+ description: 'Original price shown struck through, for example 24.99.',
+ required: false,
+ }),
+ sku: Property.ShortText({
+ displayName: 'SKU',
+ description: 'Stock keeping unit, for example "TSHIRT-M-RED".',
+ required: false,
+ }),
+ barcode: Property.ShortText({
+ displayName: 'Barcode',
+ description: 'Barcode such as a UPC or ISBN. Replaces all barcodes of the variant with this one.',
+ required: false,
+ }),
+ barcode_type: shopifyProps.barcodeType(),
+ inventory_policy: Property.StaticDropdown({
+ displayName: 'When Out of Stock',
+ description: 'Whether customers can buy the variant when it is out of stock.',
+ required: false,
+ options: {
+ options: [
+ { label: 'Stop selling (deny)', value: 'DENY' },
+ { label: 'Continue selling', value: 'CONTINUE' },
+ ],
+ },
+ }),
+ },
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const productId = shopifyValues.nonEmpty(propsValue.product_id);
+ const productHandle = shopifyValues.nonEmpty(propsValue.product_handle);
+ const isUpdate = productId !== undefined || productHandle !== undefined;
+ const title = shopifyValues.nonEmpty(propsValue.title);
+ if (!isUpdate && !title) {
+ throw new Error('Give a title to create a new product, or a product_id / product_handle to overwrite one.');
+ }
+ const productOptions = shopifyValues.readRecords(propsValue.product_options).map((option, index) => {
+ const name = shopifyValues.readText(option['name']);
+ const values = shopifyValues.splitList(option['values']);
+ if (!name || values.length === 0) {
+ throw new Error('Every option needs a name and at least one value.');
+ }
+ return { name, position: index + 1, values: values.map((value) => ({ name: value })) };
+ });
+ const variants = shopifyValues.readRecords(propsValue.variants).map((variant) => {
+ const optionValues = shopifyValues.parseOptionValues(variant['option_values']);
+ if (optionValues.length === 0) {
+ throw new Error('Every variant needs option_values, for example "Size=M, Color=Red".');
+ }
+ const price = shopifyValues.readNumber(variant['price']);
+ const compareAtPrice = shopifyValues.readNumber(variant['compare_at_price']);
+ return shopifyValues.compact({
+ optionValues,
+ price: price !== undefined ? String(price) : undefined,
+ compareAtPrice: compareAtPrice !== undefined ? String(compareAtPrice) : undefined,
+ sku: shopifyValues.readText(variant['sku']),
+ barcodes: shopifyValues.toBarcodes({
+ value: shopifyValues.readText(variant['barcode']),
+ type: shopifyValues.readText(variant['barcode_type']),
+ }),
+ inventoryPolicy: shopifyValues.readText(variant['inventory_policy']),
+ });
+ });
+ if (productOptions.length === 0 || variants.length === 0) {
+ throw new Error('set_product needs the full list of options and variants. Use update_product_fields to change single fields.');
+ }
+ const tags = shopifyValues.readStringList(propsValue.tags);
+ const input = shopifyValues.compact({
+ title,
+ descriptionHtml: shopifyValues.nonEmpty(propsValue.description_html),
+ vendor: shopifyValues.nonEmpty(propsValue.vendor),
+ productType: shopifyValues.nonEmpty(propsValue.product_type),
+ status: propsValue.status ?? (isUpdate ? undefined : 'DRAFT'),
+ tags: tags && tags.length > 0 ? tags : undefined,
+ productOptions,
+ variants,
+ });
+ const resolved = isUpdate
+ ? await resolveExistingProduct({ auth, productId, productHandle })
+ : { identifier: undefined, redactedFields: [] };
+ const identifier = resolved.identifier;
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ productSet: { product: GqlProduct | null } | null;
+ }>({
+ auth,
+ query: `mutation SetProduct($input: ProductSetInput!, $identifier: ProductSetIdentifiers) { productSet(input: $input, identifier: $identifier, synchronous: true) { product { ${shopifyFields.PRODUCT_DETAIL_FIELDS} } userErrors { field message code } } }`,
+ variables: shopifyValues.compact({ input, identifier }),
+ });
+ const product = data.productSet?.product;
+ if (!product) {
+ throw new Error('Shopify did not return the product.');
+ }
+ return {
+ ...shopifyMappers.mapProductDetail(product),
+ created: !isUpdate,
+ redacted_fields: [...resolved.redactedFields, ...redactedFields],
+ };
+ },
+});
+
+async function resolveExistingProduct({
+ auth,
+ productId,
+ productHandle,
+}: {
+ auth: ShopifyAuth;
+ productId: string | undefined;
+ productHandle: string | undefined;
+}): Promise<{ identifier: { id: string }; redactedFields: string[] }> {
+ if (productId !== undefined) {
+ return { identifier: { id: shopifyGraphqlClient.toGid({ type: 'Product', id: productId }) }, redactedFields: [] };
+ }
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ productByIdentifier: { id: string } | null;
+ }>({
+ auth,
+ query: 'query SetProductResolveHandle($identifier: ProductIdentifierInput!) { productByIdentifier(identifier: $identifier) { id } }',
+ variables: { identifier: { handle: productHandle } },
+ });
+ const found = data.productByIdentifier;
+ if (!found) {
+ throw new Error(`No product with handle "${productHandle ?? ''}"; omit the handle to create one. Nothing was changed.`);
+ }
+ return { identifier: { id: found.id }, redactedFields };
+}
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/unpublish-resource.ts b/packages/pieces/community/shopify/src/lib/actions/ai/unpublish-resource.ts
new file mode 100644
index 00000000000..4b874032434
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/unpublish-resource.ts
@@ -0,0 +1,70 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import { shopifyGraphqlClient, shopifyValues } from '../../common/graphql';
+import { publishResourceOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiUnpublishResource = createAction({
+ auth: shopifyAuth,
+ name: 'unpublish_resource',
+ classification: 'DESTRUCTIVE',
+ displayName: 'Unpublish Product or Collection',
+ description: 'Remove a product or collection from one or more sales channels or catalogs.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Unpublishes one product or collection from the given publications (find them with list_publications), hiding it on those channels. The product or collection itself is not deleted and can be published again with publish_resource. Unpublishing from a publication it is not on leaves it unpublished. Needs the write_publications access scope.',
+ idempotent: true,
+ },
+ outputSchema: publishResourceOutputSchema,
+ props: {
+ resource_type: Property.StaticDropdown({
+ displayName: 'Resource Type',
+ description: 'Whether the id is a product or a collection.',
+ required: true,
+ options: {
+ options: [
+ { label: 'Product', value: 'Product' },
+ { label: 'Collection', value: 'Collection' },
+ ],
+ },
+ }),
+ resource_id: Property.ShortText({
+ displayName: 'Resource ID',
+ description: 'The product or collection id, numeric or a full id such as "gid://shopify/Product/632910392".',
+ required: true,
+ }),
+ publication_ids: Property.Array({
+ displayName: 'Publication IDs',
+ description: 'Publications to unpublish from, for example ["gid://shopify/Publication/762454635"].',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: propsValue.resource_type, id: propsValue.resource_id });
+ const publicationIds = shopifyValues.toGidList({ type: 'Publication', value: propsValue.publication_ids });
+ if (!publicationIds) {
+ throw new Error('Provide at least one publication id. Find them with list_publications.');
+ }
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ publishableUnpublish: {
+ publishable: {
+ id?: string | null;
+ title?: string | null;
+ resourcePublicationsCount?: { count?: number | null } | null;
+ } | null;
+ } | null;
+ }>({
+ auth,
+ query: `mutation UnpublishResource($id: ID!, $input: [PublicationInput!]!) { publishableUnpublish(id: $id, input: $input) { publishable { resourcePublicationsCount(onlyPublished: true) { count } ... on Product { id title } ... on Collection { id title } } userErrors { field message } } }`,
+ variables: { id, input: publicationIds.map((publicationId) => ({ publicationId })) },
+ });
+ const publishable = data.publishableUnpublish?.publishable;
+ return {
+ id: publishable?.id ?? id,
+ title: publishable?.title ?? null,
+ published_publications_count: publishable?.resourcePublicationsCount?.count ?? null,
+ publication_ids: publicationIds,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/update-collection.ts b/packages/pieces/community/shopify/src/lib/actions/ai/update-collection.ts
new file mode 100644
index 00000000000..af9bfca8cba
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/update-collection.ts
@@ -0,0 +1,183 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlCollection,
+ GqlJob,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { updateCollectionOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiUpdateCollection = createAction({
+ auth: shopifyAuth,
+ name: 'update_collection',
+ classification: 'WRITE',
+ displayName: 'Update Collection',
+ description: 'Change a collection\'s title, description, handle, sort order, image or SEO, and add or remove its rule conditions.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Changes one collection; fields left empty are not sent and keep their values. Rule conditions change only through explicit edits on one conditions source: conditions_to_add adds new conditions, condition_ids_to_delete removes conditions by id, match_type switches ALL/ANY; the source id and condition ids come from get_collection. Nothing is replaced implicitly. Manual product picks are changed with add_products_to_collection and remove_products_from_collection. Membership changes can finish in the background (job_id, poll get_job). Re-running the same field values is safe; adding the same condition twice creates a duplicate condition. A shared conditions source (shareable=true in get_collection, reused by other collections) is refused, so editing one collection never changes another.',
+ idempotent: false,
+ },
+ outputSchema: updateCollectionOutputSchema,
+ props: {
+ collection_id: Property.ShortText({
+ displayName: 'Collection ID',
+ description: 'The collection id, numeric or "gid://shopify/Collection/…". Find it with search_collections.',
+ required: true,
+ }),
+ title: Property.ShortText({
+ displayName: 'Title',
+ description: 'New title.',
+ required: false,
+ }),
+ description_html: Property.LongText({
+ displayName: 'Description (HTML)',
+ description: 'New description, HTML allowed. Replaces the existing description.',
+ required: false,
+ }),
+ handle: Property.ShortText({
+ displayName: 'Handle',
+ description: 'New URL handle.',
+ required: false,
+ }),
+ redirect_new_handle: shopifyProps.booleanChoice({
+ displayName: 'Redirect Old Handle',
+ description: 'When changing the handle, create a redirect from the old URL. Leave empty for the Shopify default.',
+ }),
+ sort_order: shopifyProps.collectionSortOrder(),
+ template_suffix: Property.ShortText({
+ displayName: 'Template Suffix',
+ description: 'New theme template suffix.',
+ required: false,
+ }),
+ image_url: Property.ShortText({
+ displayName: 'Image URL',
+ description: 'Public URL of a new collection image.',
+ required: false,
+ }),
+ image_alt: Property.ShortText({
+ displayName: 'Image Alt Text',
+ description: 'Alt text for the new image. Only used together with an image URL.',
+ required: false,
+ }),
+ seo_title: Property.ShortText({
+ displayName: 'SEO Title',
+ description: 'New page title for search engines.',
+ required: false,
+ }),
+ seo_description: Property.LongText({
+ displayName: 'SEO Description',
+ description: 'New meta description for search engines.',
+ required: false,
+ }),
+ source_id: Property.ShortText({
+ displayName: 'Conditions Source ID',
+ description: 'The conditions source to edit (from get_collection sources). Required for the condition fields below.',
+ required: false,
+ }),
+ match_type: Property.StaticDropdown({
+ displayName: 'Match',
+ description: 'Switch the source between matching all conditions or any of them.',
+ required: false,
+ options: {
+ options: [
+ { label: 'All conditions', value: 'ALL' },
+ { label: 'Any condition', value: 'ANY' },
+ ],
+ },
+ }),
+ conditions_to_add: shopifyProps.conditions({
+ required: false,
+ description: 'New conditions to add to the source. Existing conditions are kept.',
+ }),
+ condition_ids_to_delete: Property.Array({
+ displayName: 'Condition IDs to Delete',
+ description: 'Ids of conditions to remove (from get_collection sources[].conditions).',
+ required: false,
+ }),
+ currency: Property.ShortText({
+ displayName: 'Currency',
+ description: 'Shop currency code for new price conditions, for example "USD".',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const conditionsToCreate = shopifyValues.buildConditions({
+ value: propsValue.conditions_to_add,
+ currency: shopifyValues.nonEmpty(propsValue.currency)?.toUpperCase(),
+ });
+ const conditionsToDelete = shopifyValues.readStringList(propsValue.condition_ids_to_delete) ?? [];
+ const inclusion = shopifyValues.compact({
+ matchType: propsValue.match_type,
+ conditionsToCreate: conditionsToCreate.length > 0 ? conditionsToCreate : undefined,
+ conditionsToDelete: conditionsToDelete.length > 0 ? conditionsToDelete : undefined,
+ });
+ const rawSourceId = shopifyValues.nonEmpty(propsValue.source_id);
+ const sourceId = rawSourceId
+ ? shopifyGraphqlClient.toGid({ type: 'CollectionConditionsSource', id: rawSourceId })
+ : undefined;
+ if (Object.keys(inclusion).length > 0 && !sourceId) {
+ throw new Error('Set source_id (from get_collection sources) to change conditions or the match type.');
+ }
+ const id = shopifyGraphqlClient.toGid({ type: 'Collection', id: propsValue.collection_id });
+ if (rawSourceId && Object.keys(inclusion).length > 0) {
+ const lookup = await shopifyGraphqlClient.request<{ collection: GqlCollection | null }>({
+ auth,
+ query: `query UpdateCollectionSources($id: ID!) { collection(id: $id) { ${shopifyFields.COLLECTION_SOURCE_LOOKUP_FIELDS} } }`,
+ variables: { id },
+ });
+ if (!lookup.data.collection) {
+ throw new Error(`Collection ${id} was not found.`);
+ }
+ shopifyValues.findConditionsSource({ collection: lookup.data.collection, sourceId: rawSourceId });
+ }
+ const seo = await shopifyValues.mergeSeo({
+ auth,
+ id,
+ title: propsValue.seo_title,
+ description: propsValue.seo_description,
+ });
+ const imageUrl = shopifyValues.nonEmpty(propsValue.image_url);
+ const patch = shopifyValues.compact({
+ title: shopifyValues.nonEmpty(propsValue.title),
+ descriptionHtml: shopifyValues.nonEmpty(propsValue.description_html),
+ handle: shopifyValues.nonEmpty(propsValue.handle),
+ redirectNewHandle: shopifyValues.toBooleanChoice(propsValue.redirect_new_handle),
+ sortOrder: propsValue.sort_order,
+ templateSuffix: shopifyValues.nonEmpty(propsValue.template_suffix),
+ image: imageUrl
+ ? shopifyValues.compact({ src: imageUrl, altText: shopifyValues.nonEmpty(propsValue.image_alt) })
+ : undefined,
+ seo,
+ sourcesToUpdate:
+ sourceId && Object.keys(inclusion).length > 0
+ ? [{ condition: { id: sourceId, inclusion } }]
+ : undefined,
+ });
+ if (Object.keys(patch).length === 0) {
+ throw new Error('Provide at least one field to update.');
+ }
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ collectionUpdate: { collection: GqlCollection | null; job: GqlJob | null } | null;
+ }>({
+ auth,
+ query: `mutation UpdateCollection($collection: CollectionUpdateInput!) { collectionUpdate(collection: $collection) { collection { ${shopifyFields.COLLECTION_FIELDS} } job { id done } userErrors { field message } } }`,
+ variables: { collection: { id, ...patch } },
+ });
+ const collection = data.collectionUpdate?.collection;
+ if (!collection) {
+ throw new Error(`Collection ${id} was not returned by Shopify.`);
+ }
+ return {
+ ...shopifyMappers.mapCollection(collection),
+ job_id: data.collectionUpdate?.job?.id ?? null,
+ job_done: data.collectionUpdate?.job?.done ?? null,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/update-inventory-item.ts b/packages/pieces/community/shopify/src/lib/actions/ai/update-inventory-item.ts
new file mode 100644
index 00000000000..31e5ab070a2
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/update-inventory-item.ts
@@ -0,0 +1,126 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlInventoryItem,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { inventoryItemOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiUpdateInventoryItem = createAction({
+ auth: shopifyAuth,
+ name: 'update_inventory_item',
+ classification: 'WRITE',
+ displayName: 'Update Inventory Item',
+ description: 'Change the SKU, unit cost, tracking, shipping, weight or customs data of an inventory item.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Changes one inventory item; fields left empty are not sent and keep their values. Turning tracking off stops Shopify from counting stock for the variant. Quantities are not changed here; use set_inventory_quantities or adjust_inventory_quantities. Needs the write_inventory access scope. Re-running with the same values is safe.',
+ idempotent: true,
+ },
+ outputSchema: inventoryItemOutputSchema,
+ props: {
+ inventory_item_id: Property.ShortText({
+ displayName: 'Inventory Item ID',
+ description: 'The inventory item id, numeric or "gid://shopify/InventoryItem/…" (from get_product_variant_details).',
+ required: true,
+ }),
+ sku: Property.ShortText({
+ displayName: 'SKU',
+ description: 'New SKU, for example "TSHIRT-RED-L".',
+ required: false,
+ }),
+ cost: Property.Number({
+ displayName: 'Unit Cost',
+ description: 'New unit cost in the shop currency, for example 7.50.',
+ required: false,
+ }),
+ tracked: shopifyProps.booleanChoice({
+ displayName: 'Track Quantity',
+ description: 'Whether Shopify tracks stock for this item. Leave empty to keep the current setting.',
+ }),
+ requires_shipping: shopifyProps.booleanChoice({
+ displayName: 'Requires Shipping',
+ description: 'Whether the item is a physical product that needs shipping. Leave empty to keep the current setting.',
+ }),
+ country_code_of_origin: Property.ShortText({
+ displayName: 'Country of Origin',
+ description: 'Two-letter ISO country code where the item was made, for example "CN".',
+ required: false,
+ }),
+ province_code_of_origin: Property.ShortText({
+ displayName: 'Province of Origin',
+ description: 'Province or state code of origin, for example "ON".',
+ required: false,
+ }),
+ harmonized_system_code: Property.ShortText({
+ displayName: 'HS Code',
+ description: 'Harmonized System code for customs, for example "6109.10".',
+ required: false,
+ }),
+ weight_value: Property.Number({
+ displayName: 'Weight',
+ description: 'Item weight, for example 0.25. Set together with the weight unit.',
+ required: false,
+ }),
+ weight_unit: Property.StaticDropdown({
+ displayName: 'Weight Unit',
+ description: 'Unit of the weight.',
+ required: false,
+ options: {
+ options: [
+ { label: 'Kilograms', value: 'KILOGRAMS' },
+ { label: 'Grams', value: 'GRAMS' },
+ { label: 'Pounds', value: 'POUNDS' },
+ { label: 'Ounces', value: 'OUNCES' },
+ ],
+ },
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const weightValue = shopifyValues.readNumber(propsValue.weight_value);
+ const weightUnit = propsValue.weight_unit;
+ if ((weightValue === undefined) !== (weightUnit === undefined || weightUnit === null)) {
+ throw new Error('Set both weight_value and weight_unit to change the weight.');
+ }
+ const countryCode = shopifyValues.nonEmpty(propsValue.country_code_of_origin)?.toUpperCase();
+ if (countryCode !== undefined && !/^[A-Z]{2}$/.test(countryCode)) {
+ throw new Error('country_code_of_origin must be a two-letter ISO country code, for example "CN".');
+ }
+ const cost = shopifyValues.readNumber(propsValue.cost);
+ const input = shopifyValues.compact({
+ sku: shopifyValues.nonEmpty(propsValue.sku),
+ cost: cost !== undefined ? String(cost) : undefined,
+ tracked: shopifyValues.toBooleanChoice(propsValue.tracked),
+ requiresShipping: shopifyValues.toBooleanChoice(propsValue.requires_shipping),
+ countryCodeOfOrigin: countryCode,
+ provinceCodeOfOrigin: shopifyValues.nonEmpty(propsValue.province_code_of_origin),
+ harmonizedSystemCode: shopifyValues.nonEmpty(propsValue.harmonized_system_code),
+ measurement:
+ weightValue !== undefined && weightUnit ? { weight: { value: weightValue, unit: weightUnit } } : undefined,
+ });
+ if (Object.keys(input).length === 0) {
+ throw new Error('Provide at least one field to update.');
+ }
+ const id = shopifyGraphqlClient.toGid({ type: 'InventoryItem', id: propsValue.inventory_item_id });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ inventoryItemUpdate: { inventoryItem: GqlInventoryItem | null } | null;
+ }>({
+ auth,
+ query: `mutation UpdateInventoryItem($id: ID!, $input: InventoryItemInput!) { inventoryItemUpdate(id: $id, input: $input) { inventoryItem { ${shopifyFields.INVENTORY_ITEM_FIELDS} } userErrors { field message } } }`,
+ variables: { id, input },
+ });
+ const item = data.inventoryItemUpdate?.inventoryItem;
+ if (!item) {
+ throw new Error(`Inventory item ${id} was not returned by Shopify.`);
+ }
+ return {
+ ...shopifyMappers.mapInventoryItem(item),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/update-product-fields.ts b/packages/pieces/community/shopify/src/lib/actions/ai/update-product-fields.ts
new file mode 100644
index 00000000000..8501f09f607
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/update-product-fields.ts
@@ -0,0 +1,137 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlProduct,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { productDetailOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiUpdateProductFields = createAction({
+ auth: shopifyAuth,
+ name: 'update_product_fields',
+ classification: 'WRITE',
+ displayName: 'Update Product',
+ description: 'Change the title, description, vendor, type, status, handle, tags, category, SEO or collections of a product.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Changes one product; fields left empty are not sent and keep their values, and variants, options and media are never touched. Sending tags replaces all tags, so use add_tags or remove_tags for single tags. Setting status to ACTIVE makes the product visible on its sales channels. Re-running with the same values is safe.',
+ idempotent: true,
+ },
+ outputSchema: productDetailOutputSchema,
+ props: {
+ product_id: Property.ShortText({
+ displayName: 'Product ID',
+ description: 'The product id, numeric or "gid://shopify/Product/…". Find it with search_products.',
+ required: true,
+ }),
+ title: Property.ShortText({
+ displayName: 'Title',
+ description: 'New product title.',
+ required: false,
+ }),
+ description_html: Property.LongText({
+ displayName: 'Description (HTML)',
+ description: 'New description, HTML allowed. Replaces the existing description.',
+ required: false,
+ }),
+ vendor: Property.ShortText({
+ displayName: 'Vendor',
+ description: 'New vendor name.',
+ required: false,
+ }),
+ product_type: Property.ShortText({
+ displayName: 'Product Type',
+ description: 'New product type.',
+ required: false,
+ }),
+ status: shopifyProps.productStatus({
+ description: 'New status. Leave empty to keep the current status.',
+ }),
+ handle: Property.ShortText({
+ displayName: 'Handle',
+ description: 'New URL handle, for example "organic-cotton-t-shirt".',
+ required: false,
+ }),
+ redirect_new_handle: shopifyProps.booleanChoice({
+ displayName: 'Redirect Old Handle',
+ description: 'When changing the handle, create a redirect from the old URL. Leave empty for the Shopify default.',
+ }),
+ tags: Property.Array({
+ displayName: 'Tags',
+ description: 'The complete new tag list. Replaces every existing tag; leave empty to keep the current tags.',
+ required: false,
+ }),
+ category_id: Property.ShortText({
+ displayName: 'Category ID',
+ description: 'New taxonomy category id, for example "gid://shopify/TaxonomyCategory/aa-1-13-8".',
+ required: false,
+ }),
+ collections_to_join: Property.Array({
+ displayName: 'Collections to Join',
+ description: 'Collection ids to add the product to, numeric or "gid://shopify/Collection/…".',
+ required: false,
+ }),
+ collections_to_leave: Property.Array({
+ displayName: 'Collections to Leave',
+ description: 'Collection ids to remove the product from.',
+ required: false,
+ }),
+ seo_title: Property.ShortText({
+ displayName: 'SEO Title',
+ description: 'New page title for search engines.',
+ required: false,
+ }),
+ seo_description: Property.LongText({
+ displayName: 'SEO Description',
+ description: 'New meta description for search engines.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'Product', id: propsValue.product_id });
+ const tags = shopifyValues.readStringList(propsValue.tags);
+ const seo = await shopifyValues.mergeSeo({
+ auth,
+ id,
+ title: propsValue.seo_title,
+ description: propsValue.seo_description,
+ });
+ const patch = shopifyValues.compact({
+ title: shopifyValues.nonEmpty(propsValue.title),
+ descriptionHtml: shopifyValues.nonEmpty(propsValue.description_html),
+ vendor: shopifyValues.nonEmpty(propsValue.vendor),
+ productType: shopifyValues.nonEmpty(propsValue.product_type),
+ status: propsValue.status,
+ handle: shopifyValues.nonEmpty(propsValue.handle),
+ redirectNewHandle: shopifyValues.toBooleanChoice(propsValue.redirect_new_handle),
+ tags: tags && tags.length > 0 ? tags : undefined,
+ category: shopifyValues.toCategoryGid(propsValue.category_id),
+ collectionsToJoin: shopifyValues.toGidList({ type: 'Collection', value: propsValue.collections_to_join }),
+ collectionsToLeave: shopifyValues.toGidList({ type: 'Collection', value: propsValue.collections_to_leave }),
+ seo,
+ });
+ if (Object.keys(patch).length === 0) {
+ throw new Error('Provide at least one field to update.');
+ }
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ productUpdate: { product: GqlProduct | null } | null;
+ }>({
+ auth,
+ query: `mutation UpdateProductFields($product: ProductUpdateInput!) { productUpdate(product: $product) { product { ${shopifyFields.PRODUCT_DETAIL_FIELDS} } userErrors { field message } } }`,
+ variables: { product: { id, ...patch } },
+ });
+ const product = data.productUpdate?.product;
+ if (!product) {
+ throw new Error(`Product ${id} was not returned by Shopify.`);
+ }
+ return {
+ ...shopifyMappers.mapProductDetail(product),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/update-product-media.ts b/packages/pieces/community/shopify/src/lib/actions/ai/update-product-media.ts
new file mode 100644
index 00000000000..9655c69225d
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/update-product-media.ts
@@ -0,0 +1,80 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import { shopifyGraphqlClient, shopifyValues } from '../../common/graphql';
+import { updateProductMediaOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiUpdateProductMedia = createAction({
+ auth: shopifyAuth,
+ name: 'update_product_media',
+ classification: 'WRITE',
+ displayName: 'Update Product Media',
+ description: 'Change the alt text, filename or image of an existing media file.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Changes one existing media file: its alt text, its filename (the extension must stay the same) or, for images, replaces the file content from a public URL while keeping the same media id. Fields left empty keep their values. The file must be in READY state. Needs the write_files (or write_themes) access scope. Re-running with the same values is safe.',
+ idempotent: true,
+ },
+ outputSchema: updateProductMediaOutputSchema,
+ props: {
+ media_id: Property.ShortText({
+ displayName: 'Media ID',
+ description: 'The media id, for example "gid://shopify/MediaImage/1072273219". Find it with list_product_media.',
+ required: true,
+ }),
+ alt: Property.ShortText({
+ displayName: 'Alt Text',
+ description: 'New accessible description, for example "Red t-shirt, back view".',
+ required: false,
+ }),
+ filename: Property.ShortText({
+ displayName: 'Filename',
+ description: 'New filename with the same extension, for example "red-shirt-back.jpg".',
+ required: false,
+ }),
+ replacement_url: Property.ShortText({
+ displayName: 'Replacement Image URL',
+ description: 'Public URL of a new image that replaces the file content, for example "https://example.com/new.jpg". Images only.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const patch = shopifyValues.compact({
+ alt: shopifyValues.nonEmpty(propsValue.alt),
+ filename: shopifyValues.nonEmpty(propsValue.filename),
+ originalSource: shopifyValues.nonEmpty(propsValue.replacement_url),
+ });
+ if (Object.keys(patch).length === 0) {
+ throw new Error('Provide at least one field to update.');
+ }
+ const id = shopifyGraphqlClient.toGid({ type: 'MediaImage', id: propsValue.media_id });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ fileUpdate: {
+ files:
+ | {
+ id?: string | null;
+ alt?: string | null;
+ fileStatus?: string | null;
+ updatedAt?: string | null;
+ image?: { url?: string | null } | null;
+ preview?: { image?: { url?: string | null } | null } | null;
+ }[]
+ | null;
+ } | null;
+ }>({
+ auth,
+ query: `mutation UpdateProductMedia($files: [FileUpdateInput!]!) { fileUpdate(files: $files) { files { id alt fileStatus updatedAt preview { image { url } } ... on MediaImage { image { url } } } userErrors { field message code } } }`,
+ variables: { files: [{ id, ...patch }] },
+ });
+ const file = data.fileUpdate?.files?.[0];
+ return {
+ id: file?.id ?? id,
+ alt: file?.alt ?? null,
+ file_status: file?.fileStatus ?? null,
+ image_url: file?.image?.url ?? null,
+ preview_url: file?.preview?.image?.url ?? null,
+ updated_at: file?.updatedAt ?? null,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/update-product-option.ts b/packages/pieces/community/shopify/src/lib/actions/ai/update-product-option.ts
new file mode 100644
index 00000000000..d427b7bc041
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/update-product-option.ts
@@ -0,0 +1,133 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlProduct,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyValues,
+} from '../../common/graphql';
+import { productDetailOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiUpdateProductOption = createAction({
+ auth: shopifyAuth,
+ name: 'update_product_option',
+ classification: 'WRITE',
+ displayName: 'Update Product Option',
+ description: 'Rename or move a product option and add, rename or delete its values.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Changes one product option: its name or position, and its values through explicit changes only (values to add, values to rename by id, value ids to delete). Values not mentioned stay as they are. Deleting a value that variants use needs variant_strategy MANAGE, which also removes those variants. Option and value ids come from get_product_details. Renaming to the same name again is safe; adding a value twice fails.',
+ idempotent: false,
+ },
+ outputSchema: productDetailOutputSchema,
+ props: {
+ product_id: Property.ShortText({
+ displayName: 'Product ID',
+ description: 'The product id, numeric or "gid://shopify/Product/…".',
+ required: true,
+ }),
+ option_id: Property.ShortText({
+ displayName: 'Option ID',
+ description: 'The option id, for example "gid://shopify/ProductOption/1064576516". Find it with get_product_details.',
+ required: true,
+ }),
+ name: Property.ShortText({
+ displayName: 'New Name',
+ description: 'New option name, for example "Colour".',
+ required: false,
+ }),
+ position: Property.Number({
+ displayName: 'New Position',
+ description: 'New position of the option, starting at 1.',
+ required: false,
+ }),
+ values_to_add: Property.Array({
+ displayName: 'Values to Add',
+ description: 'New values for this option, for example ["Purple"].',
+ required: false,
+ }),
+ values_to_rename: Property.Array({
+ displayName: 'Values to Rename',
+ description: 'Existing values to rename.',
+ required: false,
+ properties: {
+ value_id: Property.ShortText({
+ displayName: 'Value ID',
+ description: 'The option value id, for example "gid://shopify/ProductOptionValue/1054672275".',
+ required: true,
+ }),
+ name: Property.ShortText({
+ displayName: 'New Name',
+ description: 'New value name, for example "Navy".',
+ required: true,
+ }),
+ },
+ }),
+ value_ids_to_delete: Property.Array({
+ displayName: 'Value IDs to Delete',
+ description: 'Ids of option values to delete.',
+ required: false,
+ }),
+ variant_strategy: Property.StaticDropdown({
+ displayName: 'Variant Strategy',
+ description: 'How variants follow value changes. Leave empty for the Shopify default (leave variants as they are).',
+ required: false,
+ options: {
+ options: [
+ { label: 'Leave variants as they are', value: 'LEAVE_AS_IS' },
+ { label: 'Manage variants (create and delete as needed)', value: 'MANAGE' },
+ ],
+ },
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const productId = shopifyGraphqlClient.toGid({ type: 'Product', id: propsValue.product_id });
+ const optionId = shopifyGraphqlClient.toGid({ type: 'ProductOption', id: propsValue.option_id });
+ const valuesToAdd = (shopifyValues.readStringList(propsValue.values_to_add) ?? []).map((name) => ({ name }));
+ const valuesToRename = shopifyValues.readRecords(propsValue.values_to_rename).map((item) => {
+ const valueId = shopifyValues.readText(item['value_id']);
+ const name = shopifyValues.readText(item['name']);
+ if (!valueId || !name) {
+ throw new Error('Every value to rename needs a value_id and a name.');
+ }
+ return { id: shopifyGraphqlClient.toGid({ type: 'ProductOptionValue', id: valueId }), name };
+ });
+ const valueIdsToDelete = shopifyValues.toGidList({ type: 'ProductOptionValue', value: propsValue.value_ids_to_delete });
+ const optionPatch = shopifyValues.compact({
+ name: shopifyValues.nonEmpty(propsValue.name),
+ position: shopifyValues.readNumber(propsValue.position),
+ });
+ if (
+ Object.keys(optionPatch).length === 0 &&
+ valuesToAdd.length === 0 &&
+ valuesToRename.length === 0 &&
+ !valueIdsToDelete
+ ) {
+ throw new Error('Provide at least one change: a new name, a position, or values to add, rename or delete.');
+ }
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ productOptionUpdate: { product: GqlProduct | null } | null;
+ }>({
+ auth,
+ query: `mutation UpdateProductOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!], $variantStrategy: ProductOptionUpdateVariantStrategy) { productOptionUpdate(productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete, variantStrategy: $variantStrategy) { product { ${shopifyFields.PRODUCT_DETAIL_FIELDS} } userErrors { field message code } } }`,
+ variables: shopifyValues.compact({
+ productId,
+ option: { id: optionId, ...optionPatch },
+ optionValuesToAdd: valuesToAdd.length > 0 ? valuesToAdd : undefined,
+ optionValuesToUpdate: valuesToRename.length > 0 ? valuesToRename : undefined,
+ optionValuesToDelete: valueIdsToDelete,
+ variantStrategy: propsValue.variant_strategy,
+ }),
+ });
+ const product = data.productOptionUpdate?.product;
+ if (!product) {
+ throw new Error(`Product ${productId} was not returned by Shopify.`);
+ }
+ return {
+ ...shopifyMappers.mapProductDetail(product),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/update-product-variants.ts b/packages/pieces/community/shopify/src/lib/actions/ai/update-product-variants.ts
new file mode 100644
index 00000000000..6e976228103
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/update-product-variants.ts
@@ -0,0 +1,55 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlVariant,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { variantListOutputSchema } from '../../output-schemas/products';
+
+export const shopifyAiUpdateProductVariants = createAction({
+ auth: shopifyAuth,
+ name: 'update_product_variants',
+ classification: 'WRITE',
+ displayName: 'Update Product Variants',
+ description: 'Change the price, SKU, barcode, stock policy or option values of one or more variants of a product.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Changes one or many variants of the same product in one call; fields left empty are not sent and keep their values. All-or-nothing: if any variant is invalid, nothing is changed. Stock quantities are not changed here; use set_inventory_quantities or adjust_inventory_quantities. Variant ids come from list_product_variants. Re-running with the same values is safe.',
+ idempotent: true,
+ },
+ outputSchema: variantListOutputSchema,
+ props: {
+ product_id: Property.ShortText({
+ displayName: 'Product ID',
+ description: 'The product the variants belong to, numeric or "gid://shopify/Product/…".',
+ required: true,
+ }),
+ variants: shopifyProps.variants({ mode: 'update' }),
+ },
+ async run({ auth, propsValue }) {
+ const productId = shopifyGraphqlClient.toGid({ type: 'Product', id: propsValue.product_id });
+ const variants = shopifyValues.buildVariantInputs({ value: propsValue.variants, mode: 'update' });
+ if (variants.length === 0) {
+ throw new Error('Provide at least one variant to update.');
+ }
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ productVariantsBulkUpdate: { productVariants: GqlVariant[] | null; product: { id: string } | null } | null;
+ }>({
+ auth,
+ query: `mutation UpdateProductVariants($productId: ID!, $variants: [ProductVariantsBulkInput!]!) { productVariantsBulkUpdate(productId: $productId, variants: $variants, allowPartialUpdates: false) { product { id } productVariants { ${shopifyFields.VARIANT_FIELDS} } userErrors { field message code } } }`,
+ variables: { productId, variants },
+ });
+ const items = (data.productVariantsBulkUpdate?.productVariants ?? []).map(shopifyMappers.mapVariant);
+ return {
+ product_id: data.productVariantsBulkUpdate?.product?.id ?? productId,
+ variants: items,
+ count: items.length,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/update-product.ts b/packages/pieces/community/shopify/src/lib/actions/update-product.ts
index 42861c4ae5d..6a63e912bfe 100644
--- a/packages/pieces/community/shopify/src/lib/actions/update-product.ts
+++ b/packages/pieces/community/shopify/src/lib/actions/update-product.ts
@@ -6,11 +6,11 @@ import { ShopifyImage, ShopifyProductStatuses } from '../common/types';
export const updateProductAction = createAction({
auth: shopifyAuth,
name: 'update_product',
- classification: 'WRITE',
+ classification: 'DESTRUCTIVE',
displayName: 'Update Product',
description: 'Update an existing product.',
audience: 'both',
- aiMetadata: { description: 'Update fields on an existing Shopify product by product ID (title, description, type, vendor, tags, status, and an optional image). Pick this to edit a known product rather than creating one; the product ID is required. Sets absolute field values, so re-running with the same input is idempotent (though a supplied image is appended each time).', idempotent: true },
+ aiMetadata: { description: 'Update fields on an existing Shopify product by product ID (title, description, type, vendor, tags, status, and an optional image). Pick this to edit a known product rather than creating one; the product ID is required. Sets absolute field values, but a supplied image is appended on every call, so repeating a call that includes an image adds duplicate images.', idempotent: false },
props: {
id: Property.ShortText({
displayName: 'Product',
diff --git a/packages/pieces/community/shopify/src/lib/common/auth.ts b/packages/pieces/community/shopify/src/lib/common/auth.ts
index 676083016c2..15ad5e9b2f0 100644
--- a/packages/pieces/community/shopify/src/lib/common/auth.ts
+++ b/packages/pieces/community/shopify/src/lib/common/auth.ts
@@ -23,7 +23,7 @@ You can find your shop name in the URL. For example, if the URL is \`https://exa
1. Log in to your Shopify admin.
2. Go to **Settings** -> **Apps and sales channels** -> **Develop apps**.
3. Open your existing custom app.
-4. Under **Configuration**, check that the Admin API scopes include: \`read_orders\`, \`write_orders\`, \`read_customers\`, \`write_customers\`, \`read_products\`, \`write_products\`, \`read_draft_orders\`, \`write_draft_orders\`, \`read_locations\`, \`read_inventory\`, \`write_inventory\`, \`read_themes\`, \`write_fulfillments\`.
+4. Under **Configuration**, check that the Admin API scopes include: \`read_orders\`, \`write_orders\`, \`read_customers\`, \`write_customers\`, \`read_products\`, \`write_products\`, \`read_draft_orders\`, \`write_draft_orders\`, \`read_locations\`, \`read_inventory\`, \`write_inventory\`, \`read_themes\`, \`write_fulfillments\`, \`read_publications\`, \`write_publications\`, \`write_files\`.
5. Under **API credentials**, copy the **Admin API access token**.
`;
@@ -33,7 +33,7 @@ Use this option for apps created in the Shopify **Dev Dashboard** (all new apps
**Important:** the app and the store must belong to the **same Shopify organization**, otherwise Shopify rejects the connection.
1. Go to the [Shopify Dev Dashboard](https://dev.shopify.com/dashboard) and click **Create app**. Give it a name.
-2. Create a version of the app and, under **Access** -> **Scopes**, select these Admin API scopes: \`read_orders\`, \`write_orders\`, \`read_customers\`, \`write_customers\`, \`read_products\`, \`write_products\`, \`read_draft_orders\`, \`write_draft_orders\`, \`read_locations\`, \`read_inventory\`, \`write_inventory\`, \`read_themes\`, \`write_fulfillments\`.
+2. Create a version of the app and, under **Access** -> **Scopes**, select these Admin API scopes: \`read_orders\`, \`write_orders\`, \`read_customers\`, \`write_customers\`, \`read_products\`, \`write_products\`, \`read_draft_orders\`, \`write_draft_orders\`, \`read_locations\`, \`read_inventory\`, \`write_inventory\`, \`read_themes\`, \`write_fulfillments\`, \`read_publications\`, \`write_publications\`, \`write_files\`.
3. Release a version with these scopes and install/approve it on the store: from the app's **Home** page, click **Install app** and install it on your store (reinstall it if it was installed before the scopes were added). The store must be in the same organization as the app.
4. Open the app's **Settings** page and copy the **Client ID** and **Client secret**.
5. Enter your shop name below (for \`https://example.myshopify.com\`, enter **example**), then paste the client ID and client secret.
diff --git a/packages/pieces/community/shopify/src/lib/common/graphql.ts b/packages/pieces/community/shopify/src/lib/common/graphql.ts
index d9faa696b45..0280924138f 100644
--- a/packages/pieces/community/shopify/src/lib/common/graphql.ts
+++ b/packages/pieces/community/shopify/src/lib/common/graphql.ts
@@ -20,14 +20,27 @@ async function shopifyGraphql<TData>(
}
const { data, error } = await tryCatch(() => sendGraphqlRequest<TData>(params));
if (error) {
- const hint = error.message.startsWith(WITHHELD_RESULT_PREFIX)
- ? `[idempotency_key used: ${idempotencyKey}.]`
- : `[idempotency_key used: ${idempotencyKey}. Retry with this same idempotency_key so Shopify does not repeat the operation.]`;
- throw new Error(`${error.message} ${hint}`);
+ throw new Error(`${error.message} ${idempotencyHint({ message: error.message, idempotencyKey })}`);
}
return data;
}
+function idempotencyHint({
+ message,
+ idempotencyKey,
+}: {
+ message: string;
+ idempotencyKey: string;
+}): string {
+ if (message.startsWith(WITHHELD_RESULT_PREFIX)) {
+ return `[idempotency_key used: ${idempotencyKey}.]`;
+ }
+ if (message.includes('CHANGE_FROM_QUANTITY_STALE')) {
+ return `[idempotency_key used: ${idempotencyKey}. The current quantity changed since it was read: read it again with list_inventory_levels and retry with the new expected_quantity and a new idempotency_key.]`;
+ }
+ return `[idempotency_key used: ${idempotencyKey}. Retry with this same idempotency_key so Shopify does not repeat the operation.]`;
+}
+
async function sendGraphqlRequest<TData>({
auth,
query,
@@ -339,6 +352,14 @@ function toGid({ type, id, query }: ToGidParams): string {
return value;
}
+function toOpaqueGid({ type, id }: { type: string; id: string }): string {
+ const value = id.trim();
+ if (value.length === 0 || value.startsWith('gid://')) {
+ return value;
+ }
+ return `gid://shopify/${type}/${value}`;
+}
+
function resolveIdempotencyKey(value: string | undefined | null): string {
const trimmed = (value ?? '').trim();
return trimmed.length > 0 ? trimmed : randomUUID();
@@ -1099,6 +1120,825 @@ function idempotencyKeyProp() {
});
}
+function mapProductSummary(product: GqlProduct) {
+ return {
+ id: product.id,
+ legacy_resource_id: product.legacyResourceId ?? null,
+ title: product.title ?? null,
+ handle: product.handle ?? null,
+ status: product.status ?? null,
+ vendor: product.vendor ?? null,
+ product_type: product.productType ?? null,
+ tags: joinTags(product.tags),
+ created_at: product.createdAt ?? null,
+ updated_at: product.updatedAt ?? null,
+ published_at: product.publishedAt ?? null,
+ total_inventory: product.totalInventory ?? null,
+ tracks_inventory: product.tracksInventory ?? null,
+ has_only_default_variant: product.hasOnlyDefaultVariant ?? null,
+ variants_count: product.variantsCount?.count ?? null,
+ media_count: product.mediaCount?.count ?? null,
+ min_price: product.priceRangeV2?.minVariantPrice?.amount ?? null,
+ max_price: product.priceRangeV2?.maxVariantPrice?.amount ?? null,
+ currency_code: product.priceRangeV2?.minVariantPrice?.currencyCode ?? null,
+ featured_media_id: product.featuredMedia?.id ?? null,
+ featured_image_url: product.featuredMedia?.preview?.image?.url ?? null,
+ category_id: product.category?.id ?? null,
+ category_name: product.category?.fullName ?? null,
+ };
+}
+
+function mapProductDetail(product: GqlProduct) {
+ return {
+ ...mapProductSummary(product),
+ description_html: product.descriptionHtml ?? null,
+ template_suffix: product.templateSuffix ?? null,
+ seo_title: product.seo?.title ?? null,
+ seo_description: product.seo?.description ?? null,
+ is_gift_card: product.isGiftCard ?? null,
+ requires_selling_plan: product.requiresSellingPlan ?? null,
+ options: (product.options ?? []).map(mapProductOption),
+ variants: (product.variants?.nodes ?? []).map(mapVariant),
+ variants_has_more: product.variants?.pageInfo?.hasNextPage ?? false,
+ media: (product.media?.nodes ?? []).map(mapMedia),
+ media_has_more: product.media?.pageInfo?.hasNextPage ?? false,
+ };
+}
+
+function mapProductOption(option: GqlProductOption) {
+ return {
+ id: option.id,
+ name: option.name ?? null,
+ position: option.position ?? null,
+ values: (option.optionValues ?? []).map((value) => ({
+ id: value.id,
+ name: value.name ?? null,
+ has_variants: value.hasVariants ?? null,
+ })),
+ };
+}
+
+function toBarcodes({
+ value,
+ type,
+}: {
+ value: string | undefined;
+ type: string | undefined;
+}): { value: string; type?: string }[] | undefined {
+ if (value === undefined) {
+ if (type !== undefined) {
+ throw new Error('Set "barcode" when giving a barcode_type.');
+ }
+ return undefined;
+ }
+ return [type === undefined ? { value } : { value, type }];
+}
+
+function barcodeTypeProp() {
+ return Property.StaticDropdown({
+ displayName: 'Barcode Type',
+ description: 'The standard the barcode follows. Shopify then checks its format. Leave empty to store the value as entered.',
+ required: false,
+ options: {
+ options: BARCODE_TYPES.map((type) => ({ label: type, value: type })),
+ },
+ });
+}
+
+function mapVariant(variant: GqlVariant) {
+ return {
+ id: variant.id,
+ legacy_resource_id: variant.legacyResourceId ?? null,
+ title: variant.title ?? null,
+ display_name: variant.displayName ?? null,
+ sku: variant.sku ?? null,
+ barcode: variant.barcodes?.nodes?.[0]?.value ?? null,
+ barcodes: (variant.barcodes?.nodes ?? []).map((barcode) => ({
+ value: barcode.value,
+ type: barcode.type ?? null,
+ })),
+ price: variant.price ?? null,
+ compare_at_price: variant.compareAtPrice ?? null,
+ position: variant.position ?? null,
+ inventory_quantity: variant.inventoryQuantity ?? null,
+ inventory_policy: variant.inventoryPolicy ?? null,
+ available_for_sale: variant.availableForSale ?? null,
+ taxable: variant.taxable ?? null,
+ selected_options: (variant.selectedOptions ?? []).map((option) => ({
+ name: option.name ?? null,
+ value: option.value ?? null,
+ })),
+ inventory_item_id: variant.inventoryItem?.id ?? null,
+ inventory_tracked: variant.inventoryItem?.tracked ?? null,
+ requires_shipping: variant.inventoryItem?.requiresShipping ?? null,
+ product_id: variant.product?.id ?? null,
+ product_title: variant.product?.title ?? null,
+ created_at: variant.createdAt ?? null,
+ updated_at: variant.updatedAt ?? null,
+ };
+}
+
+function mapMedia(media: GqlMedia) {
+ const errors = (media.mediaErrors ?? [])
+ .map((error) => error.message ?? error.code ?? '')
+ .filter((message) => message.length > 0);
+ return {
+ id: media.id ?? null,
+ alt: media.alt ?? null,
+ media_content_type: media.mediaContentType ?? null,
+ status: media.status ?? null,
+ image_url: media.image?.url ?? null,
+ width: media.image?.width ?? null,
+ height: media.image?.height ?? null,
+ mime_type: media.mimeType ?? null,
+ preview_url: media.preview?.image?.url ?? null,
+ external_url: media.originUrl ?? null,
+ filename: media.filename ?? null,
+ errors: errors.length > 0 ? errors.join('; ') : null,
+ };
+}
+
+function mapCollectionSummary(collection: GqlCollection) {
+ return {
+ id: collection.id,
+ legacy_resource_id: collection.legacyResourceId ?? null,
+ title: collection.title ?? null,
+ handle: collection.handle ?? null,
+ sort_order: collection.sortOrder ?? null,
+ updated_at: collection.updatedAt ?? null,
+ products_count: collection.productsCount?.count ?? null,
+ image_url: collection.image?.url ?? null,
+ image_alt: collection.image?.altText ?? null,
+ };
+}
+
+function mapCollection(collection: GqlCollection) {
+ return {
+ ...mapCollectionSummary(collection),
+ description_html: collection.descriptionHtml ?? null,
+ template_suffix: collection.templateSuffix ?? null,
+ seo_title: collection.seo?.title ?? null,
+ seo_description: collection.seo?.description ?? null,
+ sources: (collection.sources ?? []).map((source) => {
+ const selections = source.inclusion?.selections;
+ return {
+ id: source.id,
+ title: source.title ?? null,
+ type: source.__typename === 'CollectionConditionsSource' ? 'conditions' : 'sub_collections',
+ shareable: source.shareable ?? null,
+ app_id: source.app?.id ?? null,
+ target_type: source.targetType ?? null,
+ match_type: source.inclusion?.matchType ?? null,
+ conditions: (source.inclusion?.conditions ?? []).map(mapCollectionCondition),
+ selected_products: (selections?.nodes ?? []).map((selection) => ({
+ product_id: selection.product?.id ?? null,
+ product_title: selection.product?.title ?? null,
+ variant_ids: selection.variantIds ?? null,
+ })),
+ selected_products_count: selections?.nodes?.length ?? 0,
+ selected_products_truncated: selections?.pageInfo?.hasNextPage ?? false,
+ };
+ }),
+ };
+}
+
+function mapCollectionCondition(condition: GqlCollectionCondition) {
+ const relation =
+ condition.tagRelation ??
+ condition.titleRelation ??
+ condition.typeRelation ??
+ condition.vendorRelation ??
+ condition.variantTitleRelation ??
+ condition.priceRelation ??
+ condition.compareAtPriceRelation ??
+ condition.inventoryRelation ??
+ null;
+ const textValues =
+ condition.tagValues ??
+ condition.titleValues ??
+ condition.typeValues ??
+ condition.vendorValues ??
+ condition.variantTitleValues;
+ const money = condition.priceValue ?? condition.compareAtPriceValue;
+ const values = textValues
+ ? textValues
+ : money?.amount !== undefined && money.amount !== null
+ ? [money.amount]
+ : condition.inventoryValue !== undefined && condition.inventoryValue !== null
+ ? [String(condition.inventoryValue)]
+ : [];
+ return {
+ id: condition.id,
+ kind: (condition.__typename ?? '').replace('CollectionSourceInclusionCondition', ''),
+ relation,
+ values,
+ currency_code: money?.currencyCode ?? null,
+ };
+}
+
+function findConditionsSource({
+ collection,
+ sourceId,
+}: {
+ collection: GqlCollection;
+ sourceId: string | undefined;
+}): GqlCollectionSource | undefined {
+ if (sourceId !== undefined) {
+ return findExplicitConditionsSource({ collection, sourceId });
+ }
+ return editableConditionsSources(collection)[0];
+}
+
+function findExplicitConditionsSource({
+ collection,
+ sourceId,
+}: {
+ collection: GqlCollection;
+ sourceId: string;
+}): GqlCollectionSource {
+ const sourceGid = toGid({ type: 'CollectionConditionsSource', id: sourceId });
+ const match = conditionsSources(collection).find((source) => source.id === sourceGid);
+ if (!match) {
+ throw new Error(
+ `Source ${sourceId} is not a conditions source of collection ${collection.id}. Read the collection sources with get_collection.`
+ );
+ }
+ if (match.shareable === true) {
+ throw new Error(
+ `Source ${sourceId} ("${match.title ?? ''}") is shared with other collections, so changing its picks would change those collections too. Pick a non-shared source from get_collection, or omit source_id.`
+ );
+ }
+ return match;
+}
+
+function conditionsSources(collection: GqlCollection): GqlCollectionSource[] {
+ return (collection.sources ?? []).filter((source) => source.__typename === 'CollectionConditionsSource');
+}
+
+function editableConditionsSources(collection: GqlCollection): GqlCollectionSource[] {
+ return conditionsSources(collection).filter((source) => source.shareable !== true);
+}
+
+function sharedConditionsSources(collection: GqlCollection): GqlCollectionSource[] {
+ return conditionsSources(collection).filter((source) => source.shareable === true);
+}
+
+function mapInventoryItem(item: GqlInventoryItem) {
+ const variant = item.variants?.nodes?.[0];
+ return {
+ id: item.id,
+ legacy_resource_id: item.legacyResourceId ?? null,
+ sku: item.sku ?? null,
+ tracked: item.tracked ?? null,
+ requires_shipping: item.requiresShipping ?? null,
+ unit_cost: item.unitCost?.amount ?? null,
+ unit_cost_currency: item.unitCost?.currencyCode ?? null,
+ country_code_of_origin: item.countryCodeOfOrigin ?? null,
+ province_code_of_origin: item.provinceCodeOfOrigin ?? null,
+ harmonized_system_code: item.harmonizedSystemCode ?? null,
+ weight_value: item.measurement?.weight?.value ?? null,
+ weight_unit: item.measurement?.weight?.unit ?? null,
+ locations_count: item.locationsCount?.count ?? null,
+ variant_id: variant?.id ?? null,
+ variant_title: variant?.displayName ?? null,
+ product_id: variant?.product?.id ?? null,
+ product_title: variant?.product?.title ?? null,
+ created_at: item.createdAt ?? null,
+ updated_at: item.updatedAt ?? null,
+ };
+}
+
+function mapInventoryLevel(level: GqlInventoryLevel) {
+ const quantity = (name: string): number | null =>
+ (level.quantities ?? []).find((entry) => entry.name === name)?.quantity ?? null;
+ return {
+ id: level.id,
+ is_active: level.isActive ?? null,
+ can_deactivate: level.canDeactivate ?? null,
+ deactivation_alert: level.deactivationAlert ?? null,
+ inventory_item_id: level.item?.id ?? null,
+ sku: level.item?.sku ?? null,
+ location_id: level.location?.id ?? null,
+ location_name: level.location?.name ?? null,
+ available: quantity('available'),
+ on_hand: quantity('on_hand'),
+ committed: quantity('committed'),
+ incoming: quantity('incoming'),
+ reserved: quantity('reserved'),
+ damaged: quantity('damaged'),
+ safety_stock: quantity('safety_stock'),
+ quality_control: quantity('quality_control'),
+ updated_at: level.updatedAt ?? null,
+ };
+}
+
+function mapAdjustmentGroup(group: GqlInventoryAdjustmentGroup | null | undefined) {
+ return {
+ adjustment_group_id: group?.id ?? null,
+ created_at: group?.createdAt ?? null,
+ reason: group?.reason ?? null,
+ reference_document_uri: group?.referenceDocumentUri ?? null,
+ changes: (group?.changes ?? []).map((change) => ({
+ name: change.name ?? null,
+ delta: change.delta ?? null,
+ quantity_after_change: change.quantityAfterChange ?? null,
+ ledger_document_uri: change.ledgerDocumentUri ?? null,
+ inventory_item_id: change.item?.id ?? null,
+ sku: change.item?.sku ?? null,
+ location_id: change.location?.id ?? null,
+ location_name: change.location?.name ?? null,
+ })),
+ };
+}
+
+function mapLocation(location: GqlLocation) {
+ const address = location.address;
+ return {
+ id: location.id,
+ legacy_resource_id: location.legacyResourceId ?? null,
+ name: location.name ?? null,
+ is_active: location.isActive ?? null,
+ activatable: location.activatable ?? null,
+ deactivatable: location.deactivatable ?? null,
+ deletable: location.deletable ?? null,
+ fulfills_online_orders: location.fulfillsOnlineOrders ?? null,
+ ships_inventory: location.shipsInventory ?? null,
+ has_active_inventory: location.hasActiveInventory ?? null,
+ has_unfulfilled_orders: location.hasUnfulfilledOrders ?? null,
+ is_fulfillment_service: location.isFulfillmentService ?? null,
+ deactivated_at: location.deactivatedAt ?? null,
+ address1: address?.address1 ?? null,
+ address2: address?.address2 ?? null,
+ city: address?.city ?? null,
+ province: address?.province ?? null,
+ province_code: address?.provinceCode ?? null,
+ country: address?.country ?? null,
+ country_code: address?.countryCode ?? null,
+ zip: address?.zip ?? null,
+ phone: address?.phone ?? null,
+ formatted_address: Array.isArray(address?.formatted) ? address.formatted.join(', ') : null,
+ created_at: location.createdAt ?? null,
+ updated_at: location.updatedAt ?? null,
+ };
+}
+
+function mapPublication(publication: GqlPublication) {
+ return {
+ id: publication.id,
+ title: publication.catalog?.title ?? null,
+ catalog_id: publication.catalog?.id ?? null,
+ catalog_status: publication.catalog?.status ?? null,
+ auto_publish: publication.autoPublish ?? null,
+ supports_future_publishing: publication.supportsFuturePublishing ?? null,
+ };
+}
+
+function mapChannel(publication: GqlChannelPublication) {
+ const app = publication.catalog?.apps?.nodes?.[0];
+ return {
+ name: app?.title ?? publication.catalog?.title ?? null,
+ handle: app?.handle ?? null,
+ app_id: app?.id ?? null,
+ publication_id: publication.id,
+ catalog_id: publication.catalog?.id ?? null,
+ catalog_status: publication.catalog?.status ?? null,
+ auto_publish: publication.autoPublish ?? null,
+ supports_future_publishing: publication.supportsFuturePublishing ?? null,
+ };
+}
+
+function mapTaxonomyCategory(category: GqlTaxonomyCategory) {
+ return {
+ id: category.id,
+ name: category.name ?? null,
+ full_name: category.fullName ?? null,
+ level: category.level ?? null,
+ is_leaf: category.isLeaf ?? null,
+ is_root: category.isRoot ?? null,
+ is_archived: category.isArchived ?? null,
+ parent_id: category.parentId ?? null,
+ children_ids: category.childrenIds ?? [],
+ };
+}
+
+function parseOptionValues(value: unknown): Record<string, string>[] {
+ const text = readText(value);
+ if (!text) {
+ return [];
+ }
+ return splitEscaped(text).map((pair) => {
+ const [optionName, ...rest] = pair.split('=');
+ const name = rest.join('=').trim();
+ if (!optionName || optionName.trim().length === 0 || name.length === 0) {
+ throw new Error(
+ `Option values must look like "Color=Red, Size=Large"; could not read "${pair.trim()}".`
+ );
+ }
+ return { optionName: optionName.trim(), name };
+ });
+}
+
+function splitList(value: unknown): string[] {
+ const text = readText(value);
+ if (!text) {
+ return [];
+ }
+ return splitEscaped(text)
+ .map((item) => item.trim())
+ .filter((item) => item.length > 0);
+}
+
+function splitEscaped(text: string): string[] {
+ return text
+ .split(/(?<!\\),/)
+ .map((part) => part.replace(/\\,/g, ','));
+}
+
+function buildVariantInputs({
+ value,
+ mode,
+}: {
+ value: unknown;
+ mode: 'create' | 'update';
+}): Record<string, unknown>[] {
+ return readRecords(value).map((item) => {
+ const variantId = readText(item['variant_id']);
+ if (mode === 'update' && !variantId) {
+ throw new Error('Every variant to update needs a variant_id.');
+ }
+ const optionValues = parseOptionValues(item['option_values']);
+ if (mode === 'create' && optionValues.length === 0) {
+ throw new Error('Every new variant needs option_values, for example "Color=Red, Size=Large".');
+ }
+ const price = readNumber(item['price']);
+ const compareAtPrice = readNumber(item['compare_at_price']);
+ const sku = readText(item['sku']);
+ const locationId = readText(item['location_id']);
+ const availableQuantity = readNumber(item['available_quantity']);
+ if (mode === 'create' && (locationId === undefined) !== (availableQuantity === undefined)) {
+ throw new Error('Give both location_id and available_quantity to stock a new variant, or neither.');
+ }
+ const fields = compact({
+ optionValues: optionValues.length > 0 ? optionValues : undefined,
+ price: price !== undefined ? String(price) : undefined,
+ compareAtPrice: compareAtPrice !== undefined ? String(compareAtPrice) : undefined,
+ barcodes: toBarcodes({ value: readText(item['barcode']), type: readText(item['barcode_type']) }),
+ inventoryPolicy: readText(item['inventory_policy']),
+ taxable: toBooleanChoice(item['taxable']),
+ inventoryItem: sku !== undefined ? { sku } : undefined,
+ inventoryQuantities:
+ mode === 'create' && locationId !== undefined && availableQuantity !== undefined
+ ? [
+ {
+ locationId: toGid({ type: 'Location', id: locationId }),
+ availableQuantity,
+ },
+ ]
+ : undefined,
+ });
+ if (mode === 'update') {
+ if (Object.keys(fields).length === 0) {
+ throw new Error(`Variant ${variantId}: provide at least one field to update.`);
+ }
+ return { id: toGid({ type: 'ProductVariant', id: variantId ?? '' }), ...fields };
+ }
+ return fields;
+ });
+}
+
+function variantsProp({ mode }: { mode: 'create' | 'update' }) {
+ return Property.Array({
+ displayName: 'Variants',
+ description:
+ mode === 'create'
+ ? 'The variants to create, one entry per variant. Each needs option values for every product option.'
+ : 'The variants to change, one entry per variant. Fields left empty keep their values.',
+ required: true,
+ properties: {
+ ...(mode === 'update'
+ ? {
+ variant_id: Property.ShortText({
+ displayName: 'Variant ID',
+ description: 'The variant id, numeric or "gid://shopify/ProductVariant/…". Find it with list_product_variants.',
+ required: true,
+ }),
+ }
+ : {}),
+ option_values: Property.ShortText({
+ displayName: 'Option Values',
+ description:
+ mode === 'create'
+ ? 'Option name and value pairs, for example "Color=Red, Size=Large". Write \\, for a comma inside a value. New values are added to the option.'
+ : 'Change the option values, for example "Color=Blue". Write \\, for a comma inside a value. Leave empty to keep them.',
+ required: mode === 'create',
+ }),
+ price: Property.Number({
+ displayName: 'Price',
+ description: 'Price in the shop currency, for example 19.99.',
+ required: false,
+ }),
+ compare_at_price: Property.Number({
+ displayName: 'Compare-at Price',
+ description: 'Original price shown struck through, for example 24.99.',
+ required: false,
+ }),
+ sku: Property.ShortText({
+ displayName: 'SKU',
+ description: 'Stock keeping unit, for example "TSHIRT-RED-L".',
+ required: false,
+ }),
+ barcode: Property.ShortText({
+ displayName: 'Barcode',
+ description: 'Barcode such as a UPC or ISBN. Replaces all barcodes of the variant with this one.',
+ required: false,
+ }),
+ barcode_type: barcodeTypeProp(),
+ inventory_policy: Property.StaticDropdown({
+ displayName: 'When Out of Stock',
+ description: 'Whether customers can buy the variant when it is out of stock.',
+ required: false,
+ options: {
+ options: [
+ { label: 'Stop selling (deny)', value: 'DENY' },
+ { label: 'Continue selling', value: 'CONTINUE' },
+ ],
+ },
+ }),
+ taxable: Property.StaticDropdown({
+ displayName: 'Taxable',
+ description: 'Whether taxes are charged on this variant. Leave empty to keep the current setting.',
+ required: false,
+ options: {
+ options: [
+ { label: 'Yes', value: 'true' },
+ { label: 'No', value: 'false' },
+ ],
+ },
+ }),
+ ...(mode === 'create'
+ ? {
+ location_id: Property.ShortText({
+ displayName: 'Stock Location ID',
+ description: 'Location to stock the new variant at, numeric or "gid://shopify/Location/…". Use with available_quantity.',
+ required: false,
+ }),
+ available_quantity: Property.Number({
+ displayName: 'Available Quantity',
+ description: 'Starting available quantity at the stock location, for example 10.',
+ required: false,
+ }),
+ }
+ : {}),
+ },
+ });
+}
+
+function buildConditions({
+ value,
+ currency,
+}: {
+ value: unknown;
+ currency: string | undefined;
+}): Record<string, unknown>[] {
+ return readRecords(value).map((item) => {
+ const field = readText(item['field']);
+ const relation = readText(item['relation']);
+ const conditionValue = readText(item['value']);
+ if (!field || !relation) {
+ throw new Error('Every condition needs a field and a relation.');
+ }
+ const allowed = CONDITION_RELATIONS[field];
+ if (!allowed) {
+ throw new Error(`Unknown condition field "${field}".`);
+ }
+ if (!allowed.includes(relation)) {
+ throw new Error(`Condition field "${field}" allows only these relations: ${allowed.join(', ')}.`);
+ }
+ const key = CONDITION_INPUT_KEYS[field];
+ if (TEXT_CONDITION_FIELDS.includes(field)) {
+ if (!conditionValue) {
+ throw new Error(`Condition "${field}" needs a value.`);
+ }
+ return { [key]: { relation, values: [conditionValue], matchType: 'ANY' } };
+ }
+ if (field === 'variant_inventory') {
+ const quantity = readNumber(conditionValue);
+ if (quantity === undefined || !Number.isInteger(quantity)) {
+ throw new Error('Condition "variant_inventory" needs a whole-number value.');
+ }
+ return { [key]: { relation, value: quantity } };
+ }
+ if (field === 'variant_compare_at_price' && (relation === 'IS_SET' || relation === 'IS_NOT_SET')) {
+ return { [key]: { relation } };
+ }
+ const amount = readNumber(conditionValue);
+ if (amount === undefined) {
+ throw new Error(`Condition "${field}" needs a numeric value, for example 25.`);
+ }
+ if (!currency) {
+ throw new Error('Set "currency" (for example "USD") when using a price condition.');
+ }
+ return { [key]: { relation, value: { amount: String(amount), currencyCode: currency } } };
+ });
+}
+
+function conditionsProp({ required, description }: { required: boolean; description: string }) {
+ return Property.Array({
+ displayName: 'Conditions',
+ description,
+ required,
+ properties: {
+ field: Property.StaticDropdown({
+ displayName: 'Field',
+ description: 'The product or variant field to test.',
+ required: true,
+ options: {
+ options: [
+ { label: 'Product tag', value: 'product_tag' },
+ { label: 'Product title', value: 'product_title' },
+ { label: 'Product type', value: 'product_type' },
+ { label: 'Product vendor', value: 'product_vendor' },
+ { label: 'Variant title', value: 'variant_title' },
+ { label: 'Variant price', value: 'variant_price' },
+ { label: 'Variant compare-at price', value: 'variant_compare_at_price' },
+ { label: 'Variant inventory', value: 'variant_inventory' },
+ ],
+ },
+ }),
+ relation: Property.StaticDropdown({
+ displayName: 'Relation',
+ description:
+ 'How to compare. Tags: TAGGED_WITH or NOT_TAGGED_WITH. Text fields: EQUALS, NOT_EQUALS, CONTAINS, DOES_NOT_CONTAIN, STARTS_WITH, ENDS_WITH. Prices: EQUALS, NOT_EQUALS, GREATER_THAN, LESS_THAN (compare-at price also IS_SET, IS_NOT_SET). Inventory: EQUALS, GREATER_THAN, LESS_THAN.',
+ required: true,
+ options: {
+ options: [
+ { label: 'Tagged with', value: 'TAGGED_WITH' },
+ { label: 'Not tagged with', value: 'NOT_TAGGED_WITH' },
+ { label: 'Equals', value: 'EQUALS' },
+ { label: 'Does not equal', value: 'NOT_EQUALS' },
+ { label: 'Contains', value: 'CONTAINS' },
+ { label: 'Does not contain', value: 'DOES_NOT_CONTAIN' },
+ { label: 'Starts with', value: 'STARTS_WITH' },
+ { label: 'Ends with', value: 'ENDS_WITH' },
+ { label: 'Greater than', value: 'GREATER_THAN' },
+ { label: 'Less than', value: 'LESS_THAN' },
+ { label: 'Is set', value: 'IS_SET' },
+ { label: 'Is not set', value: 'IS_NOT_SET' },
+ ],
+ },
+ }),
+ value: Property.ShortText({
+ displayName: 'Value',
+ description: 'The value to compare with, for example "summer", "Nike" or 25. Leave empty only for IS_SET / IS_NOT_SET.',
+ required: false,
+ }),
+ },
+ });
+}
+
+function collectionSortOrderProp() {
+ return Property.StaticDropdown({
+ displayName: 'Product Sort Order',
+ description: 'How products are ordered inside the collection. Manual is required before reorder_collection_products.',
+ required: false,
+ options: {
+ options: [
+ { label: 'Manual', value: 'MANUAL' },
+ { label: 'Best selling', value: 'BEST_SELLING' },
+ { label: 'Alphabetical A-Z', value: 'ALPHA_ASC' },
+ { label: 'Alphabetical Z-A', value: 'ALPHA_DESC' },
+ { label: 'Price low to high', value: 'PRICE_ASC' },
+ { label: 'Price high to low', value: 'PRICE_DESC' },
+ { label: 'Newest first', value: 'CREATED_DESC' },
+ { label: 'Oldest first', value: 'CREATED' },
+ { label: 'Most relevant', value: 'MOST_RELEVANT' },
+ ],
+ },
+ });
+}
+
+function productStatusProp({ description }: { description: string }) {
+ return Property.StaticDropdown({
+ displayName: 'Status',
+ description,
+ required: false,
+ options: {
+ options: [
+ { label: 'Active', value: 'ACTIVE' },
+ { label: 'Draft', value: 'DRAFT' },
+ { label: 'Archived', value: 'ARCHIVED' },
+ { label: 'Unlisted', value: 'UNLISTED' },
+ ],
+ },
+ });
+}
+
+function toSeo({
+ title,
+ description,
+}: {
+ title: string | undefined | null;
+ description: string | undefined | null;
+}): Record<string, unknown> | undefined {
+ const seo = compact({ title: nonEmpty(title), description: nonEmpty(description) });
+ return Object.keys(seo).length > 0 ? seo : undefined;
+}
+
+function toCategoryGid(value: string | undefined | null): string | undefined {
+ const category = nonEmpty(value);
+ return category ? toOpaqueGid({ type: 'TaxonomyCategory', id: category }) : undefined;
+}
+
+async function assertStockedAtLocations({
+ auth,
+ pairs,
+}: {
+ auth: ShopifyAuth;
+ pairs: { inventoryItemId: string; locationId: string }[];
+}): Promise<void> {
+ const unique = [...new Map(pairs.map((pair) => [`${pair.inventoryItemId}|${pair.locationId}`, pair])).values()];
+ const declarations = unique.map((_, index) => `$item${index}: ID!, $location${index}: ID!`).join(', ');
+ const selections = unique
+ .map((_, index) => `level${index}: inventoryItem(id: $item${index}) { inventoryLevel(locationId: $location${index}) { isActive } }`)
+ .join(' ');
+ const variables = Object.fromEntries(
+ unique.flatMap((pair, index) => [
+ [`item${index}`, pair.inventoryItemId],
+ [`location${index}`, pair.locationId],
+ ])
+ );
+ const { data } = await shopifyGraphql<Record<string, { inventoryLevel: { isActive?: boolean | null } | null } | null>>({
+ auth,
+ query: `query CheckInventoryLevels(${declarations}) { ${selections} }`,
+ variables,
+ });
+ const missing = unique.find((_, index) => data[`level${index}`]?.inventoryLevel?.isActive !== true);
+ if (missing) {
+ throw new Error(
+ `Inventory item ${missing.inventoryItemId} is not stocked at location ${missing.locationId} (or the item does not exist). Shopify would store the quantity in an inactive level that cannot be sold. Call activate_inventory_at_location first. Nothing was changed.`
+ );
+ }
+}
+
+async function mergeSeo({
+ auth,
+ id,
+ title,
+ description,
+}: {
+ auth: ShopifyAuth;
+ id: string;
+ title: string | undefined | null;
+ description: string | undefined | null;
+}): Promise<Record<string, unknown> | undefined> {
+ const newTitle = nonEmpty(title);
+ const newDescription = nonEmpty(description);
+ if (newTitle === undefined && newDescription === undefined) {
+ return undefined;
+ }
+ if (newTitle !== undefined && newDescription !== undefined) {
+ return { title: newTitle, description: newDescription };
+ }
+ const { data } = await shopifyGraphql<{
+ node: { seo?: { title?: string | null; description?: string | null } | null } | null;
+ }>({
+ auth,
+ query: `query ReadCurrentSeo($id: ID!) { node(id: $id) { ... on Product { seo { title description } } ... on Collection { seo { title description } } } }`,
+ variables: { id },
+ });
+ const current = data.node?.seo;
+ return {
+ title: newTitle ?? current?.title ?? null,
+ description: newDescription ?? current?.description ?? null,
+ };
+}
+
+function groupVariantMedia(value: unknown): { variantId: string; mediaIds: string[] }[] {
+ const grouped = readRecords(value).reduce<Record<string, string[]>>((acc, item) => {
+ const variantId = readText(item['variant_id']);
+ const mediaId = readText(item['media_id']);
+ if (!variantId || !mediaId) {
+ throw new Error('Every entry needs a variant_id and a media_id.');
+ }
+ const key = toGid({ type: 'ProductVariant', id: variantId });
+ const media = toGid({ type: 'MediaImage', id: mediaId });
+ return { ...acc, [key]: [...(acc[key] ?? []), media] };
+ }, {});
+ const entries = Object.entries(grouped).map(([variantId, mediaIds]) => ({ variantId, mediaIds }));
+ if (entries.length === 0) {
+ throw new Error('Provide at least one variant and media pair.');
+ }
+ return entries;
+}
+
+function toGidList({ type, value }: { type: string; value: unknown }): string[] | undefined {
+ const ids = readStringList(value);
+ if (!ids || ids.length === 0) {
+ return undefined;
+ }
+ return ids.map((id) => toGid({ type, id }));
+}
+
const MONEY_FIELDS = 'shopMoney { amount currencyCode }';
const MONEY_WITH_PRESENTMENT_FIELDS =
@@ -1132,6 +1972,91 @@ const ABANDONMENT_FIELDS = `id abandonmentType mostRecentStep createdAt emailSta
const PAGE_INFO_FIELDS = 'pageInfo { hasNextPage endCursor }';
export { SHOPIFY_API_VERSION };
+const MEDIA_SUMMARY_FIELDS =
+ 'id alt mediaContentType status preview { image { url } } ... on MediaImage { mimeType image { url width height } } ... on ExternalVideo { originUrl } ... on Video { filename } ... on Model3d { filename }';
+
+const MEDIA_FIELDS = `${MEDIA_SUMMARY_FIELDS} mediaErrors { code message }`;
+
+const BARCODE_TYPES = ['UPC', 'EAN', 'ISBN', 'GTIN', 'ASIN', 'NS_PID'];
+
+const VARIANT_FIELDS =
+ 'id legacyResourceId title displayName sku barcodes(first: 20) { nodes { type value } } price compareAtPrice position inventoryQuantity inventoryPolicy availableForSale taxable createdAt updatedAt selectedOptions { name value } inventoryItem { id tracked requiresShipping } product { id title }';
+
+const PRODUCT_SUMMARY_FIELDS =
+ 'id legacyResourceId title handle status vendor productType tags createdAt updatedAt publishedAt totalInventory tracksInventory hasOnlyDefaultVariant variantsCount { count } mediaCount { count } priceRangeV2 { minVariantPrice { amount currencyCode } maxVariantPrice { amount currencyCode } } featuredMedia { id preview { image { url } } } category { id fullName }';
+
+const PRODUCT_DETAIL_FIELDS = `${PRODUCT_SUMMARY_FIELDS} descriptionHtml templateSuffix seo { title description } isGiftCard requiresSellingPlan options { id name position optionValues { id name hasVariants } } variants(first: 100) { pageInfo { hasNextPage } nodes { ${VARIANT_FIELDS} } } media(first: 50) { pageInfo { hasNextPage } nodes { ${MEDIA_SUMMARY_FIELDS} } }`;
+
+const COLLECTION_SUMMARY_FIELDS =
+ 'id legacyResourceId title handle sortOrder updatedAt productsCount { count } image { url altText }';
+
+const COLLECTION_CONDITION_FIELDS =
+ '__typename id ... on CollectionSourceInclusionConditionProductTag { tagRelation: relation tagValues: values } ... on CollectionSourceInclusionConditionProductTitle { titleRelation: relation titleValues: values } ... on CollectionSourceInclusionConditionProductType { typeRelation: relation typeValues: values } ... on CollectionSourceInclusionConditionProductVendor { vendorRelation: relation vendorValues: values } ... on CollectionSourceInclusionConditionVariantTitle { variantTitleRelation: relation variantTitleValues: values } ... on CollectionSourceInclusionConditionVariantPrice { priceRelation: relation priceValue: value { amount currencyCode } } ... on CollectionSourceInclusionConditionVariantCompareAtPrice { compareAtPriceRelation: relation compareAtPriceValue: value { amount currencyCode } } ... on CollectionSourceInclusionConditionVariantInventory { inventoryRelation: relation inventoryValue: value }';
+
+const COLLECTION_SELECTIONS_LIMIT = 25;
+
+const COLLECTION_FIELDS = `${COLLECTION_SUMMARY_FIELDS} descriptionHtml templateSuffix seo { title description } sources { __typename id title ... on CollectionConditionsSource { shareable app { id } targetType inclusion { matchType conditions { ${COLLECTION_CONDITION_FIELDS} } selections(first: ${COLLECTION_SELECTIONS_LIMIT}) { pageInfo { hasNextPage } nodes { product { id title } variantIds } } } } }`;
+
+const COLLECTION_SOURCE_LOOKUP_FIELDS =
+ 'id sources { __typename id title ... on CollectionConditionsSource { shareable app { id } } }';
+
+const INVENTORY_ITEM_FIELDS =
+ 'id legacyResourceId sku tracked requiresShipping countryCodeOfOrigin provinceCodeOfOrigin harmonizedSystemCode unitCost { amount currencyCode } measurement { weight { value unit } } locationsCount { count } createdAt updatedAt variants(first: 1) { nodes { id displayName product { id title } } }';
+
+const INVENTORY_LEVEL_FIELDS =
+ 'id isActive canDeactivate deactivationAlert updatedAt item { id sku } location { id name } quantities(names: ["available", "on_hand", "committed", "incoming", "reserved", "damaged", "safety_stock", "quality_control"]) { name quantity }';
+
+const INVENTORY_ADJUSTMENT_GROUP_FIELDS =
+ 'id createdAt reason referenceDocumentUri changes { name delta quantityAfterChange ledgerDocumentUri item { id sku } location { id name } }';
+
+const LOCATION_FIELDS =
+ 'id legacyResourceId name isActive activatable deactivatable deletable fulfillsOnlineOrders shipsInventory hasActiveInventory hasUnfulfilledOrders isFulfillmentService deactivatedAt createdAt updatedAt address { address1 address2 city province provinceCode country countryCode zip phone formatted }';
+
+const PUBLICATION_FIELDS =
+ 'id autoPublish supportsFuturePublishing catalog { id title status }';
+
+const CHANNEL_FIELDS =
+ 'id autoPublish supportsFuturePublishing catalog { id title status ... on AppCatalog { apps(first: 1) { nodes { id title handle } } } }';
+
+const TAXONOMY_CATEGORY_FIELDS =
+ 'id name fullName level isLeaf isRoot isArchived parentId childrenIds';
+
+const TEXT_CONDITION_FIELDS = [
+ 'product_tag',
+ 'product_title',
+ 'product_type',
+ 'product_vendor',
+ 'variant_title',
+];
+
+const TEXT_RELATIONS = ['EQUALS', 'NOT_EQUALS', 'CONTAINS', 'DOES_NOT_CONTAIN', 'STARTS_WITH', 'ENDS_WITH'];
+
+const CONDITION_RELATIONS: Record<string, string[]> = {
+ product_tag: ['TAGGED_WITH', 'NOT_TAGGED_WITH'],
+ product_title: TEXT_RELATIONS,
+ product_type: TEXT_RELATIONS,
+ product_vendor: TEXT_RELATIONS,
+ variant_title: TEXT_RELATIONS,
+ variant_price: ['EQUALS', 'NOT_EQUALS', 'GREATER_THAN', 'LESS_THAN'],
+ variant_compare_at_price: ['EQUALS', 'NOT_EQUALS', 'GREATER_THAN', 'LESS_THAN', 'IS_SET', 'IS_NOT_SET'],
+ variant_inventory: ['EQUALS', 'GREATER_THAN', 'LESS_THAN'],
+};
+
+const CONDITION_INPUT_KEYS: Record<string, string> = {
+ product_tag: 'productTag',
+ product_title: 'productTitle',
+ product_type: 'productType',
+ product_vendor: 'productVendor',
+ variant_title: 'variantTitle',
+ variant_price: 'variantPrice',
+ variant_compare_at_price: 'variantCompareAtPrice',
+ variant_inventory: 'variantInventory',
+};
+
+const MANUAL_SELECTION_SOURCE_TITLE = 'Selected products';
+
+const CONDITIONS_SOURCE_TITLE = 'Product conditions';
+
export const shopifyFields = {
MONEY_FIELDS,
@@ -1148,16 +2073,36 @@ export const shopifyFields = {
ABANDONED_CHECKOUT_FIELDS,
ABANDONMENT_FIELDS,
PAGE_INFO_FIELDS,
+ MEDIA_FIELDS,
+ VARIANT_FIELDS,
+ PRODUCT_SUMMARY_FIELDS,
+ PRODUCT_DETAIL_FIELDS,
+ COLLECTION_SUMMARY_FIELDS,
+ COLLECTION_FIELDS,
+ COLLECTION_SOURCE_LOOKUP_FIELDS,
+ COLLECTION_SELECTIONS_LIMIT,
+ INVENTORY_ITEM_FIELDS,
+ INVENTORY_LEVEL_FIELDS,
+ INVENTORY_ADJUSTMENT_GROUP_FIELDS,
+ LOCATION_FIELDS,
+ PUBLICATION_FIELDS,
+ CHANNEL_FIELDS,
+ TAXONOMY_CATEGORY_FIELDS,
+ MANUAL_SELECTION_SOURCE_TITLE,
+ CONDITIONS_SOURCE_TITLE,
};
export const shopifyGraphqlClient = {
request: shopifyGraphql,
toGid,
+ toOpaqueGid,
resolveIdempotencyKey,
+ assertStockedAtLocations,
};
export const shopifyValues = {
readClearable,
+ toBarcodes,
readFirst,
nonEmpty,
readStringList,
@@ -1173,6 +2118,19 @@ export const shopifyValues = {
buildMailingAddress,
buildRefundLineItems,
buildDraftLineItems,
+ parseOptionValues,
+ splitList,
+ buildVariantInputs,
+ buildConditions,
+ toSeo,
+ mergeSeo,
+ toCategoryGid,
+ toGidList,
+ findConditionsSource,
+ editableConditionsSources,
+ sharedConditionsSources,
+ findExplicitConditionsSource,
+ groupVariantMedia,
};
export const shopifyMappers = {
@@ -1188,9 +2146,24 @@ export const shopifyMappers = {
mapCustomer,
mapAbandonedCheckout,
mapAbandonment,
+ mapProductSummary,
+ mapProductDetail,
+ mapProductOption,
+ mapVariant,
+ mapMedia,
+ mapCollectionSummary,
+ mapCollection,
+ mapInventoryItem,
+ mapInventoryLevel,
+ mapAdjustmentGroup,
+ mapLocation,
+ mapPublication,
+ mapChannel,
+ mapTaxonomyCategory,
};
export const shopifyProps = {
+ barcodeType: barcodeTypeProp,
address: addressProps,
first: firstProp,
after: afterProp,
@@ -1200,6 +2173,10 @@ export const shopifyProps = {
idempotencyKey: idempotencyKeyProp,
refundLineItems: refundLineItemsProp,
draftLineItems: draftLineItemsProp,
+ variants: variantsProp,
+ conditions: conditionsProp,
+ collectionSortOrder: collectionSortOrderProp,
+ productStatus: productStatusProp,
};
export type ShopifyGraphqlParams = {
@@ -1561,3 +2538,241 @@ export type GqlAbandonment = {
totalPriceSet?: GqlMoneyBag | null;
} | null;
};
+
+export type GqlMedia = {
+ id?: string | null;
+ alt?: string | null;
+ mediaContentType?: string | null;
+ status?: string | null;
+ mediaErrors?: { code?: string | null; message?: string | null }[] | null;
+ preview?: { image?: { url?: string | null } | null } | null;
+ mimeType?: string | null;
+ image?: { url?: string | null; width?: number | null; height?: number | null } | null;
+ originUrl?: string | null;
+ filename?: string | null;
+};
+
+export type GqlVariant = {
+ id: string;
+ legacyResourceId?: string | null;
+ title?: string | null;
+ displayName?: string | null;
+ sku?: string | null;
+ barcodes?: { nodes?: { value: string; type?: string | null }[] | null } | null;
+ price?: string | null;
+ compareAtPrice?: string | null;
+ position?: number | null;
+ inventoryQuantity?: number | null;
+ inventoryPolicy?: string | null;
+ availableForSale?: boolean | null;
+ taxable?: boolean | null;
+ createdAt?: string | null;
+ updatedAt?: string | null;
+ selectedOptions?: { name?: string | null; value?: string | null }[] | null;
+ inventoryItem?: { id?: string | null; tracked?: boolean | null; requiresShipping?: boolean | null } | null;
+ product?: { id?: string | null; title?: string | null } | null;
+ media?: GqlConnection<{ id?: string | null }> | null;
+};
+
+export type GqlProductOption = {
+ id: string;
+ name?: string | null;
+ position?: number | null;
+ optionValues?: { id: string; name?: string | null; hasVariants?: boolean | null }[] | null;
+};
+
+export type GqlProduct = {
+ id: string;
+ legacyResourceId?: string | null;
+ title?: string | null;
+ handle?: string | null;
+ status?: string | null;
+ vendor?: string | null;
+ productType?: string | null;
+ tags?: string[] | null;
+ createdAt?: string | null;
+ updatedAt?: string | null;
+ publishedAt?: string | null;
+ totalInventory?: number | null;
+ tracksInventory?: boolean | null;
+ hasOnlyDefaultVariant?: boolean | null;
+ variantsCount?: GqlCount | null;
+ mediaCount?: GqlCount | null;
+ priceRangeV2?: { minVariantPrice?: GqlMoneyV2 | null; maxVariantPrice?: GqlMoneyV2 | null } | null;
+ featuredMedia?: { id?: string | null; preview?: { image?: { url?: string | null } | null } | null } | null;
+ category?: { id?: string | null; fullName?: string | null } | null;
+ descriptionHtml?: string | null;
+ templateSuffix?: string | null;
+ seo?: { title?: string | null; description?: string | null } | null;
+ isGiftCard?: boolean | null;
+ requiresSellingPlan?: boolean | null;
+ options?: GqlProductOption[] | null;
+ variants?: GqlConnection<GqlVariant> | null;
+ media?: GqlConnection<GqlMedia> | null;
+};
+
+export type GqlCollectionCondition = {
+ __typename?: string | null;
+ id: string;
+ tagRelation?: string | null;
+ tagValues?: string[] | null;
+ titleRelation?: string | null;
+ titleValues?: string[] | null;
+ typeRelation?: string | null;
+ typeValues?: string[] | null;
+ vendorRelation?: string | null;
+ vendorValues?: string[] | null;
+ variantTitleRelation?: string | null;
+ variantTitleValues?: string[] | null;
+ priceRelation?: string | null;
+ priceValue?: GqlMoneyV2 | null;
+ compareAtPriceRelation?: string | null;
+ compareAtPriceValue?: GqlMoneyV2 | null;
+ inventoryRelation?: string | null;
+ inventoryValue?: number | null;
+};
+
+export type GqlCollectionSource = {
+ __typename?: string | null;
+ id: string;
+ title?: string | null;
+ shareable?: boolean | null;
+ app?: { id?: string | null } | null;
+ targetType?: string | null;
+ inclusion?: {
+ matchType?: string | null;
+ conditions?: GqlCollectionCondition[] | null;
+ selections?: {
+ pageInfo?: { hasNextPage?: boolean | null } | null;
+ nodes?: { product?: { id?: string | null; title?: string | null } | null; variantIds?: string[] | null }[] | null;
+ } | null;
+ } | null;
+};
+
+export type GqlCollection = {
+ id: string;
+ legacyResourceId?: string | null;
+ title?: string | null;
+ handle?: string | null;
+ sortOrder?: string | null;
+ updatedAt?: string | null;
+ productsCount?: GqlCount | null;
+ image?: { url?: string | null; altText?: string | null } | null;
+ descriptionHtml?: string | null;
+ templateSuffix?: string | null;
+ seo?: { title?: string | null; description?: string | null } | null;
+ sources?: GqlCollectionSource[] | null;
+};
+
+export type GqlInventoryItem = {
+ id: string;
+ legacyResourceId?: string | null;
+ sku?: string | null;
+ tracked?: boolean | null;
+ requiresShipping?: boolean | null;
+ countryCodeOfOrigin?: string | null;
+ provinceCodeOfOrigin?: string | null;
+ harmonizedSystemCode?: string | null;
+ unitCost?: GqlMoneyV2 | null;
+ measurement?: { weight?: { value?: number | null; unit?: string | null } | null } | null;
+ locationsCount?: GqlCount | null;
+ createdAt?: string | null;
+ updatedAt?: string | null;
+ variants?: GqlConnection<{
+ id?: string | null;
+ displayName?: string | null;
+ product?: { id?: string | null; title?: string | null } | null;
+ }> | null;
+};
+
+export type GqlInventoryLevel = {
+ id: string;
+ isActive?: boolean | null;
+ canDeactivate?: boolean | null;
+ deactivationAlert?: string | null;
+ updatedAt?: string | null;
+ item?: { id?: string | null; sku?: string | null } | null;
+ location?: { id?: string | null; name?: string | null } | null;
+ quantities?: { name?: string | null; quantity?: number | null }[] | null;
+};
+
+export type GqlInventoryAdjustmentGroup = {
+ id?: string | null;
+ createdAt?: string | null;
+ reason?: string | null;
+ referenceDocumentUri?: string | null;
+ changes?: {
+ name?: string | null;
+ delta?: number | null;
+ quantityAfterChange?: number | null;
+ ledgerDocumentUri?: string | null;
+ item?: { id?: string | null; sku?: string | null } | null;
+ location?: { id?: string | null; name?: string | null } | null;
+ }[] | null;
+};
+
+export type GqlLocation = {
+ id: string;
+ legacyResourceId?: string | null;
+ name?: string | null;
+ isActive?: boolean | null;
+ activatable?: boolean | null;
+ deactivatable?: boolean | null;
+ deletable?: boolean | null;
+ fulfillsOnlineOrders?: boolean | null;
+ shipsInventory?: boolean | null;
+ hasActiveInventory?: boolean | null;
+ hasUnfulfilledOrders?: boolean | null;
+ isFulfillmentService?: boolean | null;
+ deactivatedAt?: string | null;
+ createdAt?: string | null;
+ updatedAt?: string | null;
+ address?: {
+ address1?: string | null;
+ address2?: string | null;
+ city?: string | null;
+ province?: string | null;
+ provinceCode?: string | null;
+ country?: string | null;
+ countryCode?: string | null;
+ zip?: string | null;
+ phone?: string | null;
+ formatted?: string[] | null;
+ } | null;
+};
+
+export type GqlPublication = {
+ id: string;
+ autoPublish?: boolean | null;
+ supportsFuturePublishing?: boolean | null;
+ catalog?: { id?: string | null; title?: string | null; status?: string | null } | null;
+};
+
+export type GqlChannelPublication = {
+ id: string;
+ autoPublish?: boolean | null;
+ supportsFuturePublishing?: boolean | null;
+ catalog?: {
+ id?: string | null;
+ title?: string | null;
+ status?: string | null;
+ apps?: { nodes?: { id?: string | null; title?: string | null; handle?: string | null }[] | null } | null;
+ } | null;
+};
+
+export type GqlTaxonomyCategory = {
+ id: string;
+ name?: string | null;
+ fullName?: string | null;
+ level?: number | null;
+ isLeaf?: boolean | null;
+ isRoot?: boolean | null;
+ isArchived?: boolean | null;
+ parentId?: string | null;
+ childrenIds?: string[] | null;
+};
+
+export type GqlJob = {
+ id?: string | null;
+ done?: boolean | null;
+};
diff --git a/packages/pieces/community/shopify/src/lib/output-schemas/products.ts b/packages/pieces/community/shopify/src/lib/output-schemas/products.ts
new file mode 100644
index 00000000000..9121bbca533
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/output-schemas/products.ts
@@ -0,0 +1,755 @@
+import { OutputSchema, OutputSchemaField } from '@activepieces/pieces-framework';
+
+const redactedFieldsField: OutputSchemaField = {
+ key: 'redacted_fields',
+ label: 'Redacted Fields',
+ description:
+ 'Response paths Shopify withheld, for example because an access scope is missing.',
+};
+
+const pageFields: OutputSchema['fields'] = [
+ { key: 'count', label: 'Count', format: 'number' },
+ { key: 'has_next_page', label: 'Has Next Page', format: 'boolean' },
+ {
+ key: 'end_cursor',
+ label: 'End Cursor',
+ description: 'Pass back as the cursor to read the next page.',
+ },
+ redactedFieldsField,
+];
+
+const countFields: OutputSchema['fields'] = [
+ { key: 'count', label: 'Count', format: 'number' },
+ {
+ key: 'precision',
+ label: 'Precision',
+ description: 'EXACT, or AT_LEAST when Shopify capped the count.',
+ },
+ redactedFieldsField,
+];
+
+const productSummaryFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Product ID' },
+ { key: 'legacy_resource_id', label: 'Numeric ID' },
+ { key: 'title', label: 'Title' },
+ { key: 'handle', label: 'Handle' },
+ { key: 'status', label: 'Status' },
+ { key: 'vendor', label: 'Vendor' },
+ { key: 'product_type', label: 'Product Type' },
+ { key: 'tags', label: 'Tags', description: 'Comma-separated tags.' },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },
+ { key: 'published_at', label: 'Published At', format: 'datetime' },
+ { key: 'total_inventory', label: 'Total Inventory', format: 'number' },
+ { key: 'tracks_inventory', label: 'Tracks Inventory', format: 'boolean' },
+ {
+ key: 'has_only_default_variant',
+ label: 'Has Only Default Variant',
+ format: 'boolean',
+ },
+ { key: 'variants_count', label: 'Variants Count', format: 'number' },
+ { key: 'media_count', label: 'Media Count', format: 'number' },
+ { key: 'min_price', label: 'Min Price', format: 'number' },
+ { key: 'max_price', label: 'Max Price', format: 'number' },
+ { key: 'currency_code', label: 'Currency Code' },
+ { key: 'featured_media_id', label: 'Featured Media ID' },
+ { key: 'featured_image_url', label: 'Featured Image', format: 'image' },
+ { key: 'category_id', label: 'Category ID' },
+ { key: 'category_name', label: 'Category Name' },
+];
+
+const selectedOptionsField: OutputSchemaField = {
+ key: 'selected_options',
+ label: 'Selected Options',
+ labelKey: 'name',
+ listItems: [
+ { key: 'name', label: 'Option' },
+ { key: 'value', label: 'Value' },
+ ],
+};
+
+const variantFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Variant ID' },
+ { key: 'legacy_resource_id', label: 'Numeric ID' },
+ { key: 'title', label: 'Title' },
+ { key: 'display_name', label: 'Display Name' },
+ { key: 'sku', label: 'SKU' },
+ { key: 'barcode', label: 'Barcode', description: 'The first barcode of the variant.' },
+ {
+ key: 'barcodes',
+ label: 'Barcodes',
+ labelKey: 'value',
+ listItems: [
+ { key: 'value', label: 'Barcode' },
+ { key: 'type', label: 'Type', description: 'UPC, EAN, ISBN, GTIN, ASIN or NS_PID; empty when stored as entered.' },
+ ],
+ },
+ { key: 'price', label: 'Price', format: 'number' },
+ { key: 'compare_at_price', label: 'Compare-at Price', format: 'number' },
+ { key: 'position', label: 'Position', format: 'number' },
+ { key: 'inventory_quantity', label: 'Inventory Quantity', format: 'number' },
+ {
+ key: 'inventory_policy',
+ label: 'Inventory Policy',
+ description: 'DENY or CONTINUE selling when out of stock.',
+ },
+ { key: 'available_for_sale', label: 'Available for Sale', format: 'boolean' },
+ { key: 'taxable', label: 'Taxable', format: 'boolean' },
+ selectedOptionsField,
+ { key: 'inventory_item_id', label: 'Inventory Item ID' },
+ { key: 'inventory_tracked', label: 'Inventory Tracked', format: 'boolean' },
+ { key: 'requires_shipping', label: 'Requires Shipping', format: 'boolean' },
+ { key: 'product_id', label: 'Product ID' },
+ { key: 'product_title', label: 'Product Title' },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },
+];
+
+const mediaFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Media ID' },
+ { key: 'alt', label: 'Alt Text' },
+ {
+ key: 'media_content_type',
+ label: 'Media Type',
+ description: 'IMAGE, VIDEO, EXTERNAL_VIDEO or MODEL_3D.',
+ },
+ {
+ key: 'status',
+ label: 'Status',
+ description: 'UPLOADED, PROCESSING, READY or FAILED.',
+ },
+ { key: 'image_url', label: 'Image URL', format: 'image' },
+ { key: 'width', label: 'Width', format: 'number' },
+ { key: 'height', label: 'Height', format: 'number' },
+ { key: 'mime_type', label: 'MIME Type' },
+ { key: 'preview_url', label: 'Preview Image', format: 'image' },
+ { key: 'external_url', label: 'External URL', format: 'url' },
+ { key: 'filename', label: 'Filename' },
+ { key: 'errors', label: 'Errors', description: 'Processing errors, joined with "; ".' },
+];
+
+const productDetailFields: OutputSchema['fields'] = [
+ ...productSummaryFields,
+ { key: 'description_html', label: 'Description', format: 'html' },
+ { key: 'template_suffix', label: 'Template Suffix' },
+ { key: 'seo_title', label: 'SEO Title' },
+ { key: 'seo_description', label: 'SEO Description' },
+ { key: 'is_gift_card', label: 'Is Gift Card', format: 'boolean' },
+ {
+ key: 'requires_selling_plan',
+ label: 'Requires Selling Plan',
+ format: 'boolean',
+ },
+ {
+ key: 'options',
+ label: 'Options',
+ labelKey: 'name',
+ listItems: [
+ { key: 'id', label: 'Option ID' },
+ { key: 'name', label: 'Name' },
+ { key: 'position', label: 'Position', format: 'number' },
+ {
+ key: 'values',
+ label: 'Values',
+ labelKey: 'name',
+ listItems: [
+ { key: 'id', label: 'Value ID' },
+ { key: 'name', label: 'Name' },
+ { key: 'has_variants', label: 'Has Variants', format: 'boolean' },
+ ],
+ },
+ ],
+ },
+ {
+ key: 'variants',
+ label: 'Variants',
+ labelKey: 'title',
+ listItems: variantFields,
+ },
+ {
+ key: 'variants_has_more',
+ label: 'More Variants',
+ format: 'boolean',
+ description: 'True when the product has more variants than listed; read them with list_product_variants.',
+ },
+ { key: 'media', label: 'Media', labelKey: 'id', listItems: mediaFields },
+ {
+ key: 'media_has_more',
+ label: 'More Media',
+ format: 'boolean',
+ description: 'True when the product has more media than listed; read them with list_product_media.',
+ },
+];
+
+const variantListFields: OutputSchema['fields'] = [
+ { key: 'product_id', label: 'Product ID' },
+ { key: 'variants', label: 'Variants', labelKey: 'title', listItems: variantFields },
+ { key: 'count', label: 'Count', format: 'number' },
+ redactedFieldsField,
+];
+
+const variantMediaFields: OutputSchema['fields'] = [
+ { key: 'product_id', label: 'Product ID' },
+ {
+ key: 'variants',
+ label: 'Variants',
+ labelKey: 'title',
+ listItems: [
+ { key: 'id', label: 'Variant ID' },
+ { key: 'title', label: 'Title' },
+ { key: 'media_ids', label: 'Media IDs' },
+ ],
+ },
+ redactedFieldsField,
+];
+
+const inventoryItemFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Inventory Item ID' },
+ { key: 'legacy_resource_id', label: 'Numeric ID' },
+ { key: 'sku', label: 'SKU' },
+ { key: 'tracked', label: 'Tracked', format: 'boolean' },
+ { key: 'requires_shipping', label: 'Requires Shipping', format: 'boolean' },
+ { key: 'unit_cost', label: 'Unit Cost', format: 'number' },
+ { key: 'unit_cost_currency', label: 'Unit Cost Currency' },
+ { key: 'country_code_of_origin', label: 'Country of Origin' },
+ { key: 'province_code_of_origin', label: 'Province of Origin' },
+ { key: 'harmonized_system_code', label: 'HS Code' },
+ { key: 'weight_value', label: 'Weight', format: 'number' },
+ { key: 'weight_unit', label: 'Weight Unit' },
+ { key: 'locations_count', label: 'Locations Count', format: 'number' },
+ { key: 'variant_id', label: 'Variant ID' },
+ { key: 'variant_title', label: 'Variant Title' },
+ { key: 'product_id', label: 'Product ID' },
+ { key: 'product_title', label: 'Product Title' },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },
+];
+
+const inventoryLevelFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Inventory Level ID' },
+ { key: 'is_active', label: 'Is Active', format: 'boolean' },
+ { key: 'can_deactivate', label: 'Can Deactivate', format: 'boolean' },
+ { key: 'deactivation_alert', label: 'Deactivation Alert' },
+ { key: 'inventory_item_id', label: 'Inventory Item ID' },
+ { key: 'sku', label: 'SKU' },
+ { key: 'location_id', label: 'Location ID' },
+ { key: 'location_name', label: 'Location Name' },
+ { key: 'available', label: 'Available', format: 'number' },
+ { key: 'on_hand', label: 'On Hand', format: 'number' },
+ { key: 'committed', label: 'Committed', format: 'number' },
+ { key: 'incoming', label: 'Incoming', format: 'number' },
+ { key: 'reserved', label: 'Reserved', format: 'number' },
+ { key: 'damaged', label: 'Damaged', format: 'number' },
+ { key: 'safety_stock', label: 'Safety Stock', format: 'number' },
+ { key: 'quality_control', label: 'Quality Control', format: 'number' },
+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },
+];
+
+const inventoryChangeFields: OutputSchema['fields'] = [
+ { key: 'adjustment_group_id', label: 'Adjustment Group ID' },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+ { key: 'reason', label: 'Reason' },
+ { key: 'reference_document_uri', label: 'Reference Document URI' },
+ {
+ key: 'changes',
+ label: 'Changes',
+ labelKey: 'name',
+ listItems: [
+ { key: 'name', label: 'Quantity Name' },
+ { key: 'delta', label: 'Delta', format: 'number' },
+ {
+ key: 'quantity_after_change',
+ label: 'Quantity After Change',
+ format: 'number',
+ },
+ { key: 'ledger_document_uri', label: 'Ledger Document URI' },
+ { key: 'inventory_item_id', label: 'Inventory Item ID' },
+ { key: 'sku', label: 'SKU' },
+ { key: 'location_id', label: 'Location ID' },
+ { key: 'location_name', label: 'Location Name' },
+ ],
+ },
+ {
+ key: 'idempotency_key',
+ label: 'Idempotency Key',
+ description: 'Reuse it to retry this exact change without applying it twice.',
+ },
+ redactedFieldsField,
+];
+
+const locationFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Location ID' },
+ { key: 'legacy_resource_id', label: 'Numeric ID' },
+ { key: 'name', label: 'Name' },
+ { key: 'is_active', label: 'Is Active', format: 'boolean' },
+ { key: 'activatable', label: 'Activatable', format: 'boolean' },
+ { key: 'deactivatable', label: 'Deactivatable', format: 'boolean' },
+ { key: 'deletable', label: 'Deletable', format: 'boolean' },
+ {
+ key: 'fulfills_online_orders',
+ label: 'Fulfills Online Orders',
+ format: 'boolean',
+ },
+ { key: 'ships_inventory', label: 'Ships Inventory', format: 'boolean' },
+ { key: 'has_active_inventory', label: 'Has Active Inventory', format: 'boolean' },
+ {
+ key: 'has_unfulfilled_orders',
+ label: 'Has Unfulfilled Orders',
+ format: 'boolean',
+ },
+ {
+ key: 'is_fulfillment_service',
+ label: 'Is Fulfillment Service',
+ format: 'boolean',
+ },
+ { key: 'deactivated_at', label: 'Deactivated At', format: 'datetime' },
+ { key: 'address1', label: 'Address Line 1' },
+ { key: 'address2', label: 'Address Line 2' },
+ { key: 'city', label: 'City' },
+ { key: 'province', label: 'Province' },
+ { key: 'province_code', label: 'Province Code' },
+ { key: 'country', label: 'Country' },
+ { key: 'country_code', label: 'Country Code' },
+ { key: 'zip', label: 'ZIP' },
+ { key: 'phone', label: 'Phone' },
+ { key: 'formatted_address', label: 'Formatted Address' },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },
+];
+
+const collectionSummaryFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Collection ID' },
+ { key: 'legacy_resource_id', label: 'Numeric ID' },
+ { key: 'title', label: 'Title' },
+ { key: 'handle', label: 'Handle' },
+ { key: 'sort_order', label: 'Sort Order' },
+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },
+ {
+ key: 'products_count',
+ label: 'Products Count',
+ format: 'number',
+ description: 'Shopify updates it asynchronously, so it can lag behind recent changes.',
+ },
+ { key: 'image_url', label: 'Image', format: 'image' },
+ { key: 'image_alt', label: 'Image Alt Text' },
+];
+
+const collectionFields: OutputSchema['fields'] = [
+ ...collectionSummaryFields,
+ { key: 'description_html', label: 'Description', format: 'html' },
+ { key: 'template_suffix', label: 'Template Suffix' },
+ { key: 'seo_title', label: 'SEO Title' },
+ { key: 'seo_description', label: 'SEO Description' },
+ {
+ key: 'sources',
+ label: 'Sources',
+ labelKey: 'title',
+ listItems: [
+ { key: 'id', label: 'Source ID' },
+ { key: 'title', label: 'Title' },
+ { key: 'type', label: 'Type' },
+ {
+ key: 'shareable',
+ label: 'Shared',
+ format: 'boolean',
+ description: 'True when other collections reuse this source.',
+ },
+ { key: 'app_id', label: 'App ID' },
+ { key: 'target_type', label: 'Target Type' },
+ { key: 'match_type', label: 'Match Type', description: 'ALL or ANY.' },
+ {
+ key: 'conditions',
+ label: 'Conditions',
+ labelKey: 'kind',
+ listItems: [
+ { key: 'id', label: 'Condition ID' },
+ { key: 'kind', label: 'Kind' },
+ { key: 'relation', label: 'Relation' },
+ { key: 'values', label: 'Values' },
+ { key: 'currency_code', label: 'Currency Code' },
+ ],
+ },
+ {
+ key: 'selected_products',
+ label: 'Selected Products',
+ labelKey: 'product_title',
+ listItems: [
+ { key: 'product_id', label: 'Product ID' },
+ { key: 'product_title', label: 'Product Title' },
+ { key: 'variant_ids', label: 'Variant IDs' },
+ ],
+ },
+ {
+ key: 'selected_products_count',
+ label: 'Selected Products Count',
+ format: 'number',
+ },
+ {
+ key: 'selected_products_truncated',
+ label: 'Selected Products Truncated',
+ format: 'boolean',
+ },
+ ],
+ },
+];
+
+const collectionJobFields: OutputSchema['fields'] = [
+ { key: 'job_id', label: 'Job ID', description: 'Poll with get_job while job_done is false.' },
+ { key: 'job_done', label: 'Job Done', format: 'boolean' },
+];
+
+const publicationFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Publication ID' },
+ { key: 'title', label: 'Title' },
+ { key: 'catalog_id', label: 'Catalog ID' },
+ { key: 'catalog_status', label: 'Catalog Status' },
+ { key: 'auto_publish', label: 'Auto Publish', format: 'boolean' },
+ {
+ key: 'supports_future_publishing',
+ label: 'Supports Future Publishing',
+ format: 'boolean',
+ },
+];
+
+const publishFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Resource ID' },
+ { key: 'title', label: 'Title' },
+ {
+ key: 'published_publications_count',
+ label: 'Published Publications Count',
+ format: 'number',
+ },
+ { key: 'publication_ids', label: 'Publication IDs' },
+ redactedFieldsField,
+];
+
+const reorderJobFields: OutputSchema['fields'] = [
+ { key: 'job_id', label: 'Job ID', description: 'Poll with get_job while done is false.' },
+ { key: 'done', label: 'Done', format: 'boolean' },
+ redactedFieldsField,
+];
+
+export const productDetailOutputSchema: OutputSchema = {
+ fields: [...productDetailFields, redactedFieldsField],
+};
+
+export const deleteProductOptionsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'deleted_option_ids', label: 'Deleted Option IDs' },
+ ...productDetailFields,
+ redactedFieldsField,
+ ],
+};
+
+export const setProductOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'created',
+ label: 'Created',
+ format: 'boolean',
+ description: 'True when a new product was created, false when an existing one was updated.',
+ },
+ ...productDetailFields,
+ redactedFieldsField,
+ ],
+};
+
+export const duplicateProductOutputSchema: OutputSchema = {
+ fields: [
+ ...productDetailFields,
+ { key: 'source_product_id', label: 'Source Product ID' },
+ {
+ key: 'image_job_id',
+ label: 'Image Job ID',
+ description: 'Poll with get_job when set; null when the images were copied synchronously.',
+ },
+ { key: 'image_job_done', label: 'Image Job Done', format: 'boolean' },
+ redactedFieldsField,
+ ],
+};
+
+export const productCountOutputSchema: OutputSchema = { fields: countFields };
+
+export const searchProductsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'items', label: 'Products', labelKey: 'title', listItems: productSummaryFields },
+ ...pageFields,
+ ],
+};
+
+export const deleteProductOutputSchema: OutputSchema = {
+ fields: [{ key: 'deleted_product_id', label: 'Deleted Product ID' }, redactedFieldsField],
+};
+
+export const getProductDuplicateJobOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'id', label: 'Job ID' },
+ { key: 'done', label: 'Done', format: 'boolean' },
+ redactedFieldsField,
+ ],
+};
+
+export const variantListOutputSchema: OutputSchema = { fields: variantListFields };
+
+export const listProductVariantsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'items', label: 'Variants', labelKey: 'title', listItems: variantFields },
+ ...pageFields,
+ ],
+};
+
+export const productVariantOutputSchema: OutputSchema = {
+ fields: [...variantFields, redactedFieldsField],
+};
+
+export const deleteProductVariantsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'product_id', label: 'Product ID' },
+ { key: 'deleted_variant_ids', label: 'Deleted Variant IDs' },
+ redactedFieldsField,
+ ],
+};
+
+export const listProductMediaOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'items', label: 'Media', labelKey: 'id', listItems: mediaFields },
+ ...pageFields,
+ ],
+};
+
+export const productMediaOutputSchema: OutputSchema = {
+ fields: [...mediaFields, redactedFieldsField],
+};
+
+export const updateProductMediaOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'id', label: 'Media ID' },
+ { key: 'alt', label: 'Alt Text' },
+ {
+ key: 'file_status',
+ label: 'File Status',
+ description: 'UPLOADED, PROCESSING, READY or FAILED.',
+ },
+ {
+ key: 'image_url',
+ label: 'Image URL',
+ format: 'image',
+ description: 'Null while a replacement file is still processing.',
+ },
+ { key: 'preview_url', label: 'Preview Image', format: 'image' },
+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },
+ redactedFieldsField,
+ ],
+};
+
+export const reorderProductMediaOutputSchema: OutputSchema = {
+ fields: [{ key: 'product_id', label: 'Product ID' }, ...reorderJobFields],
+};
+
+export const variantMediaOutputSchema: OutputSchema = { fields: variantMediaFields };
+
+export const deleteProductMediaOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'product_id', label: 'Product ID' },
+ { key: 'removed_media_ids', label: 'Removed Media IDs' },
+ redactedFieldsField,
+ ],
+};
+
+export const inventoryItemOutputSchema: OutputSchema = {
+ fields: [...inventoryItemFields, redactedFieldsField],
+};
+
+export const listInventoryItemsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'items', label: 'Inventory Items', labelKey: 'sku', listItems: inventoryItemFields },
+ ...pageFields,
+ ],
+};
+
+export const listInventoryLevelsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'items',
+ label: 'Inventory Levels',
+ labelKey: 'location_name',
+ listItems: inventoryLevelFields,
+ },
+ ...pageFields,
+ ],
+};
+
+export const activateInventoryAtLocationOutputSchema: OutputSchema = {
+ fields: [
+ ...inventoryLevelFields,
+ {
+ key: 'idempotency_key',
+ label: 'Idempotency Key',
+ description: 'Reuse it to retry this exact change without applying it twice.',
+ },
+ redactedFieldsField,
+ ],
+};
+
+export const inventoryChangeOutputSchema: OutputSchema = { fields: inventoryChangeFields };
+
+export const deactivateInventoryAtLocationOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'deactivated', label: 'Deactivated', format: 'boolean' },
+ { key: 'inventory_level_id', label: 'Inventory Level ID' },
+ { key: 'inventory_item_id', label: 'Inventory Item ID' },
+ { key: 'location_id', label: 'Location ID' },
+ redactedFieldsField,
+ ],
+};
+
+export const listLocationsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'items', label: 'Locations', labelKey: 'name', listItems: locationFields },
+ ...pageFields,
+ ],
+};
+
+export const locationCountOutputSchema: OutputSchema = { fields: countFields };
+
+export const locationOutputSchema: OutputSchema = {
+ fields: [...locationFields, redactedFieldsField],
+};
+
+export const collectionOutputSchema: OutputSchema = {
+ fields: [...collectionFields, redactedFieldsField],
+};
+
+export const updateCollectionOutputSchema: OutputSchema = {
+ fields: [...collectionFields, ...collectionJobFields, redactedFieldsField],
+};
+
+export const addProductsToCollectionOutputSchema: OutputSchema = {
+ fields: [
+ ...collectionFields,
+ { key: 'added_product_ids', label: 'Added Product IDs' },
+ { key: 'source_id_used', label: 'Source ID Used' },
+ {
+ key: 'created_source',
+ label: 'Created Source',
+ format: 'boolean',
+ description: 'True when a new manual-selection source was created for the products.',
+ },
+ ...collectionJobFields,
+ redactedFieldsField,
+ ],
+};
+
+export const removeProductsFromCollectionOutputSchema: OutputSchema = {
+ fields: [
+ ...collectionFields,
+ { key: 'removed_product_ids', label: 'Removed Product IDs' },
+ { key: 'source_ids_used', label: 'Source IDs Used' },
+ ...collectionJobFields,
+ redactedFieldsField,
+ ],
+};
+
+export const listCollectionProductsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'items', label: 'Products', labelKey: 'title', listItems: productSummaryFields },
+ ...pageFields,
+ ],
+};
+
+export const reorderCollectionProductsOutputSchema: OutputSchema = {
+ fields: [{ key: 'collection_id', label: 'Collection ID' }, ...reorderJobFields],
+};
+
+export const searchCollectionsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'items',
+ label: 'Collections',
+ labelKey: 'title',
+ listItems: collectionSummaryFields,
+ },
+ ...pageFields,
+ ],
+};
+
+export const collectionCountOutputSchema: OutputSchema = { fields: countFields };
+
+export const deleteCollectionOutputSchema: OutputSchema = {
+ fields: [{ key: 'deleted_collection_id', label: 'Deleted Collection ID' }, redactedFieldsField],
+};
+
+export const listPublicationsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'items', label: 'Publications', labelKey: 'title', listItems: publicationFields },
+ ...pageFields,
+ ],
+};
+
+export const publicationOutputSchema: OutputSchema = {
+ fields: [...publicationFields, redactedFieldsField],
+};
+
+export const publishResourceOutputSchema: OutputSchema = { fields: publishFields };
+
+export const searchProductTaxonomyOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'items',
+ label: 'Categories',
+ labelKey: 'full_name',
+ listItems: [
+ { key: 'id', label: 'Category ID' },
+ { key: 'name', label: 'Name' },
+ { key: 'full_name', label: 'Full Name' },
+ { key: 'level', label: 'Level', format: 'number' },
+ { key: 'is_leaf', label: 'Is Leaf', format: 'boolean' },
+ { key: 'is_root', label: 'Is Root', format: 'boolean' },
+ { key: 'is_archived', label: 'Is Archived', format: 'boolean' },
+ { key: 'parent_id', label: 'Parent ID' },
+ { key: 'children_ids', label: 'Children IDs' },
+ ],
+ },
+ ...pageFields,
+ ],
+};
+
+export const addProductMediaOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'product_id', label: 'Product ID' },
+ {
+ key: 'media',
+ label: 'Added Media',
+ labelKey: 'id',
+ description: 'Image URL, size and MIME type stay empty until Shopify finishes processing; read them later with list_product_media.',
+ listItems: mediaFields,
+ },
+ { key: 'count', label: 'Count', format: 'number' },
+ redactedFieldsField,
+ ],
+};
+
+export const listSalesChannelsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'items',
+ label: 'Sales Channels',
+ labelKey: 'name',
+ listItems: [
+ { key: 'name', label: 'Name' },
+ { key: 'handle', label: 'Handle' },
+ { key: 'app_id', label: 'App ID' },
+ {
+ key: 'publication_id',
+ label: 'Publication ID',
+ description: 'Pass this to publish_resource or unpublish_resource.',
+ },
+ { key: 'catalog_id', label: 'Catalog ID' },
+ { key: 'catalog_status', label: 'Catalog Status', description: 'ACTIVE, ARCHIVED or DRAFT.' },
+ { key: 'auto_publish', label: 'Auto Publish', format: 'boolean' },
+ { key: 'supports_future_publishing', label: 'Supports Scheduled Publishing', format: 'boolean' },
+ ],
+ },
+ ...pageFields,
+ ],
+};
diff --git a/packages/pieces/community/shopify/test/w2-products.test.ts b/packages/pieces/community/shopify/test/w2-products.test.ts
new file mode 100644
index 00000000000..f4727772272
--- /dev/null
+++ b/packages/pieces/community/shopify/test/w2-products.test.ts
@@ -0,0 +1,280 @@
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import '../src';
+import { shopifyAiAddProductMedia } from '../src/lib/actions/ai/add-product-media';
+import { shopifyAiAdjustInventoryQuantities } from '../src/lib/actions/ai/adjust-inventory-quantities';
+import { shopifyAiCreateProductVariants } from '../src/lib/actions/ai/create-product-variants';
+import { shopifyAiDeleteProductMedia } from '../src/lib/actions/ai/delete-product-media';
+import { shopifyAiSetInventoryQuantities } from '../src/lib/actions/ai/set-inventory-quantities';
+import { shopifyAiUpdateCollection } from '../src/lib/actions/ai/update-collection';
+import { shopifyAiUpdateProductVariants } from '../src/lib/actions/ai/update-product-variants';
+import { mockShopify, runAction } from './helpers';
+
+const ITEM = 'gid://shopify/InventoryItem/11';
+const LOCATION = 'gid://shopify/Location/22';
+const PRODUCT = 'gid://shopify/Product/1';
+
+const SET_PROPS = {
+ name: 'available',
+ reason: 'correction',
+ quantities: [{ inventory_item_id: '11', location_id: '22', quantity: 5 }],
+ idempotency_key: 'set-1',
+};
+
+const ADJUST_PROPS = {
+ name: 'available',
+ reason: 'correction',
+ changes: [{ inventory_item_id: '11', location_id: '22', delta: -2 }],
+ idempotency_key: 'adjust-1',
+};
+
+const INVENTORY_CASES = [
+ { label: 'set_inventory_quantities', action: shopifyAiSetInventoryQuantities, propsValue: SET_PROPS, mutation: 'inventorySetQuantities' },
+ { label: 'adjust_inventory_quantities', action: shopifyAiAdjustInventoryQuantities, propsValue: ADJUST_PROPS, mutation: 'inventoryAdjustQuantities' },
+];
+
+afterEach(() => {
+ vi.restoreAllMocks();
+});
+
+describe.each(INVENTORY_CASES)('$label stock pre-check', ({ action, propsValue, mutation }) => {
+ it('refuses when the item has no inventory level at the location, without sending the mutation', async () => {
+ const sent = mockShopify({ replies: [{ data: { level0: { inventoryLevel: null } } }] });
+
+ await expect(runAction({ action, propsValue })).rejects.toThrow(`Inventory item ${ITEM} is not stocked at location ${LOCATION}`);
+ expect(sent).toHaveLength(1);
+ expect(sent[0].query).toContain('query CheckInventoryLevels');
+ expect(sent[0].variables).toEqual({ item0: ITEM, location0: LOCATION });
+ });
+
+ it('refuses when the inventory level is inactive, without sending the mutation', async () => {
+ const sent = mockShopify({ replies: [{ data: { level0: { inventoryLevel: { isActive: false } } } }] });
+
+ await expect(runAction({ action, propsValue })).rejects.toThrow('not stocked');
+ expect(sent).toHaveLength(1);
+ });
+
+ it('sends the mutation with the idempotency key when the level is active', async () => {
+ const sent = mockShopify({
+ replies: [
+ { data: { level0: { inventoryLevel: { isActive: true } } } },
+ { data: { [mutation]: { inventoryAdjustmentGroup: { id: 'gid://shopify/InventoryAdjustmentGroup/9', changes: [] }, userErrors: [] } } },
+ ],
+ });
+
+ const result = await runAction({ action, propsValue });
+
+ expect(sent).toHaveLength(2);
+ expect(sent[1].query).toContain(`${mutation}(input: $input) @idempotent(key: $idempotencyKey)`);
+ expect(sent[1].variables['idempotencyKey']).toBe(propsValue.idempotency_key);
+ expect(result).toMatchObject({ adjustment_group_id: 'gid://shopify/InventoryAdjustmentGroup/9', idempotency_key: propsValue.idempotency_key });
+ });
+});
+
+describe('inventory mutation input', () => {
+ it('set_inventory_quantities sends the exact quantities input', async () => {
+ const sent = mockShopify({
+ replies: [
+ { data: { level0: { inventoryLevel: { isActive: true } } } },
+ { data: { inventorySetQuantities: { inventoryAdjustmentGroup: null, userErrors: [] } } },
+ ],
+ });
+
+ await runAction({ action: shopifyAiSetInventoryQuantities, propsValue: SET_PROPS });
+
+ expect(sent[1].variables).toEqual({
+ input: {
+ name: 'available',
+ reason: 'correction',
+ quantities: [{ inventoryItemId: ITEM, locationId: LOCATION, quantity: 5, changeFromQuantity: null }],
+ },
+ idempotencyKey: 'set-1',
+ });
+ });
+
+ it('adjust_inventory_quantities sends the exact changes input', async () => {
+ const sent = mockShopify({
+ replies: [
+ { data: { level0: { inventoryLevel: { isActive: true } } } },
+ { data: { inventoryAdjustQuantities: { inventoryAdjustmentGroup: null, userErrors: [] } } },
+ ],
+ });
+
+ await runAction({ action: shopifyAiAdjustInventoryQuantities, propsValue: ADJUST_PROPS });
+
+ expect(sent[1].variables).toEqual({
+ input: {
+ name: 'available',
+ reason: 'correction',
+ changes: [{ inventoryItemId: ITEM, locationId: LOCATION, delta: -2, changeFromQuantity: null }],
+ },
+ idempotencyKey: 'adjust-1',
+ });
+ });
+});
+
+describe('option value parsing', () => {
+ it('create_product_variants keeps an escaped comma inside a value', async () => {
+ const sent = mockShopify({
+ replies: [{ data: { productVariantsBulkCreate: { product: { id: PRODUCT }, productVariants: [], userErrors: [] } } }],
+ });
+
+ await runAction({
+ action: shopifyAiCreateProductVariants,
+ propsValue: { product_id: '1', variants: [{ option_values: 'Material=Cotton\\, Linen, Size=L' }] },
+ });
+
+ expect(sent[0].variables).toEqual({
+ productId: PRODUCT,
+ variants: [
+ {
+ optionValues: [
+ { optionName: 'Material', name: 'Cotton, Linen' },
+ { optionName: 'Size', name: 'L' },
+ ],
+ },
+ ],
+ });
+ });
+});
+
+describe('delete_product_media', () => {
+ const MEDIA_STATUS = {
+ data: {
+ product: {
+ media: {
+ nodes: [
+ { id: 'gid://shopify/MediaImage/100', status: 'READY' },
+ { id: 'gid://shopify/MediaImage/200', status: 'FAILED' },
+ ],
+ },
+ },
+ },
+ };
+
+ it('refuses a media id that is not on the product, deleting nothing', async () => {
+ const sent = mockShopify({ replies: [MEDIA_STATUS] });
+
+ await expect(
+ runAction({ action: shopifyAiDeleteProductMedia, propsValue: { product_id: '1', media_ids: ['100', '999'] } })
+ ).rejects.toThrow(`gid://shopify/MediaImage/999 is not media of product ${PRODUCT}`);
+ expect(sent).toHaveLength(1);
+ expect(sent[0].variables).toEqual({ id: PRODUCT });
+ });
+
+ it('deletes a FAILED media file with fileDelete', async () => {
+ const sent = mockShopify({
+ replies: [MEDIA_STATUS, { data: { fileDelete: { deletedFileIds: ['gid://shopify/MediaImage/200'], userErrors: [] } } }],
+ });
+
+ const result = await runAction({ action: shopifyAiDeleteProductMedia, propsValue: { product_id: '1', media_ids: ['200'] } });
+
+ expect(sent).toHaveLength(2);
+ expect(sent[1].query).toContain('fileDelete(fileIds: $fileIds)');
+ expect(sent[1].variables).toEqual({ fileIds: ['gid://shopify/MediaImage/200'] });
+ expect(result).toEqual({ product_id: PRODUCT, removed_media_ids: ['gid://shopify/MediaImage/200'], redacted_fields: [] });
+ });
+
+ it('detaches READY media from the product with fileUpdate referencesToRemove', async () => {
+ const sent = mockShopify({
+ replies: [MEDIA_STATUS, { data: { fileUpdate: { files: [{ id: 'gid://shopify/MediaImage/100' }], userErrors: [] } } }],
+ });
+
+ await runAction({ action: shopifyAiDeleteProductMedia, propsValue: { product_id: '1', media_ids: ['100'] } });
+
+ expect(sent).toHaveLength(2);
+ expect(sent[1].query).toContain('fileUpdate(files: $files)');
+ expect(sent[1].variables).toEqual({ files: [{ id: 'gid://shopify/MediaImage/100', referencesToRemove: [PRODUCT] }] });
+ });
+});
+
+describe('add_product_media', () => {
+ it('returns only the media that were not on the product before the update', async () => {
+ const sent = mockShopify({
+ replies: [
+ { data: { product: { media: { nodes: [{ id: 'gid://shopify/MediaImage/1' }] } } } },
+ {
+ data: {
+ productUpdate: {
+ product: {
+ id: PRODUCT,
+ media: {
+ nodes: [
+ { id: 'gid://shopify/MediaImage/1', status: 'READY' },
+ { id: 'gid://shopify/MediaImage/2', status: 'UPLOADED', alt: 'Front' },
+ ],
+ },
+ },
+ userErrors: [],
+ },
+ },
+ },
+ ],
+ });
+
+ const result = await runAction({
+ action: shopifyAiAddProductMedia,
+ propsValue: { product_id: '1', media: [{ url: 'https://cdn.example.com/front.png', alt: 'Front' }] },
+ });
+
+ expect(sent[1].variables).toEqual({
+ product: { id: PRODUCT },
+ media: [{ originalSource: 'https://cdn.example.com/front.png', alt: 'Front', mediaContentType: 'IMAGE' }],
+ });
+ expect(result).toMatchObject({ product_id: PRODUCT, count: 1, media: [{ id: 'gid://shopify/MediaImage/2', alt: 'Front' }] });
+ });
+});
+
+describe('update_collection', () => {
+ it('refuses a rule change on a shared conditions source, without sending collectionUpdate', async () => {
+ const sent = mockShopify({
+ replies: [
+ {
+ data: {
+ collection: {
+ id: 'gid://shopify/Collection/5',
+ sources: [
+ { __typename: 'CollectionConditionsSource', id: 'gid://shopify/CollectionConditionsSource/77', title: 'Shared rules', shareable: true },
+ ],
+ },
+ },
+ },
+ ],
+ });
+
+ await expect(
+ runAction({ action: shopifyAiUpdateCollection, propsValue: { collection_id: '5', source_id: '77', match_type: 'ANY' } })
+ ).rejects.toThrow('Source 77 ("Shared rules") is shared with other collections');
+ expect(sent).toHaveLength(1);
+ expect(sent[0].query).toContain('query UpdateCollectionSources');
+ });
+});
+
+describe('variant barcodes', () => {
+ it('update_product_variants sends the barcode with its type', async () => {
+ const sent = mockShopify({
+ replies: [{ data: { productVariantsBulkUpdate: { product: { id: PRODUCT }, productVariants: [], userErrors: [] } } }],
+ });
+
+ await runAction({
+ action: shopifyAiUpdateProductVariants,
+ propsValue: { product_id: '1', variants: [{ variant_id: '3', barcode: '4006381333931', barcode_type: 'EAN' }] },
+ });
+
+ expect(sent[0].variables).toEqual({
+ productId: PRODUCT,
+ variants: [{ id: 'gid://shopify/ProductVariant/3', barcodes: [{ value: '4006381333931', type: 'EAN' }] }],
+ });
+ });
+
+ it('refuses barcode_type without a barcode before calling Shopify', async () => {
+ const sent = mockShopify({ replies: [] });
+
+ await expect(
+ runAction({
+ action: shopifyAiUpdateProductVariants,
+ propsValue: { product_id: '1', variants: [{ variant_id: '3', barcode_type: 'EAN' }] },
+ })
+ ).rejects.toThrow('Set "barcode" when giving a barcode_type.');
+ expect(sent).toHaveLength(0);
+ });
+});