@swishapp/sdk 0.120.0 → 0.121.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/dom/dom-utils.d.ts +1 -0
- package/dist/events/event-bus.d.ts +1 -1
- package/dist/intents/handlers/edit-item-lists-handler.d.ts +3 -3
- package/dist/intents/handlers/edit-item-variant-handler.d.ts +3 -3
- package/dist/intents/handlers/{open-quick-buy-handler.d.ts → initiate-quick-buy-handler.d.ts} +5 -5
- package/dist/intents/handlers/save-item-handler.d.ts +3 -3
- package/dist/intents/handlers/view-home-handler.d.ts +6 -0
- package/dist/intents/handlers/view-list-detail-page-menu-handler.d.ts +11 -0
- package/dist/intents/handlers/{open-list-handler.d.ts → view-list-handler.d.ts} +5 -5
- package/dist/intents/handlers/{open-list-menu-handler.d.ts → view-list-menu-handler.d.ts} +5 -5
- package/dist/intents/handlers/view-lists-handler.d.ts +6 -0
- package/dist/intents/handlers/view-notifications-handler.d.ts +6 -0
- package/dist/intents/handlers/{open-order-handler.d.ts → view-order-handler.d.ts} +5 -5
- package/dist/intents/handlers/view-order-menu-handler.d.ts +11 -0
- package/dist/intents/handlers/view-orders-handler.d.ts +6 -0
- package/dist/intents/handlers/{open-product-handler.d.ts → view-product-handler.d.ts} +5 -5
- package/dist/intents/handlers/view-profile-handler.d.ts +6 -0
- package/dist/intents/handlers/view-saves-handler.d.ts +6 -0
- package/dist/intents/hooks/after-view-home-hook.d.ts +5 -0
- package/dist/intents/intents.d.ts +16 -1
- package/dist/intents/types.d.ts +41 -45
- package/dist/options/swish-options.d.ts +2 -1
- package/dist/options/types.d.ts +36 -2
- package/dist/query/client.d.ts +2 -0
- package/dist/query/index.d.ts +18 -0
- package/dist/query/invalidation.d.ts +6 -0
- package/dist/query/keys.d.ts +16 -0
- package/dist/query/persistence.d.ts +13 -0
- package/dist/query/storage-key.d.ts +4 -0
- package/dist/state/declarative-state.d.ts +2 -0
- package/dist/state/item-context-signal.d.ts +1 -1
- package/dist/state/item-context-source.d.ts +2 -0
- package/dist/state/item-state-signal.d.ts +1 -0
- package/dist/state/swish-query-signals.d.ts +1 -1
- package/dist/state/tanstack-query-signal.d.ts +14 -0
- package/dist/storefront-api/queries/fragments.d.ts +0 -1
- package/dist/storefront-api/queries/index.d.ts +0 -2
- package/dist/storefront-api/storefront-api-client.d.ts +0 -5
- package/dist/storefront-api/types/storefront.generated.d.ts +0 -50
- package/dist/swish-api/swish-api-auth.d.ts +2 -1
- package/dist/swish-api/swish-api-client.d.ts +1 -1
- package/dist/swish-ui/swish-ui.d.ts +5 -3
- package/dist/swish-ui/types.d.ts +1 -0
- package/dist/swish.d.ts +6 -2
- package/dist/swish.js +24 -77
- package/package.json +2 -1
- package/dist/intents/handlers/open-home-handler.d.ts +0 -6
- package/dist/intents/handlers/open-list-detail-page-menu-handler.d.ts +0 -11
- package/dist/intents/handlers/open-lists-handler.d.ts +0 -6
- package/dist/intents/handlers/open-notifications-handler.d.ts +0 -6
- package/dist/intents/handlers/open-order-menu-handler.d.ts +0 -11
- package/dist/intents/handlers/open-orders-handler.d.ts +0 -6
- package/dist/intents/handlers/open-profile-handler.d.ts +0 -6
- package/dist/intents/handlers/open-saves-handler.d.ts +0 -6
- package/dist/intents/handlers/open-sign-in-handler.d.ts +0 -11
- package/dist/intents/hooks/after-open-home-hook.d.ts +0 -5
- package/dist/storefront-api/load-save-intent-data.d.ts +0 -13
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Signal } from "@preact/signals-core";
|
|
1
2
|
import { ApiError, ApiResponse, PageInfo, PaginatedApiResponse } from "@swishapp/api-client";
|
|
2
3
|
import { EventName } from "../events/event-bus";
|
|
3
4
|
import { SwishApp } from "../swish";
|
|
4
|
-
import { Signal } from "@preact/signals-core";
|
|
5
5
|
export type FetchFn<TResponse, TVariables> = (variables?: TVariables) => Promise<TResponse>;
|
|
6
6
|
type DataOf<T> = T extends {
|
|
7
7
|
data: infer D;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ReadonlySignal } from "@preact/signals-core";
|
|
2
|
+
import { QueryClient, QueryKey, QueryObserverOptions } from "@tanstack/query-core";
|
|
3
|
+
export declare function createTanstackQuerySignal<TData, TError = Error, TQueryKey extends QueryKey = QueryKey>({ queryClient, options, restored, }: {
|
|
4
|
+
queryClient: QueryClient;
|
|
5
|
+
options: ReadonlySignal<QueryObserverOptions<TData, TError, TData, TData, TQueryKey>>;
|
|
6
|
+
restored?: ReadonlySignal<boolean>;
|
|
7
|
+
}): {
|
|
8
|
+
data: import("@preact/signals-core").Signal<TData | null>;
|
|
9
|
+
loading: import("@preact/signals-core").Signal<boolean>;
|
|
10
|
+
error: import("@preact/signals-core").Signal<TError | null>;
|
|
11
|
+
refetching: import("@preact/signals-core").Signal<boolean>;
|
|
12
|
+
refetch: () => Promise<import("@tanstack/query-core").QueryObserverResult<TData, TError>>;
|
|
13
|
+
dispose: () => void;
|
|
14
|
+
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export declare const PRODUCT_IMAGE_FIELDS = "\n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n";
|
|
2
|
-
export declare const SAVE_INTENT_DATA_FIELDS = "\n fragment saveIntentProductFields on Product {\n id\n availableForSale\n featuredImage {\n ...productImageFields\n }\n handle\n title\n variantsCount {\n count\n }\n selectedOrFirstAvailableVariant {\n ...saveIntentVariantFields\n }\n }\n fragment saveIntentVariantFields on ProductVariant {\n id\n availableForSale\n currentlyNotInStock\n image {\n ...productImageFields\n }\n title\n }\n";
|
|
3
2
|
export declare const PRODUCT_FIELDS = "\n fragment productFields on Product {\n id\n availableForSale\n category {\n id\n name\n }\n compareAtPriceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n description\n descriptionHtml\n encodedVariantAvailability\n encodedVariantExistence\n featuredImage {\n ...productImageFields\n }\n handle\n images(first: 20) {\n nodes {\n ...productImageFields\n }\n }\n isGiftCard\n metafields(identifiers: $productMetafields) {\n key\n namespace\n value\n }\n onlineStoreUrl\n selectedOrFirstAvailableVariant(selectedOptions: $selectedOptions) {\n ...productVariantDataFields\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n productType\n tags\n title\n variantsCount {\n count\n precision\n }\n # totalInventory\n }\n";
|
|
4
3
|
export declare const PRODUCT_VARIANT_DATA_FIELDS = "\n fragment productVariantDataFields on ProductVariant {\n id\n availableForSale\n compareAtPrice {\n amount\n currencyCode\n }\n currentlyNotInStock\n image {\n ...productImageFields\n }\n price {\n amount\n currencyCode\n }\n # quantityAvailable\n selectedOptions {\n name\n value\n }\n sku\n title\n metafields(identifiers: $variantMetafields) {\n key\n namespace\n value\n }\n }\n";
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export declare const GET_SAVE_INTENT_DATA_BY_ID = "\n query GetSaveIntentData(\n $productId: ID!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...saveIntentProductFields\n }\n }\n \n fragment saveIntentProductFields on Product {\n id\n availableForSale\n featuredImage {\n ...productImageFields\n }\n handle\n title\n variantsCount {\n count\n }\n selectedOrFirstAvailableVariant {\n ...saveIntentVariantFields\n }\n }\n fragment saveIntentVariantFields on ProductVariant {\n id\n availableForSale\n currentlyNotInStock\n image {\n ...productImageFields\n }\n title\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
|
|
2
|
-
export declare const GET_SAVE_INTENT_DATA_BY_ID_WITH_VARIANT = "\n query GetSaveIntentDataWithVariant(\n $productId: ID!\n $variantId: ID!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...saveIntentProductFields\n }\n variant: node(id: $variantId) {\n ...saveIntentVariantFields\n }\n }\n \n fragment saveIntentProductFields on Product {\n id\n availableForSale\n featuredImage {\n ...productImageFields\n }\n handle\n title\n variantsCount {\n count\n }\n selectedOrFirstAvailableVariant {\n ...saveIntentVariantFields\n }\n }\n fragment saveIntentVariantFields on ProductVariant {\n id\n availableForSale\n currentlyNotInStock\n image {\n ...productImageFields\n }\n title\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
|
|
3
1
|
export declare const GET_PRODUCT_BY_ID = "\n query GetProduct(\n $productId: ID!\n $variantId: ID!\n $selectedOptions: [SelectedOptionInput!]!\n $productMetafields: [HasMetafieldsIdentifier!]!\n $variantMetafields: [HasMetafieldsIdentifier!]!\n $includeVariantById: Boolean!\n $includeVariantBySelectedOptions: Boolean!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...productFields\n variant: variantBySelectedOptions(selectedOptions: $selectedOptions)\n @include(if: $includeVariantBySelectedOptions) {\n ...productVariantDataFields\n }\n }\n variantNode: node(id: $variantId) @include(if: $includeVariantById) {\n ... on ProductVariant {\n ...productVariantDataFields\n }\n }\n }\n \n fragment productFields on Product {\n id\n availableForSale\n category {\n id\n name\n }\n compareAtPriceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n description\n descriptionHtml\n encodedVariantAvailability\n encodedVariantExistence\n featuredImage {\n ...productImageFields\n }\n handle\n images(first: 20) {\n nodes {\n ...productImageFields\n }\n }\n isGiftCard\n metafields(identifiers: $productMetafields) {\n key\n namespace\n value\n }\n onlineStoreUrl\n selectedOrFirstAvailableVariant(selectedOptions: $selectedOptions) {\n ...productVariantDataFields\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n productType\n tags\n title\n variantsCount {\n count\n precision\n }\n # totalInventory\n }\n\n \n fragment productVariantDataFields on ProductVariant {\n id\n availableForSale\n compareAtPrice {\n amount\n currencyCode\n }\n currentlyNotInStock\n image {\n ...productImageFields\n }\n price {\n amount\n currencyCode\n }\n # quantityAvailable\n selectedOptions {\n name\n value\n }\n sku\n title\n metafields(identifiers: $variantMetafields) {\n key\n namespace\n value\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
|
|
4
2
|
export declare const GET_PRODUCT_BY_HANDLE = "\n query GetProductByHandle(\n $handle: String!\n $variantId: ID!\n $selectedOptions: [SelectedOptionInput!]!\n $productMetafields: [HasMetafieldsIdentifier!]!\n $variantMetafields: [HasMetafieldsIdentifier!]!\n $includeVariantById: Boolean!\n $includeVariantBySelectedOptions: Boolean!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(handle: $handle) {\n ...productFields\n variant: variantBySelectedOptions(selectedOptions: $selectedOptions)\n @include(if: $includeVariantBySelectedOptions) {\n ...productVariantDataFields\n }\n }\n variantNode: node(id: $variantId) @include(if: $includeVariantById) {\n ... on ProductVariant {\n ...productVariantDataFields\n }\n }\n }\n \n fragment productFields on Product {\n id\n availableForSale\n category {\n id\n name\n }\n compareAtPriceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n description\n descriptionHtml\n encodedVariantAvailability\n encodedVariantExistence\n featuredImage {\n ...productImageFields\n }\n handle\n images(first: 20) {\n nodes {\n ...productImageFields\n }\n }\n isGiftCard\n metafields(identifiers: $productMetafields) {\n key\n namespace\n value\n }\n onlineStoreUrl\n selectedOrFirstAvailableVariant(selectedOptions: $selectedOptions) {\n ...productVariantDataFields\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n productType\n tags\n title\n variantsCount {\n count\n precision\n }\n # totalInventory\n }\n\n \n fragment productVariantDataFields on ProductVariant {\n id\n availableForSale\n compareAtPrice {\n amount\n currencyCode\n }\n currentlyNotInStock\n image {\n ...productImageFields\n }\n price {\n amount\n currencyCode\n }\n # quantityAvailable\n selectedOptions {\n name\n value\n }\n sku\n title\n metafields(identifiers: $variantMetafields) {\n key\n namespace\n value\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
|
|
5
3
|
export declare const GET_PRODUCT_IMAGES_BY_ID = "\n query GetProductImagesById(\n $ids: [ID!]!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n nodes(ids: $ids) {\n ... on Product {\n featuredImage {\n ...productImageFields\n }\n }\n ... on ProductVariant {\n image {\n ...productImageFields\n }\n product {\n featuredImage {\n ...productImageFields\n }\n }\n }\n }\n }\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
|
|
@@ -4,7 +4,6 @@ import { LoadProductArgs } from "./load-product";
|
|
|
4
4
|
import { LoadProductIdArgs } from "./load-product-id";
|
|
5
5
|
import { LoadProductImagesArgs } from "./load-product-images";
|
|
6
6
|
import { LoadProductRecommendationsArgs } from "./load-product-recommendations";
|
|
7
|
-
import { LoadSaveIntentDataArgs } from "./load-save-intent-data";
|
|
8
7
|
export * from "./load-product";
|
|
9
8
|
export * from "./load-product-recommendations";
|
|
10
9
|
export * from "./types/storefront.generated";
|
|
@@ -103,10 +102,6 @@ export declare class StorefrontApiClient {
|
|
|
103
102
|
data: import("./storefront-api-client").GetProductIdByHandleQuery | undefined;
|
|
104
103
|
errors: ResponseErrors | null;
|
|
105
104
|
}>;
|
|
106
|
-
loadSaveIntentData: (args: ArgsWithoutDefaults<LoadSaveIntentDataArgs>) => Promise<{
|
|
107
|
-
data: import("./storefront-api-client").GetSaveIntentDataQuery | import("./storefront-api-client").GetSaveIntentDataWithVariantQuery | undefined;
|
|
108
|
-
errors: ResponseErrors | null;
|
|
109
|
-
}>;
|
|
110
105
|
clearCache(): Promise<void>;
|
|
111
106
|
}
|
|
112
107
|
type ArgsWithoutDefaults<T> = Omit<T, "country" | "language" | "productMetafields" | "variantMetafields">;
|
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
import * as StorefrontTypes from "./storefront.types";
|
|
2
2
|
export type ProductImageFieldsFragment = Pick<StorefrontTypes.Image, "id" | "altText" | "url" | "thumbhash">;
|
|
3
|
-
export type SaveIntentProductFieldsFragment = Pick<StorefrontTypes.Product, "id" | "availableForSale" | "handle" | "title"> & {
|
|
4
|
-
featuredImage?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Image, "id" | "altText" | "url" | "thumbhash">>;
|
|
5
|
-
variantsCount?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Count, "count">>;
|
|
6
|
-
selectedOrFirstAvailableVariant?: StorefrontTypes.Maybe<Pick<StorefrontTypes.ProductVariant, "id" | "availableForSale" | "currentlyNotInStock" | "title"> & {
|
|
7
|
-
image?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Image, "id" | "altText" | "url" | "thumbhash">>;
|
|
8
|
-
}>;
|
|
9
|
-
};
|
|
10
|
-
export type SaveIntentVariantFieldsFragment = Pick<StorefrontTypes.ProductVariant, "id" | "availableForSale" | "currentlyNotInStock" | "title"> & {
|
|
11
|
-
image?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Image, "id" | "altText" | "url" | "thumbhash">>;
|
|
12
|
-
};
|
|
13
3
|
export type ProductFieldsFragment = Pick<StorefrontTypes.Product, "id" | "availableForSale" | "description" | "descriptionHtml" | "encodedVariantAvailability" | "encodedVariantExistence" | "handle" | "isGiftCard" | "onlineStoreUrl" | "productType" | "tags" | "title"> & {
|
|
14
4
|
category?: StorefrontTypes.Maybe<Pick<StorefrontTypes.TaxonomyCategory, "id" | "name">>;
|
|
15
5
|
compareAtPriceRange: {
|
|
@@ -53,38 +43,6 @@ export type ProductVariantDataFieldsFragment = Pick<StorefrontTypes.ProductVaria
|
|
|
53
43
|
selectedOptions: Array<Pick<StorefrontTypes.SelectedOption, "name" | "value">>;
|
|
54
44
|
metafields: Array<StorefrontTypes.Maybe<Pick<StorefrontTypes.Metafield, "key" | "namespace" | "value">>>;
|
|
55
45
|
};
|
|
56
|
-
export type GetSaveIntentDataQueryVariables = StorefrontTypes.Exact<{
|
|
57
|
-
productId: StorefrontTypes.Scalars["ID"]["input"];
|
|
58
|
-
country: StorefrontTypes.CountryCode;
|
|
59
|
-
language: StorefrontTypes.LanguageCode;
|
|
60
|
-
}>;
|
|
61
|
-
export type GetSaveIntentDataQuery = {
|
|
62
|
-
product?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Product, "id" | "availableForSale" | "handle" | "title"> & {
|
|
63
|
-
featuredImage?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Image, "id" | "altText" | "url" | "thumbhash">>;
|
|
64
|
-
variantsCount?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Count, "count">>;
|
|
65
|
-
selectedOrFirstAvailableVariant?: StorefrontTypes.Maybe<Pick<StorefrontTypes.ProductVariant, "id" | "availableForSale" | "currentlyNotInStock" | "title"> & {
|
|
66
|
-
image?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Image, "id" | "altText" | "url" | "thumbhash">>;
|
|
67
|
-
}>;
|
|
68
|
-
}>;
|
|
69
|
-
};
|
|
70
|
-
export type GetSaveIntentDataWithVariantQueryVariables = StorefrontTypes.Exact<{
|
|
71
|
-
productId: StorefrontTypes.Scalars["ID"]["input"];
|
|
72
|
-
variantId: StorefrontTypes.Scalars["ID"]["input"];
|
|
73
|
-
country: StorefrontTypes.CountryCode;
|
|
74
|
-
language: StorefrontTypes.LanguageCode;
|
|
75
|
-
}>;
|
|
76
|
-
export type GetSaveIntentDataWithVariantQuery = {
|
|
77
|
-
product?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Product, "id" | "availableForSale" | "handle" | "title"> & {
|
|
78
|
-
featuredImage?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Image, "id" | "altText" | "url" | "thumbhash">>;
|
|
79
|
-
variantsCount?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Count, "count">>;
|
|
80
|
-
selectedOrFirstAvailableVariant?: StorefrontTypes.Maybe<Pick<StorefrontTypes.ProductVariant, "id" | "availableForSale" | "currentlyNotInStock" | "title"> & {
|
|
81
|
-
image?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Image, "id" | "altText" | "url" | "thumbhash">>;
|
|
82
|
-
}>;
|
|
83
|
-
}>;
|
|
84
|
-
variant?: StorefrontTypes.Maybe<Pick<StorefrontTypes.ProductVariant, "id" | "availableForSale" | "currentlyNotInStock" | "title"> & {
|
|
85
|
-
image?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Image, "id" | "altText" | "url" | "thumbhash">>;
|
|
86
|
-
}>;
|
|
87
|
-
};
|
|
88
46
|
export type GetProductQueryVariables = StorefrontTypes.Exact<{
|
|
89
47
|
productId: StorefrontTypes.Scalars["ID"]["input"];
|
|
90
48
|
variantId: StorefrontTypes.Scalars["ID"]["input"];
|
|
@@ -251,14 +209,6 @@ export type GetProductIdByHandleQuery = {
|
|
|
251
209
|
product?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Product, "id">>;
|
|
252
210
|
};
|
|
253
211
|
interface GeneratedQueryTypes {
|
|
254
|
-
"\n query GetSaveIntentData(\n $productId: ID!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...saveIntentProductFields\n }\n }\n \n fragment saveIntentProductFields on Product {\n id\n availableForSale\n featuredImage {\n ...productImageFields\n }\n handle\n title\n variantsCount {\n count\n }\n selectedOrFirstAvailableVariant {\n ...saveIntentVariantFields\n }\n }\n fragment saveIntentVariantFields on ProductVariant {\n id\n availableForSale\n currentlyNotInStock\n image {\n ...productImageFields\n }\n title\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n": {
|
|
255
|
-
return: GetSaveIntentDataQuery;
|
|
256
|
-
variables: GetSaveIntentDataQueryVariables;
|
|
257
|
-
};
|
|
258
|
-
"\n query GetSaveIntentDataWithVariant(\n $productId: ID!\n $variantId: ID!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...saveIntentProductFields\n }\n variant: node(id: $variantId) {\n ...saveIntentVariantFields\n }\n }\n \n fragment saveIntentProductFields on Product {\n id\n availableForSale\n featuredImage {\n ...productImageFields\n }\n handle\n title\n variantsCount {\n count\n }\n selectedOrFirstAvailableVariant {\n ...saveIntentVariantFields\n }\n }\n fragment saveIntentVariantFields on ProductVariant {\n id\n availableForSale\n currentlyNotInStock\n image {\n ...productImageFields\n }\n title\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n": {
|
|
259
|
-
return: GetSaveIntentDataWithVariantQuery;
|
|
260
|
-
variables: GetSaveIntentDataWithVariantQueryVariables;
|
|
261
|
-
};
|
|
262
212
|
"\n query GetProduct(\n $productId: ID!\n $variantId: ID!\n $selectedOptions: [SelectedOptionInput!]!\n $productMetafields: [HasMetafieldsIdentifier!]!\n $variantMetafields: [HasMetafieldsIdentifier!]!\n $includeVariantById: Boolean!\n $includeVariantBySelectedOptions: Boolean!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...productFields\n variant: variantBySelectedOptions(selectedOptions: $selectedOptions)\n @include(if: $includeVariantBySelectedOptions) {\n ...productVariantDataFields\n }\n }\n variantNode: node(id: $variantId) @include(if: $includeVariantById) {\n ... on ProductVariant {\n ...productVariantDataFields\n }\n }\n }\n \n fragment productFields on Product {\n id\n availableForSale\n category {\n id\n name\n }\n compareAtPriceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n description\n descriptionHtml\n encodedVariantAvailability\n encodedVariantExistence\n featuredImage {\n ...productImageFields\n }\n handle\n images(first: 20) {\n nodes {\n ...productImageFields\n }\n }\n isGiftCard\n metafields(identifiers: $productMetafields) {\n key\n namespace\n value\n }\n onlineStoreUrl\n selectedOrFirstAvailableVariant(selectedOptions: $selectedOptions) {\n ...productVariantDataFields\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n productType\n tags\n title\n variantsCount {\n count\n precision\n }\n # totalInventory\n }\n\n \n fragment productVariantDataFields on ProductVariant {\n id\n availableForSale\n compareAtPrice {\n amount\n currencyCode\n }\n currentlyNotInStock\n image {\n ...productImageFields\n }\n price {\n amount\n currencyCode\n }\n # quantityAvailable\n selectedOptions {\n name\n value\n }\n sku\n title\n metafields(identifiers: $variantMetafields) {\n key\n namespace\n value\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n": {
|
|
263
213
|
return: GetProductQuery;
|
|
264
214
|
variables: GetProductQueryVariables;
|
|
@@ -5,8 +5,9 @@ export declare class SwishApiAuth {
|
|
|
5
5
|
private readonly context;
|
|
6
6
|
private readonly api;
|
|
7
7
|
private readonly eventBus;
|
|
8
|
+
private readonly tokenUrl;
|
|
8
9
|
private tokenHasProfile;
|
|
9
|
-
constructor(api: SwishApi, context: StorefrontContext, eventBus: EventBus);
|
|
10
|
+
constructor(api: SwishApi, context: StorefrontContext, eventBus: EventBus, tokenUrl: string);
|
|
10
11
|
hasProfile(): boolean;
|
|
11
12
|
hasToken(): boolean;
|
|
12
13
|
private _renewPromise?;
|
|
@@ -12,7 +12,7 @@ export declare class SwishApi {
|
|
|
12
12
|
private readonly itemsLoader;
|
|
13
13
|
private readonly auth;
|
|
14
14
|
private readonly storefrontContext;
|
|
15
|
-
constructor(config: SwishApiConfig, context: StorefrontContext, eventBus: EventBus, cacheKeyPrefix: string);
|
|
15
|
+
constructor(config: SwishApiConfig, context: StorefrontContext, eventBus: EventBus, cacheKeyPrefix: string, tokenUrl: string);
|
|
16
16
|
private fetchFunction;
|
|
17
17
|
private requestInterceptor;
|
|
18
18
|
private responseInterceptor;
|
|
@@ -8,9 +8,10 @@ export declare class SwishUi {
|
|
|
8
8
|
private scrollLockStyleSheet;
|
|
9
9
|
private scrollLockRefCount;
|
|
10
10
|
private scrollPositionBeforeLock;
|
|
11
|
+
private elementId;
|
|
11
12
|
constructor(swishApp: SwishApp);
|
|
12
|
-
hideModal(element: string | HTMLElement): Promise<void>;
|
|
13
13
|
showModal(element: string | HTMLElement): Promise<void>;
|
|
14
|
+
hideModal(element: string | HTMLElement): Promise<void>;
|
|
14
15
|
private waitForEvent;
|
|
15
16
|
showSignIn(options?: SignInOptions): Promise<UiResponse<void>>;
|
|
16
17
|
showUnsaveAlert(options: UnsaveAlertOptions): Promise<UiResponse<UnsaveAlertSubmitData>>;
|
|
@@ -45,13 +46,14 @@ export declare class SwishUi {
|
|
|
45
46
|
bundleCssStylesheet: CSSStyleSheet;
|
|
46
47
|
customCssStylesheets: CSSStyleSheet[];
|
|
47
48
|
}>;
|
|
48
|
-
insertComponent<T extends HTMLElement = SwishUiElement>({ name, template, position, refElement, }: {
|
|
49
|
+
insertComponent<T extends HTMLElement = SwishUiElement>({ name, template, position, refElement, singleInstance, }: {
|
|
49
50
|
name: string;
|
|
50
51
|
template: string;
|
|
51
52
|
position: InsertPosition;
|
|
52
53
|
refElement: HTMLElement;
|
|
54
|
+
singleInstance: boolean;
|
|
53
55
|
}): Promise<T>;
|
|
54
|
-
queryComponent<T extends HTMLElement = SwishUiElement>(name: string, instance?:
|
|
56
|
+
queryComponent<T extends HTMLElement = SwishUiElement>(name: string, instance?: number): T;
|
|
55
57
|
private lockScroll;
|
|
56
58
|
private unlockScroll;
|
|
57
59
|
_lockScroll: () => void;
|
package/dist/swish-ui/types.d.ts
CHANGED
|
@@ -117,6 +117,7 @@ export interface ListEditorOptions {
|
|
|
117
117
|
listId?: string;
|
|
118
118
|
}
|
|
119
119
|
export interface RequireUiComponentOptions<TComponent = SwishUiElement> {
|
|
120
|
+
singleInstance?: boolean;
|
|
120
121
|
onHydrated?: (ref: Ref<TComponent>) => void;
|
|
121
122
|
refElement?: HTMLElement;
|
|
122
123
|
}
|
package/dist/swish.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { EventBus } from "./events/event-bus";
|
|
|
6
6
|
import { Intents } from "./intents/intents";
|
|
7
7
|
import { SwishOptionsInput } from "./options/swish-options";
|
|
8
8
|
import { SwishOptions } from "./options/types";
|
|
9
|
+
import { SwishQuery } from "./query";
|
|
9
10
|
import { computed, effect, signal } from "./state";
|
|
10
11
|
import { StorefrontApiClient } from "./storefront-api/storefront-api-client";
|
|
11
12
|
import { SwishApi } from "./swish-api/swish-api-client";
|
|
@@ -26,6 +27,7 @@ declare class SwishApp {
|
|
|
26
27
|
private readonly _i18n;
|
|
27
28
|
readonly events: EventBus;
|
|
28
29
|
readonly intents: Intents;
|
|
30
|
+
readonly query: SwishQuery;
|
|
29
31
|
constructor(options: SwishOptions);
|
|
30
32
|
get options(): SwishOptions;
|
|
31
33
|
get storefrontContext(): import("./swish").StorefrontContext;
|
|
@@ -52,7 +54,7 @@ declare class SwishApp {
|
|
|
52
54
|
}) => URL;
|
|
53
55
|
};
|
|
54
56
|
readonly state: {
|
|
55
|
-
itemContext: (source
|
|
57
|
+
itemContext: (source: HTMLElement | Location) => import("@preact/signals-core").Signal<import("./state").ItemContext>;
|
|
56
58
|
itemState: (context: import("@preact/signals-core").Signal<import("./state").ItemContext>) => import("@preact/signals-core").ReadonlySignal<{
|
|
57
59
|
error: import("@swishapp/api-client").ApiError | null;
|
|
58
60
|
status: string;
|
|
@@ -67,6 +69,7 @@ declare class SwishApp {
|
|
|
67
69
|
unsave: () => Promise<void>;
|
|
68
70
|
update: () => Promise<void>;
|
|
69
71
|
toggle: () => Promise<void>;
|
|
72
|
+
dispose: () => void;
|
|
70
73
|
};
|
|
71
74
|
itemCount: () => import("@preact/signals-core").ReadonlySignal<{
|
|
72
75
|
count: number;
|
|
@@ -101,9 +104,10 @@ export type * from "./options/types";
|
|
|
101
104
|
export type * from "./storefront-api/storefront-api-client";
|
|
102
105
|
export type { Ref, SwishUiElement } from "./swish-ui/swish-ui-element";
|
|
103
106
|
export type { ListSelectOptions, ListSelectSubmitData, QuickBuyOptions, QuickBuySubmitData, Toast, ToastManager, UnsaveAlertOptions, UnsaveAlertSubmitData, VariantSelectOptions, VariantSelectSubmitData, } from "./swish-ui/types";
|
|
104
|
-
export type {
|
|
107
|
+
export type { Product, ProductVariant, SwishUiElementSpec, SwishUiManifest, } from "./types";
|
|
105
108
|
export { buildShareListUrl } from "./utils/build-share-list-url";
|
|
106
109
|
export { copyToClipboard } from "./utils/copy-to-clipboard";
|
|
110
|
+
export { getSwishQueryStorageKey } from "./query";
|
|
107
111
|
export type { SwishApp };
|
|
108
112
|
declare global {
|
|
109
113
|
interface Window {
|