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,656 @@
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 customers_exports = {};
20
+ __export(customers_exports, {
21
+ runCustomers: () => runCustomers
22
+ });
23
+ module.exports = __toCommonJS(customers_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 parseBool = (value, flag, { allowEmpty = false } = {}) => {
32
+ if (value === void 0 || value === null || value === "") {
33
+ if (allowEmpty) return void 0;
34
+ throw new import_errors.CliError(`Missing ${flag}`, 2);
35
+ }
36
+ if (typeof value !== "string") throw new import_errors.CliError(`${flag} must be a string`, 2);
37
+ const raw = value.trim().toLowerCase();
38
+ if (!raw) {
39
+ if (allowEmpty) return void 0;
40
+ throw new import_errors.CliError(`Missing ${flag}`, 2);
41
+ }
42
+ if (raw === "true" || raw === "1" || raw === "yes") return true;
43
+ if (raw === "false" || raw === "0" || raw === "no") return false;
44
+ throw new import_errors.CliError(`${flag} must be a boolean (true/false)`, 2);
45
+ };
46
+ const customerSummarySelection = {
47
+ id: true,
48
+ displayName: true,
49
+ email: true,
50
+ state: true,
51
+ updatedAt: true
52
+ };
53
+ const customerFullSelection = {
54
+ ...customerSummarySelection,
55
+ createdAt: true,
56
+ phone: true,
57
+ tags: true
58
+ };
59
+ const getCustomerSelection = (view) => {
60
+ if (view === "ids") return { id: true };
61
+ if (view === "full") return customerFullSelection;
62
+ if (view === "raw") return {};
63
+ return customerSummarySelection;
64
+ };
65
+ const runCustomers = async ({
66
+ ctx,
67
+ verb,
68
+ argv
69
+ }) => {
70
+ if (argv.includes("--help") || argv.includes("-h")) {
71
+ console.log(
72
+ [
73
+ "Usage:",
74
+ " shop customers <verb> [flags]",
75
+ "",
76
+ "Verbs:",
77
+ " create|get|list|count|update|delete",
78
+ " add-tags|remove-tags|merge|merge-preview|merge-job-status",
79
+ " by-identifier|set",
80
+ " address-create|address-update|address-delete|update-default-address",
81
+ " email-marketing-consent-update|sms-marketing-consent-update",
82
+ " add-tax-exemptions|remove-tax-exemptions|replace-tax-exemptions",
83
+ " generate-account-activation-url",
84
+ " request-data-erasure|cancel-data-erasure",
85
+ " send-invite",
86
+ " metafields upsert",
87
+ "",
88
+ "Common output flags:",
89
+ " --view summary|ids|full|raw",
90
+ " --select <path> (repeatable; dot paths; adds to base view selection)",
91
+ " --selection <graphql> (selection override; can be @file.gql)"
92
+ ].join("\n")
93
+ );
94
+ return;
95
+ }
96
+ if (verb === "by-identifier") {
97
+ const args = (0, import_router.parseStandardArgs)({
98
+ argv,
99
+ extraOptions: {
100
+ "email-address": { type: "string" },
101
+ "phone-number": { type: "string" },
102
+ "identifier-id": { type: "string" },
103
+ "custom-id": { type: "string" }
104
+ }
105
+ });
106
+ const emailAddress = args["email-address"];
107
+ const phoneNumber = args["phone-number"];
108
+ const identifierId = args["identifier-id"];
109
+ const customIdRaw = args["custom-id"];
110
+ const present = [
111
+ emailAddress ? "emailAddress" : void 0,
112
+ phoneNumber ? "phoneNumber" : void 0,
113
+ identifierId ? "id" : void 0,
114
+ customIdRaw ? "customId" : void 0
115
+ ].filter(Boolean);
116
+ if (present.length === 0) throw new import_errors.CliError("Missing --email-address", 2);
117
+ if (present.length > 1) {
118
+ throw new import_errors.CliError(`Pass exactly one identifier (--email-address, --phone-number, --identifier-id, --custom-id). Got: ${present.join(", ")}`, 2);
119
+ }
120
+ const identifier = {};
121
+ if (emailAddress) identifier.emailAddress = String(emailAddress);
122
+ if (phoneNumber) identifier.phoneNumber = String(phoneNumber);
123
+ if (identifierId) identifier.id = (0, import_shared.requireGidFlag)(identifierId, "--identifier-id", "Customer");
124
+ if (customIdRaw) identifier.customId = (0, import_shared.parseJsonArg)(customIdRaw, "--custom-id");
125
+ const selection = (0, import_select.resolveSelection)({
126
+ resource: "customers",
127
+ view: ctx.view,
128
+ baseSelection: getCustomerSelection(ctx.view),
129
+ select: args.select,
130
+ selection: args.selection,
131
+ include: args.include,
132
+ ensureId: ctx.quiet
133
+ });
134
+ const result = await (0, import_router.runQuery)(ctx, { customerByIdentifier: { __args: { identifier }, ...selection } });
135
+ if (result === void 0) return;
136
+ (0, import_output.printNode)({ node: result.customerByIdentifier, format: ctx.format, quiet: ctx.quiet });
137
+ return;
138
+ }
139
+ if (verb === "merge-preview") {
140
+ const args = (0, import_router.parseStandardArgs)({
141
+ argv,
142
+ extraOptions: {
143
+ "other-id": { type: "string" },
144
+ "override-fields": { type: "string" }
145
+ }
146
+ });
147
+ const customerOneId = (0, import_shared.requireId)(args.id, "Customer");
148
+ const other = args["other-id"];
149
+ if (!other) throw new import_errors.CliError("Missing --other-id", 2);
150
+ const customerTwoId = (0, import_shared.requireId)(other, "Customer");
151
+ const overrideFieldsRaw = args["override-fields"];
152
+ const overrideFields = overrideFieldsRaw !== void 0 ? (0, import_shared.parseJsonArg)(overrideFieldsRaw, "--override-fields", { allowEmpty: true }) : void 0;
153
+ const result = await (0, import_router.runQuery)(ctx, {
154
+ customerMergePreview: {
155
+ __args: {
156
+ customerOneId,
157
+ customerTwoId,
158
+ ...overrideFields ? { overrideFields } : {}
159
+ },
160
+ resultingCustomerId: true,
161
+ customerMergeErrors: { message: true, errorFields: true },
162
+ blockingFields: { __typename: true },
163
+ defaultFields: { __typename: true },
164
+ alternateFields: { __typename: true }
165
+ }
166
+ });
167
+ if (result === void 0) return;
168
+ if (ctx.quiet) return console.log(result.customerMergePreview?.resultingCustomerId ?? "");
169
+ (0, import_output.printJson)(result.customerMergePreview, ctx.format !== "raw");
170
+ return;
171
+ }
172
+ if (verb === "merge-job-status") {
173
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { "job-id": { type: "string" } } });
174
+ const jobId = (0, import_shared.requireStringFlag)(args["job-id"], "--job-id");
175
+ const result = await (0, import_router.runQuery)(ctx, {
176
+ customerMergeJobStatus: {
177
+ __args: { jobId },
178
+ jobId: true,
179
+ status: true,
180
+ resultingCustomerId: true,
181
+ customerMergeErrors: { message: true, errorFields: true }
182
+ }
183
+ });
184
+ if (result === void 0) return;
185
+ if (ctx.quiet) return console.log(result.customerMergeJobStatus?.jobId ?? "");
186
+ (0, import_output.printJson)(result.customerMergeJobStatus, ctx.format !== "raw");
187
+ return;
188
+ }
189
+ if (verb === "set") {
190
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { identifier: { type: "string" } } });
191
+ const built = (0, import_input.buildInput)({
192
+ inputArg: args.input,
193
+ setArgs: args.set,
194
+ setJsonArgs: args["set-json"]
195
+ });
196
+ if (!built.used) throw new import_errors.CliError("Missing --input or --set/--set-json", 2);
197
+ const identifierRaw = args.identifier;
198
+ const identifier = identifierRaw ? (0, import_shared.parseJsonArg)(identifierRaw, "--identifier", { allowEmpty: true }) : void 0;
199
+ const result = await (0, import_router.runMutation)(ctx, {
200
+ customerSet: {
201
+ __args: { input: built.input, ...identifier ? { identifier } : {} },
202
+ customer: customerSummarySelection,
203
+ userErrors: { code: true, field: true, message: true }
204
+ }
205
+ });
206
+ if (result === void 0) return;
207
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.customerSet, failOnUserErrors: ctx.failOnUserErrors });
208
+ if (ctx.quiet) return console.log(result.customerSet?.customer?.id ?? "");
209
+ (0, import_output.printJson)(result.customerSet, ctx.format !== "raw");
210
+ return;
211
+ }
212
+ if (verb === "address-create") {
213
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { address: { type: "string" }, "set-as-default": { type: "string" } } });
214
+ const customerId = (0, import_shared.requireId)(args.id, "Customer");
215
+ const address = (0, import_shared.parseJsonArg)(args.address, "--address");
216
+ const setAsDefault = parseBool(args["set-as-default"], "--set-as-default", { allowEmpty: true });
217
+ const result = await (0, import_router.runMutation)(ctx, {
218
+ customerAddressCreate: {
219
+ __args: { customerId, address, ...setAsDefault !== void 0 ? { setAsDefault } : {} },
220
+ address: { id: true, address1: true, city: true, provinceCode: true, countryCode: true, zip: true },
221
+ userErrors: { field: true, message: true }
222
+ }
223
+ });
224
+ if (result === void 0) return;
225
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.customerAddressCreate, failOnUserErrors: ctx.failOnUserErrors });
226
+ if (ctx.quiet) return console.log(result.customerAddressCreate?.address?.id ?? "");
227
+ (0, import_output.printJson)(result.customerAddressCreate, ctx.format !== "raw");
228
+ return;
229
+ }
230
+ if (verb === "address-update") {
231
+ const args = (0, import_router.parseStandardArgs)({
232
+ argv,
233
+ extraOptions: { "address-id": { type: "string" }, address: { type: "string" }, "set-as-default": { type: "string" } }
234
+ });
235
+ const customerId = (0, import_shared.requireId)(args.id, "Customer");
236
+ const addressId = (0, import_shared.requireGidFlag)(args["address-id"], "--address-id", "MailingAddress");
237
+ const address = (0, import_shared.parseJsonArg)(args.address, "--address");
238
+ const setAsDefault = parseBool(args["set-as-default"], "--set-as-default", { allowEmpty: true });
239
+ const result = await (0, import_router.runMutation)(ctx, {
240
+ customerAddressUpdate: {
241
+ __args: { customerId, addressId, address, ...setAsDefault !== void 0 ? { setAsDefault } : {} },
242
+ address: { id: true, address1: true, city: true, provinceCode: true, countryCode: true, zip: true },
243
+ userErrors: { field: true, message: true }
244
+ }
245
+ });
246
+ if (result === void 0) return;
247
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.customerAddressUpdate, failOnUserErrors: ctx.failOnUserErrors });
248
+ if (ctx.quiet) return console.log(result.customerAddressUpdate?.address?.id ?? "");
249
+ (0, import_output.printJson)(result.customerAddressUpdate, ctx.format !== "raw");
250
+ return;
251
+ }
252
+ if (verb === "address-delete") {
253
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { "address-id": { type: "string" } } });
254
+ const customerId = (0, import_shared.requireId)(args.id, "Customer");
255
+ const addressId = (0, import_shared.requireGidFlag)(args["address-id"], "--address-id", "MailingAddress");
256
+ const result = await (0, import_router.runMutation)(ctx, {
257
+ customerAddressDelete: {
258
+ __args: { customerId, addressId },
259
+ deletedAddressId: true,
260
+ userErrors: { field: true, message: true }
261
+ }
262
+ });
263
+ if (result === void 0) return;
264
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.customerAddressDelete, failOnUserErrors: ctx.failOnUserErrors });
265
+ if (ctx.quiet) return console.log(result.customerAddressDelete?.deletedAddressId ?? "");
266
+ (0, import_output.printJson)(result.customerAddressDelete, ctx.format !== "raw");
267
+ return;
268
+ }
269
+ if (verb === "update-default-address") {
270
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { "address-id": { type: "string" } } });
271
+ const customerId = (0, import_shared.requireId)(args.id, "Customer");
272
+ const addressId = (0, import_shared.requireGidFlag)(args["address-id"], "--address-id", "MailingAddress");
273
+ const result = await (0, import_router.runMutation)(ctx, {
274
+ customerUpdateDefaultAddress: {
275
+ __args: { customerId, addressId },
276
+ customer: customerSummarySelection,
277
+ userErrors: { field: true, message: true }
278
+ }
279
+ });
280
+ if (result === void 0) return;
281
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.customerUpdateDefaultAddress, failOnUserErrors: ctx.failOnUserErrors });
282
+ if (ctx.quiet) return console.log(result.customerUpdateDefaultAddress?.customer?.id ?? "");
283
+ (0, import_output.printJson)(result.customerUpdateDefaultAddress, ctx.format !== "raw");
284
+ return;
285
+ }
286
+ if (verb === "email-marketing-consent-update") {
287
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { "email-marketing-consent": { type: "string" } } });
288
+ const customerId = (0, import_shared.requireId)(args.id, "Customer");
289
+ const emailMarketingConsent = (0, import_shared.parseJsonArg)(args["email-marketing-consent"], "--email-marketing-consent");
290
+ const result = await (0, import_router.runMutation)(ctx, {
291
+ customerEmailMarketingConsentUpdate: {
292
+ __args: { input: { customerId, emailMarketingConsent } },
293
+ customer: customerSummarySelection,
294
+ userErrors: { field: true, message: true, code: true }
295
+ }
296
+ });
297
+ if (result === void 0) return;
298
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.customerEmailMarketingConsentUpdate, failOnUserErrors: ctx.failOnUserErrors });
299
+ if (ctx.quiet) return console.log(result.customerEmailMarketingConsentUpdate?.customer?.id ?? "");
300
+ (0, import_output.printJson)(result.customerEmailMarketingConsentUpdate, ctx.format !== "raw");
301
+ return;
302
+ }
303
+ if (verb === "sms-marketing-consent-update") {
304
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { "sms-marketing-consent": { type: "string" } } });
305
+ const customerId = (0, import_shared.requireId)(args.id, "Customer");
306
+ const smsMarketingConsent = (0, import_shared.parseJsonArg)(args["sms-marketing-consent"], "--sms-marketing-consent");
307
+ const result = await (0, import_router.runMutation)(ctx, {
308
+ customerSmsMarketingConsentUpdate: {
309
+ __args: { input: { customerId, smsMarketingConsent } },
310
+ customer: customerSummarySelection,
311
+ userErrors: { field: true, message: true, code: true }
312
+ }
313
+ });
314
+ if (result === void 0) return;
315
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.customerSmsMarketingConsentUpdate, failOnUserErrors: ctx.failOnUserErrors });
316
+ if (ctx.quiet) return console.log(result.customerSmsMarketingConsentUpdate?.customer?.id ?? "");
317
+ (0, import_output.printJson)(result.customerSmsMarketingConsentUpdate, ctx.format !== "raw");
318
+ return;
319
+ }
320
+ if (verb === "add-tax-exemptions" || verb === "remove-tax-exemptions" || verb === "replace-tax-exemptions") {
321
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { exemptions: { type: "string" } } });
322
+ const customerId = (0, import_shared.requireId)(args.id, "Customer");
323
+ const taxExemptions = (0, import_shared.parseCsv)(args.exemptions, "--exemptions");
324
+ const op = verb === "add-tax-exemptions" ? "customerAddTaxExemptions" : verb === "remove-tax-exemptions" ? "customerRemoveTaxExemptions" : "customerReplaceTaxExemptions";
325
+ const request = {
326
+ [op]: {
327
+ __args: { customerId, taxExemptions },
328
+ customer: customerSummarySelection,
329
+ userErrors: { field: true, message: true }
330
+ }
331
+ };
332
+ const result = await (0, import_router.runMutation)(ctx, request);
333
+ if (result === void 0) return;
334
+ const payload = result[op];
335
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload, failOnUserErrors: ctx.failOnUserErrors });
336
+ if (ctx.quiet) return console.log(payload?.customer?.id ?? "");
337
+ (0, import_output.printJson)(payload, ctx.format !== "raw");
338
+ return;
339
+ }
340
+ if (verb === "generate-account-activation-url") {
341
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
342
+ const customerId = (0, import_shared.requireId)(args.id, "Customer");
343
+ const result = await (0, import_router.runMutation)(ctx, {
344
+ customerGenerateAccountActivationUrl: {
345
+ __args: { customerId },
346
+ accountActivationUrl: true,
347
+ userErrors: { field: true, message: true }
348
+ }
349
+ });
350
+ if (result === void 0) return;
351
+ (0, import_userErrors.maybeFailOnUserErrors)({
352
+ payload: result.customerGenerateAccountActivationUrl,
353
+ failOnUserErrors: ctx.failOnUserErrors
354
+ });
355
+ const url = result.customerGenerateAccountActivationUrl?.accountActivationUrl ?? "";
356
+ if (ctx.quiet) return console.log(url);
357
+ (0, import_output.printJson)(result.customerGenerateAccountActivationUrl, ctx.format !== "raw");
358
+ return;
359
+ }
360
+ if (verb === "request-data-erasure" || verb === "cancel-data-erasure") {
361
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
362
+ const customerId = (0, import_shared.requireId)(args.id, "Customer");
363
+ const op = verb === "request-data-erasure" ? "customerRequestDataErasure" : "customerCancelDataErasure";
364
+ const request = {
365
+ [op]: {
366
+ __args: { customerId },
367
+ customerId: true,
368
+ userErrors: { field: true, message: true, code: true }
369
+ }
370
+ };
371
+ const result = await (0, import_router.runMutation)(ctx, request);
372
+ if (result === void 0) return;
373
+ const payload = result[op];
374
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload, failOnUserErrors: ctx.failOnUserErrors });
375
+ if (ctx.quiet) return console.log(payload?.customerId ?? "");
376
+ (0, import_output.printJson)(payload, ctx.format !== "raw");
377
+ return;
378
+ }
379
+ if (verb === "count") {
380
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { limit: { type: "string" } } });
381
+ const query = args.query;
382
+ const limitRaw = args.limit;
383
+ const limit = limitRaw === void 0 || limitRaw === null || limitRaw === "" ? void 0 : Number(limitRaw);
384
+ if (limit !== void 0 && (!Number.isFinite(limit) || limit <= 0)) {
385
+ throw new import_errors.CliError("--limit must be a positive number", 2);
386
+ }
387
+ const result = await (0, import_router.runQuery)(ctx, {
388
+ customersCount: {
389
+ __args: {
390
+ ...query ? { query } : {},
391
+ ...limit !== void 0 ? { limit: Math.floor(limit) } : {}
392
+ },
393
+ count: true,
394
+ precision: true
395
+ }
396
+ });
397
+ if (result === void 0) return;
398
+ if (ctx.quiet) return console.log(result.customersCount?.count ?? "");
399
+ (0, import_output.printJson)(result.customersCount, ctx.format !== "raw");
400
+ return;
401
+ }
402
+ if (verb === "metafields upsert") {
403
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
404
+ const built = (0, import_input.buildInput)({
405
+ inputArg: args.input,
406
+ setArgs: args.set,
407
+ setJsonArgs: args["set-json"]
408
+ });
409
+ if (!built.used) throw new import_errors.CliError("Missing --input or --set/--set-json", 2);
410
+ const ownerId = (0, import_shared.requireId)(args.id, "Customer");
411
+ const asArray = (value) => {
412
+ if (Array.isArray(value)) return value;
413
+ if (value && Array.isArray(value.metafields)) return value.metafields;
414
+ if (value && typeof value === "object") return [value];
415
+ return [];
416
+ };
417
+ const items = asArray(built.input);
418
+ if (items.length === 0) throw new import_errors.CliError("Missing metafield input: pass --input/--set/--set-json", 2);
419
+ const normalized = items.map((m) => {
420
+ if (!m || typeof m !== "object") throw new import_errors.CliError("Metafield inputs must be objects", 2);
421
+ const { key, namespace, type, value, compareDigest } = m;
422
+ if (!key) throw new import_errors.CliError("Metafield input missing key", 2);
423
+ if (value === void 0) throw new import_errors.CliError("Metafield input missing value", 2);
424
+ return {
425
+ ownerId,
426
+ key,
427
+ namespace,
428
+ type,
429
+ value: String(value),
430
+ compareDigest
431
+ };
432
+ });
433
+ const chunk = (arr, size) => {
434
+ const out = [];
435
+ for (let i = 0; i < arr.length; i += size) out.push(arr.slice(i, i + size));
436
+ return out;
437
+ };
438
+ const payloads = [];
439
+ const ids = [];
440
+ for (const group of chunk(normalized, 25)) {
441
+ const result = await (0, import_router.runMutation)(ctx, {
442
+ metafieldsSet: {
443
+ __args: { metafields: group },
444
+ metafields: { id: true },
445
+ userErrors: { field: true, message: true, elementIndex: true, code: true }
446
+ }
447
+ });
448
+ if (result === void 0) return;
449
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.metafieldsSet, failOnUserErrors: ctx.failOnUserErrors });
450
+ payloads.push(result.metafieldsSet);
451
+ for (const mf of result.metafieldsSet?.metafields ?? []) ids.push(mf?.id);
452
+ }
453
+ if (ctx.quiet) {
454
+ (0, import_output.printIds)(ids);
455
+ return;
456
+ }
457
+ (0, import_output.printJson)(payloads.length === 1 ? payloads[0] : payloads, ctx.format !== "raw");
458
+ return;
459
+ }
460
+ if (verb === "get") {
461
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
462
+ const id = (0, import_shared.requireId)(args.id, "Customer");
463
+ const selection = (0, import_select.resolveSelection)({
464
+ resource: "customers",
465
+ view: ctx.view,
466
+ baseSelection: getCustomerSelection(ctx.view),
467
+ select: args.select,
468
+ selection: args.selection,
469
+ include: args.include,
470
+ ensureId: ctx.quiet
471
+ });
472
+ const result = await (0, import_router.runQuery)(ctx, { customer: { __args: { id }, ...selection } });
473
+ if (result === void 0) return;
474
+ (0, import_output.printNode)({ node: result.customer, format: ctx.format, quiet: ctx.quiet });
475
+ return;
476
+ }
477
+ if (verb === "list") {
478
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
479
+ const first = (0, import_shared.parseFirst)(args.first);
480
+ const after = args.after;
481
+ const query = args.query;
482
+ const reverse = args.reverse;
483
+ const sortKey = args.sort;
484
+ const nodeSelection = (0, import_select.resolveSelection)({
485
+ resource: "customers",
486
+ view: ctx.view,
487
+ baseSelection: getCustomerSelection(ctx.view),
488
+ select: args.select,
489
+ selection: args.selection,
490
+ include: args.include,
491
+ ensureId: ctx.quiet
492
+ });
493
+ const result = await (0, import_router.runQuery)(ctx, {
494
+ customers: {
495
+ __args: { first, after, query, reverse, sortKey },
496
+ pageInfo: { hasNextPage: true, endCursor: true },
497
+ nodes: nodeSelection
498
+ }
499
+ });
500
+ if (result === void 0) return;
501
+ (0, import_output.printConnection)({
502
+ connection: result.customers,
503
+ format: ctx.format,
504
+ quiet: ctx.quiet,
505
+ nextPageArgs: (0, import_shared.buildListNextPageArgs)("customers", { first, query, sort: sortKey, reverse })
506
+ });
507
+ return;
508
+ }
509
+ if (verb === "create") {
510
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
511
+ const built = (0, import_input.buildInput)({
512
+ inputArg: args.input,
513
+ setArgs: args.set,
514
+ setJsonArgs: args["set-json"]
515
+ });
516
+ if (!built.used) throw new import_errors.CliError("Missing --input or --set/--set-json", 2);
517
+ const result = await (0, import_router.runMutation)(ctx, {
518
+ customerCreate: {
519
+ __args: { input: built.input },
520
+ customer: customerSummarySelection,
521
+ userErrors: { field: true, message: true }
522
+ }
523
+ });
524
+ if (result === void 0) return;
525
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.customerCreate, failOnUserErrors: ctx.failOnUserErrors });
526
+ if (ctx.quiet) return console.log(result.customerCreate?.customer?.id ?? "");
527
+ (0, import_output.printJson)(result.customerCreate, ctx.format !== "raw");
528
+ return;
529
+ }
530
+ if (verb === "add-tags" || verb === "remove-tags") {
531
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
532
+ const id = (0, import_shared.requireId)(args.id, "Customer");
533
+ const tags = (0, import_shared.parseCsv)(args.tags, "--tags");
534
+ const mutationField = verb === "add-tags" ? "tagsAdd" : "tagsRemove";
535
+ const request = {
536
+ [mutationField]: {
537
+ __args: { id, tags },
538
+ node: { id: true },
539
+ userErrors: { field: true, message: true }
540
+ }
541
+ };
542
+ const result = await (0, import_router.runMutation)(ctx, request);
543
+ if (result === void 0) return;
544
+ const payload = result[mutationField];
545
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload, failOnUserErrors: ctx.failOnUserErrors });
546
+ if (ctx.quiet) return console.log(payload?.node?.id ?? "");
547
+ (0, import_output.printJson)(payload, ctx.format !== "raw");
548
+ return;
549
+ }
550
+ if (verb === "merge") {
551
+ const args = (0, import_router.parseStandardArgs)({
552
+ argv,
553
+ extraOptions: {
554
+ "other-id": { type: "string" },
555
+ "override-fields": { type: "string" }
556
+ }
557
+ });
558
+ const customerOneId = (0, import_shared.requireId)(args.id, "Customer");
559
+ const other = args["other-id"];
560
+ if (!other) throw new import_errors.CliError("Missing --other-id", 2);
561
+ const customerTwoId = (0, import_shared.requireId)(other, "Customer");
562
+ const overrideFieldsRaw = args["override-fields"];
563
+ const overrideFields = overrideFieldsRaw !== void 0 ? (0, import_shared.parseJsonArg)(overrideFieldsRaw, "--override-fields", { allowEmpty: true }) : void 0;
564
+ const result = await (0, import_router.runMutation)(ctx, {
565
+ customerMerge: {
566
+ __args: {
567
+ customerOneId,
568
+ customerTwoId,
569
+ ...overrideFields ? { overrideFields } : {}
570
+ },
571
+ job: { id: true, done: true },
572
+ userErrors: { field: true, message: true }
573
+ }
574
+ });
575
+ if (result === void 0) return;
576
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.customerMerge, failOnUserErrors: ctx.failOnUserErrors });
577
+ if (ctx.quiet) return console.log(result.customerMerge?.job?.id ?? "");
578
+ (0, import_output.printJson)(result.customerMerge, ctx.format !== "raw");
579
+ return;
580
+ }
581
+ if (verb === "send-invite") {
582
+ const args = (0, import_router.parseStandardArgs)({
583
+ argv,
584
+ extraOptions: {
585
+ email: { type: "string" }
586
+ }
587
+ });
588
+ const customerId = (0, import_shared.requireId)(args.id, "Customer");
589
+ const emailRaw = args.email;
590
+ const email = emailRaw !== void 0 ? (0, import_shared.parseJsonArg)(emailRaw, "--email", { allowEmpty: true }) : void 0;
591
+ const result = await (0, import_router.runMutation)(ctx, {
592
+ customerSendAccountInviteEmail: {
593
+ __args: {
594
+ customerId,
595
+ ...email ? { email } : {}
596
+ },
597
+ customer: { id: true },
598
+ userErrors: { field: true, message: true, code: true }
599
+ }
600
+ });
601
+ if (result === void 0) return;
602
+ (0, import_userErrors.maybeFailOnUserErrors)({
603
+ payload: result.customerSendAccountInviteEmail,
604
+ failOnUserErrors: ctx.failOnUserErrors
605
+ });
606
+ if (ctx.quiet) return console.log(result.customerSendAccountInviteEmail?.customer?.id ?? "");
607
+ (0, import_output.printJson)(result.customerSendAccountInviteEmail, ctx.format !== "raw");
608
+ return;
609
+ }
610
+ if (verb === "update") {
611
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
612
+ const id = (0, import_shared.requireId)(args.id, "Customer");
613
+ const built = (0, import_input.buildInput)({
614
+ inputArg: args.input,
615
+ setArgs: args.set,
616
+ setJsonArgs: args["set-json"]
617
+ });
618
+ if (!built.used) throw new import_errors.CliError("Missing --input or --set/--set-json", 2);
619
+ const input = { ...built.input, id };
620
+ const result = await (0, import_router.runMutation)(ctx, {
621
+ customerUpdate: {
622
+ __args: { input },
623
+ customer: customerSummarySelection,
624
+ userErrors: { field: true, message: true }
625
+ }
626
+ });
627
+ if (result === void 0) return;
628
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.customerUpdate, failOnUserErrors: ctx.failOnUserErrors });
629
+ if (ctx.quiet) return console.log(result.customerUpdate?.customer?.id ?? "");
630
+ (0, import_output.printJson)(result.customerUpdate, ctx.format !== "raw");
631
+ return;
632
+ }
633
+ if (verb === "delete") {
634
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
635
+ const id = (0, import_shared.requireId)(args.id, "Customer");
636
+ if (!args.yes) throw new import_errors.CliError("Refusing to delete without --yes", 2);
637
+ const result = await (0, import_router.runMutation)(ctx, {
638
+ customerDelete: {
639
+ __args: { input: { id } },
640
+ deletedCustomerId: true,
641
+ userErrors: { field: true, message: true }
642
+ }
643
+ });
644
+ if (result === void 0) return;
645
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.customerDelete, failOnUserErrors: ctx.failOnUserErrors });
646
+ if (ctx.quiet) return console.log(result.customerDelete?.deletedCustomerId ?? "");
647
+ (0, import_output.printJson)(result.customerDelete, ctx.format !== "raw");
648
+ return;
649
+ }
650
+ throw new import_errors.CliError(`Unknown verb for customers: ${verb}`, 2);
651
+ };
652
+ // Annotate the CommonJS export names for ESM import in node:
653
+ 0 && (module.exports = {
654
+ runCustomers
655
+ });
656
+ //# sourceMappingURL=customers.js.map
@@ -0,0 +1,6 @@
1
+ import { type CommandContext } from '../router';
2
+ export declare const runDelegateTokens: ({ ctx, verb, argv, }: {
3
+ ctx: CommandContext;
4
+ verb: string;
5
+ argv: string[];
6
+ }) => Promise<void>;