shop-cli 0.1.0

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 (340) 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 +5651 -0
  23. package/dist/cli/help/render.d.ts +7 -0
  24. package/dist/cli/help/render.js +352 -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/router.d.ts +29 -0
  42. package/dist/cli/router.js +480 -0
  43. package/dist/cli/selection/buildAllSelection.d.ts +13 -0
  44. package/dist/cli/selection/buildAllSelection.js +108 -0
  45. package/dist/cli/selection/graphqlSelection.d.ts +5 -0
  46. package/dist/cli/selection/graphqlSelection.js +301 -0
  47. package/dist/cli/selection/select.d.ts +13 -0
  48. package/dist/cli/selection/select.js +136 -0
  49. package/dist/cli/selection/stripDeprecated.d.ts +2 -0
  50. package/dist/cli/selection/stripDeprecated.js +63 -0
  51. package/dist/cli/userErrors.d.ts +4 -0
  52. package/dist/cli/userErrors.js +41 -0
  53. package/dist/cli/verbs/_shared.d.ts +38 -0
  54. package/dist/cli/verbs/_shared.js +180 -0
  55. package/dist/cli/verbs/abandoned-checkouts.d.ts +6 -0
  56. package/dist/cli/verbs/abandoned-checkouts.js +259 -0
  57. package/dist/cli/verbs/app-billing.d.ts +6 -0
  58. package/dist/cli/verbs/app-billing.js +452 -0
  59. package/dist/cli/verbs/apps.d.ts +6 -0
  60. package/dist/cli/verbs/apps.js +296 -0
  61. package/dist/cli/verbs/articles.d.ts +6 -0
  62. package/dist/cli/verbs/articles.js +251 -0
  63. package/dist/cli/verbs/backup.d.ts +6 -0
  64. package/dist/cli/verbs/backup.js +94 -0
  65. package/dist/cli/verbs/blogs.d.ts +6 -0
  66. package/dist/cli/verbs/blogs.js +273 -0
  67. package/dist/cli/verbs/bulk-operations.d.ts +6 -0
  68. package/dist/cli/verbs/bulk-operations.js +272 -0
  69. package/dist/cli/verbs/business-entities.d.ts +6 -0
  70. package/dist/cli/verbs/business-entities.js +102 -0
  71. package/dist/cli/verbs/carrier-services.d.ts +6 -0
  72. package/dist/cli/verbs/carrier-services.js +195 -0
  73. package/dist/cli/verbs/cart-transforms.d.ts +6 -0
  74. package/dist/cli/verbs/cart-transforms.js +141 -0
  75. package/dist/cli/verbs/cash-tracking.d.ts +6 -0
  76. package/dist/cli/verbs/cash-tracking.js +118 -0
  77. package/dist/cli/verbs/catalogs.d.ts +6 -0
  78. package/dist/cli/verbs/catalogs.js +267 -0
  79. package/dist/cli/verbs/channels.d.ts +6 -0
  80. package/dist/cli/verbs/channels.js +120 -0
  81. package/dist/cli/verbs/checkout-branding.d.ts +6 -0
  82. package/dist/cli/verbs/checkout-branding.js +144 -0
  83. package/dist/cli/verbs/checkout-profiles.d.ts +6 -0
  84. package/dist/cli/verbs/checkout-profiles.js +124 -0
  85. package/dist/cli/verbs/collections.d.ts +6 -0
  86. package/dist/cli/verbs/collections.js +485 -0
  87. package/dist/cli/verbs/comments.d.ts +6 -0
  88. package/dist/cli/verbs/comments.js +160 -0
  89. package/dist/cli/verbs/companies.d.ts +6 -0
  90. package/dist/cli/verbs/companies.js +313 -0
  91. package/dist/cli/verbs/company-contacts.d.ts +6 -0
  92. package/dist/cli/verbs/company-contacts.js +314 -0
  93. package/dist/cli/verbs/company-locations.d.ts +6 -0
  94. package/dist/cli/verbs/company-locations.js +467 -0
  95. package/dist/cli/verbs/customer-account-pages.d.ts +6 -0
  96. package/dist/cli/verbs/customer-account-pages.js +97 -0
  97. package/dist/cli/verbs/customer-payment-methods.d.ts +6 -0
  98. package/dist/cli/verbs/customer-payment-methods.js +358 -0
  99. package/dist/cli/verbs/customer-privacy.d.ts +6 -0
  100. package/dist/cli/verbs/customer-privacy.js +167 -0
  101. package/dist/cli/verbs/customer-segments.d.ts +6 -0
  102. package/dist/cli/verbs/customer-segments.js +193 -0
  103. package/dist/cli/verbs/customers.d.ts +6 -0
  104. package/dist/cli/verbs/customers.js +656 -0
  105. package/dist/cli/verbs/delegate-tokens.d.ts +6 -0
  106. package/dist/cli/verbs/delegate-tokens.js +95 -0
  107. package/dist/cli/verbs/delivery-customizations.d.ts +6 -0
  108. package/dist/cli/verbs/delivery-customizations.js +205 -0
  109. package/dist/cli/verbs/delivery-profile-locations.d.ts +6 -0
  110. package/dist/cli/verbs/delivery-profile-locations.js +90 -0
  111. package/dist/cli/verbs/delivery-profiles.d.ts +6 -0
  112. package/dist/cli/verbs/delivery-profiles.js +207 -0
  113. package/dist/cli/verbs/delivery-promises.d.ts +6 -0
  114. package/dist/cli/verbs/delivery-promises.js +262 -0
  115. package/dist/cli/verbs/delivery-settings.d.ts +6 -0
  116. package/dist/cli/verbs/delivery-settings.js +85 -0
  117. package/dist/cli/verbs/discount-nodes.d.ts +6 -0
  118. package/dist/cli/verbs/discount-nodes.js +169 -0
  119. package/dist/cli/verbs/discount-redeem-codes.d.ts +6 -0
  120. package/dist/cli/verbs/discount-redeem-codes.js +102 -0
  121. package/dist/cli/verbs/discount-saved-searches.d.ts +6 -0
  122. package/dist/cli/verbs/discount-saved-searches.js +113 -0
  123. package/dist/cli/verbs/discounts-automatic.d.ts +6 -0
  124. package/dist/cli/verbs/discounts-automatic.js +475 -0
  125. package/dist/cli/verbs/discounts-code.d.ts +6 -0
  126. package/dist/cli/verbs/discounts-code.js +523 -0
  127. package/dist/cli/verbs/disputes.d.ts +6 -0
  128. package/dist/cli/verbs/disputes.js +154 -0
  129. package/dist/cli/verbs/draft-orders.d.ts +6 -0
  130. package/dist/cli/verbs/draft-orders.js +429 -0
  131. package/dist/cli/verbs/events.d.ts +6 -0
  132. package/dist/cli/verbs/events.js +182 -0
  133. package/dist/cli/verbs/file-saved-searches.d.ts +6 -0
  134. package/dist/cli/verbs/file-saved-searches.js +83 -0
  135. package/dist/cli/verbs/files.d.ts +6 -0
  136. package/dist/cli/verbs/files.js +213 -0
  137. package/dist/cli/verbs/finance.d.ts +6 -0
  138. package/dist/cli/verbs/finance.js +115 -0
  139. package/dist/cli/verbs/flow.d.ts +6 -0
  140. package/dist/cli/verbs/flow.js +94 -0
  141. package/dist/cli/verbs/fulfillment-constraint-rules.d.ts +6 -0
  142. package/dist/cli/verbs/fulfillment-constraint-rules.js +139 -0
  143. package/dist/cli/verbs/fulfillment-orders.d.ts +6 -0
  144. package/dist/cli/verbs/fulfillment-orders.js +674 -0
  145. package/dist/cli/verbs/fulfillment-services.d.ts +6 -0
  146. package/dist/cli/verbs/fulfillment-services.js +212 -0
  147. package/dist/cli/verbs/fulfillments.d.ts +6 -0
  148. package/dist/cli/verbs/fulfillments.js +273 -0
  149. package/dist/cli/verbs/gift-cards.d.ts +6 -0
  150. package/dist/cli/verbs/gift-cards.js +359 -0
  151. package/dist/cli/verbs/graphql.d.ts +14 -0
  152. package/dist/cli/verbs/graphql.js +285 -0
  153. package/dist/cli/verbs/inventory-items.d.ts +6 -0
  154. package/dist/cli/verbs/inventory-items.js +164 -0
  155. package/dist/cli/verbs/inventory-shipments.d.ts +6 -0
  156. package/dist/cli/verbs/inventory-shipments.js +276 -0
  157. package/dist/cli/verbs/inventory-transfers.d.ts +6 -0
  158. package/dist/cli/verbs/inventory-transfers.js +396 -0
  159. package/dist/cli/verbs/inventory.d.ts +6 -0
  160. package/dist/cli/verbs/inventory.js +551 -0
  161. package/dist/cli/verbs/locales.d.ts +6 -0
  162. package/dist/cli/verbs/locales.js +61 -0
  163. package/dist/cli/verbs/locations.d.ts +6 -0
  164. package/dist/cli/verbs/locations.js +385 -0
  165. package/dist/cli/verbs/market-localizations.d.ts +6 -0
  166. package/dist/cli/verbs/market-localizations.js +291 -0
  167. package/dist/cli/verbs/market-web-presences.d.ts +6 -0
  168. package/dist/cli/verbs/market-web-presences.js +139 -0
  169. package/dist/cli/verbs/marketing-activities.d.ts +6 -0
  170. package/dist/cli/verbs/marketing-activities.js +353 -0
  171. package/dist/cli/verbs/marketing-events.d.ts +6 -0
  172. package/dist/cli/verbs/marketing-events.js +132 -0
  173. package/dist/cli/verbs/markets.d.ts +6 -0
  174. package/dist/cli/verbs/markets.js +324 -0
  175. package/dist/cli/verbs/menus.d.ts +6 -0
  176. package/dist/cli/verbs/menus.js +251 -0
  177. package/dist/cli/verbs/metafield-definition-tools.d.ts +6 -0
  178. package/dist/cli/verbs/metafield-definition-tools.js +289 -0
  179. package/dist/cli/verbs/metafield-definitions.d.ts +6 -0
  180. package/dist/cli/verbs/metafield-definitions.js +240 -0
  181. package/dist/cli/verbs/metafields.d.ts +6 -0
  182. package/dist/cli/verbs/metafields.js +112 -0
  183. package/dist/cli/verbs/metaobject-definition-tools.d.ts +6 -0
  184. package/dist/cli/verbs/metaobject-definition-tools.js +83 -0
  185. package/dist/cli/verbs/metaobject-definitions.d.ts +6 -0
  186. package/dist/cli/verbs/metaobject-definitions.js +176 -0
  187. package/dist/cli/verbs/metaobjects.d.ts +6 -0
  188. package/dist/cli/verbs/metaobjects.js +297 -0
  189. package/dist/cli/verbs/mobile-platform-applications.d.ts +6 -0
  190. package/dist/cli/verbs/mobile-platform-applications.js +247 -0
  191. package/dist/cli/verbs/order-edit.d.ts +6 -0
  192. package/dist/cli/verbs/order-edit.js +596 -0
  193. package/dist/cli/verbs/orders.d.ts +6 -0
  194. package/dist/cli/verbs/orders.js +781 -0
  195. package/dist/cli/verbs/pages.d.ts +6 -0
  196. package/dist/cli/verbs/pages.js +234 -0
  197. package/dist/cli/verbs/payment-customizations.d.ts +6 -0
  198. package/dist/cli/verbs/payment-customizations.js +193 -0
  199. package/dist/cli/verbs/payment-terms.d.ts +6 -0
  200. package/dist/cli/verbs/payment-terms.js +228 -0
  201. package/dist/cli/verbs/point-of-sale.d.ts +6 -0
  202. package/dist/cli/verbs/point-of-sale.js +57 -0
  203. package/dist/cli/verbs/price-lists.d.ts +6 -0
  204. package/dist/cli/verbs/price-lists.js +426 -0
  205. package/dist/cli/verbs/product-feeds.d.ts +6 -0
  206. package/dist/cli/verbs/product-feeds.js +187 -0
  207. package/dist/cli/verbs/product-variants.d.ts +6 -0
  208. package/dist/cli/verbs/product-variants.js +388 -0
  209. package/dist/cli/verbs/products.d.ts +6 -0
  210. package/dist/cli/verbs/products.js +1257 -0
  211. package/dist/cli/verbs/publications.d.ts +6 -0
  212. package/dist/cli/verbs/publications.js +256 -0
  213. package/dist/cli/verbs/publishables.d.ts +6 -0
  214. package/dist/cli/verbs/publishables.js +73 -0
  215. package/dist/cli/verbs/refunds.d.ts +6 -0
  216. package/dist/cli/verbs/refunds.js +226 -0
  217. package/dist/cli/verbs/resource-feedback.d.ts +6 -0
  218. package/dist/cli/verbs/resource-feedback.js +119 -0
  219. package/dist/cli/verbs/returnable-fulfillments.d.ts +6 -0
  220. package/dist/cli/verbs/returnable-fulfillments.js +102 -0
  221. package/dist/cli/verbs/returns.d.ts +6 -0
  222. package/dist/cli/verbs/returns.js +506 -0
  223. package/dist/cli/verbs/reverse-deliveries.d.ts +6 -0
  224. package/dist/cli/verbs/reverse-deliveries.js +203 -0
  225. package/dist/cli/verbs/reverse-fulfillment-orders.d.ts +6 -0
  226. package/dist/cli/verbs/reverse-fulfillment-orders.js +157 -0
  227. package/dist/cli/verbs/saved-searches.d.ts +6 -0
  228. package/dist/cli/verbs/saved-searches.js +150 -0
  229. package/dist/cli/verbs/script-tags.d.ts +6 -0
  230. package/dist/cli/verbs/script-tags.js +179 -0
  231. package/dist/cli/verbs/segments.d.ts +6 -0
  232. package/dist/cli/verbs/segments.js +343 -0
  233. package/dist/cli/verbs/selling-plan-group-products.d.ts +6 -0
  234. package/dist/cli/verbs/selling-plan-group-products.js +115 -0
  235. package/dist/cli/verbs/selling-plan-groups.d.ts +6 -0
  236. package/dist/cli/verbs/selling-plan-groups.js +208 -0
  237. package/dist/cli/verbs/server-pixels.d.ts +6 -0
  238. package/dist/cli/verbs/server-pixels.js +172 -0
  239. package/dist/cli/verbs/shipping-packages.d.ts +6 -0
  240. package/dist/cli/verbs/shipping-packages.js +107 -0
  241. package/dist/cli/verbs/shop-policies.d.ts +6 -0
  242. package/dist/cli/verbs/shop-policies.js +91 -0
  243. package/dist/cli/verbs/shop-utils.d.ts +6 -0
  244. package/dist/cli/verbs/shop-utils.js +147 -0
  245. package/dist/cli/verbs/shop.d.ts +6 -0
  246. package/dist/cli/verbs/shop.js +177 -0
  247. package/dist/cli/verbs/shopify-functions.d.ts +6 -0
  248. package/dist/cli/verbs/shopify-functions.js +127 -0
  249. package/dist/cli/verbs/shopify-payments.d.ts +6 -0
  250. package/dist/cli/verbs/shopify-payments.js +111 -0
  251. package/dist/cli/verbs/staff.d.ts +6 -0
  252. package/dist/cli/verbs/staff.js +127 -0
  253. package/dist/cli/verbs/staged-uploads.d.ts +6 -0
  254. package/dist/cli/verbs/staged-uploads.js +128 -0
  255. package/dist/cli/verbs/store-credit.d.ts +6 -0
  256. package/dist/cli/verbs/store-credit.js +209 -0
  257. package/dist/cli/verbs/storefront-access-tokens.d.ts +6 -0
  258. package/dist/cli/verbs/storefront-access-tokens.js +183 -0
  259. package/dist/cli/verbs/subscription-billing-cycles.d.ts +6 -0
  260. package/dist/cli/verbs/subscription-billing-cycles.js +391 -0
  261. package/dist/cli/verbs/subscription-billing.d.ts +6 -0
  262. package/dist/cli/verbs/subscription-billing.js +391 -0
  263. package/dist/cli/verbs/subscription-contracts.d.ts +6 -0
  264. package/dist/cli/verbs/subscription-contracts.js +391 -0
  265. package/dist/cli/verbs/subscription-drafts.d.ts +6 -0
  266. package/dist/cli/verbs/subscription-drafts.js +315 -0
  267. package/dist/cli/verbs/tags.d.ts +6 -0
  268. package/dist/cli/verbs/tags.js +73 -0
  269. package/dist/cli/verbs/tax.d.ts +6 -0
  270. package/dist/cli/verbs/tax.js +114 -0
  271. package/dist/cli/verbs/taxonomy.d.ts +6 -0
  272. package/dist/cli/verbs/taxonomy.js +99 -0
  273. package/dist/cli/verbs/tender-transactions.d.ts +6 -0
  274. package/dist/cli/verbs/tender-transactions.js +105 -0
  275. package/dist/cli/verbs/themes.d.ts +6 -0
  276. package/dist/cli/verbs/themes.js +297 -0
  277. package/dist/cli/verbs/translations.d.ts +6 -0
  278. package/dist/cli/verbs/translations.js +221 -0
  279. package/dist/cli/verbs/types.d.ts +4 -0
  280. package/dist/cli/verbs/types.js +224 -0
  281. package/dist/cli/verbs/url-redirects.d.ts +6 -0
  282. package/dist/cli/verbs/url-redirects.js +407 -0
  283. package/dist/cli/verbs/validations.d.ts +6 -0
  284. package/dist/cli/verbs/validations.js +181 -0
  285. package/dist/cli/verbs/web-pixels.d.ts +6 -0
  286. package/dist/cli/verbs/web-pixels.js +145 -0
  287. package/dist/cli/verbs/web-presences.d.ts +6 -0
  288. package/dist/cli/verbs/web-presences.js +186 -0
  289. package/dist/cli/verbs/webhooks.d.ts +6 -0
  290. package/dist/cli/verbs/webhooks.js +336 -0
  291. package/dist/cli/workflows/files/stagedUploads.d.ts +28 -0
  292. package/dist/cli/workflows/files/stagedUploads.js +175 -0
  293. package/dist/cli/workflows/inventory/resolveInventoryItemId.d.ts +6 -0
  294. package/dist/cli/workflows/inventory/resolveInventoryItemId.js +59 -0
  295. package/dist/cli/workflows/productVariants/upsert.d.ts +8 -0
  296. package/dist/cli/workflows/productVariants/upsert.js +110 -0
  297. package/dist/cli/workflows/products/metafieldsUpsert.d.ts +6 -0
  298. package/dist/cli/workflows/products/metafieldsUpsert.js +94 -0
  299. package/dist/cli/workflows/products/publishablePublish.d.ts +21 -0
  300. package/dist/cli/workflows/products/publishablePublish.js +131 -0
  301. package/dist/cli/workflows/publications/resolvePublicationId.d.ts +17 -0
  302. package/dist/cli/workflows/publications/resolvePublicationId.js +93 -0
  303. package/dist/cli.d.ts +1 -0
  304. package/dist/cli.js +152 -0
  305. package/dist/defaults.d.ts +2 -0
  306. package/dist/defaults.js +38 -0
  307. package/dist/generated/admin-2026-04/index.d.ts +25 -0
  308. package/dist/generated/admin-2026-04/index.js +70 -0
  309. package/dist/generated/admin-2026-04/runtime/batcher.d.ts +105 -0
  310. package/dist/generated/admin-2026-04/runtime/batcher.js +203 -0
  311. package/dist/generated/admin-2026-04/runtime/createClient.d.ts +17 -0
  312. package/dist/generated/admin-2026-04/runtime/createClient.js +59 -0
  313. package/dist/generated/admin-2026-04/runtime/error.d.ts +18 -0
  314. package/dist/generated/admin-2026-04/runtime/error.js +44 -0
  315. package/dist/generated/admin-2026-04/runtime/fetcher.d.ts +10 -0
  316. package/dist/generated/admin-2026-04/runtime/fetcher.js +104 -0
  317. package/dist/generated/admin-2026-04/runtime/generateGraphqlOperation.d.ts +30 -0
  318. package/dist/generated/admin-2026-04/runtime/generateGraphqlOperation.js +191 -0
  319. package/dist/generated/admin-2026-04/runtime/index.d.ts +11 -0
  320. package/dist/generated/admin-2026-04/runtime/index.js +46 -0
  321. package/dist/generated/admin-2026-04/runtime/linkTypeMap.d.ts +9 -0
  322. package/dist/generated/admin-2026-04/runtime/linkTypeMap.js +142 -0
  323. package/dist/generated/admin-2026-04/runtime/typeSelection.d.ts +28 -0
  324. package/dist/generated/admin-2026-04/runtime/typeSelection.js +17 -0
  325. package/dist/generated/admin-2026-04/runtime/types.d.ts +55 -0
  326. package/dist/generated/admin-2026-04/runtime/types.js +17 -0
  327. package/dist/generated/admin-2026-04/schema.d.ts +102240 -0
  328. package/dist/generated/admin-2026-04/schema.graphql +91596 -0
  329. package/dist/generated/admin-2026-04/schema.js +20322 -0
  330. package/dist/generated/admin-2026-04/types.d.ts +24224 -0
  331. package/dist/generated/admin-2026-04/types.js +62299 -0
  332. package/dist/generated/help/schema-help.d.ts +30 -0
  333. package/dist/generated/help/schema-help.js +61833 -0
  334. package/dist/graphqlValidator.d.ts +17 -0
  335. package/dist/graphqlValidator.js +84 -0
  336. package/dist/index.d.ts +1 -0
  337. package/dist/index.js +23 -0
  338. package/package.json +65 -0
  339. package/schema/2026-04.graphql +61256 -0
  340. package/schema/2026-04.introspection.json +1 -0
