shop-cli 0.1.1

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 (350) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +392 -0
  3. package/bin/shop-cli.js +17 -0
  4. package/bin/shop.js +16 -0
  5. package/dist/adminClient.d.ts +34 -0
  6. package/dist/adminClient.js +144 -0
  7. package/dist/cli/client.d.ts +10 -0
  8. package/dist/cli/client.js +56 -0
  9. package/dist/cli/command.d.ts +5 -0
  10. package/dist/cli/command.js +62 -0
  11. package/dist/cli/errors.d.ts +4 -0
  12. package/dist/cli/errors.js +35 -0
  13. package/dist/cli/gid.d.ts +3 -0
  14. package/dist/cli/gid.js +42 -0
  15. package/dist/cli/globalFlags.d.ts +15 -0
  16. package/dist/cli/globalFlags.js +100 -0
  17. package/dist/cli/headers.d.ts +2 -0
  18. package/dist/cli/headers.js +79 -0
  19. package/dist/cli/help/format.d.ts +8 -0
  20. package/dist/cli/help/format.js +78 -0
  21. package/dist/cli/help/registry.d.ts +5 -0
  22. package/dist/cli/help/registry.js +6443 -0
  23. package/dist/cli/help/render.d.ts +8 -0
  24. package/dist/cli/help/render.js +399 -0
  25. package/dist/cli/help/spec.d.ts +39 -0
  26. package/dist/cli/help/spec.js +17 -0
  27. package/dist/cli/input.d.ts +9 -0
  28. package/dist/cli/input.js +104 -0
  29. package/dist/cli/introspection/deprecations.d.ts +1 -0
  30. package/dist/cli/introspection/deprecations.js +83 -0
  31. package/dist/cli/introspection/format.d.ts +6 -0
  32. package/dist/cli/introspection/format.js +63 -0
  33. package/dist/cli/introspection/index.d.ts +14 -0
  34. package/dist/cli/introspection/index.js +89 -0
  35. package/dist/cli/introspection/resources.d.ts +1 -0
  36. package/dist/cli/introspection/resources.js +127 -0
  37. package/dist/cli/output/computedFields.d.ts +39 -0
  38. package/dist/cli/output/computedFields.js +104 -0
  39. package/dist/cli/output.d.ts +37 -0
  40. package/dist/cli/output.js +332 -0
  41. package/dist/cli/parse-command.d.ts +18 -0
  42. package/dist/cli/parse-command.js +109 -0
  43. package/dist/cli/router.d.ts +29 -0
  44. package/dist/cli/router.js +480 -0
  45. package/dist/cli/selection/buildAllSelection.d.ts +13 -0
  46. package/dist/cli/selection/buildAllSelection.js +108 -0
  47. package/dist/cli/selection/graphqlSelection.d.ts +5 -0
  48. package/dist/cli/selection/graphqlSelection.js +301 -0
  49. package/dist/cli/selection/select.d.ts +13 -0
  50. package/dist/cli/selection/select.js +136 -0
  51. package/dist/cli/selection/stripDeprecated.d.ts +2 -0
  52. package/dist/cli/selection/stripDeprecated.js +63 -0
  53. package/dist/cli/suggest.d.ts +5 -0
  54. package/dist/cli/suggest.js +88 -0
  55. package/dist/cli/userErrors.d.ts +4 -0
  56. package/dist/cli/userErrors.js +41 -0
  57. package/dist/cli/verbs/_shared.d.ts +38 -0
  58. package/dist/cli/verbs/_shared.js +181 -0
  59. package/dist/cli/verbs/abandoned-checkouts.d.ts +6 -0
  60. package/dist/cli/verbs/abandoned-checkouts.js +259 -0
  61. package/dist/cli/verbs/app-billing.d.ts +6 -0
  62. package/dist/cli/verbs/app-billing.js +452 -0
  63. package/dist/cli/verbs/apps.d.ts +6 -0
  64. package/dist/cli/verbs/apps.js +296 -0
  65. package/dist/cli/verbs/articles.d.ts +6 -0
  66. package/dist/cli/verbs/articles.js +251 -0
  67. package/dist/cli/verbs/backup.d.ts +6 -0
  68. package/dist/cli/verbs/backup.js +94 -0
  69. package/dist/cli/verbs/blogs.d.ts +6 -0
  70. package/dist/cli/verbs/blogs.js +273 -0
  71. package/dist/cli/verbs/bulk-operations.d.ts +6 -0
  72. package/dist/cli/verbs/bulk-operations.js +272 -0
  73. package/dist/cli/verbs/business-entities.d.ts +6 -0
  74. package/dist/cli/verbs/business-entities.js +102 -0
  75. package/dist/cli/verbs/carrier-services.d.ts +6 -0
  76. package/dist/cli/verbs/carrier-services.js +195 -0
  77. package/dist/cli/verbs/cart-transforms.d.ts +6 -0
  78. package/dist/cli/verbs/cart-transforms.js +141 -0
  79. package/dist/cli/verbs/cash-tracking.d.ts +6 -0
  80. package/dist/cli/verbs/cash-tracking.js +118 -0
  81. package/dist/cli/verbs/catalogs.d.ts +6 -0
  82. package/dist/cli/verbs/catalogs.js +267 -0
  83. package/dist/cli/verbs/channels.d.ts +6 -0
  84. package/dist/cli/verbs/channels.js +120 -0
  85. package/dist/cli/verbs/checkout-branding.d.ts +6 -0
  86. package/dist/cli/verbs/checkout-branding.js +144 -0
  87. package/dist/cli/verbs/checkout-profiles.d.ts +6 -0
  88. package/dist/cli/verbs/checkout-profiles.js +124 -0
  89. package/dist/cli/verbs/collections.d.ts +6 -0
  90. package/dist/cli/verbs/collections.js +620 -0
  91. package/dist/cli/verbs/comments.d.ts +6 -0
  92. package/dist/cli/verbs/comments.js +160 -0
  93. package/dist/cli/verbs/companies.d.ts +6 -0
  94. package/dist/cli/verbs/companies.js +313 -0
  95. package/dist/cli/verbs/company-contacts.d.ts +6 -0
  96. package/dist/cli/verbs/company-contacts.js +318 -0
  97. package/dist/cli/verbs/company-locations.d.ts +6 -0
  98. package/dist/cli/verbs/company-locations.js +467 -0
  99. package/dist/cli/verbs/customer-account-pages.d.ts +6 -0
  100. package/dist/cli/verbs/customer-account-pages.js +97 -0
  101. package/dist/cli/verbs/customer-payment-methods.d.ts +6 -0
  102. package/dist/cli/verbs/customer-payment-methods.js +358 -0
  103. package/dist/cli/verbs/customer-privacy.d.ts +6 -0
  104. package/dist/cli/verbs/customer-privacy.js +167 -0
  105. package/dist/cli/verbs/customer-segments.d.ts +6 -0
  106. package/dist/cli/verbs/customer-segments.js +193 -0
  107. package/dist/cli/verbs/customers.d.ts +6 -0
  108. package/dist/cli/verbs/customers.js +793 -0
  109. package/dist/cli/verbs/delegate-tokens.d.ts +6 -0
  110. package/dist/cli/verbs/delegate-tokens.js +95 -0
  111. package/dist/cli/verbs/delivery-customizations.d.ts +6 -0
  112. package/dist/cli/verbs/delivery-customizations.js +205 -0
  113. package/dist/cli/verbs/delivery-profile-locations.d.ts +6 -0
  114. package/dist/cli/verbs/delivery-profile-locations.js +90 -0
  115. package/dist/cli/verbs/delivery-profiles.d.ts +6 -0
  116. package/dist/cli/verbs/delivery-profiles.js +207 -0
  117. package/dist/cli/verbs/delivery-promises.d.ts +6 -0
  118. package/dist/cli/verbs/delivery-promises.js +262 -0
  119. package/dist/cli/verbs/delivery-settings.d.ts +6 -0
  120. package/dist/cli/verbs/delivery-settings.js +85 -0
  121. package/dist/cli/verbs/discount-nodes.d.ts +6 -0
  122. package/dist/cli/verbs/discount-nodes.js +169 -0
  123. package/dist/cli/verbs/discount-redeem-codes.d.ts +6 -0
  124. package/dist/cli/verbs/discount-redeem-codes.js +102 -0
  125. package/dist/cli/verbs/discount-saved-searches.d.ts +6 -0
  126. package/dist/cli/verbs/discount-saved-searches.js +113 -0
  127. package/dist/cli/verbs/discounts-automatic.d.ts +6 -0
  128. package/dist/cli/verbs/discounts-automatic.js +501 -0
  129. package/dist/cli/verbs/discounts-code.d.ts +6 -0
  130. package/dist/cli/verbs/discounts-code.js +540 -0
  131. package/dist/cli/verbs/disputes.d.ts +6 -0
  132. package/dist/cli/verbs/disputes.js +154 -0
  133. package/dist/cli/verbs/draft-orders.d.ts +6 -0
  134. package/dist/cli/verbs/draft-orders.js +475 -0
  135. package/dist/cli/verbs/events.d.ts +6 -0
  136. package/dist/cli/verbs/events.js +182 -0
  137. package/dist/cli/verbs/file-saved-searches.d.ts +6 -0
  138. package/dist/cli/verbs/file-saved-searches.js +83 -0
  139. package/dist/cli/verbs/files.d.ts +6 -0
  140. package/dist/cli/verbs/files.js +329 -0
  141. package/dist/cli/verbs/finance.d.ts +6 -0
  142. package/dist/cli/verbs/finance.js +115 -0
  143. package/dist/cli/verbs/flow.d.ts +6 -0
  144. package/dist/cli/verbs/flow.js +94 -0
  145. package/dist/cli/verbs/fulfillment-constraint-rules.d.ts +6 -0
  146. package/dist/cli/verbs/fulfillment-constraint-rules.js +139 -0
  147. package/dist/cli/verbs/fulfillment-orders.d.ts +6 -0
  148. package/dist/cli/verbs/fulfillment-orders.js +689 -0
  149. package/dist/cli/verbs/fulfillment-services.d.ts +6 -0
  150. package/dist/cli/verbs/fulfillment-services.js +212 -0
  151. package/dist/cli/verbs/fulfillments.d.ts +6 -0
  152. package/dist/cli/verbs/fulfillments.js +279 -0
  153. package/dist/cli/verbs/gift-cards.d.ts +6 -0
  154. package/dist/cli/verbs/gift-cards.js +359 -0
  155. package/dist/cli/verbs/graphql.d.ts +14 -0
  156. package/dist/cli/verbs/graphql.js +285 -0
  157. package/dist/cli/verbs/inventory-items.d.ts +6 -0
  158. package/dist/cli/verbs/inventory-items.js +164 -0
  159. package/dist/cli/verbs/inventory-shipments.d.ts +6 -0
  160. package/dist/cli/verbs/inventory-shipments.js +276 -0
  161. package/dist/cli/verbs/inventory-transfers.d.ts +6 -0
  162. package/dist/cli/verbs/inventory-transfers.js +396 -0
  163. package/dist/cli/verbs/inventory.d.ts +6 -0
  164. package/dist/cli/verbs/inventory.js +557 -0
  165. package/dist/cli/verbs/locales.d.ts +6 -0
  166. package/dist/cli/verbs/locales.js +61 -0
  167. package/dist/cli/verbs/locations.d.ts +6 -0
  168. package/dist/cli/verbs/locations.js +385 -0
  169. package/dist/cli/verbs/market-localizations.d.ts +6 -0
  170. package/dist/cli/verbs/market-localizations.js +291 -0
  171. package/dist/cli/verbs/market-web-presences.d.ts +6 -0
  172. package/dist/cli/verbs/market-web-presences.js +139 -0
  173. package/dist/cli/verbs/marketing-activities.d.ts +6 -0
  174. package/dist/cli/verbs/marketing-activities.js +353 -0
  175. package/dist/cli/verbs/marketing-events.d.ts +6 -0
  176. package/dist/cli/verbs/marketing-events.js +132 -0
  177. package/dist/cli/verbs/markets.d.ts +6 -0
  178. package/dist/cli/verbs/markets.js +357 -0
  179. package/dist/cli/verbs/menus.d.ts +6 -0
  180. package/dist/cli/verbs/menus.js +251 -0
  181. package/dist/cli/verbs/metafield-definition-tools.d.ts +6 -0
  182. package/dist/cli/verbs/metafield-definition-tools.js +289 -0
  183. package/dist/cli/verbs/metafield-definitions.d.ts +6 -0
  184. package/dist/cli/verbs/metafield-definitions.js +240 -0
  185. package/dist/cli/verbs/metafields.d.ts +6 -0
  186. package/dist/cli/verbs/metafields.js +112 -0
  187. package/dist/cli/verbs/metaobject-definition-tools.d.ts +6 -0
  188. package/dist/cli/verbs/metaobject-definition-tools.js +83 -0
  189. package/dist/cli/verbs/metaobject-definitions.d.ts +6 -0
  190. package/dist/cli/verbs/metaobject-definitions.js +176 -0
  191. package/dist/cli/verbs/metaobjects.d.ts +6 -0
  192. package/dist/cli/verbs/metaobjects.js +306 -0
  193. package/dist/cli/verbs/mobile-platform-applications.d.ts +6 -0
  194. package/dist/cli/verbs/mobile-platform-applications.js +247 -0
  195. package/dist/cli/verbs/order-edit.d.ts +6 -0
  196. package/dist/cli/verbs/order-edit.js +596 -0
  197. package/dist/cli/verbs/orders.d.ts +6 -0
  198. package/dist/cli/verbs/orders.js +853 -0
  199. package/dist/cli/verbs/pages.d.ts +6 -0
  200. package/dist/cli/verbs/pages.js +234 -0
  201. package/dist/cli/verbs/payment-customizations.d.ts +6 -0
  202. package/dist/cli/verbs/payment-customizations.js +193 -0
  203. package/dist/cli/verbs/payment-terms.d.ts +6 -0
  204. package/dist/cli/verbs/payment-terms.js +228 -0
  205. package/dist/cli/verbs/point-of-sale.d.ts +6 -0
  206. package/dist/cli/verbs/point-of-sale.js +57 -0
  207. package/dist/cli/verbs/price-lists.d.ts +6 -0
  208. package/dist/cli/verbs/price-lists.js +426 -0
  209. package/dist/cli/verbs/product-feeds.d.ts +6 -0
  210. package/dist/cli/verbs/product-feeds.js +187 -0
  211. package/dist/cli/verbs/product-variants.d.ts +6 -0
  212. package/dist/cli/verbs/product-variants.js +439 -0
  213. package/dist/cli/verbs/products.d.ts +6 -0
  214. package/dist/cli/verbs/products.js +2309 -0
  215. package/dist/cli/verbs/publications.d.ts +6 -0
  216. package/dist/cli/verbs/publications.js +256 -0
  217. package/dist/cli/verbs/publishables.d.ts +6 -0
  218. package/dist/cli/verbs/publishables.js +73 -0
  219. package/dist/cli/verbs/refunds.d.ts +6 -0
  220. package/dist/cli/verbs/refunds.js +226 -0
  221. package/dist/cli/verbs/resource-feedback.d.ts +6 -0
  222. package/dist/cli/verbs/resource-feedback.js +119 -0
  223. package/dist/cli/verbs/returnable-fulfillments.d.ts +6 -0
  224. package/dist/cli/verbs/returnable-fulfillments.js +102 -0
  225. package/dist/cli/verbs/returns.d.ts +6 -0
  226. package/dist/cli/verbs/returns.js +506 -0
  227. package/dist/cli/verbs/reverse-deliveries.d.ts +6 -0
  228. package/dist/cli/verbs/reverse-deliveries.js +203 -0
  229. package/dist/cli/verbs/reverse-fulfillment-orders.d.ts +6 -0
  230. package/dist/cli/verbs/reverse-fulfillment-orders.js +157 -0
  231. package/dist/cli/verbs/saved-searches.d.ts +6 -0
  232. package/dist/cli/verbs/saved-searches.js +150 -0
  233. package/dist/cli/verbs/script-tags.d.ts +6 -0
  234. package/dist/cli/verbs/script-tags.js +179 -0
  235. package/dist/cli/verbs/segments.d.ts +6 -0
  236. package/dist/cli/verbs/segments.js +343 -0
  237. package/dist/cli/verbs/selling-plan-group-products.d.ts +6 -0
  238. package/dist/cli/verbs/selling-plan-group-products.js +115 -0
  239. package/dist/cli/verbs/selling-plan-groups.d.ts +6 -0
  240. package/dist/cli/verbs/selling-plan-groups.js +230 -0
  241. package/dist/cli/verbs/server-pixels.d.ts +6 -0
  242. package/dist/cli/verbs/server-pixels.js +172 -0
  243. package/dist/cli/verbs/shipping-packages.d.ts +6 -0
  244. package/dist/cli/verbs/shipping-packages.js +107 -0
  245. package/dist/cli/verbs/shop-policies.d.ts +6 -0
  246. package/dist/cli/verbs/shop-policies.js +91 -0
  247. package/dist/cli/verbs/shop-utils.d.ts +6 -0
  248. package/dist/cli/verbs/shop-utils.js +147 -0
  249. package/dist/cli/verbs/shop.d.ts +6 -0
  250. package/dist/cli/verbs/shop.js +177 -0
  251. package/dist/cli/verbs/shopify-functions.d.ts +6 -0
  252. package/dist/cli/verbs/shopify-functions.js +127 -0
  253. package/dist/cli/verbs/shopify-payments.d.ts +6 -0
  254. package/dist/cli/verbs/shopify-payments.js +111 -0
  255. package/dist/cli/verbs/staff.d.ts +6 -0
  256. package/dist/cli/verbs/staff.js +127 -0
  257. package/dist/cli/verbs/staged-uploads.d.ts +6 -0
  258. package/dist/cli/verbs/staged-uploads.js +128 -0
  259. package/dist/cli/verbs/store-credit.d.ts +6 -0
  260. package/dist/cli/verbs/store-credit.js +209 -0
  261. package/dist/cli/verbs/storefront-access-tokens.d.ts +6 -0
  262. package/dist/cli/verbs/storefront-access-tokens.js +183 -0
  263. package/dist/cli/verbs/subscription-billing-cycles.d.ts +6 -0
  264. package/dist/cli/verbs/subscription-billing-cycles.js +391 -0
  265. package/dist/cli/verbs/subscription-billing.d.ts +6 -0
  266. package/dist/cli/verbs/subscription-billing.js +391 -0
  267. package/dist/cli/verbs/subscription-contracts.d.ts +6 -0
  268. package/dist/cli/verbs/subscription-contracts.js +392 -0
  269. package/dist/cli/verbs/subscription-drafts.d.ts +6 -0
  270. package/dist/cli/verbs/subscription-drafts.js +315 -0
  271. package/dist/cli/verbs/tags.d.ts +6 -0
  272. package/dist/cli/verbs/tags.js +73 -0
  273. package/dist/cli/verbs/tax.d.ts +6 -0
  274. package/dist/cli/verbs/tax.js +114 -0
  275. package/dist/cli/verbs/taxonomy.d.ts +6 -0
  276. package/dist/cli/verbs/taxonomy.js +99 -0
  277. package/dist/cli/verbs/tender-transactions.d.ts +6 -0
  278. package/dist/cli/verbs/tender-transactions.js +105 -0
  279. package/dist/cli/verbs/themes.d.ts +6 -0
  280. package/dist/cli/verbs/themes.js +315 -0
  281. package/dist/cli/verbs/translations.d.ts +6 -0
  282. package/dist/cli/verbs/translations.js +221 -0
  283. package/dist/cli/verbs/types.d.ts +4 -0
  284. package/dist/cli/verbs/types.js +224 -0
  285. package/dist/cli/verbs/url-redirects.d.ts +6 -0
  286. package/dist/cli/verbs/url-redirects.js +465 -0
  287. package/dist/cli/verbs/validations.d.ts +6 -0
  288. package/dist/cli/verbs/validations.js +181 -0
  289. package/dist/cli/verbs/web-pixels.d.ts +6 -0
  290. package/dist/cli/verbs/web-pixels.js +145 -0
  291. package/dist/cli/verbs/web-presences.d.ts +6 -0
  292. package/dist/cli/verbs/web-presences.js +186 -0
  293. package/dist/cli/verbs/webhooks.d.ts +6 -0
  294. package/dist/cli/verbs/webhooks.js +336 -0
  295. package/dist/cli/workflows/files/stagedUploads.d.ts +28 -0
  296. package/dist/cli/workflows/files/stagedUploads.js +227 -0
  297. package/dist/cli/workflows/files/stdinFile.d.ts +7 -0
  298. package/dist/cli/workflows/files/stdinFile.js +65 -0
  299. package/dist/cli/workflows/files/urlDownloads.d.ts +14 -0
  300. package/dist/cli/workflows/files/urlDownloads.js +114 -0
  301. package/dist/cli/workflows/files/waitForReady.d.ts +20 -0
  302. package/dist/cli/workflows/files/waitForReady.js +114 -0
  303. package/dist/cli/workflows/inventory/resolveInventoryItemId.d.ts +6 -0
  304. package/dist/cli/workflows/inventory/resolveInventoryItemId.js +59 -0
  305. package/dist/cli/workflows/productVariants/upsert.d.ts +8 -0
  306. package/dist/cli/workflows/productVariants/upsert.js +110 -0
  307. package/dist/cli/workflows/products/metafieldsUpsert.d.ts +6 -0
  308. package/dist/cli/workflows/products/metafieldsUpsert.js +94 -0
  309. package/dist/cli/workflows/products/publishablePublish.d.ts +21 -0
  310. package/dist/cli/workflows/products/publishablePublish.js +131 -0
  311. package/dist/cli/workflows/publications/resolvePublicationId.d.ts +17 -0
  312. package/dist/cli/workflows/publications/resolvePublicationId.js +93 -0
  313. package/dist/cli.d.ts +1 -0
  314. package/dist/cli.js +238 -0
  315. package/dist/defaults.d.ts +2 -0
  316. package/dist/defaults.js +38 -0
  317. package/dist/generated/admin-2026-04/index.d.ts +25 -0
  318. package/dist/generated/admin-2026-04/index.js +70 -0
  319. package/dist/generated/admin-2026-04/runtime/batcher.d.ts +105 -0
  320. package/dist/generated/admin-2026-04/runtime/batcher.js +203 -0
  321. package/dist/generated/admin-2026-04/runtime/createClient.d.ts +17 -0
  322. package/dist/generated/admin-2026-04/runtime/createClient.js +59 -0
  323. package/dist/generated/admin-2026-04/runtime/error.d.ts +18 -0
  324. package/dist/generated/admin-2026-04/runtime/error.js +44 -0
  325. package/dist/generated/admin-2026-04/runtime/fetcher.d.ts +10 -0
  326. package/dist/generated/admin-2026-04/runtime/fetcher.js +104 -0
  327. package/dist/generated/admin-2026-04/runtime/generateGraphqlOperation.d.ts +30 -0
  328. package/dist/generated/admin-2026-04/runtime/generateGraphqlOperation.js +191 -0
  329. package/dist/generated/admin-2026-04/runtime/index.d.ts +11 -0
  330. package/dist/generated/admin-2026-04/runtime/index.js +46 -0
  331. package/dist/generated/admin-2026-04/runtime/linkTypeMap.d.ts +9 -0
  332. package/dist/generated/admin-2026-04/runtime/linkTypeMap.js +142 -0
  333. package/dist/generated/admin-2026-04/runtime/typeSelection.d.ts +28 -0
  334. package/dist/generated/admin-2026-04/runtime/typeSelection.js +17 -0
  335. package/dist/generated/admin-2026-04/runtime/types.d.ts +55 -0
  336. package/dist/generated/admin-2026-04/runtime/types.js +17 -0
  337. package/dist/generated/admin-2026-04/schema.d.ts +102240 -0
  338. package/dist/generated/admin-2026-04/schema.graphql +91596 -0
  339. package/dist/generated/admin-2026-04/schema.js +20322 -0
  340. package/dist/generated/admin-2026-04/types.d.ts +24224 -0
  341. package/dist/generated/admin-2026-04/types.js +62299 -0
  342. package/dist/generated/help/schema-help.d.ts +30 -0
  343. package/dist/generated/help/schema-help.js +61833 -0
  344. package/dist/graphqlValidator.d.ts +17 -0
  345. package/dist/graphqlValidator.js +84 -0
  346. package/dist/index.d.ts +1 -0
  347. package/dist/index.js +23 -0
  348. package/package.json +66 -0
  349. package/schema/2026-04.graphql +61256 -0
  350. package/schema/2026-04.introspection.json +1 -0
