@swishapp/sdk 0.80.3 → 0.89.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/handlers/create-item-handler.d.ts +3 -8
- package/dist/intents/handlers/create-list-handler.d.ts +4 -7
- package/dist/intents/handlers/delete-item-handler.d.ts +3 -8
- package/dist/intents/handlers/delete-list-handler.d.ts +3 -8
- package/dist/intents/handlers/edit-item-lists-handler.d.ts +3 -9
- package/dist/intents/handlers/edit-item-variant-handler.d.ts +3 -8
- package/dist/intents/handlers/edit-list-handler.d.ts +3 -8
- package/dist/intents/handlers/open-home-handler.d.ts +3 -7
- package/dist/intents/handlers/open-list-menu-handler.d.ts +3 -8
- package/dist/intents/handlers/open-quick-buy-handler.d.ts +3 -8
- package/dist/intents/handlers/open-sign-in-handler.d.ts +3 -8
- package/dist/intents/handlers/show-toast-handler.d.ts +17 -0
- package/dist/intents/hooks/after-create-item-hook.d.ts +2 -3
- package/dist/intents/hooks/after-edit-item-lists-hook.d.ts +2 -3
- package/dist/intents/hooks/after-open-home-hook.d.ts +5 -0
- package/dist/intents/intent-handler.d.ts +3 -3
- package/dist/intents/intent-hook.d.ts +2 -2
- package/dist/intents/intents.d.ts +10 -6
- package/dist/intents/types.d.ts +54 -51
- package/dist/options/types.d.ts +2 -2
- package/dist/swish-ui/swish-ui.d.ts +14 -14
- package/dist/swish-ui/types.d.ts +38 -47
- package/dist/swish.d.ts +1 -19
- package/dist/swish.js +61 -61
- package/dist/utils/{shopify-gid.d.ts → shopify-mapper.d.ts} +1 -0
- package/package.json +2 -2
package/dist/swish-ui/types.d.ts
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { DeleteItemSuccessResponse, EditItemListsSuccessResponse, EditItemVariantSuccessResponse, EditListSuccessResponse } from "../intents/types";
|
|
2
|
+
import { Ref } from "../swish";
|
|
3
|
+
type ExtractSuccessData<T> = T extends {
|
|
4
|
+
code: "ok";
|
|
5
|
+
data: infer D;
|
|
6
|
+
} ? D : never;
|
|
7
|
+
export interface UiResponseBase {
|
|
8
|
+
code: "ok" | "closed";
|
|
9
|
+
}
|
|
10
|
+
export interface ClosedUiResponse extends UiResponseBase {
|
|
11
|
+
code: "closed";
|
|
12
|
+
}
|
|
13
|
+
export interface SuccessUiResponse<T = void> extends UiResponseBase {
|
|
14
|
+
code: "ok";
|
|
15
|
+
data: T;
|
|
16
|
+
}
|
|
17
|
+
export type UiResponse<T = void> = T extends void ? ClosedUiResponse | SuccessUiResponse<void> : ClosedUiResponse | SuccessUiResponse<T>;
|
|
2
18
|
export interface ToastManager {
|
|
3
|
-
show(toast: Toast):
|
|
19
|
+
show(toast: Toast, id?: number): void;
|
|
4
20
|
hide(id: string): void;
|
|
5
21
|
clear(): void;
|
|
6
22
|
}
|
|
@@ -10,90 +26,65 @@ export interface Toast {
|
|
|
10
26
|
image?: string;
|
|
11
27
|
action?: {
|
|
12
28
|
label: string;
|
|
13
|
-
url?: string;
|
|
14
|
-
onClick?: () => void;
|
|
15
29
|
};
|
|
16
30
|
}
|
|
17
31
|
export interface SignInOptions {
|
|
18
32
|
returnTo?: string;
|
|
19
|
-
onClose?: () => void;
|
|
20
33
|
}
|
|
21
34
|
export interface UnsaveAlertOptions {
|
|
22
35
|
itemId: string;
|
|
23
|
-
onSubmit?: (data: UnsaveAlertSubmitData) => void;
|
|
24
|
-
onClose?: () => void;
|
|
25
|
-
}
|
|
26
|
-
export interface UnsaveAlertSubmitData {
|
|
27
|
-
itemId: string;
|
|
28
36
|
}
|
|
37
|
+
export type UnsaveAlertSubmitData = ExtractSuccessData<DeleteItemSuccessResponse>;
|
|
29
38
|
export interface DeleteListAlertOptions {
|
|
30
39
|
listId: string;
|
|
31
|
-
onSubmit?: () => void;
|
|
32
|
-
onClose?: () => void;
|
|
33
40
|
}
|
|
34
41
|
export interface DrawerOptions {
|
|
35
|
-
onClose?: () => void;
|
|
36
42
|
}
|
|
37
43
|
export interface ListMenuOptions {
|
|
38
44
|
listId: string;
|
|
39
|
-
onClose?: () => void;
|
|
40
|
-
onEdit?: (data: ListEditorSubmitData) => void;
|
|
41
|
-
onDelete?: () => void;
|
|
42
45
|
}
|
|
46
|
+
export type ListEditorSubmitData = ExtractSuccessData<EditListSuccessResponse>;
|
|
47
|
+
export type ListMenuResponse = UiResponse<{
|
|
48
|
+
action: "edit";
|
|
49
|
+
data: ListEditorSubmitData;
|
|
50
|
+
} | {
|
|
51
|
+
action: "delete";
|
|
52
|
+
}>;
|
|
43
53
|
export interface ListDetailPageOptions {
|
|
44
54
|
listId?: string;
|
|
45
55
|
}
|
|
46
56
|
export interface ListSelectOptions {
|
|
47
57
|
itemId: string;
|
|
48
|
-
onSubmit?: (data: ListSelectSubmitData) => void | Promise<void>;
|
|
49
|
-
onClose?: () => void;
|
|
50
|
-
onUnsave?: (data: UnsaveAlertSubmitData) => void;
|
|
51
|
-
}
|
|
52
|
-
export type ListSelectProduct = Exclude<GetProductCardDataWithVariantQuery["product"], undefined | null>;
|
|
53
|
-
export type ListSelectVariant = Exclude<GetProductCardDataWithVariantQuery["variant"], undefined | null>;
|
|
54
|
-
export interface ListSelectSubmitData {
|
|
55
|
-
item: ItemDetail;
|
|
56
|
-
product: ListSelectProduct;
|
|
57
|
-
variant?: ListSelectVariant;
|
|
58
58
|
}
|
|
59
|
+
export type ListSelectSubmitData = ExtractSuccessData<EditItemListsSuccessResponse>;
|
|
60
|
+
export type ListSelectResponse = UiResponse<{
|
|
61
|
+
action: "submit";
|
|
62
|
+
data: ListSelectSubmitData;
|
|
63
|
+
} | {
|
|
64
|
+
action: "unsave";
|
|
65
|
+
data: UnsaveAlertSubmitData;
|
|
66
|
+
}>;
|
|
59
67
|
export interface VariantSelectOptions {
|
|
60
68
|
productId?: string;
|
|
61
69
|
productHandle?: string;
|
|
62
70
|
variantId?: string;
|
|
63
71
|
displayType?: "rows" | "pills";
|
|
64
|
-
onSubmit: (data: VariantSelectSubmitData) => void;
|
|
65
|
-
onClose: () => void;
|
|
66
|
-
}
|
|
67
|
-
export type VariantSelectProduct = Exclude<GetSelectedVariantQuery["product"], undefined | null>;
|
|
68
|
-
export type VariantSelectVariant = Exclude<VariantSelectProduct["variantBySelectedOptions"], undefined | null>;
|
|
69
|
-
export interface VariantSelectSubmitData {
|
|
70
|
-
item: Item;
|
|
71
|
-
product: VariantSelectProduct;
|
|
72
|
-
variant: VariantSelectVariant;
|
|
73
72
|
}
|
|
73
|
+
export type VariantSelectSubmitData = ExtractSuccessData<EditItemVariantSuccessResponse>;
|
|
74
74
|
export interface QuickBuyOptions {
|
|
75
75
|
productId?: string;
|
|
76
76
|
variantId?: string;
|
|
77
|
-
onSubmit: (data: QuickBuySubmitData) => void;
|
|
78
|
-
onClose: () => void;
|
|
79
77
|
}
|
|
80
|
-
export type QuickBuyProduct = VariantSelectProduct;
|
|
81
|
-
export type QuickBuyVariant = VariantSelectVariant;
|
|
82
78
|
export interface QuickBuySubmitData {
|
|
83
|
-
product:
|
|
84
|
-
variant:
|
|
79
|
+
product: VariantSelectSubmitData["product"];
|
|
80
|
+
variant: VariantSelectSubmitData["variant"];
|
|
85
81
|
}
|
|
86
82
|
export interface ListEditorOptions {
|
|
87
83
|
listId?: string;
|
|
88
|
-
onSubmit: (data: ListEditorSubmitData) => void | Promise<void>;
|
|
89
|
-
onClose: () => void;
|
|
90
|
-
}
|
|
91
|
-
export interface ListEditorSubmitData {
|
|
92
|
-
list: List;
|
|
93
84
|
}
|
|
94
85
|
export interface RequireUiComponentOptions<TComponent> {
|
|
95
86
|
instance?: string;
|
|
96
|
-
listeners?: Record<string, (event: Event | CustomEvent) => void>;
|
|
97
87
|
onHydrated?: (ref: Ref<TComponent>) => void;
|
|
98
88
|
refElement?: HTMLElement;
|
|
99
89
|
}
|
|
90
|
+
export {};
|
package/dist/swish.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ import { SwishOptions } from "./options/types";
|
|
|
7
7
|
import { computed, effect, signal } from "./state";
|
|
8
8
|
import { StorefrontApiClient } from "./storefront-api/storefront-api-client";
|
|
9
9
|
import { SwishApi } from "./swish-api/swish-api-client";
|
|
10
|
-
import { SwishUi } from "./swish-ui/swish-ui";
|
|
11
10
|
import { ShopifyBadgesUtils } from "./utils/shopify-badge-utils";
|
|
12
11
|
export declare const VERSION: string;
|
|
13
12
|
export declare const createSwish: (optionsInput: SwishOptionsInput) => Promise<SwishApp>;
|
|
@@ -24,29 +23,12 @@ declare class SwishApp {
|
|
|
24
23
|
readonly intents: Intents;
|
|
25
24
|
constructor(options: SwishOptions);
|
|
26
25
|
get options(): SwishOptions;
|
|
27
|
-
get
|
|
28
|
-
id: string | null;
|
|
29
|
-
email: string | null;
|
|
30
|
-
firstName: string | null;
|
|
31
|
-
lastName: string | null;
|
|
32
|
-
b2b: boolean | null;
|
|
33
|
-
};
|
|
34
|
-
get localization(): {
|
|
35
|
-
country: import("./storefront-api/types/storefront.types").CountryCode;
|
|
36
|
-
language: import("./storefront-api/types/storefront.types").LanguageCode;
|
|
37
|
-
market: string;
|
|
38
|
-
};
|
|
39
|
-
get routes(): {
|
|
40
|
-
accountUrl: string;
|
|
41
|
-
accountLoginUrl: string;
|
|
42
|
-
rootUrl: string;
|
|
43
|
-
};
|
|
26
|
+
get storefrontContext(): import("./swish").StorefrontContext;
|
|
44
27
|
get badges(): ShopifyBadgesUtils;
|
|
45
28
|
get api(): SwishApi;
|
|
46
29
|
get storefront(): StorefrontApiClient;
|
|
47
30
|
get ajax(): AjaxApiClient;
|
|
48
31
|
get shopUrl(): string;
|
|
49
|
-
get ui(): SwishUi;
|
|
50
32
|
readonly dom: {
|
|
51
33
|
createElementLocator: typeof createElementLocator;
|
|
52
34
|
createQueryParamsObserver: typeof createLocationObserver;
|