@shopify/hydrogen-react 2022.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +218 -0
- package/dist/dev/ExternalVideo.cjs +39 -0
- package/dist/dev/ExternalVideo.cjs.map +1 -0
- package/dist/dev/ExternalVideo.js +39 -0
- package/dist/dev/ExternalVideo.js.map +1 -0
- package/dist/dev/Image.cjs +104 -0
- package/dist/dev/Image.cjs.map +1 -0
- package/dist/dev/Image.js +104 -0
- package/dist/dev/Image.js.map +1 -0
- package/dist/dev/MediaFile.cjs +57 -0
- package/dist/dev/MediaFile.cjs.map +1 -0
- package/dist/dev/MediaFile.js +57 -0
- package/dist/dev/MediaFile.js.map +1 -0
- package/dist/dev/Metafield.cjs +295 -0
- package/dist/dev/Metafield.cjs.map +1 -0
- package/dist/dev/Metafield.js +295 -0
- package/dist/dev/Metafield.js.map +1 -0
- package/dist/dev/ModelViewer.cjs +145 -0
- package/dist/dev/ModelViewer.cjs.map +1 -0
- package/dist/dev/ModelViewer.js +145 -0
- package/dist/dev/ModelViewer.js.map +1 -0
- package/dist/dev/Money.cjs +40 -0
- package/dist/dev/Money.cjs.map +1 -0
- package/dist/dev/Money.js +40 -0
- package/dist/dev/Money.js.map +1 -0
- package/dist/dev/ProductPrice.cjs +61 -0
- package/dist/dev/ProductPrice.cjs.map +1 -0
- package/dist/dev/ProductPrice.js +61 -0
- package/dist/dev/ProductPrice.js.map +1 -0
- package/dist/dev/ProductProvider.cjs +161 -0
- package/dist/dev/ProductProvider.cjs.map +1 -0
- package/dist/dev/ProductProvider.js +161 -0
- package/dist/dev/ProductProvider.js.map +1 -0
- package/dist/dev/ShopPayButton.cjs +64 -0
- package/dist/dev/ShopPayButton.cjs.map +1 -0
- package/dist/dev/ShopPayButton.js +64 -0
- package/dist/dev/ShopPayButton.js.map +1 -0
- package/dist/dev/ShopifyProvider.cjs +46 -0
- package/dist/dev/ShopifyProvider.cjs.map +1 -0
- package/dist/dev/ShopifyProvider.js +46 -0
- package/dist/dev/ShopifyProvider.js.map +1 -0
- package/dist/dev/Video.cjs +44 -0
- package/dist/dev/Video.cjs.map +1 -0
- package/dist/dev/Video.js +44 -0
- package/dist/dev/Video.js.map +1 -0
- package/dist/dev/flatten-connection.cjs +23 -0
- package/dist/dev/flatten-connection.cjs.map +1 -0
- package/dist/dev/flatten-connection.js +23 -0
- package/dist/dev/flatten-connection.js.map +1 -0
- package/dist/dev/image-size.cjs +80 -0
- package/dist/dev/image-size.cjs.map +1 -0
- package/dist/dev/image-size.js +80 -0
- package/dist/dev/image-size.js.map +1 -0
- package/dist/dev/index.cjs +35 -0
- package/dist/dev/index.cjs.map +1 -0
- package/dist/dev/index.js +35 -0
- package/dist/dev/index.js.map +1 -0
- package/dist/dev/load-script.cjs +52 -0
- package/dist/dev/load-script.cjs.map +1 -0
- package/dist/dev/load-script.js +52 -0
- package/dist/dev/load-script.js.map +1 -0
- package/dist/dev/storefront-api-constants.cjs +5 -0
- package/dist/dev/storefront-api-constants.cjs.map +1 -0
- package/dist/dev/storefront-api-constants.js +5 -0
- package/dist/dev/storefront-api-constants.js.map +1 -0
- package/dist/dev/storefront-client.cjs +72 -0
- package/dist/dev/storefront-client.cjs.map +1 -0
- package/dist/dev/storefront-client.js +72 -0
- package/dist/dev/storefront-client.js.map +1 -0
- package/dist/dev/useMoney.cjs +72 -0
- package/dist/dev/useMoney.cjs.map +1 -0
- package/dist/dev/useMoney.js +72 -0
- package/dist/dev/useMoney.js.map +1 -0
- package/dist/prod/ExternalVideo.cjs +39 -0
- package/dist/prod/ExternalVideo.cjs.map +1 -0
- package/dist/prod/ExternalVideo.js +39 -0
- package/dist/prod/ExternalVideo.js.map +1 -0
- package/dist/prod/Image.cjs +99 -0
- package/dist/prod/Image.cjs.map +1 -0
- package/dist/prod/Image.js +99 -0
- package/dist/prod/Image.js.map +1 -0
- package/dist/prod/MediaFile.cjs +59 -0
- package/dist/prod/MediaFile.cjs.map +1 -0
- package/dist/prod/MediaFile.js +59 -0
- package/dist/prod/MediaFile.js.map +1 -0
- package/dist/prod/Metafield.cjs +288 -0
- package/dist/prod/Metafield.cjs.map +1 -0
- package/dist/prod/Metafield.js +288 -0
- package/dist/prod/Metafield.js.map +1 -0
- package/dist/prod/ModelViewer.cjs +143 -0
- package/dist/prod/ModelViewer.cjs.map +1 -0
- package/dist/prod/ModelViewer.js +143 -0
- package/dist/prod/ModelViewer.js.map +1 -0
- package/dist/prod/Money.cjs +40 -0
- package/dist/prod/Money.cjs.map +1 -0
- package/dist/prod/Money.js +40 -0
- package/dist/prod/Money.js.map +1 -0
- package/dist/prod/ProductPrice.cjs +61 -0
- package/dist/prod/ProductPrice.cjs.map +1 -0
- package/dist/prod/ProductPrice.js +61 -0
- package/dist/prod/ProductPrice.js.map +1 -0
- package/dist/prod/ProductProvider.cjs +161 -0
- package/dist/prod/ProductProvider.cjs.map +1 -0
- package/dist/prod/ProductProvider.js +161 -0
- package/dist/prod/ProductProvider.js.map +1 -0
- package/dist/prod/ShopPayButton.cjs +64 -0
- package/dist/prod/ShopPayButton.cjs.map +1 -0
- package/dist/prod/ShopPayButton.js +64 -0
- package/dist/prod/ShopPayButton.js.map +1 -0
- package/dist/prod/ShopifyProvider.cjs +46 -0
- package/dist/prod/ShopifyProvider.cjs.map +1 -0
- package/dist/prod/ShopifyProvider.js +46 -0
- package/dist/prod/ShopifyProvider.js.map +1 -0
- package/dist/prod/Video.cjs +44 -0
- package/dist/prod/Video.cjs.map +1 -0
- package/dist/prod/Video.js +44 -0
- package/dist/prod/Video.js.map +1 -0
- package/dist/prod/flatten-connection.cjs +18 -0
- package/dist/prod/flatten-connection.cjs.map +1 -0
- package/dist/prod/flatten-connection.js +18 -0
- package/dist/prod/flatten-connection.js.map +1 -0
- package/dist/prod/image-size.cjs +80 -0
- package/dist/prod/image-size.cjs.map +1 -0
- package/dist/prod/image-size.js +80 -0
- package/dist/prod/image-size.js.map +1 -0
- package/dist/prod/index.cjs +35 -0
- package/dist/prod/index.cjs.map +1 -0
- package/dist/prod/index.js +35 -0
- package/dist/prod/index.js.map +1 -0
- package/dist/prod/load-script.cjs +52 -0
- package/dist/prod/load-script.cjs.map +1 -0
- package/dist/prod/load-script.js +52 -0
- package/dist/prod/load-script.js.map +1 -0
- package/dist/prod/storefront-api-constants.cjs +5 -0
- package/dist/prod/storefront-api-constants.cjs.map +1 -0
- package/dist/prod/storefront-api-constants.js +5 -0
- package/dist/prod/storefront-api-constants.js.map +1 -0
- package/dist/prod/storefront-client.cjs +57 -0
- package/dist/prod/storefront-client.cjs.map +1 -0
- package/dist/prod/storefront-client.js +57 -0
- package/dist/prod/storefront-client.js.map +1 -0
- package/dist/prod/useMoney.cjs +72 -0
- package/dist/prod/useMoney.cjs.map +1 -0
- package/dist/prod/useMoney.js +72 -0
- package/dist/prod/useMoney.js.map +1 -0
- package/dist/types/ExternalVideo.d.ts +67 -0
- package/dist/types/Image.d.ts +54 -0
- package/dist/types/MediaFile.d.ts +31 -0
- package/dist/types/Metafield.d.ts +58 -0
- package/dist/types/ModelViewer.d.ts +57 -0
- package/dist/types/Money.d.ts +29 -0
- package/dist/types/ProductPrice.d.ts +22 -0
- package/dist/types/ProductProvider.d.ts +74 -0
- package/dist/types/ShopPayButton.d.ts +42 -0
- package/dist/types/ShopifyProvider.d.ts +42 -0
- package/dist/types/Video.d.ts +20 -0
- package/dist/types/flatten-connection.d.ts +17 -0
- package/dist/types/image-size.d.ts +36 -0
- package/dist/types/index.d.cts +15 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/types/load-script.d.ts +11 -0
- package/dist/types/storefront-api-constants.d.ts +1 -0
- package/dist/types/storefront-api-response.types.d.ts +68 -0
- package/dist/types/storefront-api-types.d.ts +6537 -0
- package/dist/types/storefront-client.d.ts +63 -0
- package/dist/types/useMoney.d.ts +55 -0
- package/dist/umd/hydrogen-react.dev.js +1472 -0
- package/dist/umd/hydrogen-react.dev.js.map +1 -0
- package/dist/umd/hydrogen-react.prod.js +3 -0
- package/dist/umd/hydrogen-react.prod.js.map +1 -0
- package/package.json +106 -0
- package/storefront.schema.json +1 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { LanguageCode, CountryCode, Shop } from './storefront-api-types.js';
|
|
3
|
+
/**
|
|
4
|
+
* The `<ShopifyProvider/>` component enables use of the `useShop()` hook. The component should wrap your app.
|
|
5
|
+
*/
|
|
6
|
+
export declare function ShopifyProvider({ children, shopifyConfig, }: {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
shopifyConfig: ShopifyContextValue;
|
|
9
|
+
}): JSX.Element;
|
|
10
|
+
/**
|
|
11
|
+
* Provides access to the `shopifyConfig` prop of `<ShopifyProvider/>`. Must be a descendent of `<ShopifyProvider/>`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function useShop(): ShopifyContextValue;
|
|
14
|
+
/**
|
|
15
|
+
* Shopify-specific values that are used in various Hydrogen-UI components and hooks.
|
|
16
|
+
*/
|
|
17
|
+
export declare type ShopifyContextValue = {
|
|
18
|
+
/** The globally-unique identifier for the Shop */
|
|
19
|
+
storefrontId?: string;
|
|
20
|
+
/** The host name of the domain (eg: `{shop}.myshopify.com`). If a URL with a scheme (for example `https://`) is passed in, then the scheme is removed. */
|
|
21
|
+
storeDomain: Shop['primaryDomain']['host'];
|
|
22
|
+
/** The Storefront API public access token. Refer to the [authentication](https://shopify.dev/api/storefront#authentication) documentation for more details. */
|
|
23
|
+
storefrontToken: string;
|
|
24
|
+
/** The Storefront API version. This should almost always be the same as the version Hydrogen-UI was built for. Learn more about Shopify [API versioning](https://shopify.dev/api/usage/versioning) for more details. */
|
|
25
|
+
storefrontApiVersion: string;
|
|
26
|
+
country?: {
|
|
27
|
+
/**
|
|
28
|
+
* The code designating a country, which generally follows ISO 3166-1 alpha-2 guidelines. If a territory doesn't have a country code value in the `CountryCode` enum, it might be considered a subdivision of another country. For example, the territories associated with Spain are represented by the country code `ES`, and the territories associated with the United States of America are represented by the country code `US`.
|
|
29
|
+
*/
|
|
30
|
+
isoCode: CountryCode;
|
|
31
|
+
};
|
|
32
|
+
language?: {
|
|
33
|
+
/**
|
|
34
|
+
* `ISO 369` language codes supported by Shopify.
|
|
35
|
+
*/
|
|
36
|
+
isoCode: LanguageCode;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The locale string based on `country` and `language`.
|
|
40
|
+
*/
|
|
41
|
+
locale?: string;
|
|
42
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type HTMLAttributes } from 'react';
|
|
2
|
+
import { shopifyImageLoader } from './image-size.js';
|
|
3
|
+
import type { Video as VideoType } from './storefront-api-types.js';
|
|
4
|
+
import type { PartialDeep } from 'type-fest';
|
|
5
|
+
export interface VideoProps {
|
|
6
|
+
/** An object with fields that correspond to the Storefront API's [Video object](https://shopify.dev/api/storefront/latest/objects/video). */
|
|
7
|
+
data: PartialDeep<VideoType, {
|
|
8
|
+
recurseIntoArrays: true;
|
|
9
|
+
}>;
|
|
10
|
+
/** An object of image size options for the video's `previewImage`. Uses `shopifyImageLoader` to generate the `poster` URL. */
|
|
11
|
+
previewImageOptions?: Parameters<typeof shopifyImageLoader>[0];
|
|
12
|
+
/** Props that will be passed to the `video` element's `source` children elements. */
|
|
13
|
+
sourceProps?: HTMLAttributes<HTMLSourceElement> & {
|
|
14
|
+
'data-testid'?: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The `Video` component renders a `video` for the Storefront API's [Video object](https://shopify.dev/api/storefront/reference/products/video).
|
|
19
|
+
*/
|
|
20
|
+
export declare function Video(props: JSX.IntrinsicElements['video'] & VideoProps): JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PartialDeep } from 'type-fest';
|
|
2
|
+
/**
|
|
3
|
+
* The `flattenConnection` utility transforms a connection object from the Storefront API (for example, [Product-related connections](https://shopify.dev/api/storefront/reference/products/product)) into a flat array of nodes.
|
|
4
|
+
* The utility works with either `nodes` or `edges.node`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function flattenConnection<T>(connection: PartialDeep<GraphQLConnection<T>, {
|
|
7
|
+
recurseIntoArrays: true;
|
|
8
|
+
}>): PartialDeep<T, {
|
|
9
|
+
recurseIntoArrays: true;
|
|
10
|
+
}>[];
|
|
11
|
+
interface GraphQLConnection<T> {
|
|
12
|
+
edges?: {
|
|
13
|
+
node: T;
|
|
14
|
+
}[];
|
|
15
|
+
nodes?: T[];
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Image as ImageType } from './storefront-api-types.js';
|
|
2
|
+
import type { PartialDeep } from 'type-fest';
|
|
3
|
+
import type { ShopifyLoaderOptions, ShopifyLoaderParams } from './Image.js';
|
|
4
|
+
export declare const IMG_SRC_SET_SIZES: number[];
|
|
5
|
+
/**
|
|
6
|
+
* Adds image size parameters to an image URL hosted by Shopify's CDN
|
|
7
|
+
*/
|
|
8
|
+
export declare function addImageSizeParametersToUrl({ src, width, height, crop, scale, }: ShopifyLoaderParams): string;
|
|
9
|
+
export declare function shopifyImageLoader(params: ShopifyLoaderParams): string;
|
|
10
|
+
declare type HtmlImageProps = React.ImgHTMLAttributes<HTMLImageElement>;
|
|
11
|
+
export declare type GetShopifyImageDimensionsProps = {
|
|
12
|
+
data: Pick<PartialDeep<ImageType, {
|
|
13
|
+
recurseIntoArrays: true;
|
|
14
|
+
}>, 'altText' | 'url' | 'id' | 'width' | 'height'>;
|
|
15
|
+
loaderOptions?: ShopifyLoaderOptions;
|
|
16
|
+
elementProps?: {
|
|
17
|
+
width?: HtmlImageProps['width'];
|
|
18
|
+
height?: HtmlImageProps['height'];
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
declare type GetShopifyImageDimensionsPropsReturn = {
|
|
22
|
+
width: number | string | null;
|
|
23
|
+
height: number | string | null;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Width and height are determined using the followiing priority list:
|
|
27
|
+
* 1. `loaderOptions`'s width/height
|
|
28
|
+
* 2. `elementProps`'s width/height
|
|
29
|
+
* 3. `data`'s width/height
|
|
30
|
+
*
|
|
31
|
+
* If only one of `width` or `height` are defined, then the other will attempt to be calculated based on the Image's aspect ratio,
|
|
32
|
+
* provided that both `data.width` and `data.height` are available. If not, then the aspect ratio cannot be determined and the missing
|
|
33
|
+
* value will reamin as `null`
|
|
34
|
+
*/
|
|
35
|
+
export declare function getShopifyImageDimensions({ data: sfapiImage, loaderOptions, elementProps, }: GetShopifyImageDimensionsProps): GetShopifyImageDimensionsPropsReturn;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { ExternalVideo } from './ExternalVideo.js';
|
|
2
|
+
export { flattenConnection } from './flatten-connection.js';
|
|
3
|
+
export { Image } from './Image.js';
|
|
4
|
+
export { MediaFile } from './MediaFile.js';
|
|
5
|
+
export { Metafield, parseMetafield, parseMetafieldValue } from './Metafield.js';
|
|
6
|
+
export { ModelViewer } from './ModelViewer.js';
|
|
7
|
+
export { Money } from './Money.js';
|
|
8
|
+
export { ProductPrice } from './ProductPrice.js';
|
|
9
|
+
export { ProductProvider, useProduct } from './ProductProvider.js';
|
|
10
|
+
export { ShopifyProvider, useShop } from './ShopifyProvider.js';
|
|
11
|
+
export { ShopPayButton } from './ShopPayButton.js';
|
|
12
|
+
export type { StorefrontApiResponseOk, StorefrontApiResponseOkPartial, StorefrontApiResponseError, StorefrontApiResponse, StorefrontApiResponsePartial, } from './storefront-api-response.types.js';
|
|
13
|
+
export { createStorefrontClient } from './storefront-client.js';
|
|
14
|
+
export { useMoney } from './useMoney.js';
|
|
15
|
+
export { Video } from './Video.js';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { ExternalVideo } from './ExternalVideo.js';
|
|
2
|
+
export { flattenConnection } from './flatten-connection.js';
|
|
3
|
+
export { Image } from './Image.js';
|
|
4
|
+
export { MediaFile } from './MediaFile.js';
|
|
5
|
+
export { Metafield, parseMetafield, parseMetafieldValue } from './Metafield.js';
|
|
6
|
+
export { ModelViewer } from './ModelViewer.js';
|
|
7
|
+
export { Money } from './Money.js';
|
|
8
|
+
export { ProductPrice } from './ProductPrice.js';
|
|
9
|
+
export { ProductProvider, useProduct } from './ProductProvider.js';
|
|
10
|
+
export { ShopifyProvider, useShop } from './ShopifyProvider.js';
|
|
11
|
+
export { ShopPayButton } from './ShopPayButton.js';
|
|
12
|
+
export type { StorefrontApiResponseOk, StorefrontApiResponseOkPartial, StorefrontApiResponseError, StorefrontApiResponse, StorefrontApiResponsePartial, } from './storefront-api-response.types.js';
|
|
13
|
+
export { createStorefrontClient } from './storefront-client.js';
|
|
14
|
+
export { useMoney } from './useMoney.js';
|
|
15
|
+
export { Video } from './Video.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function loadScript(src: string, options?: {
|
|
2
|
+
module?: boolean;
|
|
3
|
+
in?: 'head' | 'body';
|
|
4
|
+
}): Promise<boolean>;
|
|
5
|
+
declare type LoadScriptParams = Parameters<typeof loadScript>;
|
|
6
|
+
/**
|
|
7
|
+
* The `useLoadScript` hook loads an external script tag in the browser. It allows React components to lazy-load large third-party dependencies.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useLoadScript(url: LoadScriptParams[0], options?: LoadScriptParams[1]): ScriptState;
|
|
10
|
+
declare type ScriptState = 'loading' | 'done' | 'error';
|
|
11
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SFAPI_VERSION = "2022-07";
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { FormattedExecutionResult } from 'graphql';
|
|
2
|
+
import type { PartialDeep } from 'type-fest';
|
|
3
|
+
/**
|
|
4
|
+
* Provides more information about the error(s) including properties and metadata.
|
|
5
|
+
* Refer to https://shopify.dev/api/storefront#status_and_error_codes for more information.
|
|
6
|
+
*/
|
|
7
|
+
declare type StorefrontApiExtensions = {
|
|
8
|
+
/**
|
|
9
|
+
* Shows error codes common to Shopify. Additional error codes may also be shown.
|
|
10
|
+
* https://shopify.dev/api/storefront#status_and_error_codes
|
|
11
|
+
*/
|
|
12
|
+
code?: 'THROTTLED' | 'ACCESS_DENIED' | 'SHOP_INACTIVE' | 'INTERNAL_SERVER_ERROR' | string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The Storefront API can return a 200 OK response code when the query succeeds, and will populate the `data` property. The generic you pass in through type parameters will be the shape of the `data` object if successful. If you prefer a "deeply-partial" version of that generic object, consider using `StorefrontApiResponseOkPartial` instead.
|
|
16
|
+
*
|
|
17
|
+
* The Storefront API can also return a 200 OK response code in cases that would typically produce 4xx errors in REST. This will propulate the `errors` property.
|
|
18
|
+
*
|
|
19
|
+
* Refer to https://shopify.dev/api/storefront#status_and_error_codes for more information.
|
|
20
|
+
*/
|
|
21
|
+
export declare type StorefrontApiResponseOk<DataGeneric> = FormattedExecutionResult<DataGeneric, StorefrontApiExtensions>;
|
|
22
|
+
/**
|
|
23
|
+
* The Storefront API can return a 200 OK response code when the query succeeds, and will populate the `data` property. The generic you pass in through type parameters will be the shape of the `data` object, with `Partial` deeply-applied to all nested objects and properties, if successful. If you prefer not using this "deeply-partial" generic data object, consider using `StorefrontApiResponseOk` instead.
|
|
24
|
+
*
|
|
25
|
+
* The Storefront API can also return a 200 OK response code in cases that would typically produce 4xx errors in REST. This will propulate the `errors` property.
|
|
26
|
+
*
|
|
27
|
+
* Refer to https://shopify.dev/api/storefront#status_and_error_codes for more information.
|
|
28
|
+
*/
|
|
29
|
+
export declare type StorefrontApiResponseOkPartial<DataGeneric> = FormattedExecutionResult<PartialDeep<DataGeneric, {
|
|
30
|
+
recurseIntoArrays: true;
|
|
31
|
+
}>, StorefrontApiExtensions>;
|
|
32
|
+
/**
|
|
33
|
+
* The 4xx and 5xx errors occur infrequently. They are often related to network communications, your account, or an issue with Shopify’s services.
|
|
34
|
+
*
|
|
35
|
+
* Many errors that would typically return a 4xx or 5xx status code, return an HTTP 200 errors response instead. Refer to the 200 OK section in the link below for details.
|
|
36
|
+
*
|
|
37
|
+
* Commonly the response is a `JSON.parse`-able string, but in rare occasions may also return HTML which is not `JSON.parse()`-able.
|
|
38
|
+
*
|
|
39
|
+
* Refer to https://shopify.dev/api/storefront#status_and_error_codes for more information.
|
|
40
|
+
*/
|
|
41
|
+
export declare type StorefrontApiResponseError = string | {
|
|
42
|
+
errors: {
|
|
43
|
+
query: string;
|
|
44
|
+
};
|
|
45
|
+
} | {
|
|
46
|
+
errors: string;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* The Storefront API can return a 200 OK response code when the query succeeds, and will populate the `data` property. The generic you pass in through type parameters will be the shape of the `data` object if successful. If you prefer a "deeply-partial" version of that generic object, consider using `StorefrontApiResponseOkPartial` instead.
|
|
50
|
+
*
|
|
51
|
+
* The Storefront API can also return a 200 OK response code in cases that would typically produce 4xx errors in REST. This will propulate the `errors` property.
|
|
52
|
+
*
|
|
53
|
+
* 4xx and 5xx errors occur infrequently. They are often related to network communications, your account, or an issue with Shopify’s services. Commonly the response is a `JSON.parse`-able string, but in rare occasions may also return HTML which is not `JSON.parse()`-able.
|
|
54
|
+
*
|
|
55
|
+
* Refer to https://shopify.dev/api/storefront#status_and_error_codes for more information.
|
|
56
|
+
*/
|
|
57
|
+
export declare type StorefrontApiResponse<DataGeneric> = StorefrontApiResponseOk<DataGeneric> | StorefrontApiResponseError;
|
|
58
|
+
/**
|
|
59
|
+
* The Storefront API can return a 200 OK response code when the query succeeds, and will populate the `data` property. The generic you pass in through type parameters will be the shape of the `data` object, with `Partial` deeply-applied to all nested objects and properties, if successful. If you prefer not using this "deeply-partial" generic data object, consider using `StorefrontApiResponseOk` instead.
|
|
60
|
+
*
|
|
61
|
+
* The Storefront API can also return a 200 OK response code in cases that would typically produce 4xx errors in REST. This will propulate the `errors` property.
|
|
62
|
+
*
|
|
63
|
+
* 4xx and 5xx errors occur infrequently. They are often related to network communications, your account, or an issue with Shopify’s services. Commonly the response is a `JSON.parse`-able string, but in rare occasions may also return HTML which is not `JSON.parse()`-able.
|
|
64
|
+
*
|
|
65
|
+
* Refer to https://shopify.dev/api/storefront#status_and_error_codes for more information.
|
|
66
|
+
*/
|
|
67
|
+
export declare type StorefrontApiResponsePartial<DataGeneric> = StorefrontApiResponseOkPartial<DataGeneric> | StorefrontApiResponseError;
|
|
68
|
+
export {};
|