@shopify/ui-extensions 2026.1.0 → 2026.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (285) hide show
  1. package/build/cjs/surfaces/checkout/preact/metafield.js +1 -0
  2. package/build/cjs/surfaces/checkout/preact/metafields.js +1 -0
  3. package/build/esm/surfaces/checkout/preact/metafield.mjs +1 -0
  4. package/build/esm/surfaces/checkout/preact/metafields.mjs +1 -0
  5. package/build/esnext/surfaces/checkout/preact/metafield.esnext +1 -0
  6. package/build/esnext/surfaces/checkout/preact/metafields.esnext +1 -0
  7. package/build/ts/api.d.ts +23 -26
  8. package/build/ts/api.d.ts.map +1 -1
  9. package/build/ts/extension.d.ts +21 -0
  10. package/build/ts/extension.d.ts.map +1 -1
  11. package/build/ts/shared.d.ts +2 -2
  12. package/build/ts/surfaces/admin/api/action/action.d.ts +7 -14
  13. package/build/ts/surfaces/admin/api/action/action.d.ts.map +1 -1
  14. package/build/ts/surfaces/admin/api/action/action.doc.d.ts.map +1 -1
  15. package/build/ts/surfaces/admin/api/block/block.d.ts +12 -16
  16. package/build/ts/surfaces/admin/api/block/block.d.ts.map +1 -1
  17. package/build/ts/surfaces/admin/api/block/block.doc.d.ts.map +1 -1
  18. package/build/ts/surfaces/admin/api/checkout-rules/launch-options.d.ts +21 -10
  19. package/build/ts/surfaces/admin/api/checkout-rules/launch-options.d.ts.map +1 -1
  20. package/build/ts/surfaces/admin/api/checkout-rules/metafields.d.ts +32 -0
  21. package/build/ts/surfaces/admin/api/checkout-rules/metafields.d.ts.map +1 -1
  22. package/build/ts/surfaces/admin/api/checkout-rules/validation-settings.d.ts +7 -3
  23. package/build/ts/surfaces/admin/api/checkout-rules/validation-settings.d.ts.map +1 -1
  24. package/build/ts/surfaces/admin/api/checkout-rules/validation-settings.doc.d.ts.map +1 -1
  25. package/build/ts/surfaces/admin/api/customer-segment-template/customer-segment-template.d.ts +18 -6
  26. package/build/ts/surfaces/admin/api/customer-segment-template/customer-segment-template.d.ts.map +1 -1
  27. package/build/ts/surfaces/admin/api/customer-segment-template/customer-segment-template.doc.d.ts.map +1 -1
  28. package/build/ts/surfaces/admin/api/discount-function-settings/discount-function-settings.d.ts +6 -1
  29. package/build/ts/surfaces/admin/api/discount-function-settings/discount-function-settings.d.ts.map +1 -1
  30. package/build/ts/surfaces/admin/api/discount-function-settings/discount-function-settings.doc.d.ts.map +1 -1
  31. package/build/ts/surfaces/admin/api/discount-function-settings/launch-options.d.ts +30 -12
  32. package/build/ts/surfaces/admin/api/discount-function-settings/launch-options.d.ts.map +1 -1
  33. package/build/ts/surfaces/admin/api/discount-function-settings/metafields.d.ts +32 -0
  34. package/build/ts/surfaces/admin/api/discount-function-settings/metafields.d.ts.map +1 -1
  35. package/build/ts/surfaces/admin/api/intents/intents.d.ts +30 -35
  36. package/build/ts/surfaces/admin/api/intents/intents.d.ts.map +1 -1
  37. package/build/ts/surfaces/admin/api/intents/intents.doc.d.ts.map +1 -1
  38. package/build/ts/surfaces/admin/api/order-routing-rule/data.d.ts +20 -0
  39. package/build/ts/surfaces/admin/api/order-routing-rule/data.d.ts.map +1 -1
  40. package/build/ts/surfaces/admin/api/order-routing-rule/metafields.d.ts +23 -0
  41. package/build/ts/surfaces/admin/api/order-routing-rule/metafields.d.ts.map +1 -1
  42. package/build/ts/surfaces/admin/api/order-routing-rule/order-routing-rule.d.ts +7 -2
  43. package/build/ts/surfaces/admin/api/order-routing-rule/order-routing-rule.d.ts.map +1 -1
  44. package/build/ts/surfaces/admin/api/order-routing-rule/order-routing-rule.doc.d.ts.map +1 -1
  45. package/build/ts/surfaces/admin/api/picker/picker.d.ts +44 -16
  46. package/build/ts/surfaces/admin/api/picker/picker.d.ts.map +1 -1
  47. package/build/ts/surfaces/admin/api/picker/picker.doc.d.ts.map +1 -1
  48. package/build/ts/surfaces/admin/api/print-action/print-action.d.ts +6 -13
  49. package/build/ts/surfaces/admin/api/print-action/print-action.d.ts.map +1 -1
  50. package/build/ts/surfaces/admin/api/print-action/print-action.doc.d.ts.map +1 -1
  51. package/build/ts/surfaces/admin/api/product-configuration/product-details-configuration.d.ts +36 -0
  52. package/build/ts/surfaces/admin/api/product-configuration/product-details-configuration.d.ts.map +1 -1
  53. package/build/ts/surfaces/admin/api/product-configuration/product-details-configuration.doc.d.ts.map +1 -1
  54. package/build/ts/surfaces/admin/api/product-configuration/product-variant-details-configuration.d.ts +36 -0
  55. package/build/ts/surfaces/admin/api/product-configuration/product-variant-details-configuration.d.ts.map +1 -1
  56. package/build/ts/surfaces/admin/api/product-configuration/product-variant-details-configuration.doc.d.ts.map +1 -1
  57. package/build/ts/surfaces/admin/api/purchase-options-card-action.d.ts +7 -0
  58. package/build/ts/surfaces/admin/api/purchase-options-card-action.d.ts.map +1 -1
  59. package/build/ts/surfaces/admin/api/purchase-options-card-action.doc.d.ts.map +1 -1
  60. package/build/ts/surfaces/admin/api/resource-picker/resource-picker.d.ts +181 -21
  61. package/build/ts/surfaces/admin/api/resource-picker/resource-picker.d.ts.map +1 -1
  62. package/build/ts/surfaces/admin/api/resource-picker/resource-picker.doc.d.ts.map +1 -1
  63. package/build/ts/surfaces/admin/api/shared.d.ts +7 -1
  64. package/build/ts/surfaces/admin/api/shared.d.ts.map +1 -1
  65. package/build/ts/surfaces/admin/api/should-render/should-render.d.ts +8 -1
  66. package/build/ts/surfaces/admin/api/should-render/should-render.d.ts.map +1 -1
  67. package/build/ts/surfaces/admin/api/should-render/should-render.doc.d.ts.map +1 -1
  68. package/build/ts/surfaces/admin/api/standard/standard-rendering.d.ts +15 -0
  69. package/build/ts/surfaces/admin/api/standard/standard-rendering.d.ts.map +1 -0
  70. package/build/ts/surfaces/admin/api/standard/standard.d.ts +20 -10
  71. package/build/ts/surfaces/admin/api/standard/standard.d.ts.map +1 -1
  72. package/build/ts/surfaces/admin/api/standard/standard.doc.d.ts.map +1 -1
  73. package/build/ts/surfaces/admin/api/standard/storage.d.ts +21 -27
  74. package/build/ts/surfaces/admin/api/standard/storage.d.ts.map +1 -1
  75. package/build/ts/surfaces/admin/api.d.ts +1 -0
  76. package/build/ts/surfaces/admin/api.d.ts.map +1 -1
  77. package/build/ts/surfaces/admin/components/ActionExtensionComponents.d.ts +3 -0
  78. package/build/ts/surfaces/admin/components/ActionExtensionComponents.d.ts.map +1 -1
  79. package/build/ts/surfaces/admin/components/BlockExtensionComponents.d.ts +3 -0
  80. package/build/ts/surfaces/admin/components/BlockExtensionComponents.d.ts.map +1 -1
  81. package/build/ts/surfaces/admin/components/FormExtensionComponents.d.ts +3 -0
  82. package/build/ts/surfaces/admin/components/FormExtensionComponents.d.ts.map +1 -1
  83. package/build/ts/surfaces/admin/components/FunctionSettingsComponents.d.ts +3 -0
  84. package/build/ts/surfaces/admin/components/FunctionSettingsComponents.d.ts.map +1 -1
  85. package/build/ts/surfaces/admin/components/PrintActionExtensionComponents.d.ts +3 -0
  86. package/build/ts/surfaces/admin/components/PrintActionExtensionComponents.d.ts.map +1 -1
  87. package/build/ts/surfaces/admin/components/StandardComponents.d.ts +3 -0
  88. package/build/ts/surfaces/admin/components/StandardComponents.d.ts.map +1 -1
  89. package/build/ts/surfaces/admin/extension-targets.d.ts +85 -169
  90. package/build/ts/surfaces/admin/extension-targets.d.ts.map +1 -1
  91. package/build/ts/surfaces/checkout/api/address-autocomplete/standard.d.ts +5 -0
  92. package/build/ts/surfaces/checkout/api/address-autocomplete/standard.d.ts.map +1 -1
  93. package/build/ts/surfaces/checkout/api/checkout/checkout.d.ts +14 -1
  94. package/build/ts/surfaces/checkout/api/checkout/checkout.d.ts.map +1 -1
  95. package/build/ts/surfaces/checkout/api/standard/standard.d.ts +5 -3
  96. package/build/ts/surfaces/checkout/api/standard/standard.d.ts.map +1 -1
  97. package/build/ts/surfaces/checkout/preact/metafield.d.ts +1 -0
  98. package/build/ts/surfaces/checkout/preact/metafield.d.ts.map +1 -1
  99. package/build/ts/surfaces/checkout/preact/metafields.d.ts +1 -0
  100. package/build/ts/surfaces/checkout/preact/metafields.d.ts.map +1 -1
  101. package/build/ts/surfaces/point-of-sale/components/Badge/Badge.doc.d.ts.map +1 -1
  102. package/build/ts/surfaces/point-of-sale/components/EmptyState.d.ts +44 -34
  103. package/build/ts/surfaces/point-of-sale/components/Icon/Icon.doc.d.ts.map +1 -1
  104. package/build/ts/surfaces/point-of-sale/components/Image/Image.doc.d.ts.map +1 -1
  105. package/build/ts/surfaces/point-of-sale/components/Link/Link.doc.d.ts.map +1 -1
  106. package/build/ts/surfaces/point-of-sale/components/Modal/Modal.doc.d.ts.map +1 -1
  107. package/build/ts/surfaces/point-of-sale/components/Page/Page.doc.d.ts.map +1 -1
  108. package/build/ts/surfaces/point-of-sale/components/Stack/Stack.doc.d.ts.map +1 -1
  109. package/build/ts/surfaces/point-of-sale/components/Stack.d.ts +10 -10
  110. package/build/ts/surfaces/point-of-sale/components/Tabs/Tabs.doc.d.ts.map +1 -1
  111. package/build/ts/surfaces/point-of-sale/components/Text/Text.doc.d.ts.map +1 -1
  112. package/build/ts/surfaces/point-of-sale/components/TextField.d.ts +1 -1
  113. package/build/ts/surfaces/point-of-sale/components/Tile/Tile.doc.d.ts.map +1 -1
  114. package/build/ts/surfaces/point-of-sale/components/components-shared.d.ts +3249 -2916
  115. package/build/tsconfig.tsbuildinfo +1 -1
  116. package/package.json +1 -1
  117. package/src/api.ts +23 -26
  118. package/src/extension.ts +21 -0
  119. package/src/shared.ts +2 -2
  120. package/src/surfaces/admin/api/action/action.ts +7 -16
  121. package/src/surfaces/admin/api/action/examples/handle-errors.jsx +47 -0
  122. package/src/surfaces/admin/api/action/examples/process-selected-products.jsx +33 -0
  123. package/src/surfaces/admin/api/action/examples/select-additional-resources.jsx +46 -0
  124. package/src/surfaces/admin/api/block/block.ts +12 -18
  125. package/src/surfaces/admin/api/block/examples/display-product-info.jsx +46 -0
  126. package/src/surfaces/admin/api/block/examples/navigate-to-action.jsx +50 -0
  127. package/src/surfaces/admin/api/block/examples/select-related-products.jsx +46 -0
  128. package/src/surfaces/admin/api/checkout-rules/examples/configure-shipping-restrictions.jsx +52 -0
  129. package/src/surfaces/admin/api/checkout-rules/examples/load-validation-config.jsx +55 -0
  130. package/src/surfaces/admin/api/checkout-rules/examples/set-minimum-quantity.jsx +40 -0
  131. package/src/surfaces/admin/api/checkout-rules/launch-options.ts +22 -10
  132. package/src/surfaces/admin/api/checkout-rules/metafields.ts +35 -0
  133. package/src/surfaces/admin/api/checkout-rules/validation-settings.ts +7 -3
  134. package/src/surfaces/admin/api/customer-segment-template/customer-segment-template.ts +19 -7
  135. package/src/surfaces/admin/api/customer-segment-template/examples/abandoned-cart-recovery.jsx +30 -0
  136. package/src/surfaces/admin/api/customer-segment-template/examples/birthday-this-month.jsx +32 -0
  137. package/src/surfaces/admin/api/customer-segment-template/examples/high-value-customers.jsx +27 -0
  138. package/src/surfaces/admin/api/discount-function-settings/discount-function-settings.ts +6 -1
  139. package/src/surfaces/admin/api/discount-function-settings/examples/configure-discount-threshold.jsx +39 -0
  140. package/src/surfaces/admin/api/discount-function-settings/examples/configure-eligibility-rules.jsx +45 -0
  141. package/src/surfaces/admin/api/discount-function-settings/examples/load-existing-settings.jsx +45 -0
  142. package/src/surfaces/admin/api/discount-function-settings/launch-options.ts +30 -12
  143. package/src/surfaces/admin/api/discount-function-settings/metafields.ts +35 -0
  144. package/src/surfaces/admin/api/intents/examples/create-article.jsx +35 -0
  145. package/src/surfaces/admin/api/intents/examples/create-catalog.jsx +35 -0
  146. package/src/surfaces/admin/api/intents/examples/create-collection.jsx +35 -0
  147. package/src/surfaces/admin/api/intents/examples/create-customer.jsx +35 -0
  148. package/src/surfaces/admin/api/intents/examples/create-discount.jsx +35 -0
  149. package/src/surfaces/admin/api/intents/examples/create-market.jsx +35 -0
  150. package/src/surfaces/admin/api/intents/examples/create-menu.jsx +35 -0
  151. package/src/surfaces/admin/api/intents/examples/create-metafield-definition.jsx +35 -0
  152. package/src/surfaces/admin/api/intents/examples/create-metaobject-definition.jsx +35 -0
  153. package/src/surfaces/admin/api/intents/examples/create-metaobject.jsx +35 -0
  154. package/src/surfaces/admin/api/intents/examples/create-page.jsx +35 -0
  155. package/src/surfaces/admin/api/intents/examples/create-product.jsx +37 -0
  156. package/src/surfaces/admin/api/intents/examples/create-variant.jsx +35 -0
  157. package/src/surfaces/admin/api/intents/examples/edit-article.jsx +41 -0
  158. package/src/surfaces/admin/api/intents/examples/edit-catalog.jsx +41 -0
  159. package/src/surfaces/admin/api/intents/examples/edit-collection.jsx +41 -0
  160. package/src/surfaces/admin/api/intents/examples/edit-customer.jsx +41 -0
  161. package/src/surfaces/admin/api/intents/examples/edit-discount.jsx +41 -0
  162. package/src/surfaces/admin/api/intents/examples/edit-market.jsx +41 -0
  163. package/src/surfaces/admin/api/intents/examples/edit-menu.jsx +41 -0
  164. package/src/surfaces/admin/api/intents/examples/edit-metafield-definition.jsx +41 -0
  165. package/src/surfaces/admin/api/intents/examples/edit-metaobject-definition.jsx +41 -0
  166. package/src/surfaces/admin/api/intents/examples/edit-metaobject.jsx +41 -0
  167. package/src/surfaces/admin/api/intents/examples/edit-page.jsx +41 -0
  168. package/src/surfaces/admin/api/intents/examples/edit-product.jsx +41 -0
  169. package/src/surfaces/admin/api/intents/examples/edit-variant.jsx +41 -0
  170. package/src/surfaces/admin/api/intents/intents.ts +30 -35
  171. package/src/surfaces/admin/api/order-routing-rule/data.ts +20 -0
  172. package/src/surfaces/admin/api/order-routing-rule/examples/configure-location-priority.jsx +46 -0
  173. package/src/surfaces/admin/api/order-routing-rule/examples/remove-deprecated-settings.jsx +35 -0
  174. package/src/surfaces/admin/api/order-routing-rule/examples/set-routing-criteria.jsx +57 -0
  175. package/src/surfaces/admin/api/order-routing-rule/metafields.ts +24 -0
  176. package/src/surfaces/admin/api/order-routing-rule/order-routing-rule.ts +7 -2
  177. package/src/surfaces/admin/api/picker/examples/direct-api.jsx +42 -0
  178. package/src/surfaces/admin/api/picker/examples/disabled.jsx +23 -0
  179. package/src/surfaces/admin/api/picker/examples/minimal.jsx +37 -0
  180. package/src/surfaces/admin/api/picker/examples/multiple-limit.jsx +26 -0
  181. package/src/surfaces/admin/api/picker/examples/multiple-true.jsx +25 -0
  182. package/src/surfaces/admin/api/picker/examples/preselected.jsx +23 -0
  183. package/src/surfaces/admin/api/picker/examples/template-picker.jsx +58 -0
  184. package/src/surfaces/admin/api/picker/picker.ts +46 -16
  185. package/src/surfaces/admin/api/print-action/examples/custom-product-labels.jsx +44 -0
  186. package/src/surfaces/admin/api/print-action/examples/generate-packing-slip.jsx +28 -0
  187. package/src/surfaces/admin/api/print-action/examples/shipping-manifest.jsx +58 -0
  188. package/src/surfaces/admin/api/print-action/print-action.ts +6 -15
  189. package/src/surfaces/admin/api/product-configuration/examples/create-variant-component.jsx +56 -0
  190. package/src/surfaces/admin/api/product-configuration/examples/load-bundle-config.jsx +47 -0
  191. package/src/surfaces/admin/api/product-configuration/examples/load-variant-bundle-config.jsx +54 -0
  192. package/src/surfaces/admin/api/product-configuration/examples/navigate-to-component.jsx +27 -0
  193. package/src/surfaces/admin/api/product-configuration/examples/select-bundle-components.jsx +50 -0
  194. package/src/surfaces/admin/api/product-configuration/examples/select-variant-components.jsx +50 -0
  195. package/src/surfaces/admin/api/product-configuration/product-details-configuration.ts +36 -6
  196. package/src/surfaces/admin/api/product-configuration/product-variant-details-configuration.ts +36 -6
  197. package/src/surfaces/admin/api/purchase-options-card/examples/manage-subscription.jsx +45 -0
  198. package/src/surfaces/admin/api/purchase-options-card/examples/remove-from-plan.jsx +44 -0
  199. package/src/surfaces/admin/api/purchase-options-card/examples/validate-selling-plan.jsx +47 -0
  200. package/src/surfaces/admin/api/purchase-options-card-action.ts +11 -1
  201. package/src/surfaces/admin/api/resource-picker/examples/action.jsx +25 -0
  202. package/src/surfaces/admin/api/resource-picker/examples/collection-picker.jsx +22 -0
  203. package/src/surfaces/admin/api/resource-picker/examples/filter-query.jsx +22 -0
  204. package/src/surfaces/admin/api/resource-picker/examples/filters.jsx +27 -0
  205. package/src/surfaces/admin/api/resource-picker/examples/multiple-limited.jsx +25 -0
  206. package/src/surfaces/admin/api/resource-picker/examples/multiple-unlimited.jsx +25 -0
  207. package/src/surfaces/admin/api/resource-picker/examples/product-picker.jsx +22 -0
  208. package/src/surfaces/admin/api/resource-picker/examples/product-variant-picker.jsx +22 -0
  209. package/src/surfaces/admin/api/resource-picker/examples/query.jsx +25 -0
  210. package/src/surfaces/admin/api/resource-picker/examples/selection-ids.jsx +28 -0
  211. package/src/surfaces/admin/api/resource-picker/examples/selection.jsx +22 -0
  212. package/src/surfaces/admin/api/resource-picker/resource-picker.ts +181 -21
  213. package/src/surfaces/admin/api/shared.ts +7 -1
  214. package/src/surfaces/admin/api/should-render/examples/bulk-selection-check.jsx +8 -0
  215. package/src/surfaces/admin/api/should-render/examples/check-order-status.jsx +7 -0
  216. package/src/surfaces/admin/api/should-render/examples/check-product-tag.jsx +7 -0
  217. package/src/surfaces/admin/api/should-render/should-render.ts +8 -1
  218. package/src/surfaces/admin/api/standard/examples/authenticate-backend-request.jsx +40 -0
  219. package/src/surfaces/admin/api/standard/examples/persist-settings.jsx +43 -0
  220. package/src/surfaces/admin/api/standard/examples/query-and-mutate.jsx +75 -0
  221. package/src/surfaces/admin/api/standard/standard-rendering.ts +18 -0
  222. package/src/surfaces/admin/api/standard/standard.ts +20 -10
  223. package/src/surfaces/admin/api/standard/storage.ts +21 -27
  224. package/src/surfaces/admin/api.ts +1 -0
  225. package/src/surfaces/admin/components/ActionExtensionComponents.ts +3 -0
  226. package/src/surfaces/admin/components/BlockExtensionComponents.ts +3 -0
  227. package/src/surfaces/admin/components/FormExtensionComponents.ts +3 -0
  228. package/src/surfaces/admin/components/FunctionSettingsComponents.ts +3 -0
  229. package/src/surfaces/admin/components/PrintActionExtensionComponents.ts +3 -0
  230. package/src/surfaces/admin/components/StandardComponents.ts +3 -0
  231. package/src/surfaces/admin/extension-targets.ts +85 -169
  232. package/src/surfaces/checkout/api/address-autocomplete/standard.ts +5 -0
  233. package/src/surfaces/checkout/api/checkout/checkout.ts +14 -1
  234. package/src/surfaces/checkout/api/standard/standard.ts +5 -3
  235. package/src/surfaces/checkout/preact/metafield.ts +1 -0
  236. package/src/surfaces/checkout/preact/metafields.ts +1 -0
  237. package/src/surfaces/point-of-sale/components/EmptyState.d.ts +44 -34
  238. package/src/surfaces/point-of-sale/components/Stack.d.ts +10 -10
  239. package/src/surfaces/point-of-sale/components/TextField.d.ts +1 -1
  240. package/src/surfaces/point-of-sale/components/components-shared.d.ts +3249 -2916
  241. package/src/surfaces/point-of-sale/components.d.ts +6504 -5829
  242. package/src/surfaces/admin/api/intents/examples/create-article.js +0 -9
  243. package/src/surfaces/admin/api/intents/examples/create-catalog.js +0 -9
  244. package/src/surfaces/admin/api/intents/examples/create-collection.js +0 -9
  245. package/src/surfaces/admin/api/intents/examples/create-customer.js +0 -9
  246. package/src/surfaces/admin/api/intents/examples/create-discount.js +0 -11
  247. package/src/surfaces/admin/api/intents/examples/create-market.js +0 -9
  248. package/src/surfaces/admin/api/intents/examples/create-menu.js +0 -9
  249. package/src/surfaces/admin/api/intents/examples/create-metafield-definition.js +0 -11
  250. package/src/surfaces/admin/api/intents/examples/create-metaobject-definition.js +0 -9
  251. package/src/surfaces/admin/api/intents/examples/create-metaobject.js +0 -11
  252. package/src/surfaces/admin/api/intents/examples/create-page.js +0 -9
  253. package/src/surfaces/admin/api/intents/examples/create-product.js +0 -9
  254. package/src/surfaces/admin/api/intents/examples/create-variant.js +0 -11
  255. package/src/surfaces/admin/api/intents/examples/edit-article.js +0 -11
  256. package/src/surfaces/admin/api/intents/examples/edit-catalog.js +0 -11
  257. package/src/surfaces/admin/api/intents/examples/edit-collection.js +0 -11
  258. package/src/surfaces/admin/api/intents/examples/edit-customer.js +0 -11
  259. package/src/surfaces/admin/api/intents/examples/edit-discount.js +0 -11
  260. package/src/surfaces/admin/api/intents/examples/edit-market.js +0 -11
  261. package/src/surfaces/admin/api/intents/examples/edit-menu.js +0 -11
  262. package/src/surfaces/admin/api/intents/examples/edit-metafield-definition.js +0 -12
  263. package/src/surfaces/admin/api/intents/examples/edit-metaobject-definition.js +0 -11
  264. package/src/surfaces/admin/api/intents/examples/edit-metaobject.js +0 -12
  265. package/src/surfaces/admin/api/intents/examples/edit-page.js +0 -11
  266. package/src/surfaces/admin/api/intents/examples/edit-product.js +0 -11
  267. package/src/surfaces/admin/api/intents/examples/edit-variant.js +0 -12
  268. package/src/surfaces/admin/api/picker/examples/direct-api.js +0 -73
  269. package/src/surfaces/admin/api/picker/examples/disabled.js +0 -16
  270. package/src/surfaces/admin/api/picker/examples/minimal.js +0 -16
  271. package/src/surfaces/admin/api/picker/examples/multiple-limit.js +0 -21
  272. package/src/surfaces/admin/api/picker/examples/multiple-true.js +0 -21
  273. package/src/surfaces/admin/api/picker/examples/preselected.js +0 -16
  274. package/src/surfaces/admin/api/picker/examples/template-picker.js +0 -37
  275. package/src/surfaces/admin/api/resource-picker/examples/action.js +0 -4
  276. package/src/surfaces/admin/api/resource-picker/examples/collection-picker.js +0 -1
  277. package/src/surfaces/admin/api/resource-picker/examples/filter-query.js +0 -6
  278. package/src/surfaces/admin/api/resource-picker/examples/filters.js +0 -9
  279. package/src/surfaces/admin/api/resource-picker/examples/multiple-limited.js +0 -4
  280. package/src/surfaces/admin/api/resource-picker/examples/multiple-unlimited.js +0 -4
  281. package/src/surfaces/admin/api/resource-picker/examples/product-picker.js +0 -3
  282. package/src/surfaces/admin/api/resource-picker/examples/product-variant-picker.js +0 -1
  283. package/src/surfaces/admin/api/resource-picker/examples/query.js +0 -4
  284. package/src/surfaces/admin/api/resource-picker/examples/selection-ids.js +0 -16
  285. package/src/surfaces/admin/api/resource-picker/examples/selection.js +0 -7