@@ -0,0 +1,359 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var gift_cards_exports = {};
20
+ __export(gift_cards_exports, {
21
+ runGiftCards: () => runGiftCards
22
+ });
23
+ module.exports = __toCommonJS(gift_cards_exports);
24
+ var import_errors = require("../errors");
25
+ var import_input = require("../input");
26
+ var import_output = require("../output");
27
+ var import_router = require("../router");
28
+ var import_select = require("../selection/select");
29
+ var import_userErrors = require("../userErrors");
30
+ var import_shared = require("./_shared");
31
+ const giftCardSummarySelection = {
32
+ id: true,
33
+ balance: { amount: true, currencyCode: true },
34
+ initialValue: { amount: true, currencyCode: true },
35
+ lastCharacters: true,
36
+ expiresOn: true,
37
+ enabled: true,
38
+ createdAt: true,
39
+ updatedAt: true
40
+ };
41
+ const giftCardFullSelection = {
42
+ ...giftCardSummarySelection,
43
+ deactivatedAt: true,
44
+ maskedCode: true,
45
+ note: true,
46
+ templateSuffix: true,
47
+ customer: { id: true, displayName: true, email: true },
48
+ order: { id: true, name: true },
49
+ recipientAttributes: {
50
+ message: true,
51
+ preferredName: true,
52
+ sendNotificationAt: true,
53
+ recipient: { id: true, displayName: true, email: true, firstName: true, lastName: true }
54
+ }
55
+ };
56
+ const giftCardConfigurationSelection = {
57
+ expirationConfiguration: { expirationUnit: true, expirationValue: true },
58
+ issueLimit: { amount: true, currencyCode: true },
59
+ purchaseLimit: { amount: true, currencyCode: true }
60
+ };
61
+ const giftCardTransactionSelection = {
62
+ id: true,
63
+ amount: { amount: true, currencyCode: true },
64
+ processedAt: true,
65
+ note: true,
66
+ giftCard: { id: true }
67
+ };
68
+ const getGiftCardSelection = (view) => {
69
+ if (view === "ids") return { id: true };
70
+ if (view === "full") return giftCardFullSelection;
71
+ if (view === "raw") return {};
72
+ return giftCardSummarySelection;
73
+ };
74
+ const parseMoneyInput = (flag, value) => {
75
+ if (typeof value !== "string" || !value.trim()) throw new import_errors.CliError(`Missing ${flag}`, 2);
76
+ const raw = value.trim();
77
+ if (raw.startsWith("{")) {
78
+ let parsed;
79
+ try {
80
+ parsed = JSON.parse(raw);
81
+ } catch (err) {
82
+ throw new import_errors.CliError(`${flag} must be valid JSON: ${err.message}`, 2);
83
+ }
84
+ if (parsed === null || typeof parsed !== "object") {
85
+ throw new import_errors.CliError(`${flag} must be a JSON object with amount and currencyCode`, 2);
86
+ }
87
+ if (parsed.amount === void 0 || parsed.currencyCode === void 0) {
88
+ throw new import_errors.CliError(`${flag} must include amount and currencyCode`, 2);
89
+ }
90
+ return parsed;
91
+ }
92
+ const parts = raw.split(/[,:\s]+/).map((part) => part.trim()).filter(Boolean);
93
+ if (parts.length !== 2) {
94
+ throw new import_errors.CliError(`${flag} must be in the form "amount,currency" (for example 10.00,USD)`, 2);
95
+ }
96
+ const [amount, currencyCode] = parts;
97
+ if (!amount || !currencyCode) {
98
+ throw new import_errors.CliError(`${flag} must include amount and currency`, 2);
99
+ }
100
+ return { amount, currencyCode: currencyCode.toUpperCase() };
101
+ };
102
+ const ensureObjectInput = (value, label) => {
103
+ if (value === null || typeof value !== "object") throw new import_errors.CliError(`${label} must be an object`, 2);
104
+ return value;
105
+ };
106
+ const runGiftCards = async ({
107
+ ctx,
108
+ verb,
109
+ argv
110
+ }) => {
111
+ if (argv.includes("--help") || argv.includes("-h")) {
112
+ console.log(
113
+ [
114
+ "Usage: shop gift-cards <verb> [flags]",
115
+ "",
116
+ "Verbs:",
117
+ " create Create a gift card",
118
+ " get Get a gift card by ID",
119
+ " list List gift cards",
120
+ " count Count gift cards",
121
+ " update Update a gift card",
122
+ " credit Credit a gift card",
123
+ " debit Debit a gift card",
124
+ " deactivate Deactivate a gift card",
125
+ " notify-customer Send a gift card notification to the customer",
126
+ " notify-recipient Send a gift card notification to the recipient",
127
+ " config Get gift card configuration",
128
+ "",
129
+ "Common output flags:",
130
+ " --view summary|ids|full|raw",
131
+ " --select <path> (repeatable; dot paths; adds to base view selection)",
132
+ " --selection <graphql> (selection override; can be @file.gql)",
133
+ "",
134
+ "Special flags:",
135
+ " --credit-amount <amount,currency> (credit)",
136
+ " --debit-amount <amount,currency> (debit)"
137
+ ].join("\n")
138
+ );
139
+ return;
140
+ }
141
+ if (verb === "get") {
142
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
143
+ const id = (0, import_shared.requireId)(args.id, "GiftCard");
144
+ const selection = (0, import_select.resolveSelection)({
145
+ resource: "gift-cards",
146
+ view: ctx.view,
147
+ baseSelection: getGiftCardSelection(ctx.view),
148
+ select: args.select,
149
+ selection: args.selection,
150
+ include: args.include,
151
+ ensureId: ctx.quiet
152
+ });
153
+ const result = await (0, import_router.runQuery)(ctx, { giftCard: { __args: { id }, ...selection } });
154
+ if (result === void 0) return;
155
+ (0, import_output.printNode)({ node: result.giftCard, format: ctx.format, quiet: ctx.quiet });
156
+ return;
157
+ }
158
+ if (verb === "list") {
159
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
160
+ const first = (0, import_shared.parseFirst)(args.first);
161
+ const after = args.after;
162
+ const query = args.query;
163
+ const reverse = args.reverse;
164
+ const sortKey = args.sort;
165
+ const nodeSelection = (0, import_select.resolveSelection)({
166
+ resource: "gift-cards",
167
+ view: ctx.view,
168
+ baseSelection: getGiftCardSelection(ctx.view),
169
+ select: args.select,
170
+ selection: args.selection,
171
+ include: args.include,
172
+ ensureId: ctx.quiet
173
+ });
174
+ const result = await (0, import_router.runQuery)(ctx, {
175
+ giftCards: {
176
+ __args: { first, after, query, reverse, sortKey },
177
+ pageInfo: { hasNextPage: true, endCursor: true },
178
+ nodes: nodeSelection
179
+ }
180
+ });
181
+ if (result === void 0) return;
182
+ (0, import_output.printConnection)({
183
+ connection: result.giftCards,
184
+ format: ctx.format,
185
+ quiet: ctx.quiet,
186
+ nextPageArgs: (0, import_shared.buildListNextPageArgs)("gift-cards", { first, query, sort: sortKey, reverse })
187
+ });
188
+ return;
189
+ }
190
+ if (verb === "count") {
191
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
192
+ const query = args.query;
193
+ const result = await (0, import_router.runQuery)(ctx, { giftCardsCount: { __args: { query }, count: true, precision: true } });
194
+ if (result === void 0) return;
195
+ if (ctx.quiet) return console.log(result.giftCardsCount?.count ?? "");
196
+ (0, import_output.printJson)(result.giftCardsCount, ctx.format !== "raw");
197
+ return;
198
+ }
199
+ if (verb === "config") {
200
+ const result = await (0, import_router.runQuery)(ctx, { giftCardConfiguration: giftCardConfigurationSelection });
201
+ if (result === void 0) return;
202
+ (0, import_output.printJson)(result.giftCardConfiguration, ctx.format !== "raw");
203
+ return;
204
+ }
205
+ if (verb === "create") {
206
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
207
+ const built = (0, import_input.buildInput)({
208
+ inputArg: args.input,
209
+ setArgs: args.set,
210
+ setJsonArgs: args["set-json"]
211
+ });
212
+ if (!built.used) throw new import_errors.CliError("Missing --input or --set/--set-json", 2);
213
+ const result = await (0, import_router.runMutation)(ctx, {
214
+ giftCardCreate: {
215
+ __args: { input: built.input },
216
+ giftCard: giftCardSummarySelection,
217
+ giftCardCode: true,
218
+ userErrors: { field: true, message: true }
219
+ }
220
+ });
221
+ if (result === void 0) return;
222
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.giftCardCreate, failOnUserErrors: ctx.failOnUserErrors });
223
+ if (ctx.quiet) return console.log(result.giftCardCreate?.giftCard?.id ?? "");
224
+ (0, import_output.printJson)(result.giftCardCreate, ctx.format !== "raw");
225
+ return;
226
+ }
227
+ if (verb === "update") {
228
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
229
+ const id = (0, import_shared.requireId)(args.id, "GiftCard");
230
+ const built = (0, import_input.buildInput)({
231
+ inputArg: args.input,
232
+ setArgs: args.set,
233
+ setJsonArgs: args["set-json"]
234
+ });
235
+ if (!built.used) throw new import_errors.CliError("Missing --input or --set/--set-json", 2);
236
+ const result = await (0, import_router.runMutation)(ctx, {
237
+ giftCardUpdate: {
238
+ __args: { id, input: built.input },
239
+ giftCard: giftCardSummarySelection,
240
+ userErrors: { field: true, message: true }
241
+ }
242
+ });
243
+ if (result === void 0) return;
244
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.giftCardUpdate, failOnUserErrors: ctx.failOnUserErrors });
245
+ if (ctx.quiet) return console.log(result.giftCardUpdate?.giftCard?.id ?? "");
246
+ (0, import_output.printJson)(result.giftCardUpdate, ctx.format !== "raw");
247
+ return;
248
+ }
249
+ if (verb === "credit") {
250
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { "credit-amount": { type: "string" } } });
251
+ const id = (0, import_shared.requireId)(args.id, "GiftCard");
252
+ const built = (0, import_input.buildInput)({
253
+ inputArg: args.input,
254
+ setArgs: args.set,
255
+ setJsonArgs: args["set-json"]
256
+ });
257
+ const creditInput = built.used ? ensureObjectInput(built.input, "Gift card credit input") : {};
258
+ if (args["credit-amount"] !== void 0) {
259
+ creditInput.creditAmount = parseMoneyInput("--credit-amount", args["credit-amount"]);
260
+ }
261
+ if (creditInput.creditAmount === void 0) {
262
+ throw new import_errors.CliError("Missing --credit-amount or creditAmount in --input/--set", 2);
263
+ }
264
+ const result = await (0, import_router.runMutation)(ctx, {
265
+ giftCardCredit: {
266
+ __args: { id, creditInput },
267
+ giftCardCreditTransaction: giftCardTransactionSelection,
268
+ userErrors: { field: true, message: true }
269
+ }
270
+ });
271
+ if (result === void 0) return;
272
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.giftCardCredit, failOnUserErrors: ctx.failOnUserErrors });
273
+ if (ctx.quiet) return console.log(result.giftCardCredit?.giftCardCreditTransaction?.id ?? "");
274
+ (0, import_output.printJson)(result.giftCardCredit, ctx.format !== "raw");
275
+ return;
276
+ }
277
+ if (verb === "debit") {
278
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { "debit-amount": { type: "string" } } });
279
+ const id = (0, import_shared.requireId)(args.id, "GiftCard");
280
+ const built = (0, import_input.buildInput)({
281
+ inputArg: args.input,
282
+ setArgs: args.set,
283
+ setJsonArgs: args["set-json"]
284
+ });
285
+ const debitInput = built.used ? ensureObjectInput(built.input, "Gift card debit input") : {};
286
+ if (args["debit-amount"] !== void 0) {
287
+ debitInput.debitAmount = parseMoneyInput("--debit-amount", args["debit-amount"]);
288
+ }
289
+ if (debitInput.debitAmount === void 0) {
290
+ throw new import_errors.CliError("Missing --debit-amount or debitAmount in --input/--set", 2);
291
+ }
292
+ const result = await (0, import_router.runMutation)(ctx, {
293
+ giftCardDebit: {
294
+ __args: { id, debitInput },
295
+ giftCardDebitTransaction: giftCardTransactionSelection,
296
+ userErrors: { field: true, message: true }
297
+ }
298
+ });
299
+ if (result === void 0) return;
300
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.giftCardDebit, failOnUserErrors: ctx.failOnUserErrors });
301
+ if (ctx.quiet) return console.log(result.giftCardDebit?.giftCardDebitTransaction?.id ?? "");
302
+ (0, import_output.printJson)(result.giftCardDebit, ctx.format !== "raw");
303
+ return;
304
+ }
305
+ if (verb === "deactivate") {
306
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
307
+ const id = (0, import_shared.requireId)(args.id, "GiftCard");
308
+ const result = await (0, import_router.runMutation)(ctx, {
309
+ giftCardDeactivate: {
310
+ __args: { id },
311
+ giftCard: giftCardSummarySelection,
312
+ userErrors: { field: true, message: true }
313
+ }
314
+ });
315
+ if (result === void 0) return;
316
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.giftCardDeactivate, failOnUserErrors: ctx.failOnUserErrors });
317
+ if (ctx.quiet) return console.log(result.giftCardDeactivate?.giftCard?.id ?? "");
318
+ (0, import_output.printJson)(result.giftCardDeactivate, ctx.format !== "raw");
319
+ return;
320
+ }
321
+ if (verb === "notify-customer") {
322
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
323
+ const id = (0, import_shared.requireId)(args.id, "GiftCard");
324
+ const result = await (0, import_router.runMutation)(ctx, {
325
+ giftCardSendNotificationToCustomer: {
326
+ __args: { id },
327
+ giftCard: giftCardSummarySelection,
328
+ userErrors: { field: true, message: true }
329
+ }
330
+ });
331
+ if (result === void 0) return;
332
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.giftCardSendNotificationToCustomer, failOnUserErrors: ctx.failOnUserErrors });
333
+ if (ctx.quiet) return console.log(result.giftCardSendNotificationToCustomer?.giftCard?.id ?? "");
334
+ (0, import_output.printJson)(result.giftCardSendNotificationToCustomer, ctx.format !== "raw");
335
+ return;
336
+ }
337
+ if (verb === "notify-recipient") {
338
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
339
+ const id = (0, import_shared.requireId)(args.id, "GiftCard");
340
+ const result = await (0, import_router.runMutation)(ctx, {
341
+ giftCardSendNotificationToRecipient: {
342
+ __args: { id },
343
+ giftCard: giftCardSummarySelection,
344
+ userErrors: { field: true, message: true }
345
+ }
346
+ });
347
+ if (result === void 0) return;
348
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.giftCardSendNotificationToRecipient, failOnUserErrors: ctx.failOnUserErrors });
349
+ if (ctx.quiet) return console.log(result.giftCardSendNotificationToRecipient?.giftCard?.id ?? "");
350
+ (0, import_output.printJson)(result.giftCardSendNotificationToRecipient, ctx.format !== "raw");
351
+ return;
352
+ }
353
+ throw new import_errors.CliError(`Unknown verb for gift-cards: ${verb}`, 2);
354
+ };
355
+ // Annotate the CommonJS export names for ESM import in node:
356
+ 0 && (module.exports = {
357
+ runGiftCards
358
+ });
359
+ //# sourceMappingURL=gift-cards.js.map
@@ -0,0 +1,14 @@
1
+ import { type CommandContext } from '../router';
2
+ type GraphQLCommandContext = CommandContext & {
3
+ shopDomain?: string;
4
+ graphqlEndpoint?: string;
5
+ accessToken?: string;
6
+ apiVersion?: string;
7
+ headers?: Record<string, string>;
8
+ };
9
+ export declare const runGraphQL: ({ ctx, verb, argv, }: {
10
+ ctx: GraphQLCommandContext;
11
+ verb: string;
12
+ argv: string[];
13
+ }) => Promise<void>;
14
+ export {};
@@ -0,0 +1,285 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var graphql_exports = {};
20
+ __export(graphql_exports, {
21
+ runGraphQL: () => runGraphQL
22
+ });
23
+ module.exports = __toCommonJS(graphql_exports);
24
+ var import_node_util = require("node:util");
25
+ var import_node_fs = require("node:fs");
26
+ var import_errors = require("../errors");
27
+ var import_output = require("../output");
28
+ var import_router = require("../router");
29
+ var import_adminClient = require("../../adminClient");
30
+ var import_graphqlValidator = require("../../graphqlValidator");
31
+ const printHelp = () => {
32
+ console.log(
33
+ [
34
+ "Usage:",
35
+ " shop graphql query <graphql> [flags]",
36
+ " shop graphql mutation <graphql> [flags]",
37
+ " shop graphql <graphql> [flags]",
38
+ " shop graphql nodes --ids <gid,gid,...> [flags]",
39
+ " shop graphql shopifyql --query <string> [flags]",
40
+ "",
41
+ "Execute raw GraphQL queries and mutations against the Shopify Admin API.",
42
+ "",
43
+ "Arguments:",
44
+ " <graphql> GraphQL query/mutation (inline or @file.graphql)",
45
+ "",
46
+ "Variables:",
47
+ " --var <name>=<value> Set a string variable (repeatable)",
48
+ " --var-json <name>=<json> Set a variable with JSON value (repeatable)",
49
+ " --variables <json> Variables as JSON object (or @file.json)",
50
+ " --operation <name> Operation name (for multi-operation documents)",
51
+ "",
52
+ "Validation:",
53
+ " Queries are validated against the bundled Shopify Admin schema before",
54
+ " execution. This catches errors locally with helpful messages, without",
55
+ " making an API request.",
56
+ "",
57
+ " --no-validate Skip local schema validation",
58
+ "",
59
+ "Output:",
60
+ " --format json|jsonl|raw Output format (default: json)",
61
+ " --include-extensions Include extensions in output",
62
+ "",
63
+ "Examples:",
64
+ " # Simple query",
65
+ " shop graphql query '{ shop { name } }'",
66
+ "",
67
+ " # Query from file",
68
+ " shop graphql query @get-products.graphql",
69
+ "",
70
+ " # Query with variables",
71
+ " shop graphql query 'query GetProduct($id: ID!) { product(id: $id) { title } }' \\",
72
+ " --var id=gid://shopify/Product/123",
73
+ "",
74
+ " # Mutation",
75
+ ` shop graphql mutation 'mutation { productCreate(input: { title: "Test" }) { product { id } } }'`,
76
+ "",
77
+ " # Auto-detect query vs mutation",
78
+ " shop graphql '{ shop { name } }'",
79
+ "",
80
+ " # Fetch nodes by ID",
81
+ " shop graphql nodes --ids gid://shopify/Product/1,gid://shopify/Order/2",
82
+ "",
83
+ " # Run a ShopifyQL query",
84
+ ' shop graphql shopifyql --query "FROM products SHOW title"',
85
+ "",
86
+ " # With JSON variables from file",
87
+ " shop graphql @query.graphql --variables @vars.json",
88
+ "",
89
+ " # Skip validation for edge cases",
90
+ " shop graphql '{ shop { name } }' --no-validate"
91
+ ].join("\n")
92
+ );
93
+ };
94
+ const readTextArg = (value) => {
95
+ const trimmed = value.trim();
96
+ if (trimmed.startsWith("@file:")) return (0, import_node_fs.readFileSync)(trimmed.slice("@file:".length), "utf8");
97
+ if (trimmed.startsWith("@")) return (0, import_node_fs.readFileSync)(trimmed.slice(1), "utf8");
98
+ return trimmed;
99
+ };
100
+ const parseVariables = ({
101
+ varArgs,
102
+ varJsonArgs,
103
+ variablesArg
104
+ }) => {
105
+ const vars = {};
106
+ let hasVars = false;
107
+ if (variablesArg) {
108
+ const raw = readTextArg(variablesArg);
109
+ try {
110
+ const parsed = JSON.parse(raw);
111
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
112
+ throw new import_errors.CliError("--variables must be a JSON object", 2);
113
+ }
114
+ Object.assign(vars, parsed);
115
+ hasVars = true;
116
+ } catch (err) {
117
+ if (err instanceof import_errors.CliError) throw err;
118
+ throw new import_errors.CliError(`--variables must be valid JSON: ${err.message}`, 2);
119
+ }
120
+ }
121
+ if (varArgs) {
122
+ for (const arg of varArgs) {
123
+ const eqIdx = arg.indexOf("=");
124
+ if (eqIdx === -1) throw new import_errors.CliError(`Invalid --var: expected name=value, got "${arg}"`, 2);
125
+ const name = arg.slice(0, eqIdx);
126
+ const value = arg.slice(eqIdx + 1);
127
+ if (!name) throw new import_errors.CliError(`Invalid --var: missing variable name in "${arg}"`, 2);
128
+ vars[name] = value;
129
+ hasVars = true;
130
+ }
131
+ }
132
+ if (varJsonArgs) {
133
+ for (const arg of varJsonArgs) {
134
+ const eqIdx = arg.indexOf("=");
135
+ if (eqIdx === -1) throw new import_errors.CliError(`Invalid --var-json: expected name=json, got "${arg}"`, 2);
136
+ const name = arg.slice(0, eqIdx);
137
+ const jsonStr = arg.slice(eqIdx + 1);
138
+ if (!name) throw new import_errors.CliError(`Invalid --var-json: missing variable name in "${arg}"`, 2);
139
+ try {
140
+ vars[name] = JSON.parse(jsonStr);
141
+ hasVars = true;
142
+ } catch (err) {
143
+ throw new import_errors.CliError(`Invalid --var-json "${name}": ${err.message}`, 2);
144
+ }
145
+ }
146
+ }
147
+ return hasVars ? vars : void 0;
148
+ };
149
+ const runGraphQL = async ({
150
+ ctx,
151
+ verb,
152
+ argv
153
+ }) => {
154
+ if (argv.includes("--help") || argv.includes("-h") || verb === "help") {
155
+ printHelp();
156
+ return;
157
+ }
158
+ if (verb === "nodes") {
159
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
160
+ const raw = args.ids;
161
+ const values = Array.isArray(raw) ? raw : raw === void 0 ? [] : [raw];
162
+ const ids = [];
163
+ for (const v of values) {
164
+ if (typeof v !== "string") throw new import_errors.CliError("--ids must be a string", 2);
165
+ ids.push(...v.split(",").map((s) => s.trim()).filter(Boolean));
166
+ }
167
+ if (ids.length === 0) throw new import_errors.CliError("Missing --ids", 2);
168
+ const result = await (0, import_router.runQuery)(ctx, {
169
+ nodes: {
170
+ __args: { ids },
171
+ __typename: true,
172
+ id: true
173
+ }
174
+ });
175
+ if (result === void 0) return;
176
+ if (ctx.quiet) {
177
+ (0, import_output.printIds)((result.nodes ?? []).map((n) => n?.id));
178
+ return;
179
+ }
180
+ (0, import_output.printJson)(result.nodes, ctx.format !== "raw");
181
+ return;
182
+ }
183
+ if (verb === "shopifyql") {
184
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
185
+ const query2 = args.query;
186
+ if (!query2) throw new import_errors.CliError("Missing --query", 2);
187
+ const result = await (0, import_router.runQuery)(ctx, {
188
+ shopifyqlQuery: {
189
+ __args: { query: query2 },
190
+ parseErrors: true,
191
+ tableData: {
192
+ columns: { name: true, displayName: true, dataType: true, subType: true },
193
+ rows: true
194
+ }
195
+ }
196
+ });
197
+ if (result === void 0) return;
198
+ if (ctx.quiet) return;
199
+ (0, import_output.printJson)(result.shopifyqlQuery, ctx.format !== "raw");
200
+ return;
201
+ }
202
+ let actualVerb = verb;
203
+ let verbGraphQL;
204
+ if (verb === "query" || verb.startsWith("query")) {
205
+ const parts = verb.split(" ");
206
+ actualVerb = "query";
207
+ verbGraphQL = parts.slice(1).join(" ").trim() || void 0;
208
+ } else if (verb === "mutation" || verb.startsWith("mutation")) {
209
+ const parts = verb.split(" ");
210
+ actualVerb = "mutation";
211
+ verbGraphQL = parts.slice(1).join(" ").trim() || void 0;
212
+ }
213
+ const parsed = (0, import_node_util.parseArgs)({
214
+ args: argv,
215
+ allowPositionals: true,
216
+ options: {
217
+ var: { type: "string", multiple: true },
218
+ "var-json": { type: "string", multiple: true },
219
+ variables: { type: "string" },
220
+ operation: { type: "string" },
221
+ "include-extensions": { type: "boolean" },
222
+ "no-validate": { type: "boolean" },
223
+ help: { type: "boolean" },
224
+ h: { type: "boolean" }
225
+ }
226
+ });
227
+ let querySource;
228
+ if (actualVerb === "query" || actualVerb === "mutation") {
229
+ querySource = verbGraphQL ?? parsed.positionals[0];
230
+ } else if (verb) {
231
+ querySource = verb;
232
+ }
233
+ if (!querySource) {
234
+ throw new import_errors.CliError("Missing GraphQL query/mutation. Use: shop graphql <query> or shop graphql query <query>", 2);
235
+ }
236
+ const query = readTextArg(querySource);
237
+ const variables = parseVariables({
238
+ varArgs: parsed.values.var,
239
+ varJsonArgs: parsed.values["var-json"],
240
+ variablesArg: parsed.values.variables
241
+ });
242
+ const request = {
243
+ query,
244
+ ...variables ? { variables } : {},
245
+ ...parsed.values.operation ? { operationName: parsed.values.operation } : {}
246
+ };
247
+ if (ctx.dryRun) {
248
+ (0, import_output.printJson)(request, ctx.format !== "raw");
249
+ return;
250
+ }
251
+ if (!parsed.values["no-validate"] && ctx.apiVersion) {
252
+ const validation = (0, import_graphqlValidator.validateGraphQL)(query, ctx.apiVersion);
253
+ if (!validation.valid) {
254
+ const errorMessage = (0, import_graphqlValidator.formatValidationErrors)(validation.errors);
255
+ console.error("GraphQL validation failed:\n");
256
+ console.error(errorMessage);
257
+ console.error("\nUse --no-validate to skip validation and send the request anyway.");
258
+ throw new import_errors.CliError("GraphQL validation failed", 1);
259
+ }
260
+ }
261
+ const rawClient = (0, import_adminClient.createRawGraphQLClient)({
262
+ shopDomain: ctx.shopDomain,
263
+ graphqlEndpoint: ctx.graphqlEndpoint,
264
+ accessToken: ctx.accessToken,
265
+ apiVersion: ctx.apiVersion,
266
+ headers: ctx.headers
267
+ });
268
+ let response;
269
+ try {
270
+ response = await rawClient.request(request);
271
+ } catch (err) {
272
+ throw new import_errors.CliError(`GraphQL request failed: ${err.message}`, 1);
273
+ }
274
+ if (response.errors && response.errors.length > 0) {
275
+ (0, import_output.printJsonError)({ errors: response.errors, data: response.data }, ctx.format !== "raw");
276
+ throw new import_errors.CliError("GraphQL request returned errors", 1);
277
+ }
278
+ const output = parsed.values["include-extensions"] ? response : response.data;
279
+ (0, import_output.printJson)(output, ctx.format !== "raw");
280
+ };
281
+ // Annotate the CommonJS export names for ESM import in node:
282
+ 0 && (module.exports = {
283
+ runGraphQL
284
+ });
285
+ //# sourceMappingURL=graphql.js.map
@@ -0,0 +1,6 @@
1
+ import { type CommandContext } from '../router';
2
+ export declare const runInventoryItems: ({ ctx, verb, argv, }: {
3
+ ctx: CommandContext;
4
+ verb: string;
5
+ argv: string[];
6
+ }) => Promise<void>;