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