@@ -1,33 +1,45 @@
1
+ /**
2
+ * A [metafield](/docs/apps/build/metafields) that stores validation function configuration data. Use metafields to persist settings that control how your validation function behaves, such as minimum quantities, restricted shipping zones, or custom validation rules.
3
+ */
1
4
  interface Metafield {
5
+ /** A human-readable description explaining the metafield's purpose and how it affects validation behavior. Use this to document your settings for other developers. */
2
6
  description?: string;
7
+ /** The unique global identifier (GID) for this metafield. Use this ID to reference the metafield in GraphQL queries or updates. */
3
8
  id: string;
9
+ /** The namespace that organizes related metafields together. All metafields for a validation should use a consistent namespace to group related settings. */
4
10
  namespace: string;
11
+ /** The unique key identifying this metafield within its namespace. This key determines how you access the metafield value (for example, `'min_quantity'` or `'blocked_countries'`). */
5
12
  key: string;
13
+ /** The metafield value stored as a string. Parse this value according to the metafield type to use it in your settings UI. */
6
14
  value: string;
15
+ /** The metafield [definition type](/docs/apps/build/metafields/list-of-data-types) that specifies the value format and validation rules. Use this to determine how to parse and display the value. */
7
16
  type: string;
8
17
  }
18
+
19
+ /**
20
+ * A validation configuration that exists and is active in the shop. Use this object to access the validation's current settings and metafields when merchants edit an existing validation.
21
+ */
9
22
  interface Validation {
10
- /**
11
- * the validation's gid when active in a shop
12
- */
23
+ /** The validation's unique global identifier (GID). Use this ID to reference the validation in GraphQL operations or when saving updated settings. */
13
24
  id: string;
14
- /**
15
- * the metafields owned by the validation
16
- */
25
+ /** An array of [metafields](/docs/apps/build/metafields) that store the validation's configuration values. Use these metafields to populate your settings UI with the current validation configuration. */
17
26
  metafields: Metafield[];
18
27
  }
