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