@swishapp/sdk 0.61.0 → 0.71.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/dist/intents/handlers/open-quick-buy-handler.d.ts +1 -1
- package/dist/intents/intent-handler.d.ts +3 -1
- package/dist/intents/intent-hook.d.ts +6 -4
- package/dist/intents/intents.d.ts +15 -5
- package/dist/options/swish-options.d.ts +14 -0
- package/dist/options/types.d.ts +118 -0
- package/dist/state/index.d.ts +1 -0
- package/dist/storefront-api/load-product-card-data.d.ts +4 -2
- package/dist/storefront-api/load-product-detail-data.d.ts +4 -2
- package/dist/storefront-api/load-product-images.d.ts +4 -1
- package/dist/storefront-api/load-product-options.d.ts +4 -1
- package/dist/storefront-api/load-product-recommendations.d.ts +4 -2
- package/dist/storefront-api/load-save-intent-data.d.ts +8 -7
- package/dist/storefront-api/load-selected-variant.d.ts +4 -2
- package/dist/storefront-api/storefront-api-client.d.ts +120 -10
- package/dist/storefront-api/types/storefront.types.d.ts +107 -1
- package/dist/swish-api/swish-api-client.d.ts +4 -8
- package/dist/swish-ui/swish-ui-element.d.ts +3 -1
- package/dist/swish-ui/swish-ui.d.ts +54 -0
- package/dist/swish-ui/{swish-ui-utils.d.ts → types.d.ts} +4 -37
- package/dist/swish.d.ts +28 -20
- package/dist/swish.js +78 -78
- package/dist/types.d.ts +2 -45
- package/dist/utils/shop-bridge.d.ts +4 -2
- package/dist/utils/shopify-badge-utils.d.ts +22 -0
- package/package.json +9 -9
- package/dist/index.d.ts +0 -9
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
import { QuickBuySubmitData } from "../../swish
|
|
2
|
+
import { QuickBuySubmitData } from "../../swish";
|
|
3
3
|
import { IntentHandler } from "../intent-handler";
|
|
4
4
|
import { IntentBase, IntentResponse, SuccessIntentResponse } from "../types";
|
|
5
5
|
export declare const OpenQuickBuyIntentDataSchema: v.ObjectSchema<{
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { SwishApp } from "../swish";
|
|
2
|
+
import { SwishUi } from "../swish-ui/swish-ui";
|
|
2
3
|
import { IntentOptions } from "./intents";
|
|
3
4
|
import { Intent, IntentEventBus, IntentResponse } from "./types";
|
|
4
5
|
export declare abstract class IntentHandler<T extends Intent = Intent> {
|
|
5
6
|
protected readonly swish: SwishApp;
|
|
7
|
+
protected readonly ui: SwishUi;
|
|
6
8
|
protected readonly eventBus: IntentEventBus;
|
|
7
9
|
protected readonly options: IntentOptions;
|
|
8
|
-
constructor(swish: SwishApp, eventBus: IntentEventBus, options: IntentOptions);
|
|
10
|
+
constructor(swish: SwishApp, ui: SwishUi, eventBus: IntentEventBus, options: IntentOptions);
|
|
9
11
|
abstract invoke(intent: T): Promise<IntentResponse<T>>;
|
|
10
12
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { SwishApp } from "../swish";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { SwishApp } from "../swish";
|
|
2
|
+
import { SwishUi } from "../swish-ui/swish-ui";
|
|
3
|
+
import type { IntentOptions } from "./intents";
|
|
4
|
+
import type { Intent, IntentResponse } from "./types";
|
|
4
5
|
export declare abstract class IntentHook<T extends Intent = Intent> {
|
|
5
6
|
protected readonly swish: SwishApp;
|
|
7
|
+
protected readonly ui: SwishUi;
|
|
6
8
|
protected readonly options: IntentOptions;
|
|
7
|
-
constructor(swish: SwishApp, options: IntentOptions);
|
|
9
|
+
constructor(swish: SwishApp, ui: SwishUi, options: IntentOptions);
|
|
8
10
|
abstract invoke(respomse: IntentResponse<T>): Promise<void>;
|
|
9
11
|
}
|
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import { SwishApp } from "../swish";
|
|
2
2
|
import { Intent, IntentActivity, IntentQuery, IntentQueryWithParams, IntentResponse } from "./types";
|
|
3
|
+
import { SwishUi } from "../swish-ui/swish-ui";
|
|
3
4
|
export interface IntentOptions {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
save: {
|
|
6
|
+
requireVariant: boolean;
|
|
7
|
+
showToast: boolean;
|
|
8
|
+
};
|
|
9
|
+
edit: {
|
|
10
|
+
showToast: boolean;
|
|
11
|
+
};
|
|
12
|
+
unsave: {
|
|
13
|
+
requireConfirmation: boolean;
|
|
14
|
+
openEditor: boolean;
|
|
15
|
+
showToast: boolean;
|
|
16
|
+
};
|
|
8
17
|
}
|
|
9
18
|
export declare class Intents {
|
|
10
19
|
private readonly swish;
|
|
20
|
+
private readonly ui;
|
|
11
21
|
private readonly eventBus;
|
|
12
22
|
private readonly options;
|
|
13
|
-
constructor(swish: SwishApp,
|
|
23
|
+
constructor(swish: SwishApp, ui: SwishUi);
|
|
14
24
|
publishAnalyticsEvent(event: string, data: Record<string, any>): void;
|
|
15
25
|
invoke<T extends Intent>(intent: T): Promise<IntentActivity<T>>;
|
|
16
26
|
listen(intent: Pick<Intent, "action" | "type">, callback: (response: IntentResponse) => void): () => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { StorefrontApiOptions, SwishClientConfig } from "../swish";
|
|
2
|
+
import { StorefrontContext, SwishBadgeOptions, SwishMetafieldOptions, SwishOptions, SwishProxyOptions, SwishUiOptions } from "./types";
|
|
3
|
+
export type SwishOptionsInput = {
|
|
4
|
+
proxy?: SwishProxyOptions;
|
|
5
|
+
storefrontApi: StorefrontApiOptions;
|
|
6
|
+
storefrontContext: StorefrontContext;
|
|
7
|
+
badges?: SwishBadgeOptions;
|
|
8
|
+
metafields?: SwishMetafieldOptions;
|
|
9
|
+
swishApi?: SwishClientConfig & {
|
|
10
|
+
version: string;
|
|
11
|
+
};
|
|
12
|
+
swishUi?: SwishUiOptions;
|
|
13
|
+
};
|
|
14
|
+
export declare const createSwishOptions: (options: SwishOptionsInput) => SwishOptions;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { IntentOptions } from "../intents/intents";
|
|
2
|
+
import { CountryCode, LanguageCode } from "../storefront-api/types/storefront.types";
|
|
3
|
+
import { GetProductCardDataQuery, GetProductCardDataWithVariantQuery, StorefrontApiOptions, SwishClientConfig } from "../swish";
|
|
4
|
+
import { Badge } from "../utils/shopify-badge-utils";
|
|
5
|
+
export interface SwishOptions {
|
|
6
|
+
proxy: SwishProxyOptions;
|
|
7
|
+
storefrontApi: StorefrontApiOptions;
|
|
8
|
+
storefrontContext: StorefrontContext;
|
|
9
|
+
badges: SwishBadgeOptions;
|
|
10
|
+
metafields: SwishMetafieldOptions;
|
|
11
|
+
swishApi: SwishClientConfig & {
|
|
12
|
+
version: string;
|
|
13
|
+
};
|
|
14
|
+
swishUi: SwishUiOptions;
|
|
15
|
+
}
|
|
16
|
+
export interface SwishMetafieldOptions {
|
|
17
|
+
product: `${string}.${string}`[];
|
|
18
|
+
productVariant: `${string}.${string}`[];
|
|
19
|
+
}
|
|
20
|
+
export interface SwishBadgeOptions {
|
|
21
|
+
getBadges: (args: {
|
|
22
|
+
product: GetProductCardDataQuery["product"];
|
|
23
|
+
variant?: GetProductCardDataWithVariantQuery["variant"];
|
|
24
|
+
defaultBadges: string[];
|
|
25
|
+
}) => (string | Badge)[];
|
|
26
|
+
}
|
|
27
|
+
export interface SwishProxyOptions {
|
|
28
|
+
baseUrl: string;
|
|
29
|
+
}
|
|
30
|
+
export interface SwishUiOptions {
|
|
31
|
+
baseUrl: string;
|
|
32
|
+
components: SwishComponentOptions;
|
|
33
|
+
css: (string | URL)[];
|
|
34
|
+
intents: IntentOptions;
|
|
35
|
+
theme: Record<string, string>;
|
|
36
|
+
version: string;
|
|
37
|
+
}
|
|
38
|
+
export interface StorefrontContext {
|
|
39
|
+
customer: {
|
|
40
|
+
id: string | null;
|
|
41
|
+
email: string | null;
|
|
42
|
+
firstName: string | null;
|
|
43
|
+
lastName: string | null;
|
|
44
|
+
b2b: boolean | null;
|
|
45
|
+
};
|
|
46
|
+
localization: {
|
|
47
|
+
country: CountryCode;
|
|
48
|
+
language: LanguageCode;
|
|
49
|
+
market: string;
|
|
50
|
+
};
|
|
51
|
+
routes: {
|
|
52
|
+
accountUrl: string;
|
|
53
|
+
accountLoginUrl: string;
|
|
54
|
+
rootUrl: string;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export interface SwishComponentOptions {
|
|
58
|
+
productRow: SwishProductRowOptions;
|
|
59
|
+
productDetail: SwishProductDetailOptions;
|
|
60
|
+
variantSelect: SwishVariantSelectOptions;
|
|
61
|
+
imageSlider: SwishImageSliderOptions;
|
|
62
|
+
images: SwishImageOptions;
|
|
63
|
+
buyButtons: SwishBuyButtonsOptions;
|
|
64
|
+
drawer: SwishDrawerOptions;
|
|
65
|
+
listDetailPage: SwishListDetailPageOptions;
|
|
66
|
+
}
|
|
67
|
+
export interface SwishListDetailPageOptions {
|
|
68
|
+
desktopColumns: number;
|
|
69
|
+
showBuyButton: boolean;
|
|
70
|
+
}
|
|
71
|
+
export interface SwishProductRowOptions {
|
|
72
|
+
showVariantTitle: boolean;
|
|
73
|
+
}
|
|
74
|
+
export interface SwishProductDetailOptions {
|
|
75
|
+
/** Clamp the description to this many lines in the UI. */
|
|
76
|
+
descriptionMaxLines: number;
|
|
77
|
+
}
|
|
78
|
+
export type SwishVariantSelectDisplay = "pills" | "rows";
|
|
79
|
+
export interface SwishVariantSelectOptions {
|
|
80
|
+
displayType: SwishVariantSelectDisplay;
|
|
81
|
+
}
|
|
82
|
+
export interface SwishImageSliderOptions {
|
|
83
|
+
flush: boolean;
|
|
84
|
+
loop: boolean;
|
|
85
|
+
}
|
|
86
|
+
export interface SwishBuyButtonsOptions {
|
|
87
|
+
shopPay: boolean;
|
|
88
|
+
}
|
|
89
|
+
export interface SwishImageOptions {
|
|
90
|
+
baseTint: boolean;
|
|
91
|
+
}
|
|
92
|
+
export type SwishDrawerNavigationVariant = "floating" | "docked";
|
|
93
|
+
export interface SwishDrawerNavigationItem {
|
|
94
|
+
id: string;
|
|
95
|
+
enabled: boolean;
|
|
96
|
+
href: string;
|
|
97
|
+
}
|
|
98
|
+
export interface SwishDrawerNavigationOptions {
|
|
99
|
+
variant: SwishDrawerNavigationVariant;
|
|
100
|
+
items: SwishDrawerNavigationItem[];
|
|
101
|
+
}
|
|
102
|
+
export interface SwishDrawerMiniMenuItem {
|
|
103
|
+
title: string;
|
|
104
|
+
url: string;
|
|
105
|
+
}
|
|
106
|
+
export interface SwishDrawerMiniMenuOptions {
|
|
107
|
+
items: SwishDrawerMiniMenuItem[];
|
|
108
|
+
}
|
|
109
|
+
export interface SwishDrawerLogoOptions {
|
|
110
|
+
url: string;
|
|
111
|
+
altText: string;
|
|
112
|
+
}
|
|
113
|
+
export interface SwishDrawerOptions {
|
|
114
|
+
title: string;
|
|
115
|
+
logo: SwishDrawerLogoOptions;
|
|
116
|
+
navigation: SwishDrawerNavigationOptions;
|
|
117
|
+
miniMenu: SwishDrawerMiniMenuOptions;
|
|
118
|
+
}
|
package/dist/state/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StorefrontApiClient, StorefrontApiResponse } from "./storefront-api-client";
|
|
2
2
|
import type { GetProductCardDataQuery, GetProductCardDataWithVariantQuery } from "./types/storefront.generated";
|
|
3
|
-
import type { HasMetafieldsIdentifier } from "./types/storefront.types";
|
|
3
|
+
import type { CountryCode, HasMetafieldsIdentifier, LanguageCode } from "./types/storefront.types";
|
|
4
4
|
export type LoadProductCardDataResponse = StorefrontApiResponse<GetProductCardDataQuery | GetProductCardDataWithVariantQuery>;
|
|
5
5
|
export type { GetProductCardDataQueryVariables } from "./types/storefront.generated";
|
|
6
6
|
export interface LoadProductCardDataArgs {
|
|
@@ -8,8 +8,10 @@ export interface LoadProductCardDataArgs {
|
|
|
8
8
|
variantId?: string;
|
|
9
9
|
productMetafields?: HasMetafieldsIdentifier[];
|
|
10
10
|
variantMetafields?: HasMetafieldsIdentifier[];
|
|
11
|
+
country: CountryCode;
|
|
12
|
+
language: LanguageCode;
|
|
11
13
|
}
|
|
12
|
-
export declare const loadProductCardData: (client: StorefrontApiClient, { productId, variantId, productMetafields, variantMetafields, }: LoadProductCardDataArgs) => Promise<{
|
|
14
|
+
export declare const loadProductCardData: (client: StorefrontApiClient, { productId, variantId, productMetafields, variantMetafields, country, language, }: LoadProductCardDataArgs) => Promise<{
|
|
13
15
|
data: GetProductCardDataQuery | GetProductCardDataWithVariantQuery | undefined;
|
|
14
16
|
errors: import("@shopify/graphql-client").ResponseErrors | null;
|
|
15
17
|
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StorefrontApiClient, StorefrontApiResponse } from "./storefront-api-client";
|
|
2
2
|
import type { GetProductDetailDataQuery, GetProductDetailDataWithVariantQuery } from "./types/storefront.generated";
|
|
3
|
-
import type { HasMetafieldsIdentifier } from "./types/storefront.types";
|
|
3
|
+
import type { CountryCode, HasMetafieldsIdentifier, LanguageCode } from "./types/storefront.types";
|
|
4
4
|
export type LoadProductDetailDataResponse = StorefrontApiResponse<GetProductDetailDataQuery | GetProductDetailDataWithVariantQuery>;
|
|
5
5
|
export type { GetProductDetailDataQueryVariables } from "./types/storefront.generated";
|
|
6
6
|
export interface LoadProductDetailDataArgs {
|
|
@@ -8,8 +8,10 @@ export interface LoadProductDetailDataArgs {
|
|
|
8
8
|
variantId?: string;
|
|
9
9
|
productMetafields?: HasMetafieldsIdentifier[];
|
|
10
10
|
variantMetafields?: HasMetafieldsIdentifier[];
|
|
11
|
+
country: CountryCode;
|
|
12
|
+
language: LanguageCode;
|
|
11
13
|
}
|
|
12
|
-
export declare const loadProductDetailData: (client: StorefrontApiClient, { productId, variantId, productMetafields, variantMetafields, }: LoadProductDetailDataArgs) => Promise<{
|
|
14
|
+
export declare const loadProductDetailData: (client: StorefrontApiClient, { productId, variantId, productMetafields, variantMetafields, country, language, }: LoadProductDetailDataArgs) => Promise<{
|
|
13
15
|
data: GetProductDetailDataQuery | GetProductDetailDataWithVariantQuery | undefined;
|
|
14
16
|
errors: import("@shopify/graphql-client").ResponseErrors | null;
|
|
15
17
|
}>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { StorefrontApiClient, StorefrontApiResponse } from "./storefront-api-client";
|
|
2
|
+
import type { CountryCode, LanguageCode } from "./types/storefront.types";
|
|
2
3
|
export type LoadProductImagesResponse = StorefrontApiResponse<{
|
|
3
4
|
id: string;
|
|
4
5
|
altText: string;
|
|
@@ -10,8 +11,10 @@ export interface LoadProductImagesArgs {
|
|
|
10
11
|
productId: number;
|
|
11
12
|
variantId?: number | null;
|
|
12
13
|
}[];
|
|
14
|
+
country: CountryCode;
|
|
15
|
+
language: LanguageCode;
|
|
13
16
|
}
|
|
14
|
-
export declare const loadProductImages: (client: StorefrontApiClient, { items }: LoadProductImagesArgs) => Promise<{
|
|
17
|
+
export declare const loadProductImages: (client: StorefrontApiClient, { items, country, language }: LoadProductImagesArgs) => Promise<{
|
|
15
18
|
data: (Pick<import("./types/storefront.types").Image, "id" | "altText" | "url" | "thumbhash"> | undefined)[];
|
|
16
19
|
error: null;
|
|
17
20
|
} | {
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { StorefrontApiClient, StorefrontApiResponse } from "./storefront-api-client";
|
|
2
2
|
import type { GetProductOptionsQuery, GetProductOptionsWithVariantQuery } from "./types/storefront.generated";
|
|
3
|
+
import type { CountryCode, LanguageCode } from "./types/storefront.types";
|
|
3
4
|
export type LoadProductOptionsResponse = StorefrontApiResponse<GetProductOptionsQuery | GetProductOptionsWithVariantQuery>;
|
|
4
5
|
export type { GetProductOptionsQueryVariables } from "./types/storefront.generated";
|
|
5
6
|
export interface LoadProductOptionsArgs {
|
|
6
7
|
productId?: string;
|
|
7
8
|
variantId?: string;
|
|
8
9
|
productHandle?: string;
|
|
10
|
+
country: CountryCode;
|
|
11
|
+
language: LanguageCode;
|
|
9
12
|
}
|
|
10
|
-
export declare const loadProductOptions: (client: StorefrontApiClient, { productId, productHandle, variantId }: LoadProductOptionsArgs) => Promise<{
|
|
13
|
+
export declare const loadProductOptions: (client: StorefrontApiClient, { productId, productHandle, variantId, country, language, }: LoadProductOptionsArgs) => Promise<{
|
|
11
14
|
data: GetProductOptionsQuery | GetProductOptionsWithVariantQuery | undefined;
|
|
12
15
|
errors: import("@shopify/graphql-client").ResponseErrors | null;
|
|
13
16
|
}>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StorefrontApiClient, StorefrontApiResponse } from "./storefront-api-client";
|
|
2
|
-
import type { HasMetafieldsIdentifier, Product, ProductRecommendationIntent } from "./types/storefront.types";
|
|
2
|
+
import type { CountryCode, HasMetafieldsIdentifier, LanguageCode, Product, ProductRecommendationIntent } from "./types/storefront.types";
|
|
3
3
|
export type LoadProductRecommendationsResponse = StorefrontApiResponse<{
|
|
4
4
|
productRecommendations?: Product[] | null;
|
|
5
5
|
}>;
|
|
@@ -8,8 +8,10 @@ export interface LoadProductRecommendationsArgs {
|
|
|
8
8
|
productHandle?: string;
|
|
9
9
|
intent?: ProductRecommendationIntent;
|
|
10
10
|
productMetafields?: HasMetafieldsIdentifier[];
|
|
11
|
+
country: CountryCode;
|
|
12
|
+
language: LanguageCode;
|
|
11
13
|
}
|
|
12
|
-
export declare const loadProductRecommendations: (client: StorefrontApiClient, { productId, productHandle, intent, productMetafields, }: LoadProductRecommendationsArgs) => Promise<{
|
|
14
|
+
export declare const loadProductRecommendations: (client: StorefrontApiClient, { productId, productHandle, intent, productMetafields, country, language, }: LoadProductRecommendationsArgs) => Promise<{
|
|
13
15
|
data: {
|
|
14
16
|
productRecommendations?: Product[] | null;
|
|
15
17
|
} | undefined;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { StorefrontApiClient } from "./storefront-api-client";
|
|
2
2
|
import type { GetSaveIntentDataQuery, GetSaveIntentDataWithVariantQuery } from "./types/storefront.generated";
|
|
3
|
-
import
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
import { CountryCode, LanguageCode } from "./types/storefront.types";
|
|
4
|
+
export type LoadSaveIntentDataArgs = {
|
|
5
|
+
productId: string;
|
|
6
|
+
variantId?: string;
|
|
7
|
+
country: CountryCode;
|
|
8
|
+
language: LanguageCode;
|
|
9
|
+
};
|
|
10
|
+
export declare const loadSaveIntentData: (client: StorefrontApiClient, { productId, variantId, country, language }: LoadSaveIntentDataArgs) => Promise<{
|
|
10
11
|
data: GetSaveIntentDataQuery | GetSaveIntentDataWithVariantQuery | undefined;
|
|
11
12
|
errors: import("@shopify/graphql-client").ResponseErrors | null;
|
|
12
13
|
}>;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { StorefrontApiClient, StorefrontApiResponse } from "./storefront-api-client";
|
|
2
|
-
import type { SelectedOptionInput } from "./types/storefront.types";
|
|
3
2
|
import type { GetSelectedVariantQuery } from "./types/storefront.generated";
|
|
3
|
+
import type { CountryCode, LanguageCode, SelectedOptionInput } from "./types/storefront.types";
|
|
4
4
|
export type LoadSelectedVariantResponse = StorefrontApiResponse<GetSelectedVariantQuery>;
|
|
5
5
|
export type { GetSelectedVariantQueryVariables } from "./types/storefront.generated";
|
|
6
6
|
export interface LoadSelectedVariantArgs {
|
|
7
7
|
productId?: string;
|
|
8
8
|
productHandle?: string;
|
|
9
9
|
selectedOptions: SelectedOptionInput[];
|
|
10
|
+
country: CountryCode;
|
|
11
|
+
language: LanguageCode;
|
|
10
12
|
}
|
|
11
|
-
export declare const loadSelectedVariant: (client: StorefrontApiClient, { productId, productHandle, selectedOptions }: LoadSelectedVariantArgs) => Promise<{
|
|
13
|
+
export declare const loadSelectedVariant: (client: StorefrontApiClient, { productId, productHandle, selectedOptions, country, language, }: LoadSelectedVariantArgs) => Promise<{
|
|
12
14
|
data: GetSelectedVariantQuery | undefined;
|
|
13
15
|
errors: import("@shopify/graphql-client").ResponseErrors | null;
|
|
14
16
|
}>;
|
|
@@ -7,6 +7,8 @@ import { LoadProductOptionsArgs } from "./load-product-options";
|
|
|
7
7
|
import { LoadProductRecommendationsArgs } from "./load-product-recommendations";
|
|
8
8
|
import { LoadSaveIntentDataArgs } from "./load-save-intent-data";
|
|
9
9
|
import { LoadSelectedVariantArgs } from "./load-selected-variant";
|
|
10
|
+
import { ShopifyBadgesUtils } from "../utils/shopify-badge-utils";
|
|
11
|
+
import { StorefrontContext, SwishMetafieldOptions } from "../options/types";
|
|
10
12
|
export * from "./load-product-card-data";
|
|
11
13
|
export * from "./load-product-options";
|
|
12
14
|
export * from "./load-product-recommendations";
|
|
@@ -16,8 +18,8 @@ export interface StorefrontApiResponse<TData> {
|
|
|
16
18
|
data: TData;
|
|
17
19
|
errors: ResponseErrors;
|
|
18
20
|
}
|
|
19
|
-
export declare const API_VERSION = "2025-
|
|
20
|
-
export interface
|
|
21
|
+
export declare const API_VERSION = "2025-10";
|
|
22
|
+
export interface StorefrontApiOptions {
|
|
21
23
|
storeDomain: string;
|
|
22
24
|
accessToken: string;
|
|
23
25
|
}
|
|
@@ -25,48 +27,156 @@ export declare class StorefrontApiClient {
|
|
|
25
27
|
private client;
|
|
26
28
|
private readonly shortCache;
|
|
27
29
|
private readonly longCache;
|
|
28
|
-
|
|
30
|
+
private readonly options;
|
|
31
|
+
private readonly context;
|
|
32
|
+
private readonly metafields;
|
|
33
|
+
private readonly badges;
|
|
34
|
+
constructor(options: StorefrontApiOptions, context: StorefrontContext, badges: ShopifyBadgesUtils, metafields?: SwishMetafieldOptions);
|
|
29
35
|
fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
|
|
30
36
|
query: <TData, TVariables extends Record<string, unknown>>(query: string, variables: TVariables) => Promise<{
|
|
31
37
|
data: (TData extends undefined ? any : TData) | undefined;
|
|
32
38
|
errors: ResponseErrors | null;
|
|
33
39
|
}>;
|
|
34
|
-
loadProductOptions: (args: LoadProductOptionsArgs) => Promise<{
|
|
40
|
+
loadProductOptions: (args: ArgsWithoutDefaults<LoadProductOptionsArgs>) => Promise<{
|
|
35
41
|
data: import("./storefront-api-client").GetProductOptionsQuery | import("./storefront-api-client").GetProductOptionsWithVariantQuery | undefined;
|
|
36
42
|
errors: ResponseErrors | null;
|
|
37
43
|
}>;
|
|
38
|
-
loadSelectedVariant: (args: LoadSelectedVariantArgs) => Promise<{
|
|
44
|
+
loadSelectedVariant: (args: ArgsWithoutDefaults<LoadSelectedVariantArgs>) => Promise<{
|
|
39
45
|
data: import("./storefront-api-client").GetSelectedVariantQuery | undefined;
|
|
40
46
|
errors: ResponseErrors | null;
|
|
41
47
|
}>;
|
|
42
|
-
loadProductCardData: (args: LoadProductCardDataArgs) => Promise<{
|
|
48
|
+
loadProductCardData: (args: ArgsWithoutDefaults<LoadProductCardDataArgs>) => Promise<{
|
|
43
49
|
data: import("./storefront-api-client").GetProductCardDataQuery | import("./storefront-api-client").GetProductCardDataWithVariantQuery | undefined;
|
|
44
50
|
errors: ResponseErrors | null;
|
|
51
|
+
} | {
|
|
52
|
+
data: {
|
|
53
|
+
badges: import("../utils/shopify-badge-utils").Badge[];
|
|
54
|
+
product?: import("./types/storefront.types").Maybe<(Pick<import("./types/storefront.types").Product, "id" | "availableForSale" | "isGiftCard" | "onlineStoreUrl" | "description" | "descriptionHtml" | "handle" | "productType" | "tags" | "title"> & {
|
|
55
|
+
category?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").TaxonomyCategory, "id" | "name">>;
|
|
56
|
+
compareAtPriceRange: {
|
|
57
|
+
maxVariantPrice: Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">;
|
|
58
|
+
minVariantPrice: Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">;
|
|
59
|
+
};
|
|
60
|
+
featuredImage?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Image, "id" | "altText" | "url" | "thumbhash">>;
|
|
61
|
+
priceRange: {
|
|
62
|
+
maxVariantPrice: Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">;
|
|
63
|
+
minVariantPrice: Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">;
|
|
64
|
+
};
|
|
65
|
+
variantsCount?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Count, "count">>;
|
|
66
|
+
metafields: Array<import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Metafield, "key" | "namespace" | "value">>>;
|
|
67
|
+
})>;
|
|
68
|
+
variant?: import("./types/storefront.types").Maybe<(Pick<import("./types/storefront.types").ProductVariant, "id" | "availableForSale" | "currentlyNotInStock" | "sku" | "title"> & {
|
|
69
|
+
compareAtPrice?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">>;
|
|
70
|
+
image?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Image, "id" | "altText" | "url" | "thumbhash">>;
|
|
71
|
+
price: Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">;
|
|
72
|
+
selectedOptions: Array<Pick<import("./types/storefront.types").SelectedOption, "name" | "value">>;
|
|
73
|
+
metafields: Array<import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Metafield, "key" | "namespace" | "value">>>;
|
|
74
|
+
})>;
|
|
75
|
+
};
|
|
76
|
+
errors: ResponseErrors | null;
|
|
45
77
|
}>;
|
|
46
|
-
loadProductDetailData: (args: LoadProductDetailDataArgs) => Promise<{
|
|
78
|
+
loadProductDetailData: (args: ArgsWithoutDefaults<LoadProductDetailDataArgs>) => Promise<{
|
|
47
79
|
data: import("./storefront-api-client").GetProductDetailDataQuery | import("./storefront-api-client").GetProductDetailDataWithVariantQuery | undefined;
|
|
48
80
|
errors: ResponseErrors | null;
|
|
81
|
+
} | {
|
|
82
|
+
data: {
|
|
83
|
+
product: (Pick<import("./types/storefront.types").Product, "title" | "id" | "availableForSale" | "handle" | "onlineStoreUrl" | "description" | "descriptionHtml" | "encodedVariantAvailability" | "encodedVariantExistence" | "isGiftCard" | "productType" | "tags"> & {
|
|
84
|
+
category?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").TaxonomyCategory, "id" | "name">>;
|
|
85
|
+
compareAtPriceRange: {
|
|
86
|
+
maxVariantPrice: Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">;
|
|
87
|
+
minVariantPrice: Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">;
|
|
88
|
+
};
|
|
89
|
+
featuredImage?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Image, "id" | "altText" | "url" | "thumbhash">>;
|
|
90
|
+
priceRange: {
|
|
91
|
+
maxVariantPrice: Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">;
|
|
92
|
+
minVariantPrice: Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">;
|
|
93
|
+
};
|
|
94
|
+
variantsCount?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Count, "count" | "precision">>;
|
|
95
|
+
metafields: Array<import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Metafield, "key" | "namespace" | "value">>>;
|
|
96
|
+
options: Array<(Pick<import("./types/storefront.types").ProductOption, "id" | "name"> & {
|
|
97
|
+
optionValues: Array<(Pick<import("./types/storefront.types").ProductOptionValue, "name"> & {
|
|
98
|
+
swatch?: import("./types/storefront.types").Maybe<(Pick<import("./types/storefront.types").ProductOptionValueSwatch, "color"> & {
|
|
99
|
+
image?: import("./types/storefront.types").Maybe<{
|
|
100
|
+
previewImage?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Image, "url">>;
|
|
101
|
+
}>;
|
|
102
|
+
})>;
|
|
103
|
+
firstSelectableVariant?: import("./types/storefront.types").Maybe<(Pick<import("./types/storefront.types").ProductVariant, "id"> & {
|
|
104
|
+
image?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Image, "id" | "altText" | "url" | "thumbhash">>;
|
|
105
|
+
})>;
|
|
106
|
+
})>;
|
|
107
|
+
})>;
|
|
108
|
+
images: {
|
|
109
|
+
nodes: Array<Pick<import("./types/storefront.types").Image, "id" | "altText" | "url" | "thumbhash">>;
|
|
110
|
+
};
|
|
111
|
+
}) | (Pick<import("./types/storefront.types").Product, "title" | "id" | "availableForSale" | "handle" | "onlineStoreUrl" | "description" | "descriptionHtml" | "encodedVariantAvailability" | "encodedVariantExistence" | "isGiftCard" | "productType" | "tags"> & {
|
|
112
|
+
category?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").TaxonomyCategory, "id" | "name">>;
|
|
113
|
+
compareAtPriceRange: {
|
|
114
|
+
maxVariantPrice: Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">;
|
|
115
|
+
minVariantPrice: Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">;
|
|
116
|
+
};
|
|
117
|
+
featuredImage?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Image, "id" | "altText" | "url" | "thumbhash">>;
|
|
118
|
+
priceRange: {
|
|
119
|
+
maxVariantPrice: Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">;
|
|
120
|
+
minVariantPrice: Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">;
|
|
121
|
+
};
|
|
122
|
+
variantsCount?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Count, "count" | "precision">>;
|
|
123
|
+
metafields: Array<import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Metafield, "key" | "namespace" | "value">>>;
|
|
124
|
+
options: Array<(Pick<import("./types/storefront.types").ProductOption, "id" | "name"> & {
|
|
125
|
+
optionValues: Array<(Pick<import("./types/storefront.types").ProductOptionValue, "name"> & {
|
|
126
|
+
swatch?: import("./types/storefront.types").Maybe<(Pick<import("./types/storefront.types").ProductOptionValueSwatch, "color"> & {
|
|
127
|
+
image?: import("./types/storefront.types").Maybe<{
|
|
128
|
+
previewImage?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Image, "url">>;
|
|
129
|
+
}>;
|
|
130
|
+
})>;
|
|
131
|
+
firstSelectableVariant?: import("./types/storefront.types").Maybe<(Pick<import("./types/storefront.types").ProductVariant, "id"> & {
|
|
132
|
+
image?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Image, "id" | "altText" | "url" | "thumbhash">>;
|
|
133
|
+
})>;
|
|
134
|
+
})>;
|
|
135
|
+
})>;
|
|
136
|
+
images: {
|
|
137
|
+
nodes: Array<Pick<import("./types/storefront.types").Image, "id" | "altText" | "url" | "thumbhash">>;
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
variant: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").ProductVariant, "title" | "id" | "availableForSale" | "currentlyNotInStock" | "sku"> & {
|
|
141
|
+
compareAtPrice?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">>;
|
|
142
|
+
image?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Image, "id" | "altText" | "url" | "thumbhash">>;
|
|
143
|
+
price: Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">;
|
|
144
|
+
selectedOptions: Array<Pick<import("./types/storefront.types").SelectedOption, "name" | "value">>;
|
|
145
|
+
metafields: Array<import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Metafield, "key" | "namespace" | "value">>>;
|
|
146
|
+
}> | undefined;
|
|
147
|
+
badges: import("../utils/shopify-badge-utils").Badge[];
|
|
148
|
+
};
|
|
149
|
+
errors: ResponseErrors | null;
|
|
49
150
|
}>;
|
|
50
|
-
loadProductImages: (args: LoadProductImagesArgs) => Promise<{
|
|
151
|
+
loadProductImages: (args: ArgsWithoutDefaults<LoadProductImagesArgs>) => Promise<{
|
|
51
152
|
data: (Pick<import("./types/storefront.types").Image, "id" | "altText" | "url" | "thumbhash"> | undefined)[];
|
|
52
153
|
error: null;
|
|
53
154
|
} | {
|
|
54
155
|
data: null;
|
|
55
156
|
error: Error;
|
|
56
157
|
}>;
|
|
57
|
-
loadProductRecommendations: (args: LoadProductRecommendationsArgs) => Promise<{
|
|
158
|
+
loadProductRecommendations: (args: ArgsWithoutDefaults<LoadProductRecommendationsArgs>) => Promise<{
|
|
58
159
|
data: {
|
|
59
160
|
productRecommendations?: import("./types/storefront.types").Product[] | null;
|
|
60
161
|
} | undefined;
|
|
61
162
|
errors: ResponseErrors | null;
|
|
163
|
+
} | {
|
|
164
|
+
data: {
|
|
165
|
+
productRecommendations: {
|
|
166
|
+
product: import("./types/storefront.types").Product;
|
|
167
|
+
badges: import("../utils/shopify-badge-utils").Badge[];
|
|
168
|
+
}[];
|
|
169
|
+
};
|
|
170
|
+
errors: ResponseErrors | null;
|
|
62
171
|
}>;
|
|
63
172
|
loadProductId: (args: LoadProductIdArgs) => Promise<{
|
|
64
173
|
data: import("./storefront-api-client").GetProductIdByHandleQuery | undefined;
|
|
65
174
|
errors: ResponseErrors | null;
|
|
66
175
|
}>;
|
|
67
|
-
loadSaveIntentData: (args: LoadSaveIntentDataArgs) => Promise<{
|
|
176
|
+
loadSaveIntentData: (args: ArgsWithoutDefaults<LoadSaveIntentDataArgs>) => Promise<{
|
|
68
177
|
data: import("./storefront-api-client").GetSaveIntentDataQuery | import("./storefront-api-client").GetSaveIntentDataWithVariantQuery | undefined;
|
|
69
178
|
errors: ResponseErrors | null;
|
|
70
179
|
}>;
|
|
71
180
|
clearCache(): Promise<void>;
|
|
72
181
|
}
|
|
182
|
+
type ArgsWithoutDefaults<T> = Omit<T, "country" | "language" | "productMetafields" | "variantMetafields">;
|