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,853 @@
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 orders_exports = {};
20
+ __export(orders_exports, {
21
+ runOrders: () => runOrders
22
+ });
23
+ module.exports = __toCommonJS(orders_exports);
24
+ var import_errors = require("../errors");
25
+ var import_gid = require("../gid");
26
+ var import_input = require("../input");
27
+ var import_output = require("../output");
28
+ var import_router = require("../router");
29
+ var import_select = require("../selection/select");
30
+ var import_userErrors = require("../userErrors");
31
+ var import_shared = require("./_shared");
32
+ const orderSummarySelection = {
33
+ id: true,
34
+ name: true,
35
+ displayFinancialStatus: true,
36
+ displayFulfillmentStatus: true,
37
+ processedAt: true,
38
+ updatedAt: true
39
+ };
40
+ const orderFullSelection = {
41
+ ...orderSummarySelection,
42
+ createdAt: true,
43
+ tags: true
44
+ };
45
+ const getOrderSelection = (view) => {
46
+ if (view === "ids") return { id: true };
47
+ if (view === "full") return orderFullSelection;
48
+ if (view === "raw") return {};
49
+ return orderSummarySelection;
50
+ };
51
+ const parseCustomIdInput = ({
52
+ namespace,
53
+ key,
54
+ value
55
+ }) => {
56
+ const customKey = typeof key === "string" ? key : void 0;
57
+ const customValue = typeof value === "string" ? value : void 0;
58
+ if (!customKey || !customValue) return void 0;
59
+ const ns = typeof namespace === "string" && namespace ? namespace : void 0;
60
+ return { ...ns ? { namespace: ns } : {}, key: customKey, value: customValue };
61
+ };
62
+ const requireOrderIdFlag = (value, flag = "--order-id") => {
63
+ if (typeof value !== "string" || !value) throw new import_errors.CliError(`Missing ${flag}`, 2);
64
+ return (0, import_gid.coerceGid)(value, "Order");
65
+ };
66
+ const requirePaymentReferenceId = (value) => {
67
+ if (typeof value !== "string" || !value) throw new import_errors.CliError("Missing --payment-reference-id", 2);
68
+ return value;
69
+ };
70
+ const parseBoolFlag = (value, flag) => {
71
+ if (value === void 0) return void 0;
72
+ if (typeof value !== "string") throw new import_errors.CliError(`${flag} must be true|false`, 2);
73
+ const v = value.trim().toLowerCase();
74
+ if (v === "true" || v === "1" || v === "yes") return true;
75
+ if (v === "false" || v === "0" || v === "no") return false;
76
+ throw new import_errors.CliError(`${flag} must be true|false`, 2);
77
+ };
78
+ const runOrders = async ({
79
+ ctx,
80
+ verb,
81
+ argv
82
+ }) => {
83
+ if (argv.includes("--help") || argv.includes("-h")) {
84
+ console.log(
85
+ [
86
+ "Usage:",
87
+ " shop orders <verb> [flags]",
88
+ "",
89
+ "Verbs:",
90
+ " create|get|list|count|update|delete",
91
+ " by-identifier|pending-count",
92
+ " payment-status|capture|create-manual-payment|invoice-send|open",
93
+ " customer-set|customer-remove|risk-assessment-create",
94
+ " add-tags|remove-tags|cancel|close|mark-paid|add-note|fulfill",
95
+ "",
96
+ "Common output flags:",
97
+ " --view summary|ids|full|raw",
98
+ " --select <path> (repeatable; dot paths; adds to base view selection)",
99
+ " --selection <graphql> (selection override; can be @file.gql)"
100
+ ].join("\n")
101
+ );
102
+ return;
103
+ }
104
+ if (verb === "pending-count") {
105
+ const result = await (0, import_router.runQuery)(ctx, { pendingOrdersCount: { count: true, precision: true } });
106
+ if (result === void 0) return;
107
+ if (ctx.quiet) return console.log(result.pendingOrdersCount?.count ?? "");
108
+ (0, import_output.printJson)(result.pendingOrdersCount, ctx.format !== "raw");
109
+ return;
110
+ }
111
+ if (verb === "count") {
112
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { limit: { type: "string" } } });
113
+ const query = args.query;
114
+ const limitRaw = args.limit;
115
+ const limit = limitRaw === void 0 || limitRaw === null || limitRaw === "" ? void 0 : Number(limitRaw);
116
+ if (limit !== void 0 && (!Number.isFinite(limit) || limit <= 0)) {
117
+ throw new import_errors.CliError("--limit must be a positive number", 2);
118
+ }
119
+ const result = await (0, import_router.runQuery)(ctx, {
120
+ ordersCount: {
121
+ __args: {
122
+ ...query ? { query } : {},
123
+ ...limit !== void 0 ? { limit: Math.floor(limit) } : {}
124
+ },
125
+ count: true,
126
+ precision: true
127
+ }
128
+ });
129
+ if (result === void 0) return;
130
+ if (ctx.quiet) return console.log(result.ordersCount?.count ?? "");
131
+ (0, import_output.printJson)(result.ordersCount, ctx.format !== "raw");
132
+ return;
133
+ }
134
+ if (verb === "by-identifier") {
135
+ const args = (0, import_router.parseStandardArgs)({
136
+ argv,
137
+ extraOptions: {
138
+ "custom-id-namespace": { type: "string" },
139
+ "custom-id-key": { type: "string" },
140
+ "custom-id-value": { type: "string" }
141
+ }
142
+ });
143
+ const idRaw = args.id;
144
+ const customId = parseCustomIdInput({
145
+ namespace: args["custom-id-namespace"],
146
+ key: args["custom-id-key"],
147
+ value: args["custom-id-value"]
148
+ });
149
+ if (!idRaw && !customId) throw new import_errors.CliError("Missing --id or --custom-id-key/--custom-id-value", 2);
150
+ const identifier = {
151
+ ...idRaw ? { id: (0, import_gid.coerceGid)(idRaw, "Order") } : {},
152
+ ...customId ? { customId } : {}
153
+ };
154
+ const selection = (0, import_select.resolveSelection)({
155
+ resource: "orders",
156
+ view: ctx.view,
157
+ baseSelection: getOrderSelection(ctx.view),
158
+ select: args.select,
159
+ selection: args.selection,
160
+ include: args.include,
161
+ ensureId: ctx.quiet
162
+ });
163
+ const result = await (0, import_router.runQuery)(ctx, { orderByIdentifier: { __args: { identifier }, ...selection } });
164
+ if (result === void 0) return;
165
+ (0, import_output.printNode)({ node: result.orderByIdentifier, format: ctx.format, quiet: ctx.quiet });
166
+ return;
167
+ }
168
+ if (verb === "get") {
169
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
170
+ const id = (0, import_shared.requireId)(args.id, "Order");
171
+ const selection = (0, import_select.resolveSelection)({
172
+ resource: "orders",
173
+ view: ctx.view,
174
+ baseSelection: getOrderSelection(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, { order: { __args: { id }, ...selection } });
181
+ if (result === void 0) return;
182
+ (0, import_output.printNode)({ node: result.order, format: ctx.format, quiet: ctx.quiet });
183
+ return;
184
+ }
185
+ if (verb === "payment-status") {
186
+ const args = (0, import_router.parseStandardArgs)({
187
+ argv,
188
+ extraOptions: {
189
+ "payment-reference-id": { type: "string" },
190
+ "order-id": { type: "string" }
191
+ }
192
+ });
193
+ const orderId = args["order-id"] !== void 0 ? requireOrderIdFlag(args["order-id"], "--order-id") : requireOrderIdFlag(args.id, "--id");
194
+ const paymentReferenceId = args["payment-reference-id"] !== void 0 ? requirePaymentReferenceId(args["payment-reference-id"]) : (() => {
195
+ throw new import_errors.CliError("Missing --payment-reference-id", 2);
196
+ })();
197
+ const result = await (0, import_router.runQuery)(ctx, {
198
+ orderPaymentStatus: {
199
+ __args: { orderId, paymentReferenceId },
200
+ paymentReferenceId: true,
201
+ status: true,
202
+ errorMessage: true,
203
+ translatedErrorMessage: true,
204
+ transactions: { id: true, kind: true, status: true, amount: true, createdAt: true }
205
+ }
206
+ });
207
+ if (result === void 0) return;
208
+ if (ctx.quiet) return console.log(result.orderPaymentStatus?.status ?? "");
209
+ (0, import_output.printJson)(result.orderPaymentStatus, ctx.format !== "raw");
210
+ return;
211
+ }
212
+ if (verb === "list") {
213
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
214
+ const first = (0, import_shared.parseFirst)(args.first);
215
+ const after = args.after;
216
+ const query = args.query;
217
+ const reverse = args.reverse;
218
+ const sortKey = args.sort;
219
+ const nodeSelection = (0, import_select.resolveSelection)({
220
+ resource: "orders",
221
+ view: ctx.view,
222
+ baseSelection: getOrderSelection(ctx.view),
223
+ select: args.select,
224
+ selection: args.selection,
225
+ include: args.include,
226
+ ensureId: ctx.quiet
227
+ });
228
+ const result = await (0, import_router.runQuery)(ctx, {
229
+ orders: {
230
+ __args: { first, after, query, reverse, sortKey },
231
+ pageInfo: { hasNextPage: true, endCursor: true },
232
+ nodes: nodeSelection
233
+ }
234
+ });
235
+ if (result === void 0) return;
236
+ (0, import_output.printConnection)({
237
+ connection: result.orders,
238
+ format: ctx.format,
239
+ quiet: ctx.quiet,
240
+ nextPageArgs: (0, import_shared.buildListNextPageArgs)("orders", { first, query, sort: sortKey, reverse })
241
+ });
242
+ return;
243
+ }
244
+ if (verb === "create") {
245
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
246
+ const built = (0, import_input.buildInput)({
247
+ inputArg: args.input,
248
+ setArgs: args.set,
249
+ setJsonArgs: args["set-json"]
250
+ });
251
+ if (!built.used) throw new import_errors.CliError("Missing --input or --set/--set-json", 2);
252
+ const result = await (0, import_router.runMutation)(ctx, {
253
+ orderCreate: {
254
+ __args: { order: built.input },
255
+ order: orderSummarySelection,
256
+ userErrors: { field: true, message: true }
257
+ }
258
+ });
259
+ if (result === void 0) return;
260
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.orderCreate, failOnUserErrors: ctx.failOnUserErrors });
261
+ if (ctx.quiet) return console.log(result.orderCreate?.order?.id ?? "");
262
+ (0, import_output.printJson)(result.orderCreate, ctx.format !== "raw");
263
+ return;
264
+ }
265
+ if (verb === "capture") {
266
+ const args = (0, import_router.parseStandardArgs)({
267
+ argv,
268
+ extraOptions: {
269
+ "parent-transaction-id": { type: "string" },
270
+ amount: { type: "string" },
271
+ currency: { type: "string" },
272
+ "final-capture": { type: "string" }
273
+ }
274
+ });
275
+ const id = (0, import_shared.requireId)(args.id, "Order");
276
+ const parentTransactionIdRaw = args["parent-transaction-id"];
277
+ const parentTransactionId = parentTransactionIdRaw !== void 0 ? (0, import_gid.coerceGid)(parentTransactionIdRaw, "OrderTransaction") : (() => {
278
+ throw new import_errors.CliError("Missing --parent-transaction-id", 2);
279
+ })();
280
+ const amount = args.amount !== void 0 ? (0, import_shared.parseTextArg)(args.amount, "--amount") : (() => {
281
+ throw new import_errors.CliError("Missing --amount", 2);
282
+ })();
283
+ const currency = args.currency !== void 0 ? (0, import_shared.parseTextArg)(args.currency, "--currency") : void 0;
284
+ const finalCapture = parseBoolFlag(args["final-capture"], "--final-capture");
285
+ const result = await (0, import_router.runMutation)(ctx, {
286
+ orderCapture: {
287
+ __args: {
288
+ input: {
289
+ id,
290
+ parentTransactionId,
291
+ amount,
292
+ ...currency ? { currency } : {},
293
+ ...finalCapture === void 0 ? {} : { finalCapture }
294
+ }
295
+ },
296
+ transaction: { id: true, kind: true, status: true, amount: true, createdAt: true },
297
+ userErrors: { field: true, message: true }
298
+ }
299
+ });
300
+ if (result === void 0) return;
301
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.orderCapture, failOnUserErrors: ctx.failOnUserErrors });
302
+ if (ctx.quiet) {
303
+ process.stdout.write(`${result.orderCapture?.transaction?.id ?? ""}
304
+ `);
305
+ return;
306
+ }
307
+ const orderAfter = await (0, import_router.runQuery)(ctx, {
308
+ order: { __args: { id }, id: true, displayFinancialStatus: true }
309
+ });
310
+ if (orderAfter === void 0) return;
311
+ (0, import_output.printNode)({
312
+ node: {
313
+ orderId: id,
314
+ transaction: result.orderCapture?.transaction,
315
+ ...orderAfter?.order ? { order: { id: orderAfter.order.id, displayFinancialStatus: orderAfter.order.displayFinancialStatus } } : {},
316
+ userErrors: result.orderCapture?.userErrors
317
+ },
318
+ format: ctx.format,
319
+ quiet: false
320
+ });
321
+ return;
322
+ }
323
+ if (verb === "create-manual-payment") {
324
+ const args = (0, import_router.parseStandardArgs)({
325
+ argv,
326
+ extraOptions: {
327
+ amount: { type: "string" },
328
+ currency: { type: "string" },
329
+ "payment-method-name": { type: "string" },
330
+ "processed-at": { type: "string" }
331
+ }
332
+ });
333
+ const id = (0, import_shared.requireId)(args.id, "Order");
334
+ const amountRaw = args.amount;
335
+ const currencyRaw = args.currency;
336
+ const amount = amountRaw ? (0, import_shared.parseTextArg)(amountRaw, "--amount") : void 0;
337
+ const currencyCode = currencyRaw ? (0, import_shared.parseTextArg)(currencyRaw, "--currency") : void 0;
338
+ if (amount !== void 0 && !currencyCode) {
339
+ throw new import_errors.CliError("Missing --currency (required with --amount)", 2);
340
+ }
341
+ const paymentMethodName = args["payment-method-name"];
342
+ const processedAt = args["processed-at"];
343
+ const result = await (0, import_router.runMutation)(ctx, {
344
+ orderCreateManualPayment: {
345
+ __args: {
346
+ id,
347
+ ...amount !== void 0 && currencyCode ? { amount: { amount, currencyCode } } : {},
348
+ ...paymentMethodName ? { paymentMethodName } : {},
349
+ ...processedAt ? { processedAt } : {}
350
+ },
351
+ order: orderSummarySelection,
352
+ userErrors: { field: true, message: true }
353
+ }
354
+ });
355
+ if (result === void 0) return;
356
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.orderCreateManualPayment, failOnUserErrors: ctx.failOnUserErrors });
357
+ if (ctx.quiet) return console.log(result.orderCreateManualPayment?.order?.id ?? "");
358
+ (0, import_output.printJson)(result.orderCreateManualPayment, ctx.format !== "raw");
359
+ return;
360
+ }
361
+ if (verb === "invoice-send") {
362
+ const args = (0, import_router.parseStandardArgs)({
363
+ argv,
364
+ extraOptions: {
365
+ email: { type: "string" }
366
+ }
367
+ });
368
+ const id = (0, import_shared.requireId)(args.id, "Order");
369
+ const emailRaw = args.email;
370
+ const email = emailRaw ? (0, import_shared.parseJsonArg)(emailRaw, "--email") : void 0;
371
+ if (email !== void 0 && (email === null || typeof email !== "object" || Array.isArray(email))) {
372
+ throw new import_errors.CliError("--email must be a JSON object", 2);
373
+ }
374
+ const result = await (0, import_router.runMutation)(ctx, {
375
+ orderInvoiceSend: {
376
+ __args: { id, ...email ? { email } : {} },
377
+ order: orderSummarySelection,
378
+ userErrors: { field: true, message: true, code: true }
379
+ }
380
+ });
381
+ if (result === void 0) return;
382
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.orderInvoiceSend, failOnUserErrors: ctx.failOnUserErrors });
383
+ if (ctx.quiet) return console.log(result.orderInvoiceSend?.order?.id ?? "");
384
+ (0, import_output.printJson)(result.orderInvoiceSend, ctx.format !== "raw");
385
+ return;
386
+ }
387
+ if (verb === "open") {
388
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
389
+ const id = (0, import_shared.requireId)(args.id, "Order");
390
+ const result = await (0, import_router.runMutation)(ctx, {
391
+ orderOpen: {
392
+ __args: { input: { id } },
393
+ order: orderSummarySelection,
394
+ userErrors: { field: true, message: true }
395
+ }
396
+ });
397
+ if (result === void 0) return;
398
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.orderOpen, failOnUserErrors: ctx.failOnUserErrors });
399
+ if (ctx.quiet) return console.log(result.orderOpen?.order?.id ?? "");
400
+ (0, import_output.printJson)(result.orderOpen, ctx.format !== "raw");
401
+ return;
402
+ }
403
+ if (verb === "customer-set") {
404
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { "customer-id": { type: "string" } } });
405
+ const orderId = (0, import_shared.requireId)(args.id, "Order");
406
+ const customerIdRaw = args["customer-id"];
407
+ if (!customerIdRaw) throw new import_errors.CliError("Missing --customer-id", 2);
408
+ const customerId = (0, import_gid.coerceGid)(customerIdRaw, "Customer");
409
+ const result = await (0, import_router.runMutation)(ctx, {
410
+ orderCustomerSet: {
411
+ __args: { orderId, customerId },
412
+ order: orderSummarySelection,
413
+ userErrors: { field: true, message: true }
414
+ }
415
+ });
416
+ if (result === void 0) return;
417
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.orderCustomerSet, failOnUserErrors: ctx.failOnUserErrors });
418
+ if (ctx.quiet) return console.log(result.orderCustomerSet?.order?.id ?? "");
419
+ (0, import_output.printJson)(result.orderCustomerSet, ctx.format !== "raw");
420
+ return;
421
+ }
422
+ if (verb === "customer-remove") {
423
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
424
+ const orderId = (0, import_shared.requireId)(args.id, "Order");
425
+ const result = await (0, import_router.runMutation)(ctx, {
426
+ orderCustomerRemove: {
427
+ __args: { orderId },
428
+ order: orderSummarySelection,
429
+ userErrors: { field: true, message: true }
430
+ }
431
+ });
432
+ if (result === void 0) return;
433
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.orderCustomerRemove, failOnUserErrors: ctx.failOnUserErrors });
434
+ if (ctx.quiet) return console.log(result.orderCustomerRemove?.order?.id ?? "");
435
+ (0, import_output.printJson)(result.orderCustomerRemove, ctx.format !== "raw");
436
+ return;
437
+ }
438
+ if (verb === "risk-assessment-create") {
439
+ const args = (0, import_router.parseStandardArgs)({
440
+ argv,
441
+ extraOptions: {
442
+ "risk-level": { type: "string" },
443
+ facts: { type: "string" }
444
+ }
445
+ });
446
+ const orderId = (0, import_shared.requireId)(args.id, "Order");
447
+ const riskLevel = args["risk-level"];
448
+ const factsRaw = args.facts;
449
+ const orderRiskAssessmentInput = {
450
+ orderId,
451
+ riskLevel,
452
+ facts: factsRaw ? (0, import_shared.parseJsonArg)(factsRaw, "--facts") : void 0
453
+ };
454
+ if (!orderRiskAssessmentInput.riskLevel) throw new import_errors.CliError("Missing --risk-level", 2);
455
+ if (!Array.isArray(orderRiskAssessmentInput.facts) || orderRiskAssessmentInput.facts.length === 0) {
456
+ throw new import_errors.CliError("Missing --facts", 2);
457
+ }
458
+ const result = await (0, import_router.runMutation)(ctx, {
459
+ orderRiskAssessmentCreate: {
460
+ __args: { orderRiskAssessmentInput },
461
+ orderRiskAssessment: { riskLevel: true, facts: { sentiment: true, description: true } },
462
+ userErrors: { field: true, message: true, code: true }
463
+ }
464
+ });
465
+ if (result === void 0) return;
466
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.orderRiskAssessmentCreate, failOnUserErrors: ctx.failOnUserErrors });
467
+ if (ctx.quiet) {
468
+ process.stdout.write(`${orderId}
469
+ `);
470
+ return;
471
+ }
472
+ (0, import_output.printNode)({
473
+ node: {
474
+ orderId,
475
+ orderRiskAssessment: result.orderRiskAssessmentCreate?.orderRiskAssessment,
476
+ userErrors: result.orderRiskAssessmentCreate?.userErrors
477
+ },
478
+ format: ctx.format,
479
+ quiet: false
480
+ });
481
+ return;
482
+ }
483
+ if (verb === "create-mandate-payment") {
484
+ const args = (0, import_router.parseStandardArgs)({
485
+ argv,
486
+ extraOptions: {
487
+ "mandate-id": { type: "string" },
488
+ "payment-schedule-id": { type: "string" },
489
+ "idempotency-key": { type: "string" },
490
+ amount: { type: "string" },
491
+ "auto-capture": { type: "string" }
492
+ }
493
+ });
494
+ const id = (0, import_shared.requireId)(args.id, "Order");
495
+ const mandateIdRaw = args["mandate-id"];
496
+ if (!mandateIdRaw) throw new import_errors.CliError("Missing --mandate-id", 2);
497
+ const mandateId = (0, import_gid.coerceGid)(mandateIdRaw, "PaymentMandate");
498
+ const idempotencyKey = args["idempotency-key"];
499
+ if (!idempotencyKey) throw new import_errors.CliError("Missing --idempotency-key", 2);
500
+ const paymentScheduleIdRaw = args["payment-schedule-id"];
501
+ const paymentScheduleId = paymentScheduleIdRaw ? (0, import_gid.coerceGid)(paymentScheduleIdRaw, "PaymentSchedule") : void 0;
502
+ const amount = args.amount !== void 0 ? (0, import_shared.parseJsonArg)(args.amount, "--amount") : void 0;
503
+ const autoCaptureRaw = args["auto-capture"];
504
+ const autoCapture = autoCaptureRaw === void 0 ? void 0 : (() => {
505
+ const v = autoCaptureRaw.trim().toLowerCase();
506
+ if (v === "true" || v === "1" || v === "yes") return true;
507
+ if (v === "false" || v === "0" || v === "no") return false;
508
+ throw new import_errors.CliError("--auto-capture must be true|false", 2);
509
+ })();
510
+ const result = await (0, import_router.runMutation)(ctx, {
511
+ orderCreateMandatePayment: {
512
+ __args: {
513
+ id,
514
+ ...paymentScheduleId ? { paymentScheduleId } : {},
515
+ idempotencyKey,
516
+ mandateId,
517
+ ...amount ? { amount } : {},
518
+ ...autoCapture === void 0 ? {} : { autoCapture }
519
+ },
520
+ job: { id: true, done: true },
521
+ paymentReferenceId: true,
522
+ userErrors: { field: true, message: true, code: true }
523
+ }
524
+ });
525
+ if (result === void 0) return;
526
+ (0, import_userErrors.maybeFailOnUserErrors)({
527
+ payload: result.orderCreateMandatePayment,
528
+ failOnUserErrors: ctx.failOnUserErrors
529
+ });
530
+ const paymentReferenceId = result.orderCreateMandatePayment?.paymentReferenceId;
531
+ const paymentStatus = paymentReferenceId ? await (0, import_router.runQuery)(ctx, {
532
+ orderPaymentStatus: {
533
+ __args: { orderId: id, paymentReferenceId },
534
+ paymentReferenceId: true,
535
+ status: true,
536
+ errorMessage: true,
537
+ translatedErrorMessage: true,
538
+ transactions: { id: true, kind: true, status: true, amount: true, createdAt: true }
539
+ }
540
+ }) : void 0;
541
+ if (paymentReferenceId && paymentStatus === void 0) return;
542
+ if (ctx.quiet) {
543
+ process.stdout.write(`${result.orderCreateMandatePayment?.job?.id ?? paymentReferenceId ?? ""}
544
+ `);
545
+ return;
546
+ }
547
+ (0, import_output.printNode)({
548
+ node: {
549
+ job: result.orderCreateMandatePayment?.job,
550
+ orderId: id,
551
+ paymentReferenceId,
552
+ ...paymentStatus?.orderPaymentStatus ? { paymentStatus: paymentStatus.orderPaymentStatus } : {},
553
+ userErrors: result.orderCreateMandatePayment?.userErrors
554
+ },
555
+ format: ctx.format,
556
+ quiet: false
557
+ });
558
+ return;
559
+ }
560
+ if (verb === "add-tags" || verb === "remove-tags") {
561
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
562
+ const id = (0, import_shared.requireId)(args.id, "Order");
563
+ const tags = (0, import_shared.parseCsv)(args.tags, "--tags");
564
+ const mutationField = verb === "add-tags" ? "tagsAdd" : "tagsRemove";
565
+ const request = {
566
+ [mutationField]: {
567
+ __args: { id, tags },
568
+ node: { id: true },
569
+ userErrors: { field: true, message: true }
570
+ }
571
+ };
572
+ const result = await (0, import_router.runMutation)(ctx, request);
573
+ if (result === void 0) return;
574
+ const payload = result[mutationField];
575
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload, failOnUserErrors: ctx.failOnUserErrors });
576
+ if (ctx.quiet) return console.log(payload?.node?.id ?? "");
577
+ (0, import_output.printJson)(payload, ctx.format !== "raw");
578
+ return;
579
+ }
580
+ if (verb === "cancel") {
581
+ const args = (0, import_router.parseStandardArgs)({
582
+ argv,
583
+ extraOptions: {
584
+ refund: { type: "boolean" },
585
+ restock: { type: "string" },
586
+ reason: { type: "string" },
587
+ "notify-customer": { type: "boolean" },
588
+ "staff-note": { type: "string" },
589
+ "refund-method": { type: "string" }
590
+ }
591
+ });
592
+ const orderId = (0, import_shared.requireId)(args.id, "Order");
593
+ const restockRaw = args.restock;
594
+ const restock = restockRaw === void 0 ? true : (() => {
595
+ const v = restockRaw.trim().toLowerCase();
596
+ if (v === "true" || v === "1" || v === "yes") return true;
597
+ if (v === "false" || v === "0" || v === "no") return false;
598
+ throw new import_errors.CliError("--restock must be true|false", 2);
599
+ })();
600
+ const reason = args.reason ?? "OTHER";
601
+ const refund = args.refund ?? false;
602
+ const notifyCustomer = args["notify-customer"] ?? false;
603
+ const staffNote = args["staff-note"];
604
+ const refundMethodRaw = args["refund-method"];
605
+ const refundMethod = refundMethodRaw !== void 0 ? (0, import_shared.parseJsonArg)(refundMethodRaw, "--refund-method", { allowEmpty: true }) : void 0;
606
+ const result = await (0, import_router.runMutation)(ctx, {
607
+ orderCancel: {
608
+ __args: {
609
+ orderId,
610
+ refund,
611
+ restock,
612
+ reason,
613
+ notifyCustomer,
614
+ ...staffNote ? { staffNote } : {},
615
+ ...refundMethod ? { refundMethod } : {}
616
+ },
617
+ job: { id: true, done: true },
618
+ orderCancelUserErrors: { field: true, message: true, code: true }
619
+ }
620
+ });
621
+ if (result === void 0) return;
622
+ (0, import_userErrors.maybeFailOnUserErrors)({
623
+ payload: { userErrors: result.orderCancel?.orderCancelUserErrors },
624
+ failOnUserErrors: ctx.failOnUserErrors
625
+ });
626
+ if (ctx.quiet) {
627
+ process.stdout.write(`${result.orderCancel?.job?.id ?? ""}
628
+ `);
629
+ return;
630
+ }
631
+ (0, import_output.printNode)({
632
+ node: {
633
+ job: result.orderCancel?.job,
634
+ orderId,
635
+ refund,
636
+ restock,
637
+ reason,
638
+ notifyCustomer,
639
+ ...staffNote ? { staffNote } : {},
640
+ ...refundMethod ? { refundMethod } : {},
641
+ userErrors: result.orderCancel?.orderCancelUserErrors
642
+ },
643
+ format: ctx.format,
644
+ quiet: false
645
+ });
646
+ return;
647
+ }
648
+ if (verb === "close") {
649
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
650
+ const id = (0, import_shared.requireId)(args.id, "Order");
651
+ const result = await (0, import_router.runMutation)(ctx, {
652
+ orderClose: {
653
+ __args: { input: { id } },
654
+ order: orderSummarySelection,
655
+ userErrors: { field: true, message: true }
656
+ }
657
+ });
658
+ if (result === void 0) return;
659
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.orderClose, failOnUserErrors: ctx.failOnUserErrors });
660
+ if (ctx.quiet) return console.log(result.orderClose?.order?.id ?? "");
661
+ (0, import_output.printJson)(result.orderClose, ctx.format !== "raw");
662
+ return;
663
+ }
664
+ if (verb === "mark-paid") {
665
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
666
+ const id = (0, import_shared.requireId)(args.id, "Order");
667
+ const result = await (0, import_router.runMutation)(ctx, {
668
+ orderMarkAsPaid: {
669
+ __args: { input: { id } },
670
+ order: orderSummarySelection,
671
+ userErrors: { field: true, message: true }
672
+ }
673
+ });
674
+ if (result === void 0) return;
675
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.orderMarkAsPaid, failOnUserErrors: ctx.failOnUserErrors });
676
+ if (ctx.quiet) return console.log(result.orderMarkAsPaid?.order?.id ?? "");
677
+ (0, import_output.printJson)(result.orderMarkAsPaid, ctx.format !== "raw");
678
+ return;
679
+ }
680
+ if (verb === "add-note") {
681
+ const args = (0, import_router.parseStandardArgs)({
682
+ argv,
683
+ extraOptions: {
684
+ note: { type: "string" }
685
+ }
686
+ });
687
+ const id = (0, import_shared.requireId)(args.id, "Order");
688
+ const note = (0, import_shared.parseTextArg)(args.note, "--note");
689
+ const result = await (0, import_router.runMutation)(ctx, {
690
+ orderUpdate: {
691
+ __args: { input: { id, note } },
692
+ order: orderSummarySelection,
693
+ userErrors: { field: true, message: true }
694
+ }
695
+ });
696
+ if (result === void 0) return;
697
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.orderUpdate, failOnUserErrors: ctx.failOnUserErrors });
698
+ if (ctx.quiet) return console.log(result.orderUpdate?.order?.id ?? "");
699
+ (0, import_output.printJson)(result.orderUpdate, ctx.format !== "raw");
700
+ return;
701
+ }
702
+ if (verb === "fulfill") {
703
+ const args = (0, import_router.parseStandardArgs)({
704
+ argv,
705
+ extraOptions: {
706
+ message: { type: "string" },
707
+ "fulfillment-order-id": { type: "string", multiple: true },
708
+ "tracking-company": { type: "string" },
709
+ "tracking-number": { type: "string" },
710
+ "tracking-url": { type: "string" },
711
+ "notify-customer": { type: "boolean" }
712
+ }
713
+ });
714
+ const orderId = (0, import_shared.requireId)(args.id, "Order");
715
+ const desiredFulfillmentOrderIds = args["fulfillment-order-id"] ?? [];
716
+ const trackingInfoInput = (() => {
717
+ const trackingInfo = {};
718
+ const company = args["tracking-company"];
719
+ const number = args["tracking-number"];
720
+ const url = args["tracking-url"];
721
+ if (company) trackingInfo.company = company;
722
+ if (number) trackingInfo.number = number;
723
+ if (url) trackingInfo.url = url;
724
+ return Object.keys(trackingInfo).length > 0 ? trackingInfo : void 0;
725
+ })();
726
+ const result = await (0, import_router.runQuery)(ctx, {
727
+ order: {
728
+ __args: { id: orderId },
729
+ id: true,
730
+ name: true,
731
+ fulfillmentOrders: {
732
+ __args: { first: 50, displayable: true },
733
+ nodes: {
734
+ id: true,
735
+ status: true,
736
+ assignedLocation: { location: { id: true, name: true } }
737
+ }
738
+ }
739
+ }
740
+ });
741
+ if (result === void 0) return;
742
+ const fulfillmentOrders = result.order?.fulfillmentOrders?.nodes ?? [];
743
+ if (!result.order) throw new import_errors.CliError("Order not found", 2);
744
+ if (fulfillmentOrders.length === 0) throw new import_errors.CliError("No fulfillment orders found for this order", 2);
745
+ const normalizedTargetIds = desiredFulfillmentOrderIds.length > 0 ? desiredFulfillmentOrderIds.map((id) => (0, import_shared.requireId)(id, "FulfillmentOrder")) : fulfillmentOrders.map((fo) => fo?.id).filter(Boolean);
746
+ const chosen = fulfillmentOrders.filter((fo) => normalizedTargetIds.includes(fo?.id));
747
+ if (chosen.length === 0) throw new import_errors.CliError("No matching fulfillment orders found for --fulfillment-order-id", 2);
748
+ const groups = /* @__PURE__ */ new Map();
749
+ for (const fo of chosen) {
750
+ const locationId = fo?.assignedLocation?.location?.id;
751
+ if (!locationId) throw new import_errors.CliError(`Fulfillment order ${fo?.id ?? "(missing id)"} is missing an assigned location`, 2);
752
+ const list = groups.get(locationId) ?? [];
753
+ list.push(fo.id);
754
+ groups.set(locationId, list);
755
+ }
756
+ const payloads = [];
757
+ for (const [locationId, fulfillmentOrderIds] of groups.entries()) {
758
+ const fulfillment = {
759
+ lineItemsByFulfillmentOrder: fulfillmentOrderIds.map((fulfillmentOrderId) => ({ fulfillmentOrderId })),
760
+ ...trackingInfoInput ? { trackingInfo: trackingInfoInput } : {},
761
+ ...args["notify-customer"] ? { notifyCustomer: true } : {}
762
+ };
763
+ const created = await (0, import_router.runMutation)(ctx, {
764
+ fulfillmentCreateV2: {
765
+ __args: { fulfillment, ...args.message ? { message: args.message } : {} },
766
+ fulfillment: {
767
+ id: true,
768
+ status: true,
769
+ name: true,
770
+ trackingInfo: { company: true, number: true, url: true }
771
+ },
772
+ userErrors: { field: true, message: true }
773
+ }
774
+ });
775
+ if (created === void 0) return;
776
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: created.fulfillmentCreateV2, failOnUserErrors: ctx.failOnUserErrors });
777
+ payloads.push({ locationId, assignedLocationId: locationId, ...created.fulfillmentCreateV2 });
778
+ }
779
+ if (ctx.quiet) {
780
+ for (const p of payloads) {
781
+ if (p?.fulfillment?.id) process.stdout.write(`${p.fulfillment.id}
782
+ `);
783
+ }
784
+ return;
785
+ }
786
+ (0, import_output.printJson)(payloads.length === 1 ? payloads[0] : payloads, ctx.format !== "raw");
787
+ return;
788
+ }
789
+ if (verb === "update") {
790
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
791
+ const id = (0, import_shared.requireId)(args.id, "Order");
792
+ const built = (0, import_input.buildInput)({
793
+ inputArg: args.input,
794
+ setArgs: args.set,
795
+ setJsonArgs: args["set-json"]
796
+ });
797
+ if (!built.used) throw new import_errors.CliError("Missing --input or --set/--set-json", 2);
798
+ const input = { ...built.input, id };
799
+ const result = await (0, import_router.runMutation)(ctx, {
800
+ orderUpdate: {
801
+ __args: { input },
802
+ order: orderSummarySelection,
803
+ userErrors: { field: true, message: true }
804
+ }
805
+ });
806
+ if (result === void 0) return;
807
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.orderUpdate, failOnUserErrors: ctx.failOnUserErrors });
808
+ if (ctx.quiet) return console.log(result.orderUpdate?.order?.id ?? "");
809
+ (0, import_output.printJson)(result.orderUpdate, ctx.format !== "raw");
810
+ return;
811
+ }
812
+ if (verb === "delete") {
813
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
814
+ const id = (0, import_shared.requireId)(args.id, "Order");
815
+ if (!args.yes) throw new import_errors.CliError("Refusing to delete without --yes", 2);
816
+ const result = await (0, import_router.runMutation)(ctx, {
817
+ orderDelete: {
818
+ __args: { orderId: id },
819
+ deletedId: true,
820
+ userErrors: { field: true, message: true }
821
+ }
822
+ });
823
+ if (result === void 0) return;
824
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.orderDelete, failOnUserErrors: ctx.failOnUserErrors });
825
+ if (ctx.quiet) return console.log(result.orderDelete?.deletedId ?? "");
826
+ (0, import_output.printJson)(result.orderDelete, ctx.format !== "raw");
827
+ return;
828
+ }
829
+ if (verb === "transaction-void") {
830
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { "parent-transaction-id": { type: "string" } } });
831
+ const parentTransactionIdRaw = args["parent-transaction-id"];
832
+ if (!parentTransactionIdRaw) throw new import_errors.CliError("Missing --parent-transaction-id", 2);
833
+ const parentTransactionId = (0, import_gid.coerceGid)(parentTransactionIdRaw, "OrderTransaction");
834
+ const result = await (0, import_router.runMutation)(ctx, {
835
+ transactionVoid: {
836
+ __args: { parentTransactionId },
837
+ transaction: { id: true, kind: true, status: true, createdAt: true },
838
+ userErrors: { field: true, message: true, code: true }
839
+ }
840
+ });
841
+ if (result === void 0) return;
842
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.transactionVoid, failOnUserErrors: ctx.failOnUserErrors });
843
+ if (ctx.quiet) return console.log(result.transactionVoid?.transaction?.id ?? "");
844
+ (0, import_output.printJson)(result.transactionVoid, ctx.format !== "raw");
845
+ return;
846
+ }
847
+ throw new import_errors.CliError(`Unknown verb for orders: ${verb}`, 2);
848
+ };
849
+ // Annotate the CommonJS export names for ESM import in node:
850
+ 0 && (module.exports = {
851
+ runOrders
852
+ });
853
+ //# sourceMappingURL=orders.js.map