@@ -0,0 +1,523 @@
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 discounts_code_exports = {};
20
+ __export(discounts_code_exports, {
21
+ runDiscountsCode: () => runDiscountsCode
22
+ });
23
+ module.exports = __toCommonJS(discounts_code_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 codeDiscountNodeSummarySelection = {
32
+ id: true,
33
+ codeDiscount: {
34
+ __typename: true,
35
+ on_DiscountCodeBasic: {
36
+ title: true,
37
+ status: true,
38
+ startsAt: true,
39
+ endsAt: true,
40
+ usageLimit: true,
41
+ asyncUsageCount: true,
42
+ codes: { __args: { first: 5 }, nodes: { id: true, code: true } }
43
+ },
44
+ on_DiscountCodeBxgy: {
45
+ title: true,
46
+ status: true,
47
+ startsAt: true,
48
+ endsAt: true,
49
+ usageLimit: true,
50
+ asyncUsageCount: true,
51
+ codes: { __args: { first: 5 }, nodes: { id: true, code: true } }
52
+ },
53
+ on_DiscountCodeFreeShipping: {
54
+ title: true,
55
+ status: true,
56
+ startsAt: true,
57
+ endsAt: true,
58
+ usageLimit: true,
59
+ asyncUsageCount: true,
60
+ codes: { __args: { first: 5 }, nodes: { id: true, code: true } }
61
+ },
62
+ on_DiscountCodeApp: {
63
+ title: true,
64
+ status: true,
65
+ startsAt: true,
66
+ endsAt: true,
67
+ usageLimit: true,
68
+ asyncUsageCount: true,
69
+ codes: { __args: { first: 5 }, nodes: { id: true, code: true } },
70
+ appDiscountType: { title: true, functionId: true }
71
+ }
72
+ }
73
+ };
74
+ const codeDiscountNodeFullSelection = {
75
+ ...codeDiscountNodeSummarySelection
76
+ };
77
+ const codeAppDiscountSummarySelection = {
78
+ discountId: true,
79
+ title: true,
80
+ status: true
81
+ };
82
+ const getCodeDiscountSelection = (view) => {
83
+ if (view === "ids") return { id: true };
84
+ if (view === "full") return codeDiscountNodeFullSelection;
85
+ if (view === "raw") return {};
86
+ return codeDiscountNodeSummarySelection;
87
+ };
88
+ const applyFunctionId = (input, functionId) => {
89
+ if (!functionId) return input;
90
+ if (input && typeof input === "object" && !Array.isArray(input)) {
91
+ if (input.functionId === void 0 && input.functionHandle === void 0) {
92
+ return { ...input, functionId };
93
+ }
94
+ }
95
+ return input;
96
+ };
97
+ const parseRedeemCodeInputs = (raw) => raw.map((code) => ({ code }));
98
+ const hasListArg = (value) => Array.isArray(value) ? value.length > 0 : value !== void 0;
99
+ const runDiscountsCode = async ({
100
+ ctx,
101
+ verb,
102
+ argv
103
+ }) => {
104
+ if (argv.includes("--help") || argv.includes("-h")) {
105
+ console.log(
106
+ [
107
+ "Usage:",
108
+ " shop discounts-code <verb> [flags]",
109
+ "",
110
+ "Verbs:",
111
+ " create-basic|create-bxgy|create-free-shipping|create-app",
112
+ " get|get-by-code|list|count",
113
+ " update-basic|update-bxgy|update-free-shipping|update-app",
114
+ " delete|bulk-delete|activate|deactivate|bulk-activate|bulk-deactivate",
115
+ " add-redeem-codes|delete-redeem-codes",
116
+ "",
117
+ "Common output flags:",
118
+ " --view summary|ids|full|raw",
119
+ " --select <path> (repeatable; dot paths; adds to base view selection)",
120
+ " --selection <graphql> (selection override; can be @file.gql)",
121
+ "",
122
+ "Notes:",
123
+ " Destructive operations require --yes.",
124
+ " add-redeem-codes accepts --codes <code,code,...>."
125
+ ].join("\n")
126
+ );
127
+ return;
128
+ }
129
+ if (verb === "get") {
130
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
131
+ const id = (0, import_shared.requireId)(args.id, "DiscountCodeNode");
132
+ const selection = (0, import_select.resolveSelection)({
133
+ resource: "discounts-code",
134
+ view: ctx.view,
135
+ baseSelection: getCodeDiscountSelection(ctx.view),
136
+ select: args.select,
137
+ selection: args.selection,
138
+ include: args.include,
139
+ ensureId: ctx.quiet
140
+ });
141
+ const result = await (0, import_router.runQuery)(ctx, { codeDiscountNode: { __args: { id }, ...selection } });
142
+ if (result === void 0) return;
143
+ (0, import_output.printNode)({ node: result.codeDiscountNode, format: ctx.format, quiet: ctx.quiet });
144
+ return;
145
+ }
146
+ if (verb === "get-by-code") {
147
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { code: { type: "string" } } });
148
+ const code = args.code;
149
+ if (!code) throw new import_errors.CliError("Missing --code", 2);
150
+ const selection = (0, import_select.resolveSelection)({
151
+ resource: "discounts-code",
152
+ view: ctx.view,
153
+ baseSelection: getCodeDiscountSelection(ctx.view),
154
+ select: args.select,
155
+ selection: args.selection,
156
+ include: args.include,
157
+ ensureId: ctx.quiet
158
+ });
159
+ const result = await (0, import_router.runQuery)(ctx, { codeDiscountNodeByCode: { __args: { code }, ...selection } });
160
+ if (result === void 0) return;
161
+ (0, import_output.printNode)({ node: result.codeDiscountNodeByCode, format: ctx.format, quiet: ctx.quiet });
162
+ return;
163
+ }
164
+ if (verb === "list") {
165
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
166
+ const first = (0, import_shared.parseFirst)(args.first);
167
+ const after = args.after;
168
+ const query = args.query;
169
+ const reverse = args.reverse;
170
+ const sortKey = args.sort;
171
+ const nodeSelection = (0, import_select.resolveSelection)({
172
+ resource: "discounts-code",
173
+ view: ctx.view,
174
+ baseSelection: getCodeDiscountSelection(ctx.view),
175
+ select: args.select,
176
+ selection: args.selection,
177
+ include: args.include,
178
+ ensureId: ctx.quiet
179
+ });
180
+ const result = await (0, import_router.runQuery)(ctx, {
181
+ codeDiscountNodes: {
182
+ __args: { first, after, query, reverse, sortKey },
183
+ pageInfo: { hasNextPage: true, endCursor: true },
184
+ nodes: nodeSelection
185
+ }
186
+ });
187
+ if (result === void 0) return;
188
+ (0, import_output.printConnection)({
189
+ connection: result.codeDiscountNodes,
190
+ format: ctx.format,
191
+ quiet: ctx.quiet,
192
+ nextPageArgs: (0, import_shared.buildListNextPageArgs)("discounts-code", { first, query, sort: sortKey, reverse })
193
+ });
194
+ return;
195
+ }
196
+ if (verb === "count") {
197
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
198
+ const query = args.query;
199
+ const result = await (0, import_router.runQuery)(ctx, { discountCodesCount: { __args: { query }, count: true, precision: true } });
200
+ if (result === void 0) return;
201
+ if (ctx.quiet) return console.log(result.discountCodesCount?.count ?? "");
202
+ (0, import_output.printJson)(result.discountCodesCount, ctx.format !== "raw");
203
+ return;
204
+ }
205
+ if (verb === "create-basic") {
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
+ discountCodeBasicCreate: {
215
+ __args: { basicCodeDiscount: built.input },
216
+ codeDiscountNode: codeDiscountNodeSummarySelection,
217
+ userErrors: { field: true, message: true }
218
+ }
219
+ });
220
+ if (result === void 0) return;
221
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.discountCodeBasicCreate, failOnUserErrors: ctx.failOnUserErrors });
222
+ if (ctx.quiet) return console.log(result.discountCodeBasicCreate?.codeDiscountNode?.id ?? "");
223
+ (0, import_output.printJson)(result.discountCodeBasicCreate, ctx.format !== "raw");
224
+ return;
225
+ }
226
+ if (verb === "create-bxgy") {
227
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
228
+ const built = (0, import_input.buildInput)({
229
+ inputArg: args.input,
230
+ setArgs: args.set,
231
+ setJsonArgs: args["set-json"]
232
+ });
233
+ if (!built.used) throw new import_errors.CliError("Missing --input or --set/--set-json", 2);
234
+ const result = await (0, import_router.runMutation)(ctx, {
235
+ discountCodeBxgyCreate: {
236
+ __args: { bxgyCodeDiscount: built.input },
237
+ codeDiscountNode: codeDiscountNodeSummarySelection,
238
+ userErrors: { field: true, message: true }
239
+ }
240
+ });
241
+ if (result === void 0) return;
242
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.discountCodeBxgyCreate, failOnUserErrors: ctx.failOnUserErrors });
243
+ if (ctx.quiet) return console.log(result.discountCodeBxgyCreate?.codeDiscountNode?.id ?? "");
244
+ (0, import_output.printJson)(result.discountCodeBxgyCreate, ctx.format !== "raw");
245
+ return;
246
+ }
247
+ if (verb === "create-free-shipping") {
248
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
249
+ const built = (0, import_input.buildInput)({
250
+ inputArg: args.input,
251
+ setArgs: args.set,
252
+ setJsonArgs: args["set-json"]
253
+ });
254
+ if (!built.used) throw new import_errors.CliError("Missing --input or --set/--set-json", 2);
255
+ const result = await (0, import_router.runMutation)(ctx, {
256
+ discountCodeFreeShippingCreate: {
257
+ __args: { freeShippingCodeDiscount: built.input },
258
+ codeDiscountNode: codeDiscountNodeSummarySelection,
259
+ userErrors: { field: true, message: true }
260
+ }
261
+ });
262
+ if (result === void 0) return;
263
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.discountCodeFreeShippingCreate, failOnUserErrors: ctx.failOnUserErrors });
264
+ if (ctx.quiet) return console.log(result.discountCodeFreeShippingCreate?.codeDiscountNode?.id ?? "");
265
+ (0, import_output.printJson)(result.discountCodeFreeShippingCreate, ctx.format !== "raw");
266
+ return;
267
+ }
268
+ if (verb === "create-app") {
269
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { "function-id": { type: "string" } } });
270
+ const built = (0, import_input.buildInput)({
271
+ inputArg: args.input,
272
+ setArgs: args.set,
273
+ setJsonArgs: args["set-json"]
274
+ });
275
+ if (!built.used) throw new import_errors.CliError("Missing --input or --set/--set-json", 2);
276
+ const input = applyFunctionId(built.input, args["function-id"]);
277
+ const result = await (0, import_router.runMutation)(ctx, {
278
+ discountCodeAppCreate: {
279
+ __args: { codeAppDiscount: input },
280
+ codeAppDiscount: codeAppDiscountSummarySelection,
281
+ userErrors: { field: true, message: true }
282
+ }
283
+ });
284
+ if (result === void 0) return;
285
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.discountCodeAppCreate, failOnUserErrors: ctx.failOnUserErrors });
286
+ if (ctx.quiet) return console.log(result.discountCodeAppCreate?.codeAppDiscount?.discountId ?? "");
287
+ (0, import_output.printJson)(result.discountCodeAppCreate, ctx.format !== "raw");
288
+ return;
289
+ }
290
+ if (verb === "update-basic") {
291
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
292
+ const id = (0, import_shared.requireId)(args.id, "DiscountCodeNode");
293
+ const built = (0, import_input.buildInput)({
294
+ inputArg: args.input,
295
+ setArgs: args.set,
296
+ setJsonArgs: args["set-json"]
297
+ });
298
+ if (!built.used) throw new import_errors.CliError("Missing --input or --set/--set-json", 2);
299
+ const result = await (0, import_router.runMutation)(ctx, {
300
+ discountCodeBasicUpdate: {
301
+ __args: { id, basicCodeDiscount: built.input },
302
+ codeDiscountNode: codeDiscountNodeSummarySelection,
303
+ userErrors: { field: true, message: true }
304
+ }
305
+ });
306
+ if (result === void 0) return;
307
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.discountCodeBasicUpdate, failOnUserErrors: ctx.failOnUserErrors });
308
+ if (ctx.quiet) return console.log(result.discountCodeBasicUpdate?.codeDiscountNode?.id ?? "");
309
+ (0, import_output.printJson)(result.discountCodeBasicUpdate, ctx.format !== "raw");
310
+ return;
311
+ }
312
+ if (verb === "update-bxgy") {
313
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
314
+ const id = (0, import_shared.requireId)(args.id, "DiscountCodeNode");
315
+ const built = (0, import_input.buildInput)({
316
+ inputArg: args.input,
317
+ setArgs: args.set,
318
+ setJsonArgs: args["set-json"]
319
+ });
320
+ if (!built.used) throw new import_errors.CliError("Missing --input or --set/--set-json", 2);
321
+ const result = await (0, import_router.runMutation)(ctx, {
322
+ discountCodeBxgyUpdate: {
323
+ __args: { id, bxgyCodeDiscount: built.input },
324
+ codeDiscountNode: codeDiscountNodeSummarySelection,
325
+ userErrors: { field: true, message: true }
326
+ }
327
+ });
328
+ if (result === void 0) return;
329
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.discountCodeBxgyUpdate, failOnUserErrors: ctx.failOnUserErrors });
330
+ if (ctx.quiet) return console.log(result.discountCodeBxgyUpdate?.codeDiscountNode?.id ?? "");
331
+ (0, import_output.printJson)(result.discountCodeBxgyUpdate, ctx.format !== "raw");
332
+ return;
333
+ }
334
+ if (verb === "update-free-shipping") {
335
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
336
+ const id = (0, import_shared.requireId)(args.id, "DiscountCodeNode");
337
+ const built = (0, import_input.buildInput)({
338
+ inputArg: args.input,
339
+ setArgs: args.set,
340
+ setJsonArgs: args["set-json"]
341
+ });
342
+ if (!built.used) throw new import_errors.CliError("Missing --input or --set/--set-json", 2);
343
+ const result = await (0, import_router.runMutation)(ctx, {
344
+ discountCodeFreeShippingUpdate: {
345
+ __args: { id, freeShippingCodeDiscount: built.input },
346
+ codeDiscountNode: codeDiscountNodeSummarySelection,
347
+ userErrors: { field: true, message: true }
348
+ }
349
+ });
350
+ if (result === void 0) return;
351
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.discountCodeFreeShippingUpdate, failOnUserErrors: ctx.failOnUserErrors });
352
+ if (ctx.quiet) return console.log(result.discountCodeFreeShippingUpdate?.codeDiscountNode?.id ?? "");
353
+ (0, import_output.printJson)(result.discountCodeFreeShippingUpdate, ctx.format !== "raw");
354
+ return;
355
+ }
356
+ if (verb === "update-app") {
357
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { "function-id": { type: "string" } } });
358
+ const id = (0, import_shared.requireId)(args.id, "DiscountCodeNode");
359
+ const built = (0, import_input.buildInput)({
360
+ inputArg: args.input,
361
+ setArgs: args.set,
362
+ setJsonArgs: args["set-json"]
363
+ });
364
+ if (!built.used) throw new import_errors.CliError("Missing --input or --set/--set-json", 2);
365
+ const input = applyFunctionId(built.input, args["function-id"]);
366
+ const result = await (0, import_router.runMutation)(ctx, {
367
+ discountCodeAppUpdate: {
368
+ __args: { id, codeAppDiscount: input },
369
+ codeAppDiscount: codeAppDiscountSummarySelection,
370
+ userErrors: { field: true, message: true }
371
+ }
372
+ });
373
+ if (result === void 0) return;
374
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.discountCodeAppUpdate, failOnUserErrors: ctx.failOnUserErrors });
375
+ if (ctx.quiet) return console.log(result.discountCodeAppUpdate?.codeAppDiscount?.discountId ?? "");
376
+ (0, import_output.printJson)(result.discountCodeAppUpdate, ctx.format !== "raw");
377
+ return;
378
+ }
379
+ if (verb === "delete") {
380
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
381
+ const id = (0, import_shared.requireId)(args.id, "DiscountCodeNode");
382
+ if (!args.yes) throw new import_errors.CliError("Refusing to delete without --yes", 2);
383
+ const result = await (0, import_router.runMutation)(ctx, {
384
+ discountCodeDelete: {
385
+ __args: { id },
386
+ deletedCodeDiscountId: true,
387
+ userErrors: { field: true, message: true }
388
+ }
389
+ });
390
+ if (result === void 0) return;
391
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.discountCodeDelete, failOnUserErrors: ctx.failOnUserErrors });
392
+ if (ctx.quiet) return console.log(result.discountCodeDelete?.deletedCodeDiscountId ?? "");
393
+ (0, import_output.printJson)(result.discountCodeDelete, ctx.format !== "raw");
394
+ return;
395
+ }
396
+ if (verb === "bulk-delete") {
397
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { ids: { type: "string", multiple: true } } });
398
+ if (!args.yes) throw new import_errors.CliError("Refusing to bulk-delete without --yes", 2);
399
+ const rawIds = args.ids;
400
+ const ids = hasListArg(rawIds) ? (0, import_shared.parseIds)(rawIds, "DiscountCodeNode") : void 0;
401
+ const search = args.query;
402
+ if ((!ids || ids.length === 0) && !search) {
403
+ throw new import_errors.CliError("Missing --ids or --query for bulk-delete", 2);
404
+ }
405
+ const result = await (0, import_router.runMutation)(ctx, {
406
+ discountCodeBulkDelete: {
407
+ __args: { ...ids ? { ids } : {}, ...search ? { search } : {} },
408
+ job: { id: true, done: true },
409
+ userErrors: { field: true, message: true }
410
+ }
411
+ });
412
+ if (result === void 0) return;
413
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.discountCodeBulkDelete, failOnUserErrors: ctx.failOnUserErrors });
414
+ if (ctx.quiet) return console.log(result.discountCodeBulkDelete?.job?.id ?? "");
415
+ (0, import_output.printJson)(result.discountCodeBulkDelete, ctx.format !== "raw");
416
+ return;
417
+ }
418
+ if (verb === "activate" || verb === "deactivate") {
419
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
420
+ const id = (0, import_shared.requireId)(args.id, "DiscountCodeNode");
421
+ const mutationField = verb === "activate" ? "discountCodeActivate" : "discountCodeDeactivate";
422
+ const result = await (0, import_router.runMutation)(ctx, {
423
+ [mutationField]: {
424
+ __args: { id },
425
+ codeDiscountNode: codeDiscountNodeSummarySelection,
426
+ userErrors: { field: true, message: true }
427
+ }
428
+ });
429
+ if (result === void 0) return;
430
+ const payload = result[mutationField];
431
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload, failOnUserErrors: ctx.failOnUserErrors });
432
+ if (ctx.quiet) return console.log(payload?.codeDiscountNode?.id ?? "");
433
+ (0, import_output.printJson)(payload, ctx.format !== "raw");
434
+ return;
435
+ }
436
+ if (verb === "bulk-activate" || verb === "bulk-deactivate") {
437
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { ids: { type: "string", multiple: true } } });
438
+ const rawIds = args.ids;
439
+ const ids = hasListArg(rawIds) ? (0, import_shared.parseIds)(rawIds, "DiscountCodeNode") : void 0;
440
+ const search = args.query;
441
+ if ((!ids || ids.length === 0) && !search) {
442
+ throw new import_errors.CliError("Missing --ids or --query for bulk operation", 2);
443
+ }
444
+ const mutationField = verb === "bulk-activate" ? "discountCodeBulkActivate" : "discountCodeBulkDeactivate";
445
+ const result = await (0, import_router.runMutation)(ctx, {
446
+ [mutationField]: {
447
+ __args: { ...ids ? { ids } : {}, ...search ? { search } : {} },
448
+ job: { id: true, done: true },
449
+ userErrors: { field: true, message: true }
450
+ }
451
+ });
452
+ if (result === void 0) return;
453
+ const payload = result[mutationField];
454
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload, failOnUserErrors: ctx.failOnUserErrors });
455
+ if (ctx.quiet) return console.log(payload?.job?.id ?? "");
456
+ (0, import_output.printJson)(payload, ctx.format !== "raw");
457
+ return;
458
+ }
459
+ if (verb === "add-redeem-codes") {
460
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { codes: { type: "string" } } });
461
+ const discountId = (0, import_shared.requireId)(args.id, "DiscountCodeNode");
462
+ const built = (0, import_input.buildInput)({
463
+ inputArg: args.input,
464
+ setArgs: args.set,
465
+ setJsonArgs: args["set-json"]
466
+ });
467
+ let codes;
468
+ if (typeof args.codes === "string") {
469
+ codes = parseRedeemCodeInputs((0, import_shared.parseCsv)(args.codes, "--codes"));
470
+ } else if (built.used) {
471
+ if (Array.isArray(built.input)) {
472
+ codes = built.input.map((c) => typeof c === "string" ? { code: c } : c);
473
+ } else if (Array.isArray(built.input?.codes)) {
474
+ codes = built.input.codes.map((c) => typeof c === "string" ? { code: c } : c);
475
+ }
476
+ }
477
+ if (!codes || codes.length === 0) throw new import_errors.CliError("Missing --codes or input codes array", 2);
478
+ const result = await (0, import_router.runMutation)(ctx, {
479
+ discountRedeemCodeBulkAdd: {
480
+ __args: { discountId, codes },
481
+ bulkCreation: { id: true, done: true, codesCount: true },
482
+ userErrors: { field: true, message: true }
483
+ }
484
+ });
485
+ if (result === void 0) return;
486
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.discountRedeemCodeBulkAdd, failOnUserErrors: ctx.failOnUserErrors });
487
+ if (ctx.quiet) return console.log(result.discountRedeemCodeBulkAdd?.bulkCreation?.id ?? "");
488
+ (0, import_output.printJson)(result.discountRedeemCodeBulkAdd, ctx.format !== "raw");
489
+ return;
490
+ }
491
+ if (verb === "delete-redeem-codes") {
492
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { ids: { type: "string", multiple: true } } });
493
+ const discountId = (0, import_shared.requireId)(args.id, "DiscountCodeNode");
494
+ if (!args.yes) throw new import_errors.CliError("Refusing to delete redeem codes without --yes", 2);
495
+ const rawIds = args.ids;
496
+ const ids = hasListArg(rawIds) ? (0, import_shared.parseIds)(rawIds, "DiscountRedeemCode") : void 0;
497
+ const search = args.query;
498
+ if ((!ids || ids.length === 0) && !search) {
499
+ throw new import_errors.CliError("Missing --ids or --query for delete-redeem-codes", 2);
500
+ }
501
+ const result = await (0, import_router.runMutation)(ctx, {
502
+ discountCodeRedeemCodeBulkDelete: {
503
+ __args: { discountId, ...ids ? { ids } : {}, ...search ? { search } : {} },
504
+ job: { id: true, done: true },
505
+ userErrors: { field: true, message: true }
506
+ }
507
+ });
508
+ if (result === void 0) return;
509
+ (0, import_userErrors.maybeFailOnUserErrors)({
510
+ payload: result.discountCodeRedeemCodeBulkDelete,
511
+ failOnUserErrors: ctx.failOnUserErrors
512
+ });
513
+ if (ctx.quiet) return console.log(result.discountCodeRedeemCodeBulkDelete?.job?.id ?? "");
514
+ (0, import_output.printJson)(result.discountCodeRedeemCodeBulkDelete, ctx.format !== "raw");
515
+ return;
516
+ }
517
+ throw new import_errors.CliError(`Unknown verb for discounts-code: ${verb}`, 2);
518
+ };
519
+ // Annotate the CommonJS export names for ESM import in node:
520
+ 0 && (module.exports = {
521
+ runDiscountsCode
522
+ });
523
+ //# sourceMappingURL=discounts-code.js.map
@@ -0,0 +1,6 @@
1
+ import { type CommandContext } from '../router';
2
+ export declare const runDisputes: ({ ctx, verb, argv, }: {
3
+ ctx: CommandContext;
4
+ verb: string;
5
+ argv: string[];
6
+ }) => Promise<void>;
@@ -0,0 +1,154 @@
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 disputes_exports = {};
20
+ __export(disputes_exports, {
21
+ runDisputes: () => runDisputes
22
+ });
23
+ module.exports = __toCommonJS(disputes_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 disputeSummarySelection = {
32
+ id: true,
33
+ status: true,
34
+ type: true,
35
+ initiatedAt: true,
36
+ evidenceDueBy: true,
37
+ amount: { amount: true, currencyCode: true },
38
+ order: { id: true, name: true }
39
+ };
40
+ const disputeEvidenceSummarySelection = {
41
+ id: true,
42
+ customerEmailAddress: true,
43
+ dispute: { id: true, status: true, initiatedAt: true }
44
+ };
45
+ const getDisputeSelection = (view) => {
46
+ if (view === "ids") return { id: true };
47
+ if (view === "raw") return {};
48
+ return disputeSummarySelection;
49
+ };
50
+ const getEvidenceSelection = (view) => {
51
+ if (view === "ids") return { id: true };
52
+ if (view === "raw") return {};
53
+ return disputeEvidenceSummarySelection;
54
+ };
55
+ const runDisputes = async ({
56
+ ctx,
57
+ verb,
58
+ argv
59
+ }) => {
60
+ if (argv.includes("--help") || argv.includes("-h")) {
61
+ console.log(
62
+ [
63
+ "Usage:",
64
+ " shop disputes <verb> [flags]",
65
+ "",
66
+ "Verbs:",
67
+ " get|list",
68
+ " evidence get|evidence update"
69
+ ].join("\n")
70
+ );
71
+ return;
72
+ }
73
+ if (verb === "get") {
74
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
75
+ const id = (0, import_shared.requireId)(args.id, "ShopifyPaymentsDispute");
76
+ const selection = (0, import_select.resolveSelection)({
77
+ view: ctx.view,
78
+ baseSelection: getDisputeSelection(ctx.view),
79
+ select: args.select,
80
+ selection: args.selection,
81
+ ensureId: ctx.quiet
82
+ });
83
+ const result = await (0, import_router.runQuery)(ctx, { dispute: { __args: { id }, ...selection } });
84
+ if (result === void 0) return;
85
+ (0, import_output.printNode)({ node: result.dispute, format: ctx.format, quiet: ctx.quiet });
86
+ return;
87
+ }
88
+ if (verb === "list") {
89
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
90
+ const first = (0, import_shared.parseFirst)(args.first);
91
+ const after = args.after;
92
+ const reverse = args.reverse;
93
+ const nodeSelection = (0, import_select.resolveSelection)({
94
+ view: ctx.view,
95
+ baseSelection: getDisputeSelection(ctx.view),
96
+ select: args.select,
97
+ selection: args.selection,
98
+ ensureId: ctx.quiet
99
+ });
100
+ const result = await (0, import_router.runQuery)(ctx, {
101
+ disputes: {
102
+ __args: { first, after, reverse },
103
+ pageInfo: { hasNextPage: true, endCursor: true },
104
+ nodes: nodeSelection
105
+ }
106
+ });
107
+ if (result === void 0) return;
108
+ (0, import_output.printConnection)({ connection: result.disputes, format: ctx.format, quiet: ctx.quiet });
109
+ return;
110
+ }
111
+ if (verb === "evidence get") {
112
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
113
+ const id = (0, import_shared.requireId)(args.id, "ShopifyPaymentsDisputeEvidence");
114
+ const selection = (0, import_select.resolveSelection)({
115
+ view: ctx.view,
116
+ baseSelection: getEvidenceSelection(ctx.view),
117
+ select: args.select,
118
+ selection: args.selection,
119
+ ensureId: ctx.quiet
120
+ });
121
+ const result = await (0, import_router.runQuery)(ctx, { disputeEvidence: { __args: { id }, ...selection } });
122
+ if (result === void 0) return;
123
+ (0, import_output.printNode)({ node: result.disputeEvidence, format: ctx.format, quiet: ctx.quiet });
124
+ return;
125
+ }
126
+ if (verb === "evidence update") {
127
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
128
+ const id = (0, import_shared.requireId)(args.id, "ShopifyPaymentsDisputeEvidence");
129
+ const built = (0, import_input.buildInput)({
130
+ inputArg: args.input,
131
+ setArgs: args.set,
132
+ setJsonArgs: args["set-json"]
133
+ });
134
+ if (!built.used) throw new import_errors.CliError("Missing --input or --set/--set-json", 2);
135
+ const result = await (0, import_router.runMutation)(ctx, {
136
+ disputeEvidenceUpdate: {
137
+ __args: { id, input: built.input },
138
+ disputeEvidence: { id: true },
139
+ userErrors: { field: true, message: true, code: true }
140
+ }
141
+ });
142
+ if (result === void 0) return;
143
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.disputeEvidenceUpdate, failOnUserErrors: ctx.failOnUserErrors });
144
+ if (ctx.quiet) return console.log(result.disputeEvidenceUpdate?.disputeEvidence?.id ?? "");
145
+ (0, import_output.printJson)(result.disputeEvidenceUpdate, ctx.format !== "raw");
146
+ return;
147
+ }
148
+ throw new import_errors.CliError(`Unknown verb for disputes: ${verb}`, 2);
149
+ };
150
+ // Annotate the CommonJS export names for ESM import in node:
151
+ 0 && (module.exports = {
152
+ runDisputes
153
+ });
154
+ //# sourceMappingURL=disputes.js.map
@@ -0,0 +1,6 @@
1
+ import { type CommandContext } from '../router';
2
+ export declare const runDraftOrders: ({ ctx, verb, argv, }: {
3
+ ctx: CommandContext;
4
+ verb: string;
5
+ argv: string[];
6
+ }) => Promise<void>;