@swishapp/sdk 0.105.1 → 0.107.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.
Files changed (30) hide show
  1. package/dist/ajax-api/ajax-api-client.d.ts +1 -1
  2. package/dist/dom/create-placement.d.ts +114 -0
  3. package/dist/dom/dom-utils.d.ts +2 -1
  4. package/dist/intents/handlers/create-cart-line-handler.d.ts +21 -0
  5. package/dist/intents/handlers/edit-item-lists-handler.d.ts +2 -2
  6. package/dist/intents/handlers/edit-list-access-handler.d.ts +15 -0
  7. package/dist/intents/handlers/open-list-menu-handler.d.ts +6 -4
  8. package/dist/intents/handlers/share-list-handler.d.ts +16 -0
  9. package/dist/intents/handlers/show-toast-handler.d.ts +2 -0
  10. package/dist/intents/handlers/unsave-item-handler.d.ts +14 -0
  11. package/dist/intents/hooks/after-edit-list-access-hook.d.ts +5 -0
  12. package/dist/intents/hooks/after-share-list-hook.d.ts +5 -0
  13. package/dist/intents/intents.d.ts +12 -12
  14. package/dist/intents/types.d.ts +28 -19
  15. package/dist/options/swish-options.d.ts +7 -3
  16. package/dist/options/types.d.ts +92 -6
  17. package/dist/storefront-api/storefront-api-client.d.ts +33 -18
  18. package/dist/storefront-api/types/storefront.types.d.ts +33 -4
  19. package/dist/swish-api/swish-api-client.d.ts +4 -1
  20. package/dist/swish-ui/swish-ui-element.d.ts +1 -0
  21. package/dist/swish-ui/swish-ui.d.ts +14 -8
  22. package/dist/swish-ui/types.d.ts +21 -5
  23. package/dist/swish.d.ts +20 -1
  24. package/dist/swish.js +64 -64
  25. package/dist/utils/build-share-list-url.d.ts +4 -0
  26. package/dist/utils/copy-to-clipboard.d.ts +6 -0
  27. package/dist/utils/is-mobile-device.d.ts +1 -0
  28. package/dist/utils/shopify-id-schema.d.ts +2 -0
  29. package/package.json +1 -1
  30. package/dist/intents/handlers/delete-item-handler.d.ts +0 -13
@@ -52,7 +52,7 @@ export interface Cart {
52
52
  cart_level_discount_applications: any[];
53
53
  }
54
54
  export interface AddToCartItem {
55
- id: string;
55
+ id: string | number;
56
56
  quantity: number;
57
57
  }
58
58
  export interface AddToCartRequest {
@@ -0,0 +1,114 @@
1
+ import { SwishApp } from "../swish";
2
+ import { CreateElementLocatorArgs } from "./dom-utils";
3
+ export declare function createPlacement<TDomElement extends HTMLElement = HTMLElement, TElementName extends ElementName = ElementName>(swish: SwishApp, spec: PlacementSpec<TDomElement, TElementName>): {
4
+ mount(): void;
5
+ unmount(): void;
6
+ };
7
+ /** --------------------------------------------
8
+ * Types
9
+ * -------------------------------------------- */
10
+ export type BreakpointsSpec = {
11
+ sm?: number;
12
+ lg?: number;
13
+ } | Record<string, number>;
14
+ export type ResponsiveValue<T> = T | {
15
+ base?: T;
16
+ [breakpoint: string]: T | undefined;
17
+ };
18
+ type ElementName = "save-button" | "home-button";
19
+ export type SaveButtonDesignSpec = {
20
+ background?: ResponsiveValue<string>;
21
+ savedBackground?: ResponsiveValue<string>;
22
+ color?: ResponsiveValue<string>;
23
+ savedColor?: ResponsiveValue<string>;
24
+ height?: ResponsiveValue<string | number>;
25
+ radius?: ResponsiveValue<string | number>;
26
+ };
27
+ export type HomeButtonDesignSpec = {
28
+ background?: ResponsiveValue<string>;
29
+ color?: ResponsiveValue<string>;
30
+ height?: ResponsiveValue<string | number>;
31
+ radius?: ResponsiveValue<string | number>;
32
+ };
33
+ type DesignSpecMap = {
34
+ "save-button": SaveButtonDesignSpec;
35
+ "home-button": HomeButtonDesignSpec;
36
+ };
37
+ export type DesignSpecForElementName<TName extends ElementName = ElementName> = TName extends keyof DesignSpecMap ? DesignSpecMap[TName] : never;
38
+ export type MountMode = "before" | "after" | "append" | "prepend" | "replace";
39
+ export type MountAt = "target" | {
40
+ closest: string;
41
+ } | {
42
+ query: string;
43
+ } | {
44
+ withinClosest: {
45
+ root: string;
46
+ selector: string;
47
+ };
48
+ };
49
+ export type ContainerSpec = {
50
+ tag?: keyof HTMLElementTagNameMap;
51
+ classNames?: string[];
52
+ };
53
+ export type OverlayAnchor = "top-left" | "top-right" | "bottom-left" | "bottom-right";
54
+ export type ElementSpec<TName extends string = ElementName> = {
55
+ name: TName;
56
+ props?: Record<string, unknown>;
57
+ classNames?: string[];
58
+ };
59
+ export type OffsetSpec = {
60
+ x?: number;
61
+ y?: number;
62
+ };
63
+ export type OverlayLayoutSpec = {
64
+ type: "overlay";
65
+ anchor?: OverlayAnchor;
66
+ zIndex?: number | string;
67
+ offset?: OffsetSpec | ResponsiveValue<OffsetSpec>;
68
+ };
69
+ export type InlineLayoutSpec = {
70
+ type: "inline";
71
+ rowSelector?: string;
72
+ };
73
+ export type PlacementLayoutSpec = OverlayLayoutSpec | InlineLayoutSpec;
74
+ export type PlacementSpec<TDomElement extends HTMLElement = HTMLElement, TElementName extends ElementName = ElementName> = {
75
+ id: string;
76
+ target: Omit<CreateElementLocatorArgs, "onElementFound">;
77
+ mount: {
78
+ at?: MountAt;
79
+ mode: MountMode;
80
+ };
81
+ layout?: PlacementLayoutSpec;
82
+ breakpoints?: BreakpointsSpec;
83
+ container?: ContainerSpec;
84
+ element?: ElementSpec<TElementName> | RenderFn;
85
+ /** Design tokens (typed when element name is known). */
86
+ design?: DesignSpecForElementName<TElementName>;
87
+ /** Custom CSS appended after defaults (one stylesheet per placement). */
88
+ css?: string;
89
+ onMount?: (ctx: MountContext<TDomElement>) => void;
90
+ onUnmount?: (ctx: UnmountContext<TDomElement>) => void;
91
+ };
92
+ export type MountContext<T extends HTMLElement> = {
93
+ id: string;
94
+ targetEl: Element;
95
+ renderTargetEl: Element;
96
+ mountEl: T;
97
+ containerEl?: HTMLElement;
98
+ rowEl?: HTMLElement;
99
+ cleanup: (fn: () => void) => void;
100
+ };
101
+ export type UnmountContext<T extends HTMLElement> = Omit<MountContext<T>, "cleanup">;
102
+ export type MountedElement<T extends HTMLElement> = {
103
+ targetEl: HTMLElement;
104
+ renderTargetEl: HTMLElement;
105
+ mountEl: T;
106
+ containerEl?: HTMLElement;
107
+ rowEl?: HTMLElement;
108
+ rowWasCreated?: boolean;
109
+ rowInlineAttrPrevValue?: string | null;
110
+ cleanupFns: Array<() => void>;
111
+ ownsNode: boolean;
112
+ };
113
+ export type RenderFn = (spec: PlacementSpec<any, any>) => HTMLElement | Promise<HTMLElement>;
114
+ export {};
@@ -3,8 +3,9 @@ export interface CreateElementLocatorArgs {
3
3
  onElementFound: (element: Element) => void;
4
4
  selector: string;
5
5
  observerOptions?: IntersectionObserverInit;
6
+ mustMatch?: (element: Element) => boolean;
6
7
  }
7
- export declare function createElementLocator({ onElementFound, selector, observerOptions, }: CreateElementLocatorArgs): MutationObserver;
8
+ export declare function createElementLocator({ onElementFound, selector, observerOptions, mustMatch, }: CreateElementLocatorArgs): MutationObserver;
8
9
  export interface CreateLocationObserverArgs {
9
10
  onLocationChange: (location: Location) => void;
10
11
  fireOnInit?: boolean;
@@ -0,0 +1,21 @@
1
+ import * as v from "valibot";
2
+ import type { AddToCartResponse } from "../../ajax-api/ajax-api-client";
3
+ import { IntentHandler } from "../intent-handler";
4
+ import { IntentResponse, SuccessIntentResponse } from "../types";
5
+ export declare const CreateCartLineIntentDataSchema: v.UnionSchema<[v.ObjectSchema<{
6
+ readonly variantId: v.SchemaWithPipe<readonly [v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, string>]>, v.NumberSchema<undefined>], undefined>, v.TransformAction<string | number, number>, v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>]>]>;
7
+ readonly quantity: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>]>, 1>;
8
+ }, undefined>, v.ObjectSchema<{
9
+ readonly items: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
10
+ readonly variantId: v.SchemaWithPipe<readonly [v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, string>]>, v.NumberSchema<undefined>], undefined>, v.TransformAction<string | number, number>, v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>]>]>;
11
+ readonly quantity: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>]>, 1>;
12
+ }, undefined>, undefined>, v.MinLengthAction<{
13
+ variantId: number;
14
+ quantity: number;
15
+ }[], 1, undefined>]>;
16
+ }, undefined>], undefined>;
17
+ export type CreateCartLineIntentData = v.InferInput<typeof CreateCartLineIntentDataSchema>;
18
+ export type CreateCartLineSuccessResponse = SuccessIntentResponse<AddToCartResponse>;
19
+ export declare class CreateCartLineHandler extends IntentHandler<"create:cart-line"> {
20
+ invoke(data: CreateCartLineIntentData): Promise<IntentResponse<"create:cart-line">>;
21
+ }
@@ -14,6 +14,6 @@ export type EditItemListsSuccessResponse = SuccessIntentResponse<{
14
14
  variant: GetSaveIntentDataWithVariantQuery["variant"];
15
15
  }>;
16
16
  export type EditItemListsIntentDataValidated = v.InferInput<typeof EditItemListsIntentDataSchema>;
17
- export declare class EditItemListsHandler extends IntentHandler<"edit:item-lists" | "delete:item"> {
18
- invoke(data: EditItemListsIntentData): Promise<IntentResponse<"edit:item-lists" | "delete:item">>;
17
+ export declare class EditItemListsHandler extends IntentHandler<"edit:item-lists" | "unsave:item"> {
18
+ invoke(data: EditItemListsIntentData): Promise<IntentResponse<"edit:item-lists" | "unsave:item">>;
19
19
  }
@@ -0,0 +1,15 @@
1
+ import { List } from "@swishapp/api-client";
2
+ import * as v from "valibot";
3
+ import { IntentHandler } from "../intent-handler";
4
+ import { IntentResponse, SuccessIntentResponse } from "../types";
5
+ export declare const EditListAccessIntentDataSchema: v.ObjectSchema<{
6
+ readonly listId: v.StringSchema<undefined>;
7
+ readonly access: v.PicklistSchema<["public", "private"], undefined>;
8
+ }, undefined>;
9
+ export type EditListAccessIntentData = v.InferInput<typeof EditListAccessIntentDataSchema>;
10
+ export type EditListAccessSuccessResponse = SuccessIntentResponse<{
11
+ list: List;
12
+ }>;
13
+ export declare class EditListAccessHandler extends IntentHandler<"edit:list-access"> {
14
+ invoke(data: EditListAccessIntentData): Promise<IntentResponse<"edit:list-access">>;
15
+ }
@@ -1,13 +1,15 @@
1
1
  import * as v from "valibot";
2
2
  import { IntentHandler } from "../intent-handler";
3
3
  import { IntentResponse } from "../types";
4
- import { EditListSuccessResponse } from "./edit-list-handler";
5
4
  import { DeleteListSuccessResponse } from "./delete-list-handler";
5
+ import { EditListAccessSuccessResponse } from "./edit-list-access-handler";
6
+ import { EditListSuccessResponse } from "./edit-list-handler";
7
+ import { ShareListSuccessResponse } from "./share-list-handler";
6
8
  export declare const OpenListMenuIntentDataSchema: v.ObjectSchema<{
7
9
  readonly listId: v.StringSchema<undefined>;
8
10
  }, undefined>;
9
11
  export type OpenListMenuIntentData = v.InferInput<typeof OpenListMenuIntentDataSchema>;
10
- export type OpenListMenuSuccessResponse = EditListSuccessResponse | DeleteListSuccessResponse;
11
- export declare class OpenListMenuHandler extends IntentHandler<"open:list-menu" | "edit:list" | "delete:list"> {
12
- invoke(data: OpenListMenuIntentData): Promise<IntentResponse<"open:list-menu" | "edit:list" | "delete:list">>;
12
+ export type OpenListMenuSuccessResponse = EditListSuccessResponse | DeleteListSuccessResponse | EditListAccessSuccessResponse | ShareListSuccessResponse;
13
+ export declare class OpenListMenuHandler extends IntentHandler<"open:list-menu" | "edit:list" | "delete:list" | "edit:list-access" | "share:list"> {
14
+ invoke(data: OpenListMenuIntentData): Promise<IntentResponse<"open:list-menu" | "edit:list" | "delete:list" | "edit:list-access" | "share:list">>;
13
15
  }
@@ -0,0 +1,16 @@
1
+ import * as v from "valibot";
2
+ import { IntentHandler } from "../intent-handler";
3
+ import { IntentResponse, SuccessIntentResponse } from "../types";
4
+ export declare const ShareListIntentDataSchema: v.ObjectSchema<{
5
+ readonly listId: v.StringSchema<undefined>;
6
+ }, undefined>;
7
+ export type ShareListIntentData = v.InferInput<typeof ShareListIntentDataSchema>;
8
+ export type ShareListSuccessResponse = SuccessIntentResponse<{
9
+ listId: string;
10
+ url: string;
11
+ method: "native" | "clipboard";
12
+ publicListId?: string;
13
+ }>;
14
+ export declare class ShareListHandler extends IntentHandler<"share:list"> {
15
+ invoke(data: ShareListIntentData): Promise<IntentResponse<"share:list">>;
16
+ }
@@ -9,6 +9,8 @@ export declare const ToastIntentDataSchema: v.ObjectSchema<{
9
9
  readonly label: v.StringSchema<undefined>;
10
10
  readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
11
11
  }, undefined>, undefined>;
12
+ readonly variant: v.OptionalSchema<v.PicklistSchema<["compact", "full"], undefined>, undefined>;
13
+ readonly icon: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
12
14
  }, undefined>;
13
15
  export type ToastIntentData = v.InferInput<typeof ToastIntentDataSchema>;
14
16
  export type ToastSuccessResponse = SuccessIntentResponse<void>;
@@ -0,0 +1,14 @@
1
+ import * as v from "valibot";
2
+ import { IntentHandler } from "../intent-handler";
3
+ import { IntentResponse, SuccessIntentResponse } from "../types";
4
+ export declare const UnsaveItemIntentDataSchema: v.ObjectSchema<{
5
+ readonly itemId: v.StringSchema<undefined>;
6
+ readonly delete: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
7
+ }, undefined>;
8
+ export type UnsaveItemIntentData = v.InferInput<typeof UnsaveItemIntentDataSchema>;
9
+ export type UnsaveItemSuccessResponse = SuccessIntentResponse<{
10
+ itemId: string;
11
+ }>;
12
+ export declare class UnsaveItemHandler extends IntentHandler<"unsave:item" | "edit:item-lists"> {
13
+ invoke(data: UnsaveItemIntentData): Promise<IntentResponse<"unsave:item" | "edit:item-lists">>;
14
+ }
@@ -0,0 +1,5 @@
1
+ import { IntentHook } from "../intent-hook";
2
+ import { IntentResponse } from "../types";
3
+ export declare class AfterEditListAccessHook extends IntentHook<"edit:list-access"> {
4
+ invoke(response: IntentResponse<"edit:list-access">): Promise<void>;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { IntentHook } from "../intent-hook";
2
+ import { IntentResponse } from "../types";
3
+ export declare class AfterShareListHook extends IntentHook<"share:list"> {
4
+ invoke(response: IntentResponse<"share:list">): Promise<void>;
5
+ }
@@ -1,20 +1,20 @@
1
1
  import { SwishApp } from "../swish";
2
- import { Intent, IntentActivity, IntentQueryWithParams, IntentResponse, IntentToData } from "./types";
3
2
  import { SwishUi } from "../swish-ui/swish-ui";
3
+ import { Intent, IntentActivity, IntentQueryWithParams, IntentResponse, IntentToData } from "./types";
4
4
  export interface IntentOptions {
5
- save: {
6
- requireVariant: boolean;
7
- requireVariantConfirmation: boolean;
8
- showToast: boolean;
5
+ saveProduct: {
6
+ promptVariantIfMissing: boolean;
7
+ promptVariantIfPresent: boolean;
8
+ showFeedback: boolean;
9
9
  };
10
- edit: {
11
- requireVariantConfirmation: boolean;
12
- showToast: boolean;
10
+ unsaveProduct: {
11
+ selectList: boolean;
12
+ confirm: boolean;
13
+ showFeedback: boolean;
13
14
  };
14
- unsave: {
15
- requireConfirmation: boolean;
16
- openEditor: boolean;
17
- showToast: boolean;
15
+ editSavedProduct: {
16
+ promptVariantChange: boolean;
17
+ showFeedback: boolean;
18
18
  };
19
19
  }
20
20
  export declare class Intents {
@@ -1,27 +1,30 @@
1
- import type { SaveItemIntentData, SaveItemSuccessResponse } from "./handlers/save-item-handler";
2
- import type { DeleteItemIntentData, DeleteItemSuccessResponse } from "./handlers/delete-item-handler";
3
- import type { EditItemVariantIntentData, EditItemVariantSuccessResponse } from "./handlers/edit-item-variant-handler";
1
+ import type { CreateListIntentData, CreateListSuccessResponse } from "./handlers/create-list-handler";
2
+ import type { CreateCartLineIntentData, CreateCartLineSuccessResponse } from "./handlers/create-cart-line-handler";
3
+ import type { DeleteListIntentData, DeleteListSuccessResponse } from "./handlers/delete-list-handler";
4
4
  import type { EditItemListsIntentData, EditItemListsSuccessResponse } from "./handlers/edit-item-lists-handler";
5
+ import type { EditItemVariantIntentData, EditItemVariantSuccessResponse } from "./handlers/edit-item-variant-handler";
6
+ import type { EditListAccessIntentData, EditListAccessSuccessResponse } from "./handlers/edit-list-access-handler";
5
7
  import type { EditListIntentData, EditListSuccessResponse } from "./handlers/edit-list-handler";
6
- import type { DeleteListIntentData, DeleteListSuccessResponse } from "./handlers/delete-list-handler";
7
- import type { CreateListIntentData, CreateListSuccessResponse } from "./handlers/create-list-handler";
8
8
  import type { OpenHomeSuccessResponse } from "./handlers/open-home-handler";
9
- import type { OpenListMenuIntentData, OpenListMenuSuccessResponse } from "./handlers/open-list-menu-handler";
10
- import type { OpenSignInIntentData, OpenSignInSuccessResponse } from "./handlers/open-sign-in-handler";
11
- import type { OpenQuickBuyIntentData, OpenQuickBuySuccessResponse } from "./handlers/open-quick-buy-handler";
12
9
  import type { OpenListDetailPageMenuIntentData, OpenListDetailPageMenuSuccessResponse } from "./handlers/open-list-detail-page-menu-handler";
13
- import { ToastIntentData, ToastSuccessResponse } from "./handlers/show-toast-handler";
10
+ import { OpenListIntentData, OpenListSuccessResponse } from "./handlers/open-list-handler";
11
+ import type { OpenListMenuIntentData, OpenListMenuSuccessResponse } from "./handlers/open-list-menu-handler";
14
12
  import { OpenListsSuccessResponse } from "./handlers/open-lists-handler";
15
- import { OpenOrdersSuccessResponse } from "./handlers/open-orders-handler";
16
- import { OpenSavesSuccessResponse } from "./handlers/open-saves-handler";
17
13
  import { OpenNotificationsSuccessResponse } from "./handlers/open-notifications-handler";
18
- import { OpenProfileSuccessResponse } from "./handlers/open-profile-handler";
19
- import { OpenListIntentData, OpenListSuccessResponse } from "./handlers/open-list-handler";
20
- import { OpenProductIntentData, OpenProductSuccessResponse } from "./handlers/open-product-handler";
21
14
  import { OpenOrderIntentData, OpenOrderSuccessResponse } from "./handlers/open-order-handler";
22
15
  import type { OpenOrderMenuIntentData, OpenOrderMenuSuccessResponse } from "./handlers/open-order-menu-handler";
23
- export type { DeleteItemSuccessResponse, EditItemVariantSuccessResponse, EditItemListsSuccessResponse, SaveItemSuccessResponse, EditListSuccessResponse, DeleteListSuccessResponse, CreateListSuccessResponse, ToastSuccessResponse, };
24
- export type Intent = "save:item" | "edit:item-variant" | "edit:item-lists" | "delete:item" | "edit:list" | "delete:list" | "create:list" | "open:home" | "open:list" | "open:lists" | "open:orders" | "open:order" | "open:saves" | "open:notifications" | "open:profile" | "open:product" | "open:list-menu" | "open:order-menu" | "open:list-detail-page-menu" | "open:sign-in" | "open:quick-buy" | "show:toast";
16
+ import { OpenOrdersSuccessResponse } from "./handlers/open-orders-handler";
17
+ import { OpenProductIntentData, OpenProductSuccessResponse } from "./handlers/open-product-handler";
18
+ import { OpenProfileSuccessResponse } from "./handlers/open-profile-handler";
19
+ import type { OpenQuickBuyIntentData, OpenQuickBuySuccessResponse } from "./handlers/open-quick-buy-handler";
20
+ import { OpenSavesSuccessResponse } from "./handlers/open-saves-handler";
21
+ import type { OpenSignInIntentData, OpenSignInSuccessResponse } from "./handlers/open-sign-in-handler";
22
+ import type { SaveItemIntentData, SaveItemSuccessResponse } from "./handlers/save-item-handler";
23
+ import type { ShareListIntentData, ShareListSuccessResponse } from "./handlers/share-list-handler";
24
+ import { ToastIntentData, ToastSuccessResponse } from "./handlers/show-toast-handler";
25
+ import type { UnsaveItemIntentData, UnsaveItemSuccessResponse } from "./handlers/unsave-item-handler";
26
+ export type { CreateCartLineSuccessResponse, CreateListSuccessResponse, DeleteListSuccessResponse, EditItemListsSuccessResponse, EditItemVariantSuccessResponse, EditListAccessSuccessResponse, EditListSuccessResponse, SaveItemSuccessResponse, ShareListSuccessResponse, ToastSuccessResponse, UnsaveItemSuccessResponse, };
27
+ export type Intent = "create:cart-line" | "save:item" | "edit:item-variant" | "edit:item-lists" | "unsave:item" | "edit:list" | "edit:list-access" | "delete:list" | "create:list" | "share:list" | "open:home" | "open:list" | "open:lists" | "open:orders" | "open:order" | "open:saves" | "open:notifications" | "open:profile" | "open:product" | "open:list-menu" | "open:order-menu" | "open:list-detail-page-menu" | "open:sign-in" | "open:quick-buy" | "show:toast";
25
28
  export type IntentQueryParam = `${string}=${string}`;
26
29
  export type IntentQueryWithParams = `${Intent},${IntentQueryParam}`;
27
30
  export type IntentResponse<I extends Intent = Intent> = ClosedIntentResponse<I> | ErrorIntentResponse<I> | IntentToSuccessResponse<I>;
@@ -48,13 +51,16 @@ export interface SuccessIntentResponse<T, I extends Intent = Intent> extends Int
48
51
  data: T;
49
52
  }
50
53
  interface IntentDataMap {
54
+ "create:cart-line": CreateCartLineIntentData;
51
55
  "save:item": SaveItemIntentData;
52
56
  "edit:item-variant": EditItemVariantIntentData;
53
57
  "edit:item-lists": EditItemListsIntentData;
54
- "delete:item": DeleteItemIntentData;
58
+ "unsave:item": UnsaveItemIntentData;
55
59
  "edit:list": EditListIntentData;
60
+ "edit:list-access": EditListAccessIntentData;
56
61
  "delete:list": DeleteListIntentData;
57
62
  "create:list": CreateListIntentData;
63
+ "share:list": ShareListIntentData;
58
64
  "open:home": void;
59
65
  "open:list": OpenListIntentData;
60
66
  "open:lists": void;
@@ -72,13 +78,16 @@ interface IntentDataMap {
72
78
  "show:toast": ToastIntentData;
73
79
  }
74
80
  interface IntentSuccessResponseMap {
81
+ "create:cart-line": CreateCartLineSuccessResponse;
75
82
  "save:item": SaveItemSuccessResponse;
76
83
  "edit:item-variant": EditItemVariantSuccessResponse;
77
- "edit:item-lists": EditItemListsSuccessResponse | DeleteItemSuccessResponse;
78
- "delete:item": DeleteItemSuccessResponse;
84
+ "edit:item-lists": EditItemListsSuccessResponse | UnsaveItemSuccessResponse;
85
+ "unsave:item": UnsaveItemSuccessResponse;
79
86
  "edit:list": EditListSuccessResponse;
87
+ "edit:list-access": EditListAccessSuccessResponse;
80
88
  "delete:list": DeleteListSuccessResponse;
81
89
  "create:list": CreateListSuccessResponse;
90
+ "share:list": ShareListSuccessResponse;
82
91
  "open:home": OpenHomeSuccessResponse;
83
92
  "open:list": OpenListSuccessResponse;
84
93
  "open:lists": OpenListsSuccessResponse;
@@ -1,13 +1,17 @@
1
+ import { IntentOptions } from "../intents/intents";
1
2
  import { StorefrontApiOptions, SwishClientConfig } from "../swish";
2
- import { StorefrontContext, SwishBadgeOptions, SwishMetafieldOptions, SwishOptions, SwishUiOptions } from "./types";
3
+ import { StorefrontContext, SwishBadgeOptions, SwishFeaturesOptions, SwishMetafieldOptions, SwishOptions, SwishProductOptions, SwishUiOptions } from "./types";
3
4
  export type SwishOptionsInput = {
4
5
  storefrontApi: StorefrontApiOptions;
5
6
  storefrontContext: StorefrontContext;
6
- badges?: SwishBadgeOptions;
7
- metafields?: SwishMetafieldOptions;
8
7
  swishApi?: SwishClientConfig & {
9
8
  version: string;
10
9
  };
11
10
  swishUi?: SwishUiOptions;
11
+ badges?: SwishBadgeOptions;
12
+ productOptions?: SwishProductOptions;
13
+ metafields?: SwishMetafieldOptions;
14
+ features?: SwishFeaturesOptions;
15
+ intents?: IntentOptions;
12
16
  };
13
17
  export declare const createSwishOptions: (options: SwishOptionsInput) => SwishOptions;
@@ -1,16 +1,19 @@
1
1
  import { IntentOptions } from "../intents/intents";
2
2
  import { CountryCode, LanguageCode } from "../storefront-api/types/storefront.types";
3
- import { GetProductCardDataQuery, GetProductCardDataWithVariantQuery, Intent, StorefrontApiOptions, SwishClientConfig } from "../swish";
3
+ import { GetProductCardDataQuery, GetProductCardDataWithVariantQuery, GetProductOptionsQuery, Intent, StorefrontApiOptions, SwishClientConfig } from "../swish";
4
4
  import { Badge } from "../utils/shopify-badge-utils";
5
5
  export interface SwishOptions {
6
6
  storefrontApi: StorefrontApiOptions;
7
7
  storefrontContext: StorefrontContext;
8
- badges: SwishBadgeOptions;
9
- metafields: SwishMetafieldOptions;
10
8
  swishApi: SwishClientConfig & {
11
9
  version: string;
12
10
  };
13
11
  swishUi: SwishUiOptions;
12
+ features: SwishFeaturesOptions;
13
+ intents: IntentOptions;
14
+ metafields: SwishMetafieldOptions;
15
+ badges: SwishBadgeOptions;
16
+ productOptions: SwishProductOptions;
14
17
  }
15
18
  export interface SwishMetafieldOptions {
16
19
  product: `${string}.${string}`[];
@@ -23,14 +26,87 @@ export interface SwishBadgeOptions {
23
26
  defaultBadges: string[];
24
27
  }) => (string | Badge)[];
25
28
  }
29
+ export interface SwishProductOptions {
30
+ sortValues: (args: {
31
+ optionValues: NonNullable<GetProductOptionsQuery["product"]>["options"][number]["optionValues"];
32
+ }) => NonNullable<GetProductOptionsQuery["product"]>["options"][number]["optionValues"];
33
+ }
34
+ export interface SwishUiDesignOptions {
35
+ appearance?: {
36
+ iconThickness?: number | string;
37
+ };
38
+ sizes?: {
39
+ buttonHeight?: number | string;
40
+ iconButtonSize?: number | string;
41
+ formInputHeight?: number | string;
42
+ iconSize?: number | string;
43
+ imageCardAspectRatio?: string;
44
+ imageSliderAspectRatio?: string;
45
+ };
46
+ rounding?: {
47
+ borderRadiusScale?: number | string;
48
+ badgeBorderRadius?: string;
49
+ buttonBorderRadius?: string;
50
+ dialogBorderRadius?: string;
51
+ formInputBorderRadius?: string;
52
+ imageCardBorderRadius?: string;
53
+ imageSliderBorderRadius?: string;
54
+ thumbnailBorderRadius?: string;
55
+ };
56
+ colors?: {
57
+ backgroundRgb?: string;
58
+ textColorRgb?: string;
59
+ textColorDangerRgb?: string;
60
+ headingColorRgb?: string;
61
+ primaryButtonBackgroundRgb?: string;
62
+ primaryButtonColorRgb?: string;
63
+ secondaryButtonBackgroundRgb?: string;
64
+ secondaryButtonColorRgb?: string;
65
+ dangerButtonColorRgb?: string;
66
+ statusDotBackgroundRgb?: string;
67
+ badgeBackgroundRgb?: string;
68
+ badgeColorRgb?: string;
69
+ };
70
+ typography?: {
71
+ headingFontFamily?: string;
72
+ headingTextTransform?: string;
73
+ headingFontSize?: number | string;
74
+ headingLetterSpacing?: string;
75
+ headingLineHeight?: number | string;
76
+ headingFontWeight?: number | string;
77
+ textFontFamily?: string;
78
+ textFontSize?: number | string;
79
+ textLetterSpacing?: string;
80
+ textLineHeight?: number | string;
81
+ textLineHeightParagraph?: number | string;
82
+ textFontWeight?: number | string;
83
+ buttonFontFamily?: string;
84
+ buttonTextTransform?: string;
85
+ buttonFontSize?: number | string;
86
+ buttonLetterSpacing?: string;
87
+ buttonLineHeight?: number | string;
88
+ buttonFontWeight?: number | string;
89
+ badgeFontFamily?: string;
90
+ badgeTextTransform?: string;
91
+ badgeFontSize?: number | string;
92
+ badgeLetterSpacing?: string;
93
+ badgeLineHeight?: number | string;
94
+ badgeFontWeight?: number | string;
95
+ };
96
+ }
26
97
  export interface SwishUiOptions {
27
98
  baseUrl: string;
28
99
  components: SwishComponentOptions;
29
100
  css: (string | URL)[];
30
- intents: IntentOptions;
31
- theme: Record<string, string>;
101
+ design: SwishUiDesignOptions;
32
102
  version: string;
33
103
  }
104
+ export interface SwishFeaturesOptions {
105
+ accounts: boolean;
106
+ lists: boolean;
107
+ orders: boolean;
108
+ notifications: boolean;
109
+ }
34
110
  export interface StorefrontContext {
35
111
  customer: {
36
112
  id: string | null;
@@ -45,10 +121,13 @@ export interface StorefrontContext {
45
121
  market: string;
46
122
  };
47
123
  myshopifyDomain: string;
48
- newCustomAccounts: boolean;
124
+ capabilities: {
125
+ newCustomerAccounts: boolean;
126
+ };
49
127
  routes: {
50
128
  accountUrl: string;
51
129
  rootUrl: string;
130
+ listDetailPagePath: string;
52
131
  };
53
132
  }
54
133
  export interface SwishComponentOptions {
@@ -96,6 +175,7 @@ export interface SwishDrawerNavigationItem {
96
175
  intent: Intent;
97
176
  }
98
177
  export interface SwishDrawerNavigationOptions {
178
+ enabled: boolean;
99
179
  variant: SwishDrawerNavigationVariant;
100
180
  items: SwishDrawerNavigationItem[];
101
181
  }
@@ -104,6 +184,7 @@ export interface SwishDrawerMiniMenuItem {
104
184
  url: string;
105
185
  }
106
186
  export interface SwishDrawerMiniMenuOptions {
187
+ enabled: boolean;
107
188
  items: SwishDrawerMiniMenuItem[];
108
189
  }
109
190
  export interface SwishDrawerListDetailViewOptions {
@@ -120,4 +201,9 @@ export interface SwishDrawerOptions {
120
201
  navigation: SwishDrawerNavigationOptions;
121
202
  miniMenu: SwishDrawerMiniMenuOptions;
122
203
  listDetailView: SwishDrawerListDetailViewOptions;
204
+ emptyCallout: SwishDrawerEmptyCalloutOptions;
205
+ }
206
+ export interface SwishDrawerEmptyCalloutOptions {
207
+ enabled: boolean;
208
+ shoppingCalloutUrl: string;
123
209
  }