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,793 @@
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 mailingAddressSummarySelection = {
66
+ id: true,
67
+ address1: true,
68
+ address2: true,
69
+ city: true,
70
+ provinceCode: true,
71
+ countryCode: true,
72
+ zip: true
73
+ };
74
+ const mailingAddressFullSelection = {
75
+ ...mailingAddressSummarySelection,
76
+ company: true,
77
+ firstName: true,
78
+ lastName: true,
79
+ name: true,
80
+ phone: true,
81
+ province: true,
82
+ country: true
83
+ };
84
+ const getMailingAddressSelection = (view) => {
85
+ if (view === "ids") return { id: true };
86
+ if (view === "full") return mailingAddressFullSelection;
87
+ if (view === "raw") return {};
88
+ return mailingAddressSummarySelection;
89
+ };
90
+ const customerTaxExemptionsSummarySelection = {
91
+ id: true,
92
+ taxExempt: true,
93
+ taxExemptions: true
94
+ };
95
+ const getCustomerSelectionForTaxExemptions = (view) => {
96
+ if (view === "ids") return { id: true };
97
+ if (view === "full") return { ...customerFullSelection, taxExempt: true, taxExemptions: true };
98
+ if (view === "raw") return {};
99
+ return customerTaxExemptionsSummarySelection;
100
+ };
101
+ const runCustomers = async ({
102
+ ctx,
103
+ verb,
104
+ argv
105
+ }) => {
106
+ if (argv.includes("--help") || argv.includes("-h")) {
107
+ console.log(
108
+ [
109
+ "Usage:",
110
+ " shop customers <verb> [flags]",
111
+ "",
112
+ "Verbs:",
113
+ " create|get|list|count|update|delete",
114
+ " add-tags|remove-tags|merge|merge-preview|merge-job-status",
115
+ " by-identifier|set",
116
+ " address-create|address-update|address-delete|update-default-address",
117
+ " email-marketing-consent-update|sms-marketing-consent-update",
118
+ " add-tax-exemptions|remove-tax-exemptions|replace-tax-exemptions",
119
+ " generate-account-activation-url",
120
+ " request-data-erasure|cancel-data-erasure",
121
+ " send-invite",
122
+ " metafields upsert",
123
+ "",
124
+ "Common output flags:",
125
+ " --view summary|ids|full|raw",
126
+ " --select <path> (repeatable; dot paths; adds to base view selection)",
127
+ " --selection <graphql> (selection override; can be @file.gql)"
128
+ ].join("\n")
129
+ );
130
+ return;
131
+ }
132
+ if (verb === "by-identifier") {
133
+ const args = (0, import_router.parseStandardArgs)({
134
+ argv,
135
+ extraOptions: {
136
+ "email-address": { type: "string" },
137
+ "phone-number": { type: "string" },
138
+ "identifier-id": { type: "string" },
139
+ "custom-id": { type: "string" }
140
+ }
141
+ });
142
+ const emailAddress = args["email-address"];
143
+ const phoneNumber = args["phone-number"];
144
+ const identifierId = args["identifier-id"];
145
+ const customIdRaw = args["custom-id"];
146
+ const present = [
147
+ emailAddress ? "emailAddress" : void 0,
148
+ phoneNumber ? "phoneNumber" : void 0,
149
+ identifierId ? "id" : void 0,
150
+ customIdRaw ? "customId" : void 0
151
+ ].filter(Boolean);
152
+ if (present.length === 0) throw new import_errors.CliError("Missing --email-address", 2);
153
+ if (present.length > 1) {
154
+ throw new import_errors.CliError(`Pass exactly one identifier (--email-address, --phone-number, --identifier-id, --custom-id). Got: ${present.join(", ")}`, 2);
155
+ }
156
+ const identifier = {};
157
+ if (emailAddress) identifier.emailAddress = String(emailAddress);
158
+ if (phoneNumber) identifier.phoneNumber = String(phoneNumber);
159
+ if (identifierId) identifier.id = (0, import_shared.requireGidFlag)(identifierId, "--identifier-id", "Customer");
160
+ if (customIdRaw) identifier.customId = (0, import_shared.parseJsonArg)(customIdRaw, "--custom-id");
161
+ const selection = (0, import_select.resolveSelection)({
162
+ resource: "customers",
163
+ view: ctx.view,
164
+ baseSelection: getCustomerSelection(ctx.view),
165
+ select: args.select,
166
+ selection: args.selection,
167
+ include: args.include,
168
+ ensureId: ctx.quiet
169
+ });
170
+ const result = await (0, import_router.runQuery)(ctx, { customerByIdentifier: { __args: { identifier }, ...selection } });
171
+ if (result === void 0) return;
172
+ (0, import_output.printNode)({ node: result.customerByIdentifier, format: ctx.format, quiet: ctx.quiet });
173
+ return;
174
+ }
175
+ if (verb === "merge-preview") {
176
+ const args = (0, import_router.parseStandardArgs)({
177
+ argv,
178
+ extraOptions: {
179
+ "other-id": { type: "string" },
180
+ "override-fields": { type: "string" }
181
+ }
182
+ });
183
+ const customerOneId = (0, import_shared.requireId)(args.id, "Customer");
184
+ const other = args["other-id"];
185
+ if (!other) throw new import_errors.CliError("Missing --other-id", 2);
186
+ const customerTwoId = (0, import_shared.requireId)(other, "Customer");
187
+ const overrideFieldsRaw = args["override-fields"];
188
+ const overrideFields = overrideFieldsRaw !== void 0 ? (0, import_shared.parseJsonArg)(overrideFieldsRaw, "--override-fields", { allowEmpty: true }) : void 0;
189
+ const result = await (0, import_router.runQuery)(ctx, {
190
+ customerMergePreview: {
191
+ __args: {
192
+ customerOneId,
193
+ customerTwoId,
194
+ ...overrideFields ? { overrideFields } : {}
195
+ },
196
+ resultingCustomerId: true,
197
+ customerMergeErrors: { message: true, errorFields: true },
198
+ blockingFields: { __typename: true },
199
+ defaultFields: { __typename: true },
200
+ alternateFields: { __typename: true }
201
+ }
202
+ });
203
+ if (result === void 0) return;
204
+ if (ctx.quiet) return console.log(result.customerMergePreview?.resultingCustomerId ?? "");
205
+ (0, import_output.printJson)(result.customerMergePreview, ctx.format !== "raw");
206
+ return;
207
+ }
208
+ if (verb === "merge-job-status") {
209
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { "job-id": { type: "string" } } });
210
+ const jobId = (0, import_shared.requireStringFlag)(args["job-id"], "--job-id");
211
+ const result = await (0, import_router.runQuery)(ctx, {
212
+ customerMergeJobStatus: {
213
+ __args: { jobId },
214
+ jobId: true,
215
+ status: true,
216
+ resultingCustomerId: true,
217
+ customerMergeErrors: { message: true, errorFields: true }
218
+ }
219
+ });
220
+ if (result === void 0) return;
221
+ if (ctx.quiet) return console.log(result.customerMergeJobStatus?.jobId ?? "");
222
+ (0, import_output.printJson)(result.customerMergeJobStatus, ctx.format !== "raw");
223
+ return;
224
+ }
225
+ if (verb === "set") {
226
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { identifier: { type: "string" } } });
227
+ const built = (0, import_input.buildInput)({
228
+ inputArg: args.input,
229
+ setArgs: args.set,
230
+ setJsonArgs: args["set-json"]
231
+ });
232
+ if (!built.used) throw new import_errors.CliError("Missing --input or --set/--set-json", 2);
233
+ const identifierRaw = args.identifier;
234
+ const identifier = identifierRaw ? (0, import_shared.parseJsonArg)(identifierRaw, "--identifier", { allowEmpty: true }) : void 0;
235
+ const result = await (0, import_router.runMutation)(ctx, {
236
+ customerSet: {
237
+ __args: { input: built.input, ...identifier ? { identifier } : {} },
238
+ customer: customerSummarySelection,
239
+ userErrors: { code: true, field: true, message: true }
240
+ }
241
+ });
242
+ if (result === void 0) return;
243
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.customerSet, failOnUserErrors: ctx.failOnUserErrors });
244
+ if (ctx.quiet) return console.log(result.customerSet?.customer?.id ?? "");
245
+ (0, import_output.printJson)(result.customerSet, ctx.format !== "raw");
246
+ return;
247
+ }
248
+ if (verb === "address-create") {
249
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { address: { type: "string" }, "set-as-default": { type: "string" } } });
250
+ const customerId = (0, import_shared.requireId)(args.id, "Customer");
251
+ const address = (0, import_shared.parseJsonArg)(args.address, "--address");
252
+ const setAsDefault = parseBool(args["set-as-default"], "--set-as-default", { allowEmpty: true });
253
+ const result = await (0, import_router.runMutation)(ctx, {
254
+ customerAddressCreate: {
255
+ __args: { customerId, address, ...setAsDefault !== void 0 ? { setAsDefault } : {} },
256
+ address: { id: true, address1: true, city: true, provinceCode: true, countryCode: true, zip: true },
257
+ userErrors: { field: true, message: true }
258
+ }
259
+ });
260
+ if (result === void 0) return;
261
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.customerAddressCreate, failOnUserErrors: ctx.failOnUserErrors });
262
+ if (ctx.quiet) return console.log(result.customerAddressCreate?.address?.id ?? "");
263
+ (0, import_output.printJson)(result.customerAddressCreate, ctx.format !== "raw");
264
+ return;
265
+ }
266
+ if (verb === "address-update") {
267
+ const args = (0, import_router.parseStandardArgs)({
268
+ argv,
269
+ extraOptions: { "address-id": { type: "string" }, address: { type: "string" }, "set-as-default": { type: "string" } }
270
+ });
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 address = (0, import_shared.parseJsonArg)(args.address, "--address");
274
+ const setAsDefault = parseBool(args["set-as-default"], "--set-as-default", { allowEmpty: true });
275
+ const result = await (0, import_router.runMutation)(ctx, {
276
+ customerAddressUpdate: {
277
+ __args: { customerId, addressId, address, ...setAsDefault !== void 0 ? { setAsDefault } : {} },
278
+ address: { id: true, address1: true, city: true, provinceCode: true, countryCode: true, zip: true },
279
+ userErrors: { field: true, message: true }
280
+ }
281
+ });
282
+ if (result === void 0) return;
283
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.customerAddressUpdate, failOnUserErrors: ctx.failOnUserErrors });
284
+ if (ctx.quiet) return console.log(result.customerAddressUpdate?.address?.id ?? "");
285
+ (0, import_output.printJson)(result.customerAddressUpdate, ctx.format !== "raw");
286
+ return;
287
+ }
288
+ if (verb === "address-delete") {
289
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { "address-id": { type: "string" } } });
290
+ const customerId = (0, import_shared.requireId)(args.id, "Customer");
291
+ const addressId = (0, import_shared.requireGidFlag)(args["address-id"], "--address-id", "MailingAddress");
292
+ const result = await (0, import_router.runMutation)(ctx, {
293
+ customerAddressDelete: {
294
+ __args: { customerId, addressId },
295
+ deletedAddressId: true,
296
+ userErrors: { field: true, message: true }
297
+ }
298
+ });
299
+ if (result === void 0) return;
300
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.customerAddressDelete, failOnUserErrors: ctx.failOnUserErrors });
301
+ if (ctx.quiet) return console.log(result.customerAddressDelete?.deletedAddressId ?? "");
302
+ (0, import_output.printJson)(result.customerAddressDelete, ctx.format !== "raw");
303
+ return;
304
+ }
305
+ if (verb === "update-default-address") {
306
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { "address-id": { type: "string" } } });
307
+ const customerId = (0, import_shared.requireId)(args.id, "Customer");
308
+ const addressId = (0, import_shared.requireGidFlag)(args["address-id"], "--address-id", "MailingAddress");
309
+ const addressSelection = (0, import_select.resolveSelection)({
310
+ typeName: "MailingAddress",
311
+ view: ctx.view,
312
+ baseSelection: getMailingAddressSelection(ctx.view),
313
+ select: args.select,
314
+ selection: args.selection,
315
+ include: args.include,
316
+ ensureId: ctx.quiet
317
+ });
318
+ const result = await (0, import_router.runMutation)(ctx, {
319
+ customerUpdateDefaultAddress: {
320
+ __args: { customerId, addressId },
321
+ customer: { id: true, defaultAddress: addressSelection },
322
+ userErrors: { field: true, message: true }
323
+ }
324
+ });
325
+ if (result === void 0) return;
326
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.customerUpdateDefaultAddress, failOnUserErrors: ctx.failOnUserErrors });
327
+ const customer = result.customerUpdateDefaultAddress?.customer;
328
+ const address = customer?.defaultAddress;
329
+ if (!address) {
330
+ if (ctx.quiet) return;
331
+ (0, import_output.printJson)({ customerId: customer?.id ?? customerId, address: null }, ctx.format !== "raw");
332
+ return;
333
+ }
334
+ if (ctx.quiet) {
335
+ (0, import_output.printIds)([address.id]);
336
+ return;
337
+ }
338
+ if (ctx.view === "ids") {
339
+ (0, import_output.printNode)({ node: { id: address.id }, format: ctx.format, quiet: false });
340
+ return;
341
+ }
342
+ const out = { ...address, customerId: customer?.id ?? customerId, isDefault: true };
343
+ (0, import_output.printNode)({ node: out, format: ctx.format, quiet: false });
344
+ return;
345
+ }
346
+ if (verb === "email-marketing-consent-update") {
347
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { "email-marketing-consent": { type: "string" } } });
348
+ const customerId = (0, import_shared.requireId)(args.id, "Customer");
349
+ const emailMarketingConsent = (0, import_shared.parseJsonArg)(args["email-marketing-consent"], "--email-marketing-consent");
350
+ const result = await (0, import_router.runMutation)(ctx, {
351
+ customerEmailMarketingConsentUpdate: {
352
+ __args: { input: { customerId, emailMarketingConsent } },
353
+ customer: {
354
+ id: true,
355
+ defaultEmailAddress: {
356
+ emailAddress: true,
357
+ marketingState: true,
358
+ marketingOptInLevel: true,
359
+ marketingUpdatedAt: true,
360
+ sourceLocation: { id: true, name: true }
361
+ }
362
+ },
363
+ userErrors: { field: true, message: true, code: true }
364
+ }
365
+ });
366
+ if (result === void 0) return;
367
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.customerEmailMarketingConsentUpdate, failOnUserErrors: ctx.failOnUserErrors });
368
+ const customer = result.customerEmailMarketingConsentUpdate?.customer;
369
+ const email = customer?.defaultEmailAddress;
370
+ const out = {
371
+ customerId: customer?.id ?? customerId,
372
+ emailAddress: email?.emailAddress,
373
+ marketingState: email?.marketingState,
374
+ marketingOptInLevel: email?.marketingOptInLevel,
375
+ marketingUpdatedAt: email?.marketingUpdatedAt,
376
+ sourceLocationId: email?.sourceLocation?.id,
377
+ sourceLocationName: email?.sourceLocation?.name
378
+ };
379
+ if (ctx.quiet || ctx.view === "ids") {
380
+ (0, import_output.printIds)([out.customerId]);
381
+ return;
382
+ }
383
+ (0, import_output.printNode)({ node: out, format: ctx.format, quiet: false });
384
+ return;
385
+ }
386
+ if (verb === "sms-marketing-consent-update") {
387
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { "sms-marketing-consent": { type: "string" } } });
388
+ const customerId = (0, import_shared.requireId)(args.id, "Customer");
389
+ const smsMarketingConsent = (0, import_shared.parseJsonArg)(args["sms-marketing-consent"], "--sms-marketing-consent");
390
+ const result = await (0, import_router.runMutation)(ctx, {
391
+ customerSmsMarketingConsentUpdate: {
392
+ __args: { input: { customerId, smsMarketingConsent } },
393
+ customer: {
394
+ id: true,
395
+ defaultPhoneNumber: {
396
+ phoneNumber: true,
397
+ marketingState: true,
398
+ marketingOptInLevel: true,
399
+ marketingUpdatedAt: true,
400
+ marketingCollectedFrom: true,
401
+ sourceLocation: { id: true, name: true }
402
+ }
403
+ },
404
+ userErrors: { field: true, message: true, code: true }
405
+ }
406
+ });
407
+ if (result === void 0) return;
408
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.customerSmsMarketingConsentUpdate, failOnUserErrors: ctx.failOnUserErrors });
409
+ const customer = result.customerSmsMarketingConsentUpdate?.customer;
410
+ const sms = customer?.defaultPhoneNumber;
411
+ const out = {
412
+ customerId: customer?.id ?? customerId,
413
+ phoneNumber: sms?.phoneNumber,
414
+ marketingState: sms?.marketingState,
415
+ marketingOptInLevel: sms?.marketingOptInLevel,
416
+ marketingUpdatedAt: sms?.marketingUpdatedAt,
417
+ marketingCollectedFrom: sms?.marketingCollectedFrom,
418
+ sourceLocationId: sms?.sourceLocation?.id,
419
+ sourceLocationName: sms?.sourceLocation?.name
420
+ };
421
+ if (ctx.quiet || ctx.view === "ids") {
422
+ (0, import_output.printIds)([out.customerId]);
423
+ return;
424
+ }
425
+ (0, import_output.printNode)({ node: out, format: ctx.format, quiet: false });
426
+ return;
427
+ }
428
+ if (verb === "add-tax-exemptions" || verb === "remove-tax-exemptions" || verb === "replace-tax-exemptions") {
429
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { exemptions: { type: "string" } } });
430
+ const customerId = (0, import_shared.requireId)(args.id, "Customer");
431
+ const taxExemptions = (0, import_shared.parseCsv)(args.exemptions, "--exemptions");
432
+ const op = verb === "add-tax-exemptions" ? "customerAddTaxExemptions" : verb === "remove-tax-exemptions" ? "customerRemoveTaxExemptions" : "customerReplaceTaxExemptions";
433
+ const customerSelection = (0, import_select.resolveSelection)({
434
+ resource: "customers",
435
+ view: ctx.view,
436
+ baseSelection: getCustomerSelectionForTaxExemptions(ctx.view),
437
+ select: args.select,
438
+ selection: args.selection,
439
+ include: args.include,
440
+ ensureId: ctx.quiet,
441
+ defaultConnectionFirst: ctx.view === "all" ? 50 : 10
442
+ });
443
+ const request = {
444
+ [op]: {
445
+ __args: { customerId, taxExemptions },
446
+ customer: customerSelection,
447
+ userErrors: { field: true, message: true }
448
+ }
449
+ };
450
+ const result = await (0, import_router.runMutation)(ctx, request);
451
+ if (result === void 0) return;
452
+ const payload = result[op];
453
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload, failOnUserErrors: ctx.failOnUserErrors });
454
+ (0, import_output.printNode)({ node: payload?.customer, format: ctx.format, quiet: ctx.quiet });
455
+ return;
456
+ }
457
+ if (verb === "generate-account-activation-url") {
458
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
459
+ const customerId = (0, import_shared.requireId)(args.id, "Customer");
460
+ const result = await (0, import_router.runMutation)(ctx, {
461
+ customerGenerateAccountActivationUrl: {
462
+ __args: { customerId },
463
+ accountActivationUrl: true,
464
+ userErrors: { field: true, message: true }
465
+ }
466
+ });
467
+ if (result === void 0) return;
468
+ (0, import_userErrors.maybeFailOnUserErrors)({
469
+ payload: result.customerGenerateAccountActivationUrl,
470
+ failOnUserErrors: ctx.failOnUserErrors
471
+ });
472
+ const url = result.customerGenerateAccountActivationUrl?.accountActivationUrl ?? "";
473
+ if (ctx.quiet) return console.log(url);
474
+ (0, import_output.printJson)(result.customerGenerateAccountActivationUrl, ctx.format !== "raw");
475
+ return;
476
+ }
477
+ if (verb === "request-data-erasure" || verb === "cancel-data-erasure") {
478
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
479
+ const customerId = (0, import_shared.requireId)(args.id, "Customer");
480
+ const op = verb === "request-data-erasure" ? "customerRequestDataErasure" : "customerCancelDataErasure";
481
+ const request = {
482
+ [op]: {
483
+ __args: { customerId },
484
+ customerId: true,
485
+ userErrors: { field: true, message: true, code: true }
486
+ }
487
+ };
488
+ const result = await (0, import_router.runMutation)(ctx, request);
489
+ if (result === void 0) return;
490
+ const payload = result[op];
491
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload, failOnUserErrors: ctx.failOnUserErrors });
492
+ const now = (/* @__PURE__ */ new Date()).toISOString();
493
+ const out = verb === "request-data-erasure" ? { customerId: payload?.customerId ?? customerId, status: "REQUESTED", requestedAt: now } : { customerId: payload?.customerId ?? customerId, status: "CANCELLED", cancelledAt: now };
494
+ if (ctx.quiet || ctx.view === "ids") {
495
+ (0, import_output.printIds)([out.customerId]);
496
+ return;
497
+ }
498
+ (0, import_output.printNode)({ node: out, format: ctx.format, quiet: false });
499
+ return;
500
+ }
501
+ if (verb === "count") {
502
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { limit: { type: "string" } } });
503
+ const query = args.query;
504
+ const limitRaw = args.limit;
505
+ const limit = limitRaw === void 0 || limitRaw === null || limitRaw === "" ? void 0 : Number(limitRaw);
506
+ if (limit !== void 0 && (!Number.isFinite(limit) || limit <= 0)) {
507
+ throw new import_errors.CliError("--limit must be a positive number", 2);
508
+ }
509
+ const result = await (0, import_router.runQuery)(ctx, {
510
+ customersCount: {
511
+ __args: {
512
+ ...query ? { query } : {},
513
+ ...limit !== void 0 ? { limit: Math.floor(limit) } : {}
514
+ },
515
+ count: true,
516
+ precision: true
517
+ }
518
+ });
519
+ if (result === void 0) return;
520
+ if (ctx.quiet) return console.log(result.customersCount?.count ?? "");
521
+ (0, import_output.printJson)(result.customersCount, ctx.format !== "raw");
522
+ return;
523
+ }
524
+ if (verb === "metafields upsert") {
525
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
526
+ const built = (0, import_input.buildInput)({
527
+ inputArg: args.input,
528
+ setArgs: args.set,
529
+ setJsonArgs: args["set-json"]
530
+ });
531
+ if (!built.used) throw new import_errors.CliError("Missing --input or --set/--set-json", 2);
532
+ const ownerId = (0, import_shared.requireId)(args.id, "Customer");
533
+ const asArray = (value) => {
534
+ if (Array.isArray(value)) return value;
535
+ if (value && Array.isArray(value.metafields)) return value.metafields;
536
+ if (value && typeof value === "object") return [value];
537
+ return [];
538
+ };
539
+ const items = asArray(built.input);
540
+ if (items.length === 0) throw new import_errors.CliError("Missing metafield input: pass --input/--set/--set-json", 2);
541
+ const normalized = items.map((m) => {
542
+ if (!m || typeof m !== "object") throw new import_errors.CliError("Metafield inputs must be objects", 2);
543
+ const { key, namespace, type, value, compareDigest } = m;
544
+ if (!key) throw new import_errors.CliError("Metafield input missing key", 2);
545
+ if (value === void 0) throw new import_errors.CliError("Metafield input missing value", 2);
546
+ return {
547
+ ownerId,
548
+ key,
549
+ namespace,
550
+ type,
551
+ value: String(value),
552
+ compareDigest
553
+ };
554
+ });
555
+ const chunk = (arr, size) => {
556
+ const out = [];
557
+ for (let i = 0; i < arr.length; i += size) out.push(arr.slice(i, i + size));
558
+ return out;
559
+ };
560
+ const payloads = [];
561
+ const ids = [];
562
+ for (const group of chunk(normalized, 25)) {
563
+ const result = await (0, import_router.runMutation)(ctx, {
564
+ metafieldsSet: {
565
+ __args: { metafields: group },
566
+ metafields: { id: true },
567
+ userErrors: { field: true, message: true, elementIndex: true, code: true }
568
+ }
569
+ });
570
+ if (result === void 0) return;
571
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.metafieldsSet, failOnUserErrors: ctx.failOnUserErrors });
572
+ payloads.push(result.metafieldsSet);
573
+ for (const mf of result.metafieldsSet?.metafields ?? []) ids.push(mf?.id);
574
+ }
575
+ if (ctx.quiet) {
576
+ (0, import_output.printIds)(ids);
577
+ return;
578
+ }
579
+ (0, import_output.printJson)(payloads.length === 1 ? payloads[0] : payloads, ctx.format !== "raw");
580
+ return;
581
+ }
582
+ if (verb === "get") {
583
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
584
+ const id = (0, import_shared.requireId)(args.id, "Customer");
585
+ const selection = (0, import_select.resolveSelection)({
586
+ resource: "customers",
587
+ view: ctx.view,
588
+ baseSelection: getCustomerSelection(ctx.view),
589
+ select: args.select,
590
+ selection: args.selection,
591
+ include: args.include,
592
+ ensureId: ctx.quiet
593
+ });
594
+ const result = await (0, import_router.runQuery)(ctx, { customer: { __args: { id }, ...selection } });
595
+ if (result === void 0) return;
596
+ (0, import_output.printNode)({ node: result.customer, format: ctx.format, quiet: ctx.quiet });
597
+ return;
598
+ }
599
+ if (verb === "list") {
600
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
601
+ const first = (0, import_shared.parseFirst)(args.first);
602
+ const after = args.after;
603
+ const query = args.query;
604
+ const reverse = args.reverse;
605
+ const sortKey = args.sort;
606
+ const nodeSelection = (0, import_select.resolveSelection)({
607
+ resource: "customers",
608
+ view: ctx.view,
609
+ baseSelection: getCustomerSelection(ctx.view),
610
+ select: args.select,
611
+ selection: args.selection,
612
+ include: args.include,
613
+ ensureId: ctx.quiet
614
+ });
615
+ const result = await (0, import_router.runQuery)(ctx, {
616
+ customers: {
617
+ __args: { first, after, query, reverse, sortKey },
618
+ pageInfo: { hasNextPage: true, endCursor: true },
619
+ nodes: nodeSelection
620
+ }
621
+ });
622
+ if (result === void 0) return;
623
+ (0, import_output.printConnection)({
624
+ connection: result.customers,
625
+ format: ctx.format,
626
+ quiet: ctx.quiet,
627
+ nextPageArgs: (0, import_shared.buildListNextPageArgs)("customers", { first, query, sort: sortKey, reverse })
628
+ });
629
+ return;
630
+ }
631
+ if (verb === "create") {
632
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
633
+ const built = (0, import_input.buildInput)({
634
+ inputArg: args.input,
635
+ setArgs: args.set,
636
+ setJsonArgs: args["set-json"]
637
+ });
638
+ if (!built.used) throw new import_errors.CliError("Missing --input or --set/--set-json", 2);
639
+ const result = await (0, import_router.runMutation)(ctx, {
640
+ customerCreate: {
641
+ __args: { input: built.input },
642
+ customer: customerSummarySelection,
643
+ userErrors: { field: true, message: true }
644
+ }
645
+ });
646
+ if (result === void 0) return;
647
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.customerCreate, failOnUserErrors: ctx.failOnUserErrors });
648
+ if (ctx.quiet) return console.log(result.customerCreate?.customer?.id ?? "");
649
+ (0, import_output.printJson)(result.customerCreate, ctx.format !== "raw");
650
+ return;
651
+ }
652
+ if (verb === "add-tags" || verb === "remove-tags") {
653
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
654
+ const id = (0, import_shared.requireId)(args.id, "Customer");
655
+ const tags = (0, import_shared.parseCsv)(args.tags, "--tags");
656
+ const mutationField = verb === "add-tags" ? "tagsAdd" : "tagsRemove";
657
+ const request = {
658
+ [mutationField]: {
659
+ __args: { id, tags },
660
+ node: { id: true },
661
+ userErrors: { field: true, message: true }
662
+ }
663
+ };
664
+ const result = await (0, import_router.runMutation)(ctx, request);
665
+ if (result === void 0) return;
666
+ const payload = result[mutationField];
667
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload, failOnUserErrors: ctx.failOnUserErrors });
668
+ if (ctx.quiet) return console.log(payload?.node?.id ?? "");
669
+ (0, import_output.printJson)(payload, ctx.format !== "raw");
670
+ return;
671
+ }
672
+ if (verb === "merge") {
673
+ const args = (0, import_router.parseStandardArgs)({
674
+ argv,
675
+ extraOptions: {
676
+ "other-id": { type: "string" },
677
+ "override-fields": { type: "string" }
678
+ }
679
+ });
680
+ const customerOneId = (0, import_shared.requireId)(args.id, "Customer");
681
+ const other = args["other-id"];
682
+ if (!other) throw new import_errors.CliError("Missing --other-id", 2);
683
+ const customerTwoId = (0, import_shared.requireId)(other, "Customer");
684
+ const overrideFieldsRaw = args["override-fields"];
685
+ const overrideFields = overrideFieldsRaw !== void 0 ? (0, import_shared.parseJsonArg)(overrideFieldsRaw, "--override-fields", { allowEmpty: true }) : void 0;
686
+ const result = await (0, import_router.runMutation)(ctx, {
687
+ customerMerge: {
688
+ __args: {
689
+ customerOneId,
690
+ customerTwoId,
691
+ ...overrideFields ? { overrideFields } : {}
692
+ },
693
+ job: { id: true, done: true },
694
+ resultingCustomerId: true,
695
+ userErrors: { field: true, message: true }
696
+ }
697
+ });
698
+ if (result === void 0) return;
699
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.customerMerge, failOnUserErrors: ctx.failOnUserErrors });
700
+ const job = result.customerMerge?.job;
701
+ const out = { job, resultingCustomerId: result.customerMerge?.resultingCustomerId };
702
+ if (ctx.quiet) {
703
+ (0, import_output.printIds)([job?.id]);
704
+ return;
705
+ }
706
+ (0, import_output.printNode)({ node: out, format: ctx.format, quiet: false });
707
+ return;
708
+ }
709
+ if (verb === "send-invite") {
710
+ const args = (0, import_router.parseStandardArgs)({
711
+ argv,
712
+ extraOptions: {
713
+ email: { type: "string" }
714
+ }
715
+ });
716
+ const customerId = (0, import_shared.requireId)(args.id, "Customer");
717
+ const emailRaw = args.email;
718
+ const email = emailRaw !== void 0 ? (0, import_shared.parseJsonArg)(emailRaw, "--email", { allowEmpty: true }) : void 0;
719
+ const result = await (0, import_router.runMutation)(ctx, {
720
+ customerSendAccountInviteEmail: {
721
+ __args: {
722
+ customerId,
723
+ ...email ? { email } : {}
724
+ },
725
+ customer: { id: true, defaultEmailAddress: { emailAddress: true } },
726
+ userErrors: { field: true, message: true, code: true }
727
+ }
728
+ });
729
+ if (result === void 0) return;
730
+ (0, import_userErrors.maybeFailOnUserErrors)({
731
+ payload: result.customerSendAccountInviteEmail,
732
+ failOnUserErrors: ctx.failOnUserErrors
733
+ });
734
+ const customer = result.customerSendAccountInviteEmail?.customer;
735
+ const out = {
736
+ customerId: customer?.id ?? customerId,
737
+ emailAddress: customer?.defaultEmailAddress?.emailAddress,
738
+ requestedAt: (/* @__PURE__ */ new Date()).toISOString()
739
+ };
740
+ if (ctx.quiet || ctx.view === "ids") {
741
+ (0, import_output.printIds)([out.customerId]);
742
+ return;
743
+ }
744
+ (0, import_output.printNode)({ node: out, format: ctx.format, quiet: false });
745
+ return;
746
+ }
747
+ if (verb === "update") {
748
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
749
+ const id = (0, import_shared.requireId)(args.id, "Customer");
750
+ const built = (0, import_input.buildInput)({
751
+ inputArg: args.input,
752
+ setArgs: args.set,
753
+ setJsonArgs: args["set-json"]
754
+ });
755
+ if (!built.used) throw new import_errors.CliError("Missing --input or --set/--set-json", 2);
756
+ const input = { ...built.input, id };
757
+ const result = await (0, import_router.runMutation)(ctx, {
758
+ customerUpdate: {
759
+ __args: { input },
760
+ customer: customerSummarySelection,
761
+ userErrors: { field: true, message: true }
762
+ }
763
+ });
764
+ if (result === void 0) return;
765
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.customerUpdate, failOnUserErrors: ctx.failOnUserErrors });
766
+ if (ctx.quiet) return console.log(result.customerUpdate?.customer?.id ?? "");
767
+ (0, import_output.printJson)(result.customerUpdate, ctx.format !== "raw");
768
+ return;
769
+ }
770
+ if (verb === "delete") {
771
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
772
+ const id = (0, import_shared.requireId)(args.id, "Customer");
773
+ if (!args.yes) throw new import_errors.CliError("Refusing to delete without --yes", 2);
774
+ const result = await (0, import_router.runMutation)(ctx, {
775
+ customerDelete: {
776
+ __args: { input: { id } },
777
+ deletedCustomerId: true,
778
+ userErrors: { field: true, message: true }
779
+ }
780
+ });
781
+ if (result === void 0) return;
782
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.customerDelete, failOnUserErrors: ctx.failOnUserErrors });
783
+ if (ctx.quiet) return console.log(result.customerDelete?.deletedCustomerId ?? "");
784
+ (0, import_output.printJson)(result.customerDelete, ctx.format !== "raw");
785
+ return;
786
+ }
787
+ throw new import_errors.CliError(`Unknown verb for customers: ${verb}`, 2);
788
+ };
789
+ // Annotate the CommonJS export names for ESM import in node:
790
+ 0 && (module.exports = {
791
+ runCustomers
792
+ });
793
+ //# sourceMappingURL=customers.js.map