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,301 @@
|
|
|
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 graphqlSelection_exports = {};
|
|
20
|
+
__export(graphqlSelection_exports, {
|
|
21
|
+
parseGraphqlSelectionArg: () => parseGraphqlSelectionArg
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(graphqlSelection_exports);
|
|
24
|
+
var import_node_fs = require("node:fs");
|
|
25
|
+
var import_errors = require("../errors");
|
|
26
|
+
const isNameStart = (ch) => /[A-Za-z_]/.test(ch);
|
|
27
|
+
const isNameContinue = (ch) => /[0-9A-Za-z_]/.test(ch);
|
|
28
|
+
const readSelectionSource = (arg) => {
|
|
29
|
+
if (arg.startsWith("@file:")) return (0, import_node_fs.readFileSync)(arg.slice("@file:".length), "utf8");
|
|
30
|
+
if (arg.startsWith("@")) return (0, import_node_fs.readFileSync)(arg.slice(1), "utf8");
|
|
31
|
+
return arg;
|
|
32
|
+
};
|
|
33
|
+
const tokenize = (src) => {
|
|
34
|
+
const tokens = [];
|
|
35
|
+
let i = 0;
|
|
36
|
+
const peek = () => src[i];
|
|
37
|
+
const next = () => src[i++];
|
|
38
|
+
const skipWhitespaceAndComments = () => {
|
|
39
|
+
while (i < src.length) {
|
|
40
|
+
const ch = peek();
|
|
41
|
+
if (!ch) return;
|
|
42
|
+
if (/\s/.test(ch)) {
|
|
43
|
+
i++;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (ch === ",") {
|
|
47
|
+
tokens.push({ type: "punct", value: "," });
|
|
48
|
+
i++;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (ch === "#") {
|
|
52
|
+
while (i < src.length && src[i] !== "\n") i++;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const readName = () => {
|
|
59
|
+
const start = i;
|
|
60
|
+
i++;
|
|
61
|
+
while (i < src.length && isNameContinue(src[i])) i++;
|
|
62
|
+
return src.slice(start, i);
|
|
63
|
+
};
|
|
64
|
+
const readString = () => {
|
|
65
|
+
const quote = next();
|
|
66
|
+
if (quote !== '"') throw new import_errors.CliError("Internal error: expected quote", 2);
|
|
67
|
+
let out = "";
|
|
68
|
+
while (i < src.length) {
|
|
69
|
+
const ch = next();
|
|
70
|
+
if (!ch) break;
|
|
71
|
+
if (ch === '"') return out;
|
|
72
|
+
if (ch === "\\") {
|
|
73
|
+
const esc = next();
|
|
74
|
+
if (!esc) throw new import_errors.CliError("Unterminated string literal", 2);
|
|
75
|
+
if (esc === '"' || esc === "\\" || esc === "/") out += esc;
|
|
76
|
+
else if (esc === "b") out += "\b";
|
|
77
|
+
else if (esc === "f") out += "\f";
|
|
78
|
+
else if (esc === "n") out += "\n";
|
|
79
|
+
else if (esc === "r") out += "\r";
|
|
80
|
+
else if (esc === "t") out += " ";
|
|
81
|
+
else if (esc === "u") {
|
|
82
|
+
const hex = src.slice(i, i + 4);
|
|
83
|
+
if (!/^[0-9A-Fa-f]{4}$/.test(hex)) throw new import_errors.CliError("Invalid unicode escape", 2);
|
|
84
|
+
out += String.fromCharCode(parseInt(hex, 16));
|
|
85
|
+
i += 4;
|
|
86
|
+
} else {
|
|
87
|
+
throw new import_errors.CliError(`Invalid escape sequence: \\${esc}`, 2);
|
|
88
|
+
}
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
out += ch;
|
|
92
|
+
}
|
|
93
|
+
throw new import_errors.CliError("Unterminated string literal", 2);
|
|
94
|
+
};
|
|
95
|
+
const readNumber = () => {
|
|
96
|
+
const start = i;
|
|
97
|
+
if (src[i] === "-") i++;
|
|
98
|
+
while (i < src.length && /[0-9]/.test(src[i])) i++;
|
|
99
|
+
if (src[i] === ".") {
|
|
100
|
+
i++;
|
|
101
|
+
while (i < src.length && /[0-9]/.test(src[i])) i++;
|
|
102
|
+
}
|
|
103
|
+
const raw = src.slice(start, i);
|
|
104
|
+
const n = Number(raw);
|
|
105
|
+
if (!Number.isFinite(n)) throw new import_errors.CliError(`Invalid number literal: ${raw}`, 2);
|
|
106
|
+
return n;
|
|
107
|
+
};
|
|
108
|
+
while (i < src.length) {
|
|
109
|
+
skipWhitespaceAndComments();
|
|
110
|
+
if (i >= src.length) break;
|
|
111
|
+
const ch = peek();
|
|
112
|
+
if (ch === "." && src.slice(i, i + 3) === "...") {
|
|
113
|
+
i += 3;
|
|
114
|
+
tokens.push({ type: "spread" });
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
if (ch === '"') {
|
|
118
|
+
tokens.push({ type: "string", value: readString() });
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
if (ch === "-" || /[0-9]/.test(ch)) {
|
|
122
|
+
tokens.push({ type: "number", value: readNumber() });
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (isNameStart(ch)) {
|
|
126
|
+
tokens.push({ type: "name", value: readName() });
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
if (ch === "{" || ch === "}" || ch === "(" || ch === ")" || ch === ":" || ch === "[" || ch === "]") {
|
|
130
|
+
i++;
|
|
131
|
+
tokens.push({ type: "punct", value: ch });
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
throw new import_errors.CliError(`Unexpected character in --selection: ${ch}`, 2);
|
|
135
|
+
}
|
|
136
|
+
return tokens.filter((t) => !(t.type === "punct" && t.value === ","));
|
|
137
|
+
};
|
|
138
|
+
const parserPeek = (p) => p.tokens[p.i];
|
|
139
|
+
const parserNext = (p) => p.tokens[p.i++];
|
|
140
|
+
const expectName = (p) => {
|
|
141
|
+
const tok = parserNext(p);
|
|
142
|
+
if (!tok || tok.type !== "name") throw new import_errors.CliError("Invalid --selection: expected name", 2);
|
|
143
|
+
return tok.value;
|
|
144
|
+
};
|
|
145
|
+
const expectPunct = (p, value) => {
|
|
146
|
+
const tok = parserNext(p);
|
|
147
|
+
if (!tok || tok.type !== "punct") throw new import_errors.CliError("Invalid --selection: expected punctuation", 2);
|
|
148
|
+
if (value && tok.value !== value) throw new import_errors.CliError(`Invalid --selection: expected '${value}'`, 2);
|
|
149
|
+
return tok.value;
|
|
150
|
+
};
|
|
151
|
+
const expectSpread = (p) => {
|
|
152
|
+
const tok = parserNext(p);
|
|
153
|
+
if (!tok || tok.type !== "spread") throw new import_errors.CliError("Invalid --selection: expected ...", 2);
|
|
154
|
+
};
|
|
155
|
+
const tryConsumePunct = (p, value) => {
|
|
156
|
+
const tok = parserPeek(p);
|
|
157
|
+
if (tok?.type === "punct" && tok.value === value) {
|
|
158
|
+
p.i++;
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
return false;
|
|
162
|
+
};
|
|
163
|
+
const parseValue = (p) => {
|
|
164
|
+
const tok = parserPeek(p);
|
|
165
|
+
if (!tok) throw new import_errors.CliError("Invalid --selection: expected value", 2);
|
|
166
|
+
if (tok.type === "string") {
|
|
167
|
+
p.i++;
|
|
168
|
+
return tok.value;
|
|
169
|
+
}
|
|
170
|
+
if (tok.type === "number") {
|
|
171
|
+
p.i++;
|
|
172
|
+
return tok.value;
|
|
173
|
+
}
|
|
174
|
+
if (tok.type === "name") {
|
|
175
|
+
p.i++;
|
|
176
|
+
if (tok.value === "true") return true;
|
|
177
|
+
if (tok.value === "false") return false;
|
|
178
|
+
if (tok.value === "null") return null;
|
|
179
|
+
return tok.value;
|
|
180
|
+
}
|
|
181
|
+
if (tok.type === "punct" && tok.value === "[") {
|
|
182
|
+
p.i++;
|
|
183
|
+
const items = [];
|
|
184
|
+
while (!tryConsumePunct(p, "]")) {
|
|
185
|
+
items.push(parseValue(p));
|
|
186
|
+
tryConsumePunct(p, ",");
|
|
187
|
+
}
|
|
188
|
+
return items;
|
|
189
|
+
}
|
|
190
|
+
if (tok.type === "punct" && tok.value === "{") {
|
|
191
|
+
p.i++;
|
|
192
|
+
const obj = {};
|
|
193
|
+
while (!tryConsumePunct(p, "}")) {
|
|
194
|
+
const key = expectName(p);
|
|
195
|
+
expectPunct(p, ":");
|
|
196
|
+
obj[key] = parseValue(p);
|
|
197
|
+
tryConsumePunct(p, ",");
|
|
198
|
+
}
|
|
199
|
+
return obj;
|
|
200
|
+
}
|
|
201
|
+
throw new import_errors.CliError("Invalid --selection: unsupported value", 2);
|
|
202
|
+
};
|
|
203
|
+
const mergeSelectionValue = (current, next) => {
|
|
204
|
+
if (current === void 0) return next;
|
|
205
|
+
if (current === true) return next;
|
|
206
|
+
if (next === true) return current;
|
|
207
|
+
const merged = { ...current };
|
|
208
|
+
if (current.__args || next.__args) {
|
|
209
|
+
merged.__args = { ...current.__args ?? {}, ...next.__args ?? {} };
|
|
210
|
+
}
|
|
211
|
+
for (const [k, v] of Object.entries(next)) {
|
|
212
|
+
if (k === "__args") continue;
|
|
213
|
+
merged[k] = mergeSelectionValue(merged[k], v);
|
|
214
|
+
}
|
|
215
|
+
return merged;
|
|
216
|
+
};
|
|
217
|
+
const parseArguments = (p) => {
|
|
218
|
+
const args = {};
|
|
219
|
+
expectPunct(p, "(");
|
|
220
|
+
while (!tryConsumePunct(p, ")")) {
|
|
221
|
+
const name = expectName(p);
|
|
222
|
+
expectPunct(p, ":");
|
|
223
|
+
args[name] = parseValue(p);
|
|
224
|
+
tryConsumePunct(p, ",");
|
|
225
|
+
}
|
|
226
|
+
return args;
|
|
227
|
+
};
|
|
228
|
+
const parseSelectionSet = (p) => {
|
|
229
|
+
const out = {};
|
|
230
|
+
if (tryConsumePunct(p, "{")) {
|
|
231
|
+
while (!tryConsumePunct(p, "}")) {
|
|
232
|
+
const selection = parseSelection(p);
|
|
233
|
+
for (const [k, v] of Object.entries(selection)) {
|
|
234
|
+
out[k] = mergeSelectionValue(out[k], v);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return out;
|
|
238
|
+
}
|
|
239
|
+
while (p.i < p.tokens.length) {
|
|
240
|
+
const selection = parseSelection(p);
|
|
241
|
+
for (const [k, v] of Object.entries(selection)) {
|
|
242
|
+
out[k] = mergeSelectionValue(out[k], v);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return out;
|
|
246
|
+
};
|
|
247
|
+
const parseField = (p) => {
|
|
248
|
+
const firstName = expectName(p);
|
|
249
|
+
let fieldName = firstName;
|
|
250
|
+
if (tryConsumePunct(p, ":")) {
|
|
251
|
+
fieldName = expectName(p);
|
|
252
|
+
}
|
|
253
|
+
const tok = parserPeek(p);
|
|
254
|
+
const hasArgs = tok?.type === "punct" && tok.value === "(";
|
|
255
|
+
const args = hasArgs ? parseArguments(p) : void 0;
|
|
256
|
+
const nextTok = parserPeek(p);
|
|
257
|
+
const hasSelectionSet = nextTok?.type === "punct" && nextTok.value === "{";
|
|
258
|
+
if (args && !hasSelectionSet) {
|
|
259
|
+
throw new import_errors.CliError(
|
|
260
|
+
`Invalid --selection: field '${fieldName}' has arguments but no sub-selection`,
|
|
261
|
+
2
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
const selection = hasSelectionSet ? parseSelectionSet(p) : true;
|
|
265
|
+
const value = args ? { __args: args, ...selection === true ? {} : selection } : selection;
|
|
266
|
+
return { [fieldName]: value };
|
|
267
|
+
};
|
|
268
|
+
const parseInlineFragment = (p) => {
|
|
269
|
+
expectSpread(p);
|
|
270
|
+
const on = expectName(p);
|
|
271
|
+
if (on !== "on") throw new import_errors.CliError('Invalid --selection: expected "on" after ...', 2);
|
|
272
|
+
const typeName = expectName(p);
|
|
273
|
+
const selection = parseSelectionSet(p);
|
|
274
|
+
return { [`on_${typeName}`]: selection };
|
|
275
|
+
};
|
|
276
|
+
const parseSelection = (p) => {
|
|
277
|
+
const tok = parserPeek(p);
|
|
278
|
+
if (!tok) throw new import_errors.CliError("Invalid --selection: unexpected end", 2);
|
|
279
|
+
if (tok.type === "spread") return parseInlineFragment(p);
|
|
280
|
+
if (tok.type === "name") return parseField(p);
|
|
281
|
+
throw new import_errors.CliError("Invalid --selection: expected field selection", 2);
|
|
282
|
+
};
|
|
283
|
+
const parseGraphqlSelectionArg = (arg) => {
|
|
284
|
+
const src = readSelectionSource(arg).trim();
|
|
285
|
+
if (!src) throw new import_errors.CliError("Invalid --selection: empty", 2);
|
|
286
|
+
const tokens = tokenize(src);
|
|
287
|
+
const p = { tokens, i: 0 };
|
|
288
|
+
const selection = parseSelectionSet(p);
|
|
289
|
+
if (p.i !== p.tokens.length) {
|
|
290
|
+
throw new import_errors.CliError("Invalid --selection: trailing tokens", 2);
|
|
291
|
+
}
|
|
292
|
+
if (Object.keys(selection).length === 0) {
|
|
293
|
+
throw new import_errors.CliError("Invalid --selection: selection set is empty", 2);
|
|
294
|
+
}
|
|
295
|
+
return selection;
|
|
296
|
+
};
|
|
297
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
298
|
+
0 && (module.exports = {
|
|
299
|
+
parseGraphqlSelectionArg
|
|
300
|
+
});
|
|
301
|
+
//# sourceMappingURL=graphqlSelection.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CliView } from '../router';
|
|
2
|
+
import { type GenqlSelection } from './graphqlSelection';
|
|
3
|
+
export declare const resolveSelection: ({ resource, typeName, view, baseSelection, select, selection, include, ensureId, defaultConnectionFirst, }: {
|
|
4
|
+
resource?: string;
|
|
5
|
+
typeName?: string;
|
|
6
|
+
view: CliView;
|
|
7
|
+
baseSelection: GenqlSelection;
|
|
8
|
+
select: unknown;
|
|
9
|
+
selection: unknown;
|
|
10
|
+
include?: unknown;
|
|
11
|
+
ensureId: boolean;
|
|
12
|
+
defaultConnectionFirst?: number;
|
|
13
|
+
}) => GenqlSelection;
|
|
@@ -0,0 +1,136 @@
|
|
|
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 select_exports = {};
|
|
20
|
+
__export(select_exports, {
|
|
21
|
+
resolveSelection: () => resolveSelection
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(select_exports);
|
|
24
|
+
var import_errors = require("../errors");
|
|
25
|
+
var import_graphqlSelection = require("./graphqlSelection");
|
|
26
|
+
var import_buildAllSelection = require("./buildAllSelection");
|
|
27
|
+
var import_introspection = require("../introspection");
|
|
28
|
+
var import_stripDeprecated = require("./stripDeprecated");
|
|
29
|
+
const isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
30
|
+
const assertValidDotPath = (path) => {
|
|
31
|
+
const parts = path.split(".").filter(Boolean);
|
|
32
|
+
if (parts.length === 0) throw new import_errors.CliError(`Invalid --select path: ${path}`, 2);
|
|
33
|
+
for (const part of parts) {
|
|
34
|
+
if (!/^[_A-Za-z][_0-9A-Za-z]*$/.test(part)) {
|
|
35
|
+
throw new import_errors.CliError(`Invalid --select path segment: ${part}`, 2);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return parts;
|
|
39
|
+
};
|
|
40
|
+
const deepCloneSelection = (selection) => JSON.parse(JSON.stringify(selection));
|
|
41
|
+
const hasAnyFields = (selection) => Object.keys(selection).filter((k) => k !== "__args").length > 0;
|
|
42
|
+
const ensureIdSelected = (selection) => {
|
|
43
|
+
if (!("id" in selection)) selection.id = true;
|
|
44
|
+
return selection;
|
|
45
|
+
};
|
|
46
|
+
const mergeDotPath = ({
|
|
47
|
+
selection,
|
|
48
|
+
path,
|
|
49
|
+
defaultConnectionFirst
|
|
50
|
+
}) => {
|
|
51
|
+
const parts = assertValidDotPath(path);
|
|
52
|
+
let cursor = selection;
|
|
53
|
+
for (let i = 0; i < parts.length; i++) {
|
|
54
|
+
const key = parts[i];
|
|
55
|
+
const isLeaf = i === parts.length - 1;
|
|
56
|
+
const nextKey = parts[i + 1];
|
|
57
|
+
const selectingConnectionChildren = nextKey === "nodes" || nextKey === "edges";
|
|
58
|
+
if (isLeaf) {
|
|
59
|
+
const existing2 = cursor[key];
|
|
60
|
+
if (existing2 === void 0) {
|
|
61
|
+
cursor[key] = true;
|
|
62
|
+
} else if (existing2 === true) {
|
|
63
|
+
} else if (isPlainObject(existing2)) {
|
|
64
|
+
} else {
|
|
65
|
+
cursor[key] = true;
|
|
66
|
+
}
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const existing = cursor[key];
|
|
70
|
+
if (existing === true) {
|
|
71
|
+
throw new import_errors.CliError(`Invalid --select: cannot select nested fields under '${parts.slice(0, i + 1).join(".")}'`, 2);
|
|
72
|
+
}
|
|
73
|
+
if (!isPlainObject(existing)) {
|
|
74
|
+
cursor[key] = {};
|
|
75
|
+
}
|
|
76
|
+
const obj = cursor[key];
|
|
77
|
+
if (selectingConnectionChildren) {
|
|
78
|
+
if (!obj.__args) obj.__args = { first: defaultConnectionFirst };
|
|
79
|
+
if (!obj.pageInfo) obj.pageInfo = { hasNextPage: true, endCursor: true };
|
|
80
|
+
}
|
|
81
|
+
cursor = obj;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const resolveSelection = ({
|
|
85
|
+
resource,
|
|
86
|
+
typeName,
|
|
87
|
+
view,
|
|
88
|
+
baseSelection,
|
|
89
|
+
select,
|
|
90
|
+
selection,
|
|
91
|
+
include,
|
|
92
|
+
ensureId,
|
|
93
|
+
defaultConnectionFirst = 10
|
|
94
|
+
}) => {
|
|
95
|
+
const override = typeof selection === "string" && selection.length > 0 ? (0, import_graphqlSelection.parseGraphqlSelectionArg)(selection) : void 0;
|
|
96
|
+
const selectPaths = Array.isArray(select) ? select : select === void 0 ? [] : [select];
|
|
97
|
+
for (const p of selectPaths) {
|
|
98
|
+
if (typeof p !== "string") throw new import_errors.CliError("--select must be a string (repeatable)", 2);
|
|
99
|
+
}
|
|
100
|
+
const includeValues = Array.isArray(include) ? include : include === void 0 ? [] : [include];
|
|
101
|
+
for (const v of includeValues) {
|
|
102
|
+
if (typeof v !== "string") throw new import_errors.CliError("--include must be a string (repeatable)", 2);
|
|
103
|
+
}
|
|
104
|
+
const includes = Array.from(new Set(includeValues));
|
|
105
|
+
const resolvedTypeName = typeName ?? (resource ? import_introspection.resourceToType[resource] : void 0);
|
|
106
|
+
const mergedBase = (() => {
|
|
107
|
+
if (view === "raw") return {};
|
|
108
|
+
if (view === "all") {
|
|
109
|
+
if (!resolvedTypeName) {
|
|
110
|
+
const suffix = resource ? ` for resource: ${resource}` : "";
|
|
111
|
+
throw new import_errors.CliError(`--view all is not supported${suffix}`, 2);
|
|
112
|
+
}
|
|
113
|
+
if (includes.length) (0, import_buildAllSelection.validateIncludes)(resolvedTypeName, includes);
|
|
114
|
+
return (0, import_buildAllSelection.buildAllSelection)(resolvedTypeName, includes, 0, 2, /* @__PURE__ */ new Set(), defaultConnectionFirst);
|
|
115
|
+
}
|
|
116
|
+
return deepCloneSelection(baseSelection);
|
|
117
|
+
})();
|
|
118
|
+
const baseForBuiltInViews = !override && resolvedTypeName && view !== "raw" ? (0, import_stripDeprecated.stripDeprecatedFromSelection)(resolvedTypeName, mergedBase) : mergedBase;
|
|
119
|
+
let out = override ? deepCloneSelection(override) : baseForBuiltInViews;
|
|
120
|
+
for (const p of selectPaths) {
|
|
121
|
+
mergeDotPath({ selection: out, path: p, defaultConnectionFirst });
|
|
122
|
+
}
|
|
123
|
+
if (ensureId) ensureIdSelected(out);
|
|
124
|
+
if (!hasAnyFields(out)) {
|
|
125
|
+
if (view === "raw") {
|
|
126
|
+
throw new import_errors.CliError("--view raw requires --select and/or --selection", 2);
|
|
127
|
+
}
|
|
128
|
+
throw new import_errors.CliError("Selection set is empty", 2);
|
|
129
|
+
}
|
|
130
|
+
return out;
|
|
131
|
+
};
|
|
132
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
133
|
+
0 && (module.exports = {
|
|
134
|
+
resolveSelection
|
|
135
|
+
});
|
|
136
|
+
//# sourceMappingURL=select.js.map
|
|
@@ -0,0 +1,63 @@
|
|
|
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 stripDeprecated_exports = {};
|
|
20
|
+
__export(stripDeprecated_exports, {
|
|
21
|
+
stripDeprecatedFromSelection: () => stripDeprecatedFromSelection
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(stripDeprecated_exports);
|
|
24
|
+
var import_introspection = require("../introspection");
|
|
25
|
+
var import_deprecations = require("../introspection/deprecations");
|
|
26
|
+
const isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
27
|
+
const stripDeprecatedInner = (typeName, selection) => {
|
|
28
|
+
const fields = (0, import_introspection.getFields)(typeName);
|
|
29
|
+
const fieldMap = new Map(fields.map((f) => [f.name, f]));
|
|
30
|
+
for (const key of Object.keys(selection)) {
|
|
31
|
+
if (key === "__args") continue;
|
|
32
|
+
if ((0, import_deprecations.isDeprecatedField)(typeName, key)) {
|
|
33
|
+
delete selection[key];
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const value = selection[key];
|
|
37
|
+
if (!isPlainObject(value)) continue;
|
|
38
|
+
const info = fieldMap.get(key);
|
|
39
|
+
if (!info) continue;
|
|
40
|
+
if (info.isConnection) {
|
|
41
|
+
const nodeType = info.connectionNodeTypeName;
|
|
42
|
+
if (!nodeType) continue;
|
|
43
|
+
const nodes = value.nodes;
|
|
44
|
+
if (isPlainObject(nodes)) stripDeprecatedInner(nodeType, nodes);
|
|
45
|
+
const edges = value.edges;
|
|
46
|
+
const node = isPlainObject(edges) ? edges.node : void 0;
|
|
47
|
+
if (isPlainObject(node)) stripDeprecatedInner(nodeType, node);
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (!info.isScalar) {
|
|
51
|
+
stripDeprecatedInner(info.typeName, value);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const stripDeprecatedFromSelection = (typeName, selection) => {
|
|
56
|
+
stripDeprecatedInner(typeName, selection);
|
|
57
|
+
return selection;
|
|
58
|
+
};
|
|
59
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
+
0 && (module.exports = {
|
|
61
|
+
stripDeprecatedFromSelection
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=stripDeprecated.js.map
|
|
@@ -0,0 +1,88 @@
|
|
|
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 suggest_exports = {};
|
|
20
|
+
__export(suggest_exports, {
|
|
21
|
+
findSuggestions: () => findSuggestions
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(suggest_exports);
|
|
24
|
+
const fuzzyMatch = (needle, haystack) => {
|
|
25
|
+
const lowerNeedle = needle.toLowerCase();
|
|
26
|
+
const lowerHaystack = haystack.toLowerCase();
|
|
27
|
+
let ni = 0;
|
|
28
|
+
for (let hi = 0; hi < lowerHaystack.length && ni < lowerNeedle.length; hi++) {
|
|
29
|
+
if (lowerHaystack[hi] === lowerNeedle[ni]) ni++;
|
|
30
|
+
}
|
|
31
|
+
return ni === lowerNeedle.length;
|
|
32
|
+
};
|
|
33
|
+
const levenshteinDistance = (a, b, maxDistance = 3) => {
|
|
34
|
+
if (a === b) return 0;
|
|
35
|
+
if (a.length === 0) return b.length;
|
|
36
|
+
if (b.length === 0) return a.length;
|
|
37
|
+
if (Math.abs(a.length - b.length) > maxDistance) return maxDistance + 1;
|
|
38
|
+
const v0 = new Array(b.length + 1);
|
|
39
|
+
const v1 = new Array(b.length + 1);
|
|
40
|
+
for (let i = 0; i <= b.length; i++) v0[i] = i;
|
|
41
|
+
for (let i = 0; i < a.length; i++) {
|
|
42
|
+
v1[0] = i + 1;
|
|
43
|
+
let bestInRow = v1[0];
|
|
44
|
+
for (let j = 0; j < b.length; j++) {
|
|
45
|
+
const cost = a[i] === b[j] ? 0 : 1;
|
|
46
|
+
v1[j + 1] = Math.min(
|
|
47
|
+
v1[j] + 1,
|
|
48
|
+
// insertion
|
|
49
|
+
v0[j + 1] + 1,
|
|
50
|
+
// deletion
|
|
51
|
+
v0[j] + cost
|
|
52
|
+
// substitution
|
|
53
|
+
);
|
|
54
|
+
if (v1[j + 1] < bestInRow) bestInRow = v1[j + 1];
|
|
55
|
+
}
|
|
56
|
+
if (bestInRow > maxDistance) return maxDistance + 1;
|
|
57
|
+
for (let j = 0; j <= b.length; j++) v0[j] = v1[j];
|
|
58
|
+
}
|
|
59
|
+
return v1[b.length];
|
|
60
|
+
};
|
|
61
|
+
const scoreMatch = (query, candidate) => {
|
|
62
|
+
const q = query.toLowerCase();
|
|
63
|
+
const c = candidate.toLowerCase();
|
|
64
|
+
if (c === q) return 0;
|
|
65
|
+
if (c === `${q}s` || c === `${q}es`) return 1;
|
|
66
|
+
if (c.startsWith(q)) return 2;
|
|
67
|
+
if (q.startsWith(c)) return 3;
|
|
68
|
+
if (c.includes(q)) return 4;
|
|
69
|
+
if (q.includes(c)) return 5;
|
|
70
|
+
const dist = levenshteinDistance(q, c, 3);
|
|
71
|
+
if (dist <= 3) return 10 + dist;
|
|
72
|
+
if (fuzzyMatch(query, candidate)) return 20;
|
|
73
|
+
if (fuzzyMatch(candidate, query)) return 21;
|
|
74
|
+
return Infinity;
|
|
75
|
+
};
|
|
76
|
+
const findSuggestions = ({
|
|
77
|
+
query,
|
|
78
|
+
candidates,
|
|
79
|
+
limit = 3
|
|
80
|
+
}) => {
|
|
81
|
+
const scored = candidates.map((name) => ({ name, score: scoreMatch(query, name) })).filter(({ score }) => score < Infinity).sort((a, b) => a.score - b.score || a.name.localeCompare(b.name)).slice(0, limit);
|
|
82
|
+
return scored.map(({ name }) => name);
|
|
83
|
+
};
|
|
84
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
85
|
+
0 && (module.exports = {
|
|
86
|
+
findSuggestions
|
|
87
|
+
});
|
|
88
|
+
//# sourceMappingURL=suggest.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
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 userErrors_exports = {};
|
|
20
|
+
__export(userErrors_exports, {
|
|
21
|
+
maybeFailOnUserErrors: () => maybeFailOnUserErrors
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(userErrors_exports);
|
|
24
|
+
var import_errors = require("./errors");
|
|
25
|
+
var import_output = require("./output");
|
|
26
|
+
const maybeFailOnUserErrors = ({
|
|
27
|
+
payload,
|
|
28
|
+
failOnUserErrors
|
|
29
|
+
}) => {
|
|
30
|
+
const userErrors = payload?.userErrors;
|
|
31
|
+
if (!Array.isArray(userErrors) || userErrors.length === 0) return;
|
|
32
|
+
(0, import_output.printJsonError)({ userErrors });
|
|
33
|
+
if (failOnUserErrors) {
|
|
34
|
+
throw new import_errors.CliError("Shopify returned userErrors", 2);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
maybeFailOnUserErrors
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=userErrors.js.map
|