19
28
 
29
+ /**
30
+ * A [Shopify Function](/docs/apps/build/functions) that implements cart and checkout validation logic. This identifies which function the settings interface is configuring.
31
+ */
20
32
  interface ShopifyFunction {
21
- /**
22
- * the validation function's unique identifier
23
- */
33
+ /** The [Shopify Function's](/docs/apps/build/functions) unique global identifier (GID). Use this ID to associate settings changes with the correct function. */
24
34
  id: string;
25
35
  }
26
36
 
27
37
  /**
28
- * The object that exposes the validation with its settings.
38
+ * The `data` object exposed to validation settings extensions in the `admin.settings.validation.render` target. Use this to access the current validation configuration and populate your settings interface with existing values.
29
39
  */
30
40
  export interface ValidationData {
41
+ /** The validation configuration containing the validation ID and metafields. Present when editing an existing validation, absent when creating a new validation. Use the presence of this value to determine if you're in create or edit mode. */
31
42
  validation?: Validation;
43
+ /** The [Shopify Function](/docs/apps/build/functions) that implements the validation logic. Use this ID to associate configuration changes with the correct function. */
32
44
  shopifyFunction: ShopifyFunction;
33
45
  }
@@ -1,31 +1,66 @@
1
1
  import {SupportedDefinitionType} from '../shared';
