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,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var urlDownloads_exports = {};
|
|
30
|
+
__export(urlDownloads_exports, {
|
|
31
|
+
downloadUrlsToTempDir: () => downloadUrlsToTempDir,
|
|
32
|
+
inferFilenameFromUrl: () => inferFilenameFromUrl
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(urlDownloads_exports);
|
|
35
|
+
var import_node_fs = require("node:fs");
|
|
36
|
+
var import_promises = require("node:fs/promises");
|
|
37
|
+
var import_promises2 = require("node:stream/promises");
|
|
38
|
+
var import_node_stream = require("node:stream");
|
|
39
|
+
var import_node_os = __toESM(require("node:os"));
|
|
40
|
+
var import_node_path = __toESM(require("node:path"));
|
|
41
|
+
var import_errors = require("../../errors");
|
|
42
|
+
const safeBasename = (name) => name.replace(/[\\/]/g, "_");
|
|
43
|
+
const inferFilenameFromUrl = (rawUrl) => {
|
|
44
|
+
let u;
|
|
45
|
+
try {
|
|
46
|
+
u = new URL(rawUrl);
|
|
47
|
+
} catch {
|
|
48
|
+
throw new import_errors.CliError(`Invalid URL: ${rawUrl}`, 2);
|
|
49
|
+
}
|
|
50
|
+
const base = import_node_path.default.posix.basename(u.pathname || "");
|
|
51
|
+
if (base && base !== "/" && base !== ".") {
|
|
52
|
+
try {
|
|
53
|
+
const decoded = decodeURIComponent(base);
|
|
54
|
+
return safeBasename(decoded) || "download";
|
|
55
|
+
} catch {
|
|
56
|
+
return safeBasename(base) || "download";
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return "download";
|
|
60
|
+
};
|
|
61
|
+
const uniqueFilename = (requested, used) => {
|
|
62
|
+
const base = safeBasename(requested) || "download";
|
|
63
|
+
const count = used.get(base) ?? 0;
|
|
64
|
+
used.set(base, count + 1);
|
|
65
|
+
if (count === 0) return base;
|
|
66
|
+
const ext = import_node_path.default.extname(base);
|
|
67
|
+
const stem = ext ? base.slice(0, -ext.length) : base;
|
|
68
|
+
return `${stem}-${count + 1}${ext}`;
|
|
69
|
+
};
|
|
70
|
+
const downloadUrlsToTempDir = async ({
|
|
71
|
+
urls,
|
|
72
|
+
filenameOverride
|
|
73
|
+
}) => {
|
|
74
|
+
if (urls.length === 0) throw new import_errors.CliError("Missing --url (repeatable)", 2);
|
|
75
|
+
if (filenameOverride && urls.length !== 1) {
|
|
76
|
+
throw new import_errors.CliError("--filename is only valid when exactly 1 --url is provided", 2);
|
|
77
|
+
}
|
|
78
|
+
const tempDir = await (0, import_promises.mkdtemp)(import_node_path.default.join(import_node_os.default.tmpdir(), "shop-cli-files-upload-"));
|
|
79
|
+
const cleanup = async () => {
|
|
80
|
+
await (0, import_promises.rm)(tempDir, { recursive: true, force: true });
|
|
81
|
+
};
|
|
82
|
+
try {
|
|
83
|
+
await (0, import_promises.mkdir)(tempDir, { recursive: true });
|
|
84
|
+
const used = /* @__PURE__ */ new Map();
|
|
85
|
+
const files = [];
|
|
86
|
+
for (let i = 0; i < urls.length; i++) {
|
|
87
|
+
const url = urls[i];
|
|
88
|
+
const inferred = filenameOverride ?? inferFilenameFromUrl(url);
|
|
89
|
+
const filename = uniqueFilename(inferred, used);
|
|
90
|
+
const filePath = import_node_path.default.join(tempDir, filename);
|
|
91
|
+
const res = await fetch(url, { redirect: "follow" });
|
|
92
|
+
if (!res.ok) {
|
|
93
|
+
throw new import_errors.CliError(`Failed to download ${url}: ${res.status} ${res.statusText}`, 2);
|
|
94
|
+
}
|
|
95
|
+
if (!res.body) {
|
|
96
|
+
throw new import_errors.CliError(`Failed to download ${url}: empty response body`, 2);
|
|
97
|
+
}
|
|
98
|
+
const nodeStream = import_node_stream.Readable.fromWeb(res.body);
|
|
99
|
+
const out = (0, import_node_fs.createWriteStream)(filePath);
|
|
100
|
+
await (0, import_promises2.pipeline)(nodeStream, out);
|
|
101
|
+
files.push({ url, filePath, filename });
|
|
102
|
+
}
|
|
103
|
+
return { tempDir, files, cleanup };
|
|
104
|
+
} catch (err) {
|
|
105
|
+
await cleanup();
|
|
106
|
+
throw err;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
110
|
+
0 && (module.exports = {
|
|
111
|
+
downloadUrlsToTempDir,
|
|
112
|
+
inferFilenameFromUrl
|
|
113
|
+
});
|
|
114
|
+
//# sourceMappingURL=urlDownloads.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type CommandContext } from '../../router';
|
|
2
|
+
export type WaitForFilesResult = {
|
|
3
|
+
nodes: any[];
|
|
4
|
+
readyIds: string[];
|
|
5
|
+
failedIds: string[];
|
|
6
|
+
};
|
|
7
|
+
export declare const pollFilesReadyOrFailed: ({ ids, pollIntervalMs, timeoutMs, fetchNodes, now, sleep, }: {
|
|
8
|
+
ids: string[];
|
|
9
|
+
pollIntervalMs: number;
|
|
10
|
+
timeoutMs: number;
|
|
11
|
+
fetchNodes: (ids: string[]) => Promise<any[]>;
|
|
12
|
+
now?: () => number;
|
|
13
|
+
sleep?: (ms: number) => Promise<void>;
|
|
14
|
+
}) => Promise<WaitForFilesResult>;
|
|
15
|
+
export declare const waitForFilesReadyOrFailed: ({ ctx, ids, pollIntervalMs, timeoutMs, }: {
|
|
16
|
+
ctx: CommandContext;
|
|
17
|
+
ids: string[];
|
|
18
|
+
pollIntervalMs: number;
|
|
19
|
+
timeoutMs: number;
|
|
20
|
+
}) => Promise<WaitForFilesResult>;
|
|
@@ -0,0 +1,114 @@
|
|
|
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 waitForReady_exports = {};
|
|
20
|
+
__export(waitForReady_exports, {
|
|
21
|
+
pollFilesReadyOrFailed: () => pollFilesReadyOrFailed,
|
|
22
|
+
waitForFilesReadyOrFailed: () => waitForFilesReadyOrFailed
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(waitForReady_exports);
|
|
25
|
+
var import_errors = require("../../errors");
|
|
26
|
+
var import_router = require("../../router");
|
|
27
|
+
const pollFilesReadyOrFailed = async ({
|
|
28
|
+
ids,
|
|
29
|
+
pollIntervalMs,
|
|
30
|
+
timeoutMs,
|
|
31
|
+
fetchNodes,
|
|
32
|
+
now = () => Date.now(),
|
|
33
|
+
sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
|
|
34
|
+
}) => {
|
|
35
|
+
const start = now();
|
|
36
|
+
const remaining = new Set(ids);
|
|
37
|
+
let lastNodes = [];
|
|
38
|
+
while (true) {
|
|
39
|
+
lastNodes = await fetchNodes(ids);
|
|
40
|
+
const readyIds = [];
|
|
41
|
+
const failedIds = [];
|
|
42
|
+
for (const node of lastNodes) {
|
|
43
|
+
if (!node || typeof node !== "object") continue;
|
|
44
|
+
const id = typeof node.id === "string" ? node.id : void 0;
|
|
45
|
+
if (!id) continue;
|
|
46
|
+
const status = node.fileStatus;
|
|
47
|
+
if (status === "READY") {
|
|
48
|
+
remaining.delete(id);
|
|
49
|
+
readyIds.push(id);
|
|
50
|
+
} else if (status === "FAILED") {
|
|
51
|
+
remaining.delete(id);
|
|
52
|
+
failedIds.push(id);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (remaining.size === 0) {
|
|
56
|
+
return { nodes: lastNodes, readyIds, failedIds };
|
|
57
|
+
}
|
|
58
|
+
const elapsed = now() - start;
|
|
59
|
+
if (elapsed >= timeoutMs) {
|
|
60
|
+
const pending = Array.from(remaining);
|
|
61
|
+
throw new import_errors.CliError(
|
|
62
|
+
`Timed out after ${timeoutMs}ms waiting for files to be READY/FAILED: ${pending.join(", ")}`,
|
|
63
|
+
2
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
await sleep(pollIntervalMs);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const waitForFilesReadyOrFailed = async ({
|
|
70
|
+
ctx,
|
|
71
|
+
ids,
|
|
72
|
+
pollIntervalMs,
|
|
73
|
+
timeoutMs
|
|
74
|
+
}) => {
|
|
75
|
+
if (ids.length === 0) return { nodes: [], readyIds: [], failedIds: [] };
|
|
76
|
+
const fileFields = {
|
|
77
|
+
id: true,
|
|
78
|
+
fileStatus: true,
|
|
79
|
+
fileErrors: { code: true, message: true, details: true },
|
|
80
|
+
preview: { status: true, image: { url: true } }
|
|
81
|
+
};
|
|
82
|
+
const nodeSelection = {
|
|
83
|
+
__typename: true,
|
|
84
|
+
// `nodes` returns `[Node]`. GenQL only allows inline fragments on concrete object types
|
|
85
|
+
// (not interfaces like `File`), so we select the known File implementations.
|
|
86
|
+
on_GenericFile: { ...fileFields, url: true },
|
|
87
|
+
on_MediaImage: fileFields,
|
|
88
|
+
on_Video: fileFields,
|
|
89
|
+
on_Model3d: fileFields,
|
|
90
|
+
on_ExternalVideo: fileFields
|
|
91
|
+
};
|
|
92
|
+
return pollFilesReadyOrFailed({
|
|
93
|
+
ids,
|
|
94
|
+
pollIntervalMs,
|
|
95
|
+
timeoutMs,
|
|
96
|
+
fetchNodes: async (fileIds) => {
|
|
97
|
+
const result = await (0, import_router.runQuery)(ctx, {
|
|
98
|
+
nodes: {
|
|
99
|
+
__args: { ids: fileIds },
|
|
100
|
+
...nodeSelection
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
if (result === void 0) return [];
|
|
104
|
+
const nodes = result.nodes ?? [];
|
|
105
|
+
return Array.isArray(nodes) ? nodes : [];
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
110
|
+
0 && (module.exports = {
|
|
111
|
+
pollFilesReadyOrFailed,
|
|
112
|
+
waitForFilesReadyOrFailed
|
|
113
|
+
});
|
|
114
|
+
//# sourceMappingURL=waitForReady.js.map
|
|
@@ -0,0 +1,59 @@
|
|
|
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 resolveInventoryItemId_exports = {};
|
|
20
|
+
__export(resolveInventoryItemId_exports, {
|
|
21
|
+
resolveInventoryItemId: () => resolveInventoryItemId
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(resolveInventoryItemId_exports);
|
|
24
|
+
var import_errors = require("../../errors");
|
|
25
|
+
var import_gid = require("../../gid");
|
|
26
|
+
var import_router = require("../../router");
|
|
27
|
+
const resolveInventoryItemId = async ({
|
|
28
|
+
ctx,
|
|
29
|
+
inventoryItemId,
|
|
30
|
+
variantId
|
|
31
|
+
}) => {
|
|
32
|
+
if (inventoryItemId && variantId) {
|
|
33
|
+
throw new import_errors.CliError("Pass only one of --inventory-item-id or --variant-id", 2);
|
|
34
|
+
}
|
|
35
|
+
if (inventoryItemId) return (0, import_gid.coerceGid)(inventoryItemId, "InventoryItem");
|
|
36
|
+
if (!variantId) {
|
|
37
|
+
throw new import_errors.CliError("Missing --inventory-item-id or --variant-id", 2);
|
|
38
|
+
}
|
|
39
|
+
if (ctx.dryRun) {
|
|
40
|
+
throw new import_errors.CliError(
|
|
41
|
+
"--dry-run with --variant-id is not supported (pass --inventory-item-id instead)",
|
|
42
|
+
2
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
const id = (0, import_gid.coerceGid)(variantId, "ProductVariant");
|
|
46
|
+
const result = await (0, import_router.runQuery)(ctx, {
|
|
47
|
+
productVariant: { __args: { id }, inventoryItem: { id: true } }
|
|
48
|
+
});
|
|
49
|
+
const inventoryItemGid = result?.productVariant?.inventoryItem?.id;
|
|
50
|
+
if (!inventoryItemGid) {
|
|
51
|
+
throw new import_errors.CliError(`Could not resolve inventory item for variant: ${variantId}`, 2);
|
|
52
|
+
}
|
|
53
|
+
return inventoryItemGid;
|
|
54
|
+
};
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
resolveInventoryItemId
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=resolveInventoryItemId.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type CommandContext } from '../../router';
|
|
2
|
+
export declare const upsertProductVariants: ({ ctx, productId, input, allowPartialUpdates, strategy, }: {
|
|
3
|
+
ctx: CommandContext;
|
|
4
|
+
productId: string | undefined;
|
|
5
|
+
input: any;
|
|
6
|
+
allowPartialUpdates: boolean;
|
|
7
|
+
strategy: string | undefined;
|
|
8
|
+
}) => Promise<any>;
|
|
@@ -0,0 +1,110 @@
|
|
|
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 upsert_exports = {};
|
|
20
|
+
__export(upsert_exports, {
|
|
21
|
+
upsertProductVariants: () => upsertProductVariants
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(upsert_exports);
|
|
24
|
+
var import_errors = require("../../errors");
|
|
25
|
+
var import_gid = require("../../gid");
|
|
26
|
+
var import_output = require("../../output");
|
|
27
|
+
var import_router = require("../../router");
|
|
28
|
+
var import_userErrors = require("../../userErrors");
|
|
29
|
+
const requireProductId = (id) => {
|
|
30
|
+
if (!id) throw new import_errors.CliError("Missing --product-id", 2);
|
|
31
|
+
return (0, import_gid.coerceGid)(id, "Product");
|
|
32
|
+
};
|
|
33
|
+
const requireVariantsInput = (input) => {
|
|
34
|
+
if (Array.isArray(input)) return { variants: input, extra: {} };
|
|
35
|
+
if (input && typeof input === "object" && Array.isArray(input.variants)) {
|
|
36
|
+
const { variants, ...extra } = input;
|
|
37
|
+
return { variants, extra };
|
|
38
|
+
}
|
|
39
|
+
throw new import_errors.CliError("Missing variants input: pass --input as an array or { variants: [...] }", 2);
|
|
40
|
+
};
|
|
41
|
+
const upsertProductVariants = async ({
|
|
42
|
+
ctx,
|
|
43
|
+
productId,
|
|
44
|
+
input,
|
|
45
|
+
allowPartialUpdates,
|
|
46
|
+
strategy
|
|
47
|
+
}) => {
|
|
48
|
+
const resolvedProductId = requireProductId(productId);
|
|
49
|
+
const { variants, extra } = requireVariantsInput(input);
|
|
50
|
+
if (variants.length === 0) throw new import_errors.CliError("variants must include at least one item", 2);
|
|
51
|
+
const toCreate = variants.filter((v) => !v?.id);
|
|
52
|
+
const toUpdate = variants.filter((v) => Boolean(v?.id));
|
|
53
|
+
const createdIds = [];
|
|
54
|
+
const updatedIds = [];
|
|
55
|
+
const out = {};
|
|
56
|
+
if (toCreate.length > 0) {
|
|
57
|
+
const result = await (0, import_router.runMutation)(ctx, {
|
|
58
|
+
productVariantsBulkCreate: {
|
|
59
|
+
__args: {
|
|
60
|
+
productId: resolvedProductId,
|
|
61
|
+
variants: toCreate,
|
|
62
|
+
...extra.media ? { media: extra.media } : {},
|
|
63
|
+
...strategy ? { strategy } : extra.strategy ? { strategy: extra.strategy } : {}
|
|
64
|
+
},
|
|
65
|
+
productVariants: { id: true },
|
|
66
|
+
userErrors: { field: true, message: true, code: true }
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
if (result === void 0) return void 0;
|
|
70
|
+
(0, import_userErrors.maybeFailOnUserErrors)({
|
|
71
|
+
payload: result.productVariantsBulkCreate,
|
|
72
|
+
failOnUserErrors: ctx.failOnUserErrors
|
|
73
|
+
});
|
|
74
|
+
out.created = result.productVariantsBulkCreate;
|
|
75
|
+
for (const v of result.productVariantsBulkCreate?.productVariants ?? []) createdIds.push(v?.id);
|
|
76
|
+
}
|
|
77
|
+
if (toUpdate.length > 0) {
|
|
78
|
+
const result = await (0, import_router.runMutation)(ctx, {
|
|
79
|
+
productVariantsBulkUpdate: {
|
|
80
|
+
__args: {
|
|
81
|
+
productId: resolvedProductId,
|
|
82
|
+
variants: toUpdate,
|
|
83
|
+
allowPartialUpdates,
|
|
84
|
+
...extra.media ? { media: extra.media } : {}
|
|
85
|
+
},
|
|
86
|
+
productVariants: { id: true },
|
|
87
|
+
userErrors: { field: true, message: true, code: true }
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
if (result === void 0) return void 0;
|
|
91
|
+
(0, import_userErrors.maybeFailOnUserErrors)({
|
|
92
|
+
payload: result.productVariantsBulkUpdate,
|
|
93
|
+
failOnUserErrors: ctx.failOnUserErrors
|
|
94
|
+
});
|
|
95
|
+
out.updated = result.productVariantsBulkUpdate;
|
|
96
|
+
for (const v of result.productVariantsBulkUpdate?.productVariants ?? []) updatedIds.push(v?.id);
|
|
97
|
+
}
|
|
98
|
+
if (ctx.quiet) {
|
|
99
|
+
(0, import_output.printIds)([...createdIds, ...updatedIds]);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (toCreate.length > 0 && toUpdate.length === 0) return out.created;
|
|
103
|
+
if (toUpdate.length > 0 && toCreate.length === 0) return out.updated;
|
|
104
|
+
return out;
|
|
105
|
+
};
|
|
106
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
107
|
+
0 && (module.exports = {
|
|
108
|
+
upsertProductVariants
|
|
109
|
+
});
|
|
110
|
+
//# sourceMappingURL=upsert.js.map
|
|
@@ -0,0 +1,94 @@
|
|
|
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 metafieldsUpsert_exports = {};
|
|
20
|
+
__export(metafieldsUpsert_exports, {
|
|
21
|
+
metafieldsUpsert: () => metafieldsUpsert
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(metafieldsUpsert_exports);
|
|
24
|
+
var import_errors = require("../../errors");
|
|
25
|
+
var import_gid = require("../../gid");
|
|
26
|
+
var import_output = require("../../output");
|
|
27
|
+
var import_router = require("../../router");
|
|
28
|
+
var import_userErrors = require("../../userErrors");
|
|
29
|
+
const requireProductId = (id) => {
|
|
30
|
+
if (!id) throw new import_errors.CliError("Missing --id", 2);
|
|
31
|
+
return (0, import_gid.coerceGid)(id, "Product");
|
|
32
|
+
};
|
|
33
|
+
const asArray = (value) => {
|
|
34
|
+
if (Array.isArray(value)) return value;
|
|
35
|
+
if (value && Array.isArray(value.metafields)) return value.metafields;
|
|
36
|
+
if (value && typeof value === "object") return [value];
|
|
37
|
+
return [];
|
|
38
|
+
};
|
|
39
|
+
const chunk = (items, size) => {
|
|
40
|
+
const out = [];
|
|
41
|
+
for (let i = 0; i < items.length; i += size) out.push(items.slice(i, i + size));
|
|
42
|
+
return out;
|
|
43
|
+
};
|
|
44
|
+
const metafieldsUpsert = async ({
|
|
45
|
+
ctx,
|
|
46
|
+
id,
|
|
47
|
+
input
|
|
48
|
+
}) => {
|
|
49
|
+
const ownerId = requireProductId(id);
|
|
50
|
+
const items = asArray(input);
|
|
51
|
+
if (items.length === 0) throw new import_errors.CliError("Missing metafield input: pass --input/--set/--set-json", 2);
|
|
52
|
+
const normalized = items.map((m) => {
|
|
53
|
+
if (!m || typeof m !== "object") throw new import_errors.CliError("Metafield inputs must be objects", 2);
|
|
54
|
+
const { key, namespace, type, value, compareDigest } = m;
|
|
55
|
+
if (!key) throw new import_errors.CliError("Metafield input missing key", 2);
|
|
56
|
+
if (value === void 0) throw new import_errors.CliError("Metafield input missing value", 2);
|
|
57
|
+
return {
|
|
58
|
+
ownerId,
|
|
59
|
+
key,
|
|
60
|
+
namespace,
|
|
61
|
+
type,
|
|
62
|
+
value: String(value),
|
|
63
|
+
compareDigest
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
const payloads = [];
|
|
67
|
+
const ids = [];
|
|
68
|
+
for (const group of chunk(normalized, 25)) {
|
|
69
|
+
const result = await (0, import_router.runMutation)(ctx, {
|
|
70
|
+
metafieldsSet: {
|
|
71
|
+
__args: { metafields: group },
|
|
72
|
+
metafields: { id: true },
|
|
73
|
+
userErrors: { field: true, message: true, elementIndex: true, code: true }
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
if (result === void 0) return void 0;
|
|
77
|
+
(0, import_userErrors.maybeFailOnUserErrors)({
|
|
78
|
+
payload: result.metafieldsSet,
|
|
79
|
+
failOnUserErrors: ctx.failOnUserErrors
|
|
80
|
+
});
|
|
81
|
+
payloads.push(result.metafieldsSet);
|
|
82
|
+
for (const mf of result.metafieldsSet?.metafields ?? []) ids.push(mf?.id);
|
|
83
|
+
}
|
|
84
|
+
if (ctx.quiet) {
|
|
85
|
+
(0, import_output.printIds)(ids);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
return payloads.length === 1 ? payloads[0] : payloads;
|
|
89
|
+
};
|
|
90
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
91
|
+
0 && (module.exports = {
|
|
92
|
+
metafieldsUpsert
|
|
93
|
+
});
|
|
94
|
+
//# sourceMappingURL=metafieldsUpsert.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type CommandContext } from '../../router';
|
|
2
|
+
export declare const parsePublishDate: ({ at, now, }: {
|
|
3
|
+
at: string | undefined;
|
|
4
|
+
now: boolean | undefined;
|
|
5
|
+
}) => string | undefined;
|
|
6
|
+
export declare const resolvePublicationIds: ({ ctx, publicationIds, publicationNames, }: {
|
|
7
|
+
ctx: CommandContext;
|
|
8
|
+
publicationIds: string[];
|
|
9
|
+
publicationNames: string[];
|
|
10
|
+
}) => Promise<string[]>;
|
|
11
|
+
export declare const publishProduct: ({ ctx, id, publicationIds, publishDate, }: {
|
|
12
|
+
ctx: CommandContext;
|
|
13
|
+
id: string | undefined;
|
|
14
|
+
publicationIds: string[];
|
|
15
|
+
publishDate?: string;
|
|
16
|
+
}) => Promise<any>;
|
|
17
|
+
export declare const unpublishProduct: ({ ctx, id, publicationIds, }: {
|
|
18
|
+
ctx: CommandContext;
|
|
19
|
+
id: string | undefined;
|
|
20
|
+
publicationIds: string[];
|
|
21
|
+
}) => Promise<any>;
|