@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
package/dist/dom/dom-utils.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export interface CreateLocationObserverArgs {
|
|
|
11
11
|
fireOnInit?: boolean;
|
|
12
12
|
}
|
|
13
13
|
export declare function createLocationObserver({ onLocationChange, fireOnInit, }: CreateLocationObserverArgs): () => void;
|
|
14
|
+
export declare function findNearestElement(origin: HTMLElement, selector: string): HTMLElement | null;
|
|
14
15
|
export interface CreateHrefObserverArgs {
|
|
15
16
|
element: HTMLAnchorElement;
|
|
16
17
|
onHrefChange: (href: string) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type EventName = "cart-add" | "cart-update" | "cart-change" | "cart-clear" | "item-create" | "item-update" | "item-delete" | "item-lists-update" | "list-create" | "list-update" | "list-delete" | "notification-update" | "notification-delete" | "token-update";
|
|
1
|
+
export type EventName = "cart-add" | "cart-update" | "cart-change" | "cart-clear" | "item-create" | "item-update" | "item-delete" | "item-lists-update" | "list-create" | "list-update" | "list-delete" | "notification-update" | "notification-delete" | "auth-cache-clear" | "token-update";
|
|
2
2
|
export declare class EventBus {
|
|
3
3
|
private readonly eventBus;
|
|
4
4
|
subscribe(type: EventName | EventName[], callback: EventListenerOrEventListenerObject | null, options?: AddEventListenerOptions | boolean): () => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ItemDetail } from "@swishapp/api-client";
|
|
2
2
|
import * as v from "valibot";
|
|
3
|
-
import {
|
|
3
|
+
import type { Product, ProductVariant } from "../../types";
|
|
4
4
|
import { IntentHandler } from "../intent-handler";
|
|
5
5
|
import { IntentResponse, SuccessIntentResponse } from "../types";
|
|
6
6
|
export declare const EditItemListsIntentDataSchema: v.ObjectSchema<{
|
|
@@ -10,8 +10,8 @@ export interface EditItemListsIntentData extends EditItemListsIntentDataValidate
|
|
|
10
10
|
}
|
|
11
11
|
export type EditItemListsSuccessResponse = SuccessIntentResponse<{
|
|
12
12
|
item: ItemDetail;
|
|
13
|
-
product:
|
|
14
|
-
variant:
|
|
13
|
+
product: Product | null | undefined;
|
|
14
|
+
variant: ProductVariant | null | undefined;
|
|
15
15
|
}>;
|
|
16
16
|
export type EditItemListsIntentDataValidated = v.InferInput<typeof EditItemListsIntentDataSchema>;
|
|
17
17
|
export declare class EditItemListsHandler extends IntentHandler<"edit:item-lists" | "unsave:item"> {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Item } from "@swishapp/api-client";
|
|
2
2
|
import * as v from "valibot";
|
|
3
|
-
import {
|
|
3
|
+
import type { Product, ProductVariant } from "../../types";
|
|
4
4
|
import { IntentHandler } from "../intent-handler";
|
|
5
5
|
import { IntentResponse, SuccessIntentResponse } from "../types";
|
|
6
6
|
export declare const EditItemVariantIntentDataSchema: v.ObjectSchema<{
|
|
@@ -15,8 +15,8 @@ export interface EditItemVariantIntentData extends Omit<EditItemVariantIntentDat
|
|
|
15
15
|
export type EditItemVariantIntentDataValidated = v.InferInput<typeof EditItemVariantIntentDataSchema>;
|
|
16
16
|
export type EditItemVariantSuccessResponse = SuccessIntentResponse<{
|
|
17
17
|
item: Item;
|
|
18
|
-
product:
|
|
19
|
-
variant:
|
|
18
|
+
product: Product | null | undefined;
|
|
19
|
+
variant: ProductVariant | null | undefined;
|
|
20
20
|
}>;
|
|
21
21
|
export declare class EditItemVariantHandler extends IntentHandler<"edit:item-variant"> {
|
|
22
22
|
invoke(data: EditItemVariantIntentData): Promise<IntentResponse<"edit:item-variant">>;
|
package/dist/intents/handlers/{open-quick-buy-handler.d.ts → initiate-quick-buy-handler.d.ts}
RENAMED
|
@@ -2,12 +2,12 @@ import * as v from "valibot";
|
|
|
2
2
|
import { QuickBuySubmitData } from "../../swish";
|
|
3
3
|
import { IntentHandler } from "../intent-handler";
|
|
4
4
|
import { IntentResponse, SuccessIntentResponse } from "../types";
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const InitiateQuickBuyIntentDataSchema: v.ObjectSchema<{
|
|
6
6
|
readonly productId: 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.NumberSchema<undefined>]>;
|
|
7
7
|
readonly variantId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, string>]>, v.NumberSchema<undefined>], undefined>, v.TransformAction<any, number>, v.NumberSchema<undefined>]>, undefined>;
|
|
8
8
|
}, undefined>;
|
|
9
|
-
export type
|
|
10
|
-
export type
|
|
11
|
-
export declare class
|
|
12
|
-
invoke(data:
|
|
9
|
+
export type InitiateQuickBuyIntentData = v.InferInput<typeof InitiateQuickBuyIntentDataSchema>;
|
|
10
|
+
export type InitiateQuickBuySuccessResponse = SuccessIntentResponse<QuickBuySubmitData>;
|
|
11
|
+
export declare class InitiateQuickBuyHandler extends IntentHandler<"initiate:quick-buy"> {
|
|
12
|
+
invoke(data: InitiateQuickBuyIntentData): Promise<IntentResponse<"initiate:quick-buy">>;
|
|
13
13
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Item } from "@swishapp/api-client";
|
|
2
2
|
import * as v from "valibot";
|
|
3
|
-
import {
|
|
3
|
+
import type { Product, ProductVariant } from "../../types";
|
|
4
4
|
import { IntentHandler } from "../intent-handler";
|
|
5
5
|
import { IntentResponse, SuccessIntentResponse } from "../types";
|
|
6
6
|
export declare const SaveItemIntentDataSchema: v.ObjectSchema<{
|
|
@@ -16,8 +16,8 @@ export interface SaveItemIntentData extends Omit<SaveItemIntentDataValidated, "p
|
|
|
16
16
|
export type SaveItemIntentDataValidated = v.InferInput<typeof SaveItemIntentDataSchema>;
|
|
17
17
|
export type SaveItemSuccessResponse = SuccessIntentResponse<{
|
|
18
18
|
item: Item;
|
|
19
|
-
product:
|
|
20
|
-
variant:
|
|
19
|
+
product: Product | null | undefined;
|
|
20
|
+
variant: ProductVariant | null | undefined;
|
|
21
21
|
}>;
|
|
22
22
|
export declare class SaveItemHandler extends IntentHandler<"save:item"> {
|
|
23
23
|
invoke(data: SaveItemIntentData): Promise<IntentResponse<"save:item">>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IntentHandler } from "../intent-handler";
|
|
2
|
+
import { IntentResponse, SuccessIntentResponse } from "../types";
|
|
3
|
+
export type ViewHomeSuccessResponse = SuccessIntentResponse<void>;
|
|
4
|
+
export declare class ViewHomeHandler extends IntentHandler<"view:home"> {
|
|
5
|
+
invoke(data?: void): Promise<IntentResponse<"view:home">>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { IntentHandler } from "../intent-handler";
|
|
3
|
+
import { IntentResponse, SuccessIntentResponse } from "../types";
|
|
4
|
+
export declare const ViewListDetailPageMenuIntentDataSchema: v.ObjectSchema<{
|
|
5
|
+
readonly listId: v.StringSchema<undefined>;
|
|
6
|
+
}, undefined>;
|
|
7
|
+
export type ViewListDetailPageMenuIntentData = v.InferInput<typeof ViewListDetailPageMenuIntentDataSchema>;
|
|
8
|
+
export type ViewListDetailPageMenuSuccessResponse = SuccessIntentResponse<void>;
|
|
9
|
+
export declare class ViewListDetailPageMenuHandler extends IntentHandler<"view:list-detail-page-menu"> {
|
|
10
|
+
invoke(data: ViewListDetailPageMenuIntentData): Promise<IntentResponse<"view:list-detail-page-menu">>;
|
|
11
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import { IntentHandler } from "../intent-handler";
|
|
3
3
|
import { IntentResponse, SuccessIntentResponse } from "../types";
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const ViewListIntentDataSchema: v.ObjectSchema<{
|
|
5
5
|
readonly listId: v.StringSchema<undefined>;
|
|
6
6
|
readonly listType: v.OptionalSchema<v.PicklistSchema<NonNullable<"user" | "smart" | "shared" | undefined>[], undefined>, "user">;
|
|
7
7
|
}, undefined>;
|
|
8
|
-
export type
|
|
9
|
-
export type
|
|
10
|
-
export declare class
|
|
11
|
-
invoke(data:
|
|
8
|
+
export type ViewListIntentData = v.InferInput<typeof ViewListIntentDataSchema>;
|
|
9
|
+
export type ViewListSuccessResponse = SuccessIntentResponse<void>;
|
|
10
|
+
export declare class ViewListHandler extends IntentHandler<"view:list"> {
|
|
11
|
+
invoke(data: ViewListIntentData): Promise<IntentResponse<"view:list">>;
|
|
12
12
|
}
|
|
@@ -5,15 +5,15 @@ import { DeleteListSuccessResponse } from "./delete-list-handler";
|
|
|
5
5
|
import { EditListAccessSuccessResponse } from "./edit-list-access-handler";
|
|
6
6
|
import { EditListSuccessResponse } from "./edit-list-handler";
|
|
7
7
|
import { ShareListSuccessResponse } from "./share-list-handler";
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const ViewListMenuIntentDataSchema: v.ObjectSchema<{
|
|
9
9
|
readonly listId: v.StringSchema<undefined>;
|
|
10
10
|
}, undefined>;
|
|
11
|
-
export type
|
|
11
|
+
export type ViewListMenuIntentData = v.InferInput<typeof ViewListMenuIntentDataSchema>;
|
|
12
12
|
type AddItemsSuccessResponse = SuccessIntentResponse<{
|
|
13
13
|
listId: string;
|
|
14
14
|
}>;
|
|
15
|
-
export type
|
|
16
|
-
export declare class
|
|
17
|
-
invoke(data:
|
|
15
|
+
export type ViewListMenuSuccessResponse = EditListSuccessResponse | DeleteListSuccessResponse | EditListAccessSuccessResponse | AddItemsSuccessResponse | ShareListSuccessResponse;
|
|
16
|
+
export declare class ViewListMenuHandler extends IntentHandler<"view:list-menu" | "edit:list" | "delete:list" | "edit:list-access" | "initiate:share"> {
|
|
17
|
+
invoke(data: ViewListMenuIntentData): Promise<IntentResponse<"view:list-menu" | "edit:list" | "delete:list" | "edit:list-access" | "initiate:share">>;
|
|
18
18
|
}
|
|
19
19
|
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IntentHandler } from "../intent-handler";
|
|
2
|
+
import { IntentResponse, SuccessIntentResponse } from "../types";
|
|
3
|
+
export type ViewListsSuccessResponse = SuccessIntentResponse<void>;
|
|
4
|
+
export declare class ViewListsHandler extends IntentHandler<"view:lists"> {
|
|
5
|
+
invoke(data?: void): Promise<IntentResponse<"view:lists">>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IntentHandler } from "../intent-handler";
|
|
2
|
+
import { IntentResponse, SuccessIntentResponse } from "../types";
|
|
3
|
+
export type ViewNotificationsSuccessResponse = SuccessIntentResponse<void>;
|
|
4
|
+
export declare class ViewNotificationsHandler extends IntentHandler<"view:notifications"> {
|
|
5
|
+
invoke(data?: void): Promise<IntentResponse<"view:notifications">>;
|
|
6
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import { IntentHandler } from "../intent-handler";
|
|
3
3
|
import { IntentResponse, SuccessIntentResponse } from "../types";
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const ViewOrderIntentDataSchema: v.ObjectSchema<{
|
|
5
5
|
readonly orderId: 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.NumberSchema<undefined>]>;
|
|
6
6
|
}, undefined>;
|
|
7
|
-
export type
|
|
8
|
-
export type
|
|
9
|
-
export declare class
|
|
10
|
-
invoke(data:
|
|
7
|
+
export type ViewOrderIntentData = v.InferInput<typeof ViewOrderIntentDataSchema>;
|
|
8
|
+
export type ViewOrderSuccessResponse = SuccessIntentResponse<void>;
|
|
9
|
+
export declare class ViewOrderHandler extends IntentHandler<"view:order"> {
|
|
10
|
+
invoke(data: ViewOrderIntentData): Promise<IntentResponse<"view:order">>;
|
|
11
11
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { IntentHandler } from "../intent-handler";
|
|
3
|
+
import { IntentResponse, SuccessIntentResponse } from "../types";
|
|
4
|
+
export declare const ViewOrderMenuIntentDataSchema: v.ObjectSchema<{
|
|
5
|
+
readonly orderId: v.StringSchema<undefined>;
|
|
6
|
+
}, undefined>;
|
|
7
|
+
export type ViewOrderMenuIntentData = v.InferInput<typeof ViewOrderMenuIntentDataSchema>;
|
|
8
|
+
export type ViewOrderMenuSuccessResponse = SuccessIntentResponse<void>;
|
|
9
|
+
export declare class ViewOrderMenuHandler extends IntentHandler<"view:order-menu"> {
|
|
10
|
+
invoke(data: ViewOrderMenuIntentData): Promise<IntentResponse<"view:order-menu">>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IntentHandler } from "../intent-handler";
|
|
2
|
+
import { IntentResponse, SuccessIntentResponse } from "../types";
|
|
3
|
+
export type ViewOrdersSuccessResponse = SuccessIntentResponse<void>;
|
|
4
|
+
export declare class ViewOrdersHandler extends IntentHandler<"view:orders"> {
|
|
5
|
+
invoke(data?: void): Promise<IntentResponse<"view:orders">>;
|
|
6
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import { IntentHandler } from "../intent-handler";
|
|
3
3
|
import { IntentResponse, SuccessIntentResponse } from "../types";
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const ViewProductIntentDataSchema: v.ObjectSchema<{
|
|
5
5
|
readonly productId: 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.NumberSchema<undefined>]>;
|
|
6
6
|
readonly variantId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, string>]>, v.NumberSchema<undefined>], undefined>, v.TransformAction<any, number>, v.NumberSchema<undefined>]>, undefined>;
|
|
7
7
|
}, undefined>;
|
|
8
|
-
export type
|
|
9
|
-
export type
|
|
10
|
-
export declare class
|
|
11
|
-
invoke(data:
|
|
8
|
+
export type ViewProductIntentData = v.InferInput<typeof ViewProductIntentDataSchema>;
|
|
9
|
+
export type ViewProductSuccessResponse = SuccessIntentResponse<void>;
|
|
10
|
+
export declare class ViewProductHandler extends IntentHandler<"view:product"> {
|
|
11
|
+
invoke(data: ViewProductIntentData): Promise<IntentResponse<"view:product">>;
|
|
12
12
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IntentHandler } from "../intent-handler";
|
|
2
|
+
import { IntentResponse, SuccessIntentResponse } from "../types";
|
|
3
|
+
export type ViewProfileSuccessResponse = SuccessIntentResponse<void>;
|
|
4
|
+
export declare class ViewProfileHandler extends IntentHandler<"view:profile"> {
|
|
5
|
+
invoke(data?: void): Promise<IntentResponse<"view:profile">>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IntentHandler } from "../intent-handler";
|
|
2
|
+
import { IntentResponse, SuccessIntentResponse } from "../types";
|
|
3
|
+
export type ViewSavesSuccessResponse = SuccessIntentResponse<void>;
|
|
4
|
+
export declare class ViewSavesHandler extends IntentHandler<"view:saves"> {
|
|
5
|
+
invoke(data?: void): Promise<IntentResponse<"view:saves">>;
|
|
6
|
+
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { SwishApp } from "../swish";
|
|
2
2
|
import { SwishUi } from "../swish-ui/swish-ui";
|
|
3
|
+
import type { Product, ProductVariant } from "../types";
|
|
3
4
|
import { Intent, IntentActivity, IntentQueryWithParams, IntentResponse, IntentToData } from "./types";
|
|
4
5
|
export interface IntentOptions {
|
|
5
6
|
saveProduct: {
|
|
6
|
-
promptVariantIfMissing: boolean
|
|
7
|
+
promptVariantIfMissing: boolean | ((args: {
|
|
8
|
+
product: Product;
|
|
9
|
+
variant: ProductVariant | null | undefined;
|
|
10
|
+
}) => boolean);
|
|
7
11
|
promptVariantIfPresent: boolean;
|
|
12
|
+
saveBeforeVariantPrompt: boolean;
|
|
8
13
|
showFeedback: boolean;
|
|
9
14
|
};
|
|
10
15
|
unsaveProduct: {
|
|
@@ -16,6 +21,9 @@ export interface IntentOptions {
|
|
|
16
21
|
promptVariantChange: boolean;
|
|
17
22
|
showFeedback: boolean;
|
|
18
23
|
};
|
|
24
|
+
initiateQuickBuy: {
|
|
25
|
+
promptVariantIfPresent: boolean;
|
|
26
|
+
};
|
|
19
27
|
createCartLine: {
|
|
20
28
|
afterComplete?: (response: IntentResponse<"create:cart-line">) => void;
|
|
21
29
|
};
|
|
@@ -42,6 +50,13 @@ export declare class Intents {
|
|
|
42
50
|
intent: Intent;
|
|
43
51
|
data: Record<string, string>;
|
|
44
52
|
};
|
|
53
|
+
parseIntentFromUrl(url: URL): {
|
|
54
|
+
intent: Intent;
|
|
55
|
+
data: Record<string, string>;
|
|
56
|
+
} | null;
|
|
57
|
+
private mapParamNames;
|
|
58
|
+
private resolveIntentData;
|
|
59
|
+
private invokeFromParsed;
|
|
45
60
|
parseIntentFromHash(hash: string): Intent | null;
|
|
46
61
|
handleIntent<I extends Intent>(intent: I, data: IntentToData<I>): Promise<IntentResponse<I>>;
|
|
47
62
|
initIntentHooks(): void;
|
package/dist/intents/types.d.ts
CHANGED
|
@@ -6,20 +6,19 @@ import type { EditItemListsIntentData, EditItemListsSuccessResponse } from "./ha
|
|
|
6
6
|
import type { EditItemVariantIntentData, EditItemVariantSuccessResponse } from "./handlers/edit-item-variant-handler";
|
|
7
7
|
import type { EditListAccessIntentData, EditListAccessSuccessResponse } from "./handlers/edit-list-access-handler";
|
|
8
8
|
import type { EditListIntentData, EditListSuccessResponse } from "./handlers/edit-list-handler";
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
11
|
-
import {
|
|
12
|
-
import type {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import type {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import type {
|
|
21
|
-
import {
|
|
22
|
-
import type { OpenSignInIntentData, OpenSignInSuccessResponse } from "./handlers/open-sign-in-handler";
|
|
9
|
+
import type { ViewHomeSuccessResponse } from "./handlers/view-home-handler";
|
|
10
|
+
import type { ViewListDetailPageMenuIntentData, ViewListDetailPageMenuSuccessResponse } from "./handlers/view-list-detail-page-menu-handler";
|
|
11
|
+
import { ViewListIntentData, ViewListSuccessResponse } from "./handlers/view-list-handler";
|
|
12
|
+
import type { ViewListMenuIntentData, ViewListMenuSuccessResponse } from "./handlers/view-list-menu-handler";
|
|
13
|
+
import { ViewListsSuccessResponse } from "./handlers/view-lists-handler";
|
|
14
|
+
import { ViewNotificationsSuccessResponse } from "./handlers/view-notifications-handler";
|
|
15
|
+
import { ViewOrderIntentData, ViewOrderSuccessResponse } from "./handlers/view-order-handler";
|
|
16
|
+
import type { ViewOrderMenuIntentData, ViewOrderMenuSuccessResponse } from "./handlers/view-order-menu-handler";
|
|
17
|
+
import { ViewOrdersSuccessResponse } from "./handlers/view-orders-handler";
|
|
18
|
+
import { ViewProductIntentData, ViewProductSuccessResponse } from "./handlers/view-product-handler";
|
|
19
|
+
import { ViewProfileSuccessResponse } from "./handlers/view-profile-handler";
|
|
20
|
+
import type { InitiateQuickBuyIntentData, InitiateQuickBuySuccessResponse } from "./handlers/initiate-quick-buy-handler";
|
|
21
|
+
import { ViewSavesSuccessResponse } from "./handlers/view-saves-handler";
|
|
23
22
|
import type { InitiateSignInIntentData, InitiateSignInSuccessResponse } from "./handlers/initiate-sign-in-handler";
|
|
24
23
|
import type { SaveCartLineIntentData, SaveCartLineSuccessResponse } from "./handlers/save-cart-line-handler";
|
|
25
24
|
import type { SaveItemIntentData, SaveItemSuccessResponse } from "./handlers/save-item-handler";
|
|
@@ -27,9 +26,8 @@ import type { ShareListIntentData, ShareListSuccessResponse } from "./handlers/s
|
|
|
27
26
|
import { ToastIntentData, ToastSuccessResponse } from "./handlers/show-toast-handler";
|
|
28
27
|
import type { UnsaveItemIntentData, UnsaveItemSuccessResponse } from "./handlers/unsave-item-handler";
|
|
29
28
|
export type { CreateCartLineSuccessResponse, InitiateCheckoutSuccessResponse, CreateListSuccessResponse, DeleteListSuccessResponse, EditItemListsSuccessResponse, EditItemVariantSuccessResponse, EditListAccessSuccessResponse, EditListSuccessResponse, SaveCartLineSuccessResponse, SaveItemSuccessResponse, ShareListSuccessResponse, ToastSuccessResponse, UnsaveItemSuccessResponse, };
|
|
30
|
-
export type Intent = "create:cart-line" | "initiate:checkout" | "save:item" | "edit:item-variant" | "edit:item-lists" | "unsave:item" | "edit:list" | "edit:list-access" | "delete:list" | "create:list" | "initiate:share" | "
|
|
31
|
-
export type
|
|
32
|
-
export type IntentQueryWithParams = `${Intent},${IntentQueryParam}`;
|
|
29
|
+
export type Intent = "create:cart-line" | "initiate:checkout" | "save:item" | "edit:item-variant" | "edit:item-lists" | "unsave:item" | "edit:list" | "edit:list-access" | "delete:list" | "create:list" | "initiate:share" | "view:home" | "view:list" | "view:lists" | "view:orders" | "view:order" | "view:saves" | "view:notifications" | "view:profile" | "view:product" | "view:list-menu" | "view:order-menu" | "view:list-detail-page-menu" | "initiate:sign-in" | "initiate:quick-buy" | "save:cart-line" | "show:toast";
|
|
30
|
+
export type IntentQueryWithParams = `${Intent}?${string}`;
|
|
33
31
|
export type IntentResponse<I extends Intent = Intent> = ClosedIntentResponse<I> | ErrorIntentResponse<I> | IntentToSuccessResponse<I>;
|
|
34
32
|
export type IntentResponseEvent<I extends Intent = Intent> = CustomEvent<IntentResponse<I>>;
|
|
35
33
|
export interface IntentActivity<I extends Intent = Intent, D = IntentToData<I>> {
|
|
@@ -65,21 +63,20 @@ interface IntentDataMap {
|
|
|
65
63
|
"delete:list": DeleteListIntentData;
|
|
66
64
|
"create:list": CreateListIntentData;
|
|
67
65
|
"initiate:share": ShareListIntentData;
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
66
|
+
"view:home": void;
|
|
67
|
+
"view:list": ViewListIntentData;
|
|
68
|
+
"view:lists": void;
|
|
69
|
+
"view:orders": void;
|
|
70
|
+
"view:order": ViewOrderIntentData;
|
|
71
|
+
"view:saves": void;
|
|
72
|
+
"view:notifications": void;
|
|
73
|
+
"view:profile": void;
|
|
74
|
+
"view:product": ViewProductIntentData;
|
|
75
|
+
"view:list-menu": ViewListMenuIntentData;
|
|
76
|
+
"view:order-menu": ViewOrderMenuIntentData;
|
|
77
|
+
"view:list-detail-page-menu": ViewListDetailPageMenuIntentData;
|
|
80
78
|
"initiate:sign-in": InitiateSignInIntentData;
|
|
81
|
-
"
|
|
82
|
-
"open:quick-buy": OpenQuickBuyIntentData;
|
|
79
|
+
"initiate:quick-buy": InitiateQuickBuyIntentData;
|
|
83
80
|
"save:cart-line": SaveCartLineIntentData;
|
|
84
81
|
"show:toast": ToastIntentData;
|
|
85
82
|
}
|
|
@@ -95,21 +92,20 @@ interface IntentSuccessResponseMap {
|
|
|
95
92
|
"delete:list": DeleteListSuccessResponse;
|
|
96
93
|
"create:list": CreateListSuccessResponse;
|
|
97
94
|
"initiate:share": ShareListSuccessResponse;
|
|
98
|
-
"
|
|
99
|
-
"
|
|
100
|
-
"
|
|
101
|
-
"
|
|
102
|
-
"
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
"
|
|
107
|
-
"
|
|
108
|
-
"
|
|
109
|
-
"
|
|
95
|
+
"view:home": ViewHomeSuccessResponse;
|
|
96
|
+
"view:list": ViewListSuccessResponse;
|
|
97
|
+
"view:lists": ViewListsSuccessResponse;
|
|
98
|
+
"view:orders": ViewOrdersSuccessResponse;
|
|
99
|
+
"view:order": ViewOrderSuccessResponse;
|
|
100
|
+
"view:saves": ViewSavesSuccessResponse;
|
|
101
|
+
"view:notifications": ViewNotificationsSuccessResponse;
|
|
102
|
+
"view:profile": ViewProfileSuccessResponse;
|
|
103
|
+
"view:product": ViewProductSuccessResponse;
|
|
104
|
+
"view:list-menu": ViewListMenuSuccessResponse;
|
|
105
|
+
"view:order-menu": ViewOrderMenuSuccessResponse;
|
|
106
|
+
"view:list-detail-page-menu": ViewListDetailPageMenuSuccessResponse;
|
|
110
107
|
"initiate:sign-in": InitiateSignInSuccessResponse;
|
|
111
|
-
"
|
|
112
|
-
"open:quick-buy": OpenQuickBuySuccessResponse;
|
|
108
|
+
"initiate:quick-buy": InitiateQuickBuySuccessResponse;
|
|
113
109
|
"save:cart-line": SaveCartLineSuccessResponse;
|
|
114
110
|
"show:toast": ToastSuccessResponse;
|
|
115
111
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { LanguageCode as I18nLanguageCode } from "@swishapp/i18n";
|
|
2
2
|
import { IntentOptions } from "../intents/intents";
|
|
3
3
|
import { StorefrontApiOptions, SwishClientConfig } from "../swish";
|
|
4
|
-
import { StorefrontContext, SwishFeaturesOptions, SwishOptions, SwishProductsMetafieldOptions, SwishProductTransformOptions, SwishUiOptions } from "./types";
|
|
4
|
+
import { StorefrontContext, SwishAuthOptions, SwishFeaturesOptions, SwishOptions, SwishProductsMetafieldOptions, SwishProductTransformOptions, SwishUiOptions } from "./types";
|
|
5
5
|
export type SwishOptionsInput = {
|
|
6
6
|
storefrontApi: StorefrontApiOptions;
|
|
7
7
|
storefrontContext: StorefrontContext;
|
|
8
8
|
translations?: Record<I18nLanguageCode, Record<string, string>>;
|
|
9
|
+
auth?: Partial<SwishAuthOptions>;
|
|
9
10
|
swishApi?: SwishClientConfig & {
|
|
10
11
|
version: string;
|
|
11
12
|
};
|
package/dist/options/types.d.ts
CHANGED
|
@@ -3,7 +3,11 @@ import { IntentOptions } from "../intents/intents";
|
|
|
3
3
|
import { CountryCode, LanguageCode } from "../storefront-api/types/storefront.types";
|
|
4
4
|
import { Intent, StorefrontApiOptions, SwishClientConfig } from "../swish";
|
|
5
5
|
import type { Product, ProductVariant } from "../types";
|
|
6
|
+
export interface SwishAuthOptions {
|
|
7
|
+
tokenUrl: string;
|
|
8
|
+
}
|
|
6
9
|
export interface SwishOptions {
|
|
10
|
+
auth: SwishAuthOptions;
|
|
7
11
|
products: SwishProductsOptions;
|
|
8
12
|
translations?: Record<I18nLanguageCode, Record<string, string>>;
|
|
9
13
|
storefrontApi: StorefrontApiOptions;
|
|
@@ -80,8 +84,8 @@ export interface SwishUiDesignOptions {
|
|
|
80
84
|
headingColorRgb?: string;
|
|
81
85
|
primaryButtonBackgroundRgb?: string;
|
|
82
86
|
primaryButtonColorRgb?: string;
|
|
83
|
-
|
|
84
|
-
|
|
87
|
+
neutralButtonBackgroundRgb?: string;
|
|
88
|
+
neutralButtonColorRgb?: string;
|
|
85
89
|
dangerButtonColorRgb?: string;
|
|
86
90
|
statusDotBackgroundRgb?: string;
|
|
87
91
|
badgeBackgroundRgb?: string;
|
|
@@ -125,6 +129,8 @@ export interface SwishFeaturesOptions {
|
|
|
125
129
|
lists: boolean;
|
|
126
130
|
orders: boolean;
|
|
127
131
|
notifications: boolean;
|
|
132
|
+
recentlyViewed: boolean;
|
|
133
|
+
savedFromCart: boolean;
|
|
128
134
|
}
|
|
129
135
|
export interface StorefrontContext {
|
|
130
136
|
customer: {
|
|
@@ -148,6 +154,7 @@ export interface StorefrontContext {
|
|
|
148
154
|
};
|
|
149
155
|
}
|
|
150
156
|
export interface SwishComponentOptions {
|
|
157
|
+
productCard: SwishProductCardOptions;
|
|
151
158
|
productRow: SwishProductRowOptions;
|
|
152
159
|
productDetail: SwishProductDetailOptions;
|
|
153
160
|
variantSelect: SwishVariantSelectOptions;
|
|
@@ -157,6 +164,10 @@ export interface SwishComponentOptions {
|
|
|
157
164
|
buyButtons: SwishBuyButtonsOptions;
|
|
158
165
|
drawer: SwishDrawerOptions;
|
|
159
166
|
listDetailPage: SwishListDetailPageOptions;
|
|
167
|
+
listsSection: SwishListsSectionOptions;
|
|
168
|
+
}
|
|
169
|
+
export interface SwishProductCardOptions {
|
|
170
|
+
linkToProductPage: boolean;
|
|
160
171
|
}
|
|
161
172
|
export interface SwishListDetailPageOptions {
|
|
162
173
|
desktopColumns: number;
|
|
@@ -174,6 +185,7 @@ export interface SwishProductDetailOptions {
|
|
|
174
185
|
export type SwishVariantSelectDisplay = "pills" | "rows";
|
|
175
186
|
export interface SwishVariantSelectOptions {
|
|
176
187
|
displayType: SwishVariantSelectDisplay;
|
|
188
|
+
hideSingleValueOptions: boolean;
|
|
177
189
|
}
|
|
178
190
|
export interface SwishImageSliderOptions {
|
|
179
191
|
flush: boolean;
|
|
@@ -185,6 +197,10 @@ export interface SwishBuyButtonsOptions {
|
|
|
185
197
|
export interface SwishImageOptions {
|
|
186
198
|
baseTint: boolean;
|
|
187
199
|
}
|
|
200
|
+
export type SwishListsSectionDisplay = "list" | "slider";
|
|
201
|
+
export interface SwishListsSectionOptions {
|
|
202
|
+
displayType: SwishListsSectionDisplay;
|
|
203
|
+
}
|
|
188
204
|
export type SwishDrawerNavigationVariant = "floating" | "docked";
|
|
189
205
|
export interface SwishDrawerNavigationItem {
|
|
190
206
|
id: string;
|
|
@@ -195,6 +211,7 @@ export interface SwishDrawerNavigationOptions {
|
|
|
195
211
|
enabled: boolean;
|
|
196
212
|
variant: SwishDrawerNavigationVariant;
|
|
197
213
|
showIcons: boolean;
|
|
214
|
+
showText: boolean;
|
|
198
215
|
items: SwishDrawerNavigationItem[];
|
|
199
216
|
}
|
|
200
217
|
export interface SwishDrawerMiniMenuItem {
|
|
@@ -213,6 +230,22 @@ export interface SwishDrawerLogoOptions {
|
|
|
213
230
|
url: string;
|
|
214
231
|
altText: string;
|
|
215
232
|
}
|
|
233
|
+
export interface SwishDrawerContentBlockOptions {
|
|
234
|
+
title?: string;
|
|
235
|
+
body?: string;
|
|
236
|
+
image?: {
|
|
237
|
+
url: string;
|
|
238
|
+
width?: number;
|
|
239
|
+
height?: number;
|
|
240
|
+
};
|
|
241
|
+
link?: {
|
|
242
|
+
url: string;
|
|
243
|
+
target?: string;
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
export interface SwishDrawerHomeOptions {
|
|
247
|
+
contentBlock?: SwishDrawerContentBlockOptions;
|
|
248
|
+
}
|
|
216
249
|
export interface SwishDrawerOptions {
|
|
217
250
|
title: string;
|
|
218
251
|
logo: SwishDrawerLogoOptions;
|
|
@@ -220,6 +253,7 @@ export interface SwishDrawerOptions {
|
|
|
220
253
|
miniMenu: SwishDrawerMiniMenuOptions;
|
|
221
254
|
listDetailView: SwishDrawerListDetailViewOptions;
|
|
222
255
|
emptyCallout: SwishDrawerEmptyCalloutOptions;
|
|
256
|
+
home?: SwishDrawerHomeOptions;
|
|
223
257
|
}
|
|
224
258
|
export interface SwishDrawerEmptyCalloutOptions {
|
|
225
259
|
enabled: boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { EventBus } from "../events/event-bus";
|
|
2
|
+
import { swishItemsQueryKey } from "./keys";
|
|
3
|
+
export { getSwishQueryStorageKey } from "./storage-key";
|
|
4
|
+
export declare function createSwishQuery({ events, cacheBuster, customerId, storeDomain, }: {
|
|
5
|
+
events: EventBus;
|
|
6
|
+
cacheBuster: string;
|
|
7
|
+
customerId: string | null | undefined;
|
|
8
|
+
storeDomain: string | null | undefined;
|
|
9
|
+
}): {
|
|
10
|
+
client: import("@tanstack/query-core").QueryClient;
|
|
11
|
+
cacheBuster: string;
|
|
12
|
+
restored: import("@preact/signals-core").Signal<boolean>;
|
|
13
|
+
storageKey: string;
|
|
14
|
+
keys: {
|
|
15
|
+
items: typeof swishItemsQueryKey;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export type SwishQuery = ReturnType<typeof createSwishQuery>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type SwishQueryIdInput = string | number | null | undefined;
|
|
2
|
+
export type SwishItemsQueryPrefixKey = readonly ["swish", "items"];
|
|
3
|
+
export type SwishItemsProductQueryKey = readonly [
|
|
4
|
+
...SwishItemsQueryPrefixKey,
|
|
5
|
+
string
|
|
6
|
+
];
|
|
7
|
+
export type SwishItemsVariantQueryKey = readonly [
|
|
8
|
+
...SwishItemsProductQueryKey,
|
|
9
|
+
string
|
|
10
|
+
];
|
|
11
|
+
export type SwishItemsQueryKey = SwishItemsProductQueryKey | SwishItemsVariantQueryKey;
|
|
12
|
+
export declare function normalizeSwishQueryId(value: SwishQueryIdInput): string;
|
|
13
|
+
export declare function swishItemsQueryKey(args: {
|
|
14
|
+
productId: SwishQueryIdInput;
|
|
15
|
+
variantId?: SwishQueryIdInput;
|
|
16
|
+
}): SwishItemsQueryKey;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { QueryClient } from "@tanstack/query-core";
|
|
2
|
+
export declare function initSwishQueryPersistence({ queryClient, cacheBuster, customerId, storeDomain, maxAgeMs, throttleMs, }: {
|
|
3
|
+
queryClient: QueryClient;
|
|
4
|
+
cacheBuster: string;
|
|
5
|
+
customerId: string | null | undefined;
|
|
6
|
+
storeDomain: string | null | undefined;
|
|
7
|
+
maxAgeMs?: number;
|
|
8
|
+
throttleMs?: number;
|
|
9
|
+
}): {
|
|
10
|
+
restored: import("@preact/signals-core").Signal<boolean>;
|
|
11
|
+
storageKey: string;
|
|
12
|
+
dispose: () => void;
|
|
13
|
+
};
|
|
@@ -6,4 +6,4 @@ export interface ItemContext {
|
|
|
6
6
|
variantId?: string;
|
|
7
7
|
itemId?: string;
|
|
8
8
|
}
|
|
9
|
-
export declare const itemContextSignal: (swish: SwishApp) => (source
|
|
9
|
+
export declare const itemContextSignal: (swish: SwishApp) => (source: HTMLElement | Location) => import("@preact/signals-core").Signal<ItemContext>;
|