2
2
 
3
+ /**
4
+ * A metafield update or creation operation. Use this to set or modify metafield values that store validation function configuration data.
5
+ */
3
6
  interface MetafieldUpdateChange {
7
+ /** Identifies this as an update operation. Always set to `'updateMetafield'` for updates. */
4
8
  type: 'updateMetafield';
9
+ /** The unique key identifying the metafield within its namespace. Use descriptive keys that indicate the setting's purpose (for example, `'min_quantity'` or `'shipping_restriction'`). */
5
10
  key: string;
11
+ /** The namespace that organizes related metafields. When omitted, a default namespace is assigned. Use consistent namespaces to group related settings. */
6
12
  namespace?: string;
13
+ /** The metafield value to store. Can be a string or number depending on your configuration needs. */
7
14
  value: string | number;
15
+ /** The [data type](/docs/apps/build/metafields/list-of-data-types) that defines how the value is formatted and validated. When omitted, preserves the existing type for updates or uses a default for new metafields. Choose a type that matches your value format. */
8
16
  valueType?: SupportedDefinitionType;
9
17
  }
10
18
 
19
+ /**
20
+ * A metafield removal operation. Use this to delete metafields that are no longer needed for your validation configuration.
21
+ */
11
22
  interface MetafieldRemoveChange {
23
+ /** Identifies this as a removal operation. Always set to `'removeMetafield'` for deletions. */
12
24
  type: 'removeMetafield';
25
+ /** The unique key of the metafield to remove. Must match the key used when the metafield was created. */
13
26
  key: string;
27
+ /** The namespace containing the metafield to remove. Required to ensure the correct metafield is targeted, as the same key can exist in different namespaces. */
14
28
  namespace: string;
15
29
  }
16
30
 
31
+ /**
32
+ * A metafield change operation that can either update or remove a metafield. Pass this to `applyMetafieldChange` to modify validation settings stored in metafields.
33
+ */
17
34
  type MetafieldChange = MetafieldUpdateChange | MetafieldRemoveChange;
35
+
36
+ /**
37
+ * A failed metafield change operation result. Use the error message to understand what went wrong and fix the issue, such as validation errors, permission problems, or invalid metafield types.
38
+ */
18
39
  interface MetafieldChangeResultError {
40
+ /** Indicates the operation failed. Check this value to determine if you need to handle an error. */
19
41
  type: 'error';
42
+ /** A human-readable error message explaining why the operation failed. Use this to debug issues or display feedback to merchants. */
20
43
  message: string;
21
44
  }
45
+
46
+ /**
47
+ * A successful metafield change operation result. The metafield was updated or removed as requested and the changes are now saved.
48
+ */
22
49
  interface MetafieldChangeSuccess {
50
+ /** Indicates the operation succeeded. When this value is `'success'`, the metafield change was applied successfully. */
23
51
  type: 'success';
24
52
  }
53
+
54
+ /**
55
+ * The result returned after attempting to change a metafield. Check the `type` property to determine if the operation succeeded (`'success'`) or failed (`'error'`), then handle the result appropriately in your extension.
56
+ */
25
57
  type MetafieldChangeResult =
26
58
  | MetafieldChangeSuccess
27
59
  | MetafieldChangeResultError;
28
60
 
61
+ /**
62
+ * A function that applies metafield changes to validation settings. Call this function with an update or removal operation, then await the Promise to receive a result indicating success or failure. Use the result to provide feedback or handle errors in your settings interface.
63
+ */
29
64
  export type ApplyMetafieldChange = (
30
65
  change: MetafieldChange,
31
66
  ) => Promise<MetafieldChangeResult>;
@@ -1,15 +1,19 @@
1
- import type {StandardApi} from '../standard/standard';
1
+ import type {StandardRenderingExtensionApi} from '../standard/standard-rendering';
2
2
  import type {ExtensionTarget as AnyExtensionTarget} from '../../extension-targets';
3
3
 
4
4
  import {ApplyMetafieldChange} from './metafields';
5
5
  import {ValidationData} from './launch-options';
6
6
 
7
+ /**
8
+ * The `ValidationSettingsApi` object provides methods for configuring cart and checkout validation functions. Access the following properties on the `ValidationSettingsApi` object to manage validation settings and metafields.
9
+ */
7
10
  export interface ValidationSettingsApi<
8
11
  ExtensionTarget extends AnyExtensionTarget,
9
- > extends StandardApi<ExtensionTarget> {
12
+ > extends StandardRenderingExtensionApi<ExtensionTarget> {
10
13
  /**
11
- * Applies a change to the validation settings.
14
+ * Updates or removes [metafields](/docs/apps/build/metafields) that store validation function configuration. Use this to save merchant settings for your validation function.
12
15
  */
13
16
  applyMetafieldChange: ApplyMetafieldChange;
17
+ /** The validation being configured and its associated [metafields](/docs/apps/build/metafields) storing function settings. */
14
18
  data: ValidationData;
15
19
  }
@@ -2,42 +2,54 @@ import type {StandardApi} from '../standard/standard';
2
2
  import type {I18n} from '../../../../api';
3
3
  import type {ExtensionTarget as AnyExtensionTarget} from '../../extension-targets';
4
4
 
5
+ /**
6
+ * The `CustomerSegmentTemplateApi` object provides methods for creating customer segment templates. Access the following properties on the `CustomerSegmentTemplateApi` object to build templates with translated content.
7
+ */
5
8
  export interface CustomerSegmentTemplateApi<
6
9
  ExtensionTarget extends AnyExtensionTarget,
7
10
  > extends StandardApi<ExtensionTarget> {
8
- /* Utilities for translating content according to the current `localization` of the admin. */
11
+ /** Utilities for translating template content into the merchant's language. */
9
12
  i18n: I18n;
10
13
  /** @private */
11
14
  __enabledFeatures: string[];
12
15
  }
13
16
 
17
+ /**
18
+ * Standard customer metafields that can be referenced as template dependencies.
19
+ */
14
20
  export type CustomerStandardMetafieldDependency = 'facts.birth_date';
21
+
22
+ /**
23
+ * Defines a customer segment template that merchants can use to create targeted customer groups.
24
+ */
15
25
  export interface CustomerSegmentTemplate {
16
26
  /**
17
- * The localized title of the template.
27
+ * The template title in the merchant's language.
18
28
  */
19
29
  title: string;
20
30
  /**
21
- * The localized description of the template. An array can be used for multiple paragraphs.
31
+ * The template description in the merchant's language. Use an array for multiple paragraphs.
22
32
  */
23
33
  description: string | string[];
24
34
  /**
25
- * The code snippet to render in the template with syntax highlighting. The `query` is not validated in the template.
35
+ * The segment query code to display in the template with syntax highlighting. This code is shown to merchants but not validated. Test your queries in the Shopify admin segment editor before including them in templates.
26
36
  */
27
37
  query: string;
28
38
  /**
29
- * The code snippet to insert in the segment editor. If missing, `query` will be used. The `queryToInsert` is not validated in the template.
39
+ * The segment query code to insert when the merchant selects this template. If omitted, the `query` value is used instead. This code is inserted into the editor but not validated. Test your queries in the Shopify admin segment editor before including them in templates.
30
40
  */
31
41
  queryToInsert: string;
32
42
  /**
33
- * The list of customer standard metafields or custom metafields used in the template's query.
43
+ * Customer metafields required by this template's query. Declare dependencies so the admin can guide merchants to set up required metafields before using the template.
34
44
  */
35
45
  dependencies?: {
46
+ /** Standard Shopify customer metafields used in the query. */
36
47
  standardMetafields?: CustomerStandardMetafieldDependency[];
48
+ /** Custom [metafield](/docs/apps/build/metafields) definitions used in the query. */
37
49
  customMetafields?: string[];
38
50
  };
39
51
  /**
40
- * ISO 8601-encoded date and time string. A "New" badge will be rendered for templates introduced in the last month.
52
+ * The creation date in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. Templates created within the last month display a "New" badge.
41
53
  */
42
54
  createdOn: string;
43
55
  }
@@ -0,0 +1,30 @@
1
+ export default () => {
2
+ return {
3
+ templates: [
4
+ {
5
+ title: 'Cart abandoners',
6
+ description: [
7
+ 'Customers who abandoned carts in the last 7 days',
8
+ 'Use this segment for email recovery campaigns',
9
+ ],
10
+ query: `{
11
+ abandoned_checkouts_count: {
12
+ min: 1
13
+ }
14
+ last_abandoned_order_date: {
15
+ min: "${new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString()}"
16
+ }
17
+ }`,
18
+ queryToInsert: `{
19
+ abandoned_checkouts_count: {
20
+ min: 1
21
+ }
22
+ last_abandoned_order_date: {
23
+ min: "LAST_7_DAYS"
24
+ }
25
+ }`,
26
+ createdOn: '2025-01-15T00:00:00Z',
27
+ },
28
+ ],
29
+ };
30
+ };
@@ -0,0 +1,32 @@
1
+ export default () => {
2
+ return {
3
+ templates: [
4
+ {
5
+ title: 'Birthday this month',
6
+ description: 'Customers with birthdays in the current month',
7
+ query: `{
8
+ metafields: {
9
+ key: "birth_date"
10
+ namespace: "customer"
11
+ value: {
12
+ month: ${new Date().getMonth() + 1}
13
+ }
14
+ }
15
+ }`,
16
+ queryToInsert: `{
17
+ metafields: {
18
+ key: "birth_date"
19
+ namespace: "customer"
20
+ value: {
21
+ month: ${new Date().getMonth() + 1}
22
+ }
23
+ }
24
+ }`,
25
+ dependencies: {
26
+ standardMetafields: ['facts.birth_date'],
27
+ },
28
+ createdOn: '2025-01-15T00:00:00Z',
29
+ },
30
+ ],
31
+ };
32
+ };
@@ -0,0 +1,27 @@
1
+ export default () => {
2
+ return {
3
+ templates: [
4
+ {
5
+ title: shopify.i18n.translate('templates.highValue.title'),
6
+ description: shopify.i18n.translate('templates.highValue.description'),
7
+ query: `{
8
+ total_spent: {
9
+ min: 500
10
+ }
11
+ orders_count: {
12
+ min: 5
13
+ }
14
+ }`,
15
+ queryToInsert: `{
16
+ total_spent: {
17
+ min: 500
18
+ }
19
+ orders_count: {
20
+ min: 5
21
+ }
22
+ }`,
23
+ createdOn: '2025-01-15T00:00:00Z',
24
+ },
25
+ ],
26
+ };
27
+ };
@@ -4,13 +4,18 @@ import type {ExtensionTarget as AnyExtensionTarget} from '../../extension-target
4
4
  import {ApplyMetafieldChange} from './metafields';
5
5
  import {DiscountFunctionSettingsData, DiscountsApi} from './launch-options';
6
6
 
7
+ /**
8
+ * The `DiscountFunctionSettingsApi` object provides methods for configuring discount functions. Access the following properties on the `DiscountFunctionSettingsApi` object to manage function settings and metafields.
9
+ */
7
10
  export interface DiscountFunctionSettingsApi<
8
11
  ExtensionTarget extends AnyExtensionTarget,
9
12
  > extends Omit<BlockExtensionApi<ExtensionTarget>, 'data'> {
10
13
  /**
11
- * Applies a change to the discount function settings.
14
+ * Updates or removes [metafields](/docs/apps/build/metafields) that store discount function configuration. Use this to save merchant settings for your discount function.
12
15
  */
13
16
  applyMetafieldChange: ApplyMetafieldChange;
17
+ /** The discount being configured and its associated [metafields](/docs/apps/build/metafields) storing function settings. */
14
18
  data: DiscountFunctionSettingsData;
19
+ /** The `discounts` object provides reactive access to discount configuration, including discount classes and the discount method. Use the signals to read current values and the update functions to modify discount classes in your settings UI. These values automatically update when changed by the merchant or system. */
15
20
  discounts: DiscountsApi;
16
21
  }
@@ -0,0 +1,39 @@
1
+ import {render} from 'preact';
2
+ import {useState} from 'preact/hooks';
3
+
4
+ export default async () => {
5
+ render(<Extension />, document.body);
6
+ };
7
+
8
+ function Extension() {
9
+ const [threshold, setThreshold] = useState('50.00');
10
+ const [saved, setSaved] = useState(false);
11
+
12
+ const handleSave = async () => {
13
+ const result = await shopify.applyMetafieldChange({
14
+ type: 'updateMetafield',
15
+ namespace: 'discount-config',
16
+ key: 'minimum_purchase',
17
+ value: threshold,
18
+ valueType: 'number_decimal',
19
+ });
20
+
21
+ if (result.type === 'success') {
22
+ setSaved(true);
23
+ } else {
24
+ console.error('Configuration failed:', result.message);
25
+ }
26
+ };
27
+
28
+ return (
29
+ <s-function-settings>
30
+ <s-text-field
31
+ label="Minimum purchase amount"
32
+ value={threshold}
33
+ onChange={(value) => setThreshold(value)}
34
+ />
35
+ <s-button onClick={handleSave}>Save Threshold</s-button>
36
+ {saved && <s-banner status="success">Threshold configured!</s-banner>}
37
+ </s-function-settings>
38
+ );
39
+ }
@@ -0,0 +1,45 @@
1
+ import {render} from 'preact';
2
+ import {useState} from 'preact/hooks';
3
+
4
+ export default async () => {
5
+ render(<Extension />, document.body);
6
+ };
7
+
8
+ function Extension() {
9
+ const [tags, setTags] = useState('vip, wholesale, premium');
10
+ const [maxUses, setMaxUses] = useState('5');
11
+
12
+ const handleSave = async () => {
13
+ await shopify.applyMetafieldChange({
14
+ type: 'updateMetafield',
15
+ namespace: 'discount-config',
16
+ key: 'eligible_customer_tags',
17
+ value: JSON.stringify(tags.split(',').map((t) => t.trim())),
18
+ valueType: 'json',
19
+ });
20
+
21
+ await shopify.applyMetafieldChange({
22
+ type: 'updateMetafield',
23
+ namespace: 'discount-config',
24
+ key: 'max_uses_per_customer',
25
+ value: maxUses,
26
+ valueType: 'number_integer',
27
+ });
28
+ };
29
+
30
+ return (
31
+ <s-function-settings>
32
+ <s-text-field
33
+ label="Eligible customer tags (comma-separated)"
34
+ value={tags}
35
+ onChange={(value) => setTags(value)}
36
+ />
37
+ <s-number-field
38
+ label="Max uses per customer"
39
+ value={maxUses}
40
+ onChange={(value) => setMaxUses(value)}
41
+ />
42
+ <s-button onClick={handleSave}>Save Eligibility Rules</s-button>
43
+ </s-function-settings>
44
+ );
45
+ }
@@ -0,0 +1,45 @@
1
+ import {render} from 'preact';
2
+ import {useState, useEffect} from 'preact/hooks';
3
+
4
+ export default async () => {
5
+ render(<Extension />, document.body);
6
+ };
7
+
8
+ function Extension() {
9
+ const {data} = shopify;
10
+ const [settings, setSettings] = useState({});
11
+
12
+ useEffect(() => {
13
+ const initializeSettings = async () => {
14
+ const existingSettings = data.metafields.reduce((acc, field) => {
15
+ acc[field.key] = field.value;
16
+ return acc;
17
+ }, {});
18
+
19
+ setSettings(existingSettings);
20
+
21
+ if (!existingSettings.eligible_tags) {
22
+ await shopify.applyMetafieldChange({
23
+ type: 'updateMetafield',
24
+ namespace: 'discount-config',
25
+ key: 'eligible_tags',
26
+ value: JSON.stringify(['vip', 'wholesale']),
27
+ valueType: 'json',
28
+ });
29
+ }
30
+ };
31
+
32
+ initializeSettings();
33
+ }, [data]);
34
+
35
+ return (
36
+ <s-function-settings>
37
+ <s-text>Current settings:</s-text>
38
+ {Object.entries(settings).map(([key, value]) => (
39
+ <s-text key={key}>
40
+ {key}: {String(value)}
41
+ </s-text>
42
+ ))}
43
+ </s-function-settings>
44
+ );
45
+ }
@@ -3,47 +3,65 @@ import type {
3
3
  UpdateSignalFunction,
4
4
  } from '../../../../shared';
5
5
 
6
+ /**
7
+ * A [metafield](/docs/apps/build/metafields) that stores discount function configuration data. Use metafields to persist settings that control how your discount function behaves, such as discount thresholds, eligibility rules, or custom discount logic parameters.
8
+ */
6
9
  interface Metafield {
10
+ /** A human-readable description explaining the metafield's purpose and how it affects discount behavior. Use this to document your settings for other developers. */
7
11
  description?: string;
12
+ /** The unique global identifier (GID) for this metafield. Use this ID to reference the metafield in GraphQL queries or updates. */
8
13
  id: string;
14
+ /** The namespace that organizes related metafields together. All metafields for a discount should use a consistent namespace to group related settings. */
9
15
  namespace: string;
16
+ /** The unique key identifying this metafield within its namespace. This key determines how you access the metafield value (for example, `'min_purchase_amount'` or `'eligible_customer_tags'`). */
10
17
  key: string;
18
+ /** The metafield value stored as a string. Parse this value according to the metafield type to use it in your settings UI. */
11
19
  value: string;
20
+ /** The metafield [definition type](/docs/apps/build/metafields/list-of-data-types) that specifies the value format and validation rules. Use this to determine how to parse and display the value. */
12
21
  type: string;
13
22
  }
14
23
 
15
- type DiscountClass = 'product' | 'order' | 'shipping';
24
+ /**
25
+ * The discount class that determines where the discount applies in the purchase flow. Use this to understand what type of discount the merchant is configuring (product-level, order-level, or shipping).
26
+ */
27
+ export enum DiscountClass {
28
+ /** The discount applies to specific products or product variants. Use this for discounts that reduce the price of individual line items (for example, "20% off selected products"). */
29
+ Product = 'PRODUCT',
30
+ /** The discount applies to the entire order total. Use this for cart-wide discounts that reduce the subtotal (for example, "$10 off orders over $50"). */
31
+ Order = 'ORDER',
32
+ /** The discount applies to shipping costs. Use this for free shipping or reduced shipping rate discounts (for example, "Free shipping on orders over $100"). */
33
+ Shipping = 'SHIPPING',
34
+ }
16
35
 
36
+ /**
37
+ * The method used to apply a discount. Use `'automatic'` for discounts that apply automatically at checkout, or `'code'` for discounts that require a code entered by the customer.
38
+ */
17
39
  type DiscountMethod = 'automatic' | 'code';
18
40
 
19
41
  /**
20
- * The object that exposes the validation with its settings.
42
+ * The `data` object exposed to discount function settings extensions in the `admin.discount-details.function-settings.render` target. Use this to access the current discount configuration and populate your settings interface with existing values.
21
43
  */
22
44
  export interface DiscountFunctionSettingsData {
23
- /**
24
- * The unique identifier for the discount.
25
- */
45
+ /** The discount's unique global identifier (GID) in the [GraphQL Admin API](/docs/api/admin-graphql) format (for example, `gid://shopify/DiscountAutomaticApp/123`). Use this ID to associate settings with the correct discount or query discount data. */
26
46
  id: string;
27
- /**
28
- * The discount metafields.
29
- */
47
+ /** An array of [metafields](/docs/apps/build/metafields) that store the discount function's configuration values. Use these metafields to populate your settings UI with the current discount configuration and display existing settings to merchants. */
30
48
  metafields: Metafield[];
31
49
  }
32
50
 
33
51
  /**
34
- * Reactive Api for managing discount function configuration.
52
+ * The `DiscountsApi` object provides reactive access to discount configuration. Use the signals to read discount classes and method, and the update function to change which parts of the purchase (products, order, or shipping) the discount affects.
35
53
  */
36
54
  export interface DiscountsApi {
37
55
  /**
38
- * A signal that contains the discount classes.
56
+ * A signal that contains the discount classes (Product, Order, or Shipping). Read this to determine where the discount applies in the purchase flow. A discount can apply to multiple classes simultaneously.
39
57
  */
40
58
  discountClasses: ReadonlySignalLike<DiscountClass[]>;
41
59
  /**
42
- * A function that updates the discount classes.
60
+ * A function that updates the discount classes to change where the discount applies. Call this function with an array of `DiscountClass` values to set which parts of the purchase (products, order total, or shipping) the discount affects.
43
61
  */
44
62
  updateDiscountClasses: UpdateSignalFunction<DiscountClass[]>;
45
63
  /**
46
- * A signal that contains the discount method.
64
+ * A signal that contains the discount method (`'automatic'` or `'code'`). Read this to determine whether the discount applies automatically at checkout or requires a customer-entered code.
47
65
  */
48
66
  discountMethod: ReadonlySignalLike<DiscountMethod>;
49
67
  }
@@ -1,31 +1,66 @@
1
1
  import {SupportedDefinitionType} from '../shared';
2
2
 
3
+ /**
4
+ * A metafield update or creation operation. Use this to set or modify metafield values that store discount function configuration data.
5
+ */
3
6
  interface MetafieldUpdateChange {
7
+ /** Identifies this as an update operation. Always set to `'updateMetafield'` for updates. */
4
8
  type: 'updateMetafield';
9
+ /** The unique key identifying the metafield within its namespace. Use descriptive keys that indicate the setting's purpose (for example, `'min_purchase_amount'` or `'eligible_customer_tags'`). */
5
10
  key: string;
11
+ /** The namespace that organizes related metafields. When omitted, a default namespace is assigned. Use consistent namespaces to group related settings. */
6
12
  namespace?: string;
13
+ /** The metafield value to store. Can be a string or number depending on your configuration needs. */
7
14
  value: string | number;
15
+ /** The [data type](/docs/apps/build/metafields/list-of-data-types) that defines how the value is formatted and validated. When omitted, preserves the existing type for updates or uses a default for new metafields. Choose a type that matches your value format. */
8
16
  valueType?: SupportedDefinitionType;
9
17
  }
10
18
 
19
+ /**
20
+ * A metafield removal operation. Use this to delete metafields that are no longer needed for your discount configuration.
21
+ */
11
22
  interface MetafieldRemoveChange {
23
+ /** Identifies this as a removal operation. Always set to `'removeMetafield'` for deletions. */
12
24
  type: 'removeMetafield';
25
+ /** The unique key of the metafield to remove. Must match the key used when the metafield was created. */
13
26
  key: string;
27
+ /** The namespace containing the metafield to remove. Required to ensure the correct metafield is targeted, as the same key can exist in different namespaces. */
14
28
  namespace: string;
15
29
  }
16
30
 
31
+ /**
32
+ * A metafield change operation that can either update or remove a metafield. Pass this to `applyMetafieldChange` to modify discount settings stored in metafields.
33
+ */
17
34
  type MetafieldChange = MetafieldUpdateChange | MetafieldRemoveChange;
35
+
36
+ /**
37
+ * A failed metafield change operation result. Use the error message to understand what went wrong and fix the issue, such as validation errors, permission problems, or invalid metafield types.
38
+ */
18
39
  interface MetafieldChangeResultError {
40
+ /** Indicates the operation failed. Check this value to determine if you need to handle an error. */
19
41
  type: 'error';
42
+ /** A human-readable error message explaining why the operation failed. Use this to debug issues or display feedback to merchants. */
20
43
  message: string;
21
44
  }
45
+
46
+ /**
47
+ * A successful metafield change operation result. The metafield was updated or removed as requested and the changes are now saved.
48
+ */
22
49
  interface MetafieldChangeSuccess {
50
+ /** Indicates the operation succeeded. When this value is `'success'`, the metafield change was applied successfully. */
23
51
  type: 'success';
24
52
  }
53
+
54
+ /**
55
+ * The result returned after attempting to change a metafield. Check the `type` property to determine if the operation succeeded (`'success'`) or failed (`'error'`), then handle the result appropriately in your extension.
56
+ */
25
57
  type MetafieldChangeResult =
26
58
  | MetafieldChangeSuccess
27
59
  | MetafieldChangeResultError;
28
60
 
61
+ /**
62
+ * A function that applies metafield changes to discount function settings. Call this function with an update or removal operation, then await the Promise to receive a result indicating success or failure. Use the result to provide feedback or handle errors in your settings interface.
63
+ */
29
64
  export type ApplyMetafieldChange = (
30
65
  change: MetafieldChange,
31
66
  ) => Promise<MetafieldChangeResult>;
@@ -0,0 +1,35 @@
1
+ import {render} from 'preact';
2
+ import {useState} from 'preact/hooks';
3
+
4
+ export default async () => {
5
+ render(<Extension />, document.body);
6
+ };
7
+
8
+ function Extension() {
9
+ const [result, setResult] = useState(null);
10
+ const [creating, setCreating] = useState(false);
11
+
12
+ const handleCreate = async () => {
13
+ setCreating(true);
14
+
15
+ const activity = await shopify.intents.invoke('create:shopify/Article');
16
+ const response = await activity.complete;
17
+
18
+ setResult(response);
19
+ setCreating(false);
20
+ };
21
+
22
+ return (
23
+ <s-admin-block heading="Create Article">
24
+ <s-button onClick={handleCreate} disabled={creating}>
25
+ {creating ? 'Creating...' : 'Launch Article Creator'}
26
+ </s-button>
27
+ {result?.code === 'ok' && (
28
+ <s-banner status="success">Article created successfully!</s-banner>
29
+ )}
30
+ {result?.code === 'closed' && (
31
+ <s-text>Creation cancelled</s-text>
32
+ )}
33
+ </s-admin-block>
34
+ );
35
+ }