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,336 @@
|
|
|
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 webhooks_exports = {};
|
|
20
|
+
__export(webhooks_exports, {
|
|
21
|
+
runWebhooks: () => runWebhooks
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(webhooks_exports);
|
|
24
|
+
var import_errors = require("../errors");
|
|
25
|
+
var import_input = require("../input");
|
|
26
|
+
var import_output = require("../output");
|
|
27
|
+
var import_router = require("../router");
|
|
28
|
+
var import_select = require("../selection/select");
|
|
29
|
+
var import_userErrors = require("../userErrors");
|
|
30
|
+
var import_shared = require("./_shared");
|
|
31
|
+
const webhookSummarySelection = {
|
|
32
|
+
id: true,
|
|
33
|
+
topic: true,
|
|
34
|
+
uri: true,
|
|
35
|
+
format: true,
|
|
36
|
+
createdAt: true,
|
|
37
|
+
updatedAt: true
|
|
38
|
+
};
|
|
39
|
+
const webhookFullSelection = {
|
|
40
|
+
...webhookSummarySelection,
|
|
41
|
+
filter: true,
|
|
42
|
+
includeFields: true,
|
|
43
|
+
metafieldNamespaces: true
|
|
44
|
+
};
|
|
45
|
+
const getWebhookSelection = (view) => {
|
|
46
|
+
if (view === "ids") return { id: true };
|
|
47
|
+
if (view === "full") return webhookFullSelection;
|
|
48
|
+
if (view === "raw") return {};
|
|
49
|
+
return webhookSummarySelection;
|
|
50
|
+
};
|
|
51
|
+
const runWebhooks = async ({
|
|
52
|
+
ctx,
|
|
53
|
+
verb,
|
|
54
|
+
argv
|
|
55
|
+
}) => {
|
|
56
|
+
if (argv.includes("--help") || argv.includes("-h")) {
|
|
57
|
+
console.log(
|
|
58
|
+
[
|
|
59
|
+
"Usage:",
|
|
60
|
+
" shop webhooks <verb> [flags]",
|
|
61
|
+
"",
|
|
62
|
+
"Verbs:",
|
|
63
|
+
" create|get|list|update|delete|count",
|
|
64
|
+
" pubsub-create|pubsub-update",
|
|
65
|
+
" event-bridge-create|event-bridge-update",
|
|
66
|
+
"",
|
|
67
|
+
"Common output flags:",
|
|
68
|
+
" --view summary|ids|full|raw",
|
|
69
|
+
" --select <path> (repeatable; dot paths; adds to base view selection)",
|
|
70
|
+
" --selection <graphql> (selection override; can be @file.gql)"
|
|
71
|
+
].join("\n")
|
|
72
|
+
);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (verb === "count") {
|
|
76
|
+
const args = (0, import_router.parseStandardArgs)({
|
|
77
|
+
argv,
|
|
78
|
+
extraOptions: { limit: { type: "string" } }
|
|
79
|
+
});
|
|
80
|
+
const query = args.query;
|
|
81
|
+
const limitRaw = args.limit;
|
|
82
|
+
const limit = limitRaw === void 0 || limitRaw === null || limitRaw === "" ? void 0 : Number(limitRaw);
|
|
83
|
+
if (limit !== void 0 && (!Number.isFinite(limit) || limit <= 0)) {
|
|
84
|
+
throw new import_errors.CliError("--limit must be a positive number", 2);
|
|
85
|
+
}
|
|
86
|
+
const result = await (0, import_router.runQuery)(ctx, {
|
|
87
|
+
webhookSubscriptionsCount: {
|
|
88
|
+
__args: {
|
|
89
|
+
...query ? { query } : {},
|
|
90
|
+
...limit !== void 0 ? { limit: Math.floor(limit) } : {}
|
|
91
|
+
},
|
|
92
|
+
count: true,
|
|
93
|
+
precision: true
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
if (result === void 0) return;
|
|
97
|
+
if (ctx.quiet) return console.log(result.webhookSubscriptionsCount?.count ?? "");
|
|
98
|
+
(0, import_output.printJson)(result.webhookSubscriptionsCount, ctx.format !== "raw");
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (verb === "event-bridge-create") {
|
|
102
|
+
const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { topic: { type: "string" } } });
|
|
103
|
+
const topic = args.topic;
|
|
104
|
+
if (!topic) throw new import_errors.CliError("Missing --topic", 2);
|
|
105
|
+
const built = (0, import_input.buildInput)({
|
|
106
|
+
inputArg: args.input,
|
|
107
|
+
setArgs: args.set,
|
|
108
|
+
setJsonArgs: args["set-json"]
|
|
109
|
+
});
|
|
110
|
+
if (!built.used) throw new import_errors.CliError("Missing --input or --set/--set-json (webhookSubscription)", 2);
|
|
111
|
+
const result = await (0, import_router.runMutation)(ctx, {
|
|
112
|
+
eventBridgeWebhookSubscriptionCreate: {
|
|
113
|
+
__args: { topic, webhookSubscription: built.input },
|
|
114
|
+
webhookSubscription: webhookSummarySelection,
|
|
115
|
+
userErrors: { field: true, message: true }
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
if (result === void 0) return;
|
|
119
|
+
(0, import_userErrors.maybeFailOnUserErrors)({
|
|
120
|
+
payload: result.eventBridgeWebhookSubscriptionCreate,
|
|
121
|
+
failOnUserErrors: ctx.failOnUserErrors
|
|
122
|
+
});
|
|
123
|
+
if (ctx.quiet) return console.log(result.eventBridgeWebhookSubscriptionCreate?.webhookSubscription?.id ?? "");
|
|
124
|
+
(0, import_output.printJson)(result.eventBridgeWebhookSubscriptionCreate, ctx.format !== "raw");
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (verb === "event-bridge-update") {
|
|
128
|
+
const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
|
|
129
|
+
const id = (0, import_shared.requireId)(args.id, "WebhookSubscription");
|
|
130
|
+
const built = (0, import_input.buildInput)({
|
|
131
|
+
inputArg: args.input,
|
|
132
|
+
setArgs: args.set,
|
|
133
|
+
setJsonArgs: args["set-json"]
|
|
134
|
+
});
|
|
135
|
+
if (!built.used) throw new import_errors.CliError("Missing --input or --set/--set-json (webhookSubscription)", 2);
|
|
136
|
+
const result = await (0, import_router.runMutation)(ctx, {
|
|
137
|
+
eventBridgeWebhookSubscriptionUpdate: {
|
|
138
|
+
__args: { id, webhookSubscription: built.input },
|
|
139
|
+
webhookSubscription: webhookSummarySelection,
|
|
140
|
+
userErrors: { field: true, message: true }
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
if (result === void 0) return;
|
|
144
|
+
(0, import_userErrors.maybeFailOnUserErrors)({
|
|
145
|
+
payload: result.eventBridgeWebhookSubscriptionUpdate,
|
|
146
|
+
failOnUserErrors: ctx.failOnUserErrors
|
|
147
|
+
});
|
|
148
|
+
if (ctx.quiet) return console.log(result.eventBridgeWebhookSubscriptionUpdate?.webhookSubscription?.id ?? "");
|
|
149
|
+
(0, import_output.printJson)(result.eventBridgeWebhookSubscriptionUpdate, ctx.format !== "raw");
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (verb === "get") {
|
|
153
|
+
const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
|
|
154
|
+
const id = (0, import_shared.requireId)(args.id, "WebhookSubscription");
|
|
155
|
+
const selection = (0, import_select.resolveSelection)({
|
|
156
|
+
resource: "webhooks",
|
|
157
|
+
view: ctx.view,
|
|
158
|
+
baseSelection: getWebhookSelection(ctx.view),
|
|
159
|
+
select: args.select,
|
|
160
|
+
selection: args.selection,
|
|
161
|
+
include: args.include,
|
|
162
|
+
ensureId: ctx.quiet
|
|
163
|
+
});
|
|
164
|
+
const result = await (0, import_router.runQuery)(ctx, { webhookSubscription: { __args: { id }, ...selection } });
|
|
165
|
+
if (result === void 0) return;
|
|
166
|
+
(0, import_output.printNode)({ node: result.webhookSubscription, format: ctx.format, quiet: ctx.quiet });
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (verb === "list") {
|
|
170
|
+
const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
|
|
171
|
+
const first = (0, import_shared.parseFirst)(args.first);
|
|
172
|
+
const after = args.after;
|
|
173
|
+
const query = args.query;
|
|
174
|
+
const reverse = args.reverse;
|
|
175
|
+
const sortKey = args.sort;
|
|
176
|
+
const nodeSelection = (0, import_select.resolveSelection)({
|
|
177
|
+
resource: "webhooks",
|
|
178
|
+
view: ctx.view,
|
|
179
|
+
baseSelection: getWebhookSelection(ctx.view),
|
|
180
|
+
select: args.select,
|
|
181
|
+
selection: args.selection,
|
|
182
|
+
include: args.include,
|
|
183
|
+
ensureId: ctx.quiet
|
|
184
|
+
});
|
|
185
|
+
const result = await (0, import_router.runQuery)(ctx, {
|
|
186
|
+
webhookSubscriptions: {
|
|
187
|
+
__args: { first, after, query, reverse, sortKey },
|
|
188
|
+
pageInfo: { hasNextPage: true, endCursor: true },
|
|
189
|
+
nodes: nodeSelection
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
if (result === void 0) return;
|
|
193
|
+
(0, import_output.printConnection)({
|
|
194
|
+
connection: result.webhookSubscriptions,
|
|
195
|
+
format: ctx.format,
|
|
196
|
+
quiet: ctx.quiet,
|
|
197
|
+
nextPageArgs: (0, import_shared.buildListNextPageArgs)("webhooks", { first, query, sort: sortKey, reverse })
|
|
198
|
+
});
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
if (verb === "pubsub-create") {
|
|
202
|
+
const args = (0, import_router.parseStandardArgs)({
|
|
203
|
+
argv,
|
|
204
|
+
extraOptions: { topic: { type: "string" }, "pubsub-project": { type: "string" }, "pubsub-topic": { type: "string" } }
|
|
205
|
+
});
|
|
206
|
+
const topic = args.topic;
|
|
207
|
+
if (!topic) throw new import_errors.CliError("Missing --topic", 2);
|
|
208
|
+
const built = (0, import_input.buildInput)({
|
|
209
|
+
inputArg: args.input,
|
|
210
|
+
setArgs: args.set,
|
|
211
|
+
setJsonArgs: args["set-json"]
|
|
212
|
+
});
|
|
213
|
+
const input = built.used ? built.input : {};
|
|
214
|
+
const pubSubProject = args["pubsub-project"] ?? input.pubSubProject;
|
|
215
|
+
const pubSubTopic = args["pubsub-topic"] ?? input.pubSubTopic;
|
|
216
|
+
if (!pubSubProject) throw new import_errors.CliError("Missing --pubsub-project", 2);
|
|
217
|
+
if (!pubSubTopic) throw new import_errors.CliError("Missing --pubsub-topic", 2);
|
|
218
|
+
const webhookSubscription = { ...input, pubSubProject, pubSubTopic };
|
|
219
|
+
const result = await (0, import_router.runMutation)(ctx, {
|
|
220
|
+
pubSubWebhookSubscriptionCreate: {
|
|
221
|
+
__args: { topic, webhookSubscription },
|
|
222
|
+
webhookSubscription: webhookSummarySelection,
|
|
223
|
+
userErrors: { field: true, message: true, code: true }
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
if (result === void 0) return;
|
|
227
|
+
(0, import_userErrors.maybeFailOnUserErrors)({
|
|
228
|
+
payload: result.pubSubWebhookSubscriptionCreate,
|
|
229
|
+
failOnUserErrors: ctx.failOnUserErrors
|
|
230
|
+
});
|
|
231
|
+
if (ctx.quiet) return console.log(result.pubSubWebhookSubscriptionCreate?.webhookSubscription?.id ?? "");
|
|
232
|
+
(0, import_output.printJson)(result.pubSubWebhookSubscriptionCreate, ctx.format !== "raw");
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
if (verb === "pubsub-update") {
|
|
236
|
+
const args = (0, import_router.parseStandardArgs)({
|
|
237
|
+
argv,
|
|
238
|
+
extraOptions: { "pubsub-project": { type: "string" }, "pubsub-topic": { type: "string" } }
|
|
239
|
+
});
|
|
240
|
+
const id = (0, import_shared.requireId)(args.id, "WebhookSubscription");
|
|
241
|
+
const built = (0, import_input.buildInput)({
|
|
242
|
+
inputArg: args.input,
|
|
243
|
+
setArgs: args.set,
|
|
244
|
+
setJsonArgs: args["set-json"]
|
|
245
|
+
});
|
|
246
|
+
const input = built.used ? built.input : {};
|
|
247
|
+
const pubSubProject = args["pubsub-project"] ?? input.pubSubProject;
|
|
248
|
+
const pubSubTopic = args["pubsub-topic"] ?? input.pubSubTopic;
|
|
249
|
+
if (!pubSubProject) throw new import_errors.CliError("Missing --pubsub-project", 2);
|
|
250
|
+
if (!pubSubTopic) throw new import_errors.CliError("Missing --pubsub-topic", 2);
|
|
251
|
+
const webhookSubscription = { ...input, pubSubProject, pubSubTopic };
|
|
252
|
+
const result = await (0, import_router.runMutation)(ctx, {
|
|
253
|
+
pubSubWebhookSubscriptionUpdate: {
|
|
254
|
+
__args: { id, webhookSubscription },
|
|
255
|
+
webhookSubscription: webhookSummarySelection,
|
|
256
|
+
userErrors: { field: true, message: true, code: true }
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
if (result === void 0) return;
|
|
260
|
+
(0, import_userErrors.maybeFailOnUserErrors)({
|
|
261
|
+
payload: result.pubSubWebhookSubscriptionUpdate,
|
|
262
|
+
failOnUserErrors: ctx.failOnUserErrors
|
|
263
|
+
});
|
|
264
|
+
if (ctx.quiet) return console.log(result.pubSubWebhookSubscriptionUpdate?.webhookSubscription?.id ?? "");
|
|
265
|
+
(0, import_output.printJson)(result.pubSubWebhookSubscriptionUpdate, ctx.format !== "raw");
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
if (verb === "create") {
|
|
269
|
+
const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: { topic: { type: "string" } } });
|
|
270
|
+
const topic = args.topic;
|
|
271
|
+
if (!topic) throw new import_errors.CliError("Missing --topic", 2);
|
|
272
|
+
const built = (0, import_input.buildInput)({
|
|
273
|
+
inputArg: args.input,
|
|
274
|
+
setArgs: args.set,
|
|
275
|
+
setJsonArgs: args["set-json"]
|
|
276
|
+
});
|
|
277
|
+
if (!built.used) throw new import_errors.CliError("Missing --input or --set/--set-json (webhookSubscription)", 2);
|
|
278
|
+
const result = await (0, import_router.runMutation)(ctx, {
|
|
279
|
+
webhookSubscriptionCreate: {
|
|
280
|
+
__args: { topic, webhookSubscription: built.input },
|
|
281
|
+
webhookSubscription: webhookSummarySelection,
|
|
282
|
+
userErrors: { field: true, message: true }
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
if (result === void 0) return;
|
|
286
|
+
(0, import_userErrors.maybeFailOnUserErrors)({ payload: result.webhookSubscriptionCreate, failOnUserErrors: ctx.failOnUserErrors });
|
|
287
|
+
if (ctx.quiet) return console.log(result.webhookSubscriptionCreate?.webhookSubscription?.id ?? "");
|
|
288
|
+
(0, import_output.printJson)(result.webhookSubscriptionCreate, ctx.format !== "raw");
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
if (verb === "update") {
|
|
292
|
+
const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
|
|
293
|
+
const id = (0, import_shared.requireId)(args.id, "WebhookSubscription");
|
|
294
|
+
const built = (0, import_input.buildInput)({
|
|
295
|
+
inputArg: args.input,
|
|
296
|
+
setArgs: args.set,
|
|
297
|
+
setJsonArgs: args["set-json"]
|
|
298
|
+
});
|
|
299
|
+
if (!built.used) throw new import_errors.CliError("Missing --input or --set/--set-json (webhookSubscription)", 2);
|
|
300
|
+
const result = await (0, import_router.runMutation)(ctx, {
|
|
301
|
+
webhookSubscriptionUpdate: {
|
|
302
|
+
__args: { id, webhookSubscription: built.input },
|
|
303
|
+
webhookSubscription: webhookSummarySelection,
|
|
304
|
+
userErrors: { field: true, message: true }
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
if (result === void 0) return;
|
|
308
|
+
(0, import_userErrors.maybeFailOnUserErrors)({ payload: result.webhookSubscriptionUpdate, failOnUserErrors: ctx.failOnUserErrors });
|
|
309
|
+
if (ctx.quiet) return console.log(result.webhookSubscriptionUpdate?.webhookSubscription?.id ?? "");
|
|
310
|
+
(0, import_output.printJson)(result.webhookSubscriptionUpdate, ctx.format !== "raw");
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
if (verb === "delete") {
|
|
314
|
+
const args = (0, import_router.parseStandardArgs)({ argv, extraOptions: {} });
|
|
315
|
+
const id = (0, import_shared.requireId)(args.id, "WebhookSubscription");
|
|
316
|
+
if (!args.yes) throw new import_errors.CliError("Refusing to delete without --yes", 2);
|
|
317
|
+
const result = await (0, import_router.runMutation)(ctx, {
|
|
318
|
+
webhookSubscriptionDelete: {
|
|
319
|
+
__args: { id },
|
|
320
|
+
deletedWebhookSubscriptionId: true,
|
|
321
|
+
userErrors: { field: true, message: true }
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
if (result === void 0) return;
|
|
325
|
+
(0, import_userErrors.maybeFailOnUserErrors)({ payload: result.webhookSubscriptionDelete, failOnUserErrors: ctx.failOnUserErrors });
|
|
326
|
+
if (ctx.quiet) return console.log(result.webhookSubscriptionDelete?.deletedWebhookSubscriptionId ?? "");
|
|
327
|
+
(0, import_output.printJson)(result.webhookSubscriptionDelete, ctx.format !== "raw");
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
throw new import_errors.CliError(`Unknown verb for webhooks: ${verb}`, 2);
|
|
331
|
+
};
|
|
332
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
333
|
+
0 && (module.exports = {
|
|
334
|
+
runWebhooks
|
|
335
|
+
});
|
|
336
|
+
//# sourceMappingURL=webhooks.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type CommandContext } from '../../router';
|
|
2
|
+
export type StagedUploadResource = 'FILE' | 'IMAGE' | 'VIDEO' | 'MODEL_3D';
|
|
3
|
+
export type LocalFileForStagedUpload = {
|
|
4
|
+
filePath: string;
|
|
5
|
+
filename: string;
|
|
6
|
+
mimeType: string;
|
|
7
|
+
resource: StagedUploadResource;
|
|
8
|
+
fileSize: number;
|
|
9
|
+
};
|
|
10
|
+
export type StagedUploadTarget = {
|
|
11
|
+
url: string;
|
|
12
|
+
resourceUrl: string;
|
|
13
|
+
parameters: Array<{
|
|
14
|
+
name: string;
|
|
15
|
+
value: string;
|
|
16
|
+
}>;
|
|
17
|
+
};
|
|
18
|
+
export declare const buildLocalFilesForStagedUpload: ({ filePaths, mimeType, resource, }: {
|
|
19
|
+
filePaths: string[];
|
|
20
|
+
mimeType?: string;
|
|
21
|
+
resource?: StagedUploadResource;
|
|
22
|
+
}) => Promise<LocalFileForStagedUpload[]>;
|
|
23
|
+
export declare const stagedUploadsCreate: (ctx: CommandContext, localFiles: LocalFileForStagedUpload[]) => Promise<StagedUploadTarget[] | undefined>;
|
|
24
|
+
export declare const uploadToStagedTarget: ({ target, localFile, }: {
|
|
25
|
+
target: StagedUploadTarget;
|
|
26
|
+
localFile: LocalFileForStagedUpload;
|
|
27
|
+
}) => Promise<void>;
|
|
28
|
+
export declare const stagedUploadLocalFiles: (ctx: CommandContext, localFiles: LocalFileForStagedUpload[]) => Promise<StagedUploadTarget[] | undefined>;
|
|
@@ -0,0 +1,227 @@
|
|
|
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 stagedUploads_exports = {};
|
|
30
|
+
__export(stagedUploads_exports, {
|
|
31
|
+
buildLocalFilesForStagedUpload: () => buildLocalFilesForStagedUpload,
|
|
32
|
+
stagedUploadLocalFiles: () => stagedUploadLocalFiles,
|
|
33
|
+
stagedUploadsCreate: () => stagedUploadsCreate,
|
|
34
|
+
uploadToStagedTarget: () => uploadToStagedTarget
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(stagedUploads_exports);
|
|
37
|
+
var import_node_fs = require("node:fs");
|
|
38
|
+
var import_node_path = __toESM(require("node:path"));
|
|
39
|
+
var import_node_child_process = require("node:child_process");
|
|
40
|
+
var import_mime_types = require("mime-types");
|
|
41
|
+
var import_errors = require("../../errors");
|
|
42
|
+
var import_router = require("../../router");
|
|
43
|
+
var import_userErrors = require("../../userErrors");
|
|
44
|
+
const mimeTypeFromFilename = (filename) => {
|
|
45
|
+
const mimeType = (0, import_mime_types.lookup)(filename);
|
|
46
|
+
if (typeof mimeType === "string") return mimeType;
|
|
47
|
+
return void 0;
|
|
48
|
+
};
|
|
49
|
+
const inferStagedUploadResource = ({
|
|
50
|
+
filename,
|
|
51
|
+
mimeType
|
|
52
|
+
}) => {
|
|
53
|
+
if (mimeType.startsWith("image/")) return "IMAGE";
|
|
54
|
+
if (mimeType.startsWith("video/")) return "VIDEO";
|
|
55
|
+
const ext = import_node_path.default.extname(filename).toLowerCase();
|
|
56
|
+
if (mimeType.startsWith("model/") || ext === ".glb" || ext === ".gltf" || ext === ".usdz") {
|
|
57
|
+
return "MODEL_3D";
|
|
58
|
+
}
|
|
59
|
+
return "FILE";
|
|
60
|
+
};
|
|
61
|
+
const sniffMimeTypeFromFile = async (filePath) => {
|
|
62
|
+
try {
|
|
63
|
+
const mod = await import("file-type");
|
|
64
|
+
const result = await mod.fileTypeFromFile(filePath);
|
|
65
|
+
return result?.mime;
|
|
66
|
+
} catch {
|
|
67
|
+
return void 0;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const resolveMimeType = async ({
|
|
71
|
+
filePath,
|
|
72
|
+
filename,
|
|
73
|
+
forcedMimeType
|
|
74
|
+
}) => {
|
|
75
|
+
const forced = typeof forcedMimeType === "string" ? forcedMimeType.trim() : "";
|
|
76
|
+
if (forced) return forced;
|
|
77
|
+
const sniffed = await sniffMimeTypeFromFile(filePath);
|
|
78
|
+
if (sniffed) return sniffed;
|
|
79
|
+
const byExt = mimeTypeFromFilename(filename);
|
|
80
|
+
if (byExt) return byExt;
|
|
81
|
+
throw new import_errors.CliError(
|
|
82
|
+
`Unable to determine MIME type for ${filename}. Pass --mime-type <mime>.`,
|
|
83
|
+
2
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
const buildLocalFilesForStagedUpload = async ({
|
|
87
|
+
filePaths,
|
|
88
|
+
mimeType,
|
|
89
|
+
resource
|
|
90
|
+
}) => {
|
|
91
|
+
if (filePaths.length === 0) return [];
|
|
92
|
+
return Promise.all(filePaths.map(async (filePath) => {
|
|
93
|
+
const stats = (0, import_node_fs.statSync)(filePath);
|
|
94
|
+
if (!stats.isFile()) throw new import_errors.CliError(`Not a file: ${filePath}`, 2);
|
|
95
|
+
const filename = import_node_path.default.basename(filePath);
|
|
96
|
+
const resolvedMimeType = await resolveMimeType({ filePath, filename, forcedMimeType: mimeType });
|
|
97
|
+
const inferredResource = inferStagedUploadResource({ filename, mimeType: resolvedMimeType });
|
|
98
|
+
return {
|
|
99
|
+
filePath,
|
|
100
|
+
filename,
|
|
101
|
+
mimeType: resolvedMimeType,
|
|
102
|
+
resource: resource ?? inferredResource,
|
|
103
|
+
fileSize: stats.size
|
|
104
|
+
};
|
|
105
|
+
}));
|
|
106
|
+
};
|
|
107
|
+
const stagedUploadsCreate = async (ctx, localFiles) => {
|
|
108
|
+
const input = localFiles.map((f) => ({
|
|
109
|
+
filename: f.filename,
|
|
110
|
+
mimeType: f.mimeType,
|
|
111
|
+
resource: f.resource,
|
|
112
|
+
fileSize: String(f.fileSize),
|
|
113
|
+
httpMethod: "POST"
|
|
114
|
+
}));
|
|
115
|
+
if (ctx.dryRun) {
|
|
116
|
+
await (0, import_router.runMutation)(ctx, {
|
|
117
|
+
stagedUploadsCreate: {
|
|
118
|
+
__args: { input },
|
|
119
|
+
stagedTargets: {
|
|
120
|
+
url: true,
|
|
121
|
+
resourceUrl: true,
|
|
122
|
+
parameters: { name: true, value: true }
|
|
123
|
+
},
|
|
124
|
+
userErrors: { field: true, message: true }
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
return localFiles.map((f, i) => ({
|
|
128
|
+
url: `https://example.invalid/staged-uploads/${i}`,
|
|
129
|
+
resourceUrl: `https://example.invalid/staged-resources/${encodeURIComponent(f.filename)}`,
|
|
130
|
+
parameters: []
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
const result = await (0, import_router.runMutation)(ctx, {
|
|
134
|
+
stagedUploadsCreate: {
|
|
135
|
+
__args: { input },
|
|
136
|
+
stagedTargets: {
|
|
137
|
+
url: true,
|
|
138
|
+
resourceUrl: true,
|
|
139
|
+
parameters: { name: true, value: true }
|
|
140
|
+
},
|
|
141
|
+
userErrors: { field: true, message: true }
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
if (result === void 0) return void 0;
|
|
145
|
+
(0, import_userErrors.maybeFailOnUserErrors)({
|
|
146
|
+
payload: result.stagedUploadsCreate,
|
|
147
|
+
failOnUserErrors: ctx.failOnUserErrors
|
|
148
|
+
});
|
|
149
|
+
const targets = result.stagedUploadsCreate?.stagedTargets ?? [];
|
|
150
|
+
if (!Array.isArray(targets) || targets.length !== localFiles.length) {
|
|
151
|
+
throw new import_errors.CliError(
|
|
152
|
+
`Expected ${localFiles.length} stagedTargets, got ${Array.isArray(targets) ? targets.length : "non-array"}`,
|
|
153
|
+
2
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
return targets.map((t) => ({
|
|
157
|
+
url: String(t.url ?? ""),
|
|
158
|
+
resourceUrl: String(t.resourceUrl ?? ""),
|
|
159
|
+
parameters: (t.parameters ?? []).map((p) => ({ name: p.name, value: p.value }))
|
|
160
|
+
}));
|
|
161
|
+
};
|
|
162
|
+
const uploadToStagedTarget = async ({
|
|
163
|
+
target,
|
|
164
|
+
localFile
|
|
165
|
+
}) => {
|
|
166
|
+
const args = ["--fail-with-body", "--silent", "--show-error", "-X", "POST"];
|
|
167
|
+
for (const p of target.parameters) {
|
|
168
|
+
args.push("--form-string", `${p.name}=${p.value}`);
|
|
169
|
+
}
|
|
170
|
+
args.push(
|
|
171
|
+
"--form",
|
|
172
|
+
`file=@${localFile.filePath};type=${localFile.mimeType};filename=${localFile.filename}`,
|
|
173
|
+
target.url
|
|
174
|
+
);
|
|
175
|
+
let child;
|
|
176
|
+
try {
|
|
177
|
+
child = (0, import_node_child_process.spawn)("curl", args, { stdio: ["ignore", "pipe", "pipe"] });
|
|
178
|
+
} catch (err) {
|
|
179
|
+
throw err;
|
|
180
|
+
}
|
|
181
|
+
let stdout = "";
|
|
182
|
+
let stderr = "";
|
|
183
|
+
child.stdout?.on("data", (chunk) => {
|
|
184
|
+
stdout += typeof chunk === "string" ? chunk : Buffer.from(chunk).toString("utf8");
|
|
185
|
+
});
|
|
186
|
+
child.stderr?.on("data", (chunk) => {
|
|
187
|
+
stderr += typeof chunk === "string" ? chunk : Buffer.from(chunk).toString("utf8");
|
|
188
|
+
});
|
|
189
|
+
const code = await new Promise((resolve, reject) => {
|
|
190
|
+
child.on("error", (err) => {
|
|
191
|
+
if (err && err.code === "ENOENT") {
|
|
192
|
+
reject(new import_errors.CliError("curl is required for streaming staged uploads (curl not found on PATH)", 2));
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
reject(err);
|
|
196
|
+
});
|
|
197
|
+
child.on("close", (c) => resolve(c ?? 1));
|
|
198
|
+
});
|
|
199
|
+
if (code === 0) return;
|
|
200
|
+
const trimmedErr = stderr.trim();
|
|
201
|
+
const trimmedOut = stdout.trim();
|
|
202
|
+
const details = trimmedErr || trimmedOut;
|
|
203
|
+
throw new import_errors.CliError(
|
|
204
|
+
`Staged upload failed for ${localFile.filename}: curl exited with code ${code}${details ? `
|
|
205
|
+
${details}` : ""}`,
|
|
206
|
+
2
|
|
207
|
+
);
|
|
208
|
+
};
|
|
209
|
+
const stagedUploadLocalFiles = async (ctx, localFiles) => {
|
|
210
|
+
const targets = await stagedUploadsCreate(ctx, localFiles);
|
|
211
|
+
if (targets === void 0) return void 0;
|
|
212
|
+
if (ctx.dryRun) return targets;
|
|
213
|
+
for (let i = 0; i < targets.length; i++) {
|
|
214
|
+
const target = targets[i];
|
|
215
|
+
const localFile = localFiles[i];
|
|
216
|
+
await uploadToStagedTarget({ target, localFile });
|
|
217
|
+
}
|
|
218
|
+
return targets;
|
|
219
|
+
};
|
|
220
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
221
|
+
0 && (module.exports = {
|
|
222
|
+
buildLocalFilesForStagedUpload,
|
|
223
|
+
stagedUploadLocalFiles,
|
|
224
|
+
stagedUploadsCreate,
|
|
225
|
+
uploadToStagedTarget
|
|
226
|
+
});
|
|
227
|
+
//# sourceMappingURL=stagedUploads.js.map
|
|
@@ -0,0 +1,65 @@
|
|
|
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 stdinFile_exports = {};
|
|
30
|
+
__export(stdinFile_exports, {
|
|
31
|
+
writeStdinToTempFile: () => writeStdinToTempFile
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(stdinFile_exports);
|
|
34
|
+
var import_node_fs = require("node:fs");
|
|
35
|
+
var import_promises = require("node:fs/promises");
|
|
36
|
+
var import_node_os = __toESM(require("node:os"));
|
|
37
|
+
var import_node_path = __toESM(require("node:path"));
|
|
38
|
+
var import_promises2 = require("node:stream/promises");
|
|
39
|
+
var import_errors = require("../../errors");
|
|
40
|
+
const safeBasename = (name) => name.replace(/[\\/]/g, "_");
|
|
41
|
+
const writeStdinToTempFile = async ({
|
|
42
|
+
filename,
|
|
43
|
+
stdin = process.stdin
|
|
44
|
+
}) => {
|
|
45
|
+
const raw = typeof filename === "string" ? filename.trim() : "";
|
|
46
|
+
if (!raw) throw new import_errors.CliError("Missing --filename (required with --file -)", 2);
|
|
47
|
+
const tempDir = await (0, import_promises.mkdtemp)(import_node_path.default.join(import_node_os.default.tmpdir(), "shop-cli-stdin-"));
|
|
48
|
+
const cleanup = async () => {
|
|
49
|
+
await (0, import_promises.rm)(tempDir, { recursive: true, force: true });
|
|
50
|
+
};
|
|
51
|
+
try {
|
|
52
|
+
const filePath = import_node_path.default.join(tempDir, safeBasename(raw) || "stdin");
|
|
53
|
+
const out = (0, import_node_fs.createWriteStream)(filePath);
|
|
54
|
+
await (0, import_promises2.pipeline)(stdin, out);
|
|
55
|
+
return { filePath, cleanup };
|
|
56
|
+
} catch (err) {
|
|
57
|
+
await cleanup();
|
|
58
|
+
throw err;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
62
|
+
0 && (module.exports = {
|
|
63
|
+
writeStdinToTempFile
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=stdinFile.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const inferFilenameFromUrl: (rawUrl: string) => string;
|
|
2
|
+
export type DownloadedUrlFile = {
|
|
3
|
+
url: string;
|
|
4
|
+
filePath: string;
|
|
5
|
+
filename: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const downloadUrlsToTempDir: ({ urls, filenameOverride, }: {
|
|
8
|
+
urls: string[];
|
|
9
|
+
filenameOverride?: string;
|
|
10
|
+
}) => Promise<{
|
|
11
|
+
tempDir: string;
|
|
12
|
+
files: DownloadedUrlFile[];
|
|
13
|
+
cleanup: () => Promise<void>;
|
|
14
|
+
}>;
|