@swishapp/sdk 0.58.0 → 0.60.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/intents/intent-handler.d.ts +3 -3
- package/dist/intents/intent-hook.d.ts +5 -5
- package/dist/intents/intents.d.ts +19 -5
- 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 +12 -9
- package/dist/swish-api/swish-api-client.d.ts +7 -4
- package/dist/swish-ui/swish-ui-element.d.ts +3 -1
- package/dist/swish-ui/swish-ui-utils.d.ts +7 -2
- package/dist/swish.d.ts +21 -12
- package/dist/swish.js +66 -66
- package/dist/types.d.ts +16 -13
- package/dist/utils/auth-utils.d.ts +4 -0
- package/dist/utils/shop-bridge.d.ts +7 -2
- package/package.json +10 -10
- package/dist/index.d.ts +0 -9
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { SwishApp } from "../swish";
|
|
2
|
-
import {
|
|
2
|
+
import { IntentOptionsWithDefaults } from "./intents";
|
|
3
3
|
import { Intent, IntentEventBus, IntentResponse } from "./types";
|
|
4
4
|
export declare abstract class IntentHandler<T extends Intent = Intent> {
|
|
5
5
|
protected readonly swish: SwishApp;
|
|
6
6
|
protected readonly eventBus: IntentEventBus;
|
|
7
|
-
protected readonly options:
|
|
8
|
-
constructor(swish: SwishApp, eventBus: IntentEventBus, options:
|
|
7
|
+
protected readonly options: IntentOptionsWithDefaults;
|
|
8
|
+
constructor(swish: SwishApp, eventBus: IntentEventBus, options: IntentOptionsWithDefaults);
|
|
9
9
|
abstract invoke(intent: T): Promise<IntentResponse<T>>;
|
|
10
10
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { SwishApp } from "../swish";
|
|
2
|
-
import {
|
|
3
|
-
import { Intent, IntentResponse } from "./types";
|
|
1
|
+
import type { SwishApp } from "../swish";
|
|
2
|
+
import type { IntentOptionsWithDefaults } from "./intents";
|
|
3
|
+
import type { Intent, IntentResponse } from "./types";
|
|
4
4
|
export declare abstract class IntentHook<T extends Intent = Intent> {
|
|
5
5
|
protected readonly swish: SwishApp;
|
|
6
|
-
protected readonly options:
|
|
7
|
-
constructor(swish: SwishApp, options:
|
|
6
|
+
protected readonly options: IntentOptionsWithDefaults;
|
|
7
|
+
constructor(swish: SwishApp, options: IntentOptionsWithDefaults);
|
|
8
8
|
abstract invoke(respomse: IntentResponse<T>): Promise<void>;
|
|
9
9
|
}
|
|
@@ -1,16 +1,30 @@
|
|
|
1
1
|
import { SwishApp } from "../swish";
|
|
2
2
|
import { Intent, IntentActivity, IntentQuery, IntentQueryWithParams, IntentResponse } from "./types";
|
|
3
3
|
export interface IntentOptions {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
save?: {
|
|
5
|
+
requireVariant?: boolean;
|
|
6
|
+
showToast?: boolean;
|
|
7
|
+
};
|
|
8
|
+
edit?: {
|
|
9
|
+
showToast?: boolean;
|
|
10
|
+
};
|
|
11
|
+
unsave?: {
|
|
12
|
+
requireConfirmation?: boolean;
|
|
13
|
+
openEditor?: boolean;
|
|
14
|
+
showToast?: boolean;
|
|
15
|
+
};
|
|
8
16
|
}
|
|
17
|
+
export type IntentOptionsWithDefaults = {
|
|
18
|
+
save: Required<NonNullable<IntentOptions["save"]>>;
|
|
19
|
+
edit: Required<NonNullable<IntentOptions["edit"]>>;
|
|
20
|
+
unsave: Required<NonNullable<IntentOptions["unsave"]>>;
|
|
21
|
+
};
|
|
9
22
|
export declare class Intents {
|
|
10
23
|
private readonly swish;
|
|
11
24
|
private readonly eventBus;
|
|
12
25
|
private readonly options;
|
|
13
|
-
constructor(swish: SwishApp, options
|
|
26
|
+
constructor(swish: SwishApp, options?: IntentOptions);
|
|
27
|
+
publishAnalyticsEvent(event: string, data: Record<string, any>): void;
|
|
14
28
|
invoke<T extends Intent>(intent: T): Promise<IntentActivity<T>>;
|
|
15
29
|
listen(intent: Pick<Intent, "action" | "type">, callback: (response: IntentResponse) => void): () => void;
|
|
16
30
|
getIntentQuery(intent: Pick<Intent, "action" | "type">): IntentQuery;
|
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,7 @@ 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 { StorefrontContext } from "../types";
|
|
10
11
|
export * from "./load-product-card-data";
|
|
11
12
|
export * from "./load-product-options";
|
|
12
13
|
export * from "./load-product-recommendations";
|
|
@@ -17,7 +18,7 @@ export interface StorefrontApiResponse<TData> {
|
|
|
17
18
|
errors: ResponseErrors;
|
|
18
19
|
}
|
|
19
20
|
export declare const API_VERSION = "2025-07";
|
|
20
|
-
export interface
|
|
21
|
+
export interface StorefrontApiOptions {
|
|
21
22
|
storeDomain: string;
|
|
22
23
|
accessToken: string;
|
|
23
24
|
}
|
|
@@ -25,36 +26,38 @@ export declare class StorefrontApiClient {
|
|
|
25
26
|
private client;
|
|
26
27
|
private readonly shortCache;
|
|
27
28
|
private readonly longCache;
|
|
28
|
-
|
|
29
|
+
private readonly options;
|
|
30
|
+
private readonly context;
|
|
31
|
+
constructor(options: StorefrontApiOptions, context: StorefrontContext);
|
|
29
32
|
fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
|
|
30
33
|
query: <TData, TVariables extends Record<string, unknown>>(query: string, variables: TVariables) => Promise<{
|
|
31
34
|
data: (TData extends undefined ? any : TData) | undefined;
|
|
32
35
|
errors: ResponseErrors | null;
|
|
33
36
|
}>;
|
|
34
|
-
loadProductOptions: (args: LoadProductOptionsArgs) => Promise<{
|
|
37
|
+
loadProductOptions: (args: Omit<LoadProductOptionsArgs, "country" | "language">) => Promise<{
|
|
35
38
|
data: import("./storefront-api-client").GetProductOptionsQuery | import("./storefront-api-client").GetProductOptionsWithVariantQuery | undefined;
|
|
36
39
|
errors: ResponseErrors | null;
|
|
37
40
|
}>;
|
|
38
|
-
loadSelectedVariant: (args: LoadSelectedVariantArgs) => Promise<{
|
|
41
|
+
loadSelectedVariant: (args: Omit<LoadSelectedVariantArgs, "country" | "language">) => Promise<{
|
|
39
42
|
data: import("./storefront-api-client").GetSelectedVariantQuery | undefined;
|
|
40
43
|
errors: ResponseErrors | null;
|
|
41
44
|
}>;
|
|
42
|
-
loadProductCardData: (args: LoadProductCardDataArgs) => Promise<{
|
|
45
|
+
loadProductCardData: (args: Omit<LoadProductCardDataArgs, "country" | "language">) => Promise<{
|
|
43
46
|
data: import("./storefront-api-client").GetProductCardDataQuery | import("./storefront-api-client").GetProductCardDataWithVariantQuery | undefined;
|
|
44
47
|
errors: ResponseErrors | null;
|
|
45
48
|
}>;
|
|
46
|
-
loadProductDetailData: (args: LoadProductDetailDataArgs) => Promise<{
|
|
49
|
+
loadProductDetailData: (args: Omit<LoadProductDetailDataArgs, "country" | "language">) => Promise<{
|
|
47
50
|
data: import("./storefront-api-client").GetProductDetailDataQuery | import("./storefront-api-client").GetProductDetailDataWithVariantQuery | undefined;
|
|
48
51
|
errors: ResponseErrors | null;
|
|
49
52
|
}>;
|
|
50
|
-
loadProductImages: (args: LoadProductImagesArgs) => Promise<{
|
|
53
|
+
loadProductImages: (args: Omit<LoadProductImagesArgs, "country" | "language">) => Promise<{
|
|
51
54
|
data: (Pick<import("./types/storefront.types").Image, "id" | "altText" | "url" | "thumbhash"> | undefined)[];
|
|
52
55
|
error: null;
|
|
53
56
|
} | {
|
|
54
57
|
data: null;
|
|
55
58
|
error: Error;
|
|
56
59
|
}>;
|
|
57
|
-
loadProductRecommendations: (args: LoadProductRecommendationsArgs) => Promise<{
|
|
60
|
+
loadProductRecommendations: (args: Omit<LoadProductRecommendationsArgs, "country" | "language">) => Promise<{
|
|
58
61
|
data: {
|
|
59
62
|
productRecommendations?: import("./types/storefront.types").Product[] | null;
|
|
60
63
|
} | undefined;
|
|
@@ -64,7 +67,7 @@ export declare class StorefrontApiClient {
|
|
|
64
67
|
data: import("./storefront-api-client").GetProductIdByHandleQuery | undefined;
|
|
65
68
|
errors: ResponseErrors | null;
|
|
66
69
|
}>;
|
|
67
|
-
loadSaveIntentData: (args: LoadSaveIntentDataArgs) => Promise<{
|
|
70
|
+
loadSaveIntentData: (args: Omit<LoadSaveIntentDataArgs, "country" | "language">) => Promise<{
|
|
68
71
|
data: import("./storefront-api-client").GetSaveIntentDataQuery | import("./storefront-api-client").GetSaveIntentDataWithVariantQuery | undefined;
|
|
69
72
|
errors: ResponseErrors | null;
|
|
70
73
|
}>;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ApiResponse, Item, ItemControllerFindData, ItemDetail, ListControllerFindData, ListDetail, PaginatedApiResponse, SwishClientConfig } from "@swishapp/api-client";
|
|
2
2
|
export interface SwishApiConfig extends SwishClientConfig {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
deleteProfile?: () => void;
|
|
3
|
+
proxyMode?: boolean;
|
|
4
|
+
customerId?: string;
|
|
6
5
|
responseInterceptor?: (response: Response, request: Request) => Promise<void> | void;
|
|
7
6
|
}
|
|
8
7
|
export declare class SwishApi {
|
|
@@ -11,6 +10,8 @@ export declare class SwishApi {
|
|
|
11
10
|
private readonly config;
|
|
12
11
|
private readonly itemsLoader;
|
|
13
12
|
constructor(config: SwishApiConfig, cacheKeyPrefix: string);
|
|
13
|
+
private _bootstrapAuthPromise?;
|
|
14
|
+
bootstrapAuth(): Promise<void>;
|
|
14
15
|
private processProfileHeader;
|
|
15
16
|
get items(): {
|
|
16
17
|
list: (query?: ItemControllerFindData["query"], options?: {
|
|
@@ -36,7 +37,9 @@ export declare class SwishApi {
|
|
|
36
37
|
};
|
|
37
38
|
get profiles(): {
|
|
38
39
|
customerAccountsVersion: () => Promise<ApiResponse<import("@swishapp/api-client").AccountsVersionResult>>;
|
|
39
|
-
createToken: (body?: import("@swishapp/api-client").CreateProfileTokenInput
|
|
40
|
+
createToken: (body?: import("@swishapp/api-client").CreateProfileTokenInput, options?: {
|
|
41
|
+
useProxy?: boolean;
|
|
42
|
+
}) => Promise<ApiResponse<import("@swishapp/api-client").CreateProfileTokenResult>>;
|
|
40
43
|
identify: (body: import("@swishapp/api-client").IdentifyProfileInput) => Promise<ApiResponse<import("@swishapp/api-client").IdentifyProfileResult>>;
|
|
41
44
|
};
|
|
42
45
|
clearCache(): Promise<void>;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export interface Ref<T> {
|
|
2
2
|
current: T;
|
|
3
3
|
}
|
|
4
|
-
|
|
4
|
+
declare const BaseElement: typeof HTMLElement;
|
|
5
|
+
export declare class SwishUiElement extends BaseElement {
|
|
5
6
|
constructor();
|
|
6
7
|
private componentRef;
|
|
7
8
|
getComponentRef: <TComponent = unknown>() => Ref<TComponent>;
|
|
8
9
|
setComponentRef: <TComponent = unknown>(ref: Ref<TComponent>) => void;
|
|
9
10
|
}
|
|
11
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SwishUiManifest, SwishUiOptions } from "../types";
|
|
1
|
+
import type { StorefrontContext, SwishUiManifest, SwishUiOptions } from "../types";
|
|
2
2
|
import type { ShopBridge } from "../utils/shop-bridge";
|
|
3
3
|
import type { Ref, SwishUiElement } from "./swish-ui-element";
|
|
4
4
|
import { Item, ItemDetail, List } from "@swishapp/api-client";
|
|
@@ -19,7 +19,7 @@ export interface Toast {
|
|
|
19
19
|
onClick?: () => void;
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
export declare const setConfig: (
|
|
22
|
+
export declare const setConfig: (context: StorefrontContext, uiOptions?: SwishUiOptions) => void;
|
|
23
23
|
export declare const hideModal: (element: string | HTMLElement) => Promise<void>;
|
|
24
24
|
export declare const showModal: (element: string | HTMLElement) => Promise<void>;
|
|
25
25
|
export interface SignInOptions {
|
|
@@ -67,6 +67,10 @@ export interface ListSelectSubmitData {
|
|
|
67
67
|
variant?: ListSelectVariant;
|
|
68
68
|
}
|
|
69
69
|
export declare const showListSelect: (options: ListSelectOptions) => Promise<void>;
|
|
70
|
+
export interface ListDetailPageOptions {
|
|
71
|
+
listId?: string;
|
|
72
|
+
}
|
|
73
|
+
export declare const initListDetailPage: (options: ListDetailPageOptions, refElement: HTMLElement) => Promise<void>;
|
|
70
74
|
export declare const showToast: (toast: Toast) => Promise<void>;
|
|
71
75
|
export declare const hideAllToasts: () => Promise<void>;
|
|
72
76
|
export interface VariantSelectOptions {
|
|
@@ -115,6 +119,7 @@ export interface RequireUiComponentOptions<TComponent> {
|
|
|
115
119
|
instance?: string;
|
|
116
120
|
listeners?: Record<string, (event: Event | CustomEvent) => void>;
|
|
117
121
|
onHydrated?: (ref: Ref<TComponent>) => void;
|
|
122
|
+
refElement?: HTMLElement;
|
|
118
123
|
}
|
|
119
124
|
export declare const requireUiComponent: <TComponent = unknown>(name: string, options?: RequireUiComponentOptions<TComponent>) => Promise<SwishUiElement>;
|
|
120
125
|
export declare const insertComponent: <T extends HTMLElement = SwishUiElement>({ name, instance, template, position, refElement, }: {
|
package/dist/swish.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SwishOptions } from "./types";
|
|
2
2
|
import { AjaxApiClient } from "./ajax-api/ajax-api-client";
|
|
3
3
|
import { createElementLocator, createLocationObserver } from "./dom/dom-utils";
|
|
4
4
|
import { EventBus } from "./events/event-bus";
|
|
@@ -7,8 +7,7 @@ import { computed, effect, signal } from "./state";
|
|
|
7
7
|
import { StorefrontApiClient } from "./storefront-api/storefront-api-client";
|
|
8
8
|
import { SwishApi } from "./swish-api/swish-api-client";
|
|
9
9
|
export declare const VERSION: string;
|
|
10
|
-
export declare const
|
|
11
|
-
export declare const swishApp: (options: SwishAppOptions) => Promise<SwishApp>;
|
|
10
|
+
export declare const createSwish: (options: SwishOptions) => Promise<SwishApp>;
|
|
12
11
|
export declare class SwishApp {
|
|
13
12
|
private readonly swishApi;
|
|
14
13
|
private readonly swishApiPublisher;
|
|
@@ -18,7 +17,7 @@ export declare class SwishApp {
|
|
|
18
17
|
private readonly options;
|
|
19
18
|
readonly events: EventBus;
|
|
20
19
|
readonly intents: Intents;
|
|
21
|
-
constructor(options:
|
|
20
|
+
constructor(options: SwishOptions);
|
|
22
21
|
get customer(): {
|
|
23
22
|
id: string | null;
|
|
24
23
|
email: string | null;
|
|
@@ -27,11 +26,11 @@ export declare class SwishApp {
|
|
|
27
26
|
b2b: boolean | null;
|
|
28
27
|
};
|
|
29
28
|
get localization(): {
|
|
30
|
-
country:
|
|
31
|
-
language:
|
|
32
|
-
market:
|
|
29
|
+
country: import("./storefront-api/types/storefront.types").CountryCode;
|
|
30
|
+
language: import("./storefront-api/types/storefront.types").LanguageCode;
|
|
31
|
+
market: string;
|
|
33
32
|
};
|
|
34
|
-
get
|
|
33
|
+
get routes(): {
|
|
35
34
|
accountUrl: string;
|
|
36
35
|
accountLoginUrl: string;
|
|
37
36
|
rootUrl: string;
|
|
@@ -45,8 +44,9 @@ export declare class SwishApp {
|
|
|
45
44
|
showModal: (element: string | HTMLElement) => Promise<void>;
|
|
46
45
|
initShopBridge: ({ onShopModalOpen, }: {
|
|
47
46
|
onShopModalOpen: () => void;
|
|
48
|
-
}) => Promise<import("
|
|
49
|
-
showToast: (toast: import("
|
|
47
|
+
}) => Promise<import("./swish").ShopBridge>;
|
|
48
|
+
showToast: (toast: import("./swish").Toast) => Promise<void>;
|
|
49
|
+
initListDetailPage: (options: import("./swish-ui/swish-ui-utils").ListDetailPageOptions, refElement: HTMLElement) => Promise<void>;
|
|
50
50
|
};
|
|
51
51
|
readonly dom: {
|
|
52
52
|
createElementLocator: typeof createElementLocator;
|
|
@@ -74,10 +74,10 @@ export declare class SwishApp {
|
|
|
74
74
|
loading: boolean;
|
|
75
75
|
error: import("@swishapp/api-client").ApiError | null;
|
|
76
76
|
}>;
|
|
77
|
-
swishQuery: <TResponse extends import("@swishapp/api-client").ApiResponse<any> | import("@swishapp/api-client").PaginatedApiResponse<any>, TVariables>(fetch: import("./state
|
|
77
|
+
swishQuery: <TResponse extends import("@swishapp/api-client").ApiResponse<any> | import("@swishapp/api-client").PaginatedApiResponse<any>, TVariables>(fetch: import("./state").FetchFn<TResponse, TVariables>, options?: {
|
|
78
78
|
variables?: import("@preact/signals-core").Signal<TVariables>;
|
|
79
79
|
skip?: import("@preact/signals-core").Signal<boolean>;
|
|
80
|
-
refetch?: import("
|
|
80
|
+
refetch?: import("./swish").EventName[];
|
|
81
81
|
}) => {
|
|
82
82
|
data: import("@preact/signals-core").Signal<(TResponse extends {
|
|
83
83
|
data: infer D;
|
|
@@ -92,3 +92,12 @@ export declare class SwishApp {
|
|
|
92
92
|
computed: typeof computed;
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
|
+
export type * from "./types";
|
|
96
|
+
export type * from "@swishapp/api-client";
|
|
97
|
+
export type * from "./ajax-api/ajax-api-client";
|
|
98
|
+
export type { EventName } from "./events/event-bus";
|
|
99
|
+
export type * from "./storefront-api/storefront-api-client";
|
|
100
|
+
export type * from "./intents/types";
|
|
101
|
+
export type { Ref, SwishUiElement } from "./swish-ui/swish-ui-element";
|
|
102
|
+
export type { Toast, ToastManager, UnsaveAlertSubmitData, ListSelectSubmitData, VariantSelectSubmitData, UnsaveAlertOptions, ListSelectOptions, VariantSelectOptions, QuickBuySubmitData, QuickBuyOptions, } from "./swish-ui/swish-ui-utils";
|
|
103
|
+
export type { ShopBridge } from "./utils/shop-bridge";
|