@shopify/hydrogen 1.3.0 → 1.3.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.
@@ -5,10 +5,10 @@ import { useEmbeddedVideoUrl } from '../../utilities/index.js';
5
5
  * API's [ExternalVideo object](https://shopify.dev/api/storefront/reference/products/externalvideo).
6
6
  */
7
7
  export function ExternalVideo(props) {
8
- const { data, options, id = data.id, frameBorder = '0', allow = 'accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture', allowFullScreen = true, ...passthroughProps } = props;
8
+ const { data, options, id = data.id, frameBorder = '0', allow = 'accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture', allowFullScreen = true, loading = 'lazy', ...passthroughProps } = props;
9
9
  if (!data.embedUrl) {
10
10
  throw new Error(`<ExternalVideo/> requires the 'embedUrl' property`);
11
11
  }
12
12
  const url = useEmbeddedVideoUrl(data.embedUrl, options);
13
- return (React.createElement("iframe", { ...passthroughProps, id: id ?? data.embedUrl, frameBorder: frameBorder, allow: allow, allowFullScreen: allowFullScreen, src: url }));
13
+ return (React.createElement("iframe", { ...passthroughProps, id: id ?? data.embedUrl, frameBorder: frameBorder, allow: allow, allowFullScreen: allowFullScreen, src: url, loading: loading }));
14
14
  }
@@ -527,23 +527,23 @@ export declare type CartCodeDiscountAllocation = CartDiscountAllocation & {
527
527
  */
528
528
  export declare type CartCost = {
529
529
  __typename?: 'CartCost';
530
- /** The estimated amount, before taxes and discounts, for the customer to pay at checkout. The checkout charge amount doesn't include any deferred payments that'll be paid at a later date. If the cart has no deferred payments, the checkout charge amount is equivalent to subtotalAmount. */
530
+ /** The estimated amount, before taxes and discounts, for the customer to pay at checkout. The checkout charge amount doesn't include any deferred payments that'll be paid at a later date. If the cart has no deferred payments, then the checkout charge amount is equivalent to `subtotalAmount`. */
531
531
  checkoutChargeAmount: MoneyV2;
532
532
  /** The amount, before taxes and cart-level discounts, for the customer to pay. */
533
533
  subtotalAmount: MoneyV2;
534
- /** Whether or not the subtotal amount is estimated. */
534
+ /** Whether the subtotal amount is estimated. */
535
535
  subtotalAmountEstimated: Scalars['Boolean'];
536
536
  /** The total amount for the customer to pay. */
537
537
  totalAmount: MoneyV2;
538
- /** Whether or not the total amount is estimated. */
538
+ /** Whether the total amount is estimated. */
539
539
  totalAmountEstimated: Scalars['Boolean'];
540
540
  /** The duty amount for the customer to pay at checkout. */
541
541
  totalDutyAmount?: Maybe<MoneyV2>;
542
- /** Whether or not the total duty amount is estimated. */
542
+ /** Whether the total duty amount is estimated. */
543
543
  totalDutyAmountEstimated: Scalars['Boolean'];
544
544
  /** The tax amount for the customer to pay at checkout. */
545
545
  totalTaxAmount?: Maybe<MoneyV2>;
546
- /** Whether or not the total tax amount is estimated. */
546
+ /** Whether the total tax amount is estimated. */
547
547
  totalTaxAmountEstimated: Scalars['Boolean'];
548
548
  };
549
549
  /** Return type for `cartCreate` mutation. */
@@ -662,7 +662,7 @@ export declare enum CartErrorCode {
662
662
  */
663
663
  export declare type CartEstimatedCost = {
664
664
  __typename?: 'CartEstimatedCost';
665
- /** The estimated amount, before taxes and discounts, for the customer to pay at checkout. The checkout charge amount doesn't include any deferred payments that'll be paid at a later date. If the cart has no deferred payments, the checkout charge amount is equivalent to subtotalAmount. */
665
+ /** The estimated amount, before taxes and discounts, for the customer to pay at checkout. The checkout charge amount doesn't include any deferred payments that'll be paid at a later date. If the cart has no deferred payments, then the checkout charge amount is equivalent to`subtotal_amount`. */
666
666
  checkoutChargeAmount: MoneyV2;
667
667
  /** The estimated amount, before taxes and discounts, for the customer to pay. */
668
668
  subtotalAmount: MoneyV2;
@@ -875,7 +875,7 @@ export declare type Checkout = Node & {
875
875
  * @deprecated Use `paymentDueV2` instead
876
876
  */
877
877
  paymentDue: Scalars['Money'];
878
- /** The amount left to be paid. This is equal to the cost of the line items, duties, taxes and shipping minus discounts and gift cards. */
878
+ /** The amount left to be paid. This is equal to the cost of the line items, duties, taxes, and shipping, minus discounts and gift cards. */
879
879
  paymentDueV2: MoneyV2;
880
880
  /**
881
881
  * Whether or not the Checkout is ready and can be completed. Checkouts may
@@ -901,7 +901,7 @@ export declare type Checkout = Node & {
901
901
  * @deprecated Use `subtotalPriceV2` instead
902
902
  */
903
903
  subtotalPrice: Scalars['Money'];
904
- /** Price of the checkout before duties, shipping and taxes. */
904
+ /** The price at checkout before duties, shipping, and taxes. */
905
905
  subtotalPriceV2: MoneyV2;
906
906
  /** Whether the checkout is tax exempt. */
907
907
  taxExempt: Scalars['Boolean'];
@@ -914,7 +914,7 @@ export declare type Checkout = Node & {
914
914
  * @deprecated Use `totalPriceV2` instead
915
915
  */
916
916
  totalPrice: Scalars['Money'];
917
- /** The sum of all the prices of all the items in the checkout, duties, taxes and discounts included. */
917
+ /** The sum of all the prices of all the items in the checkout, including duties, taxes, and discounts. */
918
918
  totalPriceV2: MoneyV2;
919
919
  /**
920
920
  * The sum of all the taxes applied to the line items and shipping lines in the checkout.
@@ -1050,13 +1050,6 @@ export declare type CheckoutCreateInput = {
1050
1050
  lineItems?: InputMaybe<Array<CheckoutLineItemInput>>;
1051
1051
  /** The text of an optional note that a shop owner can attach to the checkout. */
1052
1052
  note?: InputMaybe<Scalars['String']>;
1053
- /**
1054
- * The three-letter currency code of one of the shop's enabled presentment currencies.
1055
- * Including this field creates a checkout in the specified currency. By default, new
1056
- * checkouts are created in the shop's primary currency.
1057
- * This argument is deprecated: Use `country` field instead.
1058
- */
1059
- presentmentCurrencyCode?: InputMaybe<CurrencyCode>;
1060
1053
  /** The shipping address to where the line items will be shipped. */
1061
1054
  shippingAddress?: InputMaybe<MailingAddressInput>;
1062
1055
  };
@@ -1186,6 +1179,8 @@ export declare enum CheckoutErrorCode {
1186
1179
  GiftCardUnusable = "GIFT_CARD_UNUSABLE",
1187
1180
  /** The input value should be greater than or equal to the minimum value allowed. */
1188
1181
  GreaterThanOrEqualTo = "GREATER_THAN_OR_EQUAL_TO",
1182
+ /** Higher value discount applied. */
1183
+ HigherValueDiscountApplied = "HIGHER_VALUE_DISCOUNT_APPLIED",
1189
1184
  /** The input value is invalid. */
1190
1185
  Invalid = "INVALID",
1191
1186
  /** Cannot specify country and presentment currency code. */
@@ -1561,7 +1556,7 @@ export declare type Country = {
1561
1556
  };
1562
1557
  /**
1563
1558
  * The code designating a country/region, which generally follows ISO 3166-1 alpha-2 guidelines.
1564
- * If a territory doesn't have a country code value in the `CountryCode` enum, it might be considered a subdivision
1559
+ * If a territory doesn't have a country code value in the `CountryCode` enum, then it might be considered a subdivision
1565
1560
  * of another country. For example, the territories associated with Spain are represented by the country code `ES`,
1566
1561
  * and the territories associated with the United States of America are represented by the country code `US`.
1567
1562
  *
@@ -3240,11 +3235,18 @@ export declare type ImageEdge = {
3240
3235
  /**
3241
3236
  * The available options for transforming an image.
3242
3237
  *
3243
- * All transformation options are considered "best-effort". Any transformation that the original image type doesn't support will be ignored.
3238
+ * All transformation options are considered best effort. Any transformation that the original image type doesn't support will be ignored.
3244
3239
  *
3245
3240
  */
3246
3241
  export declare type ImageTransformInput = {
3247
- /** Crop the image according to the specified region. */
3242
+ /**
3243
+ * The region of the image to remain after cropping.
3244
+ * Must be used in conjunction with the `maxWidth` and/or `maxHeight` fields, where the `maxWidth` and `maxHeight` aren't equal.
3245
+ * The `crop` argument should coincide with the smaller value. A smaller `maxWidth` indicates a `LEFT` or `RIGHT` crop, while
3246
+ * a smaller `maxHeight` indicates a `TOP` or `BOTTOM` crop. For example, `{ maxWidth: 5, maxHeight: 10, crop: LEFT }` will result
3247
+ * in an image with a width of 5 and height of 10, where the right side of the image is removed.
3248
+ *
3249
+ */
3248
3250
  crop?: InputMaybe<CropRegion>;
3249
3251
  /**
3250
3252
  * Image height in pixels between 1 and 5760.
@@ -3424,7 +3426,7 @@ export declare enum LanguageCode {
3424
3426
  Lv = "LV",
3425
3427
  /** Malagasy. */
3426
3428
  Mg = "MG",
3427
- /** Maori. */
3429
+ /** Māori. */
3428
3430
  Mi = "MI",
3429
3431
  /** Macedonian. */
3430
3432
  Mk = "MK",
@@ -4111,9 +4113,10 @@ export declare type Mutation = {
4111
4113
  */
4112
4114
  customerAccessTokenCreate?: Maybe<CustomerAccessTokenCreatePayload>;
4113
4115
  /**
4114
- * Creates a customer access token using a multipass token instead of email and password.
4115
- * A customer record is created if customer does not exist. If a customer record already
4116
- * exists but the record is disabled, then it's enabled.
4116
+ * Creates a customer access token using a
4117
+ * [multipass token](https://shopify.dev/api/multipass) instead of email and
4118
+ * password. A customer record is created if the customer doesn't exist. If a customer
4119
+ * record already exists but the record is disabled, then the customer record is enabled.
4117
4120
  *
4118
4121
  */
4119
4122
  customerAccessTokenCreateWithMultipass?: Maybe<CustomerAccessTokenCreateWithMultipassPayload>;
@@ -4757,7 +4760,7 @@ export declare type Payment = Node & {
4757
4760
  idempotencyKey?: Maybe<Scalars['String']>;
4758
4761
  /** The URL where the customer needs to be redirected so they can complete the 3D Secure payment flow. */
4759
4762
  nextActionUrl?: Maybe<Scalars['URL']>;
4760
- /** Whether or not the payment is still processing asynchronously. */
4763
+ /** Whether the payment is still processing asynchronously. */
4761
4764
  ready: Scalars['Boolean'];
4762
4765
  /** A flag to indicate if the payment is to be done in test mode for gateways that support it. */
4763
4766
  test: Scalars['Boolean'];
@@ -5278,7 +5281,7 @@ export declare type QueryRoot = {
5278
5281
  blogByHandle?: Maybe<Blog>;
5279
5282
  /** List of the shop's blogs. */
5280
5283
  blogs: BlogConnection;
5281
- /** Find a cart by its ID. */
5284
+ /** Retrieve a cart by its ID. For more information, refer to [Manage a cart with the Storefront API](https://shopify.dev/api/examples/cart). */
5282
5285
  cart?: Maybe<Cart>;
5283
5286
  /** Fetch a specific `Collection` by one of its unique attributes. */
5284
5287
  collection?: Maybe<Collection>;
@@ -5538,7 +5541,7 @@ export declare type SellingPlan = {
5538
5541
  id: Scalars['ID'];
5539
5542
  /** The name of the selling plan. For example, '6 weeks of prepaid granola, delivered weekly'. */
5540
5543
  name: Scalars['String'];
5541
- /** The selling plan options available in the drop-down list in the storefront. For example, 'Delivery every week' or 'Delivery every 2 weeks' specifies the delivery frequency options for the product. */
5544
+ /** The selling plan options available in the drop-down list in the storefront. For example, 'Delivery every week' or 'Delivery every 2 weeks' specifies the delivery frequency options for the product. Individual selling plans contribute their options to the associated selling plan group. For example, a selling plan group might have an option called `option1: Delivery every`. One selling plan in that group could contribute `option1: 2 weeks` with the pricing for that option, and another selling plan could contribute `option1: 4 weeks`, with different pricing. */
5542
5545
  options: Array<SellingPlanOption>;
5543
5546
  /** The price adjustments that a selling plan makes when a variant is purchased with a selling plan. */
5544
5547
  priceAdjustments: Array<SellingPlanPriceAdjustment>;
@@ -5696,7 +5699,11 @@ export declare type SellingPlanGroupEdge = {
5696
5699
  /** The item at the end of SellingPlanGroupEdge. */
5697
5700
  node: SellingPlanGroup;
5698
5701
  };
5699
- /** Represents an option on a selling plan group that's available in the drop-down list in the storefront. */
5702
+ /**
5703
+ * Represents an option on a selling plan group that's available in the drop-down list in the storefront.
5704
+ *
5705
+ * Individual selling plans contribute their options to the associated selling plan group. For example, a selling plan group might have an option called `option1: Delivery every`. One selling plan in that group could contribute `option1: 2 weeks` with the pricing for that option, and another selling plan could contribute `option1: 4 weeks`, with different pricing.
5706
+ */
5700
5707
  export declare type SellingPlanGroupOption = {
5701
5708
  __typename?: 'SellingPlanGroupOption';
5702
5709
  /** The name of the option. For example, 'Delivery every'. */
@@ -5718,12 +5725,12 @@ export declare type SellingPlanPercentagePriceAdjustment = {
5718
5725
  /** The percentage value of the price adjustment. */
5719
5726
  adjustmentPercentage: Scalars['Int'];
5720
5727
  };
5721
- /** Represents by how much the price of a variant associated with a selling plan is adjusted. Each variant can have up to two price adjustments. */
5728
+ /** Represents by how much the price of a variant associated with a selling plan is adjusted. Each variant can have up to two price adjustments. If a variant has multiple price adjustments, then the first price adjustment applies when the variant is initially purchased. The second price adjustment applies after a certain number of orders (specified by the `orderCount` field) are made. If a selling plan doesn't have any price adjustments, then the unadjusted price of the variant is the effective price. */
5722
5729
  export declare type SellingPlanPriceAdjustment = {
5723
5730
  __typename?: 'SellingPlanPriceAdjustment';
5724
5731
  /** The type of price adjustment. An adjustment value can have one of three types: percentage, amount off, or a new price. */
5725
5732
  adjustmentValue: SellingPlanPriceAdjustmentValue;
5726
- /** The number of orders that the price adjustment applies to If the price adjustment always applies, then this field is `null`. */
5733
+ /** The number of orders that the price adjustment applies to. If the price adjustment always applies, then this field is `null`. */
5727
5734
  orderCount?: Maybe<Scalars['Int']>;
5728
5735
  };
5729
5736
  /** Represents by how much the price of a variant associated with a selling plan is adjusted. Each variant can have up to two price adjustments. */
@@ -5763,7 +5770,7 @@ export declare type Shop = HasMetafields & Node & {
5763
5770
  name: Scalars['String'];
5764
5771
  /** Settings related to payments. */
5765
5772
  paymentSettings: PaymentSettings;
5766
- /** The shop’s primary domain. */
5773
+ /** The primary domain of the shop’s Online Store. */
5767
5774
  primaryDomain: Domain;
5768
5775
  /** The shop’s privacy policy. */
5769
5776
  privacyPolicy?: Maybe<ShopPolicy>;
@@ -5827,7 +5834,7 @@ export declare type ShopPolicyWithDefault = {
5827
5834
  */
5828
5835
  export declare type StoreAvailability = {
5829
5836
  __typename?: 'StoreAvailability';
5830
- /** Whether or not this product variant is in-stock at this location. */
5837
+ /** Whether the product variant is in-stock at this location. */
5831
5838
  available: Scalars['Boolean'];
5832
5839
  /** The location where this product variant is stocked at. */
5833
5840
  location: Location;
@@ -111,6 +111,8 @@ export var CheckoutErrorCode;
111
111
  CheckoutErrorCode["GiftCardUnusable"] = "GIFT_CARD_UNUSABLE";
112
112
  /** The input value should be greater than or equal to the minimum value allowed. */
113
113
  CheckoutErrorCode["GreaterThanOrEqualTo"] = "GREATER_THAN_OR_EQUAL_TO";
114
+ /** Higher value discount applied. */
115
+ CheckoutErrorCode["HigherValueDiscountApplied"] = "HIGHER_VALUE_DISCOUNT_APPLIED";
114
116
  /** The input value is invalid. */
115
117
  CheckoutErrorCode["Invalid"] = "INVALID";
116
118
  /** Cannot specify country and presentment currency code. */
@@ -172,7 +174,7 @@ export var CollectionSortKeys;
172
174
  })(CollectionSortKeys || (CollectionSortKeys = {}));
173
175
  /**
174
176
  * The code designating a country/region, which generally follows ISO 3166-1 alpha-2 guidelines.
175
- * If a territory doesn't have a country code value in the `CountryCode` enum, it might be considered a subdivision
177
+ * If a territory doesn't have a country code value in the `CountryCode` enum, then it might be considered a subdivision
176
178
  * of another country. For example, the territories associated with Spain are represented by the country code `ES`,
177
179
  * and the territories associated with the United States of America are represented by the country code `US`.
178
180
  *
@@ -1286,7 +1288,7 @@ export var LanguageCode;
1286
1288
  LanguageCode["Lv"] = "LV";
1287
1289
  /** Malagasy. */
1288
1290
  LanguageCode["Mg"] = "MG";
1289
- /** Maori. */
1291
+ /** Māori. */
1290
1292
  LanguageCode["Mi"] = "MI";
1291
1293
  /** Macedonian. */
1292
1294
  LanguageCode["Mk"] = "MK";
@@ -11,7 +11,10 @@ export function fetchBuilder(url, options = {}) {
11
11
  return async () => {
12
12
  const response = await fetch(url, requestInit);
13
13
  if (!response.ok) {
14
- throw response;
14
+ if (response.status === 403 || response.status === 401) {
15
+ throw new Error(`Request to the Storefront API failed! You may have a bad value in 'hydrogen.config.js'. Response status: ${response.status}, Request ID: ${response.headers.get('x-request-id')}`);
16
+ }
17
+ throw new Error(`Request to the Storefront API failed! Response status: ${response.status}, Request ID: ${response.headers.get('x-request-id')}`);
15
18
  }
16
19
  const data = await response.json();
17
20
  return data;
@@ -12,8 +12,14 @@ const defaultLogger = {
12
12
  warn(context, ...args) {
13
13
  console.warn(yellow('WARN: '), ...args);
14
14
  },
15
- error(context, ...args) {
16
- console.error(red('ERROR: '), ...args);
15
+ error(context, error, ...extra) {
16
+ const url = context ? ` ${context.url}` : '';
17
+ if (error instanceof Error) {
18
+ console.error(red(`Error processing route:${url}\n${error.stack}`));
19
+ }
20
+ else {
21
+ console.error(red(`Error:${url} ${error}`));
22
+ }
17
23
  },
18
24
  fatal(context, ...args) {
19
25
  console.error(red('FATAL: '), ...args);
@@ -1 +1 @@
1
- export declare const LIB_VERSION = "1.3.0";
1
+ export declare const LIB_VERSION = "1.3.1";
@@ -1 +1 @@
1
- export const LIB_VERSION = '1.3.0';
1
+ export const LIB_VERSION = '1.3.1';
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "engines": {
8
8
  "node": ">=14"
9
9
  },
10
- "version": "1.3.0",
10
+ "version": "1.3.1",
11
11
  "description": "Modern custom Shopify storefronts",
12
12
  "license": "MIT",
13
13
  "main": "dist/esnext/index.js",
@@ -89,9 +89,9 @@
89
89
  "@graphql-codegen/typescript-operations": "2.3.2",
90
90
  "@graphql-typed-document-node/core": "^3.1.0",
91
91
  "@rollup/plugin-graphql": "^1.0.0",
92
- "@testing-library/jest-dom": "^5.16.4",
92
+ "@testing-library/jest-dom": "^5.16.5",
93
93
  "@testing-library/react": "^13.3.0",
94
- "@testing-library/user-event": "^14.3.0",
94
+ "@testing-library/user-event": "^14.4.3",
95
95
  "@types/body-parser": "^1.19.2",
96
96
  "@types/connect": "^3.4.34",
97
97
  "@types/graphql": "^14.5.0",
@@ -111,7 +111,7 @@
111
111
  "postcss": "^8",
112
112
  "raw-loader": "^4.0.2",
113
113
  "rimraf": "^3.0.2",
114
- "vitest": "^0.22.0"
114
+ "vitest": "^0.22.1"
115
115
  },
116
116
  "peerDependencies": {
117
117
  "body-parser": "^1.20.0",