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,485 @@
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 collections_exports = {};
20
+ __export(collections_exports, {
21
+ runCollections: () => runCollections
22
+ });
23
+ module.exports = __toCommonJS(collections_exports);
24
+ var import_errors = require("../errors");
25
+ var import_gid = require("../gid");
26
+ var import_input = require("../input");
27
+ var import_output = require("../output");
28
+ var import_computedFields = require("../output/computedFields");
29
+ var import_router = require("../router");
30
+ var import_select = require("../selection/select");
31
+ var import_userErrors = require("../userErrors");
32
+ var import_publishablePublish = require("../workflows/products/publishablePublish");
33
+ var import_shared = require("./_shared");
34
+ const collectionSummarySelection = {
35
+ id: true,
36
+ title: true,
37
+ handle: true,
38
+ updatedAt: true
39
+ };
40
+ const collectionFullSelection = {
41
+ ...collectionSummarySelection,
42
+ description: true,
43
+ sortOrder: true,
44
+ templateSuffix: true
45
+ };
46
+ const collectionSummarySelectionForGet = {
47
+ ...collectionSummarySelection,
48
+ ...import_computedFields.computedPublicationsSelection
49
+ };
50
+ const collectionFullSelectionForGet = {
51
+ ...collectionFullSelection,
52
+ ...import_computedFields.computedPublicationsSelection
53
+ };
54
+ const getCollectionSelection = (view) => {
55
+ if (view === "ids") return { id: true };
56
+ if (view === "full") return collectionFullSelection;
57
+ if (view === "raw") return {};
58
+ return collectionSummarySelection;
59
+ };
60
+ const getCollectionSelectionForGet = (view) => {
61
+ if (view === "ids") return { id: true };
62
+ if (view === "full") return collectionFullSelectionForGet;
63
+ if (view === "raw") return {};
64
+ return collectionSummarySelectionForGet;
65
+ };
66
+ const getListNodeSelection = (view) => getCollectionSelection(view);
67
+ const runCollections = async ({
68
+ ctx,
69
+ verb,
70
+ argv
71
+ }) => {
72
+ if (argv.includes("--help") || argv.includes("-h")) {
73
+ console.log(
74
+ [
75
+ "Usage:",
76
+ " shop collections <verb> [flags]",
77
+ "",
78
+ "Verbs:",
79
+ " create|get|by-handle|by-identifier|list|count|update|delete|duplicate",
80
+ " rules-conditions",
81
+ " add-products|remove-products|reorder-products",
82
+ " publish|unpublish",
83
+ "",
84
+ "Common output flags:",
85
+ " --view summary|ids|full|raw",
86
+ " --select <path> (repeatable; dot paths; adds to base view selection)",
87
+ " --selection <graphql> (selection override; can be @file.gql)"
88
+ ].join("\n")
89
+ );
90
+ return;
91
+ }
92
+ if (verb === "by-handle") {
93
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { handle: { type: "string" } } });
94
+ const handle = args.handle;
95
+ if (!handle) throw new import_errors.CliError("Missing --handle", 2);
96
+ const selectValues = Array.isArray(args.select) ? args.select : args.select ? [args.select] : [];
97
+ const selectionOverride = typeof args.selection === "string" && args.selection.length > 0;
98
+ const select = !selectionOverride && ctx.view !== "raw" && ctx.view !== "ids" ? Array.from(/* @__PURE__ */ new Set([...selectValues, "resourcePublicationsV2.nodes.publication.name"])) : args.select;
99
+ const includeValues = Array.isArray(args.include) ? args.include : args.include ? [args.include] : [];
100
+ const include = ctx.view === "all" ? Array.from(/* @__PURE__ */ new Set([...includeValues, "resourcePublicationsV2"])) : args.include;
101
+ const selection = (0, import_select.resolveSelection)({
102
+ resource: "collections",
103
+ view: ctx.view,
104
+ baseSelection: getCollectionSelectionForGet(ctx.view),
105
+ select,
106
+ selection: args.selection,
107
+ include,
108
+ ensureId: ctx.quiet,
109
+ defaultConnectionFirst: ctx.view === "all" ? 50 : 10
110
+ });
111
+ const result = await (0, import_router.runQuery)(ctx, {
112
+ collectionByHandle: { __args: { handle }, ...selection }
113
+ });
114
+ if (result === void 0) return;
115
+ const wantsResourcePublicationsV2 = Array.isArray(args.select) && args.select.some((p) => typeof p === "string" && p.startsWith("resourcePublicationsV2"));
116
+ const wantsResourcePublicationsV2ViaSelection = typeof args.selection === "string" && args.selection.includes("resourcePublicationsV2");
117
+ const stripResourcePublicationsV2 = !(wantsResourcePublicationsV2 || wantsResourcePublicationsV2ViaSelection);
118
+ const withComputed = (0, import_computedFields.applyComputedFieldsToNode)(result.collectionByHandle, {
119
+ view: ctx.view,
120
+ stripResourcePublicationsV2
121
+ });
122
+ (0, import_output.printNode)({ node: withComputed, format: ctx.format, quiet: ctx.quiet });
123
+ return;
124
+ }
125
+ if (verb === "by-identifier") {
126
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { identifier: { type: "string" } } });
127
+ const identifier = (0, import_shared.parseJsonArg)(args.identifier, "--identifier");
128
+ const selectValues = Array.isArray(args.select) ? args.select : args.select ? [args.select] : [];
129
+ const selectionOverride = typeof args.selection === "string" && args.selection.length > 0;
130
+ const select = !selectionOverride && ctx.view !== "raw" && ctx.view !== "ids" ? Array.from(/* @__PURE__ */ new Set([...selectValues, "resourcePublicationsV2.nodes.publication.name"])) : args.select;
131
+ const includeValues = Array.isArray(args.include) ? args.include : args.include ? [args.include] : [];
132
+ const include = ctx.view === "all" ? Array.from(/* @__PURE__ */ new Set([...includeValues, "resourcePublicationsV2"])) : args.include;
133
+ const selection = (0, import_select.resolveSelection)({
134
+ resource: "collections",
135
+ view: ctx.view,
136
+ baseSelection: getCollectionSelectionForGet(ctx.view),
137
+ select,
138
+ selection: args.selection,
139
+ include,
140
+ ensureId: ctx.quiet,
141
+ defaultConnectionFirst: ctx.view === "all" ? 50 : 10
142
+ });
143
+ const result = await (0, import_router.runQuery)(ctx, {
144
+ collectionByIdentifier: { __args: { identifier }, ...selection }
145
+ });
146
+ if (result === void 0) return;
147
+ const wantsResourcePublicationsV2 = Array.isArray(args.select) && args.select.some((p) => typeof p === "string" && p.startsWith("resourcePublicationsV2"));
148
+ const wantsResourcePublicationsV2ViaSelection = typeof args.selection === "string" && args.selection.includes("resourcePublicationsV2");
149
+ const stripResourcePublicationsV2 = !(wantsResourcePublicationsV2 || wantsResourcePublicationsV2ViaSelection);
150
+ const withComputed = (0, import_computedFields.applyComputedFieldsToNode)(result.collectionByIdentifier, {
151
+ view: ctx.view,
152
+ stripResourcePublicationsV2
153
+ });
154
+ (0, import_output.printNode)({ node: withComputed, format: ctx.format, quiet: ctx.quiet });
155
+ return;
156
+ }
157
+ if (verb === "rules-conditions") {
158
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
159
+ const selection = (0, import_select.resolveSelection)({
160
+ typeName: "CollectionRuleConditions",
161
+ view: ctx.view,
162
+ baseSelection: {
163
+ ruleType: true,
164
+ defaultRelation: true,
165
+ allowedRelations: true,
166
+ ruleObject: {
167
+ __typename: true,
168
+ on_CollectionRuleMetafieldCondition: {
169
+ metafieldDefinition: { id: true, name: true, namespace: true, key: true }
170
+ }
171
+ },
172
+ __typename: true
173
+ },
174
+ select: args.select,
175
+ selection: args.selection,
176
+ include: args.include,
177
+ ensureId: false
178
+ });
179
+ const result = await (0, import_router.runQuery)(ctx, { collectionRulesConditions: selection });
180
+ if (result === void 0) return;
181
+ (0, import_output.printJson)(result.collectionRulesConditions, ctx.format !== "raw");
182
+ return;
183
+ }
184
+ if (verb === "get") {
185
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
186
+ const id = (0, import_shared.requireId)(args.id, "Collection");
187
+ const selectValues = Array.isArray(args.select) ? args.select : args.select ? [args.select] : [];
188
+ const selectionOverride = typeof args.selection === "string" && args.selection.length > 0;
189
+ const select = !selectionOverride && ctx.view !== "raw" && ctx.view !== "ids" ? Array.from(/* @__PURE__ */ new Set([...selectValues, "resourcePublicationsV2.nodes.publication.name"])) : args.select;
190
+ const includeValues = Array.isArray(args.include) ? args.include : args.include ? [args.include] : [];
191
+ const include = ctx.view === "all" ? Array.from(/* @__PURE__ */ new Set([...includeValues, "resourcePublicationsV2"])) : args.include;
192
+ const selection = (0, import_select.resolveSelection)({
193
+ resource: "collections",
194
+ view: ctx.view,
195
+ baseSelection: getCollectionSelectionForGet(ctx.view),
196
+ select,
197
+ selection: args.selection,
198
+ include,
199
+ ensureId: ctx.quiet,
200
+ defaultConnectionFirst: ctx.view === "all" ? 50 : 10
201
+ });
202
+ const result = await (0, import_router.runQuery)(ctx, {
203
+ collection: { __args: { id }, ...selection }
204
+ });
205
+ if (result === void 0) return;
206
+ const wantsResourcePublicationsV2 = Array.isArray(args.select) && args.select.some((p) => typeof p === "string" && p.startsWith("resourcePublicationsV2"));
207
+ const wantsResourcePublicationsV2ViaSelection = typeof args.selection === "string" && args.selection.includes("resourcePublicationsV2");
208
+ const stripResourcePublicationsV2 = !(wantsResourcePublicationsV2 || wantsResourcePublicationsV2ViaSelection);
209
+ const withComputed = (0, import_computedFields.applyComputedFieldsToNode)(result.collection, {
210
+ view: ctx.view,
211
+ stripResourcePublicationsV2
212
+ });
213
+ (0, import_output.printNode)({ node: withComputed, format: ctx.format, quiet: ctx.quiet });
214
+ return;
215
+ }
216
+ if (verb === "list") {
217
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
218
+ const first = (0, import_shared.parseFirst)(args.first);
219
+ const after = args.after;
220
+ const query = args.query;
221
+ const reverse = args.reverse;
222
+ const sortKey = args.sort;
223
+ const nodeSelection = (0, import_select.resolveSelection)({
224
+ resource: "collections",
225
+ view: ctx.view,
226
+ baseSelection: getListNodeSelection(ctx.view),
227
+ select: args.select,
228
+ selection: args.selection,
229
+ include: args.include,
230
+ ensureId: ctx.quiet
231
+ });
232
+ const result = await (0, import_router.runQuery)(ctx, {
233
+ collections: {
234
+ __args: { first, after, query, reverse, sortKey },
235
+ pageInfo: { hasNextPage: true, endCursor: true },
236
+ nodes: nodeSelection
237
+ }
238
+ });
239
+ if (result === void 0) return;
240
+ (0, import_output.printConnection)({
241
+ connection: result.collections,
242
+ format: ctx.format,
243
+ quiet: ctx.quiet,
244
+ nextPageArgs: (0, import_shared.buildListNextPageArgs)("collections", { first, query, sort: sortKey, reverse })
245
+ });
246
+ return;
247
+ }
248
+ if (verb === "count") {
249
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { limit: { type: "string" } } });
250
+ const query = args.query;
251
+ const limitRaw = args.limit;
252
+ const limit = limitRaw === void 0 || limitRaw === null || limitRaw === "" ? void 0 : Number(limitRaw);
253
+ if (limit !== void 0 && (!Number.isFinite(limit) || limit <= 0)) {
254
+ throw new import_errors.CliError("--limit must be a positive number", 2);
255
+ }
256
+ const result = await (0, import_router.runQuery)(ctx, {
257
+ collectionsCount: {
258
+ __args: {
259
+ ...query ? { query } : {},
260
+ ...limit !== void 0 ? { limit: Math.floor(limit) } : {}
261
+ },
262
+ count: true,
263
+ precision: true
264
+ }
265
+ });
266
+ if (result === void 0) return;
267
+ if (ctx.quiet) return console.log(result.collectionsCount?.count ?? "");
268
+ (0, import_output.printJson)(result.collectionsCount, ctx.format !== "raw");
269
+ return;
270
+ }
271
+ if (verb === "create") {
272
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
273
+ const built = (0, import_input.buildInput)({
274
+ inputArg: args.input,
275
+ setArgs: args.set,
276
+ setJsonArgs: args["set-json"]
277
+ });
278
+ if (!built.used) throw new import_errors.CliError("Missing --input or --set/--set-json", 2);
279
+ const result = await (0, import_router.runMutation)(ctx, {
280
+ collectionCreate: {
281
+ __args: { input: built.input },
282
+ collection: collectionSummarySelection,
283
+ userErrors: { field: true, message: true }
284
+ }
285
+ });
286
+ if (result === void 0) return;
287
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.collectionCreate, failOnUserErrors: ctx.failOnUserErrors });
288
+ if (ctx.quiet) return console.log(result.collectionCreate?.collection?.id ?? "");
289
+ (0, import_output.printJson)(result.collectionCreate, ctx.format !== "raw");
290
+ return;
291
+ }
292
+ if (verb === "add-products" || verb === "remove-products") {
293
+ const args = (0, import_router.parseStandardArgs)({
294
+ argv,
295
+ extraOptions: {
296
+ "product-id": { type: "string", multiple: true }
297
+ }
298
+ });
299
+ const id = (0, import_shared.requireId)(args.id, "Collection");
300
+ const rawProducts = (0, import_shared.parseStringList)(args["product-id"], "--product-id");
301
+ const productIds = rawProducts.map((pid) => (0, import_gid.coerceGid)(pid, "Product"));
302
+ const mutation = verb === "add-products" ? "collectionAddProductsV2" : "collectionRemoveProducts";
303
+ const result = await (0, import_router.runMutation)(ctx, {
304
+ [mutation]: {
305
+ __args: { id, productIds },
306
+ job: { id: true, done: true },
307
+ userErrors: { field: true, message: true }
308
+ }
309
+ });
310
+ if (result === void 0) return;
311
+ const payload = result[mutation];
312
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload, failOnUserErrors: ctx.failOnUserErrors });
313
+ if (ctx.quiet) return console.log(payload?.job?.id ?? "");
314
+ (0, import_output.printJson)(payload, ctx.format !== "raw");
315
+ return;
316
+ }
317
+ if (verb === "reorder-products") {
318
+ const args = (0, import_router.parseStandardArgs)({
319
+ argv,
320
+ extraOptions: {
321
+ moves: { type: "string" },
322
+ move: { type: "string", multiple: true }
323
+ }
324
+ });
325
+ const id = (0, import_shared.requireId)(args.id, "Collection");
326
+ let moves = [];
327
+ if (args.moves) {
328
+ moves = (0, import_shared.parseJsonArg)(args.moves, "--moves");
329
+ if (!Array.isArray(moves)) throw new import_errors.CliError("--moves must be a JSON array", 2);
330
+ } else if (args.move) {
331
+ const raw = args.move;
332
+ const parsedMoves = [];
333
+ for (const item of raw) {
334
+ const parts = item.split(":");
335
+ if (parts.length !== 2) throw new import_errors.CliError("--move must be <productId>:<newPosition>", 2);
336
+ const productId = parts[0].trim();
337
+ const pos = Number(parts[1].trim());
338
+ if (!productId) throw new import_errors.CliError("--move productId cannot be empty", 2);
339
+ if (!Number.isFinite(pos) || pos < 0) throw new import_errors.CliError("--move newPosition must be a non-negative number", 2);
340
+ parsedMoves.push({ id: (0, import_gid.coerceGid)(productId, "Product"), newPosition: Math.floor(pos) });
341
+ }
342
+ moves = parsedMoves;
343
+ }
344
+ if (moves.length === 0) {
345
+ throw new import_errors.CliError("Missing moves: pass either --moves <json|@file> or --move <productId>:<newPosition> (repeatable)", 2);
346
+ }
347
+ const normalizedMoves = moves.map((move, i) => {
348
+ const mid = move?.id;
349
+ const newPosition = move?.newPosition;
350
+ if (typeof mid !== "string" || !mid.trim()) throw new import_errors.CliError(`moves[${i}].id is required`, 2);
351
+ const pos = Number(newPosition);
352
+ if (!Number.isFinite(pos) || pos < 0) throw new import_errors.CliError(`moves[${i}].newPosition must be a non-negative number`, 2);
353
+ return { id: mid.startsWith("gid://") ? mid : (0, import_gid.coerceGid)(mid, "Product"), newPosition: Math.floor(pos) };
354
+ });
355
+ const result = await (0, import_router.runMutation)(ctx, {
356
+ collectionReorderProducts: {
357
+ __args: { id, moves: normalizedMoves },
358
+ job: { id: true, done: true },
359
+ userErrors: { field: true, message: true }
360
+ }
361
+ });
362
+ if (result === void 0) return;
363
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.collectionReorderProducts, failOnUserErrors: ctx.failOnUserErrors });
364
+ if (ctx.quiet) return console.log(result.collectionReorderProducts?.job?.id ?? "");
365
+ (0, import_output.printJson)(result.collectionReorderProducts, ctx.format !== "raw");
366
+ return;
367
+ }
368
+ if (verb === "publish" || verb === "unpublish") {
369
+ const args = (0, import_router.parseStandardArgs)({
370
+ argv,
371
+ extraOptions: {
372
+ "publication-id": { type: "string", multiple: true },
373
+ publication: { type: "string", multiple: true }
374
+ }
375
+ });
376
+ const id = (0, import_shared.requireId)(args.id, "Collection");
377
+ const publicationIds = args["publication-id"] ?? [];
378
+ const publicationNames = args.publication ?? [];
379
+ const resolvedPublicationIds = await (0, import_publishablePublish.resolvePublicationIds)({
380
+ ctx,
381
+ publicationIds,
382
+ publicationNames
383
+ });
384
+ const collectionPublications = resolvedPublicationIds.map((publicationId) => ({ publicationId }));
385
+ const mutation = verb === "publish" ? "collectionPublish" : "collectionUnpublish";
386
+ const result = await (0, import_router.runMutation)(ctx, {
387
+ [mutation]: {
388
+ __args: { input: { id, collectionPublications } },
389
+ collection: { id: true, title: true },
390
+ userErrors: { field: true, message: true }
391
+ }
392
+ });
393
+ if (result === void 0) return;
394
+ const payload = result[mutation];
395
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload, failOnUserErrors: ctx.failOnUserErrors });
396
+ if (ctx.quiet) return console.log(payload?.collection?.id ?? "");
397
+ (0, import_output.printJson)(payload, ctx.format !== "raw");
398
+ return;
399
+ }
400
+ if (verb === "update") {
401
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
402
+ const id = (0, import_shared.requireId)(args.id, "Collection");
403
+ const built = (0, import_input.buildInput)({
404
+ inputArg: args.input,
405
+ setArgs: args.set,
406
+ setJsonArgs: args["set-json"]
407
+ });
408
+ if (!built.used) throw new import_errors.CliError("Missing --input or --set/--set-json", 2);
409
+ const input = { ...built.input, id };
410
+ const result = await (0, import_router.runMutation)(ctx, {
411
+ collectionUpdate: {
412
+ __args: { input },
413
+ collection: collectionSummarySelection,
414
+ userErrors: { field: true, message: true }
415
+ }
416
+ });
417
+ if (result === void 0) return;
418
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.collectionUpdate, failOnUserErrors: ctx.failOnUserErrors });
419
+ if (ctx.quiet) return console.log(result.collectionUpdate?.collection?.id ?? "");
420
+ (0, import_output.printJson)(result.collectionUpdate, ctx.format !== "raw");
421
+ return;
422
+ }
423
+ if (verb === "delete") {
424
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
425
+ const id = (0, import_shared.requireId)(args.id, "Collection");
426
+ if (!args.yes) throw new import_errors.CliError("Refusing to delete without --yes", 2);
427
+ const result = await (0, import_router.runMutation)(ctx, {
428
+ collectionDelete: {
429
+ __args: { input: { id } },
430
+ deletedCollectionId: true,
431
+ userErrors: { field: true, message: true }
432
+ }
433
+ });
434
+ if (result === void 0) return;
435
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.collectionDelete, failOnUserErrors: ctx.failOnUserErrors });
436
+ if (ctx.quiet) return console.log(result.collectionDelete?.deletedCollectionId ?? "");
437
+ (0, import_output.printJson)(result.collectionDelete, ctx.format !== "raw");
438
+ return;
439
+ }
440
+ if (verb === "duplicate") {
441
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { "copy-publications": { type: "boolean" } } });
442
+ const id = (0, import_shared.requireId)(args.id, "Collection");
443
+ const built = (0, import_input.buildInput)({
444
+ inputArg: void 0,
445
+ setArgs: args.set,
446
+ setJsonArgs: args["set-json"]
447
+ });
448
+ let newTitle = args["new-title"] ?? (built.used ? built.input?.newTitle : void 0);
449
+ if (!newTitle) {
450
+ const original = await (0, import_router.runQuery)(ctx, {
451
+ collection: { __args: { id }, title: true }
452
+ });
453
+ if (original === void 0) return;
454
+ const title = original.collection?.title;
455
+ if (!title) throw new import_errors.CliError("Could not resolve original collection title to auto-generate newTitle", 2);
456
+ newTitle = `${title} (Copy)`;
457
+ }
458
+ const copyPublications = args["copy-publications"];
459
+ const input = {
460
+ collectionId: id,
461
+ newTitle,
462
+ ...copyPublications === void 0 ? {} : { copyPublications },
463
+ ...built.used ? built.input : {}
464
+ };
465
+ const result = await (0, import_router.runMutation)(ctx, {
466
+ collectionDuplicate: {
467
+ __args: { input },
468
+ collection: collectionSummarySelection,
469
+ job: { id: true, done: true },
470
+ userErrors: { field: true, message: true, code: true }
471
+ }
472
+ });
473
+ if (result === void 0) return;
474
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.collectionDuplicate, failOnUserErrors: ctx.failOnUserErrors });
475
+ if (ctx.quiet) return console.log(result.collectionDuplicate?.collection?.id ?? "");
476
+ (0, import_output.printJson)(result.collectionDuplicate, ctx.format !== "raw");
477
+ return;
478
+ }
479
+ throw new import_errors.CliError(`Unknown verb for collections: ${verb}`, 2);
480
+ };
481
+ // Annotate the CommonJS export names for ESM import in node:
482
+ 0 && (module.exports = {
483
+ runCollections
484
+ });
485
+ //# sourceMappingURL=collections.js.map
@@ -0,0 +1,6 @@
1
+ import { type CommandContext } from '../router';
2
+ export declare const runComments: ({ ctx, verb, argv, }: {
3
+ ctx: CommandContext;
4
+ verb: string;
5
+ argv: string[];
6
+ }) => Promise<void>;
@@ -0,0 +1,160 @@
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 comments_exports = {};
20
+ __export(comments_exports, {
21
+ runComments: () => runComments
22
+ });
23
+ module.exports = __toCommonJS(comments_exports);
24
+ var import_errors = require("../errors");
25
+ var import_output = require("../output");
26
+ var import_router = require("../router");
27
+ var import_select = require("../selection/select");
28
+ var import_userErrors = require("../userErrors");
29
+ var import_shared = require("./_shared");
30
+ const commentSummarySelection = {
31
+ id: true,
32
+ status: true,
33
+ isPublished: true,
34
+ createdAt: true,
35
+ updatedAt: true
36
+ };
37
+ const commentFullSelection = {
38
+ ...commentSummarySelection,
39
+ body: true,
40
+ author: { name: true, email: true }
41
+ };
42
+ const getCommentSelection = (view) => {
43
+ if (view === "ids") return { id: true };
44
+ if (view === "full") return commentFullSelection;
45
+ if (view === "raw") return {};
46
+ return commentSummarySelection;
47
+ };
48
+ const runComments = async ({
49
+ ctx,
50
+ verb,
51
+ argv
52
+ }) => {
53
+ if (argv.includes("--help") || argv.includes("-h")) {
54
+ console.log(
55
+ [
56
+ "Usage:",
57
+ " shop comments <verb> [flags]",
58
+ "",
59
+ "Verbs:",
60
+ " get|list|delete|approve|spam|not-spam",
61
+ "",
62
+ "Common output flags:",
63
+ " --view summary|ids|full|raw",
64
+ " --select <path> (repeatable; dot paths; adds to base view selection)",
65
+ " --selection <graphql> (selection override; can be @file.gql)"
66
+ ].join("\n")
67
+ );
68
+ return;
69
+ }
70
+ if (verb === "approve" || verb === "spam" || verb === "not-spam") {
71
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
72
+ const id = (0, import_shared.requireId)(args.id, "Comment");
73
+ const mutation = verb === "approve" ? "commentApprove" : verb === "spam" ? "commentSpam" : "commentNotSpam";
74
+ const result = await (0, import_router.runMutation)(ctx, {
75
+ [mutation]: {
76
+ __args: { id },
77
+ comment: commentSummarySelection,
78
+ userErrors: { field: true, message: true, code: true }
79
+ }
80
+ });
81
+ if (result === void 0) return;
82
+ const payload = result[mutation];
83
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload, failOnUserErrors: ctx.failOnUserErrors });
84
+ if (ctx.quiet) return console.log(payload?.comment?.id ?? "");
85
+ (0, import_output.printJson)(payload, ctx.format !== "raw");
86
+ return;
87
+ }
88
+ if (verb === "get") {
89
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
90
+ const id = (0, import_shared.requireId)(args.id, "Comment");
91
+ const selection = (0, import_select.resolveSelection)({
92
+ resource: "comments",
93
+ view: ctx.view,
94
+ baseSelection: getCommentSelection(ctx.view),
95
+ select: args.select,
96
+ selection: args.selection,
97
+ include: args.include,
98
+ ensureId: ctx.quiet
99
+ });
100
+ const result = await (0, import_router.runQuery)(ctx, { comment: { __args: { id }, ...selection } });
101
+ if (result === void 0) return;
102
+ (0, import_output.printNode)({ node: result.comment, format: ctx.format, quiet: ctx.quiet });
103
+ return;
104
+ }
105
+ if (verb === "list") {
106
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
107
+ const first = (0, import_shared.parseFirst)(args.first);
108
+ const after = args.after;
109
+ const query = args.query;
110
+ const reverse = args.reverse;
111
+ const sortKey = args.sort;
112
+ const nodeSelection = (0, import_select.resolveSelection)({
113
+ resource: "comments",
114
+ view: ctx.view,
115
+ baseSelection: getCommentSelection(ctx.view),
116
+ select: args.select,
117
+ selection: args.selection,
118
+ include: args.include,
119
+ ensureId: ctx.quiet
120
+ });
121
+ const result = await (0, import_router.runQuery)(ctx, {
122
+ comments: {
123
+ __args: { first, after, query, reverse, sortKey },
124
+ pageInfo: { hasNextPage: true, endCursor: true },
125
+ nodes: nodeSelection
126
+ }
127
+ });
128
+ if (result === void 0) return;
129
+ (0, import_output.printConnection)({
130
+ connection: result.comments,
131
+ format: ctx.format,
132
+ quiet: ctx.quiet,
133
+ nextPageArgs: (0, import_shared.buildListNextPageArgs)("comments", { first, query, sort: sortKey, reverse })
134
+ });
135
+ return;
136
+ }
137
+ if (verb === "delete") {
138
+ const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
139
+ const id = (0, import_shared.requireId)(args.id, "Comment");
140
+ if (!args.yes) throw new import_errors.CliError("Refusing to delete without --yes", 2);
141
+ const result = await (0, import_router.runMutation)(ctx, {
142
+ commentDelete: {
143
+ __args: { id },
144
+ deletedCommentId: true,
145
+ userErrors: { field: true, message: true }
146
+ }
147
+ });
148
+ if (result === void 0) return;
149
+ (0, import_userErrors.maybeFailOnUserErrors)({ payload: result.commentDelete, failOnUserErrors: ctx.failOnUserErrors });
150
+ if (ctx.quiet) return console.log(result.commentDelete?.deletedCommentId ?? "");
151
+ (0, import_output.printJson)(result.commentDelete, ctx.format !== "raw");
152
+ return;
153
+ }
154
+ throw new import_errors.CliError(`Unknown verb for comments: ${verb}`, 2);
155
+ };
156
+ // Annotate the CommonJS export names for ESM import in node:
157
+ 0 && (module.exports = {
158
+ runComments
159
+ });
160
+ //# sourceMappingURL=comments.js.map
@@ -0,0 +1,6 @@
1
+ import { type CommandContext } from '../router';
2
+ export declare const runCompanies: ({ ctx, verb, argv, }: {
3
+ ctx: CommandContext;
4
+ verb: string;
5
+ argv: string[];
6
+ }) => Promise